trabajando en los errores de calculo de tarifas

This commit is contained in:
2024-09-18 21:01:13 +02:00
parent 8777ce19c1
commit 5c72771fbe
6 changed files with 24 additions and 2 deletions

View File

@ -209,6 +209,7 @@ class ProveedorModel extends \App\Models\BaseModel
->select(
"t1.id AS value, t1.nombre AS label, t1.propiedades AS options")
->where("tipo_id", $tipoId)
->where("is_deleted", 0)
->orderBy('t1.nombre', 'asc');
return $builder->get()->getResultObject();

View File

@ -283,6 +283,13 @@ class PresupuestoAcabadosModel extends \App\Models\BaseModel
$total = $precio_unidad * $tirada;
$margen = floatval($tarifa->margen);
if($tarifa->tarifa_precio_min > $total){
$total = $total-($total * $margen/100.0);
$margen = round(100.0 * (floatval($tarifa->tarifa_precio_min) - $total) / floatval($tarifa->tarifa_precio_min), 0);
$total = floatval($tarifa->tarifa_precio_min);
$precio_unidad = round(floatval($total / $tirada), 2);
}
if (!$is_POD){
$total += floatval($tarifa->tarifa_importe_fijo);
}

View File

@ -78,6 +78,12 @@ class PresupuestoPreimpresionesModel extends \App\Models\BaseModel
$precio = $precio * (1+ floatval($tarifa->margen)/100.0);
$margen = $tarifa->margen;
if($tarifa->tarifa_precio_min > $precio){
$precio = $precio-($precio * $margen/100.0);
$margen = round(100.0 * (floatval($tarifa->tarifa_precio_min) - $precio) / floatval($tarifa->tarifa_precio_min), 0);
$precio = floatval($tarifa->tarifa_precio_min);
}
return [$precio, $margen];
}

View File

@ -78,6 +78,12 @@ class PresupuestoServiciosExtraModel extends \App\Models\BaseModel
$precio = $precio * (1+ floatval($tarifa->margen)/100.0);
$margen = $tarifa->margen;
if($tarifa->tarifa_precio_min > $precio){
$precio = $precio-($precio * $margen/100.0);
$margen = round(100.0 * (floatval($tarifa->tarifa_precio_min) - $precio) / floatval($tarifa->tarifa_precio_min), 0);
$precio = floatval($tarifa->tarifa_precio_min);
}
return [$precio, $margen];
}

View File

@ -101,7 +101,8 @@ class TarifaextraModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS tarifa_extra_id, t1.nombre AS tarifa_extra_nombre, t1.precio AS precio, t1.margen AS margen"
"t1.id AS tarifa_extra_id, t1.nombre AS tarifa_extra_nombre, t1.precio AS precio, t1.margen AS margen,
t1.precio_min AS tarifa_precio_min, t1.importe_fijo AS importe_fijo"
)
->where("t1.is_deleted", 0);
//->where("t1.mostrar_en_presupuesto", 1)

View File

@ -101,7 +101,8 @@ class TarifapreimpresionModel extends \App\Models\BaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS tarifa_preimpresion_id, t1.nombre AS tarifa_preimpresion_nombre, t1.precio AS precio, t1.margen AS margen"
"t1.id AS tarifa_preimpresion_id, t1.nombre AS tarifa_preimpresion_nombre, t1.precio AS precio, t1.margen AS margen,
t1.precio_min AS tarifa_precio_min, t1.importe_fijo AS importe_fijo"
)
->where("t1.is_deleted", 0);
//->where("t1.mostrar_en_presupuesto", 1)