From ecdea708afe236ae14f3f75ddf82a1aea3e1ce64 Mon Sep 17 00:00:00 2001 From: roberto Date: Sun, 24 Feb 2008 15:15:34 +0000 Subject: [PATCH] =?UTF-8?q?poArreglo=20de=20recibos=20para=20que=20funcion?= =?UTF-8?q?en=20de=20forma=20aut=C3=B3noma=20sin=20necesidad=20de=20Factur?= =?UTF-8?q?as=20de=20(Segunda=20parte)?= 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.Acana_FactuGES2/trunk@139 f4e31baf-9722-1c47-927c-6f952f962d4b --- Database/scripts/factuges.sql | 2 +- .../Controller/uRecibosClienteController.pas | 60 ++++++++++++------- .../Model/uBizRecibosCliente.pas | 6 +- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/Database/scripts/factuges.sql b/Database/scripts/factuges.sql index 47195c96..7d912e77 100644 --- a/Database/scripts/factuges.sql +++ b/Database/scripts/factuges.sql @@ -3355,7 +3355,7 @@ SELECT RECIBOS_CLIENTE.ID, COALESCE(RECIBOS_CLIENTE.IMPORTE, 0) + COALESCE(RECIBOS_CLIENTE.OTROS_GASTOS, 0) + COALESCE(V_REC_CLI_COMPENSADOS.IMPORTE_TOTAL_COMPENSADO, 0), FACTURAS_CLIENTE.FECHA_FACTURA, FORMAS_PAGO.DESCRIPCION, FACTURAS_CLIENTE.IMPORTE_TOTAL, - FACTURAS_CLIENTE.ID_EMPRESA, + RECIBOS_CLIENTE.ID_EMPRESA, CONTACTOS.ID as ID_CLIENTE, CONTACTOS.NOMBRE, CONTACTOS.NIF_CIF, CONTACTOS_DATOS_BANCO.ENTIDAD, CONTACTOS_DATOS_BANCO.SUCURSAL, CONTACTOS_DATOS_BANCO.DC, CONTACTOS_DATOS_BANCO.CUENTA, diff --git a/Source/Modulos/Recibos de cliente/Controller/uRecibosClienteController.pas b/Source/Modulos/Recibos de cliente/Controller/uRecibosClienteController.pas index acd69d50..c69c8283 100644 --- a/Source/Modulos/Recibos de cliente/Controller/uRecibosClienteController.pas +++ b/Source/Modulos/Recibos de cliente/Controller/uRecibosClienteController.pas @@ -714,36 +714,52 @@ var begin Result := False; - ANuevoReciboCliente := NIL; - ImporteRestante := 0; - - if ValidarReciboCliente(ARecibosCliente) then + if ARecibosCliente.EsNuevo then begin + if ValidarReciboCliente(ARecibosCliente) then + begin ShowHourglassCursor; try - //Si el importe ha cambiado se debe hacer un recibo nuevo con el importe restante - if ImporteTotalModificado(ARecibosCliente, ImporteRestante) then - begin - ANuevoReciboCliente := Duplicar(ARecibosCliente); - ANuevoReciboCliente.Edit; - ANuevoReciboCliente.REFERENCIA := DarNuevaReferencia(ARecibosCliente.ID_FACTURA, ARecibosCliente.REFERENCIA); - ANuevoReciboCliente.IMPORTE := ImporteRestante; - ANuevoReciboCliente.DESCRIPCION := 'RECIBO ' + ANuevoReciboCliente.REFERENCIA + ' - ' + CifraToLetras(ImporteRestante); - ANuevoReciboCliente.Post; - end; - - //Primero debemos hacer el ApplyUpdates del recibo inicial por si fallase - //Así no se haría el nuevo ARecibosCliente.DataTable.ApplyUpdates; - - if Assigned(ANuevoReciboCliente) then - ANuevoReciboCliente.DataTable.ApplyUpdates; - Result := True; finally - ANuevoReciboCliente := NIL; HideHourglassCursor; end; + end; + end + else + begin + ANuevoReciboCliente := NIL; + ImporteRestante := 0; + + if ValidarReciboCliente(ARecibosCliente) then + begin + ShowHourglassCursor; + try + //Si el importe ha cambiado se debe hacer un recibo nuevo con el importe restante + if ImporteTotalModificado(ARecibosCliente, ImporteRestante) then + begin + ANuevoReciboCliente := Duplicar(ARecibosCliente); + ANuevoReciboCliente.Edit; + ANuevoReciboCliente.REFERENCIA := DarNuevaReferencia(ARecibosCliente.ID_FACTURA, ARecibosCliente.REFERENCIA); + ANuevoReciboCliente.IMPORTE := ImporteRestante; + ANuevoReciboCliente.DESCRIPCION := 'RECIBO ' + ANuevoReciboCliente.REFERENCIA + ' - ' + CifraToLetras(ImporteRestante); + ANuevoReciboCliente.Post; + end; + + //Primero debemos hacer el ApplyUpdates del recibo inicial por si fallase + //Así no se haría el nuevo + ARecibosCliente.DataTable.ApplyUpdates; + + if Assigned(ANuevoReciboCliente) then + ANuevoReciboCliente.DataTable.ApplyUpdates; + + Result := True; + finally + ANuevoReciboCliente := NIL; + HideHourglassCursor; + end; + end; end; end; diff --git a/Source/Modulos/Recibos de cliente/Model/uBizRecibosCliente.pas b/Source/Modulos/Recibos de cliente/Model/uBizRecibosCliente.pas index 0aa6167e..fe2aef48 100644 --- a/Source/Modulos/Recibos de cliente/Model/uBizRecibosCliente.pas +++ b/Source/Modulos/Recibos de cliente/Model/uBizRecibosCliente.pas @@ -109,7 +109,7 @@ implementation { TBizRecibosCliente } uses - SysUtils, uDataTableUtils, schContactosClient_Intf; + SysUtils, uDataTableUtils, schContactosClient_Intf, uFactuGES_App, uBizEmpresasTiendas; function TBizRecibosCliente.GetCliente: IBizCliente; begin @@ -200,6 +200,10 @@ begin FECHA_EMISION := Date; IMPORTE := 0; OTROS_GASTOS := 0; + ID_EMPRESA := AppFactuGES.EmpresaActiva.ID; + USUARIO := AppFactuGES.UsuarioActivo.UserName; + ID_TIENDA := CTE_ID_TODAS; +// TIENDA := CTE_TODAS; end; procedure TBizRecibosCliente.OnNewRecord(Sender: TDADataTable);