Facturacion

This commit is contained in:
2023-11-22 19:08:19 -03:00
parent b4742a501e
commit 9ab0515954
45 changed files with 1846 additions and 71 deletions

View File

@ -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;
}
}