diff --git a/Build/Build.fbl5 b/Build/Build.fbl5 index 00ef9147..b4ca78bc 100644 Binary files a/Build/Build.fbl5 and b/Build/Build.fbl5 differ diff --git a/Database/scripts/SCRIPT_CONTABILIDAD.SQL b/Database/scripts/SCRIPT_CONTABILIDAD.SQL index 510e2cb1..eab22f1a 100644 --- a/Database/scripts/SCRIPT_CONTABILIDAD.SQL +++ b/Database/scripts/SCRIPT_CONTABILIDAD.SQL @@ -67,21 +67,26 @@ CREATE TABLE CONT_SUBCUENTAS ( ALTER TABLE CONT_SUBCUENTAS ADD CONSTRAINT PK_CONT_SUBCUENTAS PRIMARY KEY (ID); - CREATE TABLE CONT_ASIENTOS ( ID TIPO_ID NOT NULL /* TIPO_ID = INTEGER */, - ID_ASIENTO_COMPENSADO TIPO_ID, - ID_SUBCUENTA TIPO_ID, - FECHA_ASIENTO date, - CONCEPTO VARCHAR(255), - PUNTEADO SMALLINT, - DEBE TIPO_IMPORTE, - HABER TIPO_IMPORTE + FECHA_ASIENTO DATE, + ORDEN INTEGER ); - ALTER TABLE CONT_ASIENTOS ADD CONSTRAINT PK_CONT_ASIENTOS PRIMARY KEY (ID); +CREATE TABLE CONT_APUNTES ( + ID TIPO_ID NOT NULL /* TIPO_ID = INTEGER */, + ID_ASIENTO TIPO_ID /* TIPO_ID = INTEGER */, + ID_SUBCUENTA TIPO_ID /* TIPO_ID = INTEGER */, + CONCEPTO VARCHAR(255), + PUNTEADO SMALLINT, + DEBE TIPO_IMPORTE /* TIPO_IMPORTE = NUMERIC(11,2) */, + HABER TIPO_IMPORTE /* TIPO_IMPORTE = NUMERIC(11,2) */, + ID_FACTURA TIPO_ID /* TIPO_ID = INTEGER */, + ID_RECIBO TIPO_ID /* TIPO_ID = INTEGER */ +); +ALTER TABLE CONT_APUNTES ADD CONSTRAINT PK_CONT_APUNTES PRIMARY KEY (ID); CREATE VIEW V_CONT_EPIGRAFES( ID, @@ -117,4 +122,41 @@ from CONT_CUENTAS left join CONT_EPIGRAFES on (CONT_EPIGRAFES.ID = CONT_CUENTAS.ID_EPIGRAFE) left join CONT_BALANCES on (CONT_BALANCES.ID = CONT_CUENTAS.ID_BALANCE) left join CONT_CUENTAS_ESPECIALES on (CONT_CUENTAS_ESPECIALES.ID = CONT_CUENTAS.ID_CUENTA_ESPECIAL) +; + + + +DROP VIEW V_CONT_SUBCUENTAS; +DROP VIEW V_CONT_SUBCUENTAS_SALDO; + +CREATE VIEW V_CONT_SUBCUENTAS_SALDO( + ID_SUBCUENTA, + DEBE, + HABER, + SALDO) +AS +select cont_subcuentas.ID, COALESCE(SUM(cont_apuntes.DEBE), 0) as DEBE, +COALESCE(SUM(cont_apuntes.HABER), 0) as HABER, +COALESCE(SUM(cont_apuntes.DEBE), 0) - COALESCE(SUM(cont_apuntes.HABER), 0) as SALDO +from cont_subcuentas +left join cont_apuntes on (cont_apuntes.id_subcuenta = cont_subcuentas.ID) +group by cont_subcuentas.ID +; + +CREATE VIEW V_CONT_SUBCUENTAS( + ID, + REF_SUBCUENTA, + DESCRIPCION, + ID_EJERCICIO, + ID_CUENTA, + CUENTA, + DEBE, + HABER, + SALDO) +AS +select CONT_SUBCUENTAS.ID, CONT_SUBCUENTAS.REF_SUBCUENTA, CONT_SUBCUENTAS.DESCRIPCION, CONT_SUBCUENTAS.ID_EJERCICIO, +CONT_SUBCUENTAS.ID_CUENTA, CONT_CUENTAS.DESCRIPCION as CUENTA, V_CONT_SUBCUENTAS_SALDO.DEBE, V_CONT_SUBCUENTAS_SALDO.HABER, V_CONT_SUBCUENTAS_SALDO.SALDO +from V_CONT_SUBCUENTAS_SALDO +left join CONT_SUBCUENTAS on (CONT_SUBCUENTAS.ID = V_CONT_SUBCUENTAS_SALDO.ID_SUBCUENTA) +left join CONT_CUENTAS on (CONT_CUENTAS.ID = CONT_SUBCUENTAS.ID_CUENTA) ; \ No newline at end of file diff --git a/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.dpk b/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.dpk index a0025261..5bdc9771 100644 --- a/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.dpk +++ b/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.dpk @@ -70,6 +70,7 @@ contains uIEditorSubCuentas in 'View\uIEditorSubCuentas.pas', uIEditorElegirEpigrafes in 'View\uIEditorElegirEpigrafes.pas', uIEditorElegirBalances in 'View\uIEditorElegirBalances.pas', - uIEditorElegirCuentasEspeciales in 'View\uIEditorElegirCuentasEspeciales.pas'; + uIEditorElegirCuentasEspeciales in 'View\uIEditorElegirCuentasEspeciales.pas', + uIEditorElegirCuentas in 'View\uIEditorElegirCuentas.pas'; end. diff --git a/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.dproj b/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.dproj index f36ed798..0c9a30eb 100644 --- a/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.dproj +++ b/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.dproj @@ -80,6 +80,7 @@ + diff --git a/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.res b/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.res index 8b251f31..1641339f 100644 Binary files a/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.res and b/Source/Modulos/Contabilidad/Controller/Contabilidad_controller.res differ diff --git a/Source/Modulos/Contabilidad/Controller/View/uIEditorElegirCuentas.pas b/Source/Modulos/Contabilidad/Controller/View/uIEditorElegirCuentas.pas new file mode 100644 index 00000000..88c0f365 --- /dev/null +++ b/Source/Modulos/Contabilidad/Controller/View/uIEditorElegirCuentas.pas @@ -0,0 +1,26 @@ +unit uIEditorElegirCuentas; + +interface + +uses + uIEditorCuentas, uBizCuentas, uGUIBase; + +type + IEditorElegirCuentas = interface(IEditorCuentas) + ['{BE99D9F2-F1BC-40BF-8E41-D0E320CE3BE5}'] + function GetCuentasSeleccionados: IBizCuenta; + property CuentasSeleccionados: IBizCuenta read GetCuentasSeleccionados; + + procedure SetMultiSelect (AValue : Boolean); + function GetMultiSelect : Boolean; + property MultiSelect : Boolean read GetMultiSelect write SetMultiSelect; + + procedure SetMensaje (const AValue: String); + function GetMensaje: String; + property Mensaje : String read GetMensaje write SetMensaje; + end; + + +implementation + +end. diff --git a/Source/Modulos/Contabilidad/Controller/uAsientosController.pas b/Source/Modulos/Contabilidad/Controller/uAsientosController.pas index 40b87dd5..baecbde9 100644 --- a/Source/Modulos/Contabilidad/Controller/uAsientosController.pas +++ b/Source/Modulos/Contabilidad/Controller/uAsientosController.pas @@ -14,11 +14,9 @@ type procedure VerTodos(AAsientos: IBizAsiento); procedure Ver(AAsiento: IBizAsiento); procedure Anadir(AAsiento : IBizAsiento); - function Eliminar(AAsiento : IBizAsiento): Boolean; + function Eliminar(AAsiento : IBizAsiento): Boolean; function Guardar(AAsiento : IBizAsiento): Boolean; procedure DescartarCambios(AAsiento : IBizAsiento); - function Localizar(AAsientos: IBizAsiento; ADescripcion:String): Boolean; - function DarListaAsientos: TStringList; end; TAsientosController = class(TObservador, IAsientosController) @@ -44,8 +42,6 @@ type function Buscar(ID: Integer): IBizAsiento; procedure VerTodos(AAsientos: IBizAsiento); procedure Ver(AAsiento: IBizAsiento); - function Localizar(AAsientos: IBizAsiento; ADescripcion:String): Boolean; - function DarListaAsientos: TStringList; end; implementation @@ -109,28 +105,6 @@ begin Result := Supports(EditorRegistry.CreateEditor(AName), IID, Intf); end; -function TAsientosController.DarListaAsientos: TStringList; -var - AAsientos: IBizAsiento; -begin - AAsientos := BuscarTodos; - AAsientos.DataTable.Active := True; - Result := TStringList.Create; - try - with Result do - begin - AAsientos.DataTable.First; - while not AAsientos.DataTable.EOF do - begin - Add(AAsientos.CONCEPTO); - AAsientos.DataTable.Next; - end; - end; - finally - AAsientos := NIL; - end; -end; - procedure TAsientosController.DescartarCambios(AAsiento: IBizAsiento); begin if not Assigned(AAsiento) then @@ -163,8 +137,8 @@ begin if (AAsiento.DataTable.State in dsEditModes) then AAsiento.DataTable.Post; - if Length(AAsiento.CONCEPTO) = 0 then - raise Exception.Create('Debe indicar un concepto para este Asiento.'); +// if Length(AAsiento.CONCEPTO) = 0 then +// raise Exception.Create('Debe indicar un concepto para este Asiento.'); Result := True; end; @@ -276,22 +250,4 @@ begin end; end; -function TAsientosController.Localizar(AAsientos: IBizAsiento; ADescripcion: String): Boolean; -begin - Result := True; - ShowHourglassCursor; - try - with AAsientos.DataTable do - begin - DisableControls; - First; - if not Locate(fld_AsientosCONCEPTO, ADescripcion, []) then - Result := False; - EnableControls; - end; - finally - HideHourglassCursor; - end; -end; - end. diff --git a/Source/Modulos/Contabilidad/Controller/uCuentasController.pas b/Source/Modulos/Contabilidad/Controller/uCuentasController.pas index 4a579cf4..c5ce176b 100644 --- a/Source/Modulos/Contabilidad/Controller/uCuentasController.pas +++ b/Source/Modulos/Contabilidad/Controller/uCuentasController.pas @@ -20,6 +20,9 @@ type function Localizar(ACuentas: IBizCuenta; ADescripcion:String): Boolean; function DarListaCuentas: TStringList; + function ExtraerSeleccionados(ACuentas: IBizCuenta) : IBizCuenta; + function ElegirCuenta(ACuentas : IBizCuenta; AMensaje: String; AMultiSelect: Boolean): IBizCuenta; + procedure ElegirEpigrafe(ACuenta: IBizCuenta); procedure ElegirBalance(ACuenta: IBizCuenta); procedure ElegirCuentaEspecial(ACuenta: IBizCuenta); @@ -51,6 +54,9 @@ type function Localizar(ACuentas: IBizCuenta; ADescripcion:String): Boolean; function DarListaCuentas: TStringList; + function ExtraerSeleccionados(ACuentas: IBizCuenta) : IBizCuenta; + function ElegirCuenta(ACuentas : IBizCuenta; AMensaje: String; AMultiSelect: Boolean): IBizCuenta; + procedure ElegirEpigrafe(ACuenta: IBizCuenta); procedure ElegirBalance(ACuenta: IBizCuenta); procedure ElegirCuentaEspecial(ACuenta: IBizCuenta); @@ -60,7 +66,7 @@ implementation uses cxControls, DB, uEditorRegistryUtils, schContabilidadClient_Intf, - uIEditorCuentas, uIEditorCuenta, uDataModuleContabilidad, + uIEditorCuentas, uIEditorCuenta, uIEditorElegirCuentas, uDataModuleContabilidad, uDAInterfaces, uDataTableUtils, uDialogUtils, uFactuGES_App, uDateUtils, uROTypes, DateUtils, Controls, Windows, uBizEpigrafes, uEpigrafesController, @@ -251,6 +257,29 @@ begin end; end; +function TCuentasController.ElegirCuenta(ACuentas: IBizCuenta; + AMensaje: String; AMultiSelect: Boolean): IBizCuenta; +var + AEditor : IEditorElegirCuentas; +begin + Result := NIL; + + CreateEditor('EditorElegirCuentas', IEditorElegirCuentas, AEditor); + try + with AEditor do + begin + Cuentas := ACuentas; + Controller := Self; + Mensaje := AMensaje; + if IsPositiveResult(ShowModal) then + Result := CuentasSeleccionados; + Release; + end; + finally + AEditor := NIL; + end; +end; + procedure TCuentasController.ElegirCuentaEspecial(ACuenta: IBizCuenta); var ACuentaEspecial : IBizCuentaEspecial; @@ -328,6 +357,15 @@ begin end; end; +function TCuentasController.ExtraerSeleccionados(ACuentas: IBizCuenta): IBizCuenta; +var + ASeleccionados : IBizCuenta; +begin + ASeleccionados := Self.Buscar(ID_NULO); + CopyDataTableDA3(ACuentas.DataTable, ASeleccionados.DataTable, True); + Result := ASeleccionados; +end; + procedure TCuentasController.FiltrarEjercicio(ACuenta: IBizCuenta); var Condicion: TDAWhereExpression; diff --git a/Source/Modulos/Contabilidad/Controller/uCuentasEspecialesController.pas b/Source/Modulos/Contabilidad/Controller/uCuentasEspecialesController.pas index 9c395b34..536f8f8c 100644 --- a/Source/Modulos/Contabilidad/Controller/uCuentasEspecialesController.pas +++ b/Source/Modulos/Contabilidad/Controller/uCuentasEspecialesController.pas @@ -224,7 +224,7 @@ var begin Result := NIL; - CreateEditor('EditorElegirBalances', IEditorElegirCuentasEspeciales, AEditor); + CreateEditor('EditorElegirCuentasEspeciales', IEditorElegirCuentasEspeciales, AEditor); try with AEditor do begin diff --git a/Source/Modulos/Contabilidad/Controller/uSubCuentasController.pas b/Source/Modulos/Contabilidad/Controller/uSubCuentasController.pas index 04cc7bc0..76f2ce08 100644 --- a/Source/Modulos/Contabilidad/Controller/uSubCuentasController.pas +++ b/Source/Modulos/Contabilidad/Controller/uSubCuentasController.pas @@ -19,6 +19,8 @@ type procedure DescartarCambios(ASubCuenta : IBizSubCuenta); function Localizar(ASubCuentas: IBizSubCuenta; ADescripcion:String): Boolean; function DarListaSubCuentas: TStringList; + + procedure ElegirCuenta(ASubCuenta: IBizSubCuenta); end; TSubCuentasController = class(TObservador, ISubCuentasController) @@ -46,6 +48,8 @@ type procedure Ver(ASubCuenta: IBizSubCuenta); function Localizar(ASubCuentas: IBizSubCuenta; ADescripcion:String): Boolean; function DarListaSubCuentas: TStringList; + + procedure ElegirCuenta(ASubCuenta: IBizSubCuenta); end; implementation @@ -53,6 +57,7 @@ implementation uses cxControls, DB, uEditorRegistryUtils, schContabilidadClient_Intf, uIEditorSubCuentas, uIEditorSubCuenta, uDataModuleContabilidad, + uBizCuentas, uCuentasController, uDAInterfaces, uDataTableUtils, uDialogUtils, uFactuGES_App, uDateUtils, uROTypes, DateUtils, Controls, Windows; @@ -212,6 +217,34 @@ begin end; end; +procedure TSubCuentasController.ElegirCuenta(ASubCuenta: IBizSubCuenta); +var + ACuenta : IBizCuenta; + AController : ICuentasController; +begin + inherited; + try + AController := TCuentasController.Create; + ACuenta := (AController.ElegirCuenta(AController.BuscarTodos, 'ddddddd', False) as IBizCuenta); + + if Assigned(ACuenta) then + begin + if Assigned(ASubCuenta) then + begin + if not ASubCuenta.DataTable.Editing then + ASubCuenta.DataTable.Edit; + + ASubCuenta.ID_CUENTA := ACuenta.ID; + ASubCuenta.CUENTA := ACuenta.DESCRIPCION; + ASubCuenta.Post; + end; + end; + finally + AController := Nil; + ACuenta := Nil; + end; +end; + function TSubCuentasController.Eliminar(ASubCuenta: IBizSubCuenta): Boolean; begin Result := False; diff --git a/Source/Modulos/Contabilidad/Data/Contabilidad_data.dpk b/Source/Modulos/Contabilidad/Data/Contabilidad_data.dpk index 6344f8d5..692a3dc3 100644 --- a/Source/Modulos/Contabilidad/Data/Contabilidad_data.dpk +++ b/Source/Modulos/Contabilidad/Data/Contabilidad_data.dpk @@ -42,6 +42,6 @@ requires dxThemeD10; contains - uDataModuleContabilidad in 'uDataModuleContabilidad.pas'; + uDataModuleContabilidad in 'uDataModuleContabilidad.pas' {DataModuleContabilidad: TDataModule}; end. diff --git a/Source/Modulos/Contabilidad/Data/Contabilidad_data.dproj b/Source/Modulos/Contabilidad/Data/Contabilidad_data.dproj index f14c8243..ab9571de 100644 --- a/Source/Modulos/Contabilidad/Data/Contabilidad_data.dproj +++ b/Source/Modulos/Contabilidad/Data/Contabilidad_data.dproj @@ -48,21 +48,24 @@ MainSource - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
DataModuleContabilidad
+ TDAClientDataModule +