Merge branch 'fix/porcentaje_margen_total' into 'main'

añadido porcentaje al margen total

See merge request jjimenez/safekat!334
This commit is contained in:
2024-09-22 10:13:04 +00:00
2 changed files with 5 additions and 1 deletions

View File

@ -47,7 +47,8 @@
<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>
<dt class="col-5 fw-normal text-end">Total Margen</dt>
<dd id="totalMargenes" class="col-6 text-end"><?= old('0', $presupuestoEntity->total_margenes) ?></dd>
<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="totalMargenes" class="col-3 text-end py-1"><?= old('0', $presupuestoEntity->total_margenes) ?>€</dd>
</dl>
<hr class="mx-n4">

View File

@ -198,10 +198,13 @@ 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 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)
$('#totalCostes').text((addSeparatorsNF(totalCostes.toFixed(2), ".", ",", ".")) + "€")
$('#totalMargenes').text((addSeparatorsNF(totalMargenes.toFixed(2), ".", ",", ".")) + "€")
$('#totalCostes').attr('val',(totalCostes).toFixed(2) + '€')
$('#totalMargenes').attr('val',(totalMargenes).toFixed(2) + '€')
$('#porcentajeMargen').text(porcentajeMargen + '%')
$('#porcentajeMargen').attr('val',porcentajeMargen)
if($('#total_descuentoPercent').val()<0){
$('#total_descuentoPercent').val(0)