Facturacion, se agrega PropiedadUnidad
This commit is contained in:
39
app/src/Service/Venta/PropiedadUnidad.php
Normal file
39
app/src/Service/Venta/PropiedadUnidad.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Venta;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
use Incoviba\Model;
|
||||
|
||||
class PropiedadUnidad
|
||||
{
|
||||
public function __construct(protected Repository\Venta\PropiedadUnidad $propiedadUnidadRepository, protected Precio $precioService) {}
|
||||
|
||||
public function getById(int $unidad_id): Model\Venta\PropiedadUnidad
|
||||
{
|
||||
return $this->process($this->propiedadUnidadRepository->fetchById($unidad_id));
|
||||
}
|
||||
public function getByVenta(int $venta_id): array
|
||||
{
|
||||
return array_map([$this, 'process'], $this->propiedadUnidadRepository->fetchByVenta($venta_id));
|
||||
}
|
||||
public function getByPropiedad(int $propiedad_id): array
|
||||
{
|
||||
return array_map([$this, 'process'], $this->propiedadUnidadRepository->fetchByPropiedad($propiedad_id));
|
||||
}
|
||||
public function edit(Model\Venta\PropiedadUnidad $propiedadUnidad, array $data): Model\Venta\PropiedadUnidad
|
||||
{
|
||||
return $this->process($this->propiedadUnidadRepository->edit($propiedadUnidad, $data));
|
||||
}
|
||||
|
||||
protected function process($unidad): Model\Venta\PropiedadUnidad
|
||||
{
|
||||
try {
|
||||
$unidad->precios = $this->precioService->getByUnidad($unidad->id);
|
||||
$unidad->currentPrecio = $this->precioService->getVigenteByUnidad($unidad->id);
|
||||
} catch (EmptyResult) {
|
||||
}
|
||||
return $unidad;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user