diff --git a/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas b/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas index e2bec2fc..f001cd4d 100644 --- a/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas +++ b/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas @@ -119,10 +119,10 @@ type implementation uses - Windows, uNumUtils, Controls, cxControls, DB, uEditorRegistryUtils, schFacturasClienteClient_Intf, + Windows, uDateUtils, uNumUtils, Controls, cxControls, DB, uEditorRegistryUtils, schFacturasClienteClient_Intf, uBizContactos, uIEditorFacturasCliente, uIEditorFacturaCliente, uFactuGES_App, uDataModuleFacturasCliente, uBizDetallesFacturaCliente, uControllerDetallesBase, - uDataModuleUsuarios, uDAInterfaces, uDataTableUtils, uDateUtils, + uDataModuleUsuarios, uDAInterfaces, uDataTableUtils, uAlbaranesClienteController, schAlbaranesClienteClient_Intf, uROTypes, uDetallesAlbaranClienteController, uBizDetallesAlbaranCliente, uFacturasClienteReportController, // uBizPedidosCliente, uPedidosClienteController, uBizDetallesPedidoCliente, @@ -656,7 +656,8 @@ begin //De esta forma obligaremos siempre a tener un recibo asociado a la factura, //porque si la forma de pago no tiene plazos es obligatorio la fecha de vencimiento - with TFormasPagoController.Create do + //OJO-----En facturas de cliente para acana no es obligatorio porque deben de poder generar facturas sin recibos asociados +{ with TFormasPagoController.Create do begin try AFormaPago := Buscar(AFactura.ID_FORMA_PAGO); @@ -669,6 +670,7 @@ begin Free; end; end; +} if (AFactura.IGNORAR_CONTABILIDAD = 0) and ((AFactura.Cliente.SubCuentas.ID < 1) //REPASAR @@ -1159,56 +1161,66 @@ begin //Se cambia la lógica a peticion de acana, en el caso de meter una fecha de vencimiento, //los plazos de la forma de pago no tendrán efecto, se generará un recibo con el 100% y fecha de vencimiento - //de la factura. + //de la factura. (Se permitirá para acana poder dar de alta facturas sin recibos asociados) With AFormaPago.Plazos.DataTable do begin i := 1; First; repeat - ARecibos := ARecibosClienteController.Nuevo; - ARecibos.Edit; - ARecibos.ID_FACTURA := AFactura.ID; - ARecibos.ID_EMPRESA := AFactura.ID_EMPRESA; - ARecibos.ID_CLIENTE := AFactura.ID_CLIENTE; - ARecibos.ID_TIENDA := AFactura.ID_TIENDA; - ARecibos.REFERENCIA := AFactura.REFERENCIA + ' - ' + IntToStr(i); - ARecibos.NOMBRE := AFactura.NOMBRE; //Es la razon social de la factura - ARecibos.CALLE := AFactura.CALLE; - ARecibos.NIF_CIF := AFactura.NIF_CIF; - ARecibos.POBLACION := AFactura.POBLACION; - ARecibos.PROVINCIA := AFactura.PROVINCIA; - ARecibos.CODIGO_POSTAL := AFactura.CODIGO_POSTAL; - ARecibos.FECHA_EMISION := AFactura.FECHA_FACTURA; - - if AFormaPago.Plazos.RecordCount < 1 then + //SOLO PARA ACANA (Leer comentario anterior + if (AFormaPago.Plazos.RecordCount > 0) + or (AFactura.FECHA_VENCIMIENTO <> 0) then begin + ARecibos := ARecibosClienteController.Nuevo; + ARecibos.Edit; + ARecibos.ID_FACTURA := AFactura.ID; + ARecibos.ID_EMPRESA := AFactura.ID_EMPRESA; + ARecibos.ID_CLIENTE := AFactura.ID_CLIENTE; + ARecibos.ID_TIENDA := AFactura.ID_TIENDA; + ARecibos.REFERENCIA := AFactura.REFERENCIA + ' - ' + IntToStr(i); + ARecibos.NOMBRE := AFactura.NOMBRE; //Es la razon social de la factura + ARecibos.CALLE := AFactura.CALLE; + ARecibos.NIF_CIF := AFactura.NIF_CIF; + ARecibos.POBLACION := AFactura.POBLACION; + ARecibos.PROVINCIA := AFactura.PROVINCIA; + ARecibos.CODIGO_POSTAL := AFactura.CODIGO_POSTAL; + ARecibos.FECHA_EMISION := AFactura.FECHA_FACTURA; + + if AFormaPago.Plazos.RecordCount < 1 then + begin ARecibos.FECHA_VENCIMIENTO := AFactura.FECHA_VENCIMIENTO; ARecibos.IMPORTE := AFactura.IMPORTE_TOTAL; - end - else - begin - AFechaVencimiento := AFactura.FECHA_FACTURA + AFormaPago.Plazos.NUM_DIAS; - ADiasMas := 0; - if (AFactura.Cliente.VENCIMIENTO_FACTURAS <> 0) then + end + else begin - ADiaVencimiento := DayOf(AFechaVencimiento); - while (ADiaVencimiento <> AFactura.Cliente.VENCIMIENTO_FACTURAS) do - begin - if ADiaVencimiento = DaysInMonth(AFechaVencimiento) then - ADiaVencimiento := 1 - else - Inc(ADiaVencimiento); - Inc(ADiasMas); - end; + AFechaVencimiento := AFactura.FECHA_FACTURA + AFormaPago.Plazos.NUM_DIAS; + ADiasMas := 0; + if (AFactura.Cliente.VENCIMIENTO_FACTURAS_1 <> 0) + or (AFactura.Cliente.VENCIMIENTO_FACTURAS_2 <> 0) + or (AFactura.Cliente.VENCIMIENTO_FACTURAS_3 <> 0) then + begin + ADiaVencimiento := DayOf(AFechaVencimiento); + while (ADiaVencimiento <> AFactura.Cliente.VENCIMIENTO_FACTURAS_1) + and (ADiaVencimiento <> AFactura.Cliente.VENCIMIENTO_FACTURAS_2) + and (ADiaVencimiento <> AFactura.Cliente.VENCIMIENTO_FACTURAS_3) do + begin + if ADiaVencimiento = DaysInMonth(AFechaVencimiento) then + ADiaVencimiento := 1 + else + Inc(ADiaVencimiento); + Inc(ADiasMas); + end; + end; + + AFechaVencimiento := IncDay(AFechaVencimiento, ADiasMas); + ARecibos.FECHA_VENCIMIENTO := AFechaVencimiento; + ARecibos.IMPORTE := AFactura.IMPORTE_TOTAL * (AFormaPago.Plazos.PORCENTAJE / 100); end; - AFechaVencimiento := IncDay(AFechaVencimiento, ADiasMas); - ARecibos.FECHA_VENCIMIENTO := AFechaVencimiento; - ARecibos.IMPORTE := AFactura.IMPORTE_TOTAL * (AFormaPago.Plazos.PORCENTAJE / 100); + ARecibos.DESCRIPCION := 'RECIBO ' + ARecibos.REFERENCIA + ' - ' + CifraToLetras(ARecibos.IMPORTE); + ARecibosClienteController.Guardar(ARecibos); end; - ARecibos.DESCRIPCION := 'RECIBO ' + ARecibos.REFERENCIA + ' - ' + CifraToLetras(ARecibos.IMPORTE); - ARecibosClienteController.Guardar(ARecibos); Inc(i); Next; until (eof);