Compare commits

...

242 Commits

Author SHA1 Message Date
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
James Cole
712b8d6e0c Merge branch 'release/5.4.3' into main 2020-10-03 16:23:07 +02:00
James Cole
50cfb54a3d Updated meta-files & translations for upcoming release. 2020-10-03 16:20:59 +02:00
James Cole
dcb1866e81 Add some breadcrumbs 2020-10-03 15:58:25 +02:00
James Cole
f2550a7861 Fix #3893 2020-10-03 15:16:42 +02:00
James Cole
5ed3d52e9a Fix #3894 2020-10-03 15:08:24 +02:00
James Cole
aadcb2cc5b Fix https://github.com/firefly-iii/firefly-iii/issues/3592 2020-10-03 07:03:41 +02:00
James Cole
96028e91be Fix #3887 2020-10-02 17:45:35 +02:00
James Cole
f92780d3da Updated meta-files & translations for upcoming release. 2020-10-02 08:46:41 +02:00
James Cole
8c7e3b3731 Fix #3884 2020-10-02 07:47:02 +02:00
James Cole
8eb6b5a364 Fix #3881 2020-10-01 18:43:41 +02:00
James Cole
d03ca0ec36 Some bug fixes. 2020-10-01 17:02:15 +02:00
James Cole
c25f5598f1 Some bug fixes. 2020-10-01 16:52:01 +02:00
James Cole
d32611b2d5 Remove unused dropdown menu. 2020-10-01 14:27:06 +02:00
James Cole
9ab034c1ad Rebuild frontend. 2020-10-01 14:24:35 +02:00
James Cole
b3edbecde2 Code for #3875 2020-10-01 12:48:27 +02:00
James Cole
3ce949f0aa Fix #3880 2020-10-01 10:50:34 +02:00
James Cole
df8c6abd5c Fix issue submitted over email by Gustav, making sure the "budgeted" amount matches the budgets below. 2020-10-01 08:06:25 +02:00
James Cole
b94561223e Fix search for #3850 2020-10-01 07:42:20 +02:00
James Cole
f633769f7b Fix links for #3824 2020-10-01 07:33:39 +02:00
James Cole
8767bad61e Fix #3879 2020-10-01 07:31:08 +02:00
James Cole
c01345468d Fix #3878 2020-10-01 07:07:18 +02:00
James Cole
8046d14d2d Clean up readme and incorporate the badges as suggested by @lastlink 2020-09-30 19:23:15 +02:00
James Cole
f957d8aeb5 Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2020-09-30 17:28:31 +02:00
James Cole
564a387505 Rebuild JS and some switch stuff for #3826 2020-09-30 17:28:16 +02:00
James Cole
116fc0c70f Merge pull request #3874 from sephrat/fix-3858
FIx #3858
2020-09-30 17:22:32 +02:00
James Cole
f82e35a8a8 New rendered JS. 2020-09-30 17:20:51 +02:00
James Cole
ea76647b29 Fix #3862 2020-09-30 17:19:58 +02:00
James Cole
26dc70c8fd Merge pull request #3863 from lastlink/patch-3
sonarcloud badges
2020-09-30 17:10:05 +02:00
James Cole
85113d50be Merge pull request #3855 from achembarpu/patch-1
Add start_url to manifest file
2020-09-30 17:06:17 +02:00
James Cole
9e41cc27af Merge pull request #3854 from sephrat/fix-3853
Fix #3853
2020-09-30 17:05:16 +02:00
Florian Dupret
89d8c11b52 More pagination fixes 2020-09-29 14:05:41 +02:00
Florian Dupret
70d16c31ad FIx #3858 2020-09-29 13:04:41 +02:00
lastlink
e07f243344 Update readme.md
pr changes
2020-09-28 13:04:22 -04:00
James Cole
ba4a43b4aa Merge pull request #3869 from firefly-iii/dependabot/npm_and_yarn/frontend/develop/popperjs/core-2.5.2
Bump @popperjs/core from 2.5.1 to 2.5.2 in /frontend
2020-09-28 08:18:22 +02:00
James Cole
860bf22503 Merge pull request #3868 from firefly-iii/dependabot/npm_and_yarn/frontend/develop/vue-router-3.4.5
Bump vue-router from 3.4.3 to 3.4.5 in /frontend
2020-09-28 08:04:27 +02:00
dependabot[bot]
4a1f009458 Bump @popperjs/core from 2.5.1 to 2.5.2 in /frontend
Bumps [@popperjs/core](https://github.com/popperjs/popper-core) from 2.5.1 to 2.5.2.
- [Release notes](https://github.com/popperjs/popper-core/releases)
- [Commits](https://github.com/popperjs/popper-core/compare/v2.5.1...v2.5.2)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-28 05:56:13 +00:00
dependabot[bot]
4830b3b2c1 Bump vue-router from 3.4.3 to 3.4.5 in /frontend
Bumps [vue-router](https://github.com/vuejs/vue-router) from 3.4.3 to 3.4.5.
- [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.3...v3.4.5)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-28 05:55:02 +00:00
James Cole
e2bf13b5ca Merge pull request #3865 from firefly-iii/dependabot/composer/develop/phpunit/phpunit-9.3.11
Bump phpunit/phpunit from 9.3.10 to 9.3.11
2020-09-28 07:29:38 +02:00
James Cole
c36a4f64d4 Merge pull request #3867 from firefly-iii/dependabot/composer/develop/doctrine/dbal-2.11.1
Bump doctrine/dbal from 2.11.0 to 2.11.1
2020-09-28 07:29:15 +02:00
James Cole
39abea0290 Merge pull request #3866 from firefly-iii/dependabot/composer/develop/phpstan/phpstan-0.12.45
Bump phpstan/phpstan from 0.12.43 to 0.12.45
2020-09-28 07:28:43 +02:00
dependabot[bot]
abec47f6c3 Bump doctrine/dbal from 2.11.0 to 2.11.1
Bumps [doctrine/dbal](https://github.com/doctrine/dbal) from 2.11.0 to 2.11.1.
- [Release notes](https://github.com/doctrine/dbal/releases)
- [Commits](https://github.com/doctrine/dbal/compare/2.11.0...2.11.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-28 05:25:41 +00:00
dependabot[bot]
4f0100b7a9 Bump phpstan/phpstan from 0.12.43 to 0.12.45
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 0.12.43 to 0.12.45.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Commits](https://github.com/phpstan/phpstan/compare/0.12.43...0.12.45)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-28 05:23:07 +00:00
dependabot[bot]
8c576953ad Bump phpunit/phpunit from 9.3.10 to 9.3.11
Bumps [phpunit/phpunit](https://github.com/sebastianbergmann/phpunit) from 9.3.10 to 9.3.11.
- [Release notes](https://github.com/sebastianbergmann/phpunit/releases)
- [Changelog](https://github.com/sebastianbergmann/phpunit/blob/master/ChangeLog-9.3.md)
- [Commits](https://github.com/sebastianbergmann/phpunit/compare/9.3.10...9.3.11)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-28 05:21:25 +00:00
lastlink
e8f9d2b608 Update readme.md
sonarcloud badges, easy fruits for open source contributors to work on. I can move the order around if preferred.
2020-09-26 23:01:37 -04:00
Arvind Chembarpu
2347267518 Add start_url to manifest
start_url is a mandatory field.
2020-09-24 22:34:58 +02:00
Florian Dupret
602f5b6646 Fix #3853 2020-09-24 19:42:12 +02:00
James Cole
b1b2e0ff09 Merge tag '5.4.2' into develop
5.4.2
2020-09-24 06:24:30 +02:00
James Cole
ab38bfe4d2 Merge branch 'release/5.4.2' into main 2020-09-24 06:24:29 +02:00
James Cole
dcb3f23078 Update meta data for new release. 2020-09-24 06:22:08 +02:00
James Cole
c0f363cf86 Consistent dates for #3847 2020-09-24 06:09:26 +02:00
James Cole
46ebf3c07c Consistent dates for #3847 2020-09-24 06:06:18 +02:00
James Cole
ed7977a105 Fix count for #3841 2020-09-24 06:00:45 +02:00
James Cole
f093dbb30b Fix #3844 2020-09-23 20:37:31 +02:00
James Cole
620b69f234 Fix #3841 2020-09-23 20:30:42 +02:00
James Cole
a346b6ee29 Bad redirect when editing a not found transaction. 2020-09-23 20:28:20 +02:00
James Cole
ccb511936e Better fix for #3842, thanks @niklas2810 2020-09-23 20:18:30 +02:00
James Cole
9f98289952 Fix #3843 2020-09-23 20:17:21 +02:00
James Cole
e549b74c97 Fix #3842 2020-09-23 20:13:08 +02:00
James Cole
f73af50eb0 Fix #3840 2020-09-23 19:32:46 +02:00
James Cole
5f5346ed71 Partial fix for #3840 2020-09-23 19:29:10 +02:00
James Cole
fc157b2944 Fix #3839 2020-09-23 19:14:50 +02:00
James Cole
cc1a537ecb Meta data for 5.4.2 2020-09-23 19:14:39 +02:00
James Cole
1e5df66c62 Expand readme. 2020-09-23 16:44:39 +02:00
James Cole
e5ea82663e Create .mergify.yml 2020-09-23 07:41:56 +00:00
James Cole
2d6e6f3ec9 Merge pull request #3837 from okaufmann/fix-account-detail
Fixes account notes parsing (Reopen)
2020-09-23 07:40:58 +00:00
James Cole
a822c9f833 Merge branch 'develop' into fix-account-detail 2020-09-23 07:40:46 +00:00
James Cole
0b8b9cb280 Update version. 2020-09-23 06:18:59 +02:00
James Cole
29b8cf936e Add mergify config 2020-09-23 06:18:49 +02:00
James Cole
b288d6b0eb Fix #3828 2020-09-23 06:18:43 +02:00
James Cole
8a2d5b12c3 Instructions for one-time donations. 2020-09-23 05:56:49 +02:00
James Cole
a7dc9e201f Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2020-09-23 05:50:51 +02:00
James Cole
c686f16a93 Merge pull request #3831 from okaufmann/main
Fixes `Unknown column 'notes' in 'where clause'` when using Rules
2020-09-23 03:49:50 +00:00
Oliver Kaufmann
58245d85b3 fix account notes 2020-09-23 02:18:53 +02:00
Oliver Kaufmann
f564ef5195 fix notes filter query 2020-09-22 23:48:36 +02:00
James Cole
18c24a7251 Fix #3827 2020-09-22 18:27:21 +02:00
James Cole
d97fd73ce5 Make sure notes always have a value, even when null #3823 2020-09-22 16:19:51 +02:00
James Cole
1624abd9ed Merge pull request #3822 from achembarpu/patch-1
Fix web app manifest
2020-09-22 05:15:50 +00:00
Arvind Chembarpu
14f22009ed Update manifest link 2020-09-21 21:25:57 +02:00
Arvind Chembarpu
86cd3c0c38 Do not force portrait mode
For easier use on larger devices like tablets
2020-09-21 21:24:32 +02:00
Arvind Chembarpu
855fe1235a Rename site.webmanifest to manifest.webmanifest
As per Web App Manifest spec - https://www.w3.org/TR/appmanifest/
2020-09-21 21:24:03 +02:00
Arvind Chembarpu
198a0f7011 Delete manifest.json 2020-09-21 21:21:32 +02:00
James Cole
2b16d73e65 Remove LDAP limit from 2FA 2020-09-21 20:40:47 +02:00
James Cole
03f68426e5 Merge tag '5.4.1' into develop
5.4.1
2020-09-21 19:52:27 +02:00
James Cole
229479b7ed Merge branch 'release/5.4.1' into main 2020-09-21 19:52:26 +02:00
James Cole
0f742aa040 Update changelog and meta files for 5.4.1 2020-09-21 18:28:34 +02:00
James Cole
e5ac6a3a1d Add some debug info. 2020-09-21 16:08:41 +02:00
James Cole
d05fb4472c Fix count reference. 2020-09-21 15:56:50 +02:00
James Cole
5161971373 Different call to count() 2020-09-21 15:45:51 +02:00
James Cole
2a5841c631 Temp debug information. 2020-09-21 15:39:14 +02:00
James Cole
766abd3336 Extra info for debug screen. 2020-09-21 15:39:03 +02:00
James Cole
b58cde5431 Add some debug info. 2020-09-21 15:30:54 +02:00
James Cole
9964cf11a4 Fix #3809 2020-09-21 15:20:14 +02:00
James Cole
7f9c8fa133 Merge tag '5.4.0' into develop
5.4.0
2020-09-21 13:21:42 +02:00
James Cole
10057f05a5 Merge branch 'release/5.4.0' into main 2020-09-21 13:21:41 +02:00
James Cole
fc61b20f6d Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2020-09-21 12:47:48 +02:00
James Cole
40e7f019dd Meta data for new release, 5.4.0. 2020-09-21 12:47:40 +02:00
James Cole
2f32ddce6b Merge pull request #3814 from firefly-iii/dependabot/composer/develop/phpstan/phpstan-0.12.43
Bump phpstan/phpstan from 0.12.42 to 0.12.43
2020-09-21 07:52:53 +00:00
James Cole
459015c01e Merge pull request #3813 from firefly-iii/dependabot/composer/develop/doctrine/dbal-2.11.0
Bump doctrine/dbal from 2.10.4 to 2.11.0
2020-09-21 07:52:41 +00:00
dependabot[bot]
b669f96036 Bump phpstan/phpstan from 0.12.42 to 0.12.43
Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 0.12.42 to 0.12.43.
- [Release notes](https://github.com/phpstan/phpstan/releases)
- [Commits](https://github.com/phpstan/phpstan/compare/0.12.42...0.12.43)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-21 05:19:54 +00:00
dependabot[bot]
4524d1cfe3 Bump doctrine/dbal from 2.10.4 to 2.11.0
Bumps [doctrine/dbal](https://github.com/doctrine/dbal) from 2.10.4 to 2.11.0.
- [Release notes](https://github.com/doctrine/dbal/releases)
- [Commits](https://github.com/doctrine/dbal/compare/2.10.4...2.11.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-21 05:17:28 +00:00
James Cole
651029e284 Don't use isset. 2020-09-20 16:18:48 +02:00
James Cole
cbeb2675fd Fix second issue in #3809 2020-09-20 16:16:49 +02:00
James Cole
7a80caf26b Fix #3790 2020-09-18 16:14:17 +02:00
James Cole
f3eaf1dd4c Code for #3790 2020-09-18 16:07:59 +02:00
James Cole
af88e91a48 Update attributes 2020-09-18 12:25:41 +02:00
James Cole
706cb47065 Code changes for v540 2020-09-18 12:16:47 +02:00
James Cole
0d72aa9673 Default is MySQL 2020-09-18 09:46:22 +02:00
James Cole
039e654ef1 Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2020-09-14 20:01:47 +02:00
James Cole
1c3fe93d59 Recognize a year. 2020-09-14 20:01:33 +02:00
James Cole
5ef45fd4a3 Merge pull request #3794 from firefly-iii/dependabot/composer/develop/league/commonmark-1.5.5
Bump league/commonmark from 1.5.4 to 1.5.5
2020-09-14 07:24:15 +00:00
James Cole
db700d6b80 Merge pull request #3793 from firefly-iii/dependabot/npm_and_yarn/develop/uiv-0.37.0
Bump uiv from 0.36.1 to 0.37.0
2020-09-14 07:16:35 +00:00
dependabot[bot]
7032bdc169 Bump league/commonmark from 1.5.4 to 1.5.5
Bumps [league/commonmark](https://github.com/thephpleague/commonmark) from 1.5.4 to 1.5.5.
- [Release notes](https://github.com/thephpleague/commonmark/releases)
- [Changelog](https://github.com/thephpleague/commonmark/blob/latest/CHANGELOG-1.x.md)
- [Commits](https://github.com/thephpleague/commonmark/compare/1.5.4...1.5.5)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-14 06:28:32 +00:00
dependabot[bot]
1dde09c738 Bump uiv from 0.36.1 to 0.37.0
Bumps [uiv](https://github.com/wxsms/uiv) from 0.36.1 to 0.37.0.
- [Release notes](https://github.com/wxsms/uiv/releases)
- [Commits](https://github.com/wxsms/uiv/compare/v0.36.1...v0.37.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-14 06:26:19 +00:00
James Cole
a54ca0141a Merge tag '5.4.0-beta.1' into develop
5.4.0-beta.1
2020-09-13 07:48:50 +02:00
898 changed files with 14572 additions and 59977 deletions

View File

@@ -9,6 +9,7 @@ parameters:
- '#is not allowed to extend#'
- '#is neither abstract nor final#'
- '#Control structures using switch should not be used\.#'
- '#has a nullable return type declaration#'
paths:
- ../app
- ../database
@@ -16,4 +17,4 @@ parameters:
- ../bootstrap/app.php
# The level 8 is the highest level. original was 5
level: 0
level: 5

View File

@@ -15,6 +15,7 @@ pl_PL
pt_BR
ro_RO
ru_RU
sk_SK
sv_SE
vi_VN
zh-hans_CN

View File

@@ -179,11 +179,22 @@ AUTHENTICATION_GUARD=web
# Some systems use X-Auth headers. In that case, use HTTP_X_AUTH_USERNAME or HTTP_X_AUTH_EMAIL
# Depending on your system, REMOTE_USER may need to be changed to HTTP_REMOTE_USER
#
# Firefly III won't be able to send emails when the header you use isn't an email address.
#
AUTHENTICATION_GUARD_HEADER=REMOTE_USER
# Likewise, it's impossible to log out users who's authentication is handled by an external system.
#
# Firefly III uses email addresses as user identifiers. When you're using an external authentication guard
# that doesn't do this, Firefly III is incapable of emailing you. Messages sent to "Bill Gates" always fail.
#
# However, if you set this value, Firefly III will store the value from this header as the user's backup
# email address and use it to communicate. So user "Bill Gates" could still have
# the email address "bill@microsoft.com".
#
# Example value: AUTHENTICATION_GUARD_EMAIL=HTTP_X_AUTH_EMAIL
#
AUTHENTICATION_GUARD_EMAIL=
# It's impossible to log out users who's authentication is handled by an external system.
# Enter a custom URL here that will force a logout (your authentication provider can tell you).
# Setting this variable only works when AUTHENTICATION_GUARD != web
#

3
.gitattributes vendored
View File

@@ -3,3 +3,6 @@
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
/tests export-ignore
/phpunit.xml export-ignore
/.ci export-ignore

7
.github/.mergify.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
pull_request_rules:
- name: PR on main is never approved.
conditions:
- base=main
actions:
close:
message: Please reopen this PR on the `develop` branch. Thank you.

1
.github/funding.yml vendored
View File

@@ -2,4 +2,3 @@
github: jc5
patreon: JC5
custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=L62W7DVD5ETPC&source=url

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

@@ -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);
}
/**
@@ -145,6 +145,9 @@ class AvailableBudgetController extends Controller
public function store(AvailableBudgetRequest $request): JsonResponse
{
$data = $request->getAll();
$data['start']->startOfDay();
$data['end']->endOfDay();
/** @var TransactionCurrencyFactory $factory */
$factory = app(TransactionCurrencyFactory::class);
$currency = $factory->find($data['currency_id'], $data['currency_code']);
@@ -162,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);
}
@@ -202,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

@@ -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,7 +199,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);
}
/**
@@ -207,8 +207,8 @@ class BillController extends Controller
*
* @param BillRequest $request
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function store(BillRequest $request): JsonResponse
{
@@ -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,7 +279,7 @@ 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);
}
/**
@@ -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

@@ -88,17 +88,17 @@ class CategoryController extends Controller
$end = $dates['end'];
$tempData = [];
$spentWith = $this->opsRepository->listExpenses($start, $end);
$spentWithout = $this->noCatRepository->listExpenses($start, $end);
$categories = [];
$tempData = [];
$spentWith = $this->opsRepository->listExpenses($start, $end);
$spentWithout = $this->noCatRepository->listExpenses($start, $end);
$categories = [];
foreach ([$spentWith, $spentWithout, ] as $set) {
foreach ([$spentWith, $spentWithout,] as $set) {
foreach ($set as $currency) {
foreach ($currency['categories'] as $category) {
$categories[] = $category['name'];
$outKey = sprintf('%d-e', $currency['currency_id']);
$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']]),

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

@@ -43,9 +43,7 @@ use League\Fractal\Resource\Item;
*/
class PiggyBankController extends Controller
{
/** @var PiggyBankRepositoryInterface The piggy bank repository */
private $repository;
private PiggyBankRepositoryInterface $repository;
/**
* PiggyBankController constructor.
@@ -111,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);
}
/**
@@ -142,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);
}
@@ -175,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);
}
@@ -197,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);
}
@@ -206,8 +204,8 @@ class PiggyBankController extends Controller
*
* @param PiggyBankStoreRequest $request
*
* @throws FireflyException
* @return JsonResponse
* @throws FireflyException
*/
public function store(PiggyBankStoreRequest $request): JsonResponse
{
@@ -220,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);
}
/**
@@ -247,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

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

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,106 @@ 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;
}
/**
* The rules that the incoming request must be matched against.
*
@@ -175,6 +275,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 +303,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

@@ -55,7 +55,7 @@ class CreateDatabase extends Command
*/
public function handle(): int
{
if ('mysql' !== env('DB_CONNECTION')) {
if ('mysql' !== env('DB_CONNECTION', 'mysql')) {
$this->info(sprintf('CreateDB does not apply to "%s", skipped.', env('DB_CONNECTION')));
return 0;

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', $id, $e->getMessage());
$this->error($message);
Log::error($message);
Log::error($value);
Log::error($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

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/*
* DetectedNewIPAddress.php
* Copyright (c) 2020 james@firefly-iii.org

View File

@@ -51,8 +51,8 @@ class GracefulNotFoundHandler extends ExceptionHandler
* @param Request $request
* @param Exception $exception
*
* @throws Exception
* @return mixed
* @throws Exception
*/
public function render($request, Throwable $exception)
{
@@ -75,9 +75,10 @@ class GracefulNotFoundHandler extends ExceptionHandler
return $this->handleAccount($request, $exception);
case 'transactions.show':
return $this->handleGroup($request, $exception);
break;
case 'attachments.show':
case 'attachments.edit':
case 'attachments.download':
case 'attachments.view':
// redirect to original attachment holder.
return $this->handleAttachment($request, $exception);
break;
@@ -118,29 +119,29 @@ 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':
case 'transactions.bulk.edit':
$request->session()->reflash();
return redirect(route('index'));
break;
if ('POST' === $request->method()) {
$request->session()->reflash();
return redirect(route('index'));
}
return parent::render($request, $exception);
}
}
/**
* @param Request $request
* @param Throwable $exception
*
* @throws Exception
* @return Redirector|Response
* @throws Exception
*/
private function handleAccount(Request $request, Throwable $exception)
{
@@ -167,8 +168,8 @@ class GracefulNotFoundHandler extends ExceptionHandler
* @param Request $request
* @param Throwable $exception
*
* @throws Exception
* @return RedirectResponse|Redirector|Response
* @throws Exception
*/
private function handleAttachment(Request $request, Throwable $exception)
{
@@ -209,11 +210,11 @@ class GracefulNotFoundHandler extends ExceptionHandler
}
/**
* @param Throwable $request
* @param Throwable $request
* @param Exception $exception
*
* @throws Exception
* @return RedirectResponse|\Illuminate\Http\Response|Redirector|Response
* @throws Exception
*/
private function handleGroup(Request $request, Throwable $exception)
{

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

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

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