2011-11-14 17:40:41 +00:00
|
|
|
|
unit uEditorAsiento;
|
|
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
|
Dialogs, uEditorDBItem, ToolWin, ComCtrls, JvExControls, JvComponent,
|
|
|
|
|
|
uBizAsientos, JvNavigationPane, ActnList,
|
|
|
|
|
|
uEditorBase, StdActns, TB2Dock, TB2Toolbar, TBX, ImgList, PngImageList,
|
|
|
|
|
|
TB2Item, uEditorItem, DB, uDADataTable, uEditorDBBase, JvFormAutoSize,
|
|
|
|
|
|
uDAScriptingProvider, uDACDSDataTable, StdCtrls, pngimage, ExtCtrls,
|
|
|
|
|
|
TBXDkPanels, JvButton, AppEvnts, uCustomView, uViewBase,
|
|
|
|
|
|
JvAppStorage, JvAppRegistryStorage, JvFormPlacement, JvComponentBase,
|
|
|
|
|
|
|
|
|
|
|
|
uIEditorAsiento, uAsientosController, JvExComCtrls,
|
|
|
|
|
|
JvStatusBar, dxLayoutLookAndFeels, uDAInterfaces, uViewDetallesGenerico,
|
|
|
|
|
|
uViewApuntes, cxDropDownEdit, cxCalendar, cxDBEdit, dxLayoutControl,
|
|
|
|
|
|
cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxSpinEdit, cxControls, DBCtrls,
|
2011-12-26 17:20:38 +00:00
|
|
|
|
dxGDIPlusClasses, cxGraphics, cxCurrencyEdit;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
|
TfEditorAsiento = class(TfEditorDBItem, IEditorAsiento)
|
|
|
|
|
|
dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
|
|
|
|
|
|
dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
|
|
|
|
|
|
dxLayoutControl1Group_Root: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1: TdxLayoutControl;
|
|
|
|
|
|
lcOrden: TdxLayoutItem;
|
|
|
|
|
|
edtOrden: TcxDBSpinEdit;
|
|
|
|
|
|
dxLayoutControl1Item2: TdxLayoutItem;
|
|
|
|
|
|
edtFecha: TcxDBDateEdit;
|
|
|
|
|
|
dxLayoutControl1Group2: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1Group3: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl1Item1: TdxLayoutItem;
|
|
|
|
|
|
frViewApuntes1: TfrViewApuntes;
|
2011-12-26 17:20:38 +00:00
|
|
|
|
EntradaSalida: TTabSheet;
|
|
|
|
|
|
dxLayoutControl2: TdxLayoutControl;
|
|
|
|
|
|
dxLayoutGroup1: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl2Item1: TdxLayoutItem;
|
|
|
|
|
|
edtFecha2: TcxDBDateEdit;
|
|
|
|
|
|
Tipo: TcxComboBox;
|
|
|
|
|
|
dxLayoutControl2Item2: TdxLayoutItem;
|
|
|
|
|
|
eDescripcion: TcxTextEdit;
|
|
|
|
|
|
dxLayoutControl2Item3: TdxLayoutItem;
|
|
|
|
|
|
dxLayoutControl2Group1: TdxLayoutGroup;
|
|
|
|
|
|
dxLayoutControl2Item4: TdxLayoutItem;
|
|
|
|
|
|
eImporte: TcxCurrencyEdit;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
|
|
procedure dsDataTableDataChange(Sender: TObject; Field: TField);
|
|
|
|
|
|
procedure CustomEditorClose(Sender: TObject; var Action: TCloseAction);
|
|
|
|
|
|
protected
|
|
|
|
|
|
FController : IAsientosController;
|
|
|
|
|
|
FAsiento: IBizAsiento;
|
|
|
|
|
|
// FViewAsiento : IViewAsiento;
|
|
|
|
|
|
|
|
|
|
|
|
function GetController : IAsientosController;
|
|
|
|
|
|
procedure SetController (const Value : IAsientosController); virtual;
|
|
|
|
|
|
function GetAsiento: IBizAsiento; virtual;
|
|
|
|
|
|
procedure SetAsiento(const Value: IBizAsiento); virtual;
|
|
|
|
|
|
// function GetViewAsiento: IViewAsiento;
|
|
|
|
|
|
// procedure SetViewAsiento(const Value: IViewAsiento);
|
|
|
|
|
|
// property ViewAsiento: IViewAsiento read GetViewAsiento write SetViewAsiento;
|
|
|
|
|
|
|
|
|
|
|
|
procedure GuardarInterno; override;
|
|
|
|
|
|
procedure EliminarInterno; override;
|
|
|
|
|
|
|
|
|
|
|
|
procedure PonerTitulos(const ATitulo: string = ''); override;
|
|
|
|
|
|
|
|
|
|
|
|
//Si queremos crear otra vista para el editor heredado solo tendriamos que
|
|
|
|
|
|
//sobreescribir este metodo
|
|
|
|
|
|
// procedure AsignarVista; virtual;
|
|
|
|
|
|
|
|
|
|
|
|
public
|
|
|
|
|
|
property Asiento: IBizAsiento read GetAsiento write SetAsiento;
|
|
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
|
|
uses
|
2011-12-26 17:20:38 +00:00
|
|
|
|
uCustomEditor, uDataModuleBase, uFactuGES_App, schContabilidadClient_Intf;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
|
|
|
|
|
|
function ShowEditorAsiento (ABizObject : TDADataTableRules): TModalResult;
|
|
|
|
|
|
var
|
|
|
|
|
|
AEditor: TfEditorAsiento;
|
|
|
|
|
|
begin
|
|
|
|
|
|
AEditor := TfEditorAsiento.Create(Application);
|
|
|
|
|
|
try
|
|
|
|
|
|
AEditor.Asiento := (ABizObject as IBizAsiento);
|
|
|
|
|
|
Result := AEditor.ShowModal;
|
|
|
|
|
|
finally
|
|
|
|
|
|
AEditor.Release;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
******************************* TfEditorAsiento *******************************
|
|
|
|
|
|
}
|
|
|
|
|
|
function TfEditorAsiento.GetAsiento: IBizAsiento;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FAsiento;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TfEditorAsiento.GetController: IAsientosController;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
function TfEditorAsiento.GetViewAsiento: IViewAsiento;
|
|
|
|
|
|
begin
|
|
|
|
|
|
Result := FViewAsiento;
|
|
|
|
|
|
end;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAsiento.GuardarInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2011-12-26 17:20:38 +00:00
|
|
|
|
|
|
|
|
|
|
if Tipo.Text = 'Entrada' then
|
|
|
|
|
|
FController.AnadirApuntesEntrada(FAsiento, eDescripcion.Text, eImporte.Value)
|
|
|
|
|
|
else
|
|
|
|
|
|
FController.AnadirApuntesSalida(FAsiento, eDescripcion.Text, eImporte.Value);
|
|
|
|
|
|
|
2011-11-14 17:40:41 +00:00
|
|
|
|
FController.Guardar(FAsiento);
|
|
|
|
|
|
Modified := False;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAsiento.PonerTitulos(const ATitulo: string);
|
|
|
|
|
|
var
|
|
|
|
|
|
FTitulo : String;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if Assigned(Asiento) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
if Asiento.EsNuevo then
|
2011-12-28 12:11:00 +00:00
|
|
|
|
FTitulo := 'Nueva entrada/salida - ' + AppFactuGES.EmpresaActiva.NOMBRE // + ' - ' + AppFactuGES.EjercicioActivo.NOMBRE + ' (' + AppFactuGES.EjercicioActivo.ESTADO + ')'
|
2011-11-14 17:40:41 +00:00
|
|
|
|
else
|
2011-12-28 12:11:00 +00:00
|
|
|
|
FTitulo := 'Entrada/salida' + ' ' + IntToStr(Asiento.ORDEN) + ' - ' + AppFactuGES.EmpresaActiva.NOMBRE; // + ' - ' + AppFactuGES.EjercicioActivo.NOMBRE + ' (' + AppFactuGES.EjercicioActivo.ESTADO + ')';
|
2011-11-14 17:40:41 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
inherited PonerTitulos(FTitulo);
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAsiento.SetAsiento(const Value: IBizAsiento);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FAsiento := Value;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FAsiento) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
dsDataTable.DataTable := FAsiento.DataTable;
|
|
|
|
|
|
frViewApuntes1.Apuntes := FAsiento.Apuntes
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
begin
|
|
|
|
|
|
dsDataTable.DataTable := Nil;
|
|
|
|
|
|
frViewApuntes1.Apuntes := Nil;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
// if Assigned(FViewAsiento) and Assigned(Asiento) then
|
|
|
|
|
|
// FViewAsiento.Asiento := Asiento;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAsiento.SetController(const Value: IAsientosController);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FController := Value;
|
|
|
|
|
|
// if Assigned(ViewAsiento) then
|
|
|
|
|
|
// ViewAsiento.Controller := FController;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
procedure TfEditorAsiento.SetViewAsiento(const Value: IViewAsiento);
|
|
|
|
|
|
begin
|
|
|
|
|
|
FViewAsiento := Value;
|
|
|
|
|
|
|
|
|
|
|
|
if Assigned(FViewAsiento) and Assigned(Asiento) then
|
|
|
|
|
|
FViewAsiento.Asiento := Asiento;
|
|
|
|
|
|
end;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAsiento.FormShow(Sender: TObject);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
|
|
|
|
// if not Assigned(FViewAsiento) then
|
|
|
|
|
|
// raise Exception.Create('No hay ninguna vista asignada');
|
|
|
|
|
|
|
|
|
|
|
|
if not Assigned(Asiento) then
|
|
|
|
|
|
raise Exception.Create('No hay ning<6E>n asiento asignado');
|
|
|
|
|
|
|
|
|
|
|
|
Asiento.DataTable.Active := True;
|
2011-12-26 17:20:38 +00:00
|
|
|
|
if not Asiento.EsNuevo then
|
|
|
|
|
|
begin
|
|
|
|
|
|
Asiento.Apuntes.First;
|
|
|
|
|
|
eDescripcion.Text := Asiento.Apuntes.CONCEPTO;
|
|
|
|
|
|
if Asiento.Apuntes.DataTable.FieldByName(fld_ApuntesDEBE).IsNull then
|
|
|
|
|
|
begin
|
|
|
|
|
|
Tipo.ItemIndex := 1;
|
|
|
|
|
|
eImporte.Value := Asiento.Apuntes.HABER;
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
begin
|
|
|
|
|
|
Tipo.ItemIndex := 0;
|
|
|
|
|
|
eImporte.Value := Asiento.Apuntes.DEBE;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
|
|
|
|
|
|
//Al insertar el orden se asigna automaticamente en el servidor, luego se podr<64> modificar
|
2011-12-26 17:20:38 +00:00
|
|
|
|
{ if Asiento.EsNuevo then
|
2011-11-14 17:40:41 +00:00
|
|
|
|
lcOrden.Visible := False
|
|
|
|
|
|
else
|
|
|
|
|
|
lcOrden.Visible := True;
|
2011-12-26 17:20:38 +00:00
|
|
|
|
}
|
2011-11-14 17:40:41 +00:00
|
|
|
|
|
|
|
|
|
|
//En el caso de tener apuntes el asiento nos posicionaremos siempre el la columna concepto del ultimo apunte
|
2011-12-26 17:20:38 +00:00
|
|
|
|
// frViewApuntes1.GotoLast;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TfEditorAsiento.Destroy;
|
|
|
|
|
|
begin
|
|
|
|
|
|
// Utilizar mejor OnClose;
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
procedure TfEditorAsiento.AsignarVista;
|
|
|
|
|
|
var
|
|
|
|
|
|
AViewAsiento: TfrViewAsiento;
|
|
|
|
|
|
begin
|
|
|
|
|
|
AViewAsiento := TfrViewAsiento.create(Self);
|
|
|
|
|
|
with AViewAsiento do
|
|
|
|
|
|
begin
|
|
|
|
|
|
Parent := pagGeneral;
|
|
|
|
|
|
Align := alClient;
|
|
|
|
|
|
// dxLayoutControlAsiento.LookAndFeel := dxLayoutOfficeLookAndFeel1;
|
|
|
|
|
|
end;
|
|
|
|
|
|
ViewAsiento := AViewAsiento;
|
|
|
|
|
|
end;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
constructor TfEditorAsiento.Create(AOwner: TComponent);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
2011-12-26 17:20:38 +00:00
|
|
|
|
pgPaginas.ActivePageIndex := 1;
|
2011-11-14 17:40:41 +00:00
|
|
|
|
// AsignarVista;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAsiento.CustomEditorClose(Sender: TObject; var Action: TCloseAction);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
dsDataTable.DataTable := NIL;
|
|
|
|
|
|
// FViewAsiento := NIL;
|
|
|
|
|
|
FAsiento := NIL;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAsiento.dsDataTableDataChange(Sender: TObject; Field: TField);
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
{
|
|
|
|
|
|
if Assigned(FAsiento) and (not (FAsiento.DataTable.Fetching) or
|
|
|
|
|
|
not (FAsiento.DataTable.Opening) or not (FAsiento.DataTable.Closing)) then
|
|
|
|
|
|
PonerTitulos;
|
|
|
|
|
|
}
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TfEditorAsiento.EliminarInterno;
|
|
|
|
|
|
begin
|
|
|
|
|
|
if (Application.MessageBox('<27>Est<73> seguro que desea borrar este asiento?', 'Atenci<63>n', MB_YESNO) = IDYES) then
|
|
|
|
|
|
begin
|
|
|
|
|
|
inherited;
|
|
|
|
|
|
if not FController.Eliminar(FAsiento) then
|
|
|
|
|
|
actRefrescar.Execute;
|
|
|
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|
|
|
|
|
|
|