From abdb717b37c34da52b9c2b272f4314800318cd8f Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 23 Oct 2022 14:46:26 +0200 Subject: [PATCH 01/20] Can no longer set currency of expense / revenue accounts. --- app/Factory/AccountFactory.php | 13 +++++++++++-- app/Repositories/Account/AccountRepository.php | 7 +++++++ .../Internal/Support/AccountServiceTrait.php | 10 ++++++++++ config/firefly.php | 7 +++++++ 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.php index 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.php index 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.php index 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.php index 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, From 2f66315416bead1c211ee0b024576bba7eceafa8 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 23 Oct 2022 14:53:13 +0200 Subject: [PATCH 02/20] Fix #6556 --- app/Http/Controllers/Chart/BillController.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php index 6ba30c5dec..ff1782f1b5 100644 --- a/app/Http/Controllers/Chart/BillController.php +++ b/app/Http/Controllers/Chart/BillController.php @@ -31,7 +31,6 @@ use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Support\CacheProperties; use Illuminate\Http\JsonResponse; -use JsonException; /** * Class BillController. @@ -134,7 +133,7 @@ class BillController extends Controller } ); - $chartData = [ + $chartData = [ ['type' => 'line', 'label' => (string) trans('firefly.min-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'currency_code' => $bill->transactionCurrency->code, 'entries' => []], ['type' => 'line', 'label' => (string) trans('firefly.max-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, @@ -142,7 +141,7 @@ class BillController extends Controller ['type' => 'bar', 'label' => (string) trans('firefly.journal-amount'), 'currency_symbol' => $bill->transactionCurrency->symbol, 'currency_code' => $bill->transactionCurrency->code, 'entries' => []], ]; - + $currencyId = (int) $bill->transaction_currency_id; foreach ($journals as $journal) { $date = $journal['date']->isoFormat((string) trans('config.month_and_day_js', [], $locale)); $chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill @@ -152,7 +151,12 @@ class BillController extends Controller if (!array_key_exists($date, $chartData[2]['entries'])) { $chartData[2]['entries'][$date] = '0'; } - $amount = bcmul($journal['amount'], '-1'); + $amount = bcmul($journal['amount'], '-1'); + if ($currencyId === $journal['foreign_currency_id']) { + $amount = bcmul($journal['foreign_amount'], '-1'); + } + + $chartData[2]['entries'][$date] = bcadd($chartData[2]['entries'][$date], $amount); // amount of journal } From d4738b21abf9a573b7a7e5978c3fe4e7ce711f55 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 23 Oct 2022 17:36:26 +0200 Subject: [PATCH 03/20] Make sure form elements are not spell checked. --- resources/assets/js/components/passport/Clients.vue | 10 +++++----- .../js/components/passport/PersonalAccessTokens.vue | 2 +- .../js/components/transactions/AccountSelect.vue | 1 + resources/assets/js/components/transactions/Amount.vue | 2 +- .../assets/js/components/transactions/Category.vue | 1 + .../js/components/transactions/CustomAttachments.vue | 2 +- .../assets/js/components/transactions/CustomDate.vue | 2 +- .../assets/js/components/transactions/CustomString.vue | 2 +- .../assets/js/components/transactions/CustomUri.vue | 2 +- .../js/components/transactions/GroupDescription.vue | 1 + .../components/transactions/TransactionDescription.vue | 1 + resources/views/accounts/reconcile/index.twig | 8 ++++---- resources/views/auth/login.twig | 4 ++-- resources/views/auth/mfa.twig | 2 +- resources/views/auth/passwords/email.twig | 2 +- resources/views/auth/passwords/reset.twig | 6 +++--- resources/views/auth/register.twig | 6 +++--- resources/views/auth/two-factor.twig | 2 +- resources/views/layout/default.twig | 2 +- resources/views/profile/change-email.twig | 2 +- resources/views/profile/change-password.twig | 6 +++--- resources/views/profile/delete-account.twig | 2 +- resources/views/profile/logout-other-sessions.twig | 2 +- resources/views/search/index.twig | 2 +- resources/views/transactions/bulk/edit.twig | 8 ++++---- resources/views/transactions/mass/edit.twig | 6 +++--- 26 files changed, 45 insertions(+), 41 deletions(-) diff --git a/resources/assets/js/components/passport/Clients.vue b/resources/assets/js/components/passport/Clients.vue index edbfa9d982..68920664d5 100644 --- a/resources/assets/js/components/passport/Clients.vue +++ b/resources/assets/js/components/passport/Clients.vue @@ -127,7 +127,7 @@
- @@ -141,7 +141,7 @@
- @@ -214,7 +214,7 @@
- @@ -228,7 +228,7 @@
- @@ -268,7 +268,7 @@ {{ $t('firefly.profile_oauth_client_secret_expl') }}

- +
diff --git a/resources/assets/js/components/passport/PersonalAccessTokens.vue b/resources/assets/js/components/passport/PersonalAccessTokens.vue index bb490f85de..ffa0dea671 100644 --- a/resources/assets/js/components/passport/PersonalAccessTokens.vue +++ b/resources/assets/js/components/passport/PersonalAccessTokens.vue @@ -108,7 +108,7 @@
- +
diff --git a/resources/assets/js/components/transactions/AccountSelect.vue b/resources/assets/js/components/transactions/AccountSelect.vue index 5a84ccb7d1..ca3705c628 100644 --- a/resources/assets/js/components/transactions/AccountSelect.vue +++ b/resources/assets/js/components/transactions/AccountSelect.vue @@ -25,6 +25,7 @@
-
-
-
-
-
- +
{{ currency.symbol }} - +
@@ -55,13 +55,13 @@
- +
{{ currency.symbol }} - +
diff --git a/resources/views/auth/login.twig b/resources/views/auth/login.twig index 9a96d56365..936f695e08 100644 --- a/resources/views/auth/login.twig +++ b/resources/views/auth/login.twig @@ -57,11 +57,11 @@ {% if config('firefly.authentication_guard') == 'web' %} {% else %} - + {% endif %}
- +
diff --git a/resources/views/auth/mfa.twig b/resources/views/auth/mfa.twig index 9297a6d4f3..ddac6e5482 100644 --- a/resources/views/auth/mfa.twig +++ b/resources/views/auth/mfa.twig @@ -18,7 +18,7 @@
- +
diff --git a/resources/views/auth/passwords/email.twig b/resources/views/auth/passwords/email.twig index cbfdb62597..1f6e0d13f9 100644 --- a/resources/views/auth/passwords/email.twig +++ b/resources/views/auth/passwords/email.twig @@ -31,7 +31,7 @@
- +
diff --git a/resources/views/auth/passwords/reset.twig b/resources/views/auth/passwords/reset.twig index 50f3ee56fc..d323ae3308 100644 --- a/resources/views/auth/passwords/reset.twig +++ b/resources/views/auth/passwords/reset.twig @@ -20,15 +20,15 @@
- +
- +
- +
diff --git a/resources/views/auth/register.twig b/resources/views/auth/register.twig index 6c2aa714b3..75f715b661 100644 --- a/resources/views/auth/register.twig +++ b/resources/views/auth/register.twig @@ -19,13 +19,13 @@
- +
- +
- +
diff --git a/resources/views/auth/two-factor.twig b/resources/views/auth/two-factor.twig index 73fd2998ae..cfe9657ee0 100644 --- a/resources/views/auth/two-factor.twig +++ b/resources/views/auth/two-factor.twig @@ -22,7 +22,7 @@
- +
diff --git a/resources/views/layout/default.twig b/resources/views/layout/default.twig index aedf826479..d1039ef92f 100644 --- a/resources/views/layout/default.twig +++ b/resources/views/layout/default.twig @@ -101,7 +101,7 @@
diff --git a/resources/views/profile/delete-account.twig b/resources/views/profile/delete-account.twig index 5783b1d910..839380e039 100644 --- a/resources/views/profile/delete-account.twig +++ b/resources/views/profile/delete-account.twig @@ -38,7 +38,7 @@
- +
diff --git a/resources/views/profile/logout-other-sessions.twig b/resources/views/profile/logout-other-sessions.twig index 01a40dfd9d..4399b044c0 100644 --- a/resources/views/profile/logout-other-sessions.twig +++ b/resources/views/profile/logout-other-sessions.twig @@ -19,7 +19,7 @@
-
diff --git a/resources/views/search/index.twig b/resources/views/search/index.twig index a053d03b20..56dd35ab2e 100644 --- a/resources/views/search/index.twig +++ b/resources/views/search/index.twig @@ -20,7 +20,7 @@
-
diff --git a/resources/views/transactions/bulk/edit.twig b/resources/views/transactions/bulk/edit.twig index 509a35838f..223b50788b 100644 --- a/resources/views/transactions/bulk/edit.twig +++ b/resources/views/transactions/bulk/edit.twig @@ -60,8 +60,8 @@ ({{ formatAmountBySymbol(journal.foreign_amount, journal.foreign_currency_symbol, journal.foreign_currency_decimal_places) }}) {% endif %} {% endif %} - - + + {{ journal.date.isoFormat(monthAndDayFormat) }} @@ -104,7 +104,7 @@ {{ trans('list.category') }} - +
@@ -136,7 +136,7 @@ {{ trans('list.tags') }} - +
diff --git a/resources/views/transactions/mass/edit.twig b/resources/views/transactions/mass/edit.twig index 6dca509a69..0402ecc3c7 100644 --- a/resources/views/transactions/mass/edit.twig +++ b/resources/views/transactions/mass/edit.twig @@ -111,7 +111,7 @@ {# SOURCE ACCOUNT NAME FOR DEPOSIT #} {% if journal.transaction_type_type == 'Deposit' %} - @@ -141,7 +141,7 @@ {# category #} - {# budget #} From b3895a04a0280acbd447f88f5112ba7712e8739f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 03:01:42 +0000 Subject: [PATCH 04/20] Bump laravel/framework from 9.36.2 to 9.36.4 Bumps [laravel/framework](https://github.com/laravel/framework) from 9.36.2 to 9.36.4. - [Release notes](https://github.com/laravel/framework/releases) - [Changelog](https://github.com/laravel/framework/blob/9.x/CHANGELOG.md) - [Commits](https://github.com/laravel/framework/compare/v9.36.2...v9.36.4) --- updated-dependencies: - dependency-name: laravel/framework dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- composer.lock | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/composer.lock b/composer.lock index 3282a6bc7f..4b1b188996 100644 --- a/composer.lock +++ b/composer.lock @@ -716,23 +716,23 @@ }, { "name": "doctrine/inflector", - "version": "2.0.5", + "version": "2.0.6", "source": { "type": "git", "url": "https://github.com/doctrine/inflector.git", - "reference": "ade2b3bbfb776f27f0558e26eed43b5d9fe1b392" + "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/inflector/zipball/ade2b3bbfb776f27f0558e26eed43b5d9fe1b392", - "reference": "ade2b3bbfb776f27f0558e26eed43b5d9fe1b392", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/d9d313a36c872fd6ee06d9a6cbcf713eaa40f024", + "reference": "d9d313a36c872fd6ee06d9a6cbcf713eaa40f024", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9", + "doctrine/coding-standard": "^10", "phpstan/phpstan": "^1.8", "phpstan/phpstan-phpunit": "^1.1", "phpstan/phpstan-strict-rules": "^1.3", @@ -787,7 +787,7 @@ ], "support": { "issues": "https://github.com/doctrine/inflector/issues", - "source": "https://github.com/doctrine/inflector/tree/2.0.5" + "source": "https://github.com/doctrine/inflector/tree/2.0.6" }, "funding": [ { @@ -803,7 +803,7 @@ "type": "tidelift" } ], - "time": "2022-09-07T09:01:28+00:00" + "time": "2022-10-20T09:10:12+00:00" }, { "name": "doctrine/lexer", @@ -1856,16 +1856,16 @@ }, { "name": "laravel/framework", - "version": "v9.36.2", + "version": "v9.36.4", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "0bcd350eec1974c9f912f129368587ef7e43722b" + "reference": "15ce569fd93124e8e2257c24e3ed85b9ef9951d6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/0bcd350eec1974c9f912f129368587ef7e43722b", - "reference": "0bcd350eec1974c9f912f129368587ef7e43722b", + "url": "https://api.github.com/repos/laravel/framework/zipball/15ce569fd93124e8e2257c24e3ed85b9ef9951d6", + "reference": "15ce569fd93124e8e2257c24e3ed85b9ef9951d6", "shasum": "" }, "require": { @@ -1877,7 +1877,7 @@ "fruitcake/php-cors": "^1.2", "laravel/serializable-closure": "^1.2.2", "league/commonmark": "^2.2", - "league/flysystem": "^3.0.16", + "league/flysystem": "^3.8.0", "monolog/monolog": "^2.0", "nesbot/carbon": "^2.62.1", "nunomaduro/termwind": "^1.13", @@ -1954,7 +1954,7 @@ "league/flysystem-read-only": "^3.3", "league/flysystem-sftp-v3": "^3.0", "mockery/mockery": "^1.5.1", - "orchestra/testbench-core": "^7.8", + "orchestra/testbench-core": "^7.11", "pda/pheanstalk": "^4.0", "phpstan/phpstan": "^1.4.7", "phpunit/phpunit": "^9.5.8", @@ -2038,7 +2038,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-10-18T18:46:20+00:00" + "time": "2022-10-20T16:11:03+00:00" }, { "name": "laravel/passport", @@ -2838,16 +2838,16 @@ }, { "name": "league/flysystem", - "version": "3.8.0", + "version": "3.10.1", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "3d2ed6215e096e900662bd8f993fc5ad81cc4135" + "reference": "9857d7208a94fc63c7bf09caf223280e59ac7274" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/3d2ed6215e096e900662bd8f993fc5ad81cc4135", - "reference": "3d2ed6215e096e900662bd8f993fc5ad81cc4135", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/9857d7208a94fc63c7bf09caf223280e59ac7274", + "reference": "9857d7208a94fc63c7bf09caf223280e59ac7274", "shasum": "" }, "require": { @@ -2863,7 +2863,7 @@ }, "require-dev": { "async-aws/s3": "^1.5", - "async-aws/simple-s3": "^1.0", + "async-aws/simple-s3": "^1.1", "aws/aws-sdk-php": "^3.198.1", "composer/semver": "^3.0", "ext-fileinfo": "*", @@ -2909,7 +2909,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.8.0" + "source": "https://github.com/thephpleague/flysystem/tree/3.10.1" }, "funding": [ { @@ -2925,7 +2925,7 @@ "type": "tidelift" } ], - "time": "2022-10-18T06:54:34+00:00" + "time": "2022-10-21T18:57:47+00:00" }, { "name": "league/fractal", From 3bdea437443ea83a796ffad4e64593434974b5fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Oct 2022 03:01:47 +0000 Subject: [PATCH 05/20] Bump doctrine/dbal from 3.4.5 to 3.5.0 Bumps [doctrine/dbal](https://github.com/doctrine/dbal) from 3.4.5 to 3.5.0. - [Release notes](https://github.com/doctrine/dbal/releases) - [Commits](https://github.com/doctrine/dbal/compare/3.4.5...3.5.0) --- updated-dependencies: - dependency-name: doctrine/dbal dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- composer.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/composer.lock b/composer.lock index 3282a6bc7f..3db4902b69 100644 --- a/composer.lock +++ b/composer.lock @@ -470,23 +470,23 @@ }, { "name": "doctrine/dbal", - "version": "3.4.5", + "version": "3.5.0", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "a5a58773109c0abb13e658c8ccd92aeec8d07f9e" + "reference": "b66f55c7037402d9f522f19d86841e71c09f0195" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/a5a58773109c0abb13e658c8ccd92aeec8d07f9e", - "reference": "a5a58773109c0abb13e658c8ccd92aeec8d07f9e", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/b66f55c7037402d9f522f19d86841e71c09f0195", + "reference": "b66f55c7037402d9f522f19d86841e71c09f0195", "shasum": "" }, "require": { "composer-runtime-api": "^2", "doctrine/cache": "^1.11|^2.0", "doctrine/deprecations": "^0.5.3|^1", - "doctrine/event-manager": "^1.0", + "doctrine/event-manager": "^1|^2", "php": "^7.4 || ^8.0", "psr/cache": "^1|^2|^3", "psr/log": "^1|^2|^3" @@ -494,14 +494,14 @@ "require-dev": { "doctrine/coding-standard": "10.0.0", "jetbrains/phpstorm-stubs": "2022.2", - "phpstan/phpstan": "1.8.3", - "phpstan/phpstan-strict-rules": "^1.3", - "phpunit/phpunit": "9.5.24", + "phpstan/phpstan": "1.8.10", + "phpstan/phpstan-strict-rules": "^1.4", + "phpunit/phpunit": "9.5.25", "psalm/plugin-phpunit": "0.17.0", "squizlabs/php_codesniffer": "3.7.1", "symfony/cache": "^5.4|^6.0", "symfony/console": "^4.4|^5.4|^6.0", - "vimeo/psalm": "4.27.0" + "vimeo/psalm": "4.29.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -561,7 +561,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.4.5" + "source": "https://github.com/doctrine/dbal/tree/3.5.0" }, "funding": [ { @@ -577,7 +577,7 @@ "type": "tidelift" } ], - "time": "2022-09-23T17:48:57+00:00" + "time": "2022-10-22T14:33:42+00:00" }, { "name": "doctrine/deprecations", From 83b8fdba05b3f9152dc93f0e68fd091fd3572cfa Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 24 Oct 2022 19:42:06 +0200 Subject: [PATCH 06/20] Fix #6564 --- resources/views/list/groups.twig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/views/list/groups.twig b/resources/views/list/groups.twig index d20f3288a2..bf74139cf7 100644 --- a/resources/views/list/groups.twig +++ b/resources/views/list/groups.twig @@ -56,7 +56,7 @@ title="{{ group.title }}">{{ group.title }} - + {% for sum in group.sums %} {% if group.transaction_type == 'Deposit' %} {{ formatAmountBySymbol(sum.amount*-1, sum.currency_symbol, sum.currency_decimal_places) }}{% if loop.index != group.sums|length %},{% endif %} @@ -75,7 +75,7 @@ {% else %}   {% endif %} - +