From f3f7fd5c166097bd0ba90150bf46241672ea8eb9 Mon Sep 17 00:00:00 2001 From: david Date: Mon, 15 Sep 2008 17:51:19 +0000 Subject: [PATCH] =?UTF-8?q?Ticket=20#110=20->=20En=20los=20presupuestos,?= =?UTF-8?q?=20al=20guardar=20uno,=20comprobar=20que=20todos=20los=20cap?= =?UTF-8?q?=C3=ADtulos=20tienen=20subtotales?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@590 0c75b7a4-871f-7646-8a2f-f78d34cc349f --- Source/Base/Base.dproj | 102 ++++++++--------- .../Controladores/uControllerDetallesBase.pas | 108 +++++++++++++++++- .../uPresupuestosClienteController.pas | 5 +- Source/Servidor/FactuGES_Server.RES | Bin 23216 -> 23208 bytes Source/Servidor/FactuGES_Server.rc | 2 +- 5 files changed, 159 insertions(+), 58 deletions(-) diff --git a/Source/Base/Base.dproj b/Source/Base/Base.dproj index e9bc58a4..aa2988cf 100644 --- a/Source/Base/Base.dproj +++ b/Source/Base/Base.dproj @@ -53,57 +53,57 @@ MainSource - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fConfigurarConexion
diff --git a/Source/Base/Controladores/uControllerDetallesBase.pas b/Source/Base/Controladores/uControllerDetallesBase.pas index 9568ee95..f1ae2f00 100644 --- a/Source/Base/Controladores/uControllerDetallesBase.pas +++ b/Source/Base/Controladores/uControllerDetallesBase.pas @@ -10,7 +10,7 @@ const TIPO_DETALLE_SUBTOTAL = 'Subtotal'; TIPO_DETALLE_SALTO = 'Salto'; TIPO_DETALLE_DESCUENTO = 'Descuento'; - + TIPO_DETALLE_OPCIONAL = 'Opcional'; CTE_DESC_SALTO = 'SALTO DE PAGINA >>'; type @@ -19,7 +19,7 @@ type IControllerDetallesBase = interface(ISujeto) ['{F0B0E714-EC0D-4B6B-98B1-76F72F70B735}'] - function getTipo(ADataTable: IDAStronglyTypedDataTable; pPosicion: Integer): String; + function GetTipo(ADataTable: IDAStronglyTypedDataTable; pPosicion: Integer): String; procedure Clear(ADataTable: IDAStronglyTypedDataTable); procedure Add(ADataTable: IDAStronglyTypedDataTable; TipoConcepto: Variant); procedure Delete(ADataTable: IDAStronglyTypedDataTable; Posicion: TIntegerArray); @@ -35,6 +35,7 @@ type function LocalizarPosicion(ADataTable: IDAStronglyTypedDataTable; const APosicion: Integer): Boolean; procedure Renumerar(DataTable: TDADataTable; LocalizaPosicion: Integer); function DarListaTiposDetalle: TStringList; + procedure ValidarCierreCapitulos(ADataTable: IDAStronglyTypedDataTable); end; TControllerDetallesBase = class (TSujeto, IControllerDetallesBase) @@ -63,6 +64,8 @@ type procedure CalculoDetalleSubtotal(DataTable: TDADataTable; var ImporteAcumulado : Double; var ImporteTotal : Double); virtual; procedure TratamientoDetalleDescuento(DataTable: TDADataTable); virtual; procedure CalculoDetalleDescuento(DataTable: TDADataTable; var ImporteAcumulado : Double; var ImporteTotal : Double); virtual; + procedure TratamientoDetalleOpcional(DataTable: TDADataTable); virtual; + procedure CalculoDetalleOpcional(DataTable: TDADataTable; var ImporteAcumulado : Double; var ImporteTotal : Double); virtual; //Si sobreescribimos este metodo es para continuar el CalcularTotales segun los tipos de concepto de los hijos function CalcularTotalesHijos(Modificar: boolean; DataTable: TDADataTable; var ImporteAcumulado : Double; var ImporteTotal : Double): Double; virtual; @@ -71,7 +74,7 @@ type constructor Create; override; destructor Destroy; override; - function getTipo(ADataTable: IDAStronglyTypedDataTable; pPosicion: Integer): String; + function GetTipo(ADataTable: IDAStronglyTypedDataTable; pPosicion: Integer): String; procedure Clear(ADataTable: IDAStronglyTypedDataTable); procedure Add(ADataTable: IDAStronglyTypedDataTable; TipoConcepto: Variant); virtual; procedure Delete(ADataTable: IDAStronglyTypedDataTable; Posicion: TIntegerArray); virtual; @@ -86,6 +89,9 @@ type function DarTotalImporteTotal(ADataTable: IDAStronglyTypedDataTable): Double; function DarListaTiposDetalle: TStringList; virtual; function LocalizarPosicion(ADataTable: IDAStronglyTypedDataTable; const APosicion: Integer): Boolean; + + // Comprueba que todos los capitulos tengan su subtotal de cierre + procedure ValidarCierreCapitulos(ADataTable: IDAStronglyTypedDataTable); end; @@ -203,6 +209,13 @@ begin TratamientoDetalleConcepto(DataTable); //Se podrá sobreescribir para que se tengan en cuenta nuevos campos CalculoDetalleConcepto(DataTable, AuxImporteAcumulado, AuxImporteTotal); //Se podrá sobreescribir para posibles nuevos calculos de los hijos end + //OPCIONALES + else if (DataTable.FieldByName(CAMPO_TIPO).AsString = TIPO_DETALLE_OPCIONAL) then + begin + if Modificar then + TratamientoDetalleOpcional(DataTable); //Se podrá sobreescribir para que se tengan en cuenta nuevos campos en hijos + CalculoDetalleOpcional(DataTable, AuxImporteAcumulado, AuxImporteTotal); //Se podrá sobreescribir para posibles nuevos calculos de los hijos + end //HIJOS else CalcularTotalesHijos(Modificar, DataTable, AuxImporteAcumulado, AuxImporteTotal); @@ -243,12 +256,18 @@ begin begin if not Editing then Edit; ImporteDto := (-1)*((ImporteTotal * DataTable.FieldByName(CAMPO_DESCUENTO).AsFloat) / 100); - ImporteTotal := ImporteTotal + ImporteDto; + ImporteTotal := ImporteTotal + ImporteDto; FieldByName(CAMPO_IMPORTE_TOTAL).AsFloat := ImporteTotal; Post; end; end; +procedure TControllerDetallesBase.CalculoDetalleOpcional( + DataTable: TDADataTable; var ImporteAcumulado, ImporteTotal: Double); +begin + // No acumular ni sumar nada. +end; + procedure TControllerDetallesBase.CalculoDetalleSalto(DataTable: TDADataTable; var ImporteAcumulado, ImporteTotal: Double); begin with DataTable do @@ -291,6 +310,7 @@ function TControllerDetallesBase.DarListaTiposDetalle: TStringList; begin Result := TStringList.Create; Result.Values[TIPO_DETALLE_CONCEPTO] := TIPO_DETALLE_CONCEPTO; + Result.Values[TIPO_DETALLE_OPCIONAL] := TIPO_DETALLE_OPCIONAL; Result.Values[TIPO_DETALLE_TITULO] := TIPO_DETALLE_TITULO; Result.Values[TIPO_DETALLE_SUBTOTAL] := TIPO_DETALLE_SUBTOTAL; //Result.Values[TIPO_DETALLE_DESCUENTO] := TIPO_DETALLE_DESCUENTO; @@ -589,6 +609,22 @@ begin end; end; +procedure TControllerDetallesBase.TratamientoDetalleOpcional( + DataTable: TDADataTable); +begin + with DataTable do + begin + if not Editing then Edit; + //Si alguno de los campos de calculo de total es nulo el total tambien será nulo + if (VarIsNull(FieldByName(CAMPO_CANTIDAD).AsVariant) or + VarIsNull(FieldByName(CAMPO_IMPORTE_UNIDAD).AsVariant)) then + FieldByName(CAMPO_IMPORTE_TOTAL).AsVariant := Null + else + FieldByName(CAMPO_IMPORTE_TOTAL).AsFloat := CalcularImporteTotalConcepto(DataTable); + Post; + end; +end; + procedure TControllerDetallesBase.TratamientoDetalleSalto(DataTable: TDADataTable); begin with DataTable do @@ -629,7 +665,7 @@ begin end; end; -procedure TControllerDetallesBase.validarCampos(DataTable: TDADataTable); +procedure TControllerDetallesBase.ValidarCampos(DataTable: TDADataTable); var AField: TDAField; begin @@ -651,4 +687,66 @@ begin raise Exception.Create('Campo ' + CAMPO_IMPORTE_TOTAL + ' no encontrado (validarCampos)'); end; +procedure TControllerDetallesBase.ValidarCierreCapitulos( + ADataTable: IDAStronglyTypedDataTable); +var + ATipoCampo : String; + bEnCapitulo : Boolean; + AuxPosicionIni : Integer; + AuxPosicion : Integer; +begin + bEnCapitulo := False; + ATipoCampo := ''; + + if (ADataTable.DataTable.State in dsEditModes) then + ADataTable.DataTable.Post; + + ValidarCampos(ADataTable.DataTable); + + AuxPosicionIni := ADataTable.DataTable.FieldByName(CAMPO_POSICION).AsInteger; + AuxPosicion := 0; + + BeginUpdate(ADataTable); + try + ADataTable.DataTable.First; + while ADataTable.DataTable.Locate(CAMPO_POSICION, AuxPosicion, []) do + begin + ATipoCampo := ADataTable.DataTable.FieldByName(CAMPO_TIPO).AsString; + + if (ATipoCampo = TIPO_DETALLE_SUBTOTAL) and bEnCapitulo then + bEnCapitulo := False; + + if (ATipoCampo = TIPO_DETALLE_TITULO) then + begin + if bEnCapitulo then + begin + ADataTable.DataTable.First; + if ADataTable.DataTable.Locate(CAMPO_POSICION, AuxPosicion-1, []) then + begin + Add(ADataTable, TIPO_DETALLE_SUBTOTAL); + bEnCapitulo := False; + end; + end + else + bEnCapitulo := True; + end; + + Inc(AuxPosicion); + ADataTable.DataTable.First; + end; + + // ¿Se ha acabado la tabla y queda algún capítulo sin cerrar? + if bEnCapitulo then + if ADataTable.DataTable.Locate(CAMPO_POSICION, AuxPosicion-1, []) then + begin + Add(ADataTable, TIPO_DETALLE_SUBTOTAL); + bEnCapitulo := False; + end; + finally + //Dejamos el puntero en la misma posición que la que partió + ADataTable.DataTable.Locate(CAMPO_POSICION, AuxPosicionIni, []); + EndUpdate(ADataTable); + end; +end; + end. diff --git a/Source/Modulos/Presupuestos de cliente/Controller/uPresupuestosClienteController.pas b/Source/Modulos/Presupuestos de cliente/Controller/uPresupuestosClienteController.pas index af0263b7..f0bd6e40 100644 --- a/Source/Modulos/Presupuestos de cliente/Controller/uPresupuestosClienteController.pas +++ b/Source/Modulos/Presupuestos de cliente/Controller/uPresupuestosClienteController.pas @@ -452,7 +452,10 @@ begin if (APresupuesto.Detalles.DataTable.RecordCount = 0) then raise Exception.Create('El presupuesto debe tener en su contenido al menos un concepto'); - + + + FDetallesController.ValidarCierreCapitulos(APresupuesto.Detalles); + { Asegurarse de valores en campos "automáticos" tanto en MODIFICACIÓN como en INSERCIÓN. } APresupuesto.Edit; diff --git a/Source/Servidor/FactuGES_Server.RES b/Source/Servidor/FactuGES_Server.RES index 456769717f3cf09d03f4de5d51353a67ec45c442..e3b4701a13cce611c0cee1294b8422c6ef3b1b00 100644 GIT binary patch delta 75 zcmdn6m2t&Z#tnBO7}rd`8zB!Q|3*YJ@=T75RAziJxi+$zIfp@Q^6yAl!5oHChCGH; ehGGUC1_cH~2GhxgQHJd13|0&V3?`E^quc>7gBQ90 delta 83 zcmZ3nm2m?Q-HBk_GWl+VJdpew5zQzvIWkh2@x$cW$ZF;i2Cd1zBV{FX88R7OG88c+ jGvqVmFr+dRGw3iVFc>lzOxBDtWVc|jVlV)*6QkS#6oMJ{ diff --git a/Source/Servidor/FactuGES_Server.rc b/Source/Servidor/FactuGES_Server.rc index b72791a3..ee464bf2 100644 --- a/Source/Servidor/FactuGES_Server.rc +++ b/Source/Servidor/FactuGES_Server.rc @@ -14,7 +14,7 @@ BEGIN BEGIN VALUE "FileVersion", "1.3.1.0\0" VALUE "ProductVersion", "1.3.1.0\0" - VALUE "CompileDate", "miércoles, 10 de septiembre de 2008 18:00\0" + VALUE "CompileDate", "lunes, 15 de septiembre de 2008 17:04\0" END END BLOCK "VarFileInfo"