Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix account validation
James Colefe8635f1ce6f
diff --git a/app/Validation/Account/DepositValidation.php b/app/Validation/Account/DepositValidation.phpindex 508708503b..236de1f6b3 100644--- a/app/Validation/Account/DepositValidation.php+++ b/app/Validation/Account/DepositValidation.php@@ -57,12 +57,13 @@ trait DepositValidation$result = 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 validateDepositDestination', $array);// source can be any of the following types.$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];- if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {+ if (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {// if both values are NULL we return false,// because the destination of a deposit can't be created.$this->destError = (string)trans('validation.deposit_dest_need_data');diff --git a/app/Validation/Account/TransferValidation.php b/app/Validation/Account/TransferValidation.phpindex 85a46715d9..4e42c5643a 100644--- a/app/Validation/Account/TransferValidation.php+++ b/app/Validation/Account/TransferValidation.php@@ -55,10 +55,11 @@ trait TransferValidation{$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);// source can be any of the following types.$validTypes = $this->combinations[$this->transactionType][$this->source->accountType->type] ?? [];- if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {+ if (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {// if both values are NULL we return false,// because the destination of a transfer can't be created.$this->destError = (string)trans('validation.transfer_dest_need_data');diff --git a/app/Validation/Account/WithdrawalValidation.php b/app/Validation/Account/WithdrawalValidation.phpindex 65566830fe..888d5e1375 100644--- a/app/Validation/Account/WithdrawalValidation.php+++ b/app/Validation/Account/WithdrawalValidation.php@@ -56,12 +56,13 @@ trait WithdrawalValidation{$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 validateGenericSource', $array);// source can be any of the following types.$validTypes = [AccountType::ASSET, AccountType::REVENUE, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];- if (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {+ if (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {// if both values are NULL we return TRUE- // because we assume the user doesnt want to submit / change anything.+ // because we assume the user doesn't want to submit / change anything.$this->sourceError = (string)trans('validation.withdrawal_source_need_data');app('log')->warning('[a] Not a valid source. Need more data.');diff --git a/resources/lang/en_US/validation.php b/resources/lang/en_US/validation.phpindex 7d2bba33da..b113b9352a 100644--- a/resources/lang/en_US/validation.php+++ b/resources/lang/en_US/validation.php@@ -204,31 +204,31 @@ return [// validation of accounts:'withdrawal_source_need_data' => 'Need to get a valid source account ID and/or valid source account name to continue.',- 'withdrawal_source_bad_data' => 'Could not find a valid source account when searching for ID ":id" or name ":name".',- 'withdrawal_dest_need_data' => 'Need to get a valid destination account ID and/or valid destination account name to continue.',+ 'withdrawal_source_bad_data' => '[a] Could not find a valid source account when searching for ID ":id" or name ":name".',+ 'withdrawal_dest_need_data' => '[a] Need to get a valid destination account ID and/or valid destination account name to continue.','withdrawal_dest_bad_data' => 'Could not find a valid destination account when searching for ID ":id" or name ":name".','reconciliation_source_bad_data' => 'Could not find a valid reconciliation account when searching for ID ":id" or name ":name".',- 'generic_source_bad_data' => 'Could not find a valid source account when searching for ID ":id" or name ":name".',+ 'generic_source_bad_data' => '[e] Could not find a valid source account when searching for ID ":id" or name ":name".','deposit_source_need_data' => 'Need to get a valid source account ID and/or valid source account name to continue.',- 'deposit_source_bad_data' => 'Could not find a valid source account when searching for ID ":id" or name ":name".',- 'deposit_dest_need_data' => 'Need to get a valid destination account ID and/or valid destination account name to continue.',+ 'deposit_source_bad_data' => '[b] Could not find a valid source account when searching for ID ":id" or name ":name".',+ 'deposit_dest_need_data' => '[b] Need to get a valid destination account ID and/or valid destination account name to continue.','deposit_dest_bad_data' => 'Could not find a valid destination account when searching for ID ":id" or name ":name".','deposit_dest_wrong_type' => 'The submitted destination account is not of the right type.',// Ignore this comment'transfer_source_need_data' => 'Need to get a valid source account ID and/or valid source account name to continue.',- 'transfer_source_bad_data' => 'Could not find a valid source account when searching for ID ":id" or name ":name".',- 'transfer_dest_need_data' => 'Need to get a valid destination account ID and/or valid destination account name to continue.',+ 'transfer_source_bad_data' => '[c] Could not find a valid source account when searching for ID ":id" or name ":name".',+ 'transfer_dest_need_data' => '[c] Need to get a valid destination account ID and/or valid destination account name to continue.','transfer_dest_bad_data' => 'Could not find a valid destination account when searching for ID ":id" or name ":name".','need_id_in_edit' => 'Each split must have transaction_journal_id (either valid ID or 0).','ob_source_need_data' => 'Need to get a valid source account ID and/or valid source account name to continue.','lc_source_need_data' => 'Need to get a valid source account ID to continue.',- 'ob_dest_need_data' => 'Need to get a valid destination account ID and/or valid destination account name to continue.',+ 'ob_dest_need_data' => '[d] Need to get a valid destination account ID and/or valid destination account name to continue.','ob_dest_bad_data' => 'Could not find a valid destination account when searching for ID ":id" or name ":name".','reconciliation_either_account' => 'To submit a reconciliation, you must submit either a source or a destination account. Not both, not neither.',