FIX: Rejected missing

This commit is contained in:
Juan Pablo Vial
2025-09-11 16:58:35 -03:00
parent 5a60e79e47
commit 5e9f1240e7
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 {