Files
oficial/app/src/Service/Venta/Cierre.php

40 lines
1.6 KiB
PHP
Raw Normal View History

2023-07-25 17:03:57 -04:00
<?php
namespace Incoviba\Service\Venta;
2023-07-25 17:03:57 -04:00
use Incoviba\Repository;
2023-07-28 16:22:20 -04:00
use Incoviba\Model;
2023-07-25 17:03:57 -04:00
class Cierre
{
public function __construct(
protected Repository\Venta\Cierre $cierreRepository,
protected Repository\Venta\EstadoCierre $estadoCierreRepository,
2023-07-28 16:22:20 -04:00
protected Repository\Venta\Unidad $unidadRepository,
protected Repository\Venta\ValorCierre $valorCierreRepository,
protected Repository\Venta\Precio $precioRepository
) {}
2023-07-25 17:03:57 -04:00
public function getByProyecto(int $proyecto_id): array
{
$cierres = $this->cierreRepository->fetchByProyecto($proyecto_id);
2025-03-03 14:57:22 -03:00
foreach ($cierres as $cierre) {
2023-07-25 17:03:57 -04:00
$cierre->estados = $this->estadoCierreRepository->fetchByCierre($cierre->id);
$cierre->current = $this->estadoCierreRepository->fetchCurrentByCierre($cierre->id);
$cierre->unidades = $this->unidadRepository->fetchByCierre($cierre->id);
}
return $cierres;
}
2023-07-28 16:22:20 -04:00
public function getById(int $cierre_id): Model\Venta\Cierre
{
$cierre = $this->cierreRepository->fetchById($cierre_id);
$cierre->estados = $this->estadoCierreRepository->fetchByCierre($cierre_id);
$cierre->current = $this->estadoCierreRepository->fetchCurrentByCierre($cierre_id);
$cierre->unidades = $this->unidadRepository->fetchByCierre($cierre_id);
2025-03-03 14:57:22 -03:00
foreach ($cierre->unidades as $unidad) {
2023-07-28 16:22:20 -04:00
$unidad->currentPrecio = $this->precioRepository->fetchByUnidadAndDate($unidad->id, $cierre->dateTime->format('Y-m-d'));
}
$cierre->valoresCierre = $this->valorCierreRepository->fetchByCierre($cierre_id);
return $cierre;
}
2023-07-25 17:03:57 -04:00
}