diff --git a/app/AccountancyModule/PaymentModule/presenters/PaymentPresenter.php b/app/AccountancyModule/PaymentModule/presenters/PaymentPresenter.php index b56e5f50f..975dcab9e 100644 --- a/app/AccountancyModule/PaymentModule/presenters/PaymentPresenter.php +++ b/app/AccountancyModule/PaymentModule/presenters/PaymentPresenter.php @@ -21,6 +21,7 @@ use App\AccountancyModule\PaymentModule\Factories\IPaymentNoteDialogFactory; use App\AccountancyModule\PaymentModule\Factories\IRemoveGroupDialogFactory; use DateTimeImmutable; +use Model\Common\UserNotFound; use Model\DTO\Payment\Payment; use Model\DTO\Payment\Person; use Model\ExcelService; @@ -250,8 +251,10 @@ public function handleComplete(int $pid): void $this->flashMessage('Platba byla zaplacena.'); } catch (PaymentClosed) { $this->flashMessage('Tato platba už je uzavřená', 'danger'); - } catch (InvalidOAuth $exc) { - $this->flashMessage($exc->getExplainedMessage(), 'danger'); + } catch (UserNotFound) { + $this->flashMessage('Uživatel nebyl nalezen', 'danger'); + } catch (PaymentNotFound) { + $this->flashMessage('Platba nebyla nalezena', 'danger'); } $this->redirect('this'); diff --git a/app/model/Bank/BankService.php b/app/model/Bank/BankService.php index 1164d0f2f..5cb7a1567 100644 --- a/app/model/Bank/BankService.php +++ b/app/model/Bank/BankService.php @@ -14,6 +14,7 @@ use Model\Payment\Group; use Model\Payment\Payment; use Model\Payment\Payment\Transaction; +use Model\Payment\PaymentClosed; use Model\Payment\Repositories\IBankAccountRepository; use Model\Payment\Repositories\IGroupRepository; use Model\Payment\Repositories\IPaymentRepository; @@ -141,6 +142,8 @@ private function resolvePairingIntervalStart(array $groups): ChronosDate * @param Payment[] $payments * * @return Payment[] + * + * @throws PaymentClosed */ private function markPaymentsAsComplete(array $transactions, array $payments): array { diff --git a/app/model/Payment/Payment.php b/app/model/Payment/Payment.php index 7c7429090..e71c928a1 100644 --- a/app/model/Payment/Payment.php +++ b/app/model/Payment/Payment.php @@ -163,6 +163,7 @@ public function update( $this->amount = $amount; } + /** @throws PaymentClosed */ private function complete(DateTimeImmutable $time): void { $this->checkNotClosed(); @@ -170,6 +171,7 @@ private function complete(DateTimeImmutable $time): void $this->closedAt = $time; } + /** @throws PaymentClosed */ public function completeManually(DateTimeImmutable $time, string $userFullName): void { $this->complete($time); @@ -177,6 +179,7 @@ public function completeManually(DateTimeImmutable $time, string $userFullName): $this->raise(new PaymentWasCompleted($this->id)); } + /** @throws PaymentClosed */ public function pairWithTransaction(DateTimeImmutable $time, Transaction $transaction): void { $this->complete($time); diff --git a/app/model/Payment/PaymentService.php b/app/model/Payment/PaymentService.php index 6422ac5e1..9a61ca4ea 100644 --- a/app/model/Payment/PaymentService.php +++ b/app/model/Payment/PaymentService.php @@ -9,6 +9,7 @@ use InvalidArgumentException; use Model\Common\Repositories\IParticipantRepository; use Model\Common\Repositories\IUserRepository; +use Model\Common\UserNotFound; use model\DTO\Participant\PaymentDetails; use Model\DTO\Payment as DTO; use model\Event\Exception\CampInvitationNotFound; @@ -24,6 +25,7 @@ use Model\Payment\MissingVariableSymbol; use Model\Payment\Payment; use Model\Payment\Payment\State; +use Model\Payment\PaymentClosed; use Model\Payment\PaymentNotFound; use Model\Payment\Repositories\IBankAccountRepository; use Model\Payment\Repositories\IGroupRepository; @@ -80,6 +82,11 @@ public function cancelPayment(int $pid): void $this->payments->save($payment); } + /** + * @throws PaymentClosed + * @throws UserNotFound + * @throws PaymentNotFound + */ public function completePayment(int $id): void { $payment = $this->payments->find($id);