mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
corregidas direfencias en totales presupuestos. tiradas alternativas ok. corregido calculo envio base
This commit is contained in:
@ -29,12 +29,15 @@ class PresupuestoAdminEdit {
|
||||
|
||||
this.tipoTapa = $('.card-title').text().toLowerCase().includes('dura') ? 'dura' : 'blanda';
|
||||
|
||||
this.cargandoPresupuesto = false;
|
||||
|
||||
this.datosGenerales = new DatosGenerales(this.domItem.find('#accordionDatosPresupuestoTip'));
|
||||
this.datosLibro = new DatosLibro(this.domItem.find('#accordionDatosLibroTip'),
|
||||
()=>{return this.cargandoPresupuesto},
|
||||
{
|
||||
checkPaginasPresupuesto: this.checkPaginasPresupuesto,
|
||||
getDimensionLibro: this.getDimensionLibro,
|
||||
calcularSolapas: this.calcularSolapas.bind(this)
|
||||
calcularSolapas: this.calcularSolapas.bind(this),
|
||||
});
|
||||
this.comparador = new Comparador(this.domItem.find('#accordionDatosPresupuestoClienteTip'),
|
||||
{
|
||||
@ -56,9 +59,7 @@ class PresupuestoAdminEdit {
|
||||
this.guardar = $('#saveForm');
|
||||
|
||||
this.calcularPresupuesto = false;
|
||||
this.cargandoPresupuesto = false;
|
||||
|
||||
|
||||
|
||||
this.configUploadDropzone = {
|
||||
domElement: '#dropzone-presupuesto-admin-files',
|
||||
nameId: "presupuesto_id",
|
||||
|
||||
@ -370,8 +370,6 @@ class Comparador {
|
||||
}
|
||||
$('#faja').prop('checked', true);
|
||||
$('.faja-div').removeClass('d-none');
|
||||
$('#faja_solapas_ancho').val(60);
|
||||
$('#faja_alto').val(50);
|
||||
$('#compPapelFaja').prop('disabled', false);
|
||||
$('#compGramajeFaja').prop('disabled', false);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ import { getToken } from '../../../common/common.js';
|
||||
|
||||
class DatosLibro {
|
||||
|
||||
constructor(domItem, functions = {}) {
|
||||
constructor(domItem, cargando, functions = {}) {
|
||||
|
||||
this.domItem = domItem;
|
||||
|
||||
@ -70,7 +70,7 @@ class DatosLibro {
|
||||
this.fajaSolapasAncho = this.domItem.find('#faja_solapas_ancho');
|
||||
this.div_faja = this.domItem.find('.faja-div');
|
||||
|
||||
this.cargando = false;
|
||||
this.cargando = cargando;
|
||||
|
||||
}
|
||||
|
||||
@ -182,6 +182,9 @@ class DatosLibro {
|
||||
|
||||
checkMinMaxInput(event) {
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
|
||||
const el = event.target;
|
||||
if (el.value != "") {
|
||||
if (parseInt(el.value) < parseInt(el.min)) {
|
||||
@ -380,7 +383,8 @@ class DatosLibro {
|
||||
|
||||
|
||||
// para que se actualice el comparador
|
||||
$('#compSobrecubierta').trigger('change');
|
||||
if($('#compGramajeSobrecubierta').select2('data').length > 0)
|
||||
$('#compGramajeSobrecubierta').trigger('change');
|
||||
|
||||
if(this.cargando)
|
||||
return;
|
||||
@ -569,8 +573,6 @@ class DatosLibro {
|
||||
|
||||
cargarDatos(datos) {
|
||||
|
||||
this.cargando = true;
|
||||
|
||||
this.paginas.val(datos.paginas);
|
||||
this.tirada.val(datos.tirada);
|
||||
this.calcular_mermas();
|
||||
@ -646,8 +648,6 @@ class DatosLibro {
|
||||
this.ferro.prop('checked', datos.ferro);
|
||||
this.ferroDigital.prop('checked', datos.ferroDigital);
|
||||
this.marcapaginas.prop('checked', datos.marcapaginas);
|
||||
|
||||
this.cargando = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -79,6 +79,8 @@ class Resumen {
|
||||
|
||||
async updateTotales(event, data = {}) {
|
||||
|
||||
const self = this;
|
||||
|
||||
let updateLP = data.updateLP || true;
|
||||
let updateServicios = data.updateServicios || true;
|
||||
let updateEnvio = data.updateEnvio || true;
|
||||
@ -116,28 +118,25 @@ class Resumen {
|
||||
|
||||
}
|
||||
if (rowData.check_impresion_total) {
|
||||
//totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||
margenPorHoras += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + '_precioImpresion').val())
|
||||
margenPorHoras += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
||||
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||
|
||||
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalClicks').val())
|
||||
|
||||
if (rowData.maquinaTipo == 'inkjet') {
|
||||
totalImpresion += parseFloat(rowData.totalTinta)
|
||||
totalImpresion += parseFloat(rowData.totalCorte)
|
||||
|
||||
totalImpresion += parseFloat(rowData.totalCorte)?? 0;
|
||||
sumForFactor += (parseFloat(rowData.totalTinta) + parseFloat(rowData.totalCorte))
|
||||
}
|
||||
//margenImpresion += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||
//margenPorHoras += parseFloat($('#' + rowData.row_id + '_margenImpresion').val())
|
||||
margenImpresion += parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||
|
||||
|
||||
|
||||
sumForFactor -= parseFloat($('#' + rowData.row_id + '_margenClicks').val())
|
||||
|
||||
if (!isNaN(parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val()))) {
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
||||
sumForFactor += parseFloat($('#' + rowData.row_id + 'lp_bn_totalTinta').val())
|
||||
if (!isNaN(parseFloat($('#' + rowData.row_id + '_totalTinta').val()))) {
|
||||
totalImpresion += parseFloat($('#' + rowData.row_id + '_totalTinta').val())
|
||||
sumForFactor += parseFloat($('#' + rowData.row_id + '_totalTinta').val())
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -177,30 +176,32 @@ class Resumen {
|
||||
if (typeof $("#tableOfServiciosEncuadernacion").DataTable() !== 'undefined' && $("#tableOfServiciosEncuadernacion").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosEncuadernacion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio_total));
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios += parseFloat(total_servicio - base);
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof $("#tableOfServiciosAcabado").DataTable() !== 'undefined' && $("#tableOfServiciosAcabado").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosAcabado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio_total));
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios += parseFloat(total_servicio - base);
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof $("#tableOfServiciosPreimpresion").DataTable() !== 'undefined' && $("#tableOfServiciosPreimpresion").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosPreimpresion').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio);
|
||||
let coste_servicio = parseFloat(rowData.coste);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio));
|
||||
let coste_servicio = self.roundToTwoDecimals(parseFloat(rowData.coste));
|
||||
totalServicios += total_servicio
|
||||
margenServicios += total_servicio - coste_servicio;
|
||||
});
|
||||
@ -209,8 +210,8 @@ class Resumen {
|
||||
if (typeof $("#tableOfServiciosExtra").DataTable() !== 'undefined' && $("#tableOfServiciosExtra").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosExtra').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio);
|
||||
let coste_servicio = parseFloat(rowData.coste);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio));
|
||||
let coste_servicio = self.roundToTwoDecimals(parseFloat(rowData.coste));
|
||||
totalServicios += total_servicio
|
||||
margenServicios += total_servicio - coste_servicio;
|
||||
});
|
||||
@ -219,11 +220,12 @@ class Resumen {
|
||||
if (typeof $("#tableOfServiciosManipulado").DataTable() !== 'undefined' && $("#tableOfServiciosManipulado").DataTable().rows().count() > 0) {
|
||||
$('#tableOfServiciosManipulado').DataTable().rows().every(function (rowIdx, tableLoop, rowLoop) {
|
||||
let rowData = this.data();
|
||||
let total_servicio = parseFloat(rowData.precio_total);
|
||||
let total_servicio = self.roundToTwoDecimals(parseFloat(rowData.precio_total));
|
||||
let margen_servicio = parseFloat(rowData.margen);
|
||||
totalServicios += total_servicio
|
||||
let base = total_servicio / (1 + margen_servicio / 100.0);
|
||||
margenServicios += parseFloat(total_servicio - base);
|
||||
let base = self.roundToTwoDecimals(total_servicio / (1 + margen_servicio / 100.0));
|
||||
base = self.roundToTwoDecimals(base / parseInt($('#tirada').val()))*parseInt($('#tirada').val());
|
||||
margenServicios += self.roundToTwoDecimals(parseFloat(total_servicio - base));
|
||||
});
|
||||
}
|
||||
|
||||
@ -346,6 +348,10 @@ class Resumen {
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
roundToTwoDecimals(num) {
|
||||
return parseFloat(num.toFixed(2));
|
||||
}
|
||||
}
|
||||
|
||||
export default Resumen;
|
||||
@ -182,6 +182,8 @@ class TiradasAlernativas {
|
||||
json_acabados: this.generate_json_servicios('acabados'),
|
||||
json_encuadernaciones: this.generate_json_servicios('encuadernaciones'),
|
||||
json_manipulado: this.generate_json_servicios('manipulado'),
|
||||
json_presimpresion: this.generate_json_servicios('presimpresion'),
|
||||
json_extra: this.generate_json_servicios('extra'),
|
||||
json_envios: envios,
|
||||
ancho: dimension.ancho,
|
||||
alto: dimension.alto,
|
||||
|
||||
Reference in New Issue
Block a user