From f43b539470fbf784a57d850b1bf8797a8e7e9818 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 14 Jul 2023 06:07:16 +0200 Subject: [PATCH] Fix transfer validation for CAMT imports --- app/Validation/Account/TransferValidation.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Validation/Account/TransferValidation.php b/app/Validation/Account/TransferValidation.php index 766f63676d..603c1b836a 100644 --- a/app/Validation/Account/TransferValidation.php +++ b/app/Validation/Account/TransferValidation.php @@ -38,7 +38,7 @@ trait TransferValidation */ protected function validateTransferDestination(array $array): bool { - $accountId = array_key_exists('id', $array) ? $array['id'] : null; + $accountId = array_key_exists('id', $array) ? $array['id'] : null; $accountName = array_key_exists('name', $array) ? $array['name'] : null; $accountIban = array_key_exists('iban', $array) ? $array['iban'] : null; Log::debug('Now in validateTransferDestination', $array); @@ -65,7 +65,7 @@ trait TransferValidation // must not be the same as the source account if (null !== $this->source && $this->source->id === $this->destination->id) { $this->sourceError = 'Source and destination are the same.'; - $this->destError = 'Source and destination are the same.'; + $this->destError = 'Source and destination are the same.'; return false; } @@ -95,12 +95,16 @@ trait TransferValidation */ protected function validateTransferSource(array $array): bool { - $accountId = array_key_exists('id', $array) ? $array['id'] : null; + $accountId = array_key_exists('id', $array) ? $array['id'] : null; $accountName = array_key_exists('name', $array) ? $array['name'] : null; + $accountIban = array_key_exists('iban', $array) ? $array['iban'] : null; + $accountNumber = array_key_exists('number', $array) ? $array['number'] : null; Log::debug('Now in validateTransferSource', $array); // source can be any of the following types. $validTypes = array_keys($this->combinations[$this->transactionType]); - if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) { + if (null === $accountId && null === $accountName + && null === $accountIban && null === $accountNumber + && false === $this->canCreateTypes($validTypes)) { // if both values are NULL we return false, // because the source of a withdrawal can't be created. $this->sourceError = (string)trans('validation.transfer_source_need_data');