diff --git a/ci4/app/Controllers/Facturacion/Facturas.php b/ci4/app/Controllers/Facturacion/Facturas.php index 4980bd96..6b826498 100755 --- a/ci4/app/Controllers/Facturacion/Facturas.php +++ b/ci4/app/Controllers/Facturacion/Facturas.php @@ -143,6 +143,11 @@ class Facturas extends \App\Controllers\BaseResourceController helper('form'); + + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_facturas"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("Facturas.facturaList"), 'route' => route_to('facturasList'), 'active' => true] + ]; $this->viewData['usingSelect2'] = true; @@ -168,9 +173,15 @@ class Facturas extends \App\Controllers\BaseResourceController $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Facturas.factura')), $id]); return $this->redirect2listView('sweet-error', $message); endif; + $this->obtenerDatosFormulario($factura); + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_facturas"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("Facturas.facturaList"), 'route' => route_to('facturasList'), 'active' => true] + ]; + $this->viewData['facturaEntity'] = $factura; $this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Facturas.factura') . ' ' . lang('Basic.global.edit3'); @@ -355,14 +366,24 @@ class Facturas extends \App\Controllers\BaseResourceController 'pendiente' => $postData['pendiente'] ?? 0, 'total_pagos' => $postData['total_pagos'] ?? 0, 'user_updated_id' => auth()->user()->id, + 'estado_pago' => (intval($postData['pendiente'] ?? 0)==0) ? 'pagada' : 'pendiente', ]; + $newTokenHash = csrf_hash(); + $csrfTokenName = csrf_token(); + $data_ret = [ + $csrfTokenName => $newTokenHash + ]; + if($factura_id == 0){ - return; + return $this->respond($data_ret); } + $data_ret['estado_pago'] = $data['estado_pago']; $model = model('\App\Models\Facturas\FacturaModel'); $model->update($factura_id, $data); + + return $this->respond($data_ret); } else { return $this->failUnauthorized('Invalid request', 403); @@ -483,6 +504,10 @@ class Facturas extends \App\Controllers\BaseResourceController 'user_updated_id' => auth()->user()->id, ]; + if((strpos($numero, "REC ") === 0)){ + $data['estado_pago'] = 'pagada'; + } + $this->model->update($factura_id, $data); } diff --git a/ci4/app/Language/en/Facturas.php b/ci4/app/Language/en/Facturas.php index 801b96c5..48c60a51 100644 --- a/ci4/app/Language/en/Facturas.php +++ b/ci4/app/Language/en/Facturas.php @@ -22,6 +22,7 @@ return [ 'serieFacturacion' => 'Billing Series', 'creditoAsegurado' => 'Secured Credit', 'facturaRectificada' => 'Rectified Invoice', + 'facturaRectificativa' => 'Rectifying Invoice', 'razonSocial' => 'Business Name', 'cif' => 'Tax ID', 'direccion' => 'Address', @@ -70,6 +71,7 @@ return [ "fechaCobro" => "Collection Date", "cantidad" => "Quantity", "addPago" => "Add Payment", + "facturaPagada" => "Rectifying Invoice already paid", 'errors' => [ 'requiredFields' => 'Fields marked with * are required', diff --git a/ci4/app/Language/es/Facturas.php b/ci4/app/Language/es/Facturas.php index a4278db9..8c7e9d14 100644 --- a/ci4/app/Language/es/Facturas.php +++ b/ci4/app/Language/es/Facturas.php @@ -22,6 +22,7 @@ return [ 'serieFacturacion' => 'Serie facturación', 'creditoAsegurado' => 'Crédito asegurado', 'facturaRectificada' => 'Factura rectificada', + 'facturaRectificativa' => 'Factura rectificativa', 'razonSocial' => 'Razón Social', 'cif' => 'CIF', 'direccion' => 'Dirección', @@ -70,6 +71,7 @@ return [ "fechaCobro" => "Fecha Cobro", "cantidad" => "Cantidad", "addPago" => "Añadir Pago", + "facturaPagada" => "Factura rectificativa ya pagada", 'errors' => [ 'requiredFields' => 'Los campos marcados con * son obligatorios', diff --git a/ci4/app/Views/themes/vuexy/form/facturas/_facturaCabeceraItems.php b/ci4/app/Views/themes/vuexy/form/facturas/_facturaCabeceraItems.php index 6b172315..5072ba4e 100644 --- a/ci4/app/Views/themes/vuexy/form/facturas/_facturaCabeceraItems.php +++ b/ci4/app/Views/themes/vuexy/form/facturas/_facturaCabeceraItems.php @@ -11,7 +11,11 @@
-

;"> estado)?>

+

+ ;"> estado)?> + estado != 'borrador')? " / ":""?> + ;estado == 'borrador')? "display:none;":""?>"> estado_pago)?> +

@@ -86,7 +90,26 @@
-
+ serie_id == 7 || $facturaEntity->serie_id == 9): ?> +
+
+ + estado!='borrador')? "disabled":"" ?> id="facturaR" name="facturaR" tabindex="" maxLength="11" class="form-control" + value= + factura_retificada_id != null && $facturaEntity->factura_retificada_id != null): ?> + "" + factura_retificada_id) ?> + ?> + " + value="factura_retificada_id != null) ? old('factura_retificada_id', $facturaEntity->factura_retificada_id): old('numero', $facturaEntity->factura_retificativa_id)?>" + > +
+
+ +
px-4">
`; - } + } + else + { + return ``; + } if (data.pedido_id === null) { @@ -349,7 +353,7 @@ function updateFooterLineas(table){ $('#total-sum').html(totalTotal.toFixed(2)); // Assuming pendiente de pago is totalTotal - totalIVA for this example - estado != 'borrador') :?> + estado == 'borrador') :?> var pendientePago = totalTotal ; var total_pagos = 0; @@ -368,7 +372,14 @@ function updateFooterLineas(table){ pendiente: pendientePago } }).done((data, textStatus, jqXHR) => { - //console.log(data); + if(data.estado_pago == 'pagada'){ + $('#estado_pago_text').text(''); + $('#estado_pago_text').css('color', 'green'); + } + else{ + $('#estado_pago_text').text(''); + $('#estado_pago_text').css('color', 'red'); + } }).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 fa036223..c50b0bae 100644 --- a/ci4/app/Views/themes/vuexy/form/facturas/_pagosFacturasItems.php +++ b/ci4/app/Views/themes/vuexy/form/facturas/_pagosFacturasItems.php @@ -169,13 +169,18 @@ var tablePagos = $('#tableOfLineasPagos').DataTable({ { data: "fecha_vencimiento_at", render: function(data, type, row) { + if(data == null){ + return ''; + } return data!='0000-00-00 00:00:00' ? moment(data).format('DD/MM/YYYY') : ''; } }, { data: "fecha_pago_at", render: function(data, type, row) { - + if(data == null){ + return ''; + } return data!='0000-00-00 00:00:00' ? moment(data).format('DD/MM/YYYY') : ''; } }, @@ -300,6 +305,14 @@ function updateFooterLineas(table){ } else { $('#validarFactura').show(); } + if(data.estado_pago == 'pagada'){ + $('#estado_pago_text').text(''); + $('#estado_pago_text').css('color', 'green'); + } + else{ + $('#estado_pago_text').text(''); + $('#estado_pago_text').css('color', 'red'); + } }).fail((jqXHR, textStatus, errorThrown) => { popErrorAlert(jqXHR.responseJSON.messages.error) }) diff --git a/ci4/app/Views/themes/vuexy/form/facturas/viewFacturaForm.php b/ci4/app/Views/themes/vuexy/form/facturas/viewFacturaForm.php index 1af0c041..31283148 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') : ?> + estado !='borrador' && (strpos($facturaEntity->numero, "REC ") === 0) ) : ?> @@ -39,14 +39,14 @@ id="borrarFactura" name="borrarFactura" value="" - /> - " - /> + /> + " + /> "btn btn-secondary float-start"]) ?>