From a48137502808a5b8eaf4402767e4a4f8c2ae104c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 2 Apr 2025 18:38:48 +0200 Subject: [PATCH] modificado --- .../Language/es/PresupuestosDirecciones.php | 1 + .../form/presupuestos/admin/_datosEnvios.php | 2 +- .../pages/presupuestoAdmin/sections/envios.js | 36 ++++++++++++------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/ci4/app/Language/es/PresupuestosDirecciones.php b/ci4/app/Language/es/PresupuestosDirecciones.php index 22a9321b..fbb1be1b 100755 --- a/ci4/app/Language/es/PresupuestosDirecciones.php +++ b/ci4/app/Language/es/PresupuestosDirecciones.php @@ -18,6 +18,7 @@ return [ 'cantidad' => 'Cantidad', 'proveedor' => 'Proveedor', 'precio' => 'Precio', + 'costePrecio' => 'Coste/Precio', 'saveDirection' => 'Guardar en direcciones de cliente', 'entregaPieCalle' => 'Entrega a pie de calle (enviado en palets)', 'validation' => [ diff --git a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.php b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.php index 9d3b89e7..982bf06f 100644 --- a/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.php +++ b/ci4/app/Views/themes/vuexy/form/presupuestos/admin/_datosEnvios.php @@ -36,7 +36,7 @@ Proveedor_id - + Pallets? diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js index 425a783b..80c7f2a5 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/sections/envios.js @@ -63,7 +63,13 @@ class Envios { { 'data': 'telefono' }, { 'data': 'proveedor' }, { 'data': 'proveedor_id', visible: false }, - { 'data': 'precio' }, + { + 'data': 'precio', render: function (data, type, row) { + let coste = parseFloat(data).toFixed(2); + let precio = parseFloat(data * (1 + row.margen / 100.0)).toFixed(2); + return coste + "/" + precio; + } + }, { 'data': 'margen', render: function (data, type, row) { return Math.round(data) } }, { 'data': 'entregaPieCalle' }, { @@ -231,14 +237,14 @@ class Envios { async guardarEnvios() { - + var id = window.location.pathname.split('/').pop(); await $.post('/presupuestodirecciones/datatable', Object.assign({ tipo: "clear_lineas", presupuesto_id: id }, window.token_ajax)) - .done(function (data) { + .done(async function (data) { - $('#tableOfDireccionesEnvio').DataTable().rows().every(async function (rowIdx, tableLoop, rowLoop) { + await $('#tableOfDireccionesEnvio').DataTable().rows().every(async function (rowIdx, tableLoop, rowLoop) { var data = this.data(); await $.post('/presupuestos/presupuestodirecciones/add', { @@ -261,6 +267,8 @@ class Envios { entregaPieCalle: data.entregaPieCalle }) }); + + }) } @@ -291,8 +299,10 @@ class Envios { let b = parseFloat(datos_tarifa.precio_max) - m * parseFloat(datos_tarifa.peso_max); datos_tarifa.precio = parseFloat(m * peso_envio + b); } + let coste = parseFloat(datos_tarifa.precio).toFixed(2); + let precio = parseFloat(coste * (1 + datos_tarifa.margen / 100.0)).toFixed(2); - $('#envio_base').val(datos_tarifa.precio.toFixed(2)); + $('#envio_base').val(precio); } } @@ -316,7 +326,7 @@ class Envios { peso_total_libro = Math.ceil(peso_total_libro); const peso_envio = peso_total_libro * parseInt(rowData.cantidad) / 1000.0; - + const tirada = parseInt($('#tirada').val()); var datos_tarifa = await self.get_precio_envio(peso_envio, rowData.pais_id, rowData.cp, parseInt(rowData.entregaPieCalle) == 1 ? 'palets' : 'cajas'); @@ -324,7 +334,7 @@ class Envios { if (datos_tarifa.id != null) { if (peso_envio > parseFloat(datos_tarifa.peso_max) || parseFloat(datos_tarifa.peso_max) == 0) { - datos_tarifa.precio = parseFloat(datos_tarifa.peso_min) + (peso_envio - parseFloat(datos_tarifa.peso_min)) * parseFloat(datos_tarifa.precio_adicional); + datos_tarifa.precio = parseFloat(datos_tarifa.precio_max) + (peso_envio - parseFloat(datos_tarifa.peso_max)) * parseFloat(datos_tarifa.precio_adicional); } // si no se calcula linealmente else { @@ -487,7 +497,7 @@ class Envios { peso_total_libro += parseFloat(rowData.peso) }) - + peso_total_libro = Math.ceil(peso_total_libro); const peso_envio = peso_total_libro * parseInt($('#add_cantidad').val()) / 1000.0; @@ -506,7 +516,7 @@ class Envios { let precios = [] for (let i = 0; i < data.length; i++) { if (peso_envio > data[i].peso_max || data[i].precio_max == 0) { - data[i].precio = (parseFloat(data[i].precio_min) + (peso_envio - parseFloat(data[i].peso_min)) * parseFloat(data[i].precio_adicional)).toFixed(2); + data[i].precio = (parseFloat(data[i].precio_max) + (peso_envio - parseFloat(data[i].peso_max)) * parseFloat(data[i].precio_adicional)).toFixed(2); } else { @@ -574,10 +584,10 @@ class Envios { } $(document).trigger('ckeck-lineas-envios'); - + $(document).trigger('update-presupuesto', { - update_lineas : false, - update_servicios : true, + update_lineas: false, + update_servicios: true, update_envios: false, update_resumen: true, update_tiradas_alternativas: true @@ -645,7 +655,7 @@ class Envios { check_unidades_enviadas(event, recogerTaller = null) { - if(recogerTaller === null) { + if (recogerTaller === null) { recogerTaller = this.recogerTaller.prop('checked'); }