Merge pull request 'feature/cierres' (#31) from feature/cierres into develop
Reviewed-on: #31
This commit is contained in:
@ -176,14 +176,28 @@ class Reservation extends Common\Ideal\Repository
|
|||||||
*/
|
*/
|
||||||
public function fetchRejected(int $project_id): array
|
public function fetchRejected(int $project_id): array
|
||||||
{
|
{
|
||||||
|
$reservations = [];
|
||||||
|
$exceptions = [];
|
||||||
try {
|
try {
|
||||||
return [
|
$reservations = [
|
||||||
|
...$reservations,
|
||||||
...$this->fetchState($project_id, Model\Venta\Reservation\State\Type::REJECTED->value),
|
...$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)
|
...$this->fetchState($project_id, Model\Venta\Reservation\State\Type::CANCELLED->value)
|
||||||
];
|
];
|
||||||
} catch (InvalidState $exception) {
|
} 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
|
protected function saveUnits(Model\Venta\Reservation $reservation): void
|
||||||
|
@ -222,6 +222,12 @@ class Reservation extends Ideal\Service\API
|
|||||||
throw new ServiceAction\Update(__CLASS__, $exception);
|
throw new ServiceAction\Update(__CLASS__, $exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Model\Venta\Reservation $reservation
|
||||||
|
* @return void
|
||||||
|
* @throws ServiceAction\Update
|
||||||
|
*/
|
||||||
public function reject(Model\Venta\Reservation $reservation): void
|
public function reject(Model\Venta\Reservation $reservation): void
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user