diff --git a/ci4/app/Controllers/Facturacion/Facturas.php b/ci4/app/Controllers/Facturacion/Facturas.php
index ea45c3c7..7d6cf687 100755
--- a/ci4/app/Controllers/Facturacion/Facturas.php
+++ b/ci4/app/Controllers/Facturacion/Facturas.php
@@ -833,9 +833,18 @@ class Facturas extends \App\Controllers\BaseResourceController
if ((strpos($numero, "REC ") === 0)) {
$data['estado_pago'] = 'pagada';
+
}
$this->model->update($factura_id, $data);
+
+ if ((strpos($numero, "REC ") === 0)) {
+
+ $this->model->where('numero', $factura->factura_rectificada_id)->set([
+ 'factura_rectificativa_id' => $numero,
+ 'user_updated_id' => auth()->user()->id,
+ ])->update();
+ }
}
diff --git a/ci4/app/Controllers/Facturacion/FacturasLineas.php b/ci4/app/Controllers/Facturacion/FacturasLineas.php
index 0c12c403..386aa70b 100755
--- a/ci4/app/Controllers/Facturacion/FacturasLineas.php
+++ b/ci4/app/Controllers/Facturacion/FacturasLineas.php
@@ -92,7 +92,7 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
Field::inst('id'),
Field::inst('base'),
Field::inst('total_iva'),
- Field::inst('total'),
+ Field::inst('total')->set(Field::SET_BOTH),
Field::inst('cantidad')
->validator(
'Validate::numeric',
@@ -126,19 +126,6 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
'message' => lang('Facturas.validation.requerido')
)
),
- Field::inst('total')
- ->validator(
- 'Validate::numeric',
- array(
- 'message' => lang('Facturas.validation.numerico')
- )
- )
- ->validator(
- 'Validate::notEmpty',
- array(
- 'message' => lang('Facturas.validation.requerido')
- )
- ),
Field::inst('pedido_linea_impresion_id')
->setFormatter(function ($val, $data, $opts) {
return $val === '' ? null : $val;
@@ -157,7 +144,7 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
$values['total'],
$values['iva'],
$values['cantidad'],
- $values['old_cantidad'],
+ $values['old_cantidad'],
$values['base']
);
$editor
@@ -183,7 +170,7 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
$values['total'],
$values['iva'],
$values['cantidad'],
- $values['old_cantidad'],
+ $values['old_cantidad'],
$values['base']
);
$editor
@@ -256,14 +243,13 @@ class FacturasLineas extends \App\Controllers\BaseResourceController
$values['base'] = $base;
$values['total_iva'] = $total_iva;
$values['total'] = $total;
- }
- else{
+ } else {
// se pasa la base y el iva
$total_iva = round($base_input * $iva / 100, 2);
$total = round($base_input + $total_iva, 2);
-
+
$values = [];
- $values['base'] = $base_input;
+ $values['base'] = (float) $base_input;
$values['total_iva'] = $total_iva;
$values['total'] = $total;
diff --git a/ci4/app/Views/themes/vuexy/form/facturas/_facturaCabeceraItems.php b/ci4/app/Views/themes/vuexy/form/facturas/_facturaCabeceraItems.php
index 2abd8168..6f58ad99 100755
--- a/ci4/app/Views/themes/vuexy/form/facturas/_facturaCabeceraItems.php
+++ b/ci4/app/Views/themes/vuexy/form/facturas/_facturaCabeceraItems.php
@@ -96,13 +96,12 @@
-
serie_id == 7 || $facturaEntity->serie_id == 9 || $facturaEntity->factura_rectificada_id != null) ? "":"style='display:none;'" ?> class="col-md-12 col-lg-2 px-4 factura-R">
+
serie_id == 7 || $facturaEntity->serie_id == 9 || $facturaEntity->factura_rectificativa_id != null) ? "":"style='display:none;'" ?> class="col-md-12 col-lg-2 px-4 factura-R">
- estado!='borrador')? "disabled":"" ?> id="facturaR" name="= ($facturaEntity->factura_rectificada_id != null) ? 'factura_rectificada_id' : 'factura_rectificativa_id' ?>" tabindex="" maxLength="25" class="form-control update-cabecera factura-R"
-
+ estado!='borrador')? "disabled":"" ?> id="facturaR" name="= ($facturaEntity->serie_id == 7 || $facturaEntity->serie_id == 9) ? 'factura_rectificada_id' : 'factura_rectificativa_id' ?>" tabindex="" maxLength="25" class="form-control update-cabecera factura-R"
factura_rectificada_id == null && $facturaEntity->factura_rectificativa_id == null): ?>
value=""
diff --git a/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php b/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php
index 013753d8..4898bb8b 100755
--- a/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php
+++ b/ci4/app/Views/themes/vuexy/form/facturas/_facturaLineasItems.php
@@ -211,7 +211,7 @@ var editor_lineas = new $.fn.dataTable.Editor( {
name: "base",
attr: {
type: "text",
- name : "total",
+ name : "base",
class :"autonumeric"
}
}, {
@@ -224,6 +224,10 @@ var editor_lineas = new $.fn.dataTable.Editor( {
name: "id",
type: "hidden"
},
+ {
+ name: "total",
+ type: "hidden"
+ }
]
} );
@@ -279,7 +283,8 @@ editor_lineas.on( 'preEdit', function ( e, json, data, id ) {
editor_lineas.on( 'postSubmit', function ( e, json, data, action ) {
- yeniden(json.= csrf_token() ?>);
+ tableLineas.clearPipeline();
+ tableLineas.draw();
});
editor_lineas.on( 'submitSuccess', function ( e, json, data, action ) {
@@ -495,7 +500,7 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
$('#total-iva-sum-4').closest('tr').addClass('d-none');
}
else{
- totalTotal += totalIVA_4;
+ //totalTotal += totalIVA_4;
$('#total-iva-sum-4').closest('tr').removeClass('d-none');
}
autoNumericIVA_21.set(totalIVA_21);
@@ -503,17 +508,18 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
$('#total-iva-sum-21').closest('tr').addClass('d-none');
}
else{
- totalTotal += totalIVA_21;
+ //totalTotal += totalIVA_21;
$('#total-iva-sum-21').closest('tr').removeClass('d-none');
}
autoNumericTotal.set(totalTotal);
- var total_pagos = autoNumericTotalCobrado.getNumber();
- var pendientePago = totalTotal - total_pagos;
-
- if (isNaN(pendientePago)) pendientePago = 0;
-
- autoNumericPendientePago.set(pendientePago);
+ if(!(= $facturaEntity->serie_id ?> == 7 || = $facturaEntity->serie_id ?> == 9)){
+ var total_pagos = autoNumericTotalCobrado.getNumber();
+ var pendientePago = totalTotal - total_pagos;
+ if (isNaN(pendientePago)) pendientePago = 0;
+ autoNumericPendientePago.set(pendientePago);
+ }
+
$.ajax({
url: '= route_to('updateFacturaTotales', $facturaEntity->id) ?>',
diff --git a/ci4/app/Views/themes/vuexy/form/facturas/viewFacturaForm.php b/ci4/app/Views/themes/vuexy/form/facturas/viewFacturaForm.php
index 23911b81..4f95d139 100755
--- a/ci4/app/Views/themes/vuexy/form/facturas/viewFacturaForm.php
+++ b/ci4/app/Views/themes/vuexy/form/facturas/viewFacturaForm.php
@@ -17,7 +17,7 @@
= !empty($validation->getErrors()) ? $validation->listErrors("bootstrap_style") : "" ?>
= view("themes/vuexy/form/facturas/_facturaCabeceraItems") ?>
- estado =='borrador') : ?>
+ estado =='borrador' && !($facturaEntity->serie_id == 7 || $facturaEntity->serie_id == 9)) : ?>
= view("themes/vuexy/form/facturas/_addPedidosItems") ?>