From 8912606c9a55ec0ae489d0a3ffaa334c80aee608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Sat, 12 Apr 2025 12:37:57 +0200 Subject: [PATCH] pagos en borrador --- ci4/app/Controllers/Facturacion/Facturas.php | 4 ++++ .../vuexy/form/facturas/_addPedidosItems.php | 1 + .../vuexy/form/facturas/_facturaLineasItems.php | 13 +++++-------- .../vuexy/form/facturas/_pagosFacturasItems.php | 14 +++++--------- .../themes/vuexy/form/facturas/viewFacturaForm.php | 5 ++++- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/ci4/app/Controllers/Facturacion/Facturas.php b/ci4/app/Controllers/Facturacion/Facturas.php index b9c445bc..195da7a5 100755 --- a/ci4/app/Controllers/Facturacion/Facturas.php +++ b/ci4/app/Controllers/Facturacion/Facturas.php @@ -230,6 +230,10 @@ class Facturas extends \App\Controllers\BaseResourceController $factura->updated_by = $userModel->getFullName($factura->user_updated_id); $factura->created_at_footer = $factura->created_at ? date(' H:i d/m/Y', strtotime($factura->created_at)) : ''; $factura->updated_at_footer = $factura->updated_at ? date(' H:i d/m/Y', strtotime($factura->updated_at)) : ''; + + $factura->showDeleteButton = model('App\Models\Facturas\FacturaPagoModel') + ->where('factura_id', $factura->id)->countAllResults() == 0; + $this->viewData['facturaEntity'] = $factura; $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Facturas.factura') . ' ' . lang('Basic.global.edit3'); diff --git a/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php b/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php index c2db9dba..a6f390aa 100644 --- a/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php +++ b/ci4/app/Views/themes/vuexy/form/facturas/_addPedidosItems.php @@ -121,6 +121,7 @@ $('#addNewPedidoImpresion').on('click', function(){ $('#pedidoImpresion').val(null).trigger('change'); // Se actualiza la tabla de lineas de factura $('#tableOfLineasFactura').DataTable().clearPipeline().draw(); + $('#tableOfLineasPagos').DataTable().clearPipeline().draw(); } }); }); diff --git a/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php b/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php index 5f3c7331..9cd3136e 100644 --- a/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php +++ b/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php @@ -455,14 +455,9 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({ autoNumericIVA.set(totalIVA); autoNumericTotal.set(totalTotal); - estado == 'borrador') :?> - var pendientePago = totalTotal; - var total_pagos = 0; - - var total_pagos = autoNumericTotalCobrado.getNumber(); - var pendientePago = totalTotal - total_pagos; - - + var total_pagos = autoNumericTotalCobrado.getNumber(); + var pendientePago = totalTotal - total_pagos; + if (isNaN(pendientePago)) pendientePago = 0; autoNumericPendientePago.set(pendientePago); @@ -522,6 +517,8 @@ function deleteConfirmedLinea(params){ : v } }).done((data, textStatus, jqXHR) => { + tablelineas.clearPipeline().footerCallback().draw(); + $('#tableOfLineasPagos').DataTable().clearPipeline().footerCallback().draw(); }).fail((jqXHR, textStatus, errorThrown) => { popErrorAlert(jqXHR.responseJSON.messages.error) diff --git a/ci4/app/Views/themes/vuexy/form/facturas/_pagosFacturasItems.php b/ci4/app/Views/themes/vuexy/form/facturas/_pagosFacturasItems.php index 78cbed7d..943f8e8d 100644 --- a/ci4/app/Views/themes/vuexy/form/facturas/_pagosFacturasItems.php +++ b/ci4/app/Views/themes/vuexy/form/facturas/_pagosFacturasItems.php @@ -185,6 +185,7 @@ editor_pagos.on( 'postSubmit', function ( e, json, data, action ) { yeniden(json.); tablePagos.clearPipeline(); tablePagos.draw(); + updateFooterLineas(tableLineas); }); const autoNumericTotalCobrado = new AutoNumeric('#totalCobrado-sum', 0, { @@ -340,13 +341,8 @@ var tablePagos = $('#tableOfLineasPagos').DataTable({ function updateFooterLineas(table){ // Assuming pendiente de pago is totalTotal - totalIVA for this example - estado == 'borrador') :?> - var pendientePago = autoNumericTotal.getNumber(); - var total_pagos = 0; - - var total_pagos = autoNumericTotalCobrado.getNumber(); - var pendientePago = autoNumericTotal.getNumber() - total_pagos; - + var total_pagos = autoNumericTotalCobrado.getNumber(); + var pendientePago = autoNumericTotal.getNumber() - total_pagos; // Se comprueba si pendientePago es un numero o NAN if(isNaN(pendientePago)){ pendientePago = 0; @@ -363,10 +359,10 @@ function updateFooterLineas(table){ pendiente: pendientePago } }).done((data, textStatus, jqXHR) => { - if($('#pendiente-pago').html() == '0.00'){ + if(autoNumericPendientePago.getNumber() == 0){ $('#addPagoRow').hide(); } else { - $('#validarFactura').show(); + $('#addPagoRow').show(); } if(data.estado_pago == 'pagada'){ $('#estado_pago_text').text(''); diff --git a/ci4/app/Views/themes/vuexy/form/facturas/viewFacturaForm.php b/ci4/app/Views/themes/vuexy/form/facturas/viewFacturaForm.php index 0736152a..23911b81 100644 --- a/ci4/app/Views/themes/vuexy/form/facturas/viewFacturaForm.php +++ b/ci4/app/Views/themes/vuexy/form/facturas/viewFacturaForm.php @@ -22,7 +22,7 @@ - estado !='borrador' && (strpos($facturaEntity->numero, "REC ") !== 0) ) : ?> + numero, "REC ") !== 0) ) : ?> estado !='borrador' && (strpos($facturaEntity->numero, "REC ") === 0) ) : ?> @@ -38,6 +38,9 @@ name="validarFactura" value="" /> + + + showDeleteButton == true && $facturaEntity->estado !='validada') : ?>