Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Can no longer set currency of expense / revenue accounts.
James Coleabdb717b37c3
diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.phpindex 2307f93b10..4a67a1d87c 100644--- a/app/Factory/AccountFactory.php+++ b/app/Factory/AccountFactory.php@@ -288,18 +288,27 @@ class AccountFactory$fields = $this->validCCFields;}+ // remove currency_id if necessary.+ $type = $account->accountType->type;+ $list = config('firefly.valid_currency_account_types');+ if (!in_array($type, $list, true)) {+ $pos = array_search('currency_id', $fields);+ if ($pos !== false) {+ unset($fields[$pos]);+ }+ }+/** @var AccountMetaFactory $factory */$factory = app(AccountMetaFactory::class);foreach ($fields as $field) {// if the field is set but NULL, skip it.// if the field is set but "", update it.if (array_key_exists($field, $data) && null !== $data[$field]) {-// convert boolean value:if (is_bool($data[$field]) && false === $data[$field]) {$data[$field] = 0;}- if (is_bool($data[$field]) && true === $data[$field]) {+ if (true === $data[$field]) {$data[$field] = 1;}diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex ad05157167..40f28a9b43 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -486,6 +486,13 @@ class AccountRepository implements AccountRepositoryInterface*/public function getAccountCurrency(Account $account): ?TransactionCurrency{+ $type = $account->accountType->type;+ $list = config('firefly.valid_currency_account_types');++ // return null if not in this list.+ if(!in_array($type, $list, true)) {+ return null;+ }$currencyId = (int) $this->getMetaValue($account, 'currency_id');if ($currencyId > 0) {return TransactionCurrency::find($currencyId);diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.phpindex 1cea2563ff..23e40c8018 100644--- a/app/Services/Internal/Support/AccountServiceTrait.php+++ b/app/Services/Internal/Support/AccountServiceTrait.php@@ -115,6 +115,16 @@ trait AccountServiceTrait$fields = $this->validAssetFields;}+ // remove currency_id if necessary.+ $type = $account->accountType->type;+ $list = config('firefly.valid_currency_account_types');+ if(!in_array($type, $list, true)) {+ $pos = array_search('currency_id', $fields);+ if ($pos !== false) {+ unset($fields[$pos]);+ }+ }+// the account role may not be set in the data but we may have it already:if (!array_key_exists('account_role', $data)) {$data['account_role'] = null;diff --git a/config/firefly.php b/config/firefly.phpindex 6e177d6708..e1c81555f6 100644--- a/config/firefly.php+++ b/config/firefly.php@@ -209,6 +209,13 @@ return ['default_language' => envNonEmpty('DEFAULT_LANGUAGE', 'en_US'),'default_locale' => envNonEmpty('DEFAULT_LOCALE', 'equal'),+ // account types that may have or set a currency+ 'valid_currency_account_types' => [+ AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE,+ AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT,+ AccountType::RECONCILIATION+ ],+// "value must be in this list" values'valid_attachment_models' => [Account::class,