diff --git a/ci4/app/Services/PresupuestoService.php b/ci4/app/Services/PresupuestoService.php index 2d45ccde..5dfa0915 100755 --- a/ci4/app/Services/PresupuestoService.php +++ b/ci4/app/Services/PresupuestoService.php @@ -359,8 +359,8 @@ class PresupuestoService extends BaseService $margen = (new \App\Models\Configuracion\PapelImpresionMargenModel())->getMargenFormPags($papel_impresion->id, $paginas); if (count($margen) > 0) { $peso_por_pliego = $maquina->alto * $maquina->ancho * $papel_impresion->gramaje / 1000000; - $precio_pliego = ($peso_por_pliego * $papel_impresion->precio_tonelada / 1000000.0) * (1 + (floatval($margen[0]['margen']) / 100.0)); - $margen_pliego = ($peso_por_pliego * $papel_impresion->precio_tonelada / 1000000.0) * (0 + (floatval($margen[0]['margen']) / 100.0)); + $precio_pliego = ($peso_por_pliego * $papel_impresion->precio_tonelada / 1000000.0) ; + $margen_pliego = ($peso_por_pliego * $papel_impresion->precio_tonelada / 1000000.0) * (floatval($margen[0]['margen']) / 100.0); return [round($precio_pliego, 6), round($margen_pliego, 6)]; } return -1; diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php index 90db7d7f..4fa564e9 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_datosEnvios.php @@ -249,9 +249,8 @@ function load_datos_envios(){ : v, }) .done(function( data ) { - console.log(data) data.data.forEach((linea) => { - tableEnvios.row + tableEnvios.row .add({ 'tarifa_id': linea.tarifa_id, 'cantidad': linea.cantidad, @@ -272,6 +271,7 @@ function load_datos_envios(){ 'actionBtns_direcciones': actionBtns_direcciones, }) .draw(); + updateTotales() }); }) } diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php index 16fc7132..122c5105 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_lineasPresupuestoItems.php @@ -889,7 +889,6 @@ $('#lp_rot_bn_vercalculos').on("click", function () { $(document).on('click', '.btn-delete', function(e) { const row_id = $(this).closest('tr')[0].id; $(".btn-remove").attr('row-id', row_id); - }); @@ -905,6 +904,7 @@ $(document).on('click', '.btn-remove', function(e) { clear_interior(row_id) } $('#confirm2delete').modal('toggle') + updateTotales() }); @@ -1299,7 +1299,6 @@ function fill_lp_bn(row, fromComparator=false){ calcularPresupuesto_bn(false) } else{ - //console.log(row); // Si viene de hacerlo a mano... $('#lp_bn_tiempo').val(row.tiempo_maquina) $('#lp_bn_numeroPliegos').val(isNaN(parseFloat(row.pliegos_libro)) ? "" : parseFloat(row.pliegos_libro).toFixed(2)) @@ -1314,7 +1313,7 @@ function fill_lp_bn(row, fromComparator=false){ $('#lp_bn_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) $('#lp_bn_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) - + updateTotales() } @@ -1542,6 +1541,7 @@ function fill_lp_color(row, fromComparator=false){ $('#lp_color_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) $('#lp_color_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) + updateTotales() } @@ -1768,6 +1768,8 @@ function fill_lp_bnhq(row, fromComparator=false){ $('#lp_bnhq_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) $('#lp_bnhq_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) + + updateTotales() } @@ -1996,6 +1998,8 @@ function fill_lp_colorhq(row, fromComparator=false){ $('#lp_colorhq_totalClicks').val(isNaN(parseFloat(row.precio_click_pedido)) ? "" : parseFloat(row.precio_click_pedido).toFixed(2)) $('#lp_colorhq_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) + + updateTotales() } @@ -2330,6 +2334,8 @@ function fill_lp_rot_bn(row, fromComparador=false){ $('#lp_rot_bn_gTintaAmarilloPed').val(isNaN(parseFloat(row.peso_gotas_amarillo_pedido)) ? "" : parseFloat(row.peso_gotas_amarillo_pedido).toFixed(2)) $('#lp_rot_bn_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) + + updateTotales() } @@ -2674,6 +2680,8 @@ function fill_lp_rot_color(row, fromComparador=false){ $('#lp_rot_color_numPagColor').val(row.paginas_color) $('#lp_rot_color_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) + + updateTotales() } @@ -2944,6 +2952,7 @@ function fill_lp_cubierta(row, fromComparador=false){ $('#lp_cubierta_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id))) ? "" : parseInt(row.tarifa_impresion_id) $('#lp_cubierta_tarifa_impresion_id').val(isNaN(parseInt(row.tarifa_impresion_id)) ? "" : parseInt(row.tarifa_impresion_id)) + updateTotales() } $('.lp_cubierta').css('display', '') diff --git a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php index 2212964c..3cecc9ea 100755 --- a/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php +++ b/ci4/app/Views/themes/backend/vuexy/form/presupuestos/cosidotapablanda/_resumenPresupuestoItems.php @@ -21,7 +21,8 @@
Coste papel
NaN €
Margen papel
-
NaN €
+
NaN €
+
NaN €
Coste impresión
NaN €
@@ -32,19 +33,20 @@
Coste servicios
NaN €
Margen servicios
-
NaN €
+
NaN €
+
NaN €
Coste de envío
-
NaN €
+
NaN€
Margen envío
-
NaN €
+
NaN €

Total Costes
-
NaN €
+
NaN €
Total Margen
-
NaN €
+
NaN €
@@ -52,13 +54,14 @@
Total
-
NaN €
-
Descuento
-
NaN €
+
NaN €
+
Descuento
+
+
NaN €
Total presupuesto
-
NaN €
+
NaN €
Precio unidad
-
NaN €
+
NaN €
@@ -100,10 +103,12 @@ function updateTotales(){ } }) + var porcentajeMargenPapel = margenPapel/(totalPapel)*100 + $('#porcentajeMargenPapel').text(porcentajeMargenPapel.toFixed(0) + '%') $('#totalCostePapel').text(totalPapel.toFixed(2) + '€') $('#margenPapel').text(margenPapel.toFixed(2) + '€') - + margenImpresion = totalImpresion*$('#margenImpresionValue').val()/100.0 $('#totalCosteImpresion').text(totalImpresion.toFixed(2) + '€') $('#margenImpresion').text((totalImpresion*$('#margenImpresionValue').val()/100.0).toFixed(2) + '€') @@ -150,9 +155,41 @@ function updateTotales(){ } totalServicios -= margenServicios; + var porcentajeMargenServicios = margenServicios/(margenServicios+totalServicios)*100 + $('#porcentajeMargenServicios').text(porcentajeMargenServicios.toFixed(0) + '%') $('#totalServicios').text(totalServicios.toFixed(2) + '€') $('#margenServicios').text(margenServicios.toFixed(2) + '€') + + var totalEnvios = 0 + var margenEnvios = 0 + if ( typeof tableEnvios !== 'undefined' && tableEnvios.rows().count() > 0){ + tableEnvios.rows().every( function ( rowIdx, tableLoop, rowLoop ) { + var data = this.data() + totalEnvios += data.precio + margenEnvios += (data.precio)*data.margen/100 + } ); + } + + totalEnvios -= margenEnvios + $('#totalEnvios').text(totalEnvios.toFixed(2) + '€') + $('#margenEnvios').text(margenEnvios.toFixed(2) + '€') + + var totalCostes = totalPapel + totalImpresion + totalServicios + totalEnvios + var totalMargenes = margenPapel + margenImpresion + margenServicios + margenEnvios + $('#totalCostes').text((totalCostes).toFixed(2) + '€') + $('#totalMargenes').text((totalMargenes).toFixed(2) + '€') + + var totalAntesDescuento = totalCostes + totalMargenes + var totalDescuento = totalAntesDescuento * parseInt($('#descuento').val())/100 + var totalPresupuesto = totalAntesDescuento - totalDescuento + var precioUnidad = totalPresupuesto/parseInt($('#tirada').val()) + + $('#totalAntesDescuento').text((totalAntesDescuento).toFixed(2) + '€') + $('#descuentoTotal').text((totalDescuento).toFixed(2) + '€') + $('#totalDespuesDecuento').text((totalPresupuesto).toFixed(2) + '€') + $('#precioUnidadPresupuesto').text((precioUnidad).toFixed(2) + '€') + } $(".update-totales").on("change", function(){