terminando servicios manipulados y preimpresion

This commit is contained in:
2023-12-04 20:50:58 +01:00
parent 76c815212f
commit ab6763aeaa
329 changed files with 811 additions and 59359 deletions

View File

@ -45,6 +45,90 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
];
public function getPrecioTarifa($tarifa_preimpresion_id){
$modelTarifa = model('App\Models\Tarifas\TarifapreimpresionModel');
$tarifa_value = $modelTarifa->getTarifaPresupuestoPreimpresion($tarifa_preimpresion_id);
if (count($tarifa_value)>0) {
$result_data = $this->calcularTarifa($tarifa_value[0]);
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_value[0]->tarifa_preimpresion_id,
'tarifa_nombre'=> $tarifa_value[0]->tarifa_preimpresion_nombre,
'precio'=> $result_data,
];
return $ret_array;
}
else{
$ret_array[] = (object)[
'tarifa_id'=> $tarifa_preimpresion_id,
'tarifa_nombre'=> $modelTarifa->getNombreTarifaPreimpresion($tarifa_preimpresion_id)[0]->nombre,
'precio' => 0,
];
return $ret_array;
}
return [];
}
private function calcularTarifa($tarifa){
$precio = floatval($tarifa->precio);
$precio = $precio * (1+ floatval($tarifa->margen)/100.0);
return $precio;
}
public function deleteAllServicios($presupuesto_id){
$this->db
->table($this->table . " t1")
->where('presupuesto_id', $presupuesto_id)
->delete();
}
public function deleteServiciosNotInArray($presupuesto_id, $tarifas_id){
$builder = $this->db
->table($this->table . " t1");
$builder->where('presupuesto_id', $presupuesto_id);
foreach($tarifas_id as $id){
$builder->where('tarifa_preimpresion_id !=', $id);
}
$builder->delete();
}
public function updateTarifas($presupuesto_id, $tarifas){
foreach($tarifas as $tarifa){
$builder = $this->db
->table($this->table . " t1");
$builder->select("id");
$builder->where('presupuesto_id', $presupuesto_id);
$builder->where('tarifa_preimpresion_id', $tarifa->tarifa_id);
$result = $builder->get()->getResultObject();
if(count($result)>0){
$this->db
->table($this->table . " t1")
->where('presupuesto_id', $presupuesto_id)
->where('tarifa_preimpresion_id', $tarifa->tarifa_id)
->set('precio', $tarifa->precio)
->update();
}
else{
$this->db
->table($this->table . " t1")
->set('presupuesto_id', $presupuesto_id)
->set('tarifa_preimpresion_id', $tarifa->tarifa_id)
->set('precio', $tarifa->precio)
->insert();
}
}
}
/**
* Get resource data.
*
@ -57,7 +141,7 @@ class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio_unidad AS precio_unidad, t1.precio_total AS precio_total, t2.nombre AS nombre"
"t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio AS precio, t2.nombre AS nombre"
);
$builder->where('t1.presupuesto_id', $presupuesto_id);