Compare commits

...

164 Commits
5.4.3 ... 5.4.5

Author SHA1 Message Date
James Cole
e6c0bbf082 Merge branch 'release/5.4.5' into main 2020-10-28 20:26:28 +01:00
James Cole
86ca234625 Update meta files for new release. 2020-10-28 20:25:51 +01:00
James Cole
7bd86fe2b6 Update translations. 2020-10-28 20:22:30 +01:00
James Cole
23356b3884 Cleanup JS 2020-10-28 20:16:21 +01:00
James Cole
ca3d836c83 Add notes to category #4002 2020-10-28 06:32:37 +01:00
James Cole
3aa835a985 Fix #4003 2020-10-28 06:14:12 +01:00
James Cole
7b9f2b6ce5 Fix #4000 2020-10-27 19:04:19 +01:00
James Cole
31a9b03c1a Refactor and cleanup. 2020-10-27 16:26:10 +01:00
James Cole
141436aebb Exclude from code coverage. 2020-10-27 06:53:47 +01:00
James Cole
8d84bffc2d Simplify methods. 2020-10-27 06:53:33 +01:00
James Cole
0fb81a6112 Append sonarqube properties file 2020-10-27 06:41:26 +01:00
James Cole
6563a79483 Clean up code. 2020-10-27 06:40:53 +01:00
James Cole
372c6ac667 Various issues fixed (SonarQube) 2020-10-26 19:15:57 +01:00
James Cole
e4923a3c69 Move JS files 2020-10-26 19:15:35 +01:00
James Cole
54f3e60ae4 Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2020-10-26 17:05:23 +01:00
James Cole
df6f65e0aa Sonarqube properties file. 2020-10-26 16:54:14 +01:00
James Cole
e83fdc58ff Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2020-10-26 16:52:34 +01:00
James Cole
7720482930 Fix bread crumbs 2020-10-26 16:51:49 +01:00
James Cole
c07fae19f9 Remove unused variable. 2020-10-26 16:50:05 +01:00
James Cole
aa3e467a3e Add message so exception isn't empty. 2020-10-26 16:22:20 +01:00
James Cole
c837692d72 Merge pull request #3997 from firefly-iii/dependabot/npm_and_yarn/frontend/develop/axios-0.21.0
Bump axios from 0.20.0 to 0.21.0 in /frontend
2020-10-26 05:58:45 +00:00
dependabot[bot]
61c8b79e30 Bump axios from 0.20.0 to 0.21.0 in /frontend
Bumps [axios](https://github.com/axios/axios) from 0.20.0 to 0.21.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v0.20.0...v0.21.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-26 05:52:19 +00:00
James Cole
d0a8e6eb5b Merge pull request #3996 from firefly-iii/dependabot/composer/develop/phpstan/phpstan-0.12.52
Bump phpstan/phpstan from 0.12.51 to 0.12.52
2020-10-26 05:50:05 +00:00
James Cole
e61236836b Merge pull request #3995 from firefly-iii/dependabot/npm_and_yarn/develop/uiv-1.1.2
Bump uiv from 1.1.1 to 1.1.2
2020-10-26 05:47:16 +00:00
James Cole
a235b60bef Merge pull request #3994 from firefly-iii/dependabot/npm_and_yarn/develop/axios-0.21.0
Bump axios from 0.20.0 to 0.21.0
2020-10-26 05:47:06 +00:00
James Cole
a7d15ef287 Temp fix for tes 2020-10-26 06:45:24 +01:00
James Cole
045cec4421 Fix #3992 2020-10-26 06:43:09 +01:00
dependabot[bot]
465e49476a Bump phpstan/phpstan from 0.12.51 to 0.12.52
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 0.12.51 to 0.12.52.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Commits](https://github.com/phpstan/phpstan/compare/0.12.51...0.12.52)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-26 05:24:43 +00:00
dependabot[bot]
ed6a331faa Bump uiv from 1.1.1 to 1.1.2
Bumps [uiv](https://github.com/uiv-lib/uiv) from 1.1.1 to 1.1.2.
- [Release notes](https://github.com/uiv-lib/uiv/releases)
- [Commits](https://github.com/uiv-lib/uiv/compare/v1.1.1...v1.1.2)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-26 05:19:05 +00:00
dependabot[bot]
f578e2c9e7 Bump axios from 0.20.0 to 0.21.0
Bumps [axios](https://github.com/axios/axios) from 0.20.0 to 0.21.0.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md)
- [Commits](https://github.com/axios/axios/compare/v0.20.0...v0.21.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-26 05:18:49 +00:00
James Cole
e0526508cb Fix #3853 2020-10-26 06:18:09 +01:00
James Cole
9151f44022 Fix #3991 2020-10-26 06:11:55 +01:00
James Cole
276de8a470 fix #3993 2020-10-26 06:10:10 +01:00
James Cole
f6ce49b586 Escape input, fixes #3990 2020-10-25 06:36:33 +01:00
James Cole
cf3d9d26fa Less hysterical about JSON errors 2020-10-25 06:35:58 +01:00
James Cole
265385c833 Merge tag '5.4.4' into develop
5.4.4
2020-10-24 18:55:40 +02:00
James Cole
ca3e4e978d Merge branch 'release/5.4.4' into main 2020-10-24 18:55:36 +02:00
James Cole
0dbfeed639 Update meta files. 2020-10-24 18:52:46 +02:00
James Cole
ca235e2287 Updated meta files for release. 2020-10-24 18:47:47 +02:00
James Cole
9d826519e3 Simplify code. 2020-10-24 18:40:17 +02:00
James Cole
3979e12043 Optimise code. 2020-10-24 17:27:36 +02:00
James Cole
b3f1737495 Reverse logic operators. 2020-10-24 16:59:56 +02:00
James Cole
179a710c5b Better note escape 2020-10-24 16:49:21 +02:00
James Cole
08f347cd57 Fix bad array validation. 2020-10-24 16:49:05 +02:00
James Cole
c910cbe5da Fix #3940 2020-10-24 15:52:51 +02:00
James Cole
34a2ab31df Update composer file. 2020-10-24 08:26:57 +02:00
James Cole
229a3b4284 Update JS 2020-10-24 08:07:30 +02:00
James Cole
dbc878950c Clean up form requests 2020-10-24 07:55:09 +02:00
James Cole
ab4bcd3703 Clean up code. 2020-10-24 07:40:56 +02:00
James Cole
048e5eeb31 Fix #3974 2020-10-24 07:18:37 +02:00
James Cole
a526559a0e Remove unused import statements. 2020-10-23 19:12:46 +02:00
James Cole
8dbd785ab8 Clean up code. 2020-10-23 19:11:25 +02:00
James Cole
0845e1cb7d Fix complicated method. 2020-10-23 18:35:56 +02:00
James Cole
20598d877d Simplify function 2020-10-23 18:33:06 +02:00
James Cole
cf540bf173 Simplify code. 2020-10-23 18:26:18 +02:00
James Cole
a8fcde1459 Fix #3985 2020-10-23 18:15:37 +02:00
James Cole
bcdc562bf7 Fix zero length limit. 2020-10-23 12:33:53 +02:00
James Cole
171f8c5848 Include IP in error message. 2020-10-23 12:30:12 +02:00
James Cole
58bb5eaeae Extra check on activity for #3974 2020-10-23 07:37:06 +02:00
James Cole
fd629d6574 Fix https://github.com/firefly-iii/firefly-iii/issues/3983 2020-10-23 06:20:59 +02:00
James Cole
9bafd067f6 Fix # 2020-10-23 06:15:56 +02:00
James Cole
bc06afe17e Fix #3978 2020-10-22 06:33:55 +02:00
James Cole
250aa989c4 Update JS 2020-10-21 06:45:53 +02:00
James Cole
2e3317b95f Remove account from preferences when set inactive, #3974 2020-10-21 06:29:25 +02:00
James Cole
c8be714d16 Do now show not uploaded attachments #3973 2020-10-21 06:24:27 +02:00
James Cole
2f885d65cc Add some cases for #3973 2020-10-21 06:24:16 +02:00
James Cole
f07c1f7164 Fix bad array 2020-10-21 06:20:11 +02:00
James Cole
ed86c26a18 Fix similar issue in piggies 2020-10-20 04:42:44 +02:00
James Cole
ec787de5e0 Simplify code 2020-10-20 04:36:36 +02:00
James Cole
0d5c09af84 Simplify budget report code. 2020-10-20 04:22:57 +02:00
James Cole
ff32f96295 Simplify report. 2020-10-19 20:34:53 +02:00
James Cole
590591f6bd Fix #3968 2020-10-19 18:44:52 +02:00
James Cole
30f708ba7a Fix bill edit submission group thing. 2020-10-19 18:28:39 +02:00
James Cole
2e3af087e8 Merge pull request #3962 from firefly-iii/dependabot/composer/develop/vimeo/psalm-3.17.2
Bump vimeo/psalm from 3.16 to 3.17.2
2020-10-19 08:39:35 +02:00
James Cole
6ce922e983 Merge pull request #3963 from firefly-iii/dependabot/composer/develop/gdbots/query-parser-2.0.1
Bump gdbots/query-parser from 2.0.0 to 2.0.1
2020-10-19 08:39:27 +02:00
James Cole
f63cff91bf Merge pull request #3964 from firefly-iii/dependabot/composer/develop/filp/whoops-2.8.0
Bump filp/whoops from 2.7.3 to 2.8.0
2020-10-19 08:39:14 +02:00
James Cole
b422ba6547 Merge pull request #3965 from firefly-iii/dependabot/npm_and_yarn/frontend/develop/chart.js-2.9.4
Bump chart.js from 2.9.3 to 2.9.4 in /frontend
2020-10-19 08:39:04 +02:00
dependabot[bot]
114d53befd Bump chart.js from 2.9.3 to 2.9.4 in /frontend
Bumps [chart.js](https://github.com/chartjs/Chart.js) from 2.9.3 to 2.9.4.
- [Release notes](https://github.com/chartjs/Chart.js/releases)
- [Commits](https://github.com/chartjs/Chart.js/compare/v2.9.3...v2.9.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-19 05:47:18 +00:00
dependabot[bot]
076010c058 Bump filp/whoops from 2.7.3 to 2.8.0
Bumps [filp/whoops](https://github.com/filp/whoops) from 2.7.3 to 2.8.0.
- [Release notes](https://github.com/filp/whoops/releases)
- [Changelog](https://github.com/filp/whoops/blob/master/CHANGELOG.md)
- [Commits](https://github.com/filp/whoops/compare/2.7.3...2.8.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-19 05:26:45 +00:00
dependabot[bot]
56a7793bf1 Bump gdbots/query-parser from 2.0.0 to 2.0.1
Bumps [gdbots/query-parser](https://github.com/gdbots/query-parser-php) from 2.0.0 to 2.0.1.
- [Release notes](https://github.com/gdbots/query-parser-php/releases)
- [Changelog](https://github.com/gdbots/query-parser-php/blob/master/CHANGELOG-2.x.md)
- [Commits](https://github.com/gdbots/query-parser-php/compare/v2.0.0...v2.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-19 05:24:10 +00:00
dependabot[bot]
00c610045d Bump vimeo/psalm from 3.16 to 3.17.2
Bumps [vimeo/psalm](https://github.com/vimeo/psalm) from 3.16 to 3.17.2.
- [Release notes](https://github.com/vimeo/psalm/releases)
- [Commits](https://github.com/vimeo/psalm/compare/3.16...3.17.2)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-19 05:21:39 +00:00
James Cole
4b0b2f46ef Merge pull request #3961 from firefly-iii/dependabot/composer/develop/doctrine/dbal-2.11.2
Bump doctrine/dbal from 2.11.1 to 2.11.2
2020-10-19 07:20:11 +02:00
dependabot[bot]
5a53cea90b Bump doctrine/dbal from 2.11.1 to 2.11.2
Bumps [doctrine/dbal](https://github.com/doctrine/dbal) from 2.11.1 to 2.11.2.
- [Release notes](https://github.com/doctrine/dbal/releases)
- [Commits](https://github.com/doctrine/dbal/compare/2.11.1...2.11.2)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-19 05:19:16 +00:00
James Cole
07a3ff01b0 Merge pull request #3960 from firefly-iii/dependabot/composer/develop/phpstan/phpstan-0.12.50
Bump phpstan/phpstan from 0.12.48 to 0.12.50
2020-10-19 07:17:25 +02:00
James Cole
03875d7e41 Merge pull request #3958 from firefly-iii/dependabot/composer/develop/nunomaduro/larastan-0.6.6
Bump nunomaduro/larastan from 0.6.4 to 0.6.6
2020-10-19 07:17:09 +02:00
dependabot[bot]
0e340288e6 Bump phpstan/phpstan from 0.12.48 to 0.12.50
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 0.12.48 to 0.12.50.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Commits](https://github.com/phpstan/phpstan/compare/0.12.48...0.12.50)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-19 05:16:51 +00:00
James Cole
1183c40114 Merge pull request #3959 from firefly-iii/dependabot/composer/develop/league/commonmark-1.5.6
Bump league/commonmark from 1.5.5 to 1.5.6
2020-10-19 07:16:51 +02:00
dependabot[bot]
06ab9df6fc Bump league/commonmark from 1.5.5 to 1.5.6
Bumps [league/commonmark](https://github.com/thephpleague/commonmark) from 1.5.5 to 1.5.6.
- [Release notes](https://github.com/thephpleague/commonmark/releases)
- [Changelog](https://github.com/thephpleague/commonmark/blob/1.5.6/CHANGELOG.md)
- [Commits](https://github.com/thephpleague/commonmark/compare/1.5.5...1.5.6)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-19 05:13:43 +00:00
dependabot[bot]
b871dab5fe Bump nunomaduro/larastan from 0.6.4 to 0.6.6
Bumps [nunomaduro/larastan](https://github.com/nunomaduro/larastan) from 0.6.4 to 0.6.6.
- [Release notes](https://github.com/nunomaduro/larastan/releases)
- [Changelog](https://github.com/nunomaduro/larastan/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nunomaduro/larastan/compare/v0.6.4...v0.6.6)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-19 05:11:26 +00:00
James Cole
054eecf541 Optimise code. 2020-10-19 06:41:31 +02:00
James Cole
348452ec7d Simplify method. 2020-10-19 06:41:01 +02:00
James Cole
1f5934d6e2 Use trait, not class extension as an experiment. 2020-10-19 06:23:22 +02:00
James Cole
60fa6c775b Merge pull request #3957 from bu4ak/add-logged-in-request
Add base request that check user's auth
2020-10-19 06:11:34 +02:00
bu4ak
ed98c01ba0 Add LoggedInRequest 2020-10-18 20:24:47 +02:00
James Cole
198c79c048 Simplify transformer. 2020-10-18 17:44:30 +02:00
James Cole
3cd331062d Cleanup code. 2020-10-18 16:44:34 +02:00
James Cole
22f1e4db31 Simplify method. 2020-10-18 16:36:19 +02:00
James Cole
68693f20bb Slight reorder of shields. 2020-10-18 12:52:16 +02:00
James Cole
54a4c25152 Slight reorder of shields. 2020-10-18 12:51:21 +02:00
James Cole
21c615818c Slight reorder of shields. 2020-10-18 12:48:30 +02:00
James Cole
204d7e57bd Merge pull request #3954 from lastlink/patch-4
add travis build badge
2020-10-18 12:43:17 +02:00
James Cole
cd151da240 Simplify chart code with external helper. 2020-10-18 12:41:49 +02:00
lastlink
687a62fe26 add travis build badge 2020-10-18 04:25:39 -04:00
James Cole
0bf0b762b8 Simplify command. 2020-10-18 08:25:56 +02:00
James Cole
53a6af7779 Simplify code 2020-10-18 08:06:00 +02:00
James Cole
4c10f2b960 Test improv 2020-10-18 08:01:22 +02:00
James Cole
2630732b8a Code cleanup [skip ci] 2020-10-18 08:01:10 +02:00
James Cole
b8774a7af3 Code cleanup [skip ci] 2020-10-18 08:00:49 +02:00
James Cole
7a89df749d Fix #3953 2020-10-18 07:59:28 +02:00
James Cole
937c11e83c Update translations + JS 2020-10-17 21:41:13 +02:00
James Cole
a79f7e3b59 Better code. 2020-10-17 09:12:51 +02:00
James Cole
c1b52524b1 #3909 2020-10-17 09:12:38 +02:00
James Cole
04d451be8d Fix #3871 2020-10-17 09:02:52 +02:00
James Cole
e5109d6a0f Fix #3942 2020-10-17 08:57:58 +02:00
James Cole
c404354890 Fix missing var 2020-10-17 08:56:38 +02:00
James Cole
01fbe89295 Better catch for long queries, #3903 2020-10-17 08:53:32 +02:00
James Cole
388da769bb Upgrade and move some scripts. 2020-10-17 07:02:18 +02:00
James Cole
0d4f203fae Stop escaping notes, move to parser. 2020-10-13 17:48:50 +02:00
James Cole
96dbd633bf Fix #3914 2020-10-13 06:51:44 +02:00
James Cole
4b1f4ae319 Fix #3915 2020-10-13 06:48:11 +02:00
James Cole
13e15d0476 Fix # 2020-10-13 06:36:34 +02:00
James Cole
7c962c617a Debug for #3903 2020-10-13 06:35:47 +02:00
James Cole
4e51f0abc4 Clean up some code. 2020-10-13 06:35:33 +02:00
James Cole
3bd5ac21c9 Fix #3901 2020-10-13 06:28:07 +02:00
James Cole
d7b872eeaa Merge pull request #3931 from firefly-iii/dependabot/npm_and_yarn/frontend/develop/sass-1.27.0
Bump sass from 1.26.11 to 1.27.0 in /frontend
2020-10-12 08:13:08 +00:00
dependabot[bot]
c868a6374d Bump sass from 1.26.11 to 1.27.0 in /frontend
Bumps [sass](https://github.com/sass/dart-sass) from 1.26.11 to 1.27.0.
- [Release notes](https://github.com/sass/dart-sass/releases)
- [Changelog](https://github.com/sass/dart-sass/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sass/dart-sass/compare/1.26.11...1.27.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-12 07:20:53 +00:00
James Cole
e61720754a Merge pull request #3926 from firefly-iii/dependabot/npm_and_yarn/develop/vue-i18n-8.22.0
Bump vue-i18n from 8.21.1 to 8.22.0
2020-10-12 06:30:55 +00:00
James Cole
f9f0eaefbe Merge pull request #3928 from firefly-iii/dependabot/composer/develop/phpunit/phpunit-9.4.1
Bump phpunit/phpunit from 9.4.0 to 9.4.1
2020-10-12 06:29:12 +00:00
James Cole
5712739df1 Merge pull request #3929 from firefly-iii/dependabot/composer/develop/laravel/framework-7.28.4
Bump laravel/framework from 7.28.3 to 7.28.4
2020-10-12 06:29:01 +00:00
James Cole
6e7152a200 Merge pull request #3930 from firefly-iii/dependabot/npm_and_yarn/frontend/develop/fortawesome/fontawesome-free-5.15.1
Bump @fortawesome/fontawesome-free from 5.15.0 to 5.15.1 in /frontend
2020-10-12 06:28:33 +00:00
James Cole
f2b8aab1d2 Merge pull request #3927 from firefly-iii/dependabot/npm_and_yarn/develop/uiv-1.1.1
Bump uiv from 1.0.1 to 1.1.1
2020-10-12 06:26:50 +00:00
James Cole
59f2e9cf72 Merge pull request #3925 from firefly-iii/dependabot/npm_and_yarn/develop/laravel-mix-5.0.7
Bump laravel-mix from 5.0.5 to 5.0.7
2020-10-12 06:26:30 +00:00
James Cole
3a0793b26a Merge pull request #3933 from firefly-iii/dependabot/npm_and_yarn/frontend/develop/sass-loader-10.0.3
Bump sass-loader from 10.0.2 to 10.0.3 in /frontend
2020-10-12 06:26:09 +00:00
James Cole
659df750d8 Merge pull request #3932 from firefly-iii/dependabot/npm_and_yarn/frontend/develop/vue-router-3.4.6
Bump vue-router from 3.4.5 to 3.4.6 in /frontend
2020-10-12 06:25:55 +00:00
James Cole
b5983f7e99 Merge pull request #3934 from firefly-iii/dependabot/npm_and_yarn/frontend/develop/laravel-mix-5.0.7
Bump laravel-mix from 5.0.5 to 5.0.7 in /frontend
2020-10-12 06:25:44 +00:00
dependabot[bot]
86d0d18b00 Bump laravel-mix from 5.0.5 to 5.0.7 in /frontend
Bumps [laravel-mix](https://github.com/JeffreyWay/laravel-mix) from 5.0.5 to 5.0.7.
- [Release notes](https://github.com/JeffreyWay/laravel-mix/releases)
- [Commits](https://github.com/JeffreyWay/laravel-mix/compare/v5.0.5...v5.0.7)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-12 05:54:12 +00:00
dependabot[bot]
28f71963f1 Bump sass-loader from 10.0.2 to 10.0.3 in /frontend
Bumps [sass-loader](https://github.com/webpack-contrib/sass-loader) from 10.0.2 to 10.0.3.
- [Release notes](https://github.com/webpack-contrib/sass-loader/releases)
- [Changelog](https://github.com/webpack-contrib/sass-loader/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webpack-contrib/sass-loader/compare/v10.0.2...v10.0.3)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-12 05:52:46 +00:00
dependabot[bot]
27f91365b4 Bump vue-router from 3.4.5 to 3.4.6 in /frontend
Bumps [vue-router](https://github.com/vuejs/vue-router) from 3.4.5 to 3.4.6.
- [Release notes](https://github.com/vuejs/vue-router/releases)
- [Changelog](https://github.com/vuejs/vue-router/blob/dev/CHANGELOG.md)
- [Commits](https://github.com/vuejs/vue-router/compare/v3.4.5...v3.4.6)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-12 05:51:46 +00:00
dependabot[bot]
8d11fecfeb Bump @fortawesome/fontawesome-free from 5.15.0 to 5.15.1 in /frontend
Bumps [@fortawesome/fontawesome-free](https://github.com/FortAwesome/Font-Awesome) from 5.15.0 to 5.15.1.
- [Release notes](https://github.com/FortAwesome/Font-Awesome/releases)
- [Changelog](https://github.com/FortAwesome/Font-Awesome/blob/master/CHANGELOG.md)
- [Commits](https://github.com/FortAwesome/Font-Awesome/compare/5.15.0...5.15.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-12 05:50:06 +00:00
dependabot[bot]
c10a955928 Bump laravel/framework from 7.28.3 to 7.28.4
Bumps [laravel/framework](https://github.com/laravel/framework) from 7.28.3 to 7.28.4.
- [Release notes](https://github.com/laravel/framework/releases)
- [Changelog](https://github.com/laravel/framework/blob/8.x/CHANGELOG-6.x.md)
- [Commits](https://github.com/laravel/framework/compare/v7.28.3...v7.28.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-12 05:20:49 +00:00
dependabot[bot]
d5a12d56a6 Bump phpunit/phpunit from 9.4.0 to 9.4.1
Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.4.0 to 9.4.1.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-9.4.md)
- [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.4.0...9.4.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-12 05:18:18 +00:00
dependabot[bot]
f869ebbb30 Bump uiv from 1.0.1 to 1.1.1
Bumps [uiv](https://github.com/uiv-lib/uiv) from 1.0.1 to 1.1.1.
- [Release notes](https://github.com/uiv-lib/uiv/releases)
- [Commits](https://github.com/uiv-lib/uiv/compare/v1.0.1...v1.1.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-12 05:07:29 +00:00
dependabot[bot]
3471c964d0 Bump vue-i18n from 8.21.1 to 8.22.0
Bumps [vue-i18n](https://github.com/kazupon/vue-i18n) from 8.21.1 to 8.22.0.
- [Release notes](https://github.com/kazupon/vue-i18n/releases)
- [Changelog](https://github.com/kazupon/vue-i18n/blob/v8.x/CHANGELOG.md)
- [Commits](https://github.com/kazupon/vue-i18n/compare/v8.21.1...v8.22.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-12 05:07:08 +00:00
dependabot[bot]
94b1934877 Bump laravel-mix from 5.0.5 to 5.0.7
Bumps [laravel-mix](https://github.com/JeffreyWay/laravel-mix) from 5.0.5 to 5.0.7.
- [Release notes](https://github.com/JeffreyWay/laravel-mix/releases)
- [Commits](https://github.com/JeffreyWay/laravel-mix/compare/v5.0.5...v5.0.7)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-12 05:06:49 +00:00
James Cole
adfd3ab3ac Update commands and test factories 2020-10-10 11:21:45 +02:00
James Cole
a42008dd7b Add captions 2020-10-10 11:21:25 +02:00
James Cole
acfc976f6d New tests 2020-10-10 11:21:14 +02:00
James Cole
76cfdef27d Remove old tests. To be reinstated later. 2020-10-10 11:20:52 +02:00
James Cole
d75f33558d Merge pull request #3913 from vcrazyV/ruble_currency_fix
Fix space ruble currency name
2020-10-07 04:08:02 +00:00
Viktor Yakovlev
7345a558ce fix ruble currency name 2020-10-06 21:24:48 +03:00
James Cole
5ba93dda9f Merge pull request #3908 from firefly-iii/dependabot/npm_and_yarn/develop/uiv-1.0.1
Bump uiv from 0.37.0 to 1.0.1
2020-10-05 08:49:52 +02:00
dependabot[bot]
a94195ae45 Bump uiv from 0.37.0 to 1.0.1
Bumps [uiv](https://github.com/uiv-lib/uiv) from 0.37.0 to 1.0.1.
- [Release notes](https://github.com/uiv-lib/uiv/releases)
- [Commits](https://github.com/uiv-lib/uiv/compare/v0.37.0...v1.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-05 05:10:12 +00:00
James Cole
0b8415e82b Debug for #3897 2020-10-04 17:11:59 +02:00
James Cole
a5c37f1e4a Fix #3902 2020-10-04 16:50:16 +02:00
James Cole
7bd0b09711 Fix #3900 2020-10-04 13:45:39 +02:00
James Cole
64370229d8 Fix #3900 2020-10-04 13:44:55 +02:00
James Cole
6671c6d45c Create some new test code. 2020-10-04 10:56:10 +02:00
James Cole
a2eedb3742 Fix #3898 2020-10-04 09:19:36 +02:00
James Cole
3bae5e236b Fix #3885 2020-10-04 07:56:03 +02:00
James Cole
9f4e950a70 Fix hard coded site ID 2020-10-04 07:25:30 +02:00
James Cole
4d2d9d4d6e Whoops. Fixed self-referencing constant. 2020-10-04 07:20:48 +02:00
James Cole
61ffc8ada6 Switch should have default thing. 2020-10-03 17:53:23 +02:00
James Cole
b8e36b0398 Replace string with constant. 2020-10-03 16:51:44 +02:00
James Cole
d89e4ec143 Merge tag '5.4.3' into develop
5.4.3
2020-10-03 16:23:09 +02:00
828 changed files with 8817 additions and 58508 deletions

View File

@@ -60,7 +60,7 @@ class AboutController extends Controller
'driver' => $currentDriver,
];
return response()->json(['data' => $data])->header('Content-Type', 'application/vnd.api+json');
return response()->json(['data' => $data])->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -78,6 +78,6 @@ class AboutController extends Controller
$resource = new Item(auth()->user(), $transformer, 'users');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -102,7 +102,7 @@ class AccountController extends Controller
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -155,7 +155,7 @@ class AccountController extends Controller
$resource = new FractalCollection($accounts, $transformer, self::RESOURCE_KEY);
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -191,7 +191,7 @@ class AccountController extends Controller
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy_banks');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -211,7 +211,7 @@ class AccountController extends Controller
$transformer->setParameters($this->parameters);
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -233,7 +233,7 @@ class AccountController extends Controller
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -283,7 +283,7 @@ class AccountController extends Controller
$resource = new FractalCollection($groups, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -306,6 +306,6 @@ class AccountController extends Controller
$transformer->setParameters($this->parameters);
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -95,8 +95,8 @@ class AttachmentController extends Controller
* @param Attachment $attachment
*
* @codeCoverageIgnore
* @throws FireflyException
* @return LaravelResponse
* @throws FireflyException
*/
public function download(Attachment $attachment): LaravelResponse
{
@@ -160,7 +160,7 @@ class AttachmentController extends Controller
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -179,7 +179,7 @@ class AttachmentController extends Controller
$resource = new Item($attachment, $transformer, 'attachments');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -187,8 +187,8 @@ class AttachmentController extends Controller
*
* @param AttachmentStoreRequest $request
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function store(AttachmentStoreRequest $request): JsonResponse
{
@@ -202,7 +202,7 @@ class AttachmentController extends Controller
$resource = new Item($attachment, $transformer, 'attachments');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -225,7 +225,7 @@ class AttachmentController extends Controller
$resource = new Item($attachment, $transformer, 'attachments');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**

View File

@@ -41,7 +41,6 @@ class AccountController extends Controller
use AccountFilter;
private array $balanceTypes;
private AccountRepositoryInterface $repository;
@@ -76,16 +75,14 @@ class AccountController extends Controller
$query = $data['query'];
$date = $data['date'] ?? today(config('app.timezone'));
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$return = [];
$result = $repository->searchAccount((string) $query, $types, $data['limit']);
$result = $this->repository->searchAccount((string) $query, $types, $data['limit']);
$defaultCurrency = app('amount')->getDefaultCurrency();
/** @var Account $account */
foreach ($result as $account) {
$nameWithBalance = $account->name;
$currency = $repository->getAccountCurrency($account) ?? $defaultCurrency;
$currency = $this->repository->getAccountCurrency($account) ?? $defaultCurrency;
if (in_array($account->accountType->type, $this->balanceTypes, true)) {
$balance = app('steam')->balance($account, $date);

View File

@@ -58,7 +58,6 @@ class BillController extends Controller
}
/**
* TODO add limit
* @param AutocompleteRequest $request
*
* @return JsonResponse

View File

@@ -58,7 +58,6 @@ class BudgetController extends Controller
}
/**
* TODO add limit
* @param AutocompleteRequest $request
*
* @return JsonResponse

View File

@@ -89,7 +89,7 @@ class CurrencyController extends Controller
*/
public function currencies(AutocompleteRequest $request): JsonResponse
{
$data = $request->getData();
$data = $request->getData();
$collection = $this->repository->searchCurrency($data['query'], $data['limit']);
$result = [];

View File

@@ -76,7 +76,7 @@ class PiggyBankController extends Controller
/** @var PiggyBank $piggy */
foreach ($piggies as $piggy) {
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;
$response[] = [
'id' => $piggy->id,
'name' => $piggy->name,
@@ -103,9 +103,9 @@ class PiggyBankController extends Controller
$response = [];
/** @var PiggyBank $piggy */
foreach ($piggies as $piggy) {
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;
$currentAmount = $this->piggyRepository->getRepetition($piggy)->currentamount ?? '0';
$response[] = [
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;
$currentAmount = $this->piggyRepository->getRepetition($piggy)->currentamount ?? '0';
$response[] = [
'id' => $piggy->id,
'name' => $piggy->name,
'name_with_balance' => sprintf(

View File

@@ -111,7 +111,7 @@ class AvailableBudgetController extends Controller
$resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -132,7 +132,7 @@ class AvailableBudgetController extends Controller
$resource = new Item($availableBudget, $transformer, 'available_budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -165,7 +165,7 @@ class AvailableBudgetController extends Controller
$resource = new Item($availableBudget, $transformer, 'available_budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -205,7 +205,7 @@ class AvailableBudgetController extends Controller
$resource = new Item($availableBudget, $transformer, 'available_budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -24,7 +24,8 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers;
use FireflyIII\Api\V1\Requests\BillRequest;
use FireflyIII\Api\V1\Requests\BillUpdateRequest;
use FireflyIII\Api\V1\Requests\BillStoreRequest;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Models\Bill;
@@ -49,8 +50,7 @@ class BillController extends Controller
{
use TransactionFilter;
/** @var BillRepositoryInterface The bill repository */
private $repository;
private BillRepositoryInterface $repository;
/**
@@ -103,7 +103,7 @@ class BillController extends Controller
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -143,7 +143,7 @@ class BillController extends Controller
$resource = new FractalCollection($bills, $transformer, 'bills');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -178,7 +178,7 @@ class BillController extends Controller
$resource = new FractalCollection($rules, $transformer, 'rules');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -199,18 +199,18 @@ class BillController extends Controller
$resource = new Item($bill, $transformer, 'bills');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
* Store a bill.
*
* @param BillRequest $request
* @param BillStoreRequest $request
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function store(BillRequest $request): JsonResponse
public function store(BillStoreRequest $request): JsonResponse
{
$bill = $this->repository->store($request->getAll());
$manager = $this->getManager();
@@ -221,7 +221,7 @@ class BillController extends Controller
$resource = new Item($bill, $transformer, 'bills');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -279,18 +279,18 @@ class BillController extends Controller
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
* Update a bill.
*
* @param BillRequest $request
* @param BillUpdateRequest $request
* @param Bill $bill
*
* @return JsonResponse
*/
public function update(BillRequest $request, Bill $bill): JsonResponse
public function update(BillUpdateRequest $request, Bill $bill): JsonResponse
{
$data = $request->getAll();
$bill = $this->repository->update($bill, $data);
@@ -302,7 +302,7 @@ class BillController extends Controller
$resource = new Item($bill, $transformer, 'bills');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -23,8 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers;
use Exception;
use FireflyIII\Api\V1\Requests\BudgetLimitRequest;
use FireflyIII\Api\V1\Requests\BudgetStoreRequest;
use FireflyIII\Api\V1\Requests\BudgetUpdateRequest;
use FireflyIII\Exceptions\FireflyException;
@@ -109,7 +107,7 @@ class BudgetController extends Controller
$resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -138,7 +136,7 @@ class BudgetController extends Controller
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -185,7 +183,7 @@ class BudgetController extends Controller
$resource = new FractalCollection($budgets, $transformer, 'budgets');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -206,7 +204,7 @@ class BudgetController extends Controller
$resource = new Item($budget, $transformer, 'budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -214,9 +212,9 @@ class BudgetController extends Controller
*
* @param BudgetStoreRequest $request
*
* @return JsonResponse
* @throws FireflyException
*
* @return JsonResponse
*/
public function store(BudgetStoreRequest $request): JsonResponse
{
@@ -229,7 +227,7 @@ class BudgetController extends Controller
$resource = new Item($budget, $transformer, 'budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -293,7 +291,7 @@ class BudgetController extends Controller
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -316,7 +314,7 @@ class BudgetController extends Controller
$resource = new Item($budget, $transformer, 'budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}

View File

@@ -129,7 +129,7 @@ class BudgetLimitController extends Controller
$resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -150,7 +150,7 @@ class BudgetLimitController extends Controller
$resource = new Item($budgetLimit, $transformer, 'budget_limits');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -178,7 +178,7 @@ class BudgetLimitController extends Controller
$resource = new Item($budgetLimit, $transformer, 'budget_limits');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -231,7 +231,7 @@ class BudgetLimitController extends Controller
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -244,9 +244,9 @@ class BudgetLimitController extends Controller
*/
public function update(BudgetLimitRequest $request, BudgetLimit $budgetLimit): JsonResponse
{
$data = $request->getAll();
$budgetLimit = $this->blRepository->update($budgetLimit, $data);
$manager = $this->getManager();
$data = $request->getAll();
$budgetLimit = $this->blRepository->update($budgetLimit, $data);
$manager = $this->getManager();
/** @var BudgetLimitTransformer $transformer */
$transformer = app(BudgetLimitTransformer::class);
@@ -254,7 +254,7 @@ class BudgetLimitController extends Controller
$resource = new Item($budgetLimit, $transformer, 'budget_limits');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -99,7 +99,7 @@ class CategoryController extends Controller
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -147,7 +147,7 @@ class CategoryController extends Controller
$resource = new FractalCollection($categories, $transformer, 'categories');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -169,7 +169,7 @@ class CategoryController extends Controller
$resource = new Item($category, $transformer, 'categories');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -177,8 +177,8 @@ class CategoryController extends Controller
*
* @param CategoryRequest $request
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function store(CategoryRequest $request): JsonResponse
{
@@ -191,7 +191,7 @@ class CategoryController extends Controller
$resource = new Item($category, $transformer, 'categories');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -247,7 +247,7 @@ class CategoryController extends Controller
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -270,7 +270,7 @@ class CategoryController extends Controller
$resource = new Item($category, $transformer, 'categories');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}

View File

@@ -31,7 +31,6 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Budget\OperationsRepositoryInterface;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection;
/**
* Class AvailableBudgetController

View File

@@ -58,13 +58,10 @@ class BudgetController extends Controller
$this->middleware(
function ($request, $next) {
//$this->generator = app(GeneratorInterface::class);
$this->repository = app(BudgetRepositoryInterface::class);
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
//$this->nbRepository = app(NoBudgetRepositoryInterface::class);
return $next($request);
}
);
@@ -134,94 +131,6 @@ class BudgetController extends Controller
return $arr;
}
/**
* @param array $budgetNames
* @param array $currencyNames
*
* @return array
*/
private function createSets(array $budgetNames, array $currencyNames): array
{
$return = [];
foreach ($currencyNames as $currencyName) {
$entries = [];
foreach ($budgetNames as $budgetName) {
$label = sprintf('%s (%s)', $budgetName, $currencyName);
$entries[$label] = '0';
}
// left
$return['left'] = [
'label' => sprintf('%s (%s)', trans('firefly.left'), $currencyName),
'data_type' => 'left',
'currency_name' => $currencyName,
'type' => 'bar',
'yAxisID' => 0, // 0, 1, 2
'entries' => $entries,
];
// spent_capped
$return['spent_capped'] = [
'label' => sprintf('%s (%s)', trans('firefly.spent'), $currencyName),
'data_type' => 'spent_capped',
'currency_name' => $currencyName,
'type' => 'bar',
'yAxisID' => 0, // 0, 1, 2
'entries' => $entries,
];
// overspent
$return['overspent'] = [
'label' => sprintf('%s (%s)', trans('firefly.overspent'), $currencyName),
'data_type' => 'overspent',
'currency_name' => $currencyName,
'type' => 'bar',
'yAxisID' => 0, // 0, 1, 2
'entries' => $entries,
];
}
return $return;
}
/**
* @param array $basic
* @param array $sets
*
* @return array
*/
private function fillSets(array $basic, array $sets): array
{
foreach ($sets as $set) {
$label = $set['label'];
//$basic['spent']['entries'][$label] = $set['entries']['spent'];
$basic['spent_capped']['entries'][$label] = $set['entries']['spent_capped'];
$basic['left']['entries'][$label] = $set['entries']['left'];
$basic['overspent']['entries'][$label] = $set['entries']['overspent'];
}
return $basic;
}
/**
* @param array $expenses
*
* @return array
*/
private function filterNulls(array $expenses): array
{
$return = [];
/** @var array|null $arr */
foreach ($expenses as $arr) {
if ([] !== $arr) {
$return[] = $arr;
}
}
return $return;
}
/**
* @param Budget $budget
* @param Carbon $start
@@ -292,10 +201,97 @@ class BudgetController extends Controller
$return['entries']['spent'] = $sumSpent;
$return['entries']['amount'] = $limit->amount;
$return['entries']['spent_capped'] = 1 === bccomp($sumSpent, $limit->amount) ? $limit->amount : $sumSpent;
$return['entries']['left'] = 1 === bccomp($limit->amount, $sumSpent) ? bcadd($set['sum'], $limit->amount) : '0'; // left
$return['entries']['left'] = 1 === bccomp($limit->amount, $sumSpent) ? bcadd($set['sum'], $limit->amount) : '0'; // left
$return['entries']['overspent'] = 1 === bccomp($limit->amount, $sumSpent) ? '0' : bcmul(bcadd($set['sum'], $limit->amount), '-1'); // overspent
return $return;
}
/**
* @param array $expenses
*
* @return array
*/
private function filterNulls(array $expenses): array
{
$return = [];
/** @var array|null $arr */
foreach ($expenses as $arr) {
if ([] !== $arr) {
$return[] = $arr;
}
}
return $return;
}
/**
* @param array $budgetNames
* @param array $currencyNames
*
* @return array
*/
private function createSets(array $budgetNames, array $currencyNames): array
{
$return = [];
foreach ($currencyNames as $currencyName) {
$entries = [];
foreach ($budgetNames as $budgetName) {
$label = sprintf('%s (%s)', $budgetName, $currencyName);
$entries[$label] = '0';
}
// left
$return['left'] = [
'label' => sprintf('%s (%s)', trans('firefly.left'), $currencyName),
'data_type' => 'left',
'currency_name' => $currencyName,
'type' => 'bar',
'yAxisID' => 0, // 0, 1, 2
'entries' => $entries,
];
// spent_capped
$return['spent_capped'] = [
'label' => sprintf('%s (%s)', trans('firefly.spent'), $currencyName),
'data_type' => 'spent_capped',
'currency_name' => $currencyName,
'type' => 'bar',
'yAxisID' => 0, // 0, 1, 2
'entries' => $entries,
];
// overspent
$return['overspent'] = [
'label' => sprintf('%s (%s)', trans('firefly.overspent'), $currencyName),
'data_type' => 'overspent',
'currency_name' => $currencyName,
'type' => 'bar',
'yAxisID' => 0, // 0, 1, 2
'entries' => $entries,
];
}
return $return;
}
/**
* @param array $basic
* @param array $sets
*
* @return array
*/
private function fillSets(array $basic, array $sets): array
{
foreach ($sets as $set) {
$label = $set['label'];
$basic['spent_capped']['entries'][$label] = $set['entries']['spent_capped'];
$basic['left']['entries'][$label] = $set['entries']['left'];
$basic['overspent']['entries'][$label] = $set['entries']['overspent'];
}
return $basic;
}
}

View File

@@ -38,15 +38,10 @@ use Illuminate\Http\JsonResponse;
*/
class CategoryController extends Controller
{
/** @var CategoryRepositoryInterface */
private $categoryRepository;
/** @var NoCategoryRepositoryInterface */
private $noCatRepository;
/** @var OperationsRepositoryInterface */
private $opsRepository;
private CategoryRepositoryInterface $categoryRepository;
private NoCategoryRepositoryInterface $noCatRepository;
private OperationsRepositoryInterface $opsRepository;
private array $categories;
/**
* AccountController constructor.
@@ -63,6 +58,7 @@ class CategoryController extends Controller
$this->categoryRepository = app(CategoryRepositoryInterface::class);
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->noCatRepository = app(NoCategoryRepositoryInterface::class);
$this->categories = [];
$this->categoryRepository->setUser($user);
$this->opsRepository->setUser($user);
$this->noCatRepository->setUser($user);
@@ -87,53 +83,75 @@ class CategoryController extends Controller
/** @var Carbon $end */
$end = $dates['end'];
$tempData = [];
$spentWith = $this->opsRepository->listExpenses($start, $end);
$spentWithout = $this->noCatRepository->listExpenses($start, $end);
$tempData = [];
$spentWith = $this->opsRepository->listExpenses($start, $end);
$spentWithout = $this->noCatRepository->listExpenses($start, $end);
$categories = [];
/** @var array $set */
foreach ([$spentWith, $spentWithout,] as $set) {
$tempData = $this->processArray($tempData, $set);
}
$chartData = $this->sortArray($tempData);
foreach ([$spentWith, $spentWithout, ] as $set) {
foreach ($set as $currency) {
foreach ($currency['categories'] as $category) {
$categories[] = $category['name'];
$outKey = sprintf('%d-e', $currency['currency_id']);
$tempData[$outKey] = $tempData[$outKey] ?? [
'currency_id' => $currency['currency_id'],
'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),
'currency_code' => $currency['currency_code'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'type' => 'bar', // line, area or bar
'yAxisID' => 0, // 0, 1, 2
'entries' => [],
];
return response()->json($chartData);
}
foreach ($category['transaction_journals'] as $journal) {
// is it expense or income?
$currentKey = sprintf('%d-%s', $currency['currency_id'], 'e');
$name = $category['name'];
$tempData[$currentKey]['entries'][$name] = $tempData[$currentKey]['entries'][$name] ?? '0';
$tempData[$currentKey]['entries'][$name] = bcadd($tempData[$currentKey]['entries'][$name], $journal['amount']);
}
/**
* @param array $tempData
* @param array $set
*
* @return array
*/
private function processArray(array $tempData, array $set): array
{
foreach ($set as $currency) {
foreach ($currency['categories'] as $category) {
$this->categories[] = $category['name'];
$outKey = sprintf('%d-e', $currency['currency_id']);
$tempData[$outKey] = $tempData[$outKey] ?? [
'currency_id' => $currency['currency_id'],
'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),
'currency_code' => $currency['currency_code'],
'currency_symbol' => $currency['currency_symbol'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'type' => 'bar', // line, area or bar
'yAxisID' => 0, // 0, 1, 2
'entries' => [],
];
foreach ($category['transaction_journals'] as $journal) {
// is it expense or income?
$currentKey = sprintf('%d-%s', $currency['currency_id'], 'e');
$name = $category['name'];
$tempData[$currentKey]['entries'][$name] = $tempData[$currentKey]['entries'][$name] ?? '0';
$tempData[$currentKey]['entries'][$name] = bcadd($tempData[$currentKey]['entries'][$name], $journal['amount']);
}
}
}
return $tempData;
}
/**
* @param array $tempData
*
* @return array
*/
private function sortArray(array $tempData): array
{
// re-sort every spent array and add 0 for missing entries.
foreach ($tempData as $index => $set) {
$oldSet = $set['entries'];
$newSet = [];
foreach ($categories as $category) {
foreach ($this->categories as $category) {
$value = $oldSet[$category] ?? '0';
$value = -1 === bccomp($value, '0') ? bcmul($value, '-1') : $value;
$newSet[$category] = $value;
}
$tempData[$index]['entries'] = $newSet;
}
$chartData = array_values($tempData);
return response()->json($chartData);
return array_values($tempData);
}
}

View File

@@ -71,24 +71,7 @@ class ConfigurationController extends Controller
{
$configData = $this->getConfigData();
return response()->json(['data' => $configData])->header('Content-Type', 'application/vnd.api+json');
}
/**
* Update the configuration.
*
* @param ConfigurationRequest $request
* @param string $name
*
* @return JsonResponse
*/
public function update(ConfigurationRequest $request, string $name): JsonResponse
{
$data = $request->getAll();
app('fireflyconfig')->set($name, $data['value']);
$configData = $this->getConfigData();
return response()->json(['data' => $configData])->header('Content-Type', 'application/vnd.api+json');
return response()->json(['data' => $configData])->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -114,4 +97,21 @@ class ConfigurationController extends Controller
'single_user_mode' => null === $singleUser ? null : $singleUser->data,
];
}
/**
* Update the configuration.
*
* @param ConfigurationRequest $request
* @param string $name
*
* @return JsonResponse
*/
public function update(ConfigurationRequest $request, string $name): JsonResponse
{
$data = $request->getAll();
app('fireflyconfig')->set($name, $data['value']);
$configData = $this->getConfigData();
return response()->json(['data' => $configData])->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -44,9 +44,9 @@ abstract class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
protected const CONTENT_TYPE = 'application/vnd.api+json';
protected ParameterBag $parameters;
/**
* Controller constructor.
*/
@@ -60,46 +60,11 @@ abstract class Controller extends BaseController
$language = app('steam')->getLanguage();
app()->setLocale($language);
}
return $next($request);
});
}
/**
* Method to help build URI's.
*
* @return string
*/
final protected function buildParams(): string
{
$return = '?';
$params = [];
foreach ($this->parameters as $key => $value) {
if ('page' === $key) {
continue;
}
if ($value instanceof Carbon) {
$params[$key] = $value->format('Y-m-d');
continue;
}
$params[$key] = $value;
}
$return .= http_build_query($params);
);
return $return;
}
/**
* @return Manager
*/
final protected function getManager(): Manager
{
// create some objects:
$manager = new Manager;
$baseUrl = request()->getSchemeAndHttpHost() . '/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl));
return $manager;
}
/**
@@ -110,7 +75,7 @@ abstract class Controller extends BaseController
private function getParameters(): ParameterBag
{
$bag = new ParameterBag;
$page = (int) request()->get('page');
$page = (int)request()->get('page');
if (0 === $page) {
$page = 1;
}
@@ -137,11 +102,47 @@ abstract class Controller extends BaseController
foreach ($integers as $integer) {
$value = request()->query->get($integer);
if (null !== $value) {
$bag->set($integer, (int) $value);
$bag->set($integer, (int)$value);
}
}
return $bag;
}
/**
* Method to help build URI's.
*
* @return string
*/
final protected function buildParams(): string
{
$return = '?';
$params = [];
foreach ($this->parameters as $key => $value) {
if ('page' === $key) {
continue;
}
if ($value instanceof Carbon) {
$params[$key] = $value->format('Y-m-d');
continue;
}
$params[$key] = $value;
}
return $return . http_build_query($params);
}
/**
* @return Manager
*/
final protected function getManager(): Manager
{
// create some objects:
$manager = new Manager;
$baseUrl = request()->getSchemeAndHttpHost() . '/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl));
return $manager;
}
}

View File

@@ -37,7 +37,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
@@ -68,11 +67,8 @@ class CurrencyController extends Controller
{
use AccountFilter, TransactionFilter;
/** @var CurrencyRepositoryInterface The currency repository */
private $repository;
/** @var UserRepositoryInterface The user repository */
private $userRepository;
private CurrencyRepositoryInterface $repository;
private UserRepositoryInterface $userRepository;
/**
@@ -148,7 +144,7 @@ class CurrencyController extends Controller
$resource = new FractalCollection($accounts, $transformer, 'accounts');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -161,22 +157,14 @@ class CurrencyController extends Controller
*/
public function availableBudgets(TransactionCurrency $currency): JsonResponse
{
/** @var User $admin */
$admin = auth()->user();
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of available budgets. Count it and split it.
/** @var BudgetRepositoryInterface $repository */
$repository = app(BudgetRepositoryInterface::class);
/** @var AvailableBudgetRepositoryInterface $abRepository */
$abRepository = app(AvailableBudgetRepositoryInterface::class);
$repository->setUser($admin);
$collection = $abRepository->getAvailableBudgetsByCurrency($currency);
$count = $collection->count();
$availableBudgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
@@ -193,7 +181,7 @@ class CurrencyController extends Controller
$resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -208,10 +196,10 @@ class CurrencyController extends Controller
{
$manager = $this->getManager();
/** @var BillRepositoryInterface $repository */
$repository = app(BillRepositoryInterface::class);
/** @var BillRepositoryInterface $billRepos */
$billRepos = app(BillRepositoryInterface::class);
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$unfiltered = $repository->getBills();
$unfiltered = $billRepos->getBills();
// filter and paginate list:
$collection = $unfiltered->filter(
@@ -233,7 +221,7 @@ class CurrencyController extends Controller
$resource = new FractalCollection($bills, $transformer, 'bills');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -264,7 +252,7 @@ class CurrencyController extends Controller
$resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -295,7 +283,7 @@ class CurrencyController extends Controller
$resource = new FractalCollection($exchangeRates, $transformer, 'currency_exchange_rates');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -303,9 +291,9 @@ class CurrencyController extends Controller
*
* @param TransactionCurrency $currency
*
* @return JsonResponse
* @throws FireflyException
* @codeCoverageIgnore
* @return JsonResponse
*/
public function delete(TransactionCurrency $currency): JsonResponse
{
@@ -354,7 +342,7 @@ class CurrencyController extends Controller
$resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -380,7 +368,7 @@ class CurrencyController extends Controller
$resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -412,7 +400,7 @@ class CurrencyController extends Controller
$resource = new FractalCollection($currencies, $transformer, 'currencies');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -440,7 +428,7 @@ class CurrencyController extends Controller
$resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -459,9 +447,9 @@ class CurrencyController extends Controller
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
/** @var RecurringRepositoryInterface $repository */
$repository = app(RecurringRepositoryInterface::class);
$unfiltered = $repository->getAll();
/** @var RecurringRepositoryInterface $recurringRepos */
$recurringRepos = app(RecurringRepositoryInterface::class);
$unfiltered = $recurringRepos->getAll();
// filter selection
$collection = $unfiltered->filter(
@@ -492,7 +480,7 @@ class CurrencyController extends Controller
$resource = new FractalCollection($piggyBanks, $transformer, 'recurrences');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -510,9 +498,9 @@ class CurrencyController extends Controller
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
/** @var RuleRepositoryInterface $repository */
$repository = app(RuleRepositoryInterface::class);
$unfiltered = $repository->getAll();
/** @var RuleRepositoryInterface $ruleRepos */
$ruleRepos = app(RuleRepositoryInterface::class);
$unfiltered = $ruleRepos->getAll();
$collection = $unfiltered->filter(
static function (Rule $rule) use ($currency) {
@@ -541,7 +529,7 @@ class CurrencyController extends Controller
$resource = new FractalCollection($rules, $transformer, 'rules');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -565,7 +553,7 @@ class CurrencyController extends Controller
$resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -586,7 +574,7 @@ class CurrencyController extends Controller
$resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -594,8 +582,8 @@ class CurrencyController extends Controller
*
* @param CurrencyRequest $request
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function store(CurrencyRequest $request): JsonResponse
{
@@ -614,7 +602,7 @@ class CurrencyController extends Controller
$resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -670,7 +658,7 @@ class CurrencyController extends Controller
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -702,7 +690,7 @@ class CurrencyController extends Controller
$resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -69,8 +69,8 @@ class CurrencyExchangeRateController extends Controller
*
* @param Request $request
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function index(Request $request): JsonResponse
{
@@ -107,6 +107,6 @@ class CurrencyExchangeRateController extends Controller
$transformer->setParameters($this->parameters);
$resource = new Item($rate, $transformer, 'currency_exchange_rates');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -160,31 +160,6 @@ class DestroyController extends Controller
return response()->json([], 204);
}
/**
* @param array $types
*/
private function destroyAccounts(array $types): void
{
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$collection = $repository->getAccountsByType($types);
$service = app(AccountDestroyService::class);
/** @var Account $account */
foreach ($collection as $account) {
$service->destroy($account, null);
}
}
/**
*
*/
private function destroyBills(): void
{
/** @var BillRepositoryInterface $repository */
$repository = app(BillRepositoryInterface::class);
$repository->destroyAll();
}
/**
*
*/
@@ -206,18 +181,11 @@ class DestroyController extends Controller
/**
*
*/
private function destroyCategories(): void
private function destroyBills(): void
{
/** @var CategoryRepositoryInterface $categoryRepos */
$categoryRepos = app(CategoryRepositoryInterface::class);
$categoryRepos->destroyAll();
}
private function destroyObjectGroups(): void
{
/** @var ObjectGroupRepositoryInterface $repository */
$repository = app(ObjectGroupRepositoryInterface::class);
$repository->deleteAll();
/** @var BillRepositoryInterface $repository */
$repository = app(BillRepositoryInterface::class);
$repository->destroyAll();
}
/**
@@ -230,16 +198,6 @@ class DestroyController extends Controller
$repository->destroyAll();
}
/**
*
*/
private function destroyRecurringTransactions(): void
{
/** @var RecurringRepositoryInterface $repository */
$repository = app(RecurringRepositoryInterface::class);
$repository->destroyAll();
}
/**
*
*/
@@ -250,6 +208,26 @@ class DestroyController extends Controller
$repository->destroyAll();
}
/**
*
*/
private function destroyRecurringTransactions(): void
{
/** @var RecurringRepositoryInterface $repository */
$repository = app(RecurringRepositoryInterface::class);
$repository->destroyAll();
}
/**
*
*/
private function destroyCategories(): void
{
/** @var CategoryRepositoryInterface $categoryRepos */
$categoryRepos = app(CategoryRepositoryInterface::class);
$categoryRepos->destroyAll();
}
/**
*
*/
@@ -260,6 +238,28 @@ class DestroyController extends Controller
$tagRepository->destroyAll();
}
private function destroyObjectGroups(): void
{
/** @var ObjectGroupRepositoryInterface $repository */
$repository = app(ObjectGroupRepositoryInterface::class);
$repository->deleteAll();
}
/**
* @param array $types
*/
private function destroyAccounts(array $types): void
{
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$collection = $repository->getAccountsByType($types);
$service = app(AccountDestroyService::class);
/** @var Account $account */
foreach ($collection as $account) {
$service->destroy($account, null);
}
}
/**
* @param array $types
*/
@@ -267,10 +267,10 @@ class DestroyController extends Controller
{
/** @var JournalRepositoryInterface $repository */
$repository = app(JournalRepositoryInterface::class);
$journals = $repository->findByType($types);
$service = app(JournalDestroyService::class);
$journals = $repository->findByType($types);
$service = app(JournalDestroyService::class);
/** @var TransactionJournal $journal */
foreach($journals as $journal) {
foreach ($journals as $journal) {
$service->destroy($journal);
}
}

View File

@@ -80,9 +80,9 @@ class LinkTypeController extends Controller
*
* @param LinkType $linkType
*
* @return JsonResponse
* @throws FireflyException
* @codeCoverageIgnore
* @return JsonResponse
*/
public function delete(LinkType $linkType): JsonResponse
{
@@ -122,7 +122,7 @@ class LinkTypeController extends Controller
$resource = new FractalCollection($linkTypes, $transformer, 'link_types');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -143,7 +143,7 @@ class LinkTypeController extends Controller
$resource = new Item($linkType, $transformer, 'link_types');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -152,8 +152,8 @@ class LinkTypeController extends Controller
*
* @param LinkTypeRequest $request
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function store(LinkTypeRequest $request): JsonResponse
{
@@ -173,7 +173,7 @@ class LinkTypeController extends Controller
$transformer->setParameters($this->parameters);
$resource = new Item($linkType, $transformer, 'link_types');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -232,7 +232,7 @@ class LinkTypeController extends Controller
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -242,8 +242,8 @@ class LinkTypeController extends Controller
* @param LinkTypeRequest $request
* @param LinkType $linkType
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function update(LinkTypeRequest $request, LinkType $linkType): JsonResponse
{
@@ -267,7 +267,7 @@ class LinkTypeController extends Controller
$resource = new Item($linkType, $transformer, 'link_types');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -111,7 +111,7 @@ class ObjectGroupController extends Controller
$resource = new FractalCollection($objectGroups, $transformer, 'object_groups');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -147,7 +147,7 @@ class ObjectGroupController extends Controller
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy_banks');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -167,7 +167,7 @@ class ObjectGroupController extends Controller
$transformer->setParameters($this->parameters);
$resource = new Item($objectGroup, $transformer, 'object_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -190,6 +190,6 @@ class ObjectGroupController extends Controller
$transformer->setParameters($this->parameters);
$resource = new Item($objectGroup, $transformer, 'object_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -109,7 +109,7 @@ class PiggyBankController extends Controller
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -140,7 +140,7 @@ class PiggyBankController extends Controller
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy_banks');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -173,7 +173,7 @@ class PiggyBankController extends Controller
$resource = new FractalCollection($events, $transformer, 'piggy_bank_events');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -195,7 +195,7 @@ class PiggyBankController extends Controller
$resource = new Item($piggyBank, $transformer, 'piggy_banks');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -204,8 +204,8 @@ class PiggyBankController extends Controller
*
* @param PiggyBankStoreRequest $request
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function store(PiggyBankStoreRequest $request): JsonResponse
{
@@ -218,7 +218,7 @@ class PiggyBankController extends Controller
$resource = new Item($piggyBank, $transformer, 'piggy_banks');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -245,7 +245,7 @@ class PiggyBankController extends Controller
$resource = new Item($piggyBank, $transformer, 'piggy_banks');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -101,7 +101,7 @@ class PreferenceController extends Controller
$resource = new FractalCollection($preferences, $transformer, 'preferences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -122,7 +122,7 @@ class PreferenceController extends Controller
$resource = new Item($preference, $transformer, 'preferences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -161,7 +161,7 @@ class PreferenceController extends Controller
$resource = new Item($result, $transformer, 'preferences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -119,7 +119,7 @@ class RecurrenceController extends Controller
$resource = new FractalCollection($piggyBanks, $transformer, 'recurrences');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -141,7 +141,7 @@ class RecurrenceController extends Controller
$resource = new Item($recurrence, $transformer, 'recurrences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -151,8 +151,8 @@ class RecurrenceController extends Controller
*
* @param RecurrenceStoreRequest $request
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function store(RecurrenceStoreRequest $request): JsonResponse
{
@@ -166,7 +166,7 @@ class RecurrenceController extends Controller
$resource = new Item($recurrence, $transformer, 'recurrences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -222,13 +222,13 @@ class RecurrenceController extends Controller
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
* @return JsonResponse
* @throws FireflyException
* @codeCoverageIgnore
* @return JsonResponse
*/
public function trigger(): JsonResponse
{
@@ -238,7 +238,7 @@ class RecurrenceController extends Controller
$result = $recurring->fire();
} catch (FireflyException $e) {
Log::error($e->getMessage());
throw new FireflyException('200022: Error in cron job.',0, $e);
throw new FireflyException('200022: Error in cron job.', 0, $e);
}
if (false === $result) {
return response()->json([], 204);
@@ -270,7 +270,7 @@ class RecurrenceController extends Controller
$resource = new Item($category, $transformer, 'recurrences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -122,7 +122,7 @@ class RuleController extends Controller
$resource = new FractalCollection($rules, $transformer, 'rules');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -143,7 +143,7 @@ class RuleController extends Controller
$resource = new Item($rule, $transformer, 'rules');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -164,7 +164,7 @@ class RuleController extends Controller
$resource = new Item($rule, $transformer, 'rules');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -185,7 +185,7 @@ class RuleController extends Controller
$resource = new Item($rule, $transformer, 'rules');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -206,7 +206,7 @@ class RuleController extends Controller
$resource = new Item($rule, $transformer, 'rules');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -255,7 +255,7 @@ class RuleController extends Controller
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -315,6 +315,6 @@ class RuleController extends Controller
$resource = new Item($rule, $transformer, 'rules');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -122,7 +122,7 @@ class RuleGroupController extends Controller
$resource = new FractalCollection($ruleGroups, $transformer, 'rule_groups');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -142,7 +142,7 @@ class RuleGroupController extends Controller
$resource = new Item($ruleGroup, $transformer, 'rule_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -162,7 +162,7 @@ class RuleGroupController extends Controller
$resource = new Item($ruleGroup, $transformer, 'rule_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -193,7 +193,7 @@ class RuleGroupController extends Controller
$resource = new FractalCollection($rules, $transformer, 'rules');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -214,7 +214,7 @@ class RuleGroupController extends Controller
$resource = new Item($ruleGroup, $transformer, 'rule_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -236,7 +236,7 @@ class RuleGroupController extends Controller
$resource = new Item($ruleGroup, $transformer, 'rule_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -291,7 +291,7 @@ class RuleGroupController extends Controller
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -357,6 +357,6 @@ class RuleGroupController extends Controller
$resource = new Item($ruleGroup, $transformer, 'rule_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -97,6 +97,6 @@ class AccountController extends Controller
$resource = new FractalCollection($accounts, $transformer, 'accounts');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -45,7 +45,7 @@ class TransactionController extends Controller
*/
public function search(Request $request, SearchInterface $searcher): JsonResponse
{
$manager = $this->getManager();
$manager = $this->getManager();
$fullQuery = (string) $request->get('query');
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
@@ -65,6 +65,6 @@ class TransactionController extends Controller
$resource = new Collection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($groups));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -101,8 +101,8 @@ class SummaryController extends Controller
/**
* @param DateRequest $request
*
* @throws Exception
* @return JsonResponse
* @throws Exception
*/
public function basic(DateRequest $request): JsonResponse
{
@@ -130,30 +130,6 @@ class SummaryController extends Controller
return response()->json($return);
}
/**
* Check if date is outside session range.
*
* @param Carbon $date
*
* @param Carbon $start
* @param Carbon $end
*
* @return bool
*/
protected function notInDateRange(Carbon $date, Carbon $start, Carbon $end): bool // Validate a preference
{
$result = false;
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
$result = true;
}
// start and end in the past? use $end
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) {
$result = true;
}
return $result;
}
/**
* @param Carbon $start
* @param Carbon $end
@@ -322,8 +298,8 @@ class SummaryController extends Controller
* @param Carbon $start
* @param Carbon $end
*
* @throws Exception
* @return array
* @throws Exception
*/
private function getLeftToSpendInfo(Carbon $start, Carbon $end): array
{
@@ -429,4 +405,28 @@ class SummaryController extends Controller
return $return;
}
/**
* Check if date is outside session range.
*
* @param Carbon $date
*
* @param Carbon $start
* @param Carbon $end
*
* @return bool
*/
protected function notInDateRange(Carbon $date, Carbon $start, Carbon $end): bool // Validate a preference
{
$result = false;
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
$result = true;
}
// start and end in the past? use $end
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) {
$result = true;
}
return $result;
}
}

View File

@@ -115,7 +115,7 @@ class TagController extends Controller
$resource = new FractalCollection($rules, $transformer, 'tags');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -145,7 +145,7 @@ class TagController extends Controller
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -165,7 +165,7 @@ class TagController extends Controller
$resource = new Item($tag, $transformer, 'tags');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -186,7 +186,7 @@ class TagController extends Controller
$resource = new Item($rule, $transformer, 'tags');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -239,7 +239,7 @@ class TagController extends Controller
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -260,7 +260,7 @@ class TagController extends Controller
$resource = new Item($rule, $transformer, 'tags');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -50,6 +50,7 @@ use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item;
use Log;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class TransactionController
*/
@@ -107,7 +108,7 @@ class TransactionController extends Controller
$resource = new FractalCollection($attachments, $transformer, 'attachments');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -127,7 +128,7 @@ class TransactionController extends Controller
$resource = new FractalCollection($journalLinks, $transformer, 'transaction_links');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -208,7 +209,7 @@ class TransactionController extends Controller
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -231,7 +232,20 @@ class TransactionController extends Controller
$resource = new FractalCollection($events, $transformer, 'piggy_bank_events');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
* Show a single transaction, by transaction journal.
*
* @param TransactionJournal $transactionJournal
*
* @return JsonResponse
* @codeCoverageIgnore
*/
public function showByJournal(TransactionJournal $transactionJournal): JsonResponse
{
return $this->show($transactionJournal->transactionGroup);
}
/**
@@ -266,20 +280,7 @@ class TransactionController extends Controller
$transformer->setParameters($this->parameters);
$resource = new Item($selectedGroup, $transformer, 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
}
/**
* Show a single transaction, by transaction journal.
*
* @param TransactionJournal $transactionJournal
*
* @return JsonResponse
* @codeCoverageIgnore
*/
public function showByJournal(TransactionJournal $transactionJournal): JsonResponse
{
return $this->show($transactionJournal->transactionGroup);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -352,7 +353,7 @@ class TransactionController extends Controller
$transformer->setParameters($this->parameters);
$resource = new Item($selectedGroup, $transformer, 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -395,6 +396,6 @@ class TransactionController extends Controller
$transformer->setParameters($this->parameters);
$resource = new Item($selectedGroup, $transformer, 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -126,7 +126,7 @@ class TransactionLinkController extends Controller
$resource = new FractalCollection($journalLinks, $transformer, 'transaction_links');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -148,7 +148,7 @@ class TransactionLinkController extends Controller
$resource = new Item($journalLink, $transformer, 'transaction_links');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -157,8 +157,8 @@ class TransactionLinkController extends Controller
*
* @param TransactionLinkRequest $request
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function store(TransactionLinkRequest $request): JsonResponse
{
@@ -179,7 +179,7 @@ class TransactionLinkController extends Controller
$resource = new Item($journalLink, $transformer, 'transaction_links');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -188,8 +188,8 @@ class TransactionLinkController extends Controller
* @param TransactionLinkRequest $request
* @param TransactionJournalLink $journalLink
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function update(TransactionLinkRequest $request, TransactionJournalLink $journalLink): JsonResponse
{
@@ -209,7 +209,7 @@ class TransactionLinkController extends Controller
$resource = new Item($journalLink, $transformer, 'transaction_links');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
}

View File

@@ -68,9 +68,9 @@ class UserController extends Controller
*
* @param User $user
*
* @return JsonResponse
* @throws FireflyException
* @codeCoverageIgnore
* @return JsonResponse
*/
public function delete(User $user): JsonResponse
{
@@ -113,7 +113,7 @@ class UserController extends Controller
$resource = new FractalCollection($users, $transformer, 'users');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -135,7 +135,7 @@ class UserController extends Controller
$resource = new Item($user, $transformer, 'users');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -159,7 +159,7 @@ class UserController extends Controller
$resource = new Item($user, $transformer, 'users');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
/**
@@ -182,7 +182,7 @@ class UserController extends Controller
$resource = new Item($user, $transformer, 'users');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Middleware;
use Closure;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Illuminate\Http\Request;

View File

@@ -132,8 +132,6 @@ class AccountStoreRequest extends FormRequest
'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly',
'notes' => 'min:0|max:65536',
];
$rules = Location::requestRules($rules);
return $rules;
return Location::requestRules($rules);
}
}

View File

@@ -38,6 +38,7 @@ use Illuminate\Foundation\Http\FormRequest;
class AccountUpdateRequest extends FormRequest
{
use ConvertsDataTypes, AppendsLocationData;
/**
* Authorize logged in users.
*
@@ -133,8 +134,6 @@ class AccountUpdateRequest extends FormRequest
'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly',
'notes' => 'min:0|max:65536',
];
$rules = Location::requestRules($rules);
return $rules;
return Location::requestRules($rules);
}
}

View File

@@ -35,6 +35,7 @@ use Illuminate\Foundation\Http\FormRequest;
class AttachmentStoreRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -34,6 +34,7 @@ use Illuminate\Foundation\Http\FormRequest;
class AttachmentUpdateRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\Autocomplete;
use FireflyIII\Models\AccountType;
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
@@ -58,6 +59,9 @@ class AutocompleteRequest extends FormRequest
$limit = $this->integer('limit');
$limit = 0 === $limit ? 10 : $limit;
// remove 'initial balance' from allowed types. its internal
$array = array_diff($array, [AccountType::INITIAL_BALANCE]);
return [
'types' => $array,
'query' => $this->string('query'),

View File

@@ -34,6 +34,7 @@ use Illuminate\Foundation\Http\FormRequest;
class AvailableBudgetRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -1,7 +1,7 @@
<?php
/**
* BillRequest.php
* BillStoreRequest.php
* Copyright (c) 2019 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
@@ -25,30 +25,19 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests;
use FireflyIII\Rules\IsBoolean;
use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
/**
* Class BillRequest
*
* TODO AFTER 4.8,0: split this into two request classes.
* Class BillStoreRequest
*
* @codeCoverageIgnore
*/
class BillRequest extends FormRequest
class BillStoreRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*
* @return bool
*/
public function authorize(): bool
{
// Only allow authenticated users
return auth()->check();
}
use ConvertsDataTypes, ChecksLogin;
/**
* Get all data from the request.
@@ -84,7 +73,7 @@ class BillRequest extends FormRequest
*/
public function rules(): array
{
$rules = [
return [
'name' => 'between:1,255|uniqueObjectForUser:bills,name',
'amount_min' => 'numeric|gt:0',
'amount_max' => 'numeric|gt:0',
@@ -96,17 +85,6 @@ class BillRequest extends FormRequest
'active' => [new IsBoolean],
'notes' => 'between:1,65536',
];
switch ($this->method()) {
default:
break;
case 'PUT':
case 'PATCH':
$bill = $this->route()->parameter('bill');
$rules['name'] .= ',' . $bill->id;
break;
}
return $rules;
}
/**

View File

@@ -0,0 +1,111 @@
<?php
/**
* BillUpdateRequest.php
* Copyright (c) 2019 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\V1\Requests;
use FireflyIII\Rules\IsBoolean;
use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
/**
* Class BillUpdateRequest
*
* @codeCoverageIgnore
*/
class BillUpdateRequest extends FormRequest
{
use ConvertsDataTypes, ChecksLogin;
/**
* Get all data from the request.
*
* @return array
*/
public function getAll(): array
{
$active = true;
if (null !== $this->get('active')) {
$active = $this->boolean('active');
}
return [
'name' => $this->string('name'),
'amount_min' => $this->string('amount_min'),
'amount_max' => $this->string('amount_max'),
'currency_id' => $this->integer('currency_id'),
'currency_code' => $this->string('currency_code'),
'date' => $this->date('date'),
'repeat_freq' => $this->string('repeat_freq'),
'skip' => $this->integer('skip'),
'active' => $active,
'order' => $this->integer('order'),
'notes' => $this->nlString('notes'),
];
}
/**
* The rules that the incoming request must be matched against.
*
* @return array
*/
public function rules(): array
{
$bill = $this->route()->parameter('bill');
return [
'name' => sprintf('between:1,255|uniqueObjectForUser:bills,name,%d', $bill->id),
'amount_min' => 'numeric|gt:0',
'amount_max' => 'numeric|gt:0',
'currency_id' => 'numeric|exists:transaction_currencies,id',
'currency_code' => 'min:3|max:3|exists:transaction_currencies,code',
'date' => 'date',
'repeat_freq' => 'in:weekly,monthly,quarterly,half-year,yearly',
'skip' => 'between:0,31',
'active' => [new IsBoolean],
'notes' => 'between:1,65536',
];
}
/**
* Configure the validator instance.
*
* @param Validator $validator
*
* @return void
*/
public function withValidator(Validator $validator): void
{
$validator->after(
static function (Validator $validator) {
$data = $validator->getData();
$min = (float) ($data['amount_min'] ?? 0);
$max = (float) ($data['amount_max'] ?? 0);
if ($min > $max) {
$validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max'));
}
}
);
}
}

View File

@@ -37,6 +37,7 @@ use Illuminate\Validation\Validator;
class BudgetStoreRequest extends FormRequest
{
use ConvertsDataTypes, ValidatesAutoBudgetRequest;
/**
* Authorize logged in users.
*

View File

@@ -37,6 +37,7 @@ use Illuminate\Validation\Validator;
class BudgetUpdateRequest extends FormRequest
{
use ConvertsDataTypes, ValidatesAutoBudgetRequest;
/**
* Authorize logged in users.
*

View File

@@ -36,6 +36,7 @@ use Illuminate\Foundation\Http\FormRequest;
class CategoryRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -36,6 +36,7 @@ use Illuminate\Foundation\Http\FormRequest;
class ConfigurationRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*
@@ -56,6 +57,8 @@ class ConfigurationRequest extends FormRequest
{
$name = $this->route()->parameter('configName');
switch ($name) {
default:
break;
case 'is_demo_site':
case 'single_user_mode':
return ['value' => $this->boolean('value')];
@@ -75,6 +78,8 @@ class ConfigurationRequest extends FormRequest
{
$name = $this->route()->parameter('configName');
switch ($name) {
default:
break;
case 'is_demo_site':
case 'single_user_mode':
return ['value' => ['required', new IsBoolean]];

View File

@@ -37,6 +37,7 @@ use Illuminate\Foundation\Http\FormRequest;
class CurrencyRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -32,6 +32,7 @@ use Illuminate\Foundation\Http\FormRequest;
class DataDestroyRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*
@@ -64,7 +65,7 @@ class DataDestroyRequest extends FormRequest
',accounts,asset_accounts,expense_accounts,revenue_accounts,liabilities,transactions,withdrawals,deposits,transfers';
return [
'objects' => sprintf('min:1|string|in:%s', $valid),
'objects' => sprintf('required|min:1|string|in:%s', $valid),
];
}
}

View File

@@ -36,6 +36,7 @@ use Illuminate\Foundation\Http\FormRequest;
class DateRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -37,6 +37,7 @@ use Illuminate\Validation\Rule;
class LinkTypeRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -35,6 +35,7 @@ use Illuminate\Foundation\Http\FormRequest;
class ObjectGroupUpdateRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -35,6 +35,7 @@ use Illuminate\Foundation\Http\FormRequest;
class PiggyBankStoreRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -40,6 +40,7 @@ use Illuminate\Validation\Validator;
class RecurrenceStoreRequest extends FormRequest
{
use ConvertsDataTypes, RecurrenceValidation, TransactionValidation, CurrencyValidation, GetRecurrenceData;
/**
* Authorize logged in users.
*
@@ -83,6 +84,56 @@ class RecurrenceStoreRequest extends FormRequest
];
}
/**
* Returns the transaction data as it is found in the submitted data. It's a complex method according to code
* standards but it just has a lot of ??-statements because of the fields that may or may not exist.
*
* @return array
*/
private function getTransactionData(): array
{
$return = [];
// transaction data:
/** @var array $transactions */
$transactions = $this->get('transactions');
if (null === $transactions) {
return [];
}
/** @var array $transaction */
foreach ($transactions as $transaction) {
$return[] = $this->getSingleRecurrenceData($transaction);
}
return $return;
}
/**
* Returns the repetition data as it is found in the submitted data.
*
* @return array
*/
private function getRepetitionData(): array
{
$return = [];
// repetition data:
/** @var array $repetitions */
$repetitions = $this->get('repetitions');
if (null === $repetitions) {
return [];
}
/** @var array $repetition */
foreach ($repetitions as $repetition) {
$return[] = [
'type' => $repetition['type'],
'moment' => $repetition['moment'],
'skip' => (int) $repetition['skip'],
'weekend' => (int) $repetition['weekend'],
];
}
return $return;
}
/**
* The rules that the incoming request must be matched against.
*
@@ -150,54 +201,4 @@ class RecurrenceStoreRequest extends FormRequest
}
);
}
/**
* Returns the repetition data as it is found in the submitted data.
*
* @return array
*/
private function getRepetitionData(): array
{
$return = [];
// repetition data:
/** @var array $repetitions */
$repetitions = $this->get('repetitions');
if (null === $repetitions) {
return [];
}
/** @var array $repetition */
foreach ($repetitions as $repetition) {
$return[] = [
'type' => $repetition['type'],
'moment' => $repetition['moment'],
'skip' => (int) $repetition['skip'],
'weekend' => (int) $repetition['weekend'],
];
}
return $return;
}
/**
* Returns the transaction data as it is found in the submitted data. It's a complex method according to code
* standards but it just has a lot of ??-statements because of the fields that may or may not exist.
*
* @return array
*/
private function getTransactionData(): array
{
$return = [];
// transaction data:
/** @var array $transactions */
$transactions = $this->get('transactions');
if (null === $transactions) {
return [];
}
/** @var array $transaction */
foreach ($transactions as $transaction) {
$return[] = $this->getSingleRecurrenceData($transaction);
}
return $return;
}
}

View File

@@ -85,6 +85,56 @@ class RecurrenceUpdateRequest extends FormRequest
];
}
/**
* Returns the transaction data as it is found in the submitted data. It's a complex method according to code
* standards but it just has a lot of ??-statements because of the fields that may or may not exist.
*
* @return array
*/
private function getTransactionData(): array
{
$return = [];
// transaction data:
/** @var array $transactions */
$transactions = $this->get('transactions');
if (null === $transactions) {
return [];
}
/** @var array $transaction */
foreach ($transactions as $transaction) {
$return[] = $this->getSingleRecurrenceData($transaction);
}
return $return;
}
/**
* Returns the repetition data as it is found in the submitted data.
*
* @return array
*/
private function getRepetitionData(): array
{
$return = [];
// repetition data:
/** @var array $repetitions */
$repetitions = $this->get('repetitions');
if (null === $repetitions) {
return [];
}
/** @var array $repetition */
foreach ($repetitions as $repetition) {
$return[] = [
'type' => $repetition['type'],
'moment' => $repetition['moment'],
'skip' => (int) $repetition['skip'],
'weekend' => (int) $repetition['weekend'],
];
}
return $return;
}
/**
* The rules that the incoming request must be matched against.
*
@@ -153,54 +203,4 @@ class RecurrenceUpdateRequest extends FormRequest
}
);
}
/**
* Returns the repetition data as it is found in the submitted data.
*
* @return array
*/
private function getRepetitionData(): array
{
$return = [];
// repetition data:
/** @var array $repetitions */
$repetitions = $this->get('repetitions');
if (null === $repetitions) {
return [];
}
/** @var array $repetition */
foreach ($repetitions as $repetition) {
$return[] = [
'type' => $repetition['type'],
'moment' => $repetition['moment'],
'skip' => (int) $repetition['skip'],
'weekend' => (int) $repetition['weekend'],
];
}
return $return;
}
/**
* Returns the transaction data as it is found in the submitted data. It's a complex method according to code
* standards but it just has a lot of ??-statements because of the fields that may or may not exist.
*
* @return array
*/
private function getTransactionData(): array
{
$return = [];
// transaction data:
/** @var array $transactions */
$transactions = $this->get('transactions');
if (null === $transactions) {
return [];
}
/** @var array $transaction */
foreach ($transactions as $transaction) {
$return[] = $this->getSingleRecurrenceData($transaction);
}
return $return;
}
}

View File

@@ -37,6 +37,7 @@ use Illuminate\Foundation\Http\FormRequest;
class RuleGroupRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -26,13 +26,9 @@ namespace FireflyIII\Api\V1\Requests;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Collection;
use Log;
/**
* Class RuleGroupTestRequest
@@ -64,6 +60,24 @@ class RuleGroupTestRequest extends FormRequest
];
}
/**
* @param string $field
*
* @return Carbon|null
*/
private function getDate(string $field): ?Carbon
{
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
}
/**
* @return Collection
*/
private function getAccounts(): string
{
return (string) $this->query('accounts');
}
/**
* @return array
*/
@@ -77,25 +91,4 @@ class RuleGroupTestRequest extends FormRequest
];
}
/**
* @return Collection
*/
private function getAccounts(): string
{
return (string) $this->query('accounts');
}
/**
* @param string $field
*
* @return Carbon|null
*/
private function getDate(string $field): ?Carbon
{
/** @var Carbon $result */
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
return $result;
}
}

View File

@@ -26,13 +26,8 @@ namespace FireflyIII\Api\V1\Requests;
use Carbon\Carbon;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Collection;
use Log;
/**
* Class RuleGroupTriggerRequest
@@ -65,14 +60,13 @@ class RuleGroupTriggerRequest extends FormRequest
}
/**
* @return array
* @param string $field
*
* @return Carbon|null
*/
public function rules(): array
private function getDate(string $field): ?Carbon
{
return [
'start' => 'date',
'end' => 'date|after:start',
];
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
}
/**
@@ -84,14 +78,14 @@ class RuleGroupTriggerRequest extends FormRequest
}
/**
* @param string $field
*
* @return Carbon|null
* @return array
*/
private function getDate(string $field): ?Carbon
public function rules(): array
{
/** @var Carbon $result */
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
return [
'start' => 'date',
'end' => 'date|after:start',
];
}
}

View File

@@ -83,6 +83,48 @@ class RuleStoreRequest extends FormRequest
];
}
/**
* @return array
*/
private function getRuleTriggers(): array
{
$triggers = $this->get('triggers');
$return = [];
if (is_array($triggers)) {
foreach ($triggers as $trigger) {
$return[] = [
'type' => $trigger['type'],
'value' => $trigger['value'],
'active' => $this->convertBoolean((string) ($trigger['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string) ($trigger['stop_processing'] ?? 'false')),
];
}
}
return $return;
}
/**
* @return array
*/
private function getRuleActions(): array
{
$actions = $this->get('actions');
$return = [];
if (is_array($actions)) {
foreach ($actions as $action) {
$return[] = [
'type' => $action['type'],
'value' => $action['value'],
'active' => $this->convertBoolean((string) ($action['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')),
];
}
}
return $return;
}
/**
* The rules that the incoming request must be matched against.
*
@@ -134,21 +176,6 @@ class RuleStoreRequest extends FormRequest
);
}
/**
* Adds an error to the validator when there are no repetitions in the array of data.
*
* @param Validator $validator
*/
protected function atLeastOneAction(Validator $validator): void
{
$data = $validator->getData();
$actions = $data['actions'] ?? [];
// need at least one trigger
if (0 === count($actions)) {
$validator->errors()->add('title', (string) trans('validation.at_least_one_action'));
}
}
/**
* Adds an error to the validator when there are no repetitions in the array of data.
*
@@ -165,44 +192,17 @@ class RuleStoreRequest extends FormRequest
}
/**
* @return array
* Adds an error to the validator when there are no repetitions in the array of data.
*
* @param Validator $validator
*/
private function getRuleActions(): array
protected function atLeastOneAction(Validator $validator): void
{
$actions = $this->get('actions');
$return = [];
if (is_array($actions)) {
foreach ($actions as $action) {
$return[] = [
'type' => $action['type'],
'value' => $action['value'],
'active' => $this->convertBoolean((string) ($action['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')),
];
}
$data = $validator->getData();
$actions = $data['actions'] ?? [];
// need at least one trigger
if (0 === count($actions)) {
$validator->errors()->add('title', (string) trans('validation.at_least_one_action'));
}
return $return;
}
/**
* @return array
*/
private function getRuleTriggers(): array
{
$triggers = $this->get('triggers');
$return = [];
if (is_array($triggers)) {
foreach ($triggers as $trigger) {
$return[] = [
'type' => $trigger['type'],
'value' => $trigger['value'],
'active' => $this->convertBoolean((string) ($trigger['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string) ($trigger['stop_processing'] ?? 'false')),
];
}
}
return $return;
}
}

View File

@@ -61,6 +61,33 @@ class RuleTestRequest extends FormRequest
];
}
/**
* @return int
*/
private function getPage(): int
{
return 0 === (int) $this->query('page') ? 1 : (int) $this->query('page');
}
/**
* @param string $field
*
* @return Carbon|null
*/
private function getDate(string $field): ?Carbon
{
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
}
/**
* @return string
*/
private function getAccounts(): string
{
return (string) $this->query('accounts');
}
/**
* @return array
*/
@@ -74,34 +101,4 @@ class RuleTestRequest extends FormRequest
];
}
/**
* @return string
*/
private function getAccounts(): string
{
return (string) $this->query('accounts');
}
/**
* @param string $field
*
* @return Carbon|null
*/
private function getDate(string $field): ?Carbon
{
/** @var Carbon $result */
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
return $result;
}
/**
* @return int
*/
private function getPage(): int
{
return 0 === (int) $this->query('page') ? 1 : (int) $this->query('page');
}
}

View File

@@ -59,6 +59,24 @@ class RuleTriggerRequest extends FormRequest
];
}
/**
* @param string $field
*
* @return Carbon|null
*/
private function getDate(string $field): ?Carbon
{
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
}
/**
* @return string
*/
private function getAccounts(): string
{
return (string) $this->query('accounts');
}
/**
* @return array
*/
@@ -72,22 +90,4 @@ class RuleTriggerRequest extends FormRequest
];
}
/**
* @return string
*/
private function getAccounts(): string
{
return (string) $this->query('accounts');
}
/**
* @param string $field
*
* @return Carbon|null
*/
private function getDate(string $field): ?Carbon
{
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', $this->query($field));
}
}

View File

@@ -37,6 +37,7 @@ use function is_array;
class RuleUpdateRequest extends FormRequest
{
use ConvertsDataTypes, GetRuleConfiguration;
/**
* Authorize logged in users.
*
@@ -82,6 +83,54 @@ class RuleUpdateRequest extends FormRequest
];
}
/**
* @return array|null
*/
private function getRuleTriggers(): ?array
{
if (!$this->has('triggers')) {
return null;
}
$triggers = $this->get('triggers');
$return = [];
if (is_array($triggers)) {
foreach ($triggers as $trigger) {
$return[] = [
'type' => $trigger['type'],
'value' => $trigger['value'],
'active' => $this->convertBoolean((string) ($trigger['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string) ($trigger['stop_processing'] ?? 'false')),
];
}
}
return $return;
}
/**
* @return array|null
*/
private function getRuleActions(): ?array
{
if (!$this->has('actions')) {
return null;
}
$actions = $this->get('actions');
$return = [];
if (is_array($actions)) {
foreach ($actions as $action) {
$return[] = [
'type' => $action['type'],
'value' => $action['value'],
'active' => $this->convertBoolean((string) ($action['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')),
];
}
}
return $return;
}
/**
* The rules that the incoming request must be matched against.
*
@@ -134,21 +183,6 @@ class RuleUpdateRequest extends FormRequest
);
}
/**
* Adds an error to the validator when there are no repetitions in the array of data.
*
* @param Validator $validator
*/
protected function atLeastOneAction(Validator $validator): void
{
$data = $validator->getData();
$actions = $data['actions'] ?? null;
// need at least one action
if (is_array($actions) && 0 === count($actions)) {
$validator->errors()->add('title', (string) trans('validation.at_least_one_action'));
}
}
/**
* Adds an error to the validator when there are no repetitions in the array of data.
*
@@ -165,50 +199,17 @@ class RuleUpdateRequest extends FormRequest
}
/**
* @return array|null
* Adds an error to the validator when there are no repetitions in the array of data.
*
* @param Validator $validator
*/
private function getRuleActions(): ?array
protected function atLeastOneAction(Validator $validator): void
{
if (!$this->has('actions')) {
return null;
$data = $validator->getData();
$actions = $data['actions'] ?? null;
// need at least one action
if (is_array($actions) && 0 === count($actions)) {
$validator->errors()->add('title', (string) trans('validation.at_least_one_action'));
}
$actions = $this->get('actions');
$return = [];
if (is_array($actions)) {
foreach ($actions as $action) {
$return[] = [
'type' => $action['type'],
'value' => $action['value'],
'active' => $this->convertBoolean((string) ($action['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')),
];
}
}
return $return;
}
/**
* @return array|null
*/
private function getRuleTriggers(): ?array
{
if (!$this->has('triggers')) {
return null;
}
$triggers = $this->get('triggers');
$return = [];
if (is_array($triggers)) {
foreach ($triggers as $trigger) {
$return[] = [
'type' => $trigger['type'],
'value' => $trigger['value'],
'active' => $this->convertBoolean((string) ($trigger['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string) ($trigger['stop_processing'] ?? 'false')),
];
}
}
return $return;
}
}

View File

@@ -35,6 +35,7 @@ use Illuminate\Foundation\Http\FormRequest;
class TagStoreRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -36,6 +36,7 @@ use Illuminate\Foundation\Http\FormRequest;
class TagUpdateRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -36,6 +36,7 @@ use Illuminate\Validation\Validator;
class TransactionLinkRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -73,6 +73,105 @@ class TransactionStoreRequest extends FormRequest
];
}
/**
* Get transaction data.
*
* @return array
*/
private function getTransactionData(): array
{
$return = [];
/**
* @var array $transaction
*/
foreach ($this->get('transactions') as $transaction) {
$object = new NullArrayObject($transaction);
$return[] = [
'type' => $this->stringFromValue($object['type']),
'date' => $this->dateFromValue($object['date']),
'order' => $this->integerFromValue((string) $object['order']),
'currency_id' => $this->integerFromValue((string) $object['currency_id']),
'currency_code' => $this->stringFromValue($object['currency_code']),
// foreign currency info:
'foreign_currency_id' => $this->integerFromValue((string) $object['foreign_currency_id']),
'foreign_currency_code' => $this->stringFromValue((string) $object['foreign_currency_code']),
// amount and foreign amount. Cannot be 0.
'amount' => $this->stringFromValue((string) $object['amount']),
'foreign_amount' => $this->stringFromValue((string) $object['foreign_amount']),
// description.
'description' => $this->stringFromValue($object['description']),
// source of transaction. If everything is null, assume cash account.
'source_id' => $this->integerFromValue((string) $object['source_id']),
'source_name' => $this->stringFromValue((string) $object['source_name']),
'source_iban' => $this->stringFromValue((string) $object['source_iban']),
'source_number' => $this->stringFromValue((string) $object['source_number']),
'source_bic' => $this->stringFromValue((string) $object['source_bic']),
// destination of transaction. If everything is null, assume cash account.
'destination_id' => $this->integerFromValue((string) $object['destination_id']),
'destination_name' => $this->stringFromValue((string) $object['destination_name']),
'destination_iban' => $this->stringFromValue((string) $object['destination_iban']),
'destination_number' => $this->stringFromValue((string) $object['destination_number']),
'destination_bic' => $this->stringFromValue((string) $object['destination_bic']),
// budget info
'budget_id' => $this->integerFromValue((string) $object['budget_id']),
'budget_name' => $this->stringFromValue((string) $object['budget_name']),
// category info
'category_id' => $this->integerFromValue((string) $object['category_id']),
'category_name' => $this->stringFromValue((string) $object['category_name']),
// journal bill reference. Optional. Will only work for withdrawals
'bill_id' => $this->integerFromValue((string) $object['bill_id']),
'bill_name' => $this->stringFromValue((string) $object['bill_name']),
// piggy bank reference. Optional. Will only work for transfers
'piggy_bank_id' => $this->integerFromValue((string) $object['piggy_bank_id']),
'piggy_bank_name' => $this->stringFromValue((string) $object['piggy_bank_name']),
// some other interesting properties
'reconciled' => $this->convertBoolean((string) $object['reconciled']),
'notes' => $this->nlStringFromValue((string) $object['notes']),
'tags' => $this->arrayFromValue($object['tags']),
// all custom fields:
'internal_reference' => $this->stringFromValue((string) $object['internal_reference']),
'external_id' => $this->stringFromValue((string) $object['external_id']),
'original_source' => sprintf('ff3-v%s|api-v%s', config('firefly.version'), config('firefly.api_version')),
'recurrence_id' => $this->integerFromValue($object['recurrence_id']),
'bunq_payment_id' => $this->stringFromValue((string) $object['bunq_payment_id']),
'external_uri' => $this->stringFromValue((string) $object['external_uri']),
'sepa_cc' => $this->stringFromValue($object['sepa_cc']),
'sepa_ct_op' => $this->stringFromValue($object['sepa_ct_op']),
'sepa_ct_id' => $this->stringFromValue($object['sepa_ct_id']),
'sepa_db' => $this->stringFromValue($object['sepa_db']),
'sepa_country' => $this->stringFromValue($object['sepa_country']),
'sepa_ep' => $this->stringFromValue($object['sepa_ep']),
'sepa_ci' => $this->stringFromValue($object['sepa_ci']),
'sepa_batch_id' => $this->stringFromValue($object['sepa_batch_id']),
// custom date fields. Must be Carbon objects. Presence is optional.
'interest_date' => $this->dateFromValue($object['interest_date']),
'book_date' => $this->dateFromValue($object['book_date']),
'process_date' => $this->dateFromValue($object['process_date']),
'due_date' => $this->dateFromValue($object['due_date']),
'payment_date' => $this->dateFromValue($object['payment_date']),
'invoice_date' => $this->dateFromValue($object['invoice_date']),
];
}
return $return;
}
/**
* The rules that the incoming request must be matched against.
*
@@ -175,6 +274,10 @@ class TransactionStoreRequest extends FormRequest
{
$validator->after(
function (Validator $validator) {
// must be valid array.
$this->validateTransactionArray($validator);
// must submit at least one transaction.
$this->validateOneTransaction($validator);
@@ -199,104 +302,4 @@ class TransactionStoreRequest extends FormRequest
}
);
}
/**
* Get transaction data.
*
* @return array
*/
private function getTransactionData(): array
{
$return = [];
/**
* @var int $index
* @var array $transaction
*/
foreach ($this->get('transactions') as $index => $transaction) {
$object = new NullArrayObject($transaction);
$return[] = [
'type' => $this->stringFromValue($object['type']),
'date' => $this->dateFromValue($object['date']),
'order' => $this->integerFromValue((string) $object['order']),
'currency_id' => $this->integerFromValue((string) $object['currency_id']),
'currency_code' => $this->stringFromValue($object['currency_code']),
// foreign currency info:
'foreign_currency_id' => $this->integerFromValue((string) $object['foreign_currency_id']),
'foreign_currency_code' => $this->stringFromValue((string) $object['foreign_currency_code']),
// amount and foreign amount. Cannot be 0.
'amount' => $this->stringFromValue((string) $object['amount']),
'foreign_amount' => $this->stringFromValue((string) $object['foreign_amount']),
// description.
'description' => $this->stringFromValue($object['description']),
// source of transaction. If everything is null, assume cash account.
'source_id' => $this->integerFromValue((string) $object['source_id']),
'source_name' => $this->stringFromValue((string) $object['source_name']),
'source_iban' => $this->stringFromValue((string) $object['source_iban']),
'source_number' => $this->stringFromValue((string) $object['source_number']),
'source_bic' => $this->stringFromValue((string) $object['source_bic']),
// destination of transaction. If everything is null, assume cash account.
'destination_id' => $this->integerFromValue((string) $object['destination_id']),
'destination_name' => $this->stringFromValue((string) $object['destination_name']),
'destination_iban' => $this->stringFromValue((string) $object['destination_iban']),
'destination_number' => $this->stringFromValue((string) $object['destination_number']),
'destination_bic' => $this->stringFromValue((string) $object['destination_bic']),
// budget info
'budget_id' => $this->integerFromValue((string) $object['budget_id']),
'budget_name' => $this->stringFromValue((string) $object['budget_name']),
// category info
'category_id' => $this->integerFromValue((string) $object['category_id']),
'category_name' => $this->stringFromValue((string) $object['category_name']),
// journal bill reference. Optional. Will only work for withdrawals
'bill_id' => $this->integerFromValue((string) $object['bill_id']),
'bill_name' => $this->stringFromValue((string) $object['bill_name']),
// piggy bank reference. Optional. Will only work for transfers
'piggy_bank_id' => $this->integerFromValue((string) $object['piggy_bank_id']),
'piggy_bank_name' => $this->stringFromValue((string) $object['piggy_bank_name']),
// some other interesting properties
'reconciled' => $this->convertBoolean((string) $object['reconciled']),
'notes' => $this->nlStringFromValue((string) $object['notes']),
'tags' => $this->arrayFromValue($object['tags']),
// all custom fields:
'internal_reference' => $this->stringFromValue((string) $object['internal_reference']),
'external_id' => $this->stringFromValue((string) $object['external_id']),
'original_source' => sprintf('ff3-v%s|api-v%s', config('firefly.version'), config('firefly.api_version')),
'recurrence_id' => $this->integerFromValue($object['recurrence_id']),
'bunq_payment_id' => $this->stringFromValue((string) $object['bunq_payment_id']),
'external_uri' => $this->stringFromValue((string) $object['external_uri']),
'sepa_cc' => $this->stringFromValue($object['sepa_cc']),
'sepa_ct_op' => $this->stringFromValue($object['sepa_ct_op']),
'sepa_ct_id' => $this->stringFromValue($object['sepa_ct_id']),
'sepa_db' => $this->stringFromValue($object['sepa_db']),
'sepa_country' => $this->stringFromValue($object['sepa_country']),
'sepa_ep' => $this->stringFromValue($object['sepa_ep']),
'sepa_ci' => $this->stringFromValue($object['sepa_ci']),
'sepa_batch_id' => $this->stringFromValue($object['sepa_batch_id']),
// custom date fields. Must be Carbon objects. Presence is optional.
'interest_date' => $this->dateFromValue($object['interest_date']),
'book_date' => $this->dateFromValue($object['book_date']),
'process_date' => $this->dateFromValue($object['process_date']),
'due_date' => $this->dateFromValue($object['due_date']),
'payment_date' => $this->dateFromValue($object['payment_date']),
'invoice_date' => $this->dateFromValue($object['invoice_date']),
];
}
return $return;
}
}

View File

@@ -146,6 +146,139 @@ class TransactionUpdateRequest extends FormRequest
return $data;
}
/**
* Get transaction data.
*
* @return array
*/
private function getTransactionData(): array
{
Log::debug('Now in getTransactionData()');
$return = [];
/**
* @var int $index
* @var array $transaction
*/
foreach ($this->get('transactions') as $transaction) {
// default response is to update nothing in the transaction:
$current = [];
$current = $this->getIntegerData($current, $transaction);
$current = $this->getStringData($current, $transaction);
$current = $this->getNlStringData($current, $transaction);
$current = $this->getDateData($current, $transaction);
$current = $this->getBooleanData($current, $transaction);
$current = $this->getArrayData($current, $transaction);
$return[] = $current;
}
return $return;
}
/**
* For each field, add it to the array if a reference is present in the request:
*
* @param array $current
*
* @return array
*/
private function getIntegerData(array $current, array $transaction): array
{
foreach ($this->integerFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->integerFromValue((string) $transaction[$fieldName]);
}
}
return $current;
}
/**
* @param array $current
* @param array $transaction
*
* @return array
*/
private function getStringData(array $current, array $transaction): array
{
foreach ($this->stringFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->stringFromValue((string) $transaction[$fieldName]);
}
}
return $current;
}
/**
* @param array $current
* @param array $transaction
*
* @return array
*/
private function getNlStringData(array $current, array $transaction): array
{
foreach ($this->textareaFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->nlStringFromValue((string) $transaction[$fieldName]);
}
}
return $current;
}
/**
* @param array $current
* @param array $transaction
*
* @return array
*/
private function getDateData(array $current, array $transaction): array
{
foreach ($this->dateFields as $fieldName) {
Log::debug(sprintf('Now at date field %s', $fieldName));
if (array_key_exists($fieldName, $transaction)) {
Log::debug(sprintf('New value: "%s"', (string) $transaction[$fieldName]));
$current[$fieldName] = $this->dateFromValue((string) $transaction[$fieldName]);
}
}
return $current;
}
/**
* @param array $current
* @param array $transaction
*
* @return array
*/
private function getBooleanData(array $current, array $transaction): array
{
foreach ($this->booleanFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->convertBoolean((string) $transaction[$fieldName]);
}
}
return $current;
}
/**
* @param array $current
* @param array $transaction
*
* @return array
*/
private function getArrayData(array $current, array $transaction): array
{
foreach ($this->arrayFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->arrayFromValue($transaction[$fieldName]);
}
}
return $current;
}
/**
* The rules that the incoming request must be matched against.
*
@@ -272,137 +405,4 @@ class TransactionUpdateRequest extends FormRequest
}
);
}
/**
* @param array $current
* @param array $transaction
*
* @return array
*/
private function getArrayData(array $current, array $transaction): array
{
foreach ($this->arrayFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->arrayFromValue($transaction[$fieldName]);
}
}
return $current;
}
/**
* @param array $current
* @param array $transaction
*
* @return array
*/
private function getBooleanData(array $current, array $transaction): array
{
foreach ($this->booleanFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->convertBoolean((string) $transaction[$fieldName]);
}
}
return $current;
}
/**
* @param array $current
* @param array $transaction
*
* @return array
*/
private function getDateData(array $current, array $transaction): array
{
foreach ($this->dateFields as $fieldName) {
Log::debug(sprintf('Now at date field %s', $fieldName));
if (array_key_exists($fieldName, $transaction)) {
Log::debug(sprintf('New value: "%s"', (string) $transaction[$fieldName]));
$current[$fieldName] = $this->dateFromValue((string) $transaction[$fieldName]);
}
}
return $current;
}
/**
* For each field, add it to the array if a reference is present in the request:
*
* @param array $current
*
* @return array
*/
private function getIntegerData(array $current, array $transaction): array
{
foreach ($this->integerFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->integerFromValue((string) $transaction[$fieldName]);
}
}
return $current;
}
/**
* @param array $current
* @param array $transaction
*
* @return array
*/
private function getNlStringData(array $current, array $transaction): array
{
foreach ($this->textareaFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->nlStringFromValue((string) $transaction[$fieldName]);
}
}
return $current;
}
/**
* @param array $current
* @param array $transaction
*
* @return array
*/
private function getStringData(array $current, array $transaction): array
{
foreach ($this->stringFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->stringFromValue((string) $transaction[$fieldName]);
}
}
return $current;
}
/**
* Get transaction data.
*
* @return array
*/
private function getTransactionData(): array
{
Log::debug('Now in getTransactionData()');
$return = [];
/**
* @var int $index
* @var array $transaction
*/
foreach ($this->get('transactions') as $transaction) {
// default response is to update nothing in the transaction:
$current = [];
$current = $this->getIntegerData($current, $transaction);
$current = $this->getStringData($current, $transaction);
$current = $this->getNlStringData($current, $transaction);
$current = $this->getDateData($current, $transaction);
$current = $this->getBooleanData($current, $transaction);
$current = $this->getArrayData($current, $transaction);
$return[] = $current;
}
return $return;
}
}

View File

@@ -35,6 +35,7 @@ use Illuminate\Foundation\Http\FormRequest;
class UserStoreRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -35,6 +35,7 @@ use Illuminate\Foundation\Http\FormRequest;
class UserUpdateRequest extends FormRequest
{
use ConvertsDataTypes;
/**
* Authorize logged in users.
*

View File

@@ -32,6 +32,7 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Illuminate\Console\Command;
use JsonException;
use Log;
/**
@@ -60,6 +61,7 @@ class CorrectOpeningBalanceCurrencies extends Command
*/
public function handle(): int
{
Log::debug(sprintf('Now in %s', __METHOD__));
// get all OB journals:
$set = TransactionJournal
::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')
@@ -70,16 +72,23 @@ class CorrectOpeningBalanceCurrencies extends Command
$count = 0;
/** @var TransactionJournal $journal */
foreach ($set as $journal) {
Log::debug(sprintf('Going to fix journal #%d', $journal->id));
$count += $this->correctJournal($journal);
Log::debug(sprintf('Done, count is now %d', $count));
}
if ($count > 0) {
$this->line(sprintf('Corrected %d opening balance transactions.', $count));
$message = sprintf('Corrected %d opening balance transaction(s).', $count);
Log::debug($message);
$this->line($message);
}
if (0 === $count) {
$this->info('There was nothing to fix in the opening balance transactions.');
$message = 'There was nothing to fix in the opening balance transactions.';
Log::debug($message);
$this->info($message);
}
Log::debug(sprintf('Done with %s', __METHOD__));
return 0;
}
@@ -94,18 +103,18 @@ class CorrectOpeningBalanceCurrencies extends Command
// get the asset account for this opening balance:
$account = $this->getAccount($journal);
if (null === $account) {
$this->warn(sprintf('Transaction journal #%d has no valid account. Cant fix this line.', $journal->id));
$message = sprintf('Transaction journal #%d has no valid account. Cant fix this line.', $journal->id);
Log::warning($message);
$this->warn($message);
return 0;
}
Log::debug(sprintf('Found %s #%d "%s".', $account->accountType->type, $account->id, $account->name));
Log::debug(sprintf('Found "%s" #%d "%s".', $account->accountType->type, $account->id, $account->name));
$currency = $this->getCurrency($account);
Log::debug(sprintf('Found currency #%d (%s)', $currency->id, $currency->code));
// update journal and all transactions:
$this->setCurrency($journal, $currency);
return 1;
return $this->setCurrency($journal, $currency);
}
/**
@@ -115,22 +124,27 @@ class CorrectOpeningBalanceCurrencies extends Command
*/
private function getAccount(TransactionJournal $journal): ?Account
{
$transactions = $journal->transactions()->with(['account', 'account.accountType'])->get();
$transactions = $journal->transactions()->get();
Log::debug(sprintf('Found %d transactions for journal #%d.', $transactions->count(), $journal->id));
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
$account = $transaction->account;
if ((null !== $account) && AccountType::INITIAL_BALANCE !== $account->accountType->type) {
Log::debug(sprintf('Testing transaction #%d', $transaction->id));
/** @var Account $account */
$account = $transaction->account()->first();
if (null !== $account && AccountType::INITIAL_BALANCE !== $account->accountType()->first()->type) {
Log::debug(sprintf('Account of transaction #%d is opposite of IB account (%s).', $transaction->id, $account->accountType()->first()->type));
return $account;
}
}
Log::debug('Found no IB account in transactions of journal.');
return null;
}
/**
* @param Account $account
*
* @return TransactionCurrency
* @throws JsonException
*/
private function getCurrency(Account $account): TransactionCurrency
{
@@ -144,16 +158,30 @@ class CorrectOpeningBalanceCurrencies extends Command
/**
* @param TransactionJournal $journal
* @param TransactionCurrency $currency
* @return int
*/
private function setCurrency(TransactionJournal $journal, TransactionCurrency $currency): void
private function setCurrency(TransactionJournal $journal, TransactionCurrency $currency): int
{
$journal->transaction_currency_id = $currency->id;
$journal->save();
Log::debug('Now in setCurrency');
$count = 0;
if ((int) $journal->transaction_currency_id !== (int) $currency->id) {
Log::debug(sprintf('Currency ID of journal #%d was #%d, now set to #%d', $journal->id, $journal->transaction_currency_id, $currency->id));
$journal->transaction_currency_id = $currency->id;
$journal->save();
$count = 1;
}
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
$transaction->transaction_currency_id = $currency->id;
$transaction->save();
if ((int) $transaction->transaction_currency_id !== (int) $currency->id) {
Log::debug(sprintf('Currency ID of transaction #%d was #%d, now set to #%d', $transaction->id, $transaction->transaction_currency_id, $currency->id));
$transaction->transaction_currency_id = $currency->id;
$transaction->save();
$count = 1;
}
}
Log::debug(sprintf('Return %d', $count));
return $count;
}
}

View File

@@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Log;
/**
* Class EnableCurrencies
@@ -75,9 +76,10 @@ class EnableCurrencies extends Command
// get all from transactions
/** @var Collection $transactions */
$transactions = Transaction::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
$transactions = Transaction::groupBy('transaction_currency_id', 'foreign_currency_id')->get(['transaction_currency_id','foreign_currency_id']);
foreach ($transactions as $entry) {
$found[] = (int) $entry->transaction_currency_id;
$found[] = (int) $entry->foreign_currency_id;
}
// get all from budget limits
@@ -87,8 +89,13 @@ class EnableCurrencies extends Command
$found[] = (int) $entry->transaction_currency_id;
}
$found = array_unique($found);
$this->info(sprintf('%d different currencies are currently in use.', count($found)));
$found = array_values(array_unique($found));
$found = array_values(array_filter($found, function (int $currencyId) {
return $currencyId !== 0;
}));
$message = sprintf('%d different currencies are currently in use.', count($found));
$this->info($message);
Log::debug($message, $found);
$disabled = TransactionCurrency::whereIn('id', $found)->where('enabled', false)->count();
if ($disabled > 0) {

View File

@@ -1,6 +1,6 @@
<?php
/**
* FixAccountTypes.php
* FixAccountOrder.php
* Copyright (c) 2020 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\AccountType;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\User;
@@ -53,7 +52,6 @@ class FixAccountOrder extends Command
/**
* Execute the console command.
*
* @throws FireflyException
* @return int
*/
public function handle(): int
@@ -69,6 +67,7 @@ class FixAccountOrder extends Command
[AccountType::EXPENSE, AccountType::BENEFICIARY],
[AccountType::REVENUE],
[AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],
[AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],
];
foreach ($sets as $set) {
$this->repository->resetAccountOrder($set);

View File

@@ -46,14 +46,10 @@ class FixAccountTypes extends Command
* The name and signature of the console command.
* @var string
*/
protected $signature = 'firefly-iii:fix-account-types';
/** @var int */
private $count;
private array $expected;
/** @var AccountFactory */
private $factory;
/** @var array */
private $fixable;
protected $signature = 'firefly-iii:fix-account-types';
private int $count;
private array $expected;
private AccountFactory $factory;
/**
@@ -65,22 +61,11 @@ class FixAccountTypes extends Command
{
$this->stupidLaravel();
Log::debug('Now in fix-account-types');
$start = microtime(true);
$this->factory = app(AccountFactory::class);
// some combinations can be fixed by this script:
$this->fixable = [// transfers from asset to liability and vice versa
sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::LOAN), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::DEBT), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::ASSET, AccountType::MORTGAGE), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::LOAN, AccountType::ASSET), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::DEBT, AccountType::ASSET), sprintf('%s%s%s', TransactionType::TRANSFER, AccountType::MORTGAGE, AccountType::ASSET),
// withdrawals with a revenue account as destination instead of an expense account.
sprintf('%s%s%s', TransactionType::WITHDRAWAL, AccountType::ASSET, AccountType::REVENUE),
// deposits with an expense account as source instead of a revenue account.
sprintf('%s%s%s', TransactionType::DEPOSIT, AccountType::EXPENSE, AccountType::ASSET),];
$start = microtime(true);
$this->factory = app(AccountFactory::class);
$this->expected = config('firefly.source_dests');
$journals = TransactionJournal::with(['TransactionType', 'transactions', 'transactions.account', 'transactions.account.accounttype'])->get();
Log::debug(sprintf('Found %d journals to fix.', $journals->count()));
Log::debug(sprintf('Found %d journals to inspect.', $journals->count()));
foreach ($journals as $journal) {
$this->inspectJournal($journal);
}
@@ -120,7 +105,9 @@ class FixAccountTypes extends Command
$withdrawal = TransactionType::whereType(TransactionType::WITHDRAWAL)->first();
$journal->transactionType()->associate($withdrawal);
$journal->save();
$this->info(sprintf('Converted transaction #%d from a transfer to a withdrawal.', $journal->id));
$message = sprintf('Converted transaction #%d from a transfer to a withdrawal.', $journal->id);
$this->info($message);
Log::debug($message);
// check it again:
$this->inspectJournal($journal);
break;
@@ -131,7 +118,9 @@ class FixAccountTypes extends Command
$deposit = TransactionType::whereType(TransactionType::DEPOSIT)->first();
$journal->transactionType()->associate($deposit);
$journal->save();
$this->info(sprintf('Converted transaction #%d from a transfer to a deposit.', $journal->id));
$message = sprintf('Converted transaction #%d from a transfer to a deposit.', $journal->id);
$this->info($message);
Log::debug($message);
// check it again:
$this->inspectJournal($journal);
@@ -143,7 +132,9 @@ class FixAccountTypes extends Command
$result = $this->factory->findOrCreate($dest->account->name, AccountType::EXPENSE);
$dest->account()->associate($result);
$dest->save();
$this->info(sprintf('Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").', $journal->id, $oldDest->id, $oldDest->name, $result->id, $result->name));
$message = sprintf('Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").', $journal->id, $oldDest->id, $oldDest->name, $result->id, $result->name);
$this->info($message);
Log::debug($message);
$this->inspectJournal($journal);
break;
case sprintf('%s%s%s', TransactionType::DEPOSIT, AccountType::EXPENSE, AccountType::ASSET):
@@ -154,12 +145,19 @@ class FixAccountTypes extends Command
$oldSource = $dest->account;
$source->account()->associate($result);
$source->save();
$this->info(sprintf('Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").', $journal->id, $oldSource->id, $oldSource->name, $result->id, $result->name));
$message = sprintf('Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").', $journal->id, $oldSource->id, $oldSource->name, $result->id, $result->name);
$this->info($message);
Log::debug($message);
$this->inspectJournal($journal);
break;
default:
$this->info(sprintf('The source account of %s #%d cannot be of type "%s".', $type, $journal->id, $source->account->accountType->type));
$this->info(sprintf('The destination account of %s #%d cannot be of type "%s".', $type, $journal->id, $dest->account->accountType->type));
$message = sprintf('The source account of %s #%d cannot be of type "%s".', $type, $journal->id, $source->account->accountType->type);
$this->info($message);
Log::debug($message);
$message = sprintf('The destination account of %s #%d cannot be of type "%s".', $type, $journal->id, $dest->account->accountType->type);
$this->info($message);
Log::debug($message);
break;
@@ -190,28 +188,16 @@ class FixAccountTypes extends Command
*/
private function inspectJournal(TransactionJournal $journal): void
{
//Log::debug(sprintf('Now trying to fix journal #%d', $journal->id));
$count = $journal->transactions()->count();
if (2 !== $count) {
Log::debug(sprintf('Journal has %d transactions, so cant fix.', $count));
$this->info(sprintf('Cannot inspect transaction journal #%d because it has %d transaction(s) instead of 2.', $journal->id, $count));
$transactions = $journal->transactions()->count();
if (2 !== $transactions) {
Log::debug(sprintf('Journal has %d transactions, so can\'t fix.', $transactions));
$this->info(sprintf('Cannot inspect transaction journal #%d because it has %d transaction(s) instead of 2.', $journal->id, $transactions));
return;
}
$type = $journal->transactionType->type;
$sourceTransaction = $this->getSourceTransaction($journal);
$destTransaction = $this->getDestinationTransaction($journal);
if (null === $sourceTransaction) {
Log::error('Source transaction is unexpectedly NULL. Wont fix this journal.');
return;
}
if (null === $destTransaction) {
Log::error('Destination transaction is unexpectedly NULL. Wont fix this journal.');
return;
}
$sourceAccount = $sourceTransaction->account;
$sourceAccountType = $sourceAccount->accountType->type;
$destAccount = $destTransaction->account;
@@ -226,12 +212,14 @@ class FixAccountTypes extends Command
// @codeCoverageIgnoreEnd
}
if (!array_key_exists($sourceAccountType, $this->expected[$type])) {
Log::debug(sprintf('Going to fix journal #%d', $journal->id));
$this->fixJournal($journal, $type, $sourceTransaction, $destTransaction);
return;
}
$expectedTypes = $this->expected[$type][$sourceAccountType];
if (!in_array($destAccountType, $expectedTypes, true)) {
Log::debug(sprintf('Going to fix journal #%d', $journal->id));
$this->fixJournal($journal, $type, $sourceTransaction, $destTransaction);
}
}

View File

@@ -57,7 +57,6 @@ class FixGroupAccounts extends Command
*/
public function handle(): int
{
// select transaction_group_id, count(transaction_group_id) as the_count from transaction_journals group by transaction_group_id having the_count > 1
$groups = [];
$res = TransactionJournal
::groupBy('transaction_group_id')

View File

@@ -76,7 +76,8 @@ class FixLongDescriptions extends Command
}
}
$end = round(microtime(true) - $start, 2);
$this->info(sprintf('Verified all transaction group and journal title lengths in %s seconds.', $end));
$this->info('Verified all transaction group and journal title lengths.');
$this->info(sprintf('Took %s seconds.', $end));
return 0;
}

View File

@@ -86,7 +86,6 @@ class FixPiggies extends Command
$event->save();
$this->line(sprintf('Piggy bank #%d was referenced by an invalid event. This has been fixed.', $event->piggy_bank_id));
$this->count++;
continue;
}
}
if (0 === $this->count) {

View File

@@ -68,7 +68,7 @@ class FixRecurringTransactions extends Command
$end = round(microtime(true) - $start, 2);
$this->info(sprintf('Corrected recurring transactions %s seconds.', $end));
$this->info(sprintf('Corrected recurring transactions in %s seconds.', $end));
return 0;
}
@@ -81,28 +81,7 @@ class FixRecurringTransactions extends Command
$users = $this->userRepos->all();
/** @var User $user */
foreach ($users as $user) {
$this->recurringRepos->setUser($user);
$recurrences = $this->recurringRepos->get();
/** @var Recurrence $recurrence */
foreach ($recurrences as $recurrence) {
/** @var RecurrenceTransaction $transaction */
foreach ($recurrence->recurrenceTransactions as $transaction) {
$source = $transaction->sourceAccount;
$destination = $transaction->destinationAccount;
$type = $recurrence->transactionType;
$link = config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
if (null !== $link && strtolower($type->type) !== strtolower($link)) {
$this->warn(
sprintf('Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.', $recurrence->id, $link, $type->type)
);
$transactionType = TransactionType::whereType($link)->first();
if (null !== $transactionType) {
$recurrence->transaction_type_id = $transactionType->id;
$recurrence->save();
}
}
}
}
$this->processUser($user);
}
}
@@ -119,5 +98,49 @@ class FixRecurringTransactions extends Command
$this->userRepos = app(UserRepositoryInterface::class);
}
/**
* @param User $user
*/
private function processUser(User $user): void
{
$this->recurringRepos->setUser($user);
$recurrences = $this->recurringRepos->get();
/** @var Recurrence $recurrence */
foreach ($recurrences as $recurrence) {
$this->processRecurrence($recurrence);
}
}
/**
* @param Recurrence $recurrence
*/
private function processRecurrence(Recurrence $recurrence): void
{
/** @var RecurrenceTransaction $transaction */
foreach ($recurrence->recurrenceTransactions as $transaction) {
$this->processTransaction($recurrence, $transaction);
}
}
/**
* @param Recurrence $recurrence
* @param RecurrenceTransaction $transaction
*/
private function processTransaction(Recurrence $recurrence, RecurrenceTransaction $transaction): void
{
$source = $transaction->sourceAccount;
$destination = $transaction->destinationAccount;
$type = $recurrence->transactionType;
$link = config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));
if (null !== $link && strtolower($type->type) !== strtolower($link)) {
$this->warn(
sprintf('Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.', $recurrence->id, $link, $type->type)
);
$transactionType = TransactionType::whereType($link)->first();
if (null !== $transactionType) {
$recurrence->transaction_type_id = $transactionType->id;
$recurrence->save();
}
}
}
}

View File

@@ -44,8 +44,7 @@ class RenameMetaFields extends Command
*/
protected $signature = 'firefly-iii:rename-meta-fields';
/** @var int */
private $count;
private int $count;
/**
@@ -93,9 +92,9 @@ class RenameMetaFields extends Command
*/
private function rename(string $original, string $update): void
{
$count = DB::table('journal_meta')
$total = DB::table('journal_meta')
->where('name', '=', $original)
->update(['name' => $update]);
$this->count += $count;
$this->count += $total;
}
}

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
use Illuminate\Console\Command;
use Log;
/**
* Class TransferBudgets
@@ -62,15 +63,21 @@ class TransferBudgets extends Command
$count = 0;
/** @var TransactionJournal $entry */
foreach ($set as $entry) {
$this->info(sprintf('Transaction journal #%d is a %s, so has no longer a budget.', $entry->id, $entry->transactionType->type));
$message = sprintf('Transaction journal #%d is a %s, so has no longer a budget.', $entry->id, $entry->transactionType->type);
$this->info($message);
Log::debug($message);
$entry->budgets()->sync([]);
$count++;
}
if (0 === $count) {
$this->info('No invalid budget/journal entries.');
$message = 'No invalid budget/journal entries.';
Log::debug($message);
$this->info($message);
}
if (0 !== $count) {
$this->line(sprintf('Corrected %d invalid budget/journal entries (entry).', $count));
$message = sprintf('Corrected %d invalid budget/journal entries (entry).', $count);
Log::debug($message);
$this->line($message);
}
$end = round(microtime(true) - $start, 2);
$this->info(sprintf('Verified budget/journals in %s seconds.', $end));

View File

@@ -0,0 +1,79 @@
<?php
declare(strict_types=1);
namespace FireflyIII\Console\Commands;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
use Str;
/**
* Class CreateFirstUser
* @package FireflyIII\Console\Commands
*/
class CreateFirstUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'firefly-iii:create-first-user {email}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Creates a new user and gives admin rights. Outputs the password on the command line. Strictly for testing.';
private UserRepositoryInterface $repository;
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
if ('testing' !== env('APP_ENV', 'local')) {
$this->error('This command only works in the testing environment.');
return 1;
}
$this->stupidLaravel();
$count = $this->repository->count();
if ($count > 0) {
$this->error('Already have more than zero users in DB.');
return 1;
}
$data = [
'blocked' => false,
'blocked_code' => null,
'email' => $this->argument('email'),
'role' => 'owner',
];
$password = Str::random(24);
$user = $this->repository->store($data);
$user->password = Hash::make($password);
$user->save();
$user->setRememberToken(Str::random(60));
$this->info(sprintf('Created new admin user (ID #%d) with email address "%s" and password "%s".', $user->id, $user->email, $password));
$this->error('Change this password.');
return 0;
}
/**
* Laravel will execute ALL __construct() methods for ALL commands whenever a SINGLE command is
* executed. This leads to noticeable slow-downs and class calls. To prevent this, this method should
* be called from the handle method instead of using the constructor to initialize the command.
*
* @codeCoverageIgnore
*/
private function stupidLaravel(): void
{
$this->repository = app(UserRepositoryInterface::class);
}
}

View File

@@ -32,6 +32,7 @@ use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\DecryptException;
use JsonException;
use Log;
use stdClass;
/**
* Class DecryptDatabase
@@ -51,11 +52,9 @@ class DecryptDatabase extends Command
*/
protected $signature = 'firefly-iii:decrypt-all';
/**
* Execute the console command.
*
* @throws FireflyException
* @return int
*/
public function handle(): int
@@ -74,52 +73,12 @@ class DecryptDatabase extends Command
'transactions' => ['description'],
'journal_links' => ['comment'],
];
/**
* @var string $table
* @var array $fields
*/
foreach ($tables as $table => $fields) {
if ($this->isDecrypted($table)) {
$this->info(sprintf('No decryption required for table "%s".', $table));
continue;
}
foreach ($fields as $field) {
$rows = DB::table($table)->get(['id', $field]);
foreach ($rows as $row) {
$original = $row->$field;
if (null === $original) {
continue;
}
$id = $row->id;
$value = $this->tryDecrypt($original);
// A separate routine for preferences:
if ('preferences' === $table) {
// try to json_decrypt the value.
try {
$value = json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value;
} catch(JsonException $e) {
Log::error($e->getMessage());
}
//Log::debug(sprintf('Decrypted field "%s" "%s" to "%s" in table "%s" (row #%d)', $field, $original, print_r($value, true), $table, $id));
/** @var Preference $object */
$object = Preference::find((int) $id);
if (null !== $object) {
$object->data = $value;
$object->save();
}
continue;
}
if ($value !== $original) {
//Log::debug(sprintf('Decrypted field "%s" "%s" to "%s" in table "%s" (row #%d)', $field, $original, $value, $table, $id));
DB::table($table)->where('id', $id)->update([$field => $value]);
}
}
}
$this->line(sprintf('Decrypted the data in table "%s".', $table));
// mark as decrypted:
$configName = sprintf('is_decrypted_%s', $table);
app('fireflyconfig')->set($configName, true);
$this->decryptTable($table, $fields);
}
$this->info('Done!');
@@ -134,7 +93,12 @@ class DecryptDatabase extends Command
private function isDecrypted(string $table): bool
{
$configName = sprintf('is_decrypted_%s', $table);
$configVar = app('fireflyconfig')->get($configName, false);
$configVar = null;
try {
$configVar = app('fireflyconfig')->get($configName, false);
} catch (FireflyException $e) {
Log::error($e->getMessage());
}
if (null !== $configVar) {
return (bool) $configVar->data;
}
@@ -148,13 +112,13 @@ class DecryptDatabase extends Command
*
* @param $value
*
* @throws FireflyException
* @return string
* @throws FireflyException
*/
private function tryDecrypt($value)
{
try {
$value = Crypt::decrypt($value); // verified
$value = Crypt::decrypt($value);
} catch (DecryptException $e) {
if ('The MAC is invalid.' === $e->getMessage()) {
throw new FireflyException($e->getMessage()); // @codeCoverageIgnore
@@ -163,4 +127,96 @@ class DecryptDatabase extends Command
return $value;
}
/**
* @param string $table
* @param array $fields
*/
private function decryptTable(string $table, array $fields): void
{
if ($this->isDecrypted($table)) {
$this->info(sprintf('No decryption required for table "%s".', $table));
return;
}
foreach ($fields as $field) {
$this->decryptField($table, $field);
}
$this->line(sprintf('Decrypted the data in table "%s".', $table));
// mark as decrypted:
$configName = sprintf('is_decrypted_%s', $table);
app('fireflyconfig')->set($configName, true);
}
/**
* @param string $table
* @param string $field
*/
private function decryptField(string $table, string $field): void
{
$rows = DB::table($table)->get(['id', $field]);
/** @var stdClass $row */
foreach ($rows as $row) {
$this->decryptRow($table, $field, $row);
}
}
/**
* @param string $table
* @param string $field
* @param stdClass $row
*/
private function decryptRow(string $table, string $field, stdClass $row): void
{
$original = $row->$field;
if (null === $original) {
return;
}
$id = (int) $row->id;
$value = '';
try {
$value = $this->tryDecrypt($original);
} catch (FireflyException $e) {
$message = sprintf('Could not decrypt field "%s" in row #%d of table "%s": %s', $field, $id, $table, $e->getMessage());
$this->error($message);
Log::error($message);
Log::error($e->getTraceAsString());
}
// A separate routine for preferences table:
if ('preferences' === $table) {
$this->decryptPreferencesRow($id, $value);
return;
}
if ($value !== $original) {
DB::table($table)->where('id', $id)->update([$field => $value]);
}
}
/**
* @param int $id
* @param string $value
*/
private function decryptPreferencesRow(int $id, string $value): void
{
// try to json_decrypt the value.
try {
$newValue = json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value;
} catch (JsonException $e) {
$message = sprintf('Could not JSON decode preference row #%d: %s. This does not have to be a problem.', $id, $e->getMessage());
$this->error($message);
Log::warning($message);
Log::warning($value);
Log::warning($e->getTraceAsString());
return;
}
/** @var Preference $object */
$object = Preference::find((int) $id);
if (null !== $object) {
$object->data = $newValue;
$object->save();
}
}
}

View File

@@ -131,11 +131,11 @@ class ApplyRules extends Command
$ruleEngine->setUser($this->getUser());
// add the accounts as filter:
$accounts = [];
$filterAccountList = [];
foreach($this->accounts as $account) {
$accounts[] = $account->id;
$filterAccountList[] = $account->id;
}
$list = implode(',', $accounts);
$list = implode(',', $filterAccountList);
$ruleEngine->addOperator(['type' => 'account_id', 'value' => $list]);
// add the date as a filter:
@@ -295,7 +295,7 @@ class ApplyRules extends Command
private function verifyInputDates(): void
{
// parse start date.
$startDate = Carbon::now()->startOfMonth();
$inputStart = Carbon::now()->startOfMonth();
$startString = $this->option('start_date');
if (null === $startString) {
/** @var JournalRepositoryInterface $repository */
@@ -303,26 +303,26 @@ class ApplyRules extends Command
$repository->setUser($this->getUser());
$first = $repository->firstNull();
if (null !== $first) {
$startDate = $first->date;
$inputStart = $first->date;
}
}
if (null !== $startString && '' !== $startString) {
$startDate = Carbon::createFromFormat('Y-m-d', $startString);
$inputStart = Carbon::createFromFormat('Y-m-d', $startString);
}
// parse end date
$endDate = Carbon::now();
$inputEnd = Carbon::now();
$endString = $this->option('end_date');
if (null !== $endString && '' !== $endString) {
$endDate = Carbon::createFromFormat('Y-m-d', $endString);
$inputEnd = Carbon::createFromFormat('Y-m-d', $endString);
}
if ($startDate > $endDate) {
[$endDate, $startDate] = [$startDate, $endDate];
if ($inputStart > $inputEnd) {
[$inputEnd, $inputStart] = [$inputStart, $inputEnd];
}
$this->startDate = $startDate;
$this->endDate = $endDate;
$this->startDate = $inputStart;
$this->endDate = $inputEnd;
}
/**

View File

@@ -72,8 +72,8 @@ class MigrateAttachments extends Command
foreach ($attachments as $att) {
// move description:
$description = (string) $att->description;
if ('' !== $description) {
$attDescription = (string) $att->description;
if ('' !== $attDescription) {
// find or create note:
$note = $att->notes()->first();
@@ -81,7 +81,7 @@ class MigrateAttachments extends Command
$note = new Note;
$note->noteable()->associate($att);
}
$note->text = $description;
$note->text = $attDescription;
$note->save();
// clear description:

View File

@@ -58,23 +58,18 @@ class MigrateToGroups extends Command
*
* @var string
*/
protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
/** @var JournalCLIRepositoryInterface */
private $cliRepository;
private $count;
/** @var TransactionGroupFactory */
private $groupFactory;
/** @var JournalRepositoryInterface */
private $journalRepository;
/** @var JournalDestroyService */
private $service;
protected $signature = 'firefly-iii:migrate-to-groups {--F|force : Force the migration, even if it fired before.}';
private JournalCLIRepositoryInterface $cliRepository;
private int $count;
private TransactionGroupFactory $groupFactory;
private JournalRepositoryInterface $journalRepository;
private JournalDestroyService $service;
/**
* Execute the console command.
*
* @throws Exception
* @return int
* @throws Exception
*/
public function handle(): int
{
@@ -254,16 +249,16 @@ class MigrateToGroups extends Command
private function makeGroupsFromAll(): void
{
$orphanedJournals = $this->cliRepository->getJournalsWithoutGroup();
$count = count($orphanedJournals);
if ($count > 0) {
Log::debug(sprintf('Going to convert %d transaction journals. Please hold..', $count));
$this->line(sprintf('Going to convert %d transaction journals. Please hold..', $count));
$total = count($orphanedJournals);
if ($total > 0) {
Log::debug(sprintf('Going to convert %d transaction journals. Please hold..', $total));
$this->line(sprintf('Going to convert %d transaction journals. Please hold..', $total));
/** @var array $journal */
foreach ($orphanedJournals as $array) {
$this->giveGroup($array);
}
}
if (0 === $count) {
if (0 === $total) {
$this->info('No need to convert transaction journals.');
}
}

View File

@@ -43,11 +43,13 @@ class OtherCurrenciesCorrections extends Command
public const CONFIG_NAME = '480_other_currencies';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update all journal currency information.';
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'firefly-iii:other-currencies {--F|force : Force the execution of this command.}';
@@ -67,6 +69,7 @@ class OtherCurrenciesCorrections extends Command
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
@@ -93,6 +96,7 @@ class OtherCurrenciesCorrections extends Command
/**
* @param Account $account
*
* @return TransactionCurrency|null
*/
private function getCurrency(Account $account): ?TransactionCurrency
@@ -120,7 +124,9 @@ class OtherCurrenciesCorrections extends Command
/**
* Gets the transaction that determines the transaction that "leads" and will determine
* the currency to be used by all transactions, and the journal itself.
*
* @param TransactionJournal $journal
*
* @return Transaction|null
*/
private function getLeadTransaction(TransactionJournal $journal): ?Transaction
@@ -128,6 +134,8 @@ class OtherCurrenciesCorrections extends Command
/** @var Transaction $lead */
$lead = null;
switch ($journal->transactionType->type) {
default:
break;
case TransactionType::WITHDRAWAL:
$lead = $journal->transactions()->where('amount', '<', 0)->first();
break;
@@ -136,11 +144,15 @@ class OtherCurrenciesCorrections extends Command
break;
case TransactionType::OPENING_BALANCE:
// whichever isn't an initial balance account:
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')->where('account_types.type', '!=', AccountType::INITIAL_BALANCE)->first(['transactions.*']);
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin(
'account_types', 'accounts.account_type_id', '=', 'account_types.id'
)->where('account_types.type', '!=', AccountType::INITIAL_BALANCE)->first(['transactions.*']);
break;
case TransactionType::RECONCILIATION:
// whichever isn't the reconciliation account:
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')->where('account_types.type', '!=', AccountType::RECONCILIATION)->first(['transactions.*']);
$lead = $journal->transactions()->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin(
'account_types', 'accounts.account_type_id', '=', 'account_types.id'
)->where('account_types.type', '!=', AccountType::RECONCILIATION)->first(['transactions.*']);
break;
}
@@ -172,6 +184,7 @@ class OtherCurrenciesCorrections extends Command
* Laravel will execute ALL __construct() methods for ALL commands whenever a SINGLE command is
* executed. This leads to noticeable slow-downs and class calls. To prevent this, this method should
* be called from the handle method instead of using the constructor to initialize the command.
*
* @codeCoverageIgnore
*/
private function stupidLaravel(): void
@@ -209,27 +222,33 @@ class OtherCurrenciesCorrections extends Command
$currency = $this->getCurrency($account);
if (null === $currency) {
// @codeCoverageIgnoreStart
$this->error(sprintf('Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected', $account->id, $account->name, $journal->id));
$this->error(
sprintf(
'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected', $account->id, $account->name, $journal->id
)
);
$this->count++;
return;
// @codeCoverageIgnoreEnd
}
// fix each transaction:
$journal->transactions->each(static function (Transaction $transaction) use ($currency) {
if (null === $transaction->transaction_currency_id) {
$transaction->transaction_currency_id = $currency->id;
$transaction->save();
}
$journal->transactions->each(
static function (Transaction $transaction) use ($currency) {
if (null === $transaction->transaction_currency_id) {
$transaction->transaction_currency_id = $currency->id;
$transaction->save();
}
// when mismatch in transaction:
if (!((int)$transaction->transaction_currency_id === (int)$currency->id)) {
$transaction->foreign_currency_id = (int)$transaction->transaction_currency_id;
$transaction->foreign_amount = $transaction->amount;
$transaction->transaction_currency_id = $currency->id;
$transaction->save();
// when mismatch in transaction:
if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {
$transaction->foreign_currency_id = (int)$transaction->transaction_currency_id;
$transaction->foreign_amount = $transaction->amount;
$transaction->transaction_currency_id = $currency->id;
$transaction->save();
}
}
});
);
// also update the journal, of course:
$journal->transaction_currency_id = $currency->id;
$this->count++;
@@ -244,7 +263,9 @@ class OtherCurrenciesCorrections extends Command
*/
private function updateOtherJournalsCurrencies(): void
{
$set = $this->cliRepos->getAllJournals([TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION,]);
$set = $this->cliRepos->getAllJournals(
[TransactionType::WITHDRAWAL, TransactionType::DEPOSIT, TransactionType::OPENING_BALANCE, TransactionType::RECONCILIATION,]
);
/** @var TransactionJournal $journal */
foreach ($set as $journal) {

View File

@@ -87,7 +87,7 @@ trait VerifiesAccessToken
return false;
}
if (!($accessToken->data === $token)) {
if ($accessToken->data !== $token) {
Log::error(sprintf('Invalid access token for user #%d.', $userId));
Log::error(sprintf('Token given is "%s", expected something else.', $token));

View File

@@ -56,14 +56,14 @@ class Kernel extends ConsoleKernel
$schedule->call(
static function () {
Log::error(
'Firefly III no longer users the Laravel scheduler to do cron jobs! Please read the instructions at https://firefly-iii.readthedocs.io/en/latest/'
'Firefly III no longer users the Laravel scheduler to do cron jobs! Please read the instructions at https://docs.firefly-iii.org/'
);
echo "\n";
echo '------------';
echo "\n";
echo wordwrap('Firefly III no longer users the Laravel scheduler to do cron jobs! Please read the instructions here:');
echo "\n";
echo 'https://firefly-iii.readthedocs.io/en/latest/';
echo 'https://docs.firefly-iii.org/';
echo "\n\n";
echo 'Disable this cron job!';
echo "\n";

View File

@@ -77,6 +77,8 @@ class GracefulNotFoundHandler extends ExceptionHandler
return $this->handleGroup($request, $exception);
case 'attachments.show':
case 'attachments.edit':
case 'attachments.download':
case 'attachments.view':
// redirect to original attachment holder.
return $this->handleAttachment($request, $exception);
break;
@@ -117,12 +119,10 @@ class GracefulNotFoundHandler extends ExceptionHandler
$request->session()->reflash();
return redirect(route('categories.index'));
break;
case 'rules.edit':
$request->session()->reflash();
return redirect(route('rules.index'));
break;
case 'transactions.edit':
case 'transactions.mass.edit':
case 'transactions.mass.delete':

View File

@@ -29,7 +29,6 @@ use FireflyIII\Models\Note;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\User;
use Log;
/**
* Class AttachmentFactory

View File

@@ -40,21 +40,7 @@ class BillFactory
{
use BillServiceTrait, CreatesObjectGroups;
/** @var User */
private $user;
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
private User $user;
/**
* @param array $data
@@ -153,11 +139,7 @@ class BillFactory
*/
public function findByName(string $name): ?Bill
{
$query = sprintf('%%%s%%', $name);
/** @var Bill $first */
$first = $this->user->bills()->where('name', 'LIKE', $query)->first();
return $first;
return $this->user->bills()->where('name', 'LIKE', sprintf('%%%s%%', $name))->first();
}
/**

View File

@@ -25,28 +25,13 @@ namespace FireflyIII\Factory;
use FireflyIII\Models\Budget;
use FireflyIII\User;
use Log;
/**
* Class BudgetFactory.
*/
class BudgetFactory
{
/** @var User */
private $user;
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
private User $user;
/**
* @param int|null $budgetId

View File

@@ -35,21 +35,7 @@ use Log;
*/
class CategoryFactory
{
/** @var User */
private $user;
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
private User $user;
/**
* @param string $name
@@ -65,13 +51,13 @@ class CategoryFactory
* @param int|null $categoryId
* @param null|string $categoryName
*
* @throws FireflyException
* @return Category|null
* @throws FireflyException
*/
public function findOrCreate(?int $categoryId, ?string $categoryName): ?Category
{
$categoryId = (int) $categoryId;
$categoryName = (string) $categoryName;
$categoryId = (int)$categoryId;
$categoryName = (string)$categoryName;
Log::debug(sprintf('Going to find category with ID %d and name "%s"', $categoryId, $categoryName));

View File

@@ -37,18 +37,6 @@ use Log;
*/
class PiggyBankEventFactory
{
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
/**
* @param TransactionJournal $journal
* @param PiggyBank|null $piggyBank

View File

@@ -26,28 +26,13 @@ namespace FireflyIII\Factory;
use FireflyIII\Models\PiggyBank;
use FireflyIII\User;
use Log;
/**
* Class PiggyBankFactory
*/
class PiggyBankFactory
{
/** @var User */
private $user;
/**
* Constructor.
*
* @codeCoverageIgnore
*/
public function __construct()
{
if ('testing' === config('app.env')) {
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', get_class($this)));
}
}
private User $user;
/**
* @param int|null $piggyBankId

View File

@@ -27,7 +27,6 @@ namespace FireflyIII\Factory;
use FireflyIII\Models\Location;
use FireflyIII\Models\Tag;
use FireflyIII\User;
use Illuminate\Support\Collection;
use Log;
/**
@@ -79,10 +78,12 @@ class TagFactory
public function findOrCreate(string $tag): ?Tag
{
$tag = trim($tag);
Log::debug(sprintf('Now in TagFactory::findOrCreate("%s")', $tag));
/** @var Tag $dbTag */
$dbTag = $this->user->tags()->where('tag', $tag)->first();
if (null !== $dbTag) {
Log::debug(sprintf('Tag exists (#%d), return it.', $dbTag->id));
return $dbTag;
}
$newTag = $this->create(
@@ -95,6 +96,11 @@ class TagFactory
'zoom_level' => null,
]
);
if (null === $newTag) {
Log::error(sprintf('TagFactory::findOrCreate("%s") but tag is unexpectedly NULL!', $tag));
return null;
}
Log::debug(sprintf('Created new tag #%d ("%s")', $newTag->id, $newTag->tag));
return $newTag;
}

View File

@@ -59,6 +59,7 @@ class TransactionGroupFactory
*/
public function create(array $data): TransactionGroup
{
Log::debug('Now in TransactionGroupFactory::create()');
$this->journalFactory->setUser($this->user);
$this->journalFactory->setErrorOnHash($data['error_if_duplicate_hash'] ?? false);
try {

View File

@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Factory;
use Carbon\Carbon;
use Exception;
use FireflyIII\Exceptions\DuplicateTransactionException;
use FireflyIII\Exceptions\FireflyException;
@@ -56,26 +55,16 @@ class TransactionJournalFactory
{
use JournalServiceTrait;
private AccountRepositoryInterface $accountRepository;
private AccountValidator $accountValidator;
private BillRepositoryInterface $billRepository;
/** @var CurrencyRepositoryInterface */
private $currencyRepository;
/** @var bool */
private $errorOnHash;
/** @var array */
private $fields;
/** @var PiggyBankEventFactory */
private $piggyEventFactory;
/** @var PiggyBankRepositoryInterface */
private $piggyRepository;
/** @var TransactionFactory */
private $transactionFactory;
/** @var TransactionTypeRepositoryInterface */
private $typeRepository;
/** @var User The user */
private $user;
private AccountRepositoryInterface $accountRepository;
private AccountValidator $accountValidator;
private BillRepositoryInterface $billRepository;
private CurrencyRepositoryInterface $currencyRepository;
private bool $errorOnHash;
private array $fields;
private PiggyBankEventFactory $piggyEventFactory;
private PiggyBankRepositoryInterface $piggyRepository;
private TransactionTypeRepositoryInterface $typeRepository;
private User $user;
/**
* Constructor.
@@ -112,7 +101,6 @@ class TransactionJournalFactory
$this->currencyRepository = app(CurrencyRepositoryInterface::class);
$this->typeRepository = app(TransactionTypeRepositoryInterface::class);
$this->transactionFactory = app(TransactionFactory::class);
$this->billRepository = app(BillRepositoryInterface::class);
$this->budgetRepository = app(BudgetRepositoryInterface::class);
$this->categoryRepository = app(CategoryRepositoryInterface::class);
@@ -134,6 +122,7 @@ class TransactionJournalFactory
*/
public function create(array $data): Collection
{
Log::debug('Now in TransactionJournalFactory::create()');
// convert to special object.
$dataObject = new NullArrayObject($data);
@@ -195,7 +184,6 @@ class TransactionJournalFactory
$this->user = $user;
$this->currencyRepository->setUser($this->user);
$this->tagFactory->setUser($user);
$this->transactionFactory->setUser($this->user);
$this->billRepository->setUser($this->user);
$this->budgetRepository->setUser($this->user);
$this->categoryRepository->setUser($this->user);
@@ -328,7 +316,6 @@ class TransactionJournalFactory
Log::debug(sprintf('Created new journal #%d: "%s"', $journal->id, $journal->description));
/** Create two transactions. */
/** @var TransactionFactory $transactionFactory */
$transactionFactory = app(TransactionFactory::class);
$transactionFactory->setUser($this->user);
$transactionFactory->setJournal($journal);

View File

@@ -209,7 +209,7 @@ class ChartJsGenerator implements GeneratorInterface
*/
public function singleSet(string $setLabel, array $data): array
{
$chartData = [
return [
'count' => 1,
'labels' => array_keys($data), // take ALL labels from the first set.
'datasets' => [
@@ -219,7 +219,5 @@ class ChartJsGenerator implements GeneratorInterface
],
],
];
return $chartData;
}
}

View File

@@ -41,12 +41,9 @@ use Throwable;
*/
class MonthReportGenerator implements ReportGeneratorInterface
{
/** @var Collection The accounts used. */
private $accounts;
/** @var Carbon End date of the report. */
private $end;
/** @var Carbon Start date of the report. */
private $start;
private Collection $accounts;
private Carbon $end;
private Carbon $start;
/**
* Generates the report.
@@ -155,17 +152,15 @@ class MonthReportGenerator implements ReportGeneratorInterface
}
$locale = app('steam')->getLocale();
$return = [
return [
'journals' => $journals,
'currency' => $currency,
'exists' => count($journals) > 0,
'exists' => !empty($journals),
'end' => $this->end->formatLocalized((string) trans('config.month_and_day', [], $locale)),
'endBalance' => app('steam')->balance($account, $this->end),
'dayBefore' => $date->formatLocalized((string) trans('config.month_and_day', [], $locale)),
'dayBeforeBalance' => $dayBeforeBalance,
];
return $return;
}
/**

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