Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Possible fix for https://github.com/firefly-iii/firefly-iii/issues/7891
James Cole63297c43b769
diff --git a/app/Validation/Account/DepositValidation.php b/app/Validation/Account/DepositValidation.phpindex cfb3c3d032..3fc58764ac 100644--- a/app/Validation/Account/DepositValidation.php+++ b/app/Validation/Account/DepositValidation.php@@ -114,7 +114,11 @@ trait DepositValidation// 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 return false,// because the source of a deposit can't be created.// (this never happens).@@ -122,12 +126,12 @@ trait DepositValidation$result = false;}- // if there is an iban, it can only be in use by a revenue account or we will fail.+ // if there is an iban, it can only be in use by a revenue account, or we will fail.if (null !== $accountIban && '' !== $accountIban) {app('log')->debug('Check if there is not already an account with this IBAN');$existing = $this->findExistingAccount([AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE], ['iban' => $accountIban]);if (null !== $existing) {- $this->destError = (string)trans('validation.deposit_src_iban_exists');+ $this->sourceError = (string)trans('validation.deposit_src_iban_exists');return false;}}diff --git a/app/Validation/AccountValidator.php b/app/Validation/AccountValidator.phpindex 3e3027b8ae..159779fbd9 100644--- a/app/Validation/AccountValidator.php+++ b/app/Validation/AccountValidator.php@@ -265,6 +265,7 @@ class AccountValidatorif (null !== $accountId && $accountId > 0) {$first = $this->accountRepository->find($accountId);if ((null !== $first) && in_array($first->accountType->type, $validTypes, true)) {+ app('log')->debug(sprintf('ID: Found %s account #%d ("%s", IBAN "%s")', $first->accountType->type, $first->id, $first->name, $first->iban ?? 'no iban'));return $first;}}@@ -273,6 +274,7 @@ class AccountValidatorif (null !== $accountIban && '' !== (string)$accountIban) {$first = $this->accountRepository->findByIbanNull($accountIban, $validTypes);if ((null !== $first) && in_array($first->accountType->type, $validTypes, true)) {+ app('log')->debug(sprintf('Iban: Found %s account #%d ("%s", IBAN "%s")', $first->accountType->type, $first->id, $first->name, $first->iban ?? 'no iban'));return $first;}}@@ -281,14 +283,19 @@ class AccountValidatorif (null !== $accountNumber && '' !== (string)$accountNumber) {$first = $this->accountRepository->findByAccountNumber($accountNumber, $validTypes);if ((null !== $first) && in_array($first->accountType->type, $validTypes, true)) {+ app('log')->debug(sprintf('Number: Found %s account #%d ("%s", IBAN "%s")', $first->accountType->type, $first->id, $first->name, $first->iban ?? 'no iban'));return $first;}}// find by name:if ('' !== (string)$accountName) {- return $this->accountRepository->findByName($accountName, $validTypes);+ $first = $this->accountRepository->findByName($accountName, $validTypes);+ if (null !== $first) {+ app('log')->debug(sprintf('Name: Found %s account #%d ("%s", IBAN "%s")', $first->accountType->type, $first->id, $first->name, $first->iban ?? 'no iban'));+ }}+ app('log')->debug('Found nothing!');return null;}diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.phpindex 1c22bd17c1..c5cbc7224e 100644--- a/app/Validation/TransactionValidation.php+++ b/app/Validation/TransactionValidation.php@@ -103,6 +103,7 @@ trait TransactionValidation*/protected function validateSingleAccount(Validator $validator, int $index, string $transactionType, array $transaction): void{+ app('log')->debug(sprintf('Now in validateSingleAccount(%d)', $index));/** @var AccountValidator $accountValidator */$accountValidator = app(AccountValidator::class);@@ -203,7 +204,8 @@ trait TransactionValidationarray $transaction,string $transactionType,int $index- ): void {+ ): void+ {Log::debug('Now in sanityCheckForeignCurrency()');if (0 !== $validator->errors()->count()) {Log::debug('Already have errors, return');@@ -784,8 +786,8 @@ trait TransactionValidationprivate function compareAccountData(string $type, array $comparison): bool{return match ($type) {- default => $this->compareAccountDataWithdrawal($comparison),- 'deposit' => $this->compareAccountDataDeposit($comparison),+ default => $this->compareAccountDataWithdrawal($comparison),+ 'deposit' => $this->compareAccountDataDeposit($comparison),'transfer' => $this->compareAccountDataTransfer($comparison),};}