Merge branch 'fix/merma_POD_presuadmin' into 'main'

Fix/merma pod presuadmin

See merge request jjimenez/safekat!540
This commit is contained in:
2025-02-10 19:01:49 +00:00
4 changed files with 23 additions and 21 deletions

View File

@ -47,6 +47,7 @@ class PresupuestoAdminEdit {
this.lineasPresupuesto = new LineasPresupuesto(this.domItem.find('#accordionLineasPresupuestoTip'),
{
getDimensionLibro: this.getDimensionLibro,
calcular_mermas: this.datosLibro.calcular_mermas,
});
this.previewFormasAdmin = null;

View File

@ -208,7 +208,7 @@ class Comparador {
'/presupuestoadmin/papelgramaje', 'Seleccione gramaje', false,
{
[this.csrf_token]: this.csrf_hash,
papel_generico: () => this.papelCubierta.getVal(),
papel_generico: () => this.papelGuardas.getVal(),
tipo_impresion: this.tipo_impresion_id,
tirada: () => $('#tirada').val(),
ancho: () => this.getDimensionLibro().ancho,
@ -1166,11 +1166,11 @@ class Comparador {
}
else if (uso == 'faja') {
if ((this.papelFaja.getVal() == 0 || this.papelFaja.getVal() == null) && this.faja.getVal()>0 && !this.cargando) {
if (this.papelFaja.getText() == "" && this.faja.val()>0 && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccionePapel, 'divAlarmasComparador');
return { error: true, data: {} };
}
if ((this.gramajeFaja.getVal() == 0 || this.gramajeFaja.getVal() == null) && this.faja.getVal()>0 && !this.cargando) {
if (this.gramajeFaja.getText() == "" && this.faja.val()>0 && !this.cargando) {
popErrorAlert(window.language.Presupuestos.errores.seleccioneGramaje, 'divAlarmasComparador');
return { error: true, data: {} };
}
@ -1413,13 +1413,13 @@ class Comparador {
}
},
(error) => {
console.log(error);
console.error(error);
self.comparadorPlanaRunning = false;
}
).post();
}
} catch (e) {
console.log(e);
console.error(e);
this.comparadorPlanaRunning = false;
}
}
@ -1507,13 +1507,13 @@ class Comparador {
self.comparadorExterioresRunning = false;
},
(error) => {
console.log(error);
console.error(error);
self.comparadorExterioresRunning = false;
}
).post();
} catch (e) {
console.log(e);
console.error(e);
self.comparadorExterioresRunning = false;
}
}
@ -1574,14 +1574,14 @@ class Comparador {
self.comparadorFajaRunning = false;
},
(error) => {
console.log(error);
console.error(error);
self.comparadorFajaRunning = false;
}
).post();
} catch (e) {
console.log(e);
console.error(e);
self.comparadorFajaRunning = false;
}
}
@ -1638,13 +1638,13 @@ class Comparador {
self.comparadorGuardasRunning = false;
},
(error) => {
console.log(error);
console.error(error);
self.comparadorGuardasRunning = false;
}
).post();
} catch (e) {
console.log(e);
console.error(e);
self.comparadorGuardasRunning = false;
}
}

View File

@ -531,17 +531,18 @@ class DatosLibro {
}
else {
let merma_lineas = []
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
var rowData = this.data();
const table = $('#tableLineasPresupuesto').DataTable();
const rows = table.rows().data();
for (let i = 0; i < rows.length; i++) {
const rowData = rows[i];
if (rowData.row_id != 'lp_guardas' && rowData.row_id != 'lp_cubierta' && rowData.row_id != 'lp_sobrecubierta') {
const formas_linea = parseInt($('#isCosido').val()) == 0 ? parseInt(rowData.formas) : parseInt(rowData.formas) / 2
const formas_linea = parseInt($('#isCosido').val()) == 0 ? parseInt(rowData.formas) : parseInt(rowData.formas) / 2;
if (formas_linea > tirada)
merma_lineas.push(formas_linea - tirada)
merma_lineas.push(formas_linea - tirada);
else
merma_lineas.push(tirada % formas_linea)
merma_lineas.push(tirada % formas_linea);
}
})
}
if (merma_lineas.length > 0)

View File

@ -9,6 +9,7 @@ class LineasPresupuesto {
constructor(domItem, functions = {}) {
this.domItem = domItem;
this.getDimensionLibro = functions.getDimensionLibro;
this.calcular_mermas = functions.calcular_mermas;
this.table = null;
@ -1681,9 +1682,8 @@ class LineasPresupuesto {
$('#' + linea + '_checkPapel').trigger('change');
/* TO-DO
calcular_mermas()
*/
this.calcular_mermas()
$(document).trigger('update-presupuesto', {
update_lineas: false,