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'), this.lineasPresupuesto = new LineasPresupuesto(this.domItem.find('#accordionLineasPresupuestoTip'),
{ {
getDimensionLibro: this.getDimensionLibro, getDimensionLibro: this.getDimensionLibro,
calcular_mermas: this.datosLibro.calcular_mermas,
}); });
this.previewFormasAdmin = null; this.previewFormasAdmin = null;

View File

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

View File

@ -531,17 +531,18 @@ class DatosLibro {
} }
else { else {
let merma_lineas = [] let merma_lineas = []
$('#tableLineasPresupuesto').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) { const table = $('#tableLineasPresupuesto').DataTable();
var rowData = this.data(); 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') { 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) if (formas_linea > tirada)
merma_lineas.push(formas_linea - tirada) merma_lineas.push(formas_linea - tirada);
else else
merma_lineas.push(tirada % formas_linea) merma_lineas.push(tirada % formas_linea);
} }
}
})
if (merma_lineas.length > 0) if (merma_lineas.length > 0)

View File

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