Merge branch 'fix/porcentaje_total_presupuesto' into 'main'

corregida division por cero

See merge request jjimenez/safekat!338
This commit is contained in:
2024-09-26 07:07:14 +00:00
2 changed files with 4 additions and 4 deletions

View File

@ -47,7 +47,7 @@
<dt class="col-5 fw-normal text-end">Total Costes</dt> <dt class="col-5 fw-normal text-end">Total Costes</dt>
<dd id="totalCostes" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_costes) ?>€</dd> <dd id="totalCostes" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_costes) ?>€</dd>
<dt class="col-5 fw-normal text-end">Total Margen</dt> <dt class="col-5 fw-normal text-end">Total Margen</dt>
<dd id="porcentajeMargen" class="col-3 text-end py-1"><?= old('0', round(100*$presupuestoEntity->total_margenes/($presupuestoEntity->total_costes+$presupuestoEntity->total_margenes),0)) ?>%</dd> <dd id="porcentajeMargen" class="col-3 text-end py-1"><?= old('0', round(($presupuestoEntity->total_costes+$presupuestoEntity->total_margenes)>0? 100*$presupuestoEntity->total_margenes/($presupuestoEntity->total_costes+$presupuestoEntity->total_margenes) : 0,0)) ?>%</dd>
<dd id="totalMargenes" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenes) ?>€</dd> <dd id="totalMargenes" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenes) ?>€</dd>
</dl> </dl>
@ -64,9 +64,9 @@
<dt class="col-5 fw-normal text-end">Precio unidad</dt> <dt class="col-5 fw-normal text-end">Precio unidad</dt>
<dd id="precioUnidadPresupuesto" class="col-6 text-end mb-2"><?= old('0', $presupuestoEntity->total_precio_unidad) ?>€</dd> <dd id="precioUnidadPresupuesto" class="col-6 text-end mb-2"><?= old('0', $presupuestoEntity->total_precio_unidad) ?>€</dd>
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor</dt> <dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor</dt>
<dd id="factor" class="col-6 text-end mb-2" style="font-size: smaller !important;"><?= old('0', $presupuestoEntity->total_factor) ?></dd> <dd id="factor" class="col-6 text-end mb-2" style="font-size: smaller !important;"><?= old('0', is_numeric($presupuestoEntity->total_factor) ? $presupuestoEntity->total_factor : 0) ?></dd>
<dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor Ponderado</dt> <dt class="col-5 fw-normal text-end" style="font-size: smaller !important;">Factor Ponderado</dt>
<dd id="factor_ponderado" class="col-6 text-end mb-0" style="font-size: smaller !important;"><?= old('0', $presupuestoEntity->total_factor_ponderado) ?></dd> <dd id="factor_ponderado" class="col-6 text-end mb-0" style="font-size: smaller !important;"><?= old('0', is_numeric($presupuestoEntity->total_factor_ponderado) ? $presupuestoEntity->total_factor_ponderado : 0) ?></dd>
</dl> </dl>
</div> </div>
<div class="d-grid float-end mb-4"> <div class="d-grid float-end mb-4">

View File

@ -198,7 +198,7 @@ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
var totalCostes = parseFloat(totalPapel.toFixed(2)) + parseFloat(totalImpresion.toFixed(2)) + parseFloat(totalServicios.toFixed(2)) + parseFloat(totalEnvios.toFixed(2)) var totalCostes = parseFloat(totalPapel.toFixed(2)) + parseFloat(totalImpresion.toFixed(2)) + parseFloat(totalServicios.toFixed(2)) + parseFloat(totalEnvios.toFixed(2))
var totalMargenes = parseFloat(margenPapel.toFixed(2)) + parseFloat(margenImpresion.toFixed(2)) + parseFloat(margenServicios.toFixed(2)) + parseFloat(margenEnvios.toFixed(2)) var totalMargenes = parseFloat(margenPapel.toFixed(2)) + parseFloat(margenImpresion.toFixed(2)) + parseFloat(margenServicios.toFixed(2)) + parseFloat(margenEnvios.toFixed(2))
var porcentajeMargen = (100*totalMargenes/(totalCostes+totalMargenes)).toFixed(0) var porcentajeMargen = totalCostes+totalMargenes>0? (100*totalMargenes/(totalCostes+totalMargenes)).toFixed(0) : 0
$('#totalCostes').text((addSeparatorsNF(totalCostes.toFixed(2), ".", ",", ".")) + "€") $('#totalCostes').text((addSeparatorsNF(totalCostes.toFixed(2), ".", ",", ".")) + "€")
$('#totalMargenes').text((addSeparatorsNF(totalMargenes.toFixed(2), ".", ",", ".")) + "€") $('#totalMargenes').text((addSeparatorsNF(totalMargenes.toFixed(2), ".", ",", ".")) + "€")
$('#totalCostes').attr('val',(totalCostes).toFixed(2) + '€') $('#totalCostes').attr('val',(totalCostes).toFixed(2) + '€')