se modifica el calculo del factor ponderado y se añade orden al tamaño de papel

This commit is contained in:
Jaime Jiménez
2024-03-14 18:27:40 +01:00
parent da2a532336
commit 8eac04292d
3 changed files with 13 additions and 3 deletions

View File

@ -9,6 +9,7 @@ class PapelFormatoEntity extends \CodeIgniter\Entity\Entity
"id" => null,
"ancho" => null,
"alto" => null,
"orden_select" => null,
"is_deleted" => 0,
"deleted_at" => null,
"created_at" => null,
@ -17,6 +18,7 @@ class PapelFormatoEntity extends \CodeIgniter\Entity\Entity
protected $casts = [
"ancho" => "float",
"alto" => "float",
"orden_select" => "int",
"is_deleted" => "int",
];
}

View File

@ -20,7 +20,7 @@ class PapelFormatoModel extends \App\Models\GoBaseModel
5 => "t1.updated_at",
];
protected $allowedFields = ["ancho", "alto"];
protected $allowedFields = ["ancho", "alto", "orden_select"];
protected $returnType = "App\Entities\Configuracion\PapelFormatoEntity";
protected $useTimestamps = true;
@ -91,6 +91,6 @@ class PapelFormatoModel extends \App\Models\GoBaseModel
->table($this->table . " t1")
->select(
"t1.id AS id, CONCAT(t1.ancho, ' x ', t1.alto) AS tamanio"
)->where('is_deleted', 0)->get()->getResultObject();
)->where('is_deleted', 0)->orderBy('orden_select', 'asc')->get()->getResultObject();
}
}

View File

@ -74,6 +74,8 @@ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
margenImpresion = parseFloat($('#margenImpresion').text().replace('€', ''))
}
sumForFactorPonderado = sumForFactor;
if(updateServicios){
if ( typeof $("#tableOfServiciosEncuadernacion").DataTable() !== 'undefined' && $("#tableOfServiciosEncuadernacion").DataTable().rows().count() > 0){
@ -119,15 +121,21 @@ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
}
totalServicios -= margenServicios;
sumForFactorPonderado += totalServicios;
var porcentajeMargenServicios = margenServicios/(margenServicios+totalServicios)*100
$('#porcentajeMargenServicios').text(isNaN(porcentajeMargenServicios.toFixed(0))?0:porcentajeMargenServicios.toFixed(0) + '%')
$('#totalServicios').text(totalServicios.toFixed(2) + '€')
$('#margenServicios').text(margenServicios.toFixed(2) + '€')
}
else{
totalServicios = parseFloat($('#totalServicios').text().replace('€', ''))
margenServicios = parseFloat($('#margenServicios').text().replace('€', ''))
sumForFactorPonderado += totalServicios;
}
if(updateEnvio){
@ -168,7 +176,7 @@ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
$('#precioUnidadPresupuesto').text((precioUnidad).toFixed(2) + '€')
$('#factor').text(((totalPresupuesto-totalEnvios-margenEnvios)/sumForFactor).toFixed(2))
$('#factor_ponderado').text(((totalPresupuesto-totalEnvios-margenEnvios)/totalCostes).toFixed(2))
$('#factor_ponderado').text(((totalPresupuesto-totalEnvios-margenEnvios)/sumForFactorPonderado).toFixed(2))
}
function getValuesResumenForm(){