mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Merge branch 'main' into 'dev/resumen_lateral'
Main See merge request jjimenez/safekat!367
This commit is contained in:
@ -37,7 +37,7 @@ class Direcciones {
|
||||
|
||||
init() {
|
||||
|
||||
$("#clienteId").on('change', this.handleChangeCliente.bind(this));
|
||||
$("#clienteId").on('change', this.handleChangeCliente.bind(this));
|
||||
|
||||
this.direccionesCliente.init();
|
||||
this.btnAdd.on('click', this.#insertDireccion.bind(this));
|
||||
@ -125,7 +125,7 @@ class Direcciones {
|
||||
validators: {
|
||||
callback: {
|
||||
callback: () => {
|
||||
/* const div = $('#divErrorEnvios'); // Selecciona el div
|
||||
const div = $('#divErrorEnvios'); // Selecciona el div
|
||||
|
||||
div.find('.fv-plugins-message-container').remove();
|
||||
|
||||
@ -136,7 +136,7 @@ class Direcciones {
|
||||
this.direcciones.forEach(direccion => {
|
||||
total_envio += parseInt(direccion.getUnidades());
|
||||
});
|
||||
if (total_envio == unidades) {
|
||||
if (total_envio < unidades) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -144,13 +144,11 @@ class Direcciones {
|
||||
div.append(`
|
||||
<div class="fv-plugins-message-container invalid-feedback">
|
||||
<div data-field="div_tipo_cubierta" data-validator="callback">
|
||||
El total de unidades enviadas no se corresponde con las unidades del pedido
|
||||
El total de unidades enviadas no puede ser mayor que la tirada seleccionada
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
return false;
|
||||
*/
|
||||
return true;
|
||||
},
|
||||
}
|
||||
|
||||
@ -260,6 +258,12 @@ class Direcciones {
|
||||
|
||||
let id = this.direccionesCliente.getVal();
|
||||
let unidades = this.unidadesAdd.val();
|
||||
|
||||
if (id == null || id <= 0 || id == undefined)
|
||||
return;
|
||||
if (unidades == null || unidades <= 0 || unidades == undefined)
|
||||
return;
|
||||
|
||||
let entregaPalets = this.entregaPieCallero.is(':checked');
|
||||
let divId = "dirEnvio-1";
|
||||
let direccionesActuales = this.divDirecciones.find('.direccion-cliente');
|
||||
@ -267,12 +271,23 @@ class Direcciones {
|
||||
// the the lass item
|
||||
let last = direccionesActuales[direccionesActuales.length - 1];
|
||||
divId = "dirEnvio-" + (parseInt(last.id.split('-')[1]) + 1);
|
||||
}
|
||||
|
||||
if (id == null || id <= 0 || id == undefined)
|
||||
return;
|
||||
if (unidades == null || unidades <= 0 || unidades == undefined)
|
||||
return;
|
||||
let total_unidades = 0;
|
||||
for (let i = 0; i < this.direcciones.length; i++) {
|
||||
total_unidades += parseInt(this.direcciones[i].getUnidades());
|
||||
}
|
||||
|
||||
if (total_unidades + parseInt(unidades) > this.getSelectedTirada()) {
|
||||
popErrorAlert("El total de unidades enviadas tiene que ser menor que " + this.getSelectedTirada());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (unidades > this.getSelectedTirada()) {
|
||||
popErrorAlert("El total de unidades enviadas tiene que ser menor que " + this.getSelectedTirada());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$('#loader').modal('show');
|
||||
let peticion = new Ajax('/misdirecciones/get/' + id, {}, {},
|
||||
|
||||
@ -163,8 +163,10 @@ class PresupuestoCliente {
|
||||
if (this.calcularPresupuesto) {
|
||||
|
||||
if (event.target.id === 'divDirecciones') {
|
||||
this.actualizarTiradasEnvio = false;
|
||||
|
||||
if (!this.direcciones.calcularPresupuesto) {
|
||||
this.actualizarTiradasEnvio = false;
|
||||
|
||||
$('#loader').modal('hide');
|
||||
return;
|
||||
}
|
||||
@ -374,6 +376,16 @@ class PresupuestoCliente {
|
||||
|
||||
#confirmPresupuesto() {
|
||||
|
||||
let total_unidades = 0;
|
||||
this.direcciones.direcciones.forEach(element => {
|
||||
total_unidades += parseInt(element.tirada.val());
|
||||
});
|
||||
|
||||
if(total_unidades != parseInt(this.direcciones.getSelectedTirada())){
|
||||
popErrorAlert("No se puede confirmar el presupuesto. La suma de las unidades enviadas no coincide con la tirada seleccionada.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.#solicitudGuardarPresupuesto(true);
|
||||
}
|
||||
|
||||
@ -477,8 +489,9 @@ class PresupuestoCliente {
|
||||
response.precio_u[i]
|
||||
);
|
||||
|
||||
if (this.actualizarTiradasEnvio)
|
||||
if (this.actualizarTiradasEnvio){
|
||||
this.direcciones.insertTirada(tiradas[i]);
|
||||
}
|
||||
|
||||
}
|
||||
this.lc.val(parseFloat(response.info.lomo_cubierta).toFixed(2));
|
||||
|
||||
Reference in New Issue
Block a user