mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado
This commit is contained in:
132
httpdocs/assets/js/safekat/pages/facturas/facturasEdit.js
Normal file
132
httpdocs/assets/js/safekat/pages/facturas/facturasEdit.js
Normal file
@ -0,0 +1,132 @@
|
||||
import DatePicker from "../../components/datepicker.js";
|
||||
|
||||
$(() =>{
|
||||
|
||||
const fechaVencimientoRectificativa = $("#vencimiento-rectificativa");
|
||||
let fechaPagoRectificativa = null;
|
||||
if(fechaVencimientoRectificativa.length > 0) {
|
||||
|
||||
const option = {
|
||||
altInput: true,
|
||||
altFormat: "d/m/Y",
|
||||
dateFormat: "Y-m-d",
|
||||
allowInput: false,
|
||||
}
|
||||
fechaPagoRectificativa = new DatePicker(fechaVencimientoRectificativa, option);
|
||||
|
||||
$('#clearRectDate').on('click', function() {
|
||||
fechaPagoRectificativa.itemDate.clear();
|
||||
})
|
||||
|
||||
$('#conformarFactura').on('click', function() {
|
||||
|
||||
Swal.fire({
|
||||
title: 'Atención!',
|
||||
text: 'La accion de conformar la factura no se puede deshacer. ¿Desea continuar?.',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Sí',
|
||||
cancelButtonText: 'Cancelar',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-danger me-1',
|
||||
cancelButton: 'btn btn-secondary'
|
||||
},
|
||||
buttonsStyling: false
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
|
||||
if(fechaVencimientoRectificativa.val() == null || fechaVencimientoRectificativa.val() == "") {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: "La fecha de vencimiento no puede estar vacía.",
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const total = new AutoNumeric('#total-sum', {
|
||||
decimalPlaces: 2,
|
||||
digitGroupSeparator: '.',
|
||||
decimalCharacter: ',',
|
||||
unformatOnSubmit: true,
|
||||
decimalPlacesShownOnFocus: 2,
|
||||
decimalPlacesShownOnBlur: 2,
|
||||
});
|
||||
|
||||
if(total.getNumber() == null || total.getNumber() == "" || total.getNumber() == 0) {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: "No se puede conformar una factura rectificativa con importe 0€.",
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const id = window.location.href.split('/').pop();
|
||||
const fechaVencimiento = fechaVencimientoRectificativa.val();
|
||||
|
||||
$.post('/facturas/conformarFactura', {
|
||||
factura_id: id,
|
||||
fecha: fechaVencimiento,
|
||||
total: total.getNumber(),
|
||||
}, function (response) {
|
||||
if (response.status) {
|
||||
|
||||
Swal.fire({
|
||||
text: response.message,
|
||||
icon: 'success',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
}).then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: response.message,
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
}
|
||||
}).fail(() => {
|
||||
Swal.fire({
|
||||
title: 'Error',
|
||||
text: 'No se pudo conformar la factura.',
|
||||
icon: 'error',
|
||||
confirmButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Ok',
|
||||
customClass: {
|
||||
confirmButton: 'btn btn-primary me-1',
|
||||
},
|
||||
buttonsStyling: false
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user