Facturacion
This commit is contained in:
@ -15,35 +15,32 @@ class Unidad
|
||||
|
||||
public function getById(int $unidad_id): Model\Venta\Unidad
|
||||
{
|
||||
$unidad = $this->unidadRepository->fetchById($unidad_id);
|
||||
$this->fillPrecios($unidad);
|
||||
return $unidad;
|
||||
return $this->process($this->unidadRepository->fetchById($unidad_id));
|
||||
}
|
||||
public function getByVenta(int $venta_id): array
|
||||
{
|
||||
return array_map([$this, 'process'], $this->unidadRepository->fetchByVenta($venta_id));
|
||||
}
|
||||
public function getByPropiedad(int $propiedad_id): array
|
||||
{
|
||||
$unidades = $this->unidadRepository->fetchByPropiedad($propiedad_id);
|
||||
array_walk($unidades, [$this, 'fillPrecios']);
|
||||
return $unidades;
|
||||
return array_map([$this, 'process'], $this->unidadRepository->fetchByPropiedad($propiedad_id));
|
||||
}
|
||||
public function getByCierre(int $cierre_id): array
|
||||
{
|
||||
$unidades = $this->unidadRepository->fetchByCierre($cierre_id);
|
||||
array_walk($unidades, [$this, 'fillPrecios']);
|
||||
return $unidades;
|
||||
return array_map([$this, 'process'], $this->unidadRepository->fetchByCierre($cierre_id));
|
||||
}
|
||||
public function getDisponiblesByProyecto(int $proyecto_id): array
|
||||
{
|
||||
$unidades = $this->unidadRepository->fetchDisponiblesByProyecto($proyecto_id);
|
||||
//array_walk($unidades, [$this, 'fillPrecios']);
|
||||
return $unidades;
|
||||
return $this->unidadRepository->fetchDisponiblesByProyecto($proyecto_id);
|
||||
}
|
||||
|
||||
protected function fillPrecios(&$unidad): void
|
||||
protected function process($unidad): Model\Venta\Unidad
|
||||
{
|
||||
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