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

View File

@ -20,7 +20,7 @@ class PapelFormatoModel extends \App\Models\GoBaseModel
5 => "t1.updated_at", 5 => "t1.updated_at",
]; ];
protected $allowedFields = ["ancho", "alto"]; protected $allowedFields = ["ancho", "alto", "orden_select"];
protected $returnType = "App\Entities\Configuracion\PapelFormatoEntity"; protected $returnType = "App\Entities\Configuracion\PapelFormatoEntity";
protected $useTimestamps = true; protected $useTimestamps = true;
@ -91,6 +91,6 @@ class PapelFormatoModel extends \App\Models\GoBaseModel
->table($this->table . " t1") ->table($this->table . " t1")
->select( ->select(
"t1.id AS id, CONCAT(t1.ancho, ' x ', t1.alto) AS tamanio" "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('€', '')) margenImpresion = parseFloat($('#margenImpresion').text().replace('€', ''))
} }
sumForFactorPonderado = sumForFactor;
if(updateServicios){ if(updateServicios){
if ( typeof $("#tableOfServiciosEncuadernacion").DataTable() !== 'undefined' && $("#tableOfServiciosEncuadernacion").DataTable().rows().count() > 0){ if ( typeof $("#tableOfServiciosEncuadernacion").DataTable() !== 'undefined' && $("#tableOfServiciosEncuadernacion").DataTable().rows().count() > 0){
@ -119,15 +121,21 @@ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
} }
totalServicios -= margenServicios; totalServicios -= margenServicios;
sumForFactorPonderado += totalServicios;
var porcentajeMargenServicios = margenServicios/(margenServicios+totalServicios)*100 var porcentajeMargenServicios = margenServicios/(margenServicios+totalServicios)*100
$('#porcentajeMargenServicios').text(isNaN(porcentajeMargenServicios.toFixed(0))?0:porcentajeMargenServicios.toFixed(0) + '%') $('#porcentajeMargenServicios').text(isNaN(porcentajeMargenServicios.toFixed(0))?0:porcentajeMargenServicios.toFixed(0) + '%')
$('#totalServicios').text(totalServicios.toFixed(2) + '€') $('#totalServicios').text(totalServicios.toFixed(2) + '€')
$('#margenServicios').text(margenServicios.toFixed(2) + '€') $('#margenServicios').text(margenServicios.toFixed(2) + '€')
} }
else{ else{
totalServicios = parseFloat($('#totalServicios').text().replace('€', '')) totalServicios = parseFloat($('#totalServicios').text().replace('€', ''))
margenServicios = parseFloat($('#margenServicios').text().replace('€', '')) margenServicios = parseFloat($('#margenServicios').text().replace('€', ''))
sumForFactorPonderado += totalServicios;
} }
if(updateEnvio){ if(updateEnvio){
@ -168,7 +176,7 @@ function updateTotales(updateLP=true, updateServicios=true, updateEnvio=true){
$('#precioUnidadPresupuesto').text((precioUnidad).toFixed(2) + '€') $('#precioUnidadPresupuesto').text((precioUnidad).toFixed(2) + '€')
$('#factor').text(((totalPresupuesto-totalEnvios-margenEnvios)/sumForFactor).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(){ function getValuesResumenForm(){