Compare commits

..

90 Commits

Author SHA1 Message Date
github-actions
b58d809063 Auto commit for release 'develop' on 2024-12-31 2024-12-31 08:09:51 +01:00
James Cole
9e34314dbc Fix various issues with new features, nullpointers and missing checks. 2024-12-31 08:05:25 +01:00
github-actions
e4aa218b5f Auto commit for release 'v6.2.0-alpha.1' on 2024-12-30 2024-12-30 17:09:40 +01:00
github-actions
31722477d4 Merge branch 'develop' 2024-12-30 16:07:29 +00:00
github-actions
ec82105433 Auto commit for release 'develop' on 2024-12-30 2024-12-30 15:35:26 +01:00
James Cole
146e164f04 Back to 8. 2024-12-30 15:31:27 +01:00
James Cole
7d37c93988 Expand workflow. 2024-12-30 15:25:39 +01:00
James Cole
73dffacd9a Expand to support alpha and beta versions. 2024-12-30 12:23:50 +01:00
James Cole
d37304fa68 Fix available budgets. 2024-12-30 12:22:39 +01:00
James Cole
62f4da6063 Update available budgets code. 2024-12-30 10:51:34 +01:00
James Cole
760da08ab7 Update exchange rates. 2024-12-30 07:36:22 +01:00
James Cole
e68c4d4408 Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2024-12-30 07:36:12 +01:00
James Cole
46a200aa1f Fix broken variable. 2024-12-30 07:30:23 +01:00
James Cole
c422039335 Merge pull request #9589 from tasnim0tantawi/autocomplete-test
Autocomplete test - CurrencyControllerTest & ObjectGroupControllerTest
2024-12-30 07:18:05 +01:00
github-actions
0579c8565d Auto commit for release 'develop' on 2024-12-30 2024-12-30 04:12:18 +01:00
James Cole
9f25880a59 Clean up several endpoints with complex code. 2024-12-29 18:32:02 +01:00
James Cole
05f1819f7d Fix API convert to native. Still needs refactoring. 2024-12-29 14:24:20 +01:00
James Cole
fa2149f957 Update API to convert to native. 2024-12-29 13:47:48 +01:00
James Cole
c21a79e029 Better, but not perfect, currency switch. 2024-12-29 08:16:27 +01:00
James Cole
03e31ebb5e Clean up endpoint. 2024-12-29 06:36:49 +01:00
James Cole
3c20e5f3af Make sure integers are converted to strings because sqlite sucks. 2024-12-29 06:32:50 +01:00
James Cole
9a9dd9e075 Double fix. Not sure yet what causes this. 2024-12-29 06:17:29 +01:00
James Cole
7189986c03 Remove some debug logging. 2024-12-29 06:15:42 +01:00
James Cole
b407d8d315 Add usergroup, clean up some code. 2024-12-29 06:14:40 +01:00
James Cole
41fa2a6208 Include user group in test set. 2024-12-29 06:10:54 +01:00
James Cole
fe00c4c373 Fix unauthenticated get default currency. 2024-12-29 06:08:35 +01:00
James Cole
7248a76c63 Fix chart, expand changelog. 2024-12-29 05:58:12 +01:00
James Cole
ee3c618797 Fix https://github.com/firefly-iii/firefly-iii/issues/9586 2024-12-29 05:55:49 +01:00
James Cole
a1241ebedb Various multi-currency things in the autocomplete API. 2024-12-28 18:38:19 +01:00
James Cole
af78d998db Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2024-12-28 14:09:42 +01:00
James Cole
d96c235ffe Fix path 2024-12-28 14:09:22 +01:00
James Cole
79ca1b5f4e Change some CS fixer settings. 2024-12-28 14:08:34 +01:00
github-actions
0f68735e1c Auto commit for release 'develop' on 2024-12-28 2024-12-28 13:59:31 +01:00
James Cole
82abee37de Fix a string of text. 2024-12-28 13:45:45 +01:00
James Cole
507040f1fd Update various code for sqlite compatibility. 2024-12-28 13:36:25 +01:00
James Cole
42dc8486e9 Fix string. 2024-12-28 11:16:55 +01:00
github-actions
6c655634bc Auto commit for release 'develop' on 2024-12-28 2024-12-28 10:58:01 +01:00
James Cole
f2166b97b8 Various fixes for sqlite databases 2024-12-28 10:52:46 +01:00
James Cole
da88e02be0 Catch exception. 2024-12-28 07:47:32 +01:00
James Cole
0d56b7d251 Ignore error. Must test more with sqlite. 2024-12-28 07:39:39 +01:00
James Cole
0a089efcac Clean up commands. 2024-12-28 07:35:20 +01:00
James Cole
89ab360391 Remove reference to cacheable models 2024-12-28 07:10:33 +01:00
James Cole
2bd97d9a99 Remove references to laravel json api 2024-12-28 07:09:25 +01:00
James Cole
103b9056e4 Expand changelog, remove unused packages. 2024-12-28 06:55:17 +01:00
github-actions
23c4352c18 Auto commit for release 'develop' on 2024-12-27 2024-12-27 22:03:16 +01:00
James Cole
2dddaa36d5 Actions will default to php 8.4 2024-12-27 19:51:20 +01:00
James Cole
8ab7cf2388 Merge branch 'v6.2' into develop
# Conflicts:
#	composer.lock
#	config/firefly.php
#	package-lock.json
2024-12-27 19:50:05 +01:00
James Cole
f191086adb Enable cache again. 2024-12-27 19:47:35 +01:00
James Cole
68b446db18 Final changes. 2024-12-27 19:46:40 +01:00
James Cole
3d49d81856 Expand some multi currency things. 2024-12-27 16:36:01 +01:00
James Cole
96493425d1 Convert more of the budget view to native currency. 2024-12-27 13:42:48 +01:00
James Cole
419975285c Fix nullpointer 2024-12-27 13:02:23 +01:00
github-actions
aa5bde122e Auto commit for release 'branch-v6.2' on 2024-12-27 2024-12-27 12:43:57 +01:00
James Cole
0fa3c2bd8d Fix issue with prefilled piggy banks. 2024-12-27 12:39:26 +01:00
James Cole
b9249a4d96 Update commands. 2024-12-27 09:30:41 +01:00
James Cole
6638ca270f Merge branch 'v6.2' of github.com:firefly-iii/firefly-iii into v6.2 2024-12-27 07:36:37 +01:00
James Cole
9bfef892f8 Remove lots of debug logs 2024-12-27 07:36:30 +01:00
github-actions
32e5efec7c Auto commit for release 'branch-v6.2' on 2024-12-27 2024-12-27 07:29:17 +01:00
James Cole
36457455ca Rename and clean up commands. 2024-12-27 07:24:47 +01:00
James Cole
062c148e43 Rename all correction commands. 2024-12-27 06:56:08 +01:00
James Cole
2314ce8004 Refactor and renam commands. 2024-12-27 06:48:58 +01:00
James Cole
a3ff73903a Fix bad error message. 2024-12-27 05:44:03 +01:00
James Cole
7c8445707e Add moar debug. 2024-12-26 14:12:05 +01:00
James Cole
291e73da4b Rename bills to subscriptions 2024-12-26 13:41:57 +01:00
James Cole
286a29ca3e Display for bills. 2024-12-26 11:28:31 +01:00
github-actions
71cf6c6a5e Auto commit for release 'branch-v6.2' on 2024-12-26 2024-12-26 10:24:39 +01:00
James Cole
1e8f0adaf8 Fix broken account balance. 2024-12-26 10:20:40 +01:00
James Cole
33531244aa Merge branch 'v6.2' of github.com:firefly-iii/firefly-iii into v6.2
# Conflicts:
#	app/Http/Controllers/Chart/AccountController.php
#	app/Support/Steam.php
2024-12-26 09:19:04 +01:00
James Cole
06049a9a28 Update various pages, clean up some code. 2024-12-26 09:16:17 +01:00
James Cole
d313f5fdf5 Fix chart balance. 2024-12-26 08:53:16 +01:00
github-actions
f4868126c1 Auto commit for release 'branch-v6.2' on 2024-12-26 2024-12-26 05:25:46 +01:00
James Cole
00147e98dd Fix home chart. 2024-12-26 05:21:28 +01:00
James Cole
6d22663ca2 Fix charts and balances. 2024-12-26 05:11:32 +01:00
James Cole
756bb9cf5e Fix overview, skip chart for now. 2024-12-25 11:59:15 +01:00
James Cole
399d7968f5 Fix another null. 2024-12-25 08:30:00 +01:00
James Cole
966b68f42e Merge branch 'v6.2' of github.com:firefly-iii/firefly-iii into v6.2 2024-12-25 08:29:50 +01:00
James Cole
134c551c12 Remove some comments, add others. 2024-12-25 08:23:17 +01:00
github-actions
9aeca15355 Auto commit for release 'branch-v6.2' on 2024-12-25 2024-12-25 08:17:59 +01:00
James Cole
6c6d31830b Fix nullpointer 2024-12-25 08:14:07 +01:00
TasneemTantawy
5971d155ef fixed create authenticated user 2024-12-23 09:37:06 +03:00
James Cole
cea52c0ac7 Merge pull request #9571 from firefly-iii/dependabot/composer/develop/phpunit/phpunit-10.5.40
Bump phpunit/phpunit from 10.5.39 to 10.5.40
2024-12-23 07:02:55 +01:00
James Cole
1b33ff9c25 Merge pull request #9573 from firefly-iii/dependabot/npm_and_yarn/develop/i18next-24.2.0
Bump i18next from 24.1.2 to 24.2.0
2024-12-23 07:02:41 +01:00
James Cole
594ba205bb Merge pull request #9574 from firefly-iii/dependabot/npm_and_yarn/develop/vite-6.0.5
Bump vite from 6.0.3 to 6.0.5
2024-12-23 07:01:29 +01:00
dependabot[bot]
495f5c71c3 Bump vite from 6.0.3 to 6.0.5
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 6.0.3 to 6.0.5.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v6.0.5/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-23 03:12:47 +00:00
dependabot[bot]
7e80f607b7 Bump i18next from 24.1.2 to 24.2.0
Bumps [i18next](https://github.com/i18next/i18next) from 24.1.2 to 24.2.0.
- [Release notes](https://github.com/i18next/i18next/releases)
- [Changelog](https://github.com/i18next/i18next/blob/master/CHANGELOG.md)
- [Commits](https://github.com/i18next/i18next/compare/v24.1.2...v24.2.0)

---
updated-dependencies:
- dependency-name: i18next
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-23 03:12:31 +00:00
github-actions
d93732e451 Auto commit for release 'develop' on 2024-12-23 2024-12-23 04:12:14 +01:00
dependabot[bot]
1b57bc7889 Bump phpunit/phpunit from 10.5.39 to 10.5.40
Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 10.5.39 to 10.5.40.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/10.5.40/ChangeLog-10.5.md)
- [Commits](https://github.com/sebastianbergmann/phpunit/compare/10.5.39...10.5.40)

---
updated-dependencies:
- dependency-name: phpunit/phpunit
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-23 03:01:52 +00:00
TasneemTantawy
9e373a9b0d object group controller test 2024-12-22 16:29:56 +03:00
TasneemTantawy
4fb61646b4 currency controller test 2024-12-22 15:54:18 +03:00
github-actions
e2f1fc307f Auto commit for release 'develop' on 2024-12-18 2024-12-18 16:52:40 +01:00
288 changed files with 2982 additions and 4689 deletions

View File

@@ -29,7 +29,7 @@ $paths = [
$current . '/../../database', $current . '/../../database',
$current . '/../../routes', $current . '/../../routes',
$current . '/../../tests', $current . '/../../tests',
$current . '/../../resources/lang', $current . '/../../resources/lang/en_US',
]; ];
$finder = PhpCsFixer\Finder::create() $finder = PhpCsFixer\Finder::create()

View File

@@ -406,16 +406,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v3.65.0", "version": "v3.66.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f" "reference": "5f5f2a142ff36b93c41885bca29cc5f861c013e6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/79d4f3e77b250a7d8043d76c6af8f0695e8a469f", "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/5f5f2a142ff36b93c41885bca29cc5f861c013e6",
"reference": "79d4f3e77b250a7d8043d76c6af8f0695e8a469f", "reference": "5f5f2a142ff36b93c41885bca29cc5f861c013e6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -441,7 +441,7 @@
"symfony/polyfill-mbstring": "^1.28", "symfony/polyfill-mbstring": "^1.28",
"symfony/polyfill-php80": "^1.28", "symfony/polyfill-php80": "^1.28",
"symfony/polyfill-php81": "^1.28", "symfony/polyfill-php81": "^1.28",
"symfony/process": "^5.4 || ^6.0 || ^7.0", "symfony/process": "^5.4 || ^6.0 || ^7.0 <7.2",
"symfony/stopwatch": "^5.4 || ^6.0 || ^7.0" "symfony/stopwatch": "^5.4 || ^6.0 || ^7.0"
}, },
"require-dev": { "require-dev": {
@@ -497,7 +497,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.65.0" "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.66.0"
}, },
"funding": [ "funding": [
{ {
@@ -505,7 +505,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-11-25T00:39:24+00:00" "time": "2024-12-29T13:46:23+00:00"
}, },
{ {
"name": "psr/container", "name": "psr/container",
@@ -1369,12 +1369,12 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": { "branch-alias": {
"dev-main": "3.5-dev" "dev-main": "3.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
} }
}, },
"autoload": { "autoload": {
@@ -1517,12 +1517,12 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": { "branch-alias": {
"dev-main": "3.5-dev" "dev-main": "3.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
} }
}, },
"autoload": { "autoload": {
@@ -2246,16 +2246,16 @@
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v7.2.0", "version": "v7.1.8",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
"reference": "d34b22ba9390ec19d2dd966c40aa9e8462f27a7e" "reference": "42783370fda6e538771f7c7a36e9fa2ee3a84892"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/d34b22ba9390ec19d2dd966c40aa9e8462f27a7e", "url": "https://api.github.com/repos/symfony/process/zipball/42783370fda6e538771f7c7a36e9fa2ee3a84892",
"reference": "d34b22ba9390ec19d2dd966c40aa9e8462f27a7e", "reference": "42783370fda6e538771f7c7a36e9fa2ee3a84892",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -2287,7 +2287,7 @@
"description": "Executes commands in sub-processes", "description": "Executes commands in sub-processes",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": { "support": {
"source": "https://github.com/symfony/process/tree/v7.2.0" "source": "https://github.com/symfony/process/tree/v7.1.8"
}, },
"funding": [ "funding": [
{ {
@@ -2303,7 +2303,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-11-06T14:24:19+00:00" "time": "2024-11-06T14:23:19+00:00"
}, },
{ {
"name": "symfony/service-contracts", "name": "symfony/service-contracts",
@@ -2329,12 +2329,12 @@
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": { "branch-alias": {
"dev-main": "3.5-dev" "dev-main": "3.5-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
} }
}, },
"autoload": { "autoload": {

View File

@@ -10,7 +10,7 @@ on:
phpversion: phpversion:
description: 'PHP version' description: 'PHP version'
required: true required: true
default: '8.3' default: '8.4'
schedule: schedule:
- cron: '0 3 * * MON' - cron: '0 3 * * MON'
@@ -168,7 +168,7 @@ jobs:
# if this is a develop build, slightly different variable names. # if this is a develop build, slightly different variable names.
if [[ "develop" == "$version" ]]; then if [[ "develop" == "$version" ]]; then
[[ -z $(git status --untracked-files=normal --porcelain) ]] && echo "this branch is clean, no need to push..." && exit 0; #[[ -z $(git status --untracked-files=normal --porcelain) ]] && echo "this branch is clean, no need to push..." && exit 0;
releaseName=$version-$(date +'%Y%m%d') releaseName=$version-$(date +'%Y%m%d')
originalName=$releaseName originalName=$releaseName
zipName=FireflyIII-develop.zip zipName=FireflyIII-develop.zip
@@ -177,7 +177,7 @@ jobs:
# if this is a branch build, also slightly different variable names. # if this is a branch build, also slightly different variable names.
if [[ "$version" == branch* ]]; then if [[ "$version" == branch* ]]; then
[[ -z $(git status --untracked-files=normal --porcelain) ]] && echo "this branch is clean, no need to push..." && exit 0; #[[ -z $(git status --untracked-files=normal --porcelain) ]] && echo "this branch is clean, no need to push..." && exit 0;
# branch builds overrule develop # branch builds overrule develop
releaseName=$version-$(date +'%Y%m%d') releaseName=$version-$(date +'%Y%m%d')
originalName=$releaseName originalName=$releaseName
@@ -229,7 +229,7 @@ jobs:
# describe the development release. # describe the development release.
if [[ "develop" == "$version" ]]; then if [[ "develop" == "$version" ]]; then
echo 'Develop release.' echo 'Develop release.'
rm output.txt rm -f output.txt
touch output.txt touch output.txt
sudo chown -R runner:docker output.txt sudo chown -R runner:docker output.txt
echo "Weekly development release of Firefly III with the latest fixes, translations and features. Docker users can find this release under the \`develop\` tag." >> output.txt echo "Weekly development release of Firefly III with the latest fixes, translations and features. Docker users can find this release under the \`develop\` tag." >> output.txt
@@ -244,7 +244,7 @@ jobs:
# describe a branch release # describe a branch release
if [[ "$version" == branch* ]]; then if [[ "$version" == branch* ]]; then
echo 'Branch release.' echo 'Branch release.'
rm output.txt rm -f output.txt
touch output.txt touch output.txt
sudo chown -R runner:docker output.txt sudo chown -R runner:docker output.txt
echo "Irregular BRANCH release of Firefly III. This release contains specific features or changes. Docker users can find this release under the \`$version\` tag." >> output.txt echo "Irregular BRANCH release of Firefly III. This release contains specific features or changes. Docker users can find this release under the \`$version\` tag." >> output.txt
@@ -257,9 +257,45 @@ jobs:
echo ":warning: Please be careful with this branch pre-release, as it may not work as expected." >> output.txt echo ":warning: Please be careful with this branch pre-release, as it may not work as expected." >> output.txt
fi fi
# describe the main release # describe the main release
if [[ "develop" != "$version" ]] && [[ "$version" != branch* ]]; then if [[ "develop" != "$version" ]] && [[ "$version" != branch* ]] && [[ "$version" != *alpha* ]] && [[ "$version" != *beta* ]]; then
sudo chown -R runner:docker output.txt
echo 'Main release.' echo 'Main release.'
sudo chown -R runner:docker output.txt
echo '' >> output.txt
echo '### Instructions' >> output.txt
echo '' >> output.txt
echo "* Installation instructions for [Docker](https://docs.firefly-iii.org/how-to/firefly-iii/installation/docker/), [Portainer](https://docs.firefly-iii.org/how-to/firefly-iii/installation/portainer/), [Kubernetes](https://docs.firefly-iii.org/how-to/firefly-iii/installation/kubernetes/) or [self-managed servers](https://docs.firefly-iii.org/how-to/firefly-iii/installation/self-managed/)" >> output.txt
echo "* Or read the upgrade instructions for [Docker](https://docs.firefly-iii.org/how-to/firefly-iii/upgrade/docker/), [Kubernetes](https://docs.firefly-iii.org/how-to/firefly-iii/upgrade/kubernetes/) or [self-managed servers](https://docs.firefly-iii.org/how-to/firefly-iii/upgrade/self-managed/)" >> output.txt
echo "* The releases are signed, and you can verify them using the [Firefly III releases PGP key](https://docs.firefly-iii.org/explanation/more-information/signatures/)." >> output.txt
fi
# describe alpha release
if [[ "$version" == *alpha* ]]; then
echo 'ALPHA release.'
rm -f output.txt
touch output.txt
sudo chown -R runner:docker output.txt
echo "Very early ALPHA release of Firefly III. This release contains specific features or changes. Docker users can find this release under the \`$version\` tag." >> output.txt
echo '' >> output.txt
echo "This release was created on **$(date +'%Y-%m-%d')** and may contain unexpected bugs. Data loss is rare but is not impossible. The releases are signed, and you can verify them using the [Firefly III releases PGP key](https://docs.firefly-iii.org/explanation/more-information/signatures/)." >> output.txt
echo '' >> output.txt
echo '### Instructions' >> output.txt
echo '' >> output.txt
echo "* Installation instructions for [Docker](https://docs.firefly-iii.org/how-to/firefly-iii/installation/docker/), [Portainer](https://docs.firefly-iii.org/how-to/firefly-iii/installation/portainer/), [Kubernetes](https://docs.firefly-iii.org/how-to/firefly-iii/installation/kubernetes/) or [self-managed servers](https://docs.firefly-iii.org/how-to/firefly-iii/installation/self-managed/)" >> output.txt
echo "* Or read the upgrade instructions for [Docker](https://docs.firefly-iii.org/how-to/firefly-iii/upgrade/docker/), [Kubernetes](https://docs.firefly-iii.org/how-to/firefly-iii/upgrade/kubernetes/) or [self-managed servers](https://docs.firefly-iii.org/how-to/firefly-iii/upgrade/self-managed/)" >> output.txt
echo "* The releases are signed, and you can verify them using the [Firefly III releases PGP key](https://docs.firefly-iii.org/explanation/more-information/signatures/)." >> output.txt
fi
# describe beta release
if [[ "$version" == *beta* ]]; then
echo 'BETA release.'
rm -f output.txt
touch output.txt
sudo chown -R runner:docker output.txt
echo "Very early BETA release of Firefly III. This release contains specific features or changes. Docker users can find this release under the \`$version\` tag." >> output.txt
echo '' >> output.txt
echo "This release was created on **$(date +'%Y-%m-%d')** and may contain unexpected bugs. Data loss is rare but is not impossible. The releases are signed, and you can verify them using the [Firefly III releases PGP key](https://docs.firefly-iii.org/explanation/more-information/signatures/)." >> output.txt
echo '' >> output.txt echo '' >> output.txt
echo '### Instructions' >> output.txt echo '### Instructions' >> output.txt
echo '' >> output.txt echo '' >> output.txt
@@ -336,12 +372,12 @@ jobs:
gh release upload $releaseName HEAD.txt gh release upload $releaseName HEAD.txt
# remove all temporary files # remove all temporary files
rm output.txt rm -f output.txt
rm HEAD.txt rm -f HEAD.txt
rm $zipName rm -f $zipName
rm $zipName.sha256 rm -f $zipName.sha256
rm $tarName rm -f $tarName
rm $tarName.sha256 rm -f $tarName.sha256
# merge main back into develop # merge main back into develop
git checkout develop git checkout develop

View File

@@ -19,7 +19,7 @@ jobs:
- name: Setup PHP with Xdebug - name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: '8.3' php-version: '8.4'
coverage: xdebug coverage: xdebug
extensions: >- extensions: >-
bcmath bcmath

View File

@@ -4,6 +4,7 @@ Over time, many people have contributed to Firefly III. Their efforts are not al
Please find below all the people who contributed to the Firefly III code. Their names are mentioned in the year of their first contribution. Please find below all the people who contributed to the Firefly III code. Their names are mentioned in the year of their first contribution.
## 2024 ## 2024
- TasneemTantawy
- Antônio Franco - Antônio Franco
- yparitcher - yparitcher
- Jhon Pedroza - Jhon Pedroza

View File

@@ -26,9 +26,9 @@ namespace FireflyIII\Api\V1\Controllers\Autocomplete;
use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest; use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Facades\Steam; use FireflyIII\Support\Facades\Steam;
use FireflyIII\Support\Http\Api\AccountFilter; use FireflyIII\Support\Http\Api\AccountFilter;
@@ -62,7 +62,7 @@ class AccountController extends Controller
return $next($request); return $next($request);
} }
); );
$this->balanceTypes = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]; $this->balanceTypes = [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
} }
/** /**
@@ -74,27 +74,27 @@ class AccountController extends Controller
*/ */
public function accounts(AutocompleteRequest $request): JsonResponse public function accounts(AutocompleteRequest $request): JsonResponse
{ {
$data = $request->getData(); $data = $request->getData();
$types = $data['types']; $types = $data['types'];
$query = $data['query']; $query = $data['query'];
$date = $data['date'] ?? today(config('app.timezone')); $date = $data['date'] ?? today(config('app.timezone'));
$return = []; $return = [];
$result = $this->repository->searchAccount((string) $query, $types, $this->parameters->get('limit')); $result = $this->repository->searchAccount((string) $query, $types, $this->parameters->get('limit'));
// TODO this code is duplicated in the V2 Autocomplete controller, which means this code is due to be deprecated.
$defaultCurrency = app('amount')->getDefaultCurrency();
/** @var Account $account */ /** @var Account $account */
foreach ($result as $account) { foreach ($result as $account) {
$nameWithBalance = $account->name; $nameWithBalance = $account->name;
$currency = $this->repository->getAccountCurrency($account) ?? $defaultCurrency; $currency = $this->repository->getAccountCurrency($account) ?? $this->defaultCurrency;
$useCurrency = $currency;
if (in_array($account->accountType->type, $this->balanceTypes, true)) { if (in_array($account->accountType->type, $this->balanceTypes, true)) {
$balance = Steam::finalAccountBalance($account, $date); $balance = Steam::finalAccountBalance($account, $date);
$key = $this->convertToNative && $currency->id !== $this->defaultCurrency->id ? 'native_balance' : 'balance';
$useCurrency = $this->convertToNative && $currency->id !== $this->defaultCurrency->id ? $this->defaultCurrency : $currency;
$amount = $balance[$key] ?? '0';
$nameWithBalance = sprintf( $nameWithBalance = sprintf(
'%s (%s)', '%s (%s)',
$account->name, $account->name,
app('amount')->formatAnything($currency, $balance['balance'], false) app('amount')->formatAnything($useCurrency, $amount, false)
); );
} }
@@ -103,11 +103,11 @@ class AccountController extends Controller
'name' => $account->name, 'name' => $account->name,
'name_with_balance' => $nameWithBalance, 'name_with_balance' => $nameWithBalance,
'type' => $account->accountType->type, 'type' => $account->accountType->type,
'currency_id' => (string) $currency->id, 'currency_id' => (string) $useCurrency->id,
'currency_name' => $currency->name, 'currency_name' => $useCurrency->name,
'currency_code' => $currency->code, 'currency_code' => $useCurrency->code,
'currency_symbol' => $currency->symbol, 'currency_symbol' => $useCurrency->symbol,
'currency_decimal_places' => $currency->decimal_places, 'currency_decimal_places' => $useCurrency->decimal_places,
]; ];
} }
@@ -115,7 +115,7 @@ class AccountController extends Controller
usort( usort(
$return, $return,
static function (array $left, array $right) { static function (array $left, array $right) {
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE]; $order = [AccountTypeEnum::ASSET->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::EXPENSE->value];
$posA = (int) array_search($left['type'], $order, true); $posA = (int) array_search($left['type'], $order, true);
$posB = (int) array_search($right['type'], $order, true); $posB = (int) array_search($right['type'], $order, true);

View File

@@ -27,9 +27,9 @@ namespace FireflyIII\Api\V1\Controllers\Chart;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Data\DateRequest; use FireflyIII\Api\V1\Requests\Data\DateRequest;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference; use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Http\Api\ApiSupport; use FireflyIII\Support\Http\Api\ApiSupport;
@@ -81,11 +81,10 @@ class AccountController extends Controller
$end = $dates['end']; $end = $dates['end'];
// user's preferences // user's preferences
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray(); $defaultSet = $this->repository->getAccountsByType([AccountTypeEnum::ASSET->value])->pluck('id')->toArray();
/** @var Preference $frontpage */ /** @var Preference $frontpage */
$frontpage = app('preferences')->get('frontpageAccounts', $defaultSet); $frontpage = app('preferences')->get('frontpageAccounts', $defaultSet);
$default = app('amount')->getDefaultCurrency();
if (!(is_array($frontpage->data) && count($frontpage->data) > 0)) { if (!(is_array($frontpage->data) && count($frontpage->data) > 0)) {
$frontpage->data = $defaultSet; $frontpage->data = $defaultSet;
@@ -98,10 +97,8 @@ class AccountController extends Controller
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
$currency = $this->repository->getAccountCurrency($account); $currency = $this->repository->getAccountCurrency($account) ?? $this->defaultCurrency;
if (null === $currency) { $field = $this->convertToNative && $currency->id !== $this->defaultCurrency->id ? 'native_balance' : 'balance';
$currency = $default;
}
$currentSet = [ $currentSet = [
'label' => $account->name, 'label' => $account->name,
'currency_id' => (string) $currency->id, 'currency_id' => (string) $currency->id,
@@ -116,13 +113,12 @@ class AccountController extends Controller
]; ];
// TODO this code is also present in the V2 chart account controller so this method is due to be deprecated. // TODO this code is also present in the V2 chart account controller so this method is due to be deprecated.
$currentStart = clone $start; $currentStart = clone $start;
$range = app('steam')->finalAccountBalanceInRange($account, $start, clone $end); $range = app('steam')->finalAccountBalanceInRange($account, $start, clone $end, $this->convertToNative);
// 2022-10-11 this method no longer converts to float. $previous = array_values($range)[0][$field];
$previous = array_values($range)[0];
while ($currentStart <= $end) { while ($currentStart <= $end) {
$format = $currentStart->format('Y-m-d'); $format = $currentStart->format('Y-m-d');
$label = $currentStart->toAtomString(); $label = $currentStart->toAtomString();
$balance = array_key_exists($format, $range) ? $range[$format]['balance'] : $previous; $balance = array_key_exists($format, $range) ? $range[$format][$field] : $previous;
$previous = $balance; $previous = $balance;
$currentStart->addDay(); $currentStart->addDay();
$currentSet['entries'][$label] = $balance; $currentSet['entries'][$label] = $balance;

View File

@@ -28,6 +28,9 @@ use Carbon\Carbon;
use Carbon\Exceptions\InvalidDateException; use Carbon\Exceptions\InvalidDateException;
use Carbon\Exceptions\InvalidFormatException; use Carbon\Exceptions\InvalidFormatException;
use FireflyIII\Models\Preference; use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Facades\Steam;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Bus\DispatchesJobs;
@@ -50,11 +53,13 @@ abstract class Controller extends BaseController
use DispatchesJobs; use DispatchesJobs;
use ValidatesRequests; use ValidatesRequests;
protected const string CONTENT_TYPE = 'application/vnd.api+json'; protected const string CONTENT_TYPE = 'application/vnd.api+json';
/** @var array<int, string> */ /** @var array<int, string> */
protected array $allowedSort; protected array $allowedSort;
protected ParameterBag $parameters; protected ParameterBag $parameters;
protected bool $convertToNative = false;
protected TransactionCurrency $defaultCurrency;
/** /**
* Controller constructor. * Controller constructor.
@@ -67,8 +72,11 @@ abstract class Controller extends BaseController
function ($request, $next) { function ($request, $next) {
$this->parameters = $this->getParameters(); $this->parameters = $this->getParameters();
if (auth()->check()) { if (auth()->check()) {
$language = app('steam')->getLanguage(); $language = Steam::getLanguage();
$this->convertToNative = Amount::convertToNative();
$this->defaultCurrency = Amount::getDefaultCurrency();
app()->setLocale($language); app()->setLocale($language);
} }
return $next($request); return $next($request);

View File

@@ -26,10 +26,10 @@ namespace FireflyIII\Api\V1\Controllers\Data;
use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Data\DestroyRequest; use FireflyIII\Api\V1\Requests\Data\DestroyRequest;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
@@ -66,9 +66,9 @@ class DestroyController extends Controller
$objects = $request->getObjects(); $objects = $request->getObjects();
$this->unused = $request->boolean('unused', false); $this->unused = $request->boolean('unused', false);
$allExceptAssets = [AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::RECONCILIATION, AccountType::REVENUE]; $allExceptAssets = [AccountTypeEnum::BENEFICIARY->value, AccountTypeEnum::CASH->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::EXPENSE->value, AccountTypeEnum::IMPORT->value, AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::LIABILITY_CREDIT->value, AccountTypeEnum::RECONCILIATION->value, AccountTypeEnum::REVENUE->value];
$all = [AccountType::ASSET, AccountType::BENEFICIARY, AccountType::CASH, AccountType::CREDITCARD, AccountType::DEBT, AccountType::DEFAULT, AccountType::EXPENSE, AccountType::IMPORT, AccountType::INITIAL_BALANCE, AccountType::LIABILITY_CREDIT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::RECONCILIATION]; $all = [AccountTypeEnum::ASSET->value, AccountTypeEnum::BENEFICIARY->value, AccountTypeEnum::CASH->value, AccountTypeEnum::CREDITCARD->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::DEFAULT->value, AccountTypeEnum::EXPENSE->value, AccountTypeEnum::IMPORT->value, AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::LIABILITY_CREDIT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::RECONCILIATION->value];
$liabilities = [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD]; $liabilities = [AccountTypeEnum::DEBT->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::CREDITCARD->value];
$transactions = [TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::DEPOSIT->value, TransactionTypeEnum::TRANSFER->value, TransactionTypeEnum::RECONCILIATION->value]; $transactions = [TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::DEPOSIT->value, TransactionTypeEnum::TRANSFER->value, TransactionTypeEnum::RECONCILIATION->value];
match ($objects) { match ($objects) {
@@ -82,9 +82,9 @@ class DestroyController extends Controller
'object_groups' => $this->destroyObjectGroups(), 'object_groups' => $this->destroyObjectGroups(),
'not_assets_liabilities' => $this->destroyAccounts($allExceptAssets), 'not_assets_liabilities' => $this->destroyAccounts($allExceptAssets),
'accounts' => $this->destroyAccounts($all), 'accounts' => $this->destroyAccounts($all),
'asset_accounts' => $this->destroyAccounts([AccountType::ASSET, AccountType::DEFAULT]), 'asset_accounts' => $this->destroyAccounts([AccountTypeEnum::ASSET->value, AccountTypeEnum::DEFAULT->value]),
'expense_accounts' => $this->destroyAccounts([AccountType::BENEFICIARY, AccountType::EXPENSE]), 'expense_accounts' => $this->destroyAccounts([AccountTypeEnum::BENEFICIARY->value, AccountTypeEnum::EXPENSE->value]),
'revenue_accounts' => $this->destroyAccounts([AccountType::REVENUE]), 'revenue_accounts' => $this->destroyAccounts([AccountTypeEnum::REVENUE->value]),
'liabilities' => $this->destroyAccounts($liabilities), 'liabilities' => $this->destroyAccounts($liabilities),
'transactions' => $this->destroyTransactions($transactions), 'transactions' => $this->destroyTransactions($transactions),
'withdrawals' => $this->destroyTransactions([TransactionTypeEnum::WITHDRAWAL->value]), 'withdrawals' => $this->destroyTransactions([TransactionTypeEnum::WITHDRAWAL->value]),

View File

@@ -29,7 +29,9 @@ use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface; use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Support\Facades\Amount;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
/** /**
* Class BillController * Class BillController
@@ -63,11 +65,13 @@ class BillController extends Controller
*/ */
public function bill(GenericRequest $request): JsonResponse public function bill(GenericRequest $request): JsonResponse
{ {
$accounts = $request->getAssetAccounts(); $accounts = $request->getAssetAccounts();
$bills = $request->getBills(); $bills = $request->getBills();
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $convertToNative = Amount::convertToNative();
$default = Amount::getDefaultCurrency();
$response = [];
// get all bills: // get all bills:
if (0 === $bills->count()) { if (0 === $bills->count()) {
@@ -75,17 +79,30 @@ class BillController extends Controller
} }
// collect all expenses in this period (regardless of type) by the given bills and accounts. // collect all expenses in this period (regardless of type) by the given bills and accounts.
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts); $collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
$collector->setBills($bills); $collector->setBills($bills);
$genericSet = $collector->getExtractedJournals(); $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) { foreach ($genericSet as $journal) {
$billId = (int) $journal['bill_id']; $billId = (int) $journal['bill_id'];
$currencyId = (int) $journal['currency_id']; $currencyId = (int) $journal['currency_id'];
$foreignCurrencyId = (int) $journal['foreign_currency_id']; $currencyCode = $journal['currency_code'];
$key = sprintf('%d-%d', $billId, $currencyId); $field = 'amount';
$foreignKey = sprintf('%d-%d', $billId, $foreignCurrencyId);
// use the native amount if the user wants to convert to native currency
if ($convertToNative && $currencyId !== $default->id) {
$currencyId = $default->id;
$currencyCode = $default->code;
$field = 'native_amount';
}
// use foreign amount when the foreign currency IS the default currency.
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
$field = 'foreign_amount';
}
Log::debug(sprintf('Journal #%d in bill #%d will use %s (%s %s)', $journal['transaction_group_id'], $billId, $field, $currencyCode, $journal[$field] ?? '0'));
$key = sprintf('%d-%d', $billId, $currencyId);
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$key] ??= [ $response[$key] ??= [
@@ -94,21 +111,11 @@ class BillController extends Controller
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string) $currencyId, 'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'], 'currency_code' => $currencyCode,
]; ];
$response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']); $response[$key]['difference'] = bcadd($response[$key]['difference'], (string) ($journal[$field] ?? '0'));
$response[$key]['difference_float'] = (float) $response[$key]['difference']; // intentional float $response[$key]['difference_float'] = (float) $response[$key]['difference']; // intentional float
} }
if (0 !== $foreignCurrencyId) {
$response[$foreignKey] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']);
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float
}
} }
return response()->json(array_values($response)); return response()->json(array_values($response));
@@ -122,42 +129,47 @@ class BillController extends Controller
*/ */
public function noBill(GenericRequest $request): JsonResponse public function noBill(GenericRequest $request): JsonResponse
{ {
$accounts = $request->getAssetAccounts(); $accounts = $request->getAssetAccounts();
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $convertToNative = Amount::convertToNative();
$default = Amount::getDefaultCurrency();
$response = [];
// collect all expenses in this period (regardless of type) by the given bills and accounts. // collect all expenses in this period (regardless of type) by the given bills and accounts.
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts); $collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
$collector->withoutBill(); $collector->withoutBill();
$genericSet = $collector->getExtractedJournals(); $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) { foreach ($genericSet as $journal) {
$currencyId = (int) $journal['currency_id']; $currencyId = (int) $journal['currency_id'];
$foreignCurrencyId = (int) $journal['foreign_currency_id']; $currencyCode = $journal['currency_code'];
$field = 'amount';
// use the native amount if the user wants to convert to native currency
if ($convertToNative && $currencyId !== $default->id) {
$currencyId = $default->id;
$currencyCode = $default->code;
$field = 'native_amount';
}
// use foreign amount when the foreign currency IS the default currency.
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
$field = 'foreign_amount';
}
Log::debug(sprintf('Journal #%d will use %s (%s %s)', $journal['transaction_group_id'], $field, $currencyCode, $journal[$field] ?? '0'));
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$currencyId] ??= [ $response[$currencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string) $currencyId, 'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'], 'currency_code' => $currencyCode,
]; ];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']); $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) ($journal[$field] ?? '0'));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float
} }
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // intentional float
}
} }
return response()->json(array_values($response)); return response()->json(array_values($response));

View File

@@ -28,7 +28,9 @@ use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Insight\GenericRequest; use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Support\Facades\Amount;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
/** /**
* Class PeriodController * Class PeriodController
@@ -41,39 +43,49 @@ class PeriodController extends Controller
*/ */
public function total(GenericRequest $request): JsonResponse public function total(GenericRequest $request): JsonResponse
{ {
$accounts = $request->getAssetAccounts(); $accounts = $request->getAssetAccounts();
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative();
$default = Amount::getDefaultCurrency();
// collect all expenses in this period (regardless of type) // collect all expenses in this period (regardless of type)
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts); $collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
$genericSet = $collector->getExtractedJournals(); $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) { foreach ($genericSet as $journal) {
$currencyId = (int) $journal['currency_id']; // same code as many other sumExpense methods. I think this needs some kind of generic method.
$foreignCurrencyId = (int) $journal['foreign_currency_id']; $amount = '0';
$currencyId = (int) $journal['currency_id'];
$currencyCode = $journal['currency_code'];
if ($convertToNative) {
$amount = Amount::getAmountFromJournal($journal);
if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) {
$currencyId = $default->id;
$currencyCode = $default->code;
}
if ($default->id !== (int) $journal['currency_id'] && $default->id === (int) $journal['foreign_currency_id']) {
$currencyId = $journal['foreign_currency_id'];
$currencyCode = $journal['foreign_currency_code'];
}
Log::debug(sprintf('[a] Add amount %s %s', $currencyCode, $amount));
}
if (!$convertToNative) {
// ignore the amount in foreign currency.
Log::debug(sprintf('[b] Add amount %s %s', $currencyCode, $journal['amount']));
$amount = $journal['amount'];
}
if (0 !== $currencyId) {
$response[$currencyId] ??= [ $response[$currencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string) $currencyId, 'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'], 'currency_code' => $currencyCode,
]; ];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']); $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $amount);
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // intentional float
}
} }
return response()->json(array_values($response)); return response()->json(array_values($response));

View File

@@ -29,7 +29,9 @@ use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface; use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Support\Facades\Amount;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Log;
/** /**
* Class TagController * Class TagController
@@ -62,42 +64,51 @@ class TagController extends Controller
*/ */
public function noTag(GenericRequest $request): JsonResponse public function noTag(GenericRequest $request): JsonResponse
{ {
$accounts = $request->getAssetAccounts(); $accounts = $request->getAssetAccounts();
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative();
$default = Amount::getDefaultCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts. // collect all expenses in this period (regardless of type) by the given bills and accounts.
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts); $collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
$collector->withoutTags(); $collector->withoutTags();
$genericSet = $collector->getExtractedJournals(); $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) { foreach ($genericSet as $journal) {
$currencyId = (int) $journal['currency_id']; // same code as many other sumExpense methods. I think this needs some kind of generic method.
$foreignCurrencyId = (int) $journal['foreign_currency_id']; $amount = '0';
$currencyId = (int) $journal['currency_id'];
$currencyCode = $journal['currency_code'];
if ($convertToNative) {
$amount = Amount::getAmountFromJournal($journal);
if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) {
$currencyId = $default->id;
$currencyCode = $default->code;
}
if ($default->id !== (int) $journal['currency_id'] && $default->id === (int) $journal['foreign_currency_id']) {
$currencyId = $journal['foreign_currency_id'];
$currencyCode = $journal['foreign_currency_code'];
}
Log::debug(sprintf('[a] Add amount %s %s', $currencyCode, $amount));
}
if (!$convertToNative) {
// ignore the amount in foreign currency.
Log::debug(sprintf('[b] Add amount %s %s', $currencyCode, $journal['amount']));
$amount = $journal['amount'];
}
if (0 !== $currencyId) { $response[$currencyId] ??= [
$response[$currencyId] ??= [ 'difference' => '0',
'difference' => '0', 'difference_float' => 0,
'difference_float' => 0, 'currency_id' => (string) $currencyId,
'currency_id' => (string) $currencyId, 'currency_code' => $currencyCode,
'currency_code' => $journal['currency_code'], ];
]; $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $amount);
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']); $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // float but on purpose.
}
} }
return response()->json(array_values($response)); return response()->json(array_values($response));

View File

@@ -73,6 +73,7 @@ class AccountController extends Controller
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$assetAccounts = $request->getAssetAccounts(); $assetAccounts = $request->getAssetAccounts();
$income = $this->opsRepository->sumIncomeByDestination($start, $end, $assetAccounts); $income = $this->opsRepository->sumIncomeByDestination($start, $end, $assetAccounts);
$result = []; $result = [];

View File

@@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Insight\GenericRequest; use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Support\Facades\Amount;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
/** /**
@@ -41,42 +42,41 @@ class PeriodController extends Controller
*/ */
public function total(GenericRequest $request): JsonResponse public function total(GenericRequest $request): JsonResponse
{ {
$accounts = $request->getAssetAccounts(); $accounts = $request->getAssetAccounts();
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative();
$default = Amount::getDefaultCurrency();
// collect all expenses in this period (regardless of type) // collect all expenses in this period (regardless of type)
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts); $collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts);
$genericSet = $collector->getExtractedJournals(); $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) { foreach ($genericSet as $journal) {
$currencyId = (int) $journal['currency_id']; // currency
$foreignCurrencyId = (int) $journal['foreign_currency_id']; $currencyId = $journal['currency_id'];
$currencyCode = $journal['currency_code'];
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
if (0 !== $currencyId) { // perhaps use default currency instead?
$response[$currencyId] ??= [ if ($convertToNative && $journal['currency_id'] !== $default->id) {
'difference' => '0', $currencyId = $default->id;
'difference_float' => 0, $currencyCode = $default->code;
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
} }
if (0 !== $foreignCurrencyId) { // use foreign amount when the foreign currency IS the default currency.
$response[$foreignCurrencyId] ??= [ if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
'difference' => '0', $field = 'foreign_amount';
'difference_float' => 0,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd(
$response[$foreignCurrencyId]['difference'],
app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // float but on purpose.
} }
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode,
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
} }
return response()->json(array_values($response)); return response()->json(array_values($response));

View File

@@ -29,6 +29,7 @@ use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface; use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Support\Facades\Amount;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
/** /**
@@ -63,45 +64,45 @@ class TagController extends Controller
*/ */
public function noTag(GenericRequest $request): JsonResponse public function noTag(GenericRequest $request): JsonResponse
{ {
$accounts = $request->getAssetAccounts(); $accounts = $request->getAssetAccounts();
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative();
$default = Amount::getDefaultCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts. // collect all expenses in this period (regardless of type) by the given bills and accounts.
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts); $collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts);
$collector->withoutTags(); $collector->withoutTags();
$genericSet = $collector->getExtractedJournals(); $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) { foreach ($genericSet as $journal) {
$currencyId = (int) $journal['currency_id']; // currency
$foreignCurrencyId = (int) $journal['foreign_currency_id']; $currencyId = $journal['currency_id'];
$currencyCode = $journal['currency_code'];
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
if (0 !== $currencyId) { // perhaps use default currency instead?
$response[$currencyId] ??= [ if ($convertToNative && $journal['currency_id'] !== $default->id) {
'difference' => '0', $currencyId = $default->id;
'difference_float' => 0, $currencyCode = $default->code;
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
} }
if (0 !== $foreignCurrencyId) { // use foreign amount when the foreign currency IS the default currency.
$response[$foreignCurrencyId] ??= [ if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
'difference' => '0', $field = 'foreign_amount';
'difference_float' => 0,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd(
$response[$foreignCurrencyId]['difference'],
app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
} }
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode,
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
} }
return response()->json(array_values($response)); return response()->json(array_values($response));

View File

@@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Insight\GenericRequest; use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Support\Facades\Amount;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
/** /**
@@ -41,42 +42,42 @@ class PeriodController extends Controller
*/ */
public function total(GenericRequest $request): JsonResponse public function total(GenericRequest $request): JsonResponse
{ {
$accounts = $request->getAssetAccounts(); $accounts = $request->getAssetAccounts();
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative();
$default = Amount::getDefaultCurrency();
// collect all expenses in this period (regardless of type) // collect all expenses in this period (regardless of type)
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts); $collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts);
$genericSet = $collector->getExtractedJournals(); $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) { foreach ($genericSet as $journal) {
$currencyId = (int) $journal['currency_id']; // currency
$foreignCurrencyId = (int) $journal['foreign_currency_id']; $currencyId = $journal['currency_id'];
$currencyCode = $journal['currency_code'];
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
if (0 !== $currencyId) { // perhaps use default currency instead?
$response[$currencyId] ??= [ if ($convertToNative && $journal['currency_id'] !== $default->id) {
'difference' => '0', $currencyId = $default->id;
'difference_float' => 0, $currencyCode = $default->code;
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
} }
if (0 !== $foreignCurrencyId) { // use foreign amount when the foreign currency IS the default currency.
$response[$foreignCurrencyId] ??= [ if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
'difference' => '0', $field = 'foreign_amount';
'difference_float' => 0,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd(
$response[$foreignCurrencyId]['difference'],
app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
} }
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode,
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
} }
return response()->json(array_values($response)); return response()->json(array_values($response));

View File

@@ -29,6 +29,7 @@ use FireflyIII\Api\V1\Requests\Insight\GenericRequest;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Tag\TagRepositoryInterface; use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Support\Facades\Amount;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
/** /**
@@ -61,45 +62,46 @@ class TagController extends Controller
*/ */
public function noTag(GenericRequest $request): JsonResponse public function noTag(GenericRequest $request): JsonResponse
{ {
$accounts = $request->getAssetAccounts(); $accounts = $request->getAssetAccounts();
$start = $request->getStart(); $start = $request->getStart();
$end = $request->getEnd(); $end = $request->getEnd();
$response = []; $response = [];
$convertToNative = Amount::convertToNative();
$default = Amount::getDefaultCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts. // collect all expenses in this period (regardless of type) by the given bills and accounts.
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts); $collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts);
$collector->withoutTags(); $collector->withoutTags();
$genericSet = $collector->getExtractedJournals(); $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) { foreach ($genericSet as $journal) {
$currencyId = (int) $journal['currency_id']; // currency
$foreignCurrencyId = (int) $journal['foreign_currency_id']; $currencyId = $journal['currency_id'];
$currencyCode = $journal['currency_code'];
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
if (0 !== $currencyId) { // perhaps use default currency instead?
$response[$currencyId] ??= [ if ($convertToNative && $journal['currency_id'] !== $default->id) {
'difference' => '0', $currencyId = $default->id;
'difference_float' => 0, $currencyCode = $default->code;
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
} }
if (0 !== $foreignCurrencyId) { // use foreign amount when the foreign currency IS the default currency.
$response[$foreignCurrencyId] ??= [ if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
'difference' => '0', $field = 'foreign_amount';
'difference_float' => 0,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd(
$response[$foreignCurrencyId]['difference'],
app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
} }
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string) $currencyId,
'currency_code' => $currencyCode,
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
} }
return response()->json(array_values($response)); return response()->json(array_values($response));

View File

@@ -105,19 +105,18 @@ class ShowController extends Controller
public function show(TransactionCurrency $currency): JsonResponse public function show(TransactionCurrency $currency): JsonResponse
{ {
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$manager = $this->getManager(); $manager = $this->getManager();
$defaultCurrency = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup); $this->parameters->set('defaultCurrency', $this->defaultCurrency);
$this->parameters->set('defaultCurrency', $defaultCurrency);
// update fields with user info. // update fields with user info.
$currency->refreshForUser($user); $currency->refreshForUser($user);
/** @var CurrencyTransformer $transformer */ /** @var CurrencyTransformer $transformer */
$transformer = app(CurrencyTransformer::class); $transformer = app(CurrencyTransformer::class);
$transformer->setParameters($this->parameters); $transformer->setParameters($this->parameters);
$resource = new Item($currency, $transformer, 'currencies'); $resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
} }
@@ -135,7 +134,7 @@ class ShowController extends Controller
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$manager = $this->getManager(); $manager = $this->getManager();
$currency = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup); $currency = $this->defaultCurrency;
// update fields with user info. // update fields with user info.
$currency->refreshForUser($user); $currency->refreshForUser($user);

View File

@@ -103,10 +103,10 @@ class BasicController extends Controller
$billData = $this->getBillInformation($start, $end); $billData = $this->getBillInformation($start, $end);
$spentData = $this->getLeftToSpendInfo($start, $end); $spentData = $this->getLeftToSpendInfo($start, $end);
$netWorthData = $this->getNetWorthInfo($start, $end); $netWorthData = $this->getNetWorthInfo($start, $end);
// $balanceData = []; // $balanceData = [];
// $billData = []; // $billData = [];
// $spentData = []; // $spentData = [];
// $netWorthData = []; // $netWorthData = [];
$total = array_merge($balanceData, $billData, $spentData, $netWorthData); $total = array_merge($balanceData, $billData, $spentData, $netWorthData);
// give new keys // give new keys
@@ -123,8 +123,8 @@ class BasicController extends Controller
private function getBalanceInformation(Carbon $start, Carbon $end): array private function getBalanceInformation(Carbon $start, Carbon $end): array
{ {
// some config settings // some config settings
$convertToNative = app('preferences')->get('convert_to_native', false)->data; $convertToNative = Amount::convertToNative();
$default = app('amount')->getDefaultCurrency(); $default = Amount::getDefaultCurrency();
// prep some arrays: // prep some arrays:
$incomes = []; $incomes = [];
$expenses = []; $expenses = [];
@@ -276,13 +276,13 @@ class BasicController extends Controller
*/ */
private function getLeftToSpendInfo(Carbon $start, Carbon $end): array private function getLeftToSpendInfo(Carbon $start, Carbon $end): array
{ {
Log::debug(sprintf('Now in getLeftToSpendInfo("%s", "%s")', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
$return = []; $return = [];
$today = today(config('app.timezone')); $today = today(config('app.timezone'));
$available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end); $available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end);
$budgets = $this->budgetRepository->getActiveBudgets(); $budgets = $this->budgetRepository->getActiveBudgets();
$spent = $this->opsRepository->sumExpenses($start, $end, null, $budgets); $spent = $this->opsRepository->sumExpenses($start, $end, null, $budgets);
$days = (int) $today->diffInDays($end, true) + 1; $days = (int) $today->diffInDays($end, true) + 1;
Log::debug(sprintf('Now in getLeftToSpendInfo("%s", "%s")', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
foreach ($spent as $row) { foreach ($spent as $row) {
// either an amount was budgeted or 0 is available. // either an amount was budgeted or 0 is available.

View File

@@ -118,7 +118,7 @@ class AccountController extends Controller
'native_entries' => [], 'native_entries' => [],
]; ];
$currentStart = clone $params['start']; $currentStart = clone $params['start'];
$range = app('steam')->finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $currency); $range = app('steam')->finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToNative);
$previous = array_values($range)[0]['balance']; $previous = array_values($range)[0]['balance'];
$previousNative = array_values($range)[0]['native_balance']; $previousNative = array_values($range)[0]['native_balance'];

View File

@@ -54,9 +54,10 @@ class Controller extends BaseController
{ {
use ValidatesUserGroupTrait; use ValidatesUserGroupTrait;
protected const string CONTENT_TYPE = 'application/vnd.api+json'; protected const string CONTENT_TYPE = 'application/vnd.api+json';
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY]; protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
protected ParameterBag $parameters; protected ParameterBag $parameters;
protected bool $convertToNative = false;
public function __construct() public function __construct()
{ {

View File

@@ -1,113 +0,0 @@
<?php
/*
* AccountController.php
* Copyright (c) 2024 james@firefly-iii.org.
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
declare(strict_types=1);
namespace FireflyIII\Api\V2\Controllers\JsonApi;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\JsonApi\V2\Accounts\AccountCollectionQuery;
use FireflyIII\JsonApi\V2\Accounts\AccountSchema;
use FireflyIII\JsonApi\V2\Accounts\AccountSingleQuery;
use FireflyIII\Models\Account;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Log;
use LaravelJsonApi\Core\Responses\DataResponse;
use LaravelJsonApi\Laravel\Http\Controllers\Actions;
/**
* Class AccountController
*
* This class handles api/v2 requests for accounts.
* Most stuff is default stuff.
*/
class AccountController extends Controller
{
use Actions\AttachRelationship;
use Actions\Destroy;
use Actions\DetachRelationship;
use Actions\FetchMany;
// use Actions\FetchOne;
use Actions\FetchRelated;
use Actions\FetchRelationship;
use Actions\Store;
use Actions\Update;
use Actions\UpdateRelationship;
/**
* Fetch zero to many JSON API resources.
*
* @return Responsable|Response
*/
public function index(AccountSchema $schema, AccountCollectionQuery $request)
{
Log::debug(__METHOD__);
$models = $schema
->repository()
->queryAll()
->withRequest($request)
->get()
;
// do something custom...
return new DataResponse($models);
}
/**
* Fetch zero to one JSON API resource by id.
*
* @return Responsable|Response
*/
public function show(AccountSchema $schema, AccountSingleQuery $request, Account $account)
{
Log::debug(__METHOD__);
$model = $schema->repository()
->queryOne($account)
->withRequest($request)
->first()
;
Log::debug(sprintf('%s again!', __METHOD__));
// do something custom...
return new DataResponse($model);
}
// public function readAccountBalances(AnonymousQuery $query, AccountBalanceSchema $schema, Account $account): Responsable
// {
// $schema = JsonApi::server()->schemas()->schemaFor('account-balances');
//
// $models = $schema
// ->repository()
// ->queryAll()
// ->withRequest($query)
// ->withAccount($account)
// ->get()
// ;
//
// return DataResponse::make($models);
// }
}

View File

@@ -25,7 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V2\Request\Chart; namespace FireflyIII\Api\V2\Request\Chart;
use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Support\Http\Api\ParsesQueryFilters;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait; use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
@@ -40,7 +39,6 @@ class ChartRequest extends FormRequest
{ {
use ChecksLogin; use ChecksLogin;
use ConvertsDataTypes; use ConvertsDataTypes;
use ParsesQueryFilters;
use ValidatesUserGroupTrait; use ValidatesUserGroupTrait;
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY]; protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];

View File

@@ -1,5 +1,25 @@
<?php <?php
/*
* ConvertsDatesToUTC.php
* Copyright (c) 2024 james@firefly-iii.org.
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
declare(strict_types=1); declare(strict_types=1);
/* /*
* ConvertDatesToUTC.php * ConvertDatesToUTC.php
@@ -21,7 +41,7 @@ declare(strict_types=1);
* along with this program. If not, see https://www.gnu.org/licenses/. * along with this program. If not, see https://www.gnu.org/licenses/.
*/ */
namespace FireflyIII\Console\Commands\Integrity; namespace FireflyIII\Console\Commands\Correction;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
@@ -31,7 +51,7 @@ use Illuminate\Database\QueryException;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class ConvertDatesToUTC extends Command class ConvertsDatesToUTC extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -47,13 +67,17 @@ class ConvertDatesToUTC extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'firefly-iii:migrate-to-utc'; protected $signature = 'correction:convert-to-utc';
/** /**
* Execute the console command. * Execute the console command.
*/ */
public function handle(): int public function handle(): int
{ {
$this->friendlyWarning('Please do not use this command.');
return 0;
/** /**
* @var string $model * @var string $model
* @var array $fields * @var array $fields

View File

@@ -4,10 +4,6 @@ namespace FireflyIII\Console\Commands\Correction;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/**
* Class CorrectionSkeleton
* TODO DONT FORGET TO ADD THIS TO THE DOCKER BUILD
*/
class CorrectionSkeleton extends Command class CorrectionSkeleton extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;

View File

@@ -29,15 +29,12 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class CorrectsAccountOrder extends Command
* Class FixAccountOrder
*/
class FixAccountOrder extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Make sure account order is correct.'; protected $description = 'Make sure account order is correct.';
protected $signature = 'firefly-iii:fix-account-order'; protected $signature = 'correction:account-order';
private AccountRepositoryInterface $repository; private AccountRepositoryInterface $repository;
@@ -54,8 +51,6 @@ class FixAccountOrder extends Command
$this->repository->resetAccountOrder(); $this->repository->resetAccountOrder();
} }
$this->friendlyPositive('All accounts are ordered correctly');
return 0; return 0;
} }

View File

@@ -36,15 +36,12 @@ use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Query\JoinClause; use Illuminate\Database\Query\JoinClause;
/** class CorrectsAccountTypes extends Command
* Class FixAccountTypes
*/
class FixAccountTypes extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Make sure all journals have the correct from/to account types.'; protected $description = 'Make sure all journals have the correct from/to account types.';
protected $signature = 'firefly-iii:fix-account-types'; protected $signature = 'correction:account-types';
private int $count; private int $count;
private array $expected; private array $expected;
private AccountFactory $factory; private AccountFactory $factory;
@@ -120,9 +117,6 @@ class FixAccountTypes extends Command
} }
} }
} }
if (0 === $this->count) {
$this->friendlyPositive('All account types are OK');
}
if (0 !== $this->count) { if (0 !== $this->count) {
app('log')->debug(sprintf('%d journals had to be fixed.', $this->count)); app('log')->debug(sprintf('%d journals had to be fixed.', $this->count));
$this->friendlyInfo(sprintf('Acted on %d transaction(s)', $this->count)); $this->friendlyInfo(sprintf('Acted on %d transaction(s)', $this->count));

View File

@@ -36,15 +36,12 @@ use FireflyIII\Models\RuleTrigger;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
/** class CorrectsAmounts extends Command
* Class ReportSkeleton
*/
class CorrectAmounts extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'This command makes sure positive and negative amounts are recorded correctly.'; protected $description = 'This command makes sure positive and negative amounts are recorded correctly.';
protected $signature = 'firefly-iii:fix-amount-pos-neg'; protected $signature = 'correction:amounts';
public function handle(): int public function handle(): int
{ {
@@ -72,7 +69,6 @@ class CorrectAmounts extends Command
{ {
$count = AutoBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); $count = AutoBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);
if (0 === $count) { if (0 === $count) {
$this->friendlyPositive('All auto budget amounts are positive.');
return; return;
} }
@@ -83,7 +79,6 @@ class CorrectAmounts extends Command
{ {
$count = AvailableBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); $count = AvailableBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);
if (0 === $count) { if (0 === $count) {
$this->friendlyPositive('All available budget amounts are positive.');
return; return;
} }
@@ -96,7 +91,6 @@ class CorrectAmounts extends Command
$count += Bill::where('amount_max', '<', 0)->update(['amount_max' => DB::raw('amount_max * -1')]); $count += Bill::where('amount_max', '<', 0)->update(['amount_max' => DB::raw('amount_max * -1')]);
$count += Bill::where('amount_min', '<', 0)->update(['amount_min' => DB::raw('amount_min * -1')]); $count += Bill::where('amount_min', '<', 0)->update(['amount_min' => DB::raw('amount_min * -1')]);
if (0 === $count) { if (0 === $count) {
$this->friendlyPositive('All bill amounts are positive.');
return; return;
} }
@@ -107,7 +101,6 @@ class CorrectAmounts extends Command
{ {
$count = BudgetLimit::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); $count = BudgetLimit::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);
if (0 === $count) { if (0 === $count) {
$this->friendlyPositive('All budget limit amounts are positive.');
return; return;
} }
@@ -118,7 +111,6 @@ class CorrectAmounts extends Command
{ {
$count = CurrencyExchangeRate::where('rate', '<', 0)->update(['rate' => DB::raw('rate * -1')]); $count = CurrencyExchangeRate::where('rate', '<', 0)->update(['rate' => DB::raw('rate * -1')]);
if (0 === $count) { if (0 === $count) {
$this->friendlyPositive('All currency exchange rates are positive.');
return; return;
} }
@@ -129,7 +121,6 @@ class CorrectAmounts extends Command
{ {
$count = PiggyBank::where('target_amount', '<', 0)->update(['target_amount' => DB::raw('target_amount * -1')]); $count = PiggyBank::where('target_amount', '<', 0)->update(['target_amount' => DB::raw('target_amount * -1')]);
if (0 === $count) { if (0 === $count) {
$this->friendlyPositive('All piggy bank amounts are positive.');
return; return;
} }
@@ -142,7 +133,6 @@ class CorrectAmounts extends Command
$count += RecurrenceTransaction::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); $count += RecurrenceTransaction::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]);
$count += RecurrenceTransaction::where('foreign_amount', '<', 0)->update(['foreign_amount' => DB::raw('foreign_amount * -1')]); $count += RecurrenceTransaction::where('foreign_amount', '<', 0)->update(['foreign_amount' => DB::raw('foreign_amount * -1')]);
if (0 === $count) { if (0 === $count) {
$this->friendlyPositive('All recurring transaction amounts are positive.');
return; return;
} }
@@ -165,7 +155,6 @@ class CorrectAmounts extends Command
} }
} }
if (0 === $fixed) { if (0 === $fixed) {
$this->friendlyPositive('All rule trigger amounts are positive.');
return; return;
} }

View File

@@ -37,15 +37,12 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Symfony\Component\Console\Command\Command as CommandAlias; use Symfony\Component\Console\Command\Command as CommandAlias;
/** class CorrectsCurrencies extends Command
* Class EnableCurrencies
*/
class EnableCurrencies extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Enables all currencies in use.'; protected $description = 'Enables all currencies in use.';
protected $signature = 'firefly-iii:enable-currencies'; protected $signature = 'correction:currencies';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -27,14 +27,11 @@ namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class CorrectsDatabase extends Command
* Class CorrectDatabase
*/
class CorrectDatabase extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Will correct the integrity of your database, if necessary.'; protected $description = 'Will validate and correct the integrity of your database, if necessary.';
protected $signature = 'firefly-iii:correct-database'; protected $signature = 'firefly-iii:correct-database';
/** /**
@@ -49,32 +46,36 @@ class CorrectDatabase extends Command
return 1; return 1;
} }
$commands = [ $commands = [
'firefly-iii:fix-piggies', 'correction:restore-oauth-keys',
'firefly-iii:create-link-types', 'correction:timezones',
'firefly-iii:create-access-tokens', 'correction:create-group-memberships',
'firefly-iii:remove-bills', 'correction:group-information',
'firefly-iii:fix-amount-pos-neg', 'correction:piggy-banks',
'firefly-iii:enable-currencies', 'correction:link-types',
'firefly-iii:fix-transfer-budgets', 'correction:access-tokens',
'firefly-iii:fix-uneven-amount', 'correction:bills',
'firefly-iii:delete-zero-amount', 'correction:amounts',
'firefly-iii:delete-orphaned-transactions', 'correction:currencies',
'firefly-iii:delete-empty-journals', 'correction:transfer-budgets',
'firefly-iii:delete-empty-groups', 'correction:uneven-amounts',
'firefly-iii:fix-account-types', 'correction:zero-amounts',
'firefly-iii:fix-ibans', 'correction:orphaned-transactions',
'firefly-iii:fix-account-order', 'correction:empty-journals',
'firefly-iii:rename-meta-fields', 'correction:empty-groups',
'firefly-iii:fix-ob-currencies', 'correction:account-types',
'firefly-iii:fix-long-descriptions', 'correction:ibans',
'firefly-iii:fix-recurring-transactions', 'correction:account-order',
'firefly-iii:upgrade-group-information', 'correction:meta-fields',
// 'firefly-iii:fix-transaction-types', // very resource heavy. 'correction:opening-balance-currencies',
'firefly-iii:fix-frontpage-accounts', 'correction:long-descriptions',
// new! 'correction:recurring-transactions',
'firefly-iii:unify-group-accounts', 'correction:frontpage-accounts',
'firefly-iii:trigger-credit-recalculation', 'correction:group-accounts',
'firefly-iii:migrate-preferences', 'correction:recalculates-liabilities',
'correction:preferences',
// 'correction:transaction-types', // resource heavy, disabled.
'correction:recalculate-native-amounts', // not necessary, disabled.
'firefly-iii:report-integrity',
]; ];
foreach ($commands as $command) { foreach ($commands as $command) {
$this->friendlyLine(sprintf('Now executing command "%s"', $command)); $this->friendlyLine(sprintf('Now executing command "%s"', $command));

View File

@@ -31,15 +31,12 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class CorrectsFrontpageAccounts extends Command
* Class FixFrontpageAccounts
*/
class FixFrontpageAccounts extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Fixes a preference that may include deleted accounts or accounts of another type.'; protected $description = 'Fixes a preference that may include deleted accounts or accounts of another type.';
protected $signature = 'firefly-iii:fix-frontpage-accounts'; protected $signature = 'correction:frontpage-accounts';
/** /**
* Execute the console command. * Execute the console command.
@@ -55,7 +52,6 @@ class FixFrontpageAccounts extends Command
$this->fixPreference($preference); $this->fixPreference($preference);
} }
} }
$this->friendlyPositive('Account preferences are OK');
return 0; return 0;
} }

View File

@@ -31,15 +31,12 @@ use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class CorrectsGroupAccounts extends Command
* Class FixGroupAccounts
*/
class FixGroupAccounts extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Unify the source / destination accounts of split groups.'; protected $description = 'Unify the source / destination accounts of split groups.';
protected $signature = 'firefly-iii:unify-group-accounts'; protected $signature = 'correction:group-accounts';
/** /**
* Execute the console command. * Execute the console command.
@@ -64,8 +61,6 @@ class FixGroupAccounts extends Command
$handler->unifyAccounts($event); $handler->unifyAccounts($event);
} }
$this->friendlyPositive('Updated possible inconsistent transaction groups.');
return 0; return 0;
} }
} }

View File

@@ -1,8 +1,8 @@
<?php <?php
/* /*
* UpdateGroupInformation.php * CorrectsGroupInformation.php
* Copyright (c) 2022 james@firefly-iii.org * Copyright (c) 2024 james@firefly-iii.org.
* *
* This file is part of Firefly III (https://github.com/firefly-iii). * This file is part of Firefly III (https://github.com/firefly-iii).
* *
@@ -17,12 +17,12 @@
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see https://www.gnu.org/licenses/.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands\Integrity; namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
@@ -45,15 +45,12 @@ use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
/** class CorrectsGroupInformation extends Command
* Class UpdateGroupInformation
*/
class UpdateGroupInformation extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Makes sure that every object is linked to a group'; protected $description = 'Makes sure that every object is linked to a group';
protected $signature = 'firefly-iii:upgrade-group-information'; protected $signature = 'correction:group-information';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -30,15 +30,12 @@ use FireflyIII\Models\AccountType;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** class CorrectsIbans extends Command
* Class FixIbans
*/
class FixIbans extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Removes spaces from IBANs'; protected $description = 'Removes spaces from IBANs';
protected $signature = 'firefly-iii:fix-ibans'; protected $signature = 'correction:ibans';
private int $count = 0; private int $count = 0;
/** /**
@@ -49,9 +46,6 @@ class FixIbans extends Command
$accounts = Account::whereNotNull('iban')->get(); $accounts = Account::whereNotNull('iban')->get();
$this->filterIbans($accounts); $this->filterIbans($accounts);
$this->countAndCorrectIbans($accounts); $this->countAndCorrectIbans($accounts);
if (0 === $this->count) {
$this->friendlyPositive('All IBANs are valid.');
}
return 0; return 0;
} }

View File

@@ -28,24 +28,22 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\TransactionGroup; use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
/** class CorrectsLongDescriptions extends Command
* Class FixLongDescriptions
*/
class FixLongDescriptions extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
private const int MAX_LENGTH = 1000; private const int MAX_LENGTH = 1000;
protected $description = 'Fixes long descriptions in journals and groups.'; protected $description = 'Fixes long descriptions in journals and groups.';
protected $signature = 'firefly-iii:fix-long-descriptions'; protected $signature = 'correction:long-descriptions';
/** /**
* Execute the console command. * Execute the console command.
*/ */
public function handle(): int public function handle(): int
{ {
$journals = TransactionJournal::get(['id', 'description']); $journals = TransactionJournal::where(DB::raw('LENGTH(description)'), '>', self::MAX_LENGTH)->get(['id', 'description']);
$count = 0; $count = 0;
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
@@ -58,7 +56,7 @@ class FixLongDescriptions extends Command
} }
} }
$groups = TransactionGroup::get(['id', 'title']); $groups = TransactionGroup::where(DB::raw('LENGTH(title)'), '>', self::MAX_LENGTH)->get(['id', 'title']);
/** @var TransactionGroup $group */ /** @var TransactionGroup $group */
foreach ($groups as $group) { foreach ($groups as $group) {
@@ -69,9 +67,6 @@ class FixLongDescriptions extends Command
++$count; ++$count;
} }
} }
if (0 === $count) {
$this->friendlyPositive('All transaction group and journal title lengths are within bounds.');
}
return 0; return 0;
} }

View File

@@ -26,16 +26,14 @@ namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
/** class CorrectsMetaDataFields extends Command
* Class RenameMetaFields
*/
class RenameMetaFields extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Rename changed meta fields.'; protected $description = 'Rename changed meta fields.';
protected $signature = 'firefly-iii:rename-meta-fields'; protected $signature = 'correction:meta-fields';
private int $count = 0; private int $count = 0;
@@ -61,9 +59,6 @@ class RenameMetaFields extends Command
foreach ($changes as $original => $update) { foreach ($changes as $original => $update) {
$this->rename($original, $update); $this->rename($original, $update);
} }
if (0 === $this->count) {
$this->friendlyPositive('All meta fields are correct.');
}
if (0 !== $this->count) { if (0 !== $this->count) {
$this->friendlyInfo(sprintf('Renamed %d meta field(s).', $this->count)); $this->friendlyInfo(sprintf('Renamed %d meta field(s).', $this->count));
} }
@@ -73,7 +68,7 @@ class RenameMetaFields extends Command
private function rename(string $original, string $update): void private function rename(string $original, string $update): void
{ {
$total = \DB::table('journal_meta') $total = DB::table('journal_meta')
->where('name', '=', $original) ->where('name', '=', $original)
->update(['name' => $update]) ->update(['name' => $update])
; ;

View File

@@ -46,19 +46,24 @@ use Illuminate\Database\Query\Builder as DatabaseBuilder;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class RecalculateNativeAmounts extends Command class CorrectsNativeAmounts extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Recalculate native amounts for all objects.'; protected $description = 'Recalculate native amounts for all objects.';
protected $signature = 'firefly-iii:recalculate-native-amounts'; protected $signature = 'correction:recalculate-native-amounts';
/** /**
* Execute the console command. * Execute the console command.
*/ */
public function handle(): int public function handle(): int
{ {
if (!config('cer.enabled')) {
$this->friendlyInfo('This command will not run because currency exchange rates are disabled.');
return 0;
}
Log::debug('Will update all native amounts. This may take some time.'); Log::debug('Will update all native amounts. This may take some time.');
$this->friendlyWarning('Recalculating native amounts for all objects. This may take some time!'); $this->friendlyWarning('Recalculating native amounts for all objects. This may take some time!');
@@ -102,7 +107,7 @@ class RecalculateNativeAmounts extends Command
foreach ($set as $account) { foreach ($set as $account) {
$account->touch(); $account->touch();
} }
Log::debug(sprintf('Recalculated %d accounts', $set->count())); Log::debug(sprintf('Recalculated %d accounts for user group #%d.', $set->count(), $userGroup->id));
} }
private function recalculatePiggyBanks(UserGroup $userGroup, TransactionCurrency $currency): void private function recalculatePiggyBanks(UserGroup $userGroup, TransactionCurrency $currency): void
@@ -124,14 +129,14 @@ class RecalculateNativeAmounts extends Command
foreach ($piggyBank->accounts as $account) { foreach ($piggyBank->accounts as $account) {
$account->pivot->native_current_amount = null; $account->pivot->native_current_amount = null;
if (0 !== bccomp($account->pivot->current_amount, '0')) { if (0 !== bccomp((string) $account->pivot->current_amount, '0')) {
$account->pivot->native_current_amount = $converter->convert($piggyBank->transactionCurrency, $currency, today(), $account->pivot->current_amount); $account->pivot->native_current_amount = $converter->convert($piggyBank->transactionCurrency, $currency, today(), (string) $account->pivot->current_amount);
} }
$account->pivot->save(); $account->pivot->save();
} }
$this->recalculatePiggyBankEvents($piggyBank); $this->recalculatePiggyBankEvents($piggyBank);
} }
Log::debug(sprintf('Recalculated %d piggy banks.', $set->count())); Log::debug(sprintf('Recalculated %d piggy banks for user group #%d.', $set->count(), $userGroup->id));
} }
@@ -168,7 +173,7 @@ class RecalculateNativeAmounts extends Command
$limit->touch(); $limit->touch();
Log::debug(sprintf('Done with touch BL #%d', $limit->id)); Log::debug(sprintf('Done with touch BL #%d', $limit->id));
} }
Log::debug(sprintf('Recalculated %d budget limits.', $set->count())); Log::debug(sprintf('Recalculated %d budget limits for budget #%d.', $set->count(), $budget->id));
} }
private function recalculateAutoBudgets(Budget $budget, TransactionCurrency $currency): void private function recalculateAutoBudgets(Budget $budget, TransactionCurrency $currency): void
@@ -179,7 +184,7 @@ class RecalculateNativeAmounts extends Command
foreach ($set as $autoBudget) { foreach ($set as $autoBudget) {
$autoBudget->touch(); $autoBudget->touch();
} }
Log::debug(sprintf('Recalculated %d auto budgets.', $set->count())); Log::debug(sprintf('Recalculated %d auto budgets for budget #%d.', $set->count(), $budget->id));
} }
private function recalculateAvailableBudgets(UserGroup $userGroup, TransactionCurrency $currency): void private function recalculateAvailableBudgets(UserGroup $userGroup, TransactionCurrency $currency): void

View File

@@ -35,15 +35,12 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** class CorrectsOpeningBalanceCurrencies extends Command
* Class CorrectOpeningBalanceCurrencies
*/
class CorrectOpeningBalanceCurrencies extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Will make sure that opening balance transaction currencies match the account they\'re for.'; protected $description = 'Will make sure that opening balance transaction currencies match the account they\'re for.';
protected $signature = 'firefly-iii:fix-ob-currencies'; protected $signature = 'correction:opening-balance-currencies';
/** /**
* Execute the console command. * Execute the console command.
@@ -62,10 +59,6 @@ class CorrectOpeningBalanceCurrencies extends Command
$message = sprintf('Corrected %d opening balance transaction(s).', $count); $message = sprintf('Corrected %d opening balance transaction(s).', $count);
$this->friendlyInfo($message); $this->friendlyInfo($message);
} }
if (0 === $count) {
$message = 'There was nothing to fix in the opening balance transactions.';
$this->friendlyPositive($message);
}
return 0; return 0;
} }

View File

@@ -29,17 +29,12 @@ use FireflyIII\Models\PiggyBankEvent;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class CorrectsPiggyBanks extends Command
* Report (and fix) piggy banks.
*
* Class FixPiggies
*/
class FixPiggies extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Fixes common issues with piggy banks.'; protected $description = 'Fixes common issues with piggy banks.';
protected $signature = 'firefly-iii:fix-piggies'; protected $signature = 'correction:piggy-banks';
/** /**
* Execute the console command. * Execute the console command.
@@ -66,9 +61,6 @@ class FixPiggies extends Command
continue; continue;
} }
} }
if (0 === $count) {
$this->friendlyPositive('All piggy bank events are OK.');
}
if (0 !== $count) { if (0 !== $count) {
$this->friendlyInfo(sprintf('Fixed %d piggy bank event(s).', $count)); $this->friendlyInfo(sprintf('Fixed %d piggy bank event(s).', $count));
} }

View File

@@ -28,11 +28,11 @@ use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Symfony\Component\Console\Command\Command as CommandAlias; use Symfony\Component\Console\Command\Command as CommandAlias;
class MigratePreferences extends Command class CorrectsPreferences extends Command
{ {
protected $description = 'Give Firefly III preferences a user group ID so they can be made administration specific.'; protected $description = 'Give Firefly III preferences a user group ID so they can be made administration specific.';
protected $signature = 'firefly-iii:migrate-preferences'; protected $signature = 'correction:preferences';
/** /**
* Execute the console command. * Execute the console command.
@@ -50,7 +50,7 @@ class MigratePreferences extends Command
if (null === $preference) { if (null === $preference) {
continue; continue;
} }
if (null !== $preference->user_group_id) { if (null === $preference->user_group_id) {
$preference->user_group_id = $user->user_group_id; $preference->user_group_id = $user->user_group_id;
$preference->save(); $preference->save();
++$count; ++$count;

View File

@@ -33,15 +33,12 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class CorrectsRecurringTransactions extends Command
* Class FixRecurringTransactions
*/
class FixRecurringTransactions extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Fixes recurring transactions with the wrong transaction type.'; protected $description = 'Fixes recurring transactions with the wrong transaction type.';
protected $signature = 'firefly-iii:fix-recurring-transactions'; protected $signature = 'correction:recurring-transactions';
private int $count = 0; private int $count = 0;
private RecurringRepositoryInterface $recurringRepos; private RecurringRepositoryInterface $recurringRepos;
private UserRepositoryInterface $userRepos; private UserRepositoryInterface $userRepos;
@@ -53,9 +50,6 @@ class FixRecurringTransactions extends Command
{ {
$this->stupidLaravel(); $this->stupidLaravel();
$this->correctTransactions(); $this->correctTransactions();
if (0 === $this->count) {
$this->friendlyPositive('All recurring transactions are OK.');
}
return 0; return 0;
} }

View File

@@ -1,5 +1,25 @@
<?php <?php
/*
* CorrectsTimezoneInformation.php
* Copyright (c) 2024 james@firefly-iii.org.
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
declare(strict_types=1); declare(strict_types=1);
/* /*
* AddTimezonesToDates.php * AddTimezonesToDates.php
@@ -21,7 +41,7 @@ declare(strict_types=1);
* along with this program. If not, see https://www.gnu.org/licenses/. * along with this program. If not, see https://www.gnu.org/licenses/.
*/ */
namespace FireflyIII\Console\Commands\Integrity; namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\AccountBalance; use FireflyIII\Models\AccountBalance;
@@ -41,7 +61,7 @@ use Illuminate\Console\Command;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class AddTimezonesToDates extends Command class CorrectsTimezoneInformation extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -73,7 +93,7 @@ class AddTimezonesToDates extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'firefly-iii:add-timezones-to-dates'; protected $signature = 'correction:timezones';
/** /**
* Execute the console command. * Execute the console command.
@@ -107,8 +127,6 @@ class AddTimezonesToDates extends Command
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
if (0 === $count) { if (0 === $count) {
$this->friendlyPositive(sprintf('Timezone information is present in field "%s" of model "%s".', $field, $shortModel));
return; return;
} }
$this->friendlyInfo(sprintf('Adding timezone information to field "%s" of model "%s".', $field, $shortModel)); $this->friendlyInfo(sprintf('Adding timezone information to field "%s" of model "%s".', $field, $shortModel));

View File

@@ -34,15 +34,12 @@ use Illuminate\Console\Command;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
/** class CorrectsTransactionTypes extends Command
* Class FixTransactionTypes
*/
class FixTransactionTypes extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Make sure all transactions are of the correct type, based on source + dest.'; protected $description = 'Make sure all transactions are of the correct type, based on source + dest.';
protected $signature = 'firefly-iii:fix-transaction-types'; protected $signature = 'correction:transaction-types';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -29,15 +29,12 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class CorrectsTransferBudgets extends Command
* Class TransferBudgets
*/
class TransferBudgets extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Removes budgets from transfers.'; protected $description = 'Removes budgets from transfers.';
protected $signature = 'firefly-iii:fix-transfer-budgets'; protected $signature = 'correction:transfer-budgets';
/** /**
* Execute the console command. * Execute the console command.
@@ -60,10 +57,6 @@ class TransferBudgets extends Command
$entry->budgets()->sync([]); $entry->budgets()->sync([]);
++$count; ++$count;
} }
if (0 === $count) {
$message = 'No invalid budget/journal entries.';
$this->friendlyPositive($message);
}
if (0 !== $count) { if (0 !== $count) {
$message = sprintf('Corrected %d invalid budget/journal entries (entry).', $count); $message = sprintf('Corrected %d invalid budget/journal entries (entry).', $count);
app('log')->debug($message); app('log')->debug($message);

View File

@@ -33,15 +33,12 @@ use FireflyIII\Support\Models\AccountBalanceCalculator;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
/** class CorrectsUnevenAmount extends Command
* Class FixUnevenAmount
*/
class FixUnevenAmount extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Fix journals with uneven amounts.'; protected $description = 'Fix journals with uneven amounts.';
protected $signature = 'firefly-iii:fix-uneven-amount'; protected $signature = 'correction:uneven-amounts';
private int $count; private int $count;
/** /**
@@ -118,11 +115,6 @@ class FixUnevenAmount extends Command
++$count; ++$count;
} }
} }
if (0 === $count) {
$this->friendlyPositive('No "old style" foreign currency transfers.');
return;
}
} }
private function fixUnevenAmounts(): void private function fixUnevenAmounts(): void
@@ -164,9 +156,6 @@ class FixUnevenAmount extends Command
$this->fixJournal($entry->transaction_journal_id); $this->fixJournal($entry->transaction_journal_id);
} }
} }
if (0 === $this->count) {
$this->friendlyPositive('Database amount integrity is OK');
}
} }
private function fixJournal(int $param): void private function fixJournal(int $param): void
@@ -291,8 +280,6 @@ class FixUnevenAmount extends Command
Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id)); Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));
} }
if (0 === $count) { if (0 === $count) {
$this->friendlyPositive('Journal currency integrity is OK');
return; return;
} }

View File

@@ -29,16 +29,13 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class CreatesAccessTokens extends Command
* Class CreateAccessTokens
*/
class CreateAccessTokens extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Creates user access tokens which are used for command line access to personal data.'; protected $description = 'Creates user access tokens which are used for command line access to personal data.';
protected $signature = 'firefly-iii:create-access-tokens'; protected $signature = 'correction:access-tokens';
/** /**
* Execute the console command. * Execute the console command.
@@ -64,9 +61,6 @@ class CreateAccessTokens extends Command
++$count; ++$count;
} }
} }
if (0 === $count) {
$this->friendlyPositive('Verified access tokens.');
}
return 0; return 0;
} }

View File

@@ -1,8 +1,8 @@
<?php <?php
/* /*
* CreateGroupMemberships.php * CreatesGroupMemberships.php
* Copyright (c) 2023 james@firefly-iii.org * Copyright (c) 2024 james@firefly-iii.org.
* *
* This file is part of Firefly III (https://github.com/firefly-iii). * This file is part of Firefly III (https://github.com/firefly-iii).
* *
@@ -17,12 +17,12 @@
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see https://www.gnu.org/licenses/.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands\Integrity; namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Enums\UserRoleEnum;
@@ -33,16 +33,13 @@ use FireflyIII\Models\UserRole;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class CreatesGroupMemberships extends Command
* Class CreateGroupMemberships
*/
class CreateGroupMemberships extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '560_create_group_memberships'; public const string CONFIG_NAME = '560_create_group_memberships';
protected $description = 'Update group memberships'; protected $description = 'Update group memberships';
protected $signature = 'firefly-iii:create-group-memberships'; protected $signature = 'correction:create-group-memberships';
/** /**
* Execute the console command. * Execute the console command.
@@ -52,7 +49,6 @@ class CreateGroupMemberships extends Command
public function handle(): int public function handle(): int
{ {
$this->createGroupMemberships(); $this->createGroupMemberships();
$this->friendlyPositive('Validated group memberships');
return 0; return 0;
} }

View File

@@ -28,16 +28,13 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\LinkType; use FireflyIII\Models\LinkType;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class CreatesLinkTypes extends Command
* Class CreateLinkTypes. Created all link types in case a migration hasn't fired.
*/
class CreateLinkTypes extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Creates all link types.'; protected $description = 'Creates all link types.';
protected $signature = 'firefly-iii:create-link-types'; protected $signature = 'correction:link-types';
/** /**
* Execute the console command. * Execute the console command.
@@ -66,9 +63,6 @@ class CreateLinkTypes extends Command
$link->editable = false; $link->editable = false;
$link->save(); $link->save();
} }
if (0 === $count) {
$this->friendlyPositive('All link types are OK');
}
return 0; return 0;
} }

View File

@@ -29,15 +29,12 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType; use FireflyIII\Models\TransactionType;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class RemovesBills extends Command
* Class RemoveBills
*/
class RemoveBills extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Remove bills from transactions that shouldn\'t have one.'; protected $description = 'Remove bills from transactions that shouldn\'t have one.';
protected $signature = 'firefly-iii:remove-bills'; protected $signature = 'correction:bills';
/** /**
* Execute the console command. * Execute the console command.
@@ -60,7 +57,6 @@ class RemoveBills extends Command
if ($journals->count() > 0) { if ($journals->count() > 0) {
$this->friendlyInfo('Fixed all transaction journals so they have correct bill information.'); $this->friendlyInfo('Fixed all transaction journals so they have correct bill information.');
} }
$this->friendlyPositive('All bills and journals are OK');
return 0; return 0;
} }

View File

@@ -29,15 +29,12 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\TransactionGroup; use FireflyIII\Models\TransactionGroup;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class RemovesEmptyGroups extends Command
* Class DeleteEmptyGroups
*/
class DeleteEmptyGroups extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Delete empty transaction groups.'; protected $description = 'Delete empty transaction groups.';
protected $signature = 'firefly-iii:delete-empty-groups'; protected $signature = 'correction:empty-groups';
/** /**
* Execute the console command. * Execute the console command.
@@ -61,9 +58,6 @@ class DeleteEmptyGroups extends Command
TransactionGroup::whereNull('deleted_at')->whereIn('id', $chunk)->delete(); TransactionGroup::whereNull('deleted_at')->whereIn('id', $chunk)->delete();
} }
} }
if (0 === $total) {
$this->friendlyInfo('Verified there are no empty groups.');
}
return 0; return 0;
} }

View File

@@ -30,16 +30,13 @@ use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
/** class RemovesEmptyJournals extends Command
* Class DeleteEmptyJournals
*/
class DeleteEmptyJournals extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Delete empty and uneven transaction journals.'; protected $description = 'Delete empty and uneven transaction journals.';
protected $signature = 'firefly-iii:delete-empty-journals'; protected $signature = 'correction:empty-journals';
/** /**
* Execute the console command. * Execute the console command.
@@ -82,9 +79,6 @@ class DeleteEmptyJournals extends Command
++$total; ++$total;
} }
} }
if (0 === $total) {
$this->friendlyPositive('No uneven transaction journals.');
}
} }
private function deleteEmptyJournals(): void private function deleteEmptyJournals(): void
@@ -107,8 +101,5 @@ class DeleteEmptyJournals extends Command
$this->friendlyInfo(sprintf('Deleted empty transaction journal #%d', $entry->id)); $this->friendlyInfo(sprintf('Deleted empty transaction journal #%d', $entry->id));
++$count; ++$count;
} }
if (0 === $count) {
$this->friendlyPositive('No empty transaction journals.');
}
} }
} }

View File

@@ -32,13 +32,13 @@ use Illuminate\Console\Command;
/** /**
* Deletes transactions where the journal has been deleted. * Deletes transactions where the journal has been deleted.
*/ */
class DeleteOrphanedTransactions extends Command class RemovesOrphanedTransactions extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Deletes orphaned transactions.'; protected $description = 'Deletes orphaned transactions.';
protected $signature = 'firefly-iii:delete-orphaned-transactions'; protected $signature = 'correction:orphaned-transactions';
/** /**
* Execute the console command. * Execute the console command.
@@ -63,7 +63,7 @@ class DeleteOrphanedTransactions extends Command
; ;
$count = $set->count(); $count = $set->count();
if (0 === $count) { if (0 === $count) {
$this->friendlyPositive('No orphaned journals.'); // $this->friendlyPositive('No orphaned journals.');
return; return;
} }
@@ -116,9 +116,6 @@ class DeleteOrphanedTransactions extends Command
++$count; ++$count;
} }
} }
if (0 === $count) {
$this->friendlyPositive('No orphaned transactions.');
}
} }
private function deleteFromOrphanedAccounts(): void private function deleteFromOrphanedAccounts(): void
@@ -147,8 +144,5 @@ class DeleteOrphanedTransactions extends Command
); );
++$count; ++$count;
} }
if (0 === $count) {
$this->friendlyPositive('No orphaned accounts.');
}
} }
} }

View File

@@ -29,16 +29,13 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class RemovesZeroAmount extends Command
* Class DeleteZeroAmount
*/
class DeleteZeroAmount extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Delete transactions with zero amount.'; protected $description = 'Delete transactions with zero amount.';
protected $signature = 'firefly-iii:delete-zero-amount'; protected $signature = 'correction:zero-amounts';
/** /**
* Execute the console command. * Execute the console command.
@@ -56,9 +53,6 @@ class DeleteZeroAmount extends Command
Transaction::where('transaction_journal_id', $journal->id)->delete(); Transaction::where('transaction_journal_id', $journal->id)->delete();
} }
if (0 === $journals->count()) {
$this->friendlyPositive('No zero-amount transaction journals.');
}
return 0; return 0;
} }

View File

@@ -1,8 +1,8 @@
<?php <?php
/** /*
* RestoreOAuthKeys.php * RestoresOAuthKeys.php
* Copyright (c) 2020 james@firefly-iii.org * Copyright (c) 2024 james@firefly-iii.org.
* *
* This file is part of Firefly III (https://github.com/firefly-iii). * This file is part of Firefly III (https://github.com/firefly-iii).
* *
@@ -17,26 +17,23 @@
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see https://www.gnu.org/licenses/.
*/ */
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Console\Commands\Integrity; namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Support\System\OAuthKeys; use FireflyIII\Support\System\OAuthKeys;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class RestoresOAuthKeys extends Command
* Class RestoreOAuthKeys
*/
class RestoreOAuthKeys extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Will restore the OAuth keys generated for the system.'; protected $description = 'Will restore the OAuth keys generated for the system.';
protected $signature = 'firefly-iii:restore-oauth-keys'; protected $signature = 'correction:restore-oauth-keys';
/** /**
* Execute the console command. * Execute the console command.
@@ -76,7 +73,6 @@ class RestoreOAuthKeys extends Command
return; return;
} }
$this->friendlyPositive('OAuth keys are OK');
} }
private function keysInDatabase(): bool private function keysInDatabase(): bool

View File

@@ -28,13 +28,10 @@ use FireflyIII\Models\Account;
use FireflyIII\Services\Internal\Support\CreditRecalculateService; use FireflyIII\Services\Internal\Support\CreditRecalculateService;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class TriggersCreditCalculation extends Command
* Class CorrectionSkeleton
*/
class TriggerCreditCalculation extends Command
{ {
protected $description = 'Triggers the credit recalculation service for liabilities.'; protected $description = 'Triggers the credit recalculation service for liabilities.';
protected $signature = 'firefly-iii:trigger-credit-recalculation'; protected $signature = 'correction:recalculates-liabilities';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -36,10 +36,7 @@ use FireflyIII\Support\Export\ExportDataGenerator;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** class ExportsData extends Command
* Class ExportData
*/
class ExportData extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
use VerifiesAccessToken; use VerifiesAccessToken;

View File

@@ -4,10 +4,6 @@ namespace FireflyIII\Console\Commands\Integrity;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/**
* Class ReportSkeleton
* TODO DONT FORGET TO ADD THIS TO THE DOCKER BUILD
*/
class ReportSkeleton extends Command class ReportSkeleton extends Command
{ {

View File

@@ -31,16 +31,13 @@ use FireflyIII\Models\Category;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class ReportsEmptyObjects extends Command
* Class ReportEmptyObjects
*/
class ReportEmptyObjects extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Reports on empty database objects.'; protected $description = 'Reports on empty database objects.';
protected $signature = 'firefly-iii:report-empty-objects'; protected $signature = 'integrity:empty-objects';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -27,10 +27,7 @@ namespace FireflyIII\Console\Commands\Integrity;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class ReportsIntegrity extends Command
* Class ReportIntegrity
*/
class ReportIntegrity extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -48,11 +45,8 @@ class ReportIntegrity extends Command
return 1; return 1;
} }
$commands = [ $commands = [
'firefly-iii:add-timezones-to-dates', 'integrity:empty-objects',
'firefly-iii:create-group-memberships', 'integrity:total-sums',
'firefly-iii:report-empty-objects',
'firefly-iii:report-sum',
'firefly-iii:upgrade-group-information',
]; ];
foreach ($commands as $command) { foreach ($commands as $command) {
$this->friendlyLine(sprintf('Now executing %s', $command)); $this->friendlyLine(sprintf('Now executing %s', $command));

View File

@@ -29,15 +29,12 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class ReportsSums extends Command
* Class ReportSkeleton
*/
class ReportSum extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Report on the total sum of transactions. Must be 0.'; protected $description = 'Report on the total sum of transactions. Must be 0.';
protected $signature = 'firefly-iii:report-sum'; protected $signature = 'integrity:total-sums';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -28,7 +28,7 @@ use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Symfony\Component\Console\Command\Command as CommandAlias; use Symfony\Component\Console\Command\Command as CommandAlias;
class LaravelPassportKeys extends Command class CallsLaravelPassportKeys extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;

View File

@@ -28,10 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use PDO; use PDO;
/** class CreatesDatabase extends Command
* Class CreateDatabase
*/
class CreateDatabase extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;

View File

@@ -29,16 +29,13 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
/** class CreatesFirstUser extends Command
* Class CreateFirstUser
*/
class CreateFirstUser extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Creates a new user and gives admin rights. Outputs the password on the command line. Strictly for testing.'; protected $description = 'Creates a new user and gives admin rights. Outputs the password on the command line. Strictly for testing.';
protected $signature = 'firefly-iii:create-first-user {email}'; protected $signature = 'system:create-first-user {email}';
private UserRepositoryInterface $repository; private UserRepositoryInterface $repository;
/** /**

View File

@@ -44,13 +44,11 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
/** /**
* Class ForceDecimalSize
*
* This command was inspired by https://github.com/elliot-gh. It will check all amount fields * This command was inspired by https://github.com/elliot-gh. It will check all amount fields
* and their values and correct them to the correct number of decimal places. This fixes issues where * and their values and correct them to the correct number of decimal places. This fixes issues where
* Firefly III would store 0.01 as 0.01000000000000000020816681711721685132943093776702880859375. * Firefly III would store 0.01 as 0.01000000000000000020816681711721685132943093776702880859375.
*/ */
class ForceDecimalSize extends Command class ForcesDecimalSize extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;

View File

@@ -33,10 +33,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
/** class ForcesMigrations extends Command
* Class ForceMigration
*/
class ForceMigration extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
use VerifiesAccessToken; use VerifiesAccessToken;

View File

@@ -27,16 +27,13 @@ namespace FireflyIII\Console\Commands\System;
use FireflyIII\Support\System\GeneratesInstallationId; use FireflyIII\Support\System\GeneratesInstallationId;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class OutputsInstructions extends Command
* Class UpgradeFireflyInstructions.
*/
class UpgradeFireflyInstructions extends Command
{ {
use GeneratesInstallationId; use GeneratesInstallationId;
protected $description = 'Instructions in case of upgrade trouble.'; protected $description = 'Instructions in case of upgrade trouble.';
protected $signature = 'firefly:instructions {task}'; protected $signature = 'firefly-iii:instructions {task=install}';
/** /**
* Execute the console command. * Execute the console command.
@@ -79,7 +76,7 @@ class UpgradeFireflyInstructions extends Command
} }
$prefix = 'v'; $prefix = 'v';
if (str_starts_with($version, 'develop')) { if (str_starts_with($version, 'develop') || str_starts_with($version, 'branch')) {
$prefix = ''; $prefix = '';
} }
@@ -94,6 +91,8 @@ class UpgradeFireflyInstructions extends Command
$this->boxedInfo('There are no extra upgrade instructions.'); $this->boxedInfo('There are no extra upgrade instructions.');
$this->boxed('Firefly III should be ready for use.'); $this->boxed('Firefly III should be ready for use.');
$this->boxed(''); $this->boxed('');
$this->donationText();
$this->boxed('');
$this->showLine(); $this->showLine();
return; return;
@@ -102,6 +101,8 @@ class UpgradeFireflyInstructions extends Command
$this->boxed(sprintf('Thank you for updating to Firefly III, %s%s!', $prefix, $version)); $this->boxed(sprintf('Thank you for updating to Firefly III, %s%s!', $prefix, $version));
$this->boxedInfo($text); $this->boxedInfo($text);
$this->boxed(''); $this->boxed('');
$this->donationText();
$this->boxed('');
$this->showLine(); $this->showLine();
} }
@@ -213,6 +214,8 @@ class UpgradeFireflyInstructions extends Command
$this->boxedInfo('There are no extra installation instructions.'); $this->boxedInfo('There are no extra installation instructions.');
$this->boxed('Firefly III should be ready for use.'); $this->boxed('Firefly III should be ready for use.');
$this->boxed(''); $this->boxed('');
$this->donationText();
$this->boxed('');
$this->showLine(); $this->showLine();
return; return;
@@ -221,6 +224,15 @@ class UpgradeFireflyInstructions extends Command
$this->boxed(sprintf('Thank you for installing Firefly III, %s%s!', $prefix, $version)); $this->boxed(sprintf('Thank you for installing Firefly III, %s%s!', $prefix, $version));
$this->boxedInfo($text); $this->boxedInfo($text);
$this->boxed(''); $this->boxed('');
$this->donationText();
$this->boxed('');
$this->showLine(); $this->showLine();
} }
private function donationText(): void
{
$this->boxed('Did you know you can support the development of Firefly III?');
$this->boxed('You can donate in many ways, like GitHub Sponsors or Patreon.');
$this->boxed('For more information, please visit https://bit.ly/donate-to-Firefly-III');
}
} }

View File

@@ -26,10 +26,7 @@ namespace FireflyIII\Console\Commands\System;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class OutputsVersion extends Command
* Class OutputVersion
*/
class OutputVersion extends Command
{ {
protected $description = 'Outputs the Firefly III version'; protected $description = 'Outputs the Firefly III version';

View File

@@ -29,10 +29,7 @@ use FireflyIII\Models\Attachment;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Contracts\Encryption\DecryptException;
/** class ScansAttachments extends Command
* Class ScanAttachments.
*/
class ScanAttachments extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;

View File

@@ -27,10 +27,7 @@ namespace FireflyIII\Console\Commands\System;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class SetsLatestVersion extends Command
* Class SetLatestVersion
*/
class SetLatestVersion extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;

View File

@@ -29,9 +29,6 @@ use Illuminate\Console\Command;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use League\Flysystem\FilesystemException; use League\Flysystem\FilesystemException;
/**
* Class VerifySecurityAlerts
*/
class VerifySecurityAlerts extends Command class VerifySecurityAlerts extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;

View File

@@ -40,9 +40,6 @@ use Illuminate\Console\Command;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
/**
* Class ApplyRules
*/
class ApplyRules extends Command class ApplyRules extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;

View File

@@ -34,9 +34,6 @@ use FireflyIII\Support\Cronjobs\RecurringCronjob;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
/**
* Class Cron
*/
class Cron extends Command class Cron extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;

View File

@@ -32,16 +32,13 @@ use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
/** class AddsTransactionIdentifiers extends Command
* Class TransactionIdentifier
*/
class TransactionIdentifier extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_transaction_identifier'; public const string CONFIG_NAME = '480_transaction_identifier';
protected $description = 'Fixes transaction identifiers.'; protected $description = 'Fixes transaction identifiers.';
protected $signature = 'firefly-iii:transaction-identifiers {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:480-transaction-identifiers {--F|force : Force the execution of this command.}';
private JournalCLIRepositoryInterface $cliRepository; private JournalCLIRepositoryInterface $cliRepository;
private int $count; private int $count;
@@ -79,9 +76,6 @@ class TransactionIdentifier extends Command
$this->updateJournalIdentifiers($journal); $this->updateJournalIdentifiers($journal);
} }
if (0 === $this->count) {
$this->friendlyPositive('All split journal transaction identifiers are OK.');
}
if (0 !== $this->count) { if (0 !== $this->count) {
$this->friendlyInfo(sprintf('Fixed %d split journal transaction identifier(s).', $this->count)); $this->friendlyInfo(sprintf('Fixed %d split journal transaction identifier(s).', $this->count));
} }

View File

@@ -30,15 +30,12 @@ use FireflyIII\Models\Preference;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\DecryptException; use Illuminate\Contracts\Encryption\DecryptException;
/** class RemovesDatabaseDecryption extends Command
* Class DecryptDatabase
*/
class DecryptDatabase extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Decrypts the database.'; protected $description = 'Decrypts the database.';
protected $signature = 'firefly-iii:decrypt-all'; protected $signature = 'upgrade:480-decrypt-all';
/** /**
* Execute the console command. * Execute the console command.
@@ -73,7 +70,6 @@ class DecryptDatabase extends Command
private function decryptTable(string $table, array $fields): void private function decryptTable(string $table, array $fields): void
{ {
if ($this->isDecrypted($table)) { if ($this->isDecrypted($table)) {
$this->friendlyInfo(sprintf('No decryption required for table "%s".', $table));
return; return;
} }

View File

@@ -28,16 +28,13 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Support\Models\AccountBalanceCalculator; use FireflyIII\Support\Models\AccountBalanceCalculator;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class RepairsAccountBalances extends Command
* Class CorrectionSkeleton
*/
class CorrectAccountBalance extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '610_correct_balances'; public const string CONFIG_NAME = '610_correct_balances';
protected $description = 'Recalculate all account balance amounts'; protected $description = 'Recalculate all account balance amounts';
protected $signature = 'firefly-iii:correct-account-balance {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:610-account-balances {--F|force : Force the execution of this command.}';
public function handle(): int public function handle(): int
{ {

View File

@@ -27,16 +27,13 @@ namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class RepairsPostgresSequences extends Command
* Class FixPostgresSequences
*/
class FixPostgresSequences extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
protected $description = 'Fixes issues with PostgreSQL sequences.'; protected $description = 'Fixes issues with PostgreSQL sequences.';
protected $signature = 'firefly-iii:fix-pgsql-sequences'; protected $signature = 'upgrade:600-pgsql-sequences';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -4,9 +4,6 @@ namespace FireflyIII\Console\Commands\Upgrade;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/**
* Class UpgradeSkeleton.
*/
class UpgradeSkeleton extends Command class UpgradeSkeleton extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -14,7 +11,7 @@ class UpgradeSkeleton extends Command
protected $description = 'SOME DESCRIPTION'; protected $description = 'SOME DESCRIPTION';
protected $signature = 'firefly-iii:UPGRSKELETON {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:UPGRSKELETON {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -36,17 +36,14 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesAccountCurrencies extends Command
* Class AccountCurrencies
*/
class AccountCurrencies extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_account_currencies'; public const string CONFIG_NAME = '480_account_currencies';
protected $description = 'Give all accounts proper currency info.'; protected $description = 'Give all accounts proper currency info.';
protected $signature = 'firefly-iii:account-currencies {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:480-account-currencies {--F|force : Force the execution of this command.}';
private AccountRepositoryInterface $accountRepos; private AccountRepositoryInterface $accountRepos;
private int $count; private int $count;
private UserRepositoryInterface $userRepos; private UserRepositoryInterface $userRepos;
@@ -65,9 +62,6 @@ class AccountCurrencies extends Command
} }
$this->updateAccountCurrencies(); $this->updateAccountCurrencies();
if (0 === $this->count) {
$this->friendlyPositive('All account currencies are OK.');
}
if (0 !== $this->count) { if (0 !== $this->count) {
$this->friendlyInfo(sprintf('Corrected %d account(s).', $this->count)); $this->friendlyInfo(sprintf('Corrected %d account(s).', $this->count));
} }

View File

@@ -29,10 +29,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\AccountMeta; use FireflyIII\Models\AccountMeta;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesAccountMetaData extends Command
* Class RenameAccountMeta
*/
class RenameAccountMeta extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -40,7 +37,7 @@ class RenameAccountMeta extends Command
protected $description = 'Rename account meta-data to new format.'; protected $description = 'Rename account meta-data to new format.';
protected $signature = 'firefly-iii:rename-account-meta {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:480-account-meta {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.
@@ -76,9 +73,6 @@ class RenameAccountMeta extends Command
$this->markAsExecuted(); $this->markAsExecuted();
if (0 === $count) {
$this->friendlyPositive('All account meta is OK.');
}
if (0 !== $count) { if (0 !== $count) {
$this->friendlyInfo(sprintf('Renamed %d account meta entries (entry).', $count)); $this->friendlyInfo(sprintf('Renamed %d account meta entries (entry).', $count));
} }

View File

@@ -30,10 +30,7 @@ use FireflyIII\Models\Attachment;
use FireflyIII\Models\Note; use FireflyIII\Models\Note;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesAttachments extends Command
* Class MigrateAttachments
*/
class MigrateAttachments extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -41,7 +38,7 @@ class MigrateAttachments extends Command
protected $description = 'Migrates attachment meta-data.'; protected $description = 'Migrates attachment meta-data.';
protected $signature = 'firefly-iii:migrate-attachments {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:480-attachments {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.
@@ -82,9 +79,6 @@ class MigrateAttachments extends Command
++$count; ++$count;
} }
} }
if (0 === $count) {
$this->friendlyPositive('All attachments are OK.');
}
if (0 !== $count) { if (0 !== $count) {
$this->friendlyInfo(sprintf('Updated %d attachment(s).', $count)); $this->friendlyInfo(sprintf('Updated %d attachment(s).', $count));
} }

View File

@@ -36,10 +36,7 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesBillsToRules extends Command
* Class MigrateToRules
*/
class MigrateToRules extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -47,7 +44,7 @@ class MigrateToRules extends Command
protected $description = 'Migrate bills to rules.'; protected $description = 'Migrate bills to rules.';
protected $signature = 'firefly-iii:bills-to-rules {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:480-bills-to-rules {--F|force : Force the execution of this command.}';
private BillRepositoryInterface $billRepository; private BillRepositoryInterface $billRepository;
private int $count; private int $count;
private RuleGroupRepositoryInterface $ruleGroupRepository; private RuleGroupRepositoryInterface $ruleGroupRepository;
@@ -76,9 +73,6 @@ class MigrateToRules extends Command
$this->migrateUser($user); $this->migrateUser($user);
} }
if (0 === $this->count) {
$this->friendlyPositive('All bills are OK.');
}
if (0 !== $this->count) { if (0 !== $this->count) {
$this->friendlyInfo(sprintf('Verified and fixed %d bill(s).', $this->count)); $this->friendlyInfo(sprintf('Verified and fixed %d bill(s).', $this->count));
} }

View File

@@ -28,10 +28,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\BudgetLimit;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesBudgetLimitPeriods extends Command
* Class AppendBudgetLimitPeriods
*/
class AppendBudgetLimitPeriods extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -39,7 +36,7 @@ class AppendBudgetLimitPeriods extends Command
protected $description = 'Append budget limits with their (estimated) timeframe.'; protected $description = 'Append budget limits with their (estimated) timeframe.';
protected $signature = 'firefly-iii:budget-limit-periods {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:550-budget-limit-periods {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -31,10 +31,7 @@ use FireflyIII\Models\BudgetLimit;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesBudgetLimits extends Command
* Class BudgetLimitCurrency
*/
class BudgetLimitCurrency extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -42,7 +39,7 @@ class BudgetLimitCurrency extends Command
protected $description = 'Give budget limits a currency'; protected $description = 'Give budget limits a currency';
protected $signature = 'firefly-iii:bl-currency {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:480-budget-limit-currencies {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.
@@ -80,9 +77,6 @@ class BudgetLimitCurrency extends Command
} }
} }
} }
if (0 === $count) {
$this->friendlyPositive('All budget limits are OK.');
}
$this->markAsExecuted(); $this->markAsExecuted();
return 0; return 0;

View File

@@ -31,16 +31,13 @@ use FireflyIII\Models\AccountType;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** class UpgradesCreditCardLiabilities extends Command
* Class CCLiabilities
*/
class CCLiabilities extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_cc_liabilities'; public const string CONFIG_NAME = '480_cc_liabilities';
protected $description = 'Convert old credit card liabilities.'; protected $description = 'Convert old credit card liabilities.';
protected $signature = 'firefly-iii:cc-liabilities {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:480-cc-liabilities {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.
@@ -58,7 +55,6 @@ class CCLiabilities extends Command
$ccType = AccountType::where('type', AccountType::CREDITCARD)->first(); $ccType = AccountType::where('type', AccountType::CREDITCARD)->first();
$debtType = AccountType::where('type', AccountType::DEBT)->first(); $debtType = AccountType::where('type', AccountType::DEBT)->first();
if (null === $ccType || null === $debtType) { if (null === $ccType || null === $debtType) {
$this->friendlyPositive('No incorrectly stored credit card liabilities.');
$this->markAsExecuted(); $this->markAsExecuted();
return 0; return 0;
@@ -76,9 +72,6 @@ class CCLiabilities extends Command
'Credit card liability types are no longer supported and have been converted to generic debts. See: https://bit.ly/FF3-credit-cards' 'Credit card liability types are no longer supported and have been converted to generic debts. See: https://bit.ly/FF3-credit-cards'
); );
} }
if (0 === $accounts->count()) {
$this->friendlyPositive('No incorrectly stored credit card liabilities.');
}
$this->markAsExecuted(); $this->markAsExecuted();
return 0; return 0;

View File

@@ -32,10 +32,7 @@ use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** class UpgradesCurrencyPreferences extends Command
* Class UpgradeCurrencyPreferences
*/
class UpgradeCurrencyPreferences extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -43,7 +40,7 @@ class UpgradeCurrencyPreferences extends Command
protected $description = 'Upgrade user currency preferences'; protected $description = 'Upgrade user currency preferences';
protected $signature = 'firefly-iii:upgrade-currency-preferences {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:610-currency-preferences {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -29,10 +29,7 @@ set_time_limit(0);
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesDatabase extends Command
* Class UpgradeDatabase
*/
class UpgradeDatabase extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -46,33 +43,29 @@ class UpgradeDatabase extends Command
{ {
$this->callInitialCommands(); $this->callInitialCommands();
$commands = [ $commands = [
'firefly-iii:transaction-identifiers', 'upgrade:480-transaction-identifiers',
'firefly-iii:migrate-to-groups', 'upgrade:480-migrate-to-groups',
'firefly-iii:account-currencies', 'upgrade:480-account-currencies',
'firefly-iii:transfer-currencies', 'upgrade:480-transfer-currencies',
'firefly-iii:other-currencies', 'upgrade:480-currency-information',
'firefly-iii:migrate-notes', 'upgrade:480-notes',
'firefly-iii:migrate-attachments', 'upgrade:480-attachments',
'firefly-iii:bills-to-rules', 'upgrade:480-bills-to-rules',
'firefly-iii:bl-currency', 'upgrade:480-budget-limit-currencies',
'firefly-iii:cc-liabilities', 'upgrade:480-cc-liabilities',
'firefly-iii:back-to-journals', 'upgrade:480-journal-meta-data',
'firefly-iii:rename-account-meta', 'upgrade:480-account-meta',
'firefly-iii:migrate-recurrence-meta', 'upgrade:481-recurrence-meta',
'firefly-iii:migrate-tag-locations', 'upgrade:500-tag-locations',
'firefly-iii:migrate-recurrence-type', 'upgrade:560-liabilities',
'firefly-iii:upgrade-liabilities', 'upgrade:600-liabilities',
'firefly-iii:liabilities-600', 'upgrade:550-budget-limit-periods',
'firefly-iii:budget-limit-periods', 'upgrade:600-rule-actions',
'firefly-iii:migrate-rule-actions', 'upgrade:610-account-balance',
'firefly-iii:restore-oauth-keys', 'upgrade:610-currency-preferences',
'firefly-iii:correct-account-balance', 'upgrade:610-currency-preferences',
// also just in case, some integrity commands: 'upgrade:620-piggy-banks',
'firefly-iii:add-timezones-to-dates', 'upgrade:620-native-amounts',
'firefly-iii:create-group-memberships',
'firefly-iii:upgrade-group-information',
'firefly-iii:upgrade-currency-preferences',
'firefly-iii:upgrade-multi-piggies',
'firefly-iii:correct-database', 'firefly-iii:correct-database',
]; ];
$args = []; $args = [];
@@ -94,7 +87,7 @@ class UpgradeDatabase extends Command
private function callInitialCommands(): void private function callInitialCommands(): void
{ {
$this->call('migrate', ['--seed' => true, '--force' => true, '--no-interaction' => true]); $this->call('migrate', ['--seed' => true, '--force' => true, '--no-interaction' => true]);
$this->call('firefly-iii:fix-pgsql-sequences'); $this->call('upgrade:600-pgsql-sequences');
$this->call('firefly-iii:decrypt-all'); $this->call('upgrade:480-decrypt-all');
} }
} }

View File

@@ -32,10 +32,7 @@ use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** class UpgradesJournalMetaData extends Command
* Class BackToJournals
*/
class BackToJournals extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -43,7 +40,7 @@ class BackToJournals extends Command
protected $description = 'Move meta data back to journals, not individual transactions.'; protected $description = 'Move meta data back to journals, not individual transactions.';
protected $signature = 'firefly-iii:back-to-journals {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:480-journal-meta-data {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.
@@ -71,7 +68,7 @@ class BackToJournals extends Command
private function isMigrated(): bool private function isMigrated(): bool
{ {
$configVar = app('fireflyconfig')->get(MigrateToGroups::CONFIG_NAME, false); $configVar = app('fireflyconfig')->get(UpgradesToGroups::CONFIG_NAME, false);
return (bool) $configVar->data; return (bool) $configVar->data;
} }

View File

@@ -29,10 +29,7 @@ use FireflyIII\Models\Note;
use FireflyIII\Models\TransactionJournalMeta; use FireflyIII\Models\TransactionJournalMeta;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesJournalNotes extends Command
* Class MigrateJournalNotes
*/
class MigrateJournalNotes extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -40,7 +37,7 @@ class MigrateJournalNotes extends Command
protected $description = 'Migrate notes for transaction journals.'; protected $description = 'Migrate notes for transaction journals.';
protected $signature = 'firefly-iii:migrate-notes {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:480-notes {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.
@@ -75,9 +72,6 @@ class MigrateJournalNotes extends Command
++$count; ++$count;
} }
if (0 === $count) {
$this->friendlyPositive('No notes to migrate.');
}
if (0 !== $count) { if (0 !== $count) {
$this->friendlyInfo(sprintf('Migrated %d note(s).', $count)); $this->friendlyInfo(sprintf('Migrated %d note(s).', $count));
} }

View File

@@ -34,16 +34,13 @@ use FireflyIII\Services\Internal\Support\CreditRecalculateService;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesLiabilities extends Command
* Class UpgradeLiabilities
*/
class UpgradeLiabilities extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '560_upgrade_liabilities'; public const string CONFIG_NAME = '560_upgrade_liabilities';
protected $description = 'Upgrade liabilities to new 5.6.0 structure.'; protected $description = 'Upgrade liabilities to new 5.6.0 structure.';
protected $signature = 'firefly-iii:upgrade-liabilities {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:560-liabilities {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -35,16 +35,13 @@ use FireflyIII\Services\Internal\Support\CreditRecalculateService;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesLiabilitiesEight extends Command
* Class UpgradeLiabilitiesEight
*/
class UpgradeLiabilitiesEight extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '600_upgrade_liabilities'; public const string CONFIG_NAME = '600_upgrade_liabilities';
protected $description = 'Upgrade liabilities to new 6.0.0 structure.'; protected $description = 'Upgrade liabilities to new 6.0.0 structure.';
protected $signature = 'firefly-iii:liabilities-600 {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:600-liabilities {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.
@@ -201,32 +198,9 @@ class UpgradeLiabilitiesEight extends Command
/** @var TransactionJournal $journal */ /** @var TransactionJournal $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {
// $delete = false;
// /** @var Transaction $source */
// $source = $journal->transactions()->where('amount', '<', 0)->first();
// /** @var Transaction $dest */
// $dest = $journal->transactions()->where('amount', '>', 0)->first();
/**
* // if source is this liability and destination is expense, remove transaction.
* // if source is revenue and destination is liability, remove transaction.
* if ($source->account_id === $account->id && $dest->account->accountType->type === AccountType::EXPENSE) {
* $delete = true;
* }
* if ($dest->account_id === $account->id && $source->account->accountType->type === AccountType::REVENUE) {
* $delete = true;
* }
*
* // overruled. No transaction will be deleted, ever.
* // code is kept in place, so I can revisit my reasoning.
* $delete = false;
*/
// if ($delete) {
$service = app(TransactionGroupDestroyService::class); $service = app(TransactionGroupDestroyService::class);
$service->destroy($journal->transactionGroup); $service->destroy($journal->transactionGroup);
++$count; ++$count;
// }
} }
return $count; return $count;

View File

@@ -30,15 +30,15 @@ use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
class UpgradeMultiPiggyBanks extends Command class UpgradesMultiPiggyBanks extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '620_make_multi_piggies'; public const string CONFIG_NAME = '620_make_multi_piggies';
protected $description = 'Upgrade piggybanks so they can use multiple accounts.'; protected $description = 'Upgrade piggy banks so they can use multiple accounts.';
protected $signature = 'firefly-iii:upgrade-multi-piggies {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:620-piggy-banks {--F|force : Force the execution of this command.}';
private AccountRepositoryInterface $accountRepository; private AccountRepositoryInterface $accountRepository;
private PiggyBankRepositoryInterface $repository; private PiggyBankRepositoryInterface $repository;

View File

@@ -1,8 +1,9 @@
<?php <?php
declare(strict_types=1);
/* /*
* MigrateRecurrenceType.php * UpgradesNativeAmounts.php
* Copyright (c) 2021 james@firefly-iii.org * Copyright (c) 2024 james@firefly-iii.org.
* *
* This file is part of Firefly III (https://github.com/firefly-iii). * This file is part of Firefly III (https://github.com/firefly-iii).
* *
@@ -17,28 +18,23 @@
* GNU Affero General Public License for more details. * GNU Affero General Public License for more details.
* *
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see https://www.gnu.org/licenses/.
*/ */
declare(strict_types=1);
namespace FireflyIII\Console\Commands\Upgrade; namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
/** class UpgradesNativeAmounts extends Command
* Class MigrateRecurrenceType
*/
class MigrateRecurrenceType extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '620_native_amounts';
public const string CONFIG_NAME = '550_migrate_recurrence_type'; protected $description = 'Runs the native amounts calculations.';
protected $description = 'Migrate transaction type of recurring transaction.'; protected $signature = 'upgrade:620-native-amounts {--F|force : Force the execution of this command.}';
protected $signature = 'firefly-iii:migrate-recurrence-type {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.
@@ -50,17 +46,23 @@ class MigrateRecurrenceType extends Command
return 0; return 0;
} }
$this->friendlyWarning('This command has been disabled.');
Artisan::call('correction:recalculate-native-amounts');
$this->markAsExecuted(); $this->markAsExecuted();
return 0; return 0;
} }
private function isExecuted(): bool private function isExecuted(): bool
{ {
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false); $configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
if (null !== $configVar) {
return (bool)$configVar->data;
}
return (bool) $configVar?->data; return false;
} }
private function markAsExecuted(): void private function markAsExecuted(): void

View File

@@ -30,10 +30,7 @@ use FireflyIII\Models\RecurrenceMeta;
use FireflyIII\Models\RecurrenceTransactionMeta; use FireflyIII\Models\RecurrenceTransactionMeta;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesRecurrenceMetaData extends Command
* Class MigrateRecurrenceMeta
*/
class MigrateRecurrenceMeta extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -41,7 +38,7 @@ class MigrateRecurrenceMeta extends Command
protected $description = 'Migrate recurrence meta data'; protected $description = 'Migrate recurrence meta data';
protected $signature = 'firefly-iii:migrate-recurrence-meta {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:481-recurrence-meta {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.
@@ -55,9 +52,6 @@ class MigrateRecurrenceMeta extends Command
} }
$count = $this->migrateMetaData(); $count = $this->migrateMetaData();
if (0 === $count) {
$this->friendlyPositive('No recurrence meta data migrated.');
}
if ($count > 0) { if ($count > 0) {
$this->friendlyInfo(sprintf('Migrated %d meta data entries', $count)); $this->friendlyInfo(sprintf('Migrated %d meta data entries', $count));
} }

View File

@@ -27,7 +27,7 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleAction;
use Illuminate\Console\Command; use Illuminate\Console\Command;
class MigrateRuleActions extends Command class UpgradesRuleActions extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -35,7 +35,7 @@ class MigrateRuleActions extends Command
protected $description = 'Migrate rule actions away from expression engine'; protected $description = 'Migrate rule actions away from expression engine';
protected $signature = 'firefly-iii:migrate-rule-actions {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:600-rule-actions {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -29,10 +29,7 @@ use FireflyIII\Models\Location;
use FireflyIII\Models\Tag; use FireflyIII\Models\Tag;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesTagLocations extends Command
* Class MigrateTagLocations
*/
class MigrateTagLocations extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
@@ -40,7 +37,7 @@ class MigrateTagLocations extends Command
protected $description = 'Migrate tag locations.'; protected $description = 'Migrate tag locations.';
protected $signature = 'firefly-iii:migrate-tag-locations {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:500-tag-locations {--F|force : Force the execution of this command.}';
/** /**
* Execute the console command. * Execute the console command.

View File

@@ -36,20 +36,13 @@ use FireflyIII\Services\Internal\Destroy\JournalDestroyService;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
/** class UpgradesToGroups extends Command
* This command will take split transactions and migrate them to "transaction groups".
*
* It will only run once, but can be forced to run again.
*
* Class MigrateToGroups
*/
class MigrateToGroups extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_migrated_to_groups'; public const string CONFIG_NAME = '480_migrated_to_groups';
protected $description = 'Migrates a pre-4.7.8 transaction structure to the 4.7.8+ transaction structure.'; protected $description = 'Migrates a pre-4.7.8 transaction structure to the 4.7.8+ transaction structure.';
protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}'; protected $signature = 'upgrade:480-migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
private JournalCLIRepositoryInterface $cliRepository; private JournalCLIRepositoryInterface $cliRepository;
private int $count; private int $count;
private TransactionGroupFactory $groupFactory; private TransactionGroupFactory $groupFactory;
@@ -79,9 +72,6 @@ class MigrateToGroups extends Command
if (0 !== $this->count) { if (0 !== $this->count) {
$this->friendlyInfo(sprintf('Migrated %d transaction journal(s).', $this->count)); $this->friendlyInfo(sprintf('Migrated %d transaction journal(s).', $this->count));
} }
if (0 === $this->count) {
$this->friendlyPositive('No journals to migrate to groups.');
}
$this->markAsMigrated(); $this->markAsMigrated();
return 0; return 0;
@@ -370,9 +360,6 @@ class MigrateToGroups extends Command
$this->giveGroup($array); $this->giveGroup($array);
} }
} }
if (0 === $total) {
$this->friendlyPositive('No need to convert transaction journals.');
}
} }
private function giveGroup(array $array): void private function giveGroup(array $array): void

View File

@@ -34,16 +34,13 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface; use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesTransferCurrencies extends Command
* Class TransferCurrenciesCorrections
*/
class TransferCurrenciesCorrections extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_transfer_currencies'; public const string CONFIG_NAME = '480_transfer_currencies';
protected $description = 'Updates transfer currency information.'; protected $description = 'Updates transfer currency information.';
protected $signature = 'firefly-iii:transfer-currencies {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:480-transfer-currencies {--F|force : Force the execution of this command.}';
private array $accountCurrencies; private array $accountCurrencies;
private AccountRepositoryInterface $accountRepos; private AccountRepositoryInterface $accountRepos;
private JournalCLIRepositoryInterface $cliRepos; private JournalCLIRepositoryInterface $cliRepos;
@@ -71,15 +68,10 @@ class TransferCurrenciesCorrections extends Command
$this->startUpdateRoutine(); $this->startUpdateRoutine();
$this->markAsExecuted(); $this->markAsExecuted();
if ($this->count > 0) {
if (0 === $this->count) { $this->friendlyInfo(sprintf('Verified currency information of %d transfer(s).', $this->count));
$this->friendlyPositive('All transfers have correct currency information.');
return 0;
} }
$this->friendlyInfo(sprintf('Verified currency information of %d transfer(s).', $this->count));
return 0; return 0;
} }

View File

@@ -36,16 +36,13 @@ use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use Illuminate\Console\Command; use Illuminate\Console\Command;
/** class UpgradesVariousCurrencyInformation extends Command
* Class OtherCurrenciesCorrections
*/
class OtherCurrenciesCorrections extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
public const string CONFIG_NAME = '480_other_currencies'; public const string CONFIG_NAME = '480_other_currencies';
protected $description = 'Update all journal currency information.'; protected $description = 'Update all journal currency information.';
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}'; protected $signature = 'upgrade:480-currency-information {--F|force : Force the execution of this command.}';
private array $accountCurrencies; private array $accountCurrencies;
private AccountRepositoryInterface $accountRepos; private AccountRepositoryInterface $accountRepos;
private JournalCLIRepositoryInterface $cliRepos; private JournalCLIRepositoryInterface $cliRepos;

View File

@@ -36,8 +36,6 @@ use Illuminate\Session\TokenMismatchException;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Validation\ValidationException as LaravelValidationException; use Illuminate\Validation\ValidationException as LaravelValidationException;
use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthException; use Laravel\Passport\Exceptions\OAuthServerException as LaravelOAuthException;
use LaravelJsonApi\Core\Exceptions\JsonApiException;
use LaravelJsonApi\Exceptions\ExceptionParser;
use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Exception\OAuthServerException;
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException; use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@@ -65,18 +63,12 @@ class Handler extends ExceptionHandler
HttpException::class, HttpException::class,
SuspiciousOperationException::class, SuspiciousOperationException::class,
BadHttpHeaderException::class, BadHttpHeaderException::class,
JsonApiException::class,
]; ];
/** /**
* Register the exception handling callbacks for the application. * Register the exception handling callbacks for the application.
*/ */
public function register(): void public function register(): void {}
{
$this->renderable(
ExceptionParser::make()->renderable()
);
}
/** /**
* Render an exception into an HTTP response. It's complex but lucky for us, we never use it because * Render an exception into an HTTP response. It's complex but lucky for us, we never use it because

View File

@@ -43,11 +43,11 @@ class PiggyBankFactory
public User $user { public User $user {
set(User $value) { set(User $value) {
$this->user = $value; $this->user = $value;
$this->currencyRepository->setUser($value); $this->currencyRepository->setUser($value);
$this->accountRepository->setUser($value); $this->accountRepository->setUser($value);
$this->piggyBankRepository->setUser($value); $this->piggyBankRepository->setUser($value);
} }
} }
private AccountRepositoryInterface $accountRepository; private AccountRepositoryInterface $accountRepository;
private CurrencyRepositoryInterface $currencyRepository; private CurrencyRepositoryInterface $currencyRepository;
@@ -62,15 +62,11 @@ class PiggyBankFactory
/** /**
* Store a piggy bank or come back with an exception. * Store a piggy bank or come back with an exception.
*
* @param array $data
*
* @return PiggyBank
*/ */
public function store(array $data): PiggyBank public function store(array $data): PiggyBank
{ {
$piggyBankData = $data; $piggyBankData = $data;
// unset some fields // unset some fields
unset($piggyBankData['object_group_title'], $piggyBankData['transaction_currency_code'], $piggyBankData['transaction_currency_id'], $piggyBankData['accounts'], $piggyBankData['object_group_id'], $piggyBankData['notes']); unset($piggyBankData['object_group_title'], $piggyBankData['transaction_currency_code'], $piggyBankData['transaction_currency_id'], $piggyBankData['accounts'], $piggyBankData['object_group_id'], $piggyBankData['notes']);
@@ -94,11 +90,11 @@ class PiggyBankFactory
throw new FireflyException('400005: Could not store new piggy bank.', 0, $e); throw new FireflyException('400005: Could not store new piggy bank.', 0, $e);
} }
$piggyBank = $this->setOrder($piggyBank, $data); $piggyBank = $this->setOrder($piggyBank, $data);
$this->linkToAccountIds($piggyBank, $data['accounts']); $this->linkToAccountIds($piggyBank, $data['accounts']);
$this->piggyBankRepository->updateNote($piggyBank, $data['notes']); $this->piggyBankRepository->updateNote($piggyBank, $data['notes']);
$objectGroupTitle = $data['object_group_title'] ?? ''; $objectGroupTitle = $data['object_group_title'] ?? '';
if ('' !== $objectGroupTitle) { if ('' !== $objectGroupTitle) {
$objectGroup = $this->findOrCreateObjectGroup($objectGroupTitle); $objectGroup = $this->findOrCreateObjectGroup($objectGroupTitle);
if (null !== $objectGroup) { if (null !== $objectGroup) {
@@ -106,7 +102,7 @@ class PiggyBankFactory
} }
} }
// try also with ID // try also with ID
$objectGroupId = (int) ($data['object_group_id'] ?? 0); $objectGroupId = (int) ($data['object_group_id'] ?? 0);
if (0 !== $objectGroupId) { if (0 !== $objectGroupId) {
$objectGroup = $this->findObjectGroupById($objectGroupId); $objectGroup = $this->findObjectGroupById($objectGroupId);
if (null !== $objectGroup) { if (null !== $objectGroup) {
@@ -114,9 +110,10 @@ class PiggyBankFactory
} }
} }
Log::debug('Touch piggy bank'); Log::debug('Touch piggy bank');
$piggyBank->encrypted = false; $piggyBank->encrypted = false;
$piggyBank->save(); $piggyBank->save();
$piggyBank->touch(); $piggyBank->touch();
return $piggyBank; return $piggyBank;
} }
@@ -132,6 +129,7 @@ class PiggyBankFactory
$currency = $this->currencyRepository->find((int) ($data['transaction_currency_id'] ?? 0)); $currency = $this->currencyRepository->find((int) ($data['transaction_currency_id'] ?? 0));
} }
$currency ??= $defaultCurrency; $currency ??= $defaultCurrency;
return $currency; return $currency;
} }
@@ -144,12 +142,12 @@ class PiggyBankFactory
} }
// first find by ID: // first find by ID:
if ($piggyBankId > 0) { if ($piggyBankId > 0) {
$piggyBank = PiggyBank $piggyBank = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', $this->user->id) ->where('accounts.user_id', $this->user->id)
->where('piggy_banks.id', $piggyBankId) ->where('piggy_banks.id', $piggyBankId)
->first(['piggy_banks.*']); ->first(['piggy_banks.*'])
;
if (null !== $piggyBank) { if (null !== $piggyBank) {
return $piggyBank; return $piggyBank;
} }
@@ -169,23 +167,24 @@ class PiggyBankFactory
public function findByName(string $name): ?PiggyBank public function findByName(string $name): ?PiggyBank
{ {
return PiggyBank return PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', $this->user->id) ->where('accounts.user_id', $this->user->id)
->where('piggy_banks.name', $name) ->where('piggy_banks.name', $name)
->first(['piggy_banks.*']); ->first(['piggy_banks.*'])
;
} }
private function setOrder(PiggyBank $piggyBank, array $data): PiggyBank private function setOrder(PiggyBank $piggyBank, array $data): PiggyBank
{ {
$this->resetOrder(); $this->resetOrder();
$order = $this->getMaxOrder() + 1; $order = $this->getMaxOrder() + 1;
if (array_key_exists('order', $data)) { if (array_key_exists('order', $data)) {
$order = $data['order']; $order = $data['order'];
} }
$piggyBank->order = $order; $piggyBank->order = $order;
$piggyBank->saveQuietly(); $piggyBank->saveQuietly();
return $piggyBank; return $piggyBank;
} }
@@ -193,8 +192,7 @@ class PiggyBankFactory
public function resetOrder(): void public function resetOrder(): void
{ {
// TODO duplicate code // TODO duplicate code
$set = PiggyBank $set = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id') ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', $this->user->id) ->where('accounts.user_id', $this->user->id)
->with( ->with(
@@ -202,7 +200,8 @@ class PiggyBankFactory
'objectGroups', 'objectGroups',
] ]
) )
->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*']); ->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*'])
;
$current = 1; $current = 1;
foreach ($set as $piggyBank) { foreach ($set as $piggyBank) {
if ($piggyBank->order !== $current) { if ($piggyBank->order !== $current) {
@@ -214,7 +213,6 @@ class PiggyBankFactory
} }
} }
private function getMaxOrder(): int private function getMaxOrder(): int
{ {
return (int) $this->piggyBankRepository->getPiggyBanks()->max('order'); return (int) $this->piggyBankRepository->getPiggyBanks()->max('order');
@@ -231,8 +229,8 @@ class PiggyBankFactory
foreach ($accounts as $info) { foreach ($accounts as $info) {
if ($account->id === $info['account_id']) { if ($account->id === $info['account_id']) {
if (array_key_exists($account->id, $accounts)) { if (array_key_exists($account->id, $accounts)) {
$toBeLinked[$account->id] = ['current_amount' => $account->pivot->current_amount]; $toBeLinked[$account->id] = ['current_amount' => $account->pivot?->current_amount ?? '0'];
Log::debug(sprintf('Prefilled for account #%d with amount %s', $account->id, $account->pivot->current_amount)); Log::debug(sprintf('Prefilled for account #%d with amount %s', $account->id, $account->pivot?->current_amount ?? '0'));
} }
} }
} }
@@ -247,7 +245,7 @@ class PiggyBankFactory
} }
if (array_key_exists('current_amount', $info)) { if (array_key_exists('current_amount', $info)) {
$toBeLinked[$account->id] = ['current_amount' => $info['current_amount']]; $toBeLinked[$account->id] = ['current_amount' => $info['current_amount']];
Log::debug(sprintf('Will link account #%d with amount %s', $account->id, $account->pivot->current_amount)); Log::debug(sprintf('Will link account #%d with amount %s', $account->id, $account->pivot?->current_amount ?? '0'));
} }
if (!array_key_exists('current_amount', $info)) { if (!array_key_exists('current_amount', $info)) {
$toBeLinked[$account->id] ??= []; $toBeLinked[$account->id] ??= [];

Some files were not shown because too many files have changed in this diff Show More