mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado
This commit is contained in:
@ -552,6 +552,7 @@ $routes->group('facturas', ['namespace' => 'App\Controllers\Facturacion'], funct
|
||||
$routes->post('updateTotales/(:any)', 'Facturas::updateTotales/$1', ['as' => 'updateFacturaTotales']);
|
||||
$routes->post('updateCabecera/(:any)', 'Facturas::updateCabecera/$1', ['as' => 'updateCabecera']);
|
||||
$routes->post('datatablePagos/(:any)', 'FacturasPagos::datatable/$1', ['as' => 'dataTableOfPagosFacturas']);
|
||||
$routes->post('conformarFactura', 'FacturasPagos::addPagoRectificativa');
|
||||
$routes->post('editorPagos', 'FacturasPagos::datatable_editor', ['as' => 'editorOfPagosFacturas']);
|
||||
$routes->post('deleteFacturaLineaPago', 'Facturas::deleteLineaPago', ['as' => 'deleteLineaPago']);
|
||||
$routes->post('datatablePedidos', 'Facturas::datatablePedidos', ['as' => 'dataTableOfFacturasPedido']);
|
||||
|
||||
@ -234,6 +234,13 @@ class Facturas extends \App\Controllers\BaseResourceController
|
||||
$factura->showDeleteButton = model('App\Models\Facturas\FacturaPagoModel')
|
||||
->where('factura_id', $factura->id)->countAllResults() == 0;
|
||||
|
||||
if($factura->numero != null && $factura->numero != '' && strpos($factura->numero, "REC ") === 0) {
|
||||
$modelPagos = model('App\Models\Facturas\FacturaPagoModel');
|
||||
if($modelPagos->where('factura_id', $factura->id)->countAllResults() > 0) {
|
||||
$factura->facturaRectificativaPagada = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$this->viewData['facturaEntity'] = $factura;
|
||||
|
||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Facturas.factura') . ' ' . lang('Basic.global.edit3');
|
||||
@ -831,11 +838,6 @@ 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);
|
||||
|
||||
if ((strpos($numero, "REC ") === 0)) {
|
||||
|
||||
@ -136,4 +136,36 @@ class FacturasPagos extends \App\Controllers\BaseResourceController
|
||||
}
|
||||
}
|
||||
|
||||
public function addPagoRectificativa()
|
||||
{
|
||||
if ($this->request->isAJAX()) {
|
||||
$data['factura_id'] = $this->request->getPost('factura_id');
|
||||
$data['fecha_vencimiento_at'] = $this->request->getPost('fecha');
|
||||
$data['total'] = $this->request->getPost('total');
|
||||
$data['user_updated_id'] = auth()->user()->id;
|
||||
$data['forma_pago_id'] = 6; // compensada
|
||||
|
||||
if($data['fecha_vencimiento_at'] != null && $data['fecha_vencimiento_at'] != '') {
|
||||
$data['fecha_vencimiento_at'] = date('Y-m-d H:i:s', strtotime($data['fecha_vencimiento_at']));
|
||||
}
|
||||
|
||||
$model = new FacturaPagoModel();
|
||||
$model->insert($data);
|
||||
|
||||
$modelFactura = model('App\Models\Facturas\FacturaModel');
|
||||
$modelFactura->update($data['factura_id'], [
|
||||
'estado_pago' => 'pagada',
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
'user_updated_id' => auth()->user()->id,
|
||||
]);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'status' => true,
|
||||
'message' => lang('Facturas.facturaConformada'),
|
||||
]);
|
||||
} else {
|
||||
return $this->failUnauthorized('Invalid request', 403);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -77,6 +77,10 @@ return [
|
||||
|
||||
"acumuladoFacturacion" => "Acumulado Facturación",
|
||||
"totalPendientePago" => "Pendiente de pago",
|
||||
|
||||
"textoConformarFactura" => "La factura rectificativa se conformará y pasará a estar pagada.",
|
||||
"conformarFactura" => "Conformar factura",
|
||||
"facturaConformada" => "Factura conformada correctamente",
|
||||
|
||||
'errors' => [
|
||||
'requiredFields' => 'Los campos marcados con * son obligatorios',
|
||||
|
||||
@ -518,28 +518,27 @@ var tableLineas = $('#tableOfLineasFactura').DataTable({
|
||||
var pendientePago = totalTotal - total_pagos;
|
||||
if (isNaN(pendientePago)) pendientePago = 0;
|
||||
autoNumericPendientePago.set(pendientePago);
|
||||
|
||||
$.ajax({
|
||||
url: '<?= route_to('updateFacturaTotales', $facturaEntity->id) ?>',
|
||||
method: 'POST',
|
||||
data: {
|
||||
base: totalSubtotal,
|
||||
total: totalTotal,
|
||||
total_pagos: total_pagos,
|
||||
pendiente: pendientePago,
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
}
|
||||
}).done(function (data) {
|
||||
if (data.estado_pago === 'pagada') {
|
||||
$('#estado_pago_text').text('<?= lang('Facturas.pagada') ?>').css('color', 'green');
|
||||
} else {
|
||||
$('#estado_pago_text').text('<?= lang('Facturas.pendiente') ?>').css('color', 'red');
|
||||
}
|
||||
}).fail(function (jqXHR) {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: '<?= route_to('updateFacturaTotales', $facturaEntity->id) ?>',
|
||||
method: 'POST',
|
||||
data: {
|
||||
base: totalSubtotal,
|
||||
total: totalTotal,
|
||||
total_pagos: total_pagos,
|
||||
pendiente: pendientePago,
|
||||
<?= csrf_token() ?? "token" ?> : <?= csrf_token() ?>v
|
||||
}
|
||||
}).done(function (data) {
|
||||
if (data.estado_pago === 'pagada') {
|
||||
$('#estado_pago_text').text('<?= lang('Facturas.pagada') ?>').css('color', 'green');
|
||||
} else {
|
||||
$('#estado_pago_text').text('<?= lang('Facturas.pendiente') ?>').css('color', 'red');
|
||||
}
|
||||
}).fail(function (jqXHR) {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@ -398,18 +398,31 @@ function updateFooterLineas(table){
|
||||
pendiente: pendientePago
|
||||
}
|
||||
}).done((data, textStatus, jqXHR) => {
|
||||
if(autoNumericPendientePago.getNumber() == 0){
|
||||
$('#addPagoRow').hide();
|
||||
} else {
|
||||
$('#addPagoRow').show();
|
||||
}
|
||||
if(data.estado_pago == 'pagada'){
|
||||
$('#estado_pago_text').text('<?= lang('Facturas.pagada') ?>');
|
||||
$('#estado_pago_text').css('color', 'green');
|
||||
if($('#numero').val().startsWith("REC")){
|
||||
|
||||
if($("#vencimiento-rectificativa").length > 0){
|
||||
$('#estado_pago_text').text('<?= lang('Facturas.pendiente') ?>');
|
||||
$('#estado_pago_text').css('color', 'red');
|
||||
}
|
||||
else{
|
||||
$('#estado_pago_text').text('<?= lang('Facturas.facturaPagada') ?>');
|
||||
$('#estado_pago_text').css('color', 'green');
|
||||
}
|
||||
}
|
||||
else{
|
||||
$('#estado_pago_text').text('<?= lang('Facturas.pendiente') ?>');
|
||||
$('#estado_pago_text').css('color', 'red');
|
||||
if(autoNumericPendientePago.getNumber() == 0){
|
||||
$('#addPagoRow').hide();
|
||||
} else {
|
||||
$('#addPagoRow').show();
|
||||
}
|
||||
if(data.estado_pago == 'pagada'){
|
||||
$('#estado_pago_text').text('<?= lang('Facturas.pagada') ?>');
|
||||
$('#estado_pago_text').css('color', 'green');
|
||||
}
|
||||
else{
|
||||
$('#estado_pago_text').text('<?= lang('Facturas.pendiente') ?>');
|
||||
$('#estado_pago_text').css('color', 'red');
|
||||
}
|
||||
}
|
||||
}).fail((jqXHR, textStatus, errorThrown) => {
|
||||
popErrorAlert(jqXHR.responseJSON.messages.error)
|
||||
|
||||
@ -1,14 +1,41 @@
|
||||
<div class="accordion accordion-bordered mt-3" id="rectificadaFactura">
|
||||
<div class="card accordion-item active">
|
||||
<h2 class="accordion-header" id="headingrectificadaFactura">
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse" data-bs-target="#accordionRectificadaFacturaTip" aria-expanded="false" aria-controls="accordionRectificadaFacturaTip">
|
||||
<h3><?= lang("Facturas.facturaRectificada") ?></h3>
|
||||
<button type="button" class="accordion-button" data-bs-toggle="collapse"
|
||||
data-bs-target="#accordionRectificadaFacturaTip" aria-expanded="false"
|
||||
aria-controls="accordionRectificadaFacturaTip">
|
||||
<h3><?= lang("Facturas.facturaRectificativa") ?></h3>
|
||||
</button>
|
||||
</h2>
|
||||
<div id="accordionRectificadaFacturaTip" class="accordion-collapse collapse show" data-bs-parent="#rectificadaFactura">
|
||||
<div id="accordionRectificadaFacturaTip" class="accordion-collapse collapse show"
|
||||
data-bs-parent="#rectificadaFactura">
|
||||
<div class="accordion-body">
|
||||
|
||||
<p><?= lang("Facturas.facturaPagada") ?></p>
|
||||
|
||||
<?php if (isset($facturaEntity->facturaRectificativaPagada)): ?>
|
||||
<p><?= lang("Facturas.facturaPagada") ?></p>
|
||||
<?php else: ?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-3 col-lg-3 mb-2">
|
||||
<label for="vencimiento_rectificativa"
|
||||
class="form-label"><?= @lang("Facturas.vencimiento") ?></label>
|
||||
<div class="input-group">
|
||||
<input type="date" class="form-control" placeholder="" name="vencimiento_rectificativa"
|
||||
id="vencimiento-rectificativa" />
|
||||
<button class="btn btn-outline-warning" id="clearRectDate" type="button"><i
|
||||
class="ti-eraser ti"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-4 col-lg-4 mb-2">
|
||||
<label for="vencimiento_rectificativa"
|
||||
class="form-label"><?= @lang("Facturas.textoConformarFactura") ?></label>
|
||||
<div class="input-group">
|
||||
<button name="conformarFactura" id="conformarFactura" class="btn btn-success" type="button">
|
||||
<?= lang("Facturas.conformarFactura") ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@ -16,7 +43,7 @@
|
||||
</div>
|
||||
|
||||
|
||||
<?=$this->section('additionalInlineJs') ?>
|
||||
<?= $this->section('additionalInlineJs') ?>
|
||||
|
||||
|
||||
<?=$this->endSection() ?>
|
||||
<?= $this->endSection() ?>
|
||||
@ -139,6 +139,8 @@ function validatedConfirmed(){
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/sk-datatables.css') ?>">
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/css/datatables-editor/editor.dataTables.min.css') ?>">
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/datetime/1.5.2/css/dataTables.dateTime.min.css">
|
||||
<link rel="stylesheet" href="<?= site_url("/themes/vuexy/vendor/libs/flatpickr/flatpickr.css") ?>">
|
||||
<link rel="stylesheet" href="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.css') ?>" />
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
<?= $this->section('additionalExternalJs') ?>
|
||||
@ -154,7 +156,9 @@ function validatedConfirmed(){
|
||||
<script src="<?= site_url('themes/vuexy/js/datatables-editor/dataTables.editor.min.js') ?>"></script>
|
||||
<script type="text/javascript" src="https://cdn.datatables.net/datetime/1.5.2/js/dataTables.dateTime.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
|
||||
<script src="<?= site_url('themes/vuexy/vendor/libs/sweetalert2/sweetalert2.js') ?>"></script>
|
||||
|
||||
<script type="module" src="<?= site_url('assets/js/safekat/pages/facturas/facturasEdit.js') ?>"></script>
|
||||
<?=$this->endSection() ?>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user