feature/cierres #31

Merged
aldarien merged 462 commits from feature/cierres into develop 2025-09-11 17:05:18 -03:00
2 changed files with 22 additions and 2 deletions

View File

@ -176,14 +176,28 @@ class Reservation extends Common\Ideal\Repository
*/
public function fetchRejected(int $project_id): array
{
$reservations = [];
$exceptions = [];
try {
return [
$reservations = [
...$reservations,
...$this->fetchState($project_id, Model\Venta\Reservation\State\Type::REJECTED->value),
];
} catch (InvalidState $exception) {
$exceptions[] = new Common\Implement\Exception\EmptyResult('No rejected reservations', $exception);
}
try {
$reservations = [
...$reservations,
...$this->fetchState($project_id, Model\Venta\Reservation\State\Type::CANCELLED->value)
];
} catch (InvalidState $exception) {
throw new Common\Implement\Exception\EmptyResult('Select rejected reservations', $exception);
$exceptions[] = new Common\Implement\Exception\EmptyResult('No cancelled reservations', $exception);
}
if (count($reservations) === 0) {
throw new Common\Implement\Exception\EmptyResult('No rejected nor cancelled reservations', last($exceptions));
}
return $reservations;
}
protected function saveUnits(Model\Venta\Reservation $reservation): void

View File

@ -222,6 +222,12 @@ class Reservation extends Ideal\Service\API
throw new ServiceAction\Update(__CLASS__, $exception);
}
}
/**
* @param Model\Venta\Reservation $reservation
* @return void
* @throws ServiceAction\Update
*/
public function reject(Model\Venta\Reservation $reservation): void
{
try {