Compare commits

..

115 Commits

Author SHA1 Message Date
github-actions[bot]
c194a1ae20 Merge pull request #10368 from firefly-iii/release-1748230057
🤖 Automatically merge the PR into the develop branch.
2025-05-26 05:27:43 +02:00
JC5
7df3728394 🤖 Auto commit for release 'develop' on 2025-05-26 2025-05-26 05:27:37 +02:00
James Cole
acad0b5b55 Actual changelog 2025-05-25 07:13:06 +02:00
github-actions[bot]
605ab38660 Merge pull request #10365 from firefly-iii/release-1748149867
🤖 Automatically merge the PR into the develop branch.
2025-05-25 07:11:18 +02:00
JC5
75b21b20d8 🤖 Auto commit for release 'v6.2.15' on 2025-05-25 2025-05-25 07:11:07 +02:00
github-actions[bot]
e82459cd29 Merge pull request #10364 from firefly-iii/release-1748149540
🤖 Automatically merge the PR into the develop branch.
2025-05-25 07:05:46 +02:00
JC5
6dcf80967e 🤖 Auto commit for release 'develop' on 2025-05-25 2025-05-25 07:05:40 +02:00
James Cole
3d9edaeaac Restore missing facades. Whoops. 2025-05-25 07:01:31 +02:00
github-actions[bot]
4a5a31bf69 Merge pull request #10362 from firefly-iii/release-1748148584
🤖 Automatically merge the PR into the develop branch.
2025-05-25 06:49:50 +02:00
JC5
5f73e37657 🤖 Auto commit for release 'v6.2.14' on 2025-05-25 2025-05-25 06:49:44 +02:00
github-actions[bot]
7a9c0a8172 Merge pull request #10361 from firefly-iii/release-1748147782
🤖 Automatically merge the PR into the develop branch.
2025-05-25 06:36:31 +02:00
JC5
39914e2380 🤖 Auto commit for release 'develop' on 2025-05-25 2025-05-25 06:36:22 +02:00
James Cole
5a3240f69d Update changelog. 2025-05-25 06:27:05 +02:00
James Cole
19e5fd6277 Back to passport 12 for the time being. 2025-05-25 06:24:01 +02:00
James Cole
e9844dc2f5 Fix #10353 2025-05-24 19:48:09 +02:00
James Cole
c9f07c093a Fix tests and migrations 2025-05-24 17:30:08 +02:00
James Cole
6a986d8119 Merge pull request #10352 from firefly-iii/rector-cleanup-2
Rector cleanup 2
2025-05-24 17:20:07 +02:00
James Cole
f780de9e71 Replace magic facades 2025-05-24 17:19:18 +02:00
James Cole
b830bd2732 Replace magic facades 2025-05-24 17:15:46 +02:00
James Cole
e333dedeec Replace magic facades. 2025-05-24 17:07:12 +02:00
James Cole
6e5a08245c Rector code cleanup 2025-05-24 16:39:20 +02:00
James Cole
6a82a813e0 Fix version, I guess. 2025-05-24 07:24:28 +02:00
James Cole
7992ecf7f6 Use other workflow thing. 2025-05-24 07:22:18 +02:00
James Cole
967f7cb015 Move fix around 2025-05-24 06:37:19 +02:00
James Cole
7ca5e03752 Fix access rights in Sonar test 2025-05-24 06:36:06 +02:00
github-actions[bot]
abc6c611fa Merge pull request #10344 from firefly-iii/release-1748061087
🤖 Automatically merge the PR into the develop branch.
2025-05-24 06:31:36 +02:00
JC5
7673b939a1 🤖 Auto commit for release 'v6.2.13' on 2025-05-24 2025-05-24 06:31:28 +02:00
github-actions[bot]
c029bd42a7 Merge pull request #10343 from firefly-iii/release-1748060657
🤖 Automatically merge the PR into the develop branch.
2025-05-24 06:24:24 +02:00
JC5
63d051d9ba 🤖 Auto commit for release 'develop' on 2025-05-24 2025-05-24 06:24:17 +02:00
James Cole
1ec5ee08aa Update changelog and some final fixes. 2025-05-24 06:19:07 +02:00
James Cole
66be8ee80e Merge pull request #10342 from firefly-iii/fix-phpunit
Fix phpunit tests
2025-05-24 06:09:47 +02:00
James Cole
d26d1b4b87 Fix phpunit tests 2025-05-24 06:07:59 +02:00
James Cole
3716b50616 Merge pull request #10341 from firefly-iii/fix-10320
Fix #10320
2025-05-24 05:53:39 +02:00
James Cole
5e398bd07a Merge pull request #10340 from firefly-iii/nestor
Nestor
2025-05-24 05:53:10 +02:00
James Cole
2ee000debb Fix #10320 2025-05-24 05:52:46 +02:00
James Cole
b8e33201bd Not sure why I keep calling this tool nestor, it's called rector 2025-05-24 05:52:31 +02:00
James Cole
1c33be4828 Various nestor-related fixes. 2025-05-24 05:46:39 +02:00
James Cole
c40229e9fa Various nestor-related fixes. 2025-05-24 05:40:20 +02:00
James Cole
b7ec7625c0 Merge pull request #10339 from firefly-iii/fix-10336
Fix #10336
2025-05-24 05:36:04 +02:00
James Cole
64170d4957 Fix #10336 2025-05-24 05:35:31 +02:00
James Cole
d82c3b55e0 Merge pull request #10331 from firefly-iii/fix-10308
Fix #10308
2025-05-22 06:41:46 +02:00
James Cole
01800a3534 Fix #10308 2025-05-22 06:41:17 +02:00
James Cole
01404bf9cd Merge pull request #10330 from firefly-iii/fix-10305
Fix #10305
2025-05-22 06:11:22 +02:00
James Cole
2f9d73c0b3 Fix #10305 2025-05-22 06:10:54 +02:00
James Cole
670c2e4872 Merge pull request #10329 from firefly-iii/fix-10302
Fix #10302
2025-05-22 06:07:02 +02:00
James Cole
1261122a57 Fix #10302 2025-05-22 06:06:30 +02:00
James Cole
2a17ec9280 Merge pull request #10328 from firefly-iii/fix-10290
Fix #10290
2025-05-22 06:03:05 +02:00
James Cole
1424410115 Fix #10290 2025-05-22 06:02:32 +02:00
James Cole
f20eccf279 Update static cron token 2025-05-19 19:45:19 +02:00
github-actions[bot]
c18cbe1d26 Merge pull request #10319 from firefly-iii/release-1747670547
🤖 Automatically merge the PR into the develop branch.
2025-05-19 18:02:33 +02:00
JC5
d5a3ae43e0 🤖 Auto commit for release 'develop' on 2025-05-19 2025-05-19 18:02:27 +02:00
James Cole
767abacd27 Add spaces. 2025-05-19 17:58:37 +02:00
James Cole
2b3172ba8e Update packcages 2025-05-19 17:53:33 +02:00
github-actions[bot]
1ff8a48ca3 Merge pull request #10317 from firefly-iii/release-1747668888
🤖 Automatically merge the PR into the develop branch.
2025-05-19 17:34:55 +02:00
JC5
5b7645b6d5 🤖 Auto commit for release 'develop' on 2025-05-19 2025-05-19 17:34:48 +02:00
James Cole
ae82474b19 Update packages. 2025-05-19 17:30:53 +02:00
github-actions[bot]
d38c59c5b1 Merge pull request #10313 from firefly-iii/release-1747625288
🤖 Automatically merge the PR into the develop branch.
2025-05-19 05:28:15 +02:00
JC5
a4205afb7b 🤖 Auto commit for release 'develop' on 2025-05-19 2025-05-19 05:28:08 +02:00
github-actions[bot]
75e187ee34 Merge pull request #10303 from firefly-iii/release-1747228276
🤖 Automatically merge the PR into the develop branch.
2025-05-14 15:11:26 +02:00
JC5
a37ed82bb4 🤖 Auto commit for release 'develop' on 2025-05-14 2025-05-14 15:11:16 +02:00
Sander Dorigo
a7233de561 Downgrade 2025-05-14 15:06:10 +02:00
github-actions[bot]
e87c5eee6b Merge pull request #10301 from firefly-iii/release-1747184469
🤖 Automatically merge the PR into the develop branch.
2025-05-14 03:01:16 +02:00
JC5
7a75290709 🤖 Auto commit for release 'develop' on 2025-05-14 2025-05-14 03:01:10 +02:00
James Cole
981f6df9ee Merge branch 'main' into develop 2025-05-14 02:57:20 +02:00
James Cole
c4572c66d3 Restore and update packages. 2025-05-14 02:56:53 +02:00
github-actions[bot]
8e7d750a5a Merge pull request #10298 from firefly-iii/release-1747132859
🤖 Automatically merge the PR into the develop branch.
2025-05-13 12:41:07 +02:00
JC5
94961466f9 🤖 Auto commit for release 'develop' on 2025-05-13 2025-05-13 12:40:59 +02:00
Sander Dorigo
0f3fe45b06 Make parameter optional 2025-05-13 12:36:26 +02:00
Sander Dorigo
0650457ea5 Experimental extra fix for #10265 2025-05-12 13:25:01 +02:00
github-actions[bot]
2e1ce03f13 Merge pull request #10296 from firefly-iii/release-1747034656
🤖 Automatically merge the PR into the develop branch.
2025-05-12 09:24:22 +02:00
JC5
9b345db623 🤖 Auto commit for release 'develop' on 2025-05-12 2025-05-12 09:24:16 +02:00
Sander Dorigo
c1afcc5219 add code improvement 2025-05-12 09:20:38 +02:00
Sander Dorigo
fb394b7f45 Fix nullpointer 2025-05-12 09:19:42 +02:00
Sander Dorigo
381598f1bb Fix optional web routes 2025-05-12 08:39:21 +02:00
James Cole
25b7a76da9 Merge pull request #10294 from firefly-iii/dependabot/github_actions/github/command-2.0.1 2025-05-12 06:37:59 +02:00
dependabot[bot]
4b03ebe3cb Bump github/command from 2.0.0 to 2.0.1
Bumps [github/command](https://github.com/github/command) from 2.0.0 to 2.0.1.
- [Release notes](https://github.com/github/command/releases)
- [Commits](https://github.com/github/command/compare/v2.0.0...v2.0.1)

---
updated-dependencies:
- dependency-name: github/command
  dependency-version: 2.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-12 03:26:53 +00:00
github-actions[bot]
664c59136a Merge pull request #10293 from firefly-iii/release-1747020359
🤖 Automatically merge the PR into the develop branch.
2025-05-12 05:26:07 +02:00
JC5
27b61aae73 🤖 Auto commit for release 'develop' on 2025-05-12 2025-05-12 05:26:00 +02:00
github-actions[bot]
d90fcd1889 Merge pull request #10288 from firefly-iii/release-1746966536
🤖 Automatically merge the PR into the develop branch.
2025-05-11 14:29:03 +02:00
JC5
979d5c579b 🤖 Auto commit for release 'develop' on 2025-05-11 2025-05-11 14:28:56 +02:00
James Cole
5124ca1738 Introduce change for CI to catch. 2025-05-11 14:24:59 +02:00
James Cole
ac5d9b656a Merge pull request #10287 from firefly-iii/add-safe
Include safe methods and require the correct package.
2025-05-11 14:19:33 +02:00
James Cole
9a02739251 Include safe methods and require the correct package. 2025-05-11 14:19:07 +02:00
James Cole
4af2aadc48 Merge pull request #10286 from firefly-iii/remove-safe-methods
Remove safe methods.
2025-05-11 14:09:02 +02:00
James Cole
84779b8d02 Remove safe methods. 2025-05-11 14:08:32 +02:00
github-actions[bot]
145e8d23f0 Merge pull request #10285 from firefly-iii/release-1746964861
🤖 Automatically merge the PR into the develop branch.
2025-05-11 14:01:08 +02:00
JC5
d0ba0583a5 🤖 Auto commit for release 'develop' on 2025-05-11 2025-05-11 14:01:01 +02:00
James Cole
17d8b54280 Merge pull request #10284 from firefly-iii/fix-missing-import-2
Temp commit because the build fails otherwise and I haven't fixed tha…
2025-05-11 13:56:41 +02:00
James Cole
2cf0bfe3c4 Temp commit because the build fails otherwise and I haven't fixed that yet. 2025-05-11 13:56:07 +02:00
James Cole
070a8cf148 Remove safe functions 2025-05-11 13:16:09 +02:00
github-actions[bot]
f94c21446a Merge pull request #10283 from firefly-iii/release-1746961946
🤖 Automatically merge the PR into the develop branch.
2025-05-11 13:12:33 +02:00
JC5
1ef1873016 🤖 Auto commit for release 'develop' on 2025-05-11 2025-05-11 13:12:26 +02:00
James Cole
32e4e29e7c Merge pull request #10282 from firefly-iii/fix-missing-import
Fix missing import.
2025-05-11 13:08:28 +02:00
James Cole
65ca0dd9e0 Fix missing import. 2025-05-11 13:07:37 +02:00
github-actions[bot]
3385e12c01 Merge pull request #10281 from firefly-iii/release-1746961196
🤖 Automatically merge the PR into the develop branch.
2025-05-11 13:00:03 +02:00
JC5
3566a4afa3 🤖 Auto commit for release 'develop' on 2025-05-11 2025-05-11 12:59:56 +02:00
James Cole
68ff033342 Merge pull request #10279 from firefly-iii/fix-10265-addendum
Fix 10265 addendum
2025-05-11 08:33:52 +02:00
James Cole
f141b0be5c Merge branch 'develop' into fix-10265-addendum
# Conflicts:
#	app/Factory/TransactionJournalFactory.php
2025-05-11 08:33:35 +02:00
James Cole
d399dd160f Merge pull request #10278 from firefly-iii/fix-10265
Fix #10265
2025-05-11 08:31:10 +02:00
James Cole
4c8ed784cd Final check for transaction types 2025-05-11 08:29:31 +02:00
James Cole
fb3402acd4 Fix storage issue with transactions. 2025-05-11 08:00:38 +02:00
James Cole
8cad430816 Fix validation error in transaction processing. 2025-05-11 07:35:20 +02:00
James Cole
01502b456e Disable fix for the moment. 2025-05-11 07:29:18 +02:00
James Cole
9b6314066b Clean up logs. 2025-05-11 07:23:35 +02:00
James Cole
e61dadcbc6 Implement correction method. 2025-05-11 07:20:17 +02:00
James Cole
f7baf5b2fd Better debug info 2025-05-11 07:11:00 +02:00
James Cole
0545826d57 Do not try to correct transactions between asset / liability with foreign amount info. 2025-05-11 07:09:48 +02:00
James Cole
a29904704c Fix #10265 2025-05-11 07:01:36 +02:00
James Cole
899d374222 Merge pull request #10271 from firefly-iii/various-updates
Fix account list and remove sanctum
2025-05-08 20:22:24 +02:00
James Cole
07ff2305fd Fix account list and remove sanctum 2025-05-08 20:22:01 +02:00
James Cole
ee96dd3ab6 Merge pull request #10270 from firefly-iii/main
Update packages
2025-05-08 20:21:12 +02:00
James Cole
a766d3a133 Merge pull request #10263 from firefly-iii/dependabot/composer/composer-761f56e718 2025-05-06 07:22:08 +02:00
dependabot[bot]
67545b0371 Bump league/commonmark in the composer group across 1 directory
Bumps the composer group with 1 update in the / directory: [league/commonmark](https://github.com/thephpleague/commonmark).


Updates `league/commonmark` from 2.6.2 to 2.7.0
- [Release notes](https://github.com/thephpleague/commonmark/releases)
- [Changelog](https://github.com/thephpleague/commonmark/blob/2.7/CHANGELOG.md)
- [Commits](https://github.com/thephpleague/commonmark/compare/2.6.2...2.7.0)

---
updated-dependencies:
- dependency-name: league/commonmark
  dependency-version: 2.7.0
  dependency-type: direct:production
  dependency-group: composer
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-06 01:59:56 +00:00
James Cole
6b86d825ea Merge pull request #10261 from firefly-iii/update-packages
Update packages
2025-05-05 07:48:50 +02:00
James Cole
31dbc57e8b Update packages 2025-05-05 07:48:13 +02:00
160 changed files with 1711 additions and 1562 deletions

View File

@@ -1349,16 +1349,16 @@
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.5.1",
"version": "v3.6.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6"
"reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
"reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62",
"reference": "63afe740e99a13ba87ec199bb07bbdee937a5b62",
"shasum": ""
},
"require": {
@@ -1371,7 +1371,7 @@
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "3.5-dev"
"dev-main": "3.6-dev"
}
},
"autoload": {
@@ -1396,7 +1396,7 @@
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1"
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.6.0"
},
"funding": [
{
@@ -1412,7 +1412,7 @@
"type": "tidelift"
}
],
"time": "2024-09-25T14:20:29+00:00"
"time": "2024-09-25T14:21:43+00:00"
},
{
"name": "symfony/event-dispatcher",
@@ -1496,16 +1496,16 @@
},
{
"name": "symfony/event-dispatcher-contracts",
"version": "v3.5.1",
"version": "v3.6.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher-contracts.git",
"reference": "7642f5e970b672283b7823222ae8ef8bbc160b9f"
"reference": "59eb412e93815df44f05f342958efa9f46b1e586"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/7642f5e970b672283b7823222ae8ef8bbc160b9f",
"reference": "7642f5e970b672283b7823222ae8ef8bbc160b9f",
"url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/59eb412e93815df44f05f342958efa9f46b1e586",
"reference": "59eb412e93815df44f05f342958efa9f46b1e586",
"shasum": ""
},
"require": {
@@ -1519,7 +1519,7 @@
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "3.5-dev"
"dev-main": "3.6-dev"
}
},
"autoload": {
@@ -1552,7 +1552,7 @@
"standards"
],
"support": {
"source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.5.1"
"source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.6.0"
},
"funding": [
{
@@ -1568,7 +1568,7 @@
"type": "tidelift"
}
],
"time": "2024-09-25T14:20:29+00:00"
"time": "2024-09-25T14:21:43+00:00"
},
{
"name": "symfony/filesystem",
@@ -2305,16 +2305,16 @@
},
{
"name": "symfony/service-contracts",
"version": "v3.5.1",
"version": "v3.6.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/service-contracts.git",
"reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0"
"reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/e53260aabf78fb3d63f8d79d69ece59f80d5eda0",
"reference": "e53260aabf78fb3d63f8d79d69ece59f80d5eda0",
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4",
"reference": "f021b05a130d35510bd6b25fe9053c2a8a15d5d4",
"shasum": ""
},
"require": {
@@ -2332,7 +2332,7 @@
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "3.5-dev"
"dev-main": "3.6-dev"
}
},
"autoload": {
@@ -2368,7 +2368,7 @@
"standards"
],
"support": {
"source": "https://github.com/symfony/service-contracts/tree/v3.5.1"
"source": "https://github.com/symfony/service-contracts/tree/v3.6.0"
},
"funding": [
{
@@ -2384,7 +2384,7 @@
"type": "tidelift"
}
],
"time": "2024-09-25T14:20:29+00:00"
"time": "2025-04-25T09:37:31+00:00"
},
{
"name": "symfony/stopwatch",

View File

@@ -1,21 +1,70 @@
<?php
/*
* rector.php
* Copyright (c) 2025 james@firefly-iii.org.
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
return RectorConfig::configure()
->withSkip([
ChangeOrIfContinueToMultiContinueRector::class,
])
->withPaths([
__DIR__ . '/../app',
__DIR__ . '/../bootstrap',
__DIR__ . '/../config',
__DIR__ . '/../public',
__DIR__ . '/../resources',
__DIR__ . '/../routes',
__DIR__ . '/../tests',
// __DIR__ . '/../app',
__DIR__ . '/../app/Api',
__DIR__ . '/../app/Http',
// __DIR__ . '/../bootstrap',
// __DIR__ . '/../config',
// __DIR__ . '/../public',
// __DIR__ . '/../resources',
// __DIR__ . '/../routes',
// __DIR__ . '/../tests',
])
// uncomment to reach your current PHP version
// uncomment to reach your current PHP version
->withPhpSets()
->withPreparedSets(
codingStyle : false, // leave false
privatization: false, // leave false.
naming : false, // leave false
instanceOf : true,
earlyReturn : true,
strictBooleans : true,
carbon : true,
rectorPreset : true,
phpunitCodeQuality : true,
doctrineCodeQuality: true,
symfonyCodeQuality : true,
symfonyConfigs : true
)
->withComposerBased(
twig: true,
doctrine: true,
phpunit: true,
symfony: true)
->withTypeCoverageLevel(0)
->withDeadCodeLevel(0)
->withCodeQualityLevel(0);
->withCodeQualityLevel(0)
->withImportNames(removeUnusedImports: true);// import statements instead of full classes.

View File

@@ -289,20 +289,13 @@ ALLOW_WEBHOOKS=false
#
# You can set this variable from a file by appending it with _FILE
#
STATIC_CRON_TOKEN=
STATIC_CRON_TOKEN=PLEASE_REPLACE_WITH_32_CHAR_CODE
# You can fine tune the start-up of a Docker container by editing these environment variables.
# Use this at your own risk. Disabling certain checks and features may result in lots of inconsistent data.
# However if you know what you're doing you can significantly speed up container start times.
# Set each value to true to enable, or false to disable.
# Set this to true to build all locales supported by Firefly III.
# This may take quite some time (several minutes) and is generally not recommended.
# If you wish to change or alter the list of locales, start your Docker container with
# `docker run -v locale.gen:/etc/locale.gen -e DKR_BUILD_LOCALE=true`
# and make sure your preferred locales are in your own locale.gen.
DKR_BUILD_LOCALE=false
# Check if the SQLite database exists. Can be skipped if you're not using SQLite.
# Won't significantly speed up things.
DKR_CHECK_SQLITE=true

View File

@@ -13,7 +13,7 @@ jobs:
close_duplicates:
runs-on: ubuntu-latest
steps:
- uses: github/command@v2.0.0
- uses: github/command@v2.0.1
id: command
with:
allowed_contexts: "issue"

View File

@@ -51,7 +51,10 @@ jobs:
wget -q https://github.com/firefly-iii/test-fixtures/raw/refs/heads/main/test-database.sqlite -O storage/database/database.sqlite
- name: "Upgrades the database to the latest version"
run: php artisan firefly-iii:upgrade-database
run: |
php artisan firefly-iii:upgrade-database
chmod 600 storage/oauth-public.key
chmod 600 storage/oauth-private.key
- name: "Integrity Database Report"
run: php artisan firefly-iii:report-integrity
@@ -63,7 +66,7 @@ jobs:
run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
uses: SonarSource/sonarqube-scan-action@v5.2.0
env:
GITHUB_TOKEN: ${{ secrets.GH_ACTIONS_PERSONAL_ACCESS_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Autocomplete;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Autocomplete\AutocompleteRequest;
use FireflyIII\Enums\UserRoleEnum;
@@ -102,7 +103,7 @@ class TransactionController extends Controller
if (is_numeric($data['query'])) {
// search for group, not journal.
$firstResult = $this->groupRepository->find((int) $data['query']);
if (null !== $firstResult) {
if ($firstResult instanceof TransactionGroup) {
// group may contain multiple journals, each a result:
foreach ($firstResult->transactionJournals as $journal) {
$result->push($journal);

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Chart;
use FireflyIII\Models\TransactionCurrency;
use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Chart\ChartRequest;
@@ -99,7 +100,7 @@ class AccountController extends Controller
private function renderAccountData(array $params, Account $account): void
{
$currency = $this->repository->getAccountCurrency($account);
if (null === $currency) {
if (!$currency instanceof TransactionCurrency) {
$currency = $this->default;
}
$currentSet = [

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\DestroyRequest;
use FireflyIII\Enums\UserRoleEnum;
@@ -59,11 +60,11 @@ class DestroyController extends Controller
public function destroy(DestroyRequest $request, TransactionCurrency $from, TransactionCurrency $to): JsonResponse
{
$date = $request->getDate();
if (null === $date) {
if (!$date instanceof Carbon) {
throw new ValidationException('Date is required');
}
$rate = $this->repository->getSpecificRateOnDate($from, $to, $date);
if (null === $rate) {
if (!$rate instanceof CurrencyExchangeRate) {
throw new NotFoundHttpException();
}
$this->repository->deleteRate($rate);

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use FireflyIII\Models\CurrencyExchangeRate;
use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\StoreRequest;
use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface;
@@ -61,11 +62,11 @@ class StoreController extends Controller
// already has rate?
$object = $this->repository->getSpecificRateOnDate($from, $to, $date);
if (null !== $object) {
if ($object instanceof CurrencyExchangeRate) {
// just update it, no matter.
$rate = $this->repository->updateExchangeRate($object, $rate, $date);
}
if (null === $object) {
if (!$object instanceof CurrencyExchangeRate) {
// store new
$rate = $this->repository->storeExchangeRate($from, $to, $rate, $date);
}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\TransactionCurrency;
use Illuminate\Support\Facades\Validator;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\TransactionCurrency;
@@ -74,15 +75,15 @@ class DestroyController extends Controller
if (!$this->userRepository->hasRole($admin, 'owner')) {
// access denied:
$messages = ['currency_code' => '200005: You need the "owner" role to do this.'];
\Validator::make([], $rules, $messages)->validate();
Validator::make([], $rules, $messages)->validate();
}
if ($this->repository->currencyInUse($currency)) {
$messages = ['currency_code' => '200006: Currency in use.'];
\Validator::make([], $rules, $messages)->validate();
Validator::make([], $rules, $messages)->validate();
}
if ($this->repository->isFallbackCurrency($currency)) {
$messages = ['currency_code' => '200026: Currency is fallback.'];
\Validator::make([], $rules, $messages)->validate();
Validator::make([], $rules, $messages)->validate();
}
$this->repository->destroy($currency);

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\TransactionLink;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\TransactionLink\StoreRequest;
use FireflyIII\Exceptions\FireflyException;
@@ -81,7 +82,7 @@ class StoreController extends Controller
$data = $request->getAll();
$inward = $this->journalRepository->find($data['inward_id'] ?? 0);
$outward = $this->journalRepository->find($data['outward_id'] ?? 0);
if (null === $inward || null === $outward) {
if (!$inward instanceof TransactionJournal || !$outward instanceof TransactionJournal) {
throw new FireflyException('200024: Source or destination does not exist.');
}
$data['direction'] = 'inward';

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\TransactionLinkType;
use Illuminate\Support\Facades\Validator;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\TransactionLinkType\StoreRequest;
use FireflyIII\Exceptions\FireflyException;
@@ -81,7 +82,7 @@ class StoreController extends Controller
if (!$this->userRepository->hasRole($admin, 'owner')) {
// access denied:
$messages = ['name' => '200005: You need the "owner" role to do this.'];
\Validator::make([], $rules, $messages)->validate();
Validator::make([], $rules, $messages)->validate();
}
$data = $request->getAll();
// if currency ID is 0, find the currency by the code:

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\TransactionLinkType;
use Illuminate\Support\Facades\Validator;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\TransactionLinkType\UpdateRequest;
use FireflyIII\Exceptions\FireflyException;
@@ -85,7 +86,7 @@ class UpdateController extends Controller
if (!$this->userRepository->hasRole($admin, 'owner')) {
$messages = ['name' => '200005: You need the "owner" role to do this.'];
\Validator::make([], $rules, $messages)->validate();
Validator::make([], $rules, $messages)->validate();
}
$data = $request->getAll();

View File

@@ -674,15 +674,14 @@ class BasicController extends Controller
*/
protected function notInDateRange(Carbon $date, Carbon $start, Carbon $end): bool // Validate a preference
{
$result = false;
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
$result = true;
return true;
}
// start and end in the past? use $end
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) {
$result = true;
return true;
}
return $result;
return false;
}
}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\System;
use Illuminate\Support\Facades\Validator;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\System\UpdateRequest;
use FireflyIII\Exceptions\FireflyException;
@@ -158,7 +159,7 @@ class ConfigurationController extends Controller
$rules = ['value' => 'required'];
if (!$this->repository->hasRole(auth()->user(), 'owner')) {
$messages = ['value' => '200005: You need the "owner" role to do this.'];
\Validator::make([], $rules, $messages)->validate();
Validator::make([], $rules, $messages)->validate();
}
$data = $request->getAll();
$shortName = str_replace('configuration.', '', $name);

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Requests\System;
use Carbon\Carbon;
use FireflyIII\Support\Request\ConvertsDataTypes;
use Illuminate\Foundation\Http\FormRequest;
@@ -58,7 +59,7 @@ class CronRequest extends FormRequest
$data['date'] = $this->getCarbonDate('date');
}
// catch NULL.
if (null === $data['date']) {
if (!$data['date'] instanceof Carbon) {
$data['date'] = today(config('app.timezone'));
}

View File

@@ -90,7 +90,7 @@ class AccountController extends Controller
'meta' => [
'type' => $account->accountType->type,
// TODO is multi currency property.
'currency_id' => null === $currency ? null : (string) $currency->id,
'currency_id' => $currency instanceof TransactionCurrency ? (string) $currency->id : null,
'currency_code' => $currency?->code,
'currency_symbol' => $currency?->symbol,
'currency_decimal_places' => $currency?->decimal_places,

View File

@@ -94,7 +94,7 @@ class AccountController extends Controller
private function renderAccountData(array $params, Account $account): void
{
$currency = $this->repository->getAccountCurrency($account);
if (null === $currency) {
if (!$currency instanceof TransactionCurrency) {
$currency = $this->default;
}
$currentSet = [

View File

@@ -117,7 +117,7 @@ class Controller extends BaseController
app('log')->warning(sprintf('Ignored invalid date "%s" in API v2 controller parameter check: %s', substr((string) $date, 0, 20), $e->getMessage()));
}
// out of range? set to null.
if (null !== $obj && ($obj->year <= 1900 || $obj->year > 2099)) {
if ($obj instanceof Carbon && ($obj->year <= 1900 || $obj->year > 2099)) {
app('log')->warning(sprintf('Refuse to use date "%s" in API v2 controller parameter check: %s', $field, $obj->toAtomString()));
$obj = null;
}

View File

@@ -398,15 +398,14 @@ class BasicController extends Controller
*/
protected function notInDateRange(Carbon $date, Carbon $start, Carbon $end): bool // Validate a preference
{
$result = false;
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
$result = true;
return true;
}
// start and end in the past? use $end
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) {
$result = true;
return true;
}
return $result;
return false;
}
}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Api\V2\Controllers\Transaction\List;
use Carbon\Carbon;
use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Api\V2\Request\Model\Transaction\ListRequest;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
@@ -62,11 +63,11 @@ class AccountController extends Controller
$start = $request->getStartDate();
$end = $request->getEndDate();
if (null !== $start) {
if ($start instanceof Carbon) {
app('log')->debug(sprintf('Set start date to %s', $start->toIso8601String()));
$collector->setStart($start);
}
if (null !== $end) {
if ($end instanceof Carbon) {
app('log')->debug(sprintf('Set end date to %s', $start->toIso8601String()));
$collector->setEnd($end);
}

View File

@@ -53,7 +53,7 @@ class InfiniteListRequest extends FormRequest
$start = $this->getStartDate();
$end = $this->getEndDate();
if (null !== $start && null !== $end) {
if ($start instanceof Carbon && $end instanceof Carbon) {
$array['start'] = $start->format('Y-m-d');
$array['end'] = $end->format('Y-m-d');
}

View File

@@ -49,7 +49,7 @@ class ListRequest extends FormRequest
$start = $this->getStartDate();
$end = $this->getEndDate();
if (null !== $start && null !== $end) {
if ($start instanceof Carbon && $end instanceof Carbon) {
$array['start'] = $start->format('Y-m-d');
$array['end'] = $end->format('Y-m-d');
}

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Schema;
class CorrectsDatabase extends Command
{
@@ -40,7 +41,7 @@ class CorrectsDatabase extends Command
public function handle(): int
{
// if table does not exist, return false
if (!\Schema::hasTable('users')) {
if (!Schema::hasTable('users')) {
$this->friendlyError('No "users"-table, will not continue.');
return 1;

View File

@@ -25,9 +25,11 @@ declare(strict_types=1);
namespace FireflyIII\Console\Commands\Correction;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Models\AccountBalanceCalculator;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
@@ -47,7 +49,12 @@ class CorrectsUnevenAmount extends Command
public function handle(): int
{
$this->count = 0;
// convert transfers with foreign currency info where the amount is NOT uneven (it should be)
$this->convertOldStyleTransfers();
// convert old-style transactions between assets and liabilities.
$this->convertOldStyleTransactions();
$this->fixUnevenAmounts();
$this->matchCurrencies();
if (true === config('firefly.feature_flags.running_balance_column')) {
@@ -72,8 +79,6 @@ class CorrectsUnevenAmount extends Command
;
$count = 0;
Log::debug(sprintf('Found %d potential journal(s)', $transactions->count()));
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
/** @var null|TransactionJournal $journal */
@@ -115,10 +120,15 @@ class CorrectsUnevenAmount extends Command
++$count;
}
}
if (0 === $count) {
return;
}
$this->friendlyPositive(sprintf('Fixed %d transfer(s) with unbalanced amounts.', $count));
}
private function fixUnevenAmounts(): void
{
Log::debug('fixUnevenAmounts()');
$journals = DB::table('transactions')
->groupBy('transaction_journal_id')
->whereNull('deleted_at')
@@ -153,7 +163,7 @@ class CorrectsUnevenAmount extends Command
Log::error($e->getTraceAsString());
}
if (0 !== $res) {
$this->fixJournal($entry->transaction_journal_id);
$this->fixJournal((int) $entry->transaction_journal_id);
}
}
}
@@ -207,8 +217,8 @@ class CorrectsUnevenAmount extends Command
}
// may still be able to salvage this journal if it is a transfer with foreign currency info
if ($this->isForeignCurrencyTransfer($journal)) {
Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));
if ($this->isForeignCurrencyTransfer($journal) || $this->isBetweenAssetAndLiability($journal)) {
Log::debug(sprintf('Can skip foreign currency transfer / asset+liability transaction #%d.', $journal->id));
return;
}
@@ -271,13 +281,13 @@ class CorrectsUnevenAmount extends Command
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
if (!$this->isForeignCurrencyTransfer($journal)) {
if (!$this->isForeignCurrencyTransfer($journal) && !$this->isBetweenAssetAndLiability($journal)) {
Transaction::where('transaction_journal_id', $journal->id)->update(['transaction_currency_id' => $journal->transaction_currency_id]);
++$count;
continue;
}
Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));
Log::debug(sprintf('Can skip foreign currency transfer or transaction between asset and liability #%d.', $journal->id));
}
if (0 === $count) {
return;
@@ -285,4 +295,155 @@ class CorrectsUnevenAmount extends Command
$this->friendlyPositive(sprintf('Fixed %d journal(s) with mismatched currencies.', $journals->count()));
}
private function isBetweenAssetAndLiability(TransactionJournal $journal): bool
{
/** @var Transaction $sourceTransaction */
$sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
/** @var Transaction $destinationTransaction */
$destinationTransaction = $journal->transactions()->where('amount', '>', 0)->first();
if (null === $sourceTransaction || null === $destinationTransaction) {
Log::warning('Either transaction is false, stop.');
return false;
}
if (null === $sourceTransaction->foreign_amount || null === $destinationTransaction->foreign_amount) {
Log::warning('Either foreign amount is false, stop.');
return false;
}
$source = $sourceTransaction->account;
$destination = $destinationTransaction->account;
if (null === $source || null === $destination) {
Log::warning('Either is false, stop.');
return false;
}
$sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
// source is liability, destination is asset
if (in_array($source->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $destination->accountType->type) {
Log::debug('Source is a liability account, destination is an asset account, return TRUE.');
return true;
}
// source is asset, destination is liability
if (in_array($destination->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $source->accountType->type) {
Log::debug('Destination is a liability account, source is an asset account, return TRUE.');
return true;
}
return false;
}
private function convertOldStyleTransactions(): void
{
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
Log::debug('convertOldStyleTransactions()');
$count = 0;
$transactions = Transaction::distinct()
->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')
->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')
->leftJoin('accounts', 'accounts.id', 'transactions.account_id')
->leftJoin('account_types', 'account_types.id', 'accounts.account_type_id')
->whereNot('transaction_types.type', TransactionTypeEnum::TRANSFER->value)
->whereNotNull('foreign_currency_id')
->whereNotNull('foreign_amount')
->whereIn('account_types.type', [AccountTypeEnum::ASSET->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value, AccountTypeEnum::LOAN->value])
->get(['transactions.transaction_journal_id'])
;
/** @var Transaction $transaction */
foreach ($transactions as $transaction) {
/** @var null|TransactionJournal $journal */
$journal = TransactionJournal::find($transaction->transaction_journal_id);
$repository->setUser($journal->user);
if (null === $journal) {
Log::debug('Found no journal, continue.');
continue;
}
if (!$this->isBetweenAssetAndLiability($journal)) {
Log::debug('Not between asset and liability, continue.');
continue;
}
$source = $journal->transactions()->where('amount', '<', 0)->first();
$destination = $journal->transactions()->where('amount', '>', 0)->first();
$sourceAccount = $source->account;
$destAccount = $destination->account;
$sourceCurrency = $repository->getAccountCurrency($sourceAccount);
$destCurrency = $repository->getAccountCurrency($destAccount);
if (null === $source || null === $destination) {
Log::debug('Either transaction is NULL, continue.');
continue;
}
if (0 === bccomp($source->amount, $source->foreign_amount) && 0 === bccomp($source->foreign_amount, $source->amount)) {
Log::debug('Already fixed, continue.');
continue;
}
// source transaction. Switch info when does not match.
if ((int) $source->transaction_currency_id !== (int) $sourceCurrency->id) {
Log::debug(sprintf('Ready to swap data in transaction #%d.', $source->id));
// swap amounts.
$amount = $source->amount;
$currency = $source->transaction_currency_id;
$source->amount = $source->foreign_amount;
$source->transaction_currency_id = $source->foreign_currency_id;
$source->foreign_amount = $amount;
$source->foreign_currency_id = $currency;
$source->saveQuietly();
$source->refresh();
// Log::debug(sprintf('source->amount = %s', $source->amount));
// Log::debug(sprintf('source->transaction_currency_id = %s', $source->transaction_currency_id));
// Log::debug(sprintf('source->foreign_amount = %s', $source->foreign_amount));
// Log::debug(sprintf('source->foreign_currency_id = %s', $source->foreign_currency_id));
++$count;
}
// same but for destination
if ((int) $destination->transaction_currency_id !== (int) $destCurrency->id) {
++$count;
Log::debug(sprintf('Ready to swap data in transaction #%d.', $destination->id));
// swap amounts.
$amount = $destination->amount;
$currency = $destination->transaction_currency_id;
$destination->amount = $destination->foreign_amount;
$destination->transaction_currency_id = $destination->foreign_currency_id;
$destination->foreign_amount = $amount;
$destination->foreign_currency_id = $currency;
$destination->balance_dirty = true;
$destination->saveQuietly();
$destination->refresh();
// Log::debug(sprintf('destination->amount = %s', $destination->amount));
// Log::debug(sprintf('destination->transaction_currency_id = %s', $destination->transaction_currency_id));
// Log::debug(sprintf('destination->foreign_amount = %s', $destination->foreign_amount));
// Log::debug(sprintf('destination->foreign_currency_id = %s', $destination->foreign_currency_id));
}
// // only fix the destination transaction
// $destination->foreign_currency_id = $source->transaction_currency_id;
// $destination->foreign_amount = app('steam')->positive($source->amount);
// $destination->transaction_currency_id = $source->foreign_currency_id;
// $destination->amount = app('steam')->positive($source->foreign_amount);
// $destination->balance_dirty = true;
// $source->balance_dirty = true;
// $destination->save();
// $source->save();
// $this->friendlyWarning(sprintf('Corrected foreign amounts of transaction #%d.', $journal->id));
}
if (0 === $count) {
return;
}
$this->friendlyPositive(sprintf('Fixed %d journal(s) with unbalanced amounts.', $count));
}
}

View File

@@ -273,7 +273,7 @@ class ExportsData extends Command
*/
private function exportData(array $options, array $data): void
{
$date = \Safe\date('Y_m_d');
$date = date('Y_m_d');
foreach ($data as $key => $content) {
$file = sprintf('%s%s_%s.csv', $options['directory'], $date, $key);
if (false === $options['force'] && file_exists($file)) {

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Integrity;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Schema;
class ReportsIntegrity extends Command
{
@@ -41,7 +42,7 @@ class ReportsIntegrity extends Command
public function handle(): int
{
// if table does not exist, return false
if (!\Schema::hasTable('users')) {
if (!Schema::hasTable('users')) {
return 1;
}
$commands = [

View File

@@ -111,8 +111,8 @@ class OutputsInstructions extends Command
*/
private function showLogo(): void
{
$today = \Safe\date('m-d');
$month = \Safe\date('m');
$today = date('m-d');
$month = date('m');
// variation in colors and effects just because I can!
// default is Ukraine flag:
$colors = ['blue', 'blue', 'blue', 'yellow', 'yellow', 'yellow', 'default', 'default'];

View File

@@ -31,6 +31,7 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Journal\JournalCLIRepositoryInterface;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Schema;
class AddsTransactionIdentifiers extends Command
{
@@ -65,7 +66,7 @@ class AddsTransactionIdentifiers extends Command
}
// if table does not exist, return false
if (!\Schema::hasTable('transaction_journals')) {
if (!Schema::hasTable('transaction_journals')) {
return 0;
}

View File

@@ -28,7 +28,7 @@ use Illuminate\Support\Facades\Log;
use Safe\Exceptions\InfoException;
try {
set_time_limit(0);
\Safe\set_time_limit(0);
} catch (InfoException) {
Log::warning('set_time_limit returned false. This could be an issue, unless you also run XDebug.');
}

View File

@@ -366,8 +366,8 @@ class UpgradesToGroups extends Command
{
$groupId = DB::table('transaction_groups')->insertGetId(
[
'created_at' => \Safe\date('Y-m-d H:i:s'),
'updated_at' => \Safe\date('Y-m-d H:i:s'),
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
'title' => null,
'user_id' => $array['user_id'],
]

View File

@@ -45,6 +45,7 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
// temp
/**
* Class Handler
*/
@@ -227,7 +228,7 @@ class Handler extends ExceptionHandler
$data = [
'class' => $e::class,
'errorMessage' => $e->getMessage(),
'time' => \Safe\date('r'),
'time' => date('r'),
'stackTrace' => $e->getTraceAsString(),
'file' => $e->getFile(),
'line' => $e->getLine(),

View File

@@ -32,6 +32,7 @@ use FireflyIII\Models\TransactionJournal;
use FireflyIII\Rules\UniqueIban;
use FireflyIII\Services\Internal\Update\AccountUpdateService;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Validator;
/**
* Class TransactionFactory
@@ -152,7 +153,7 @@ class TransactionFactory
return;
}
// validate info:
$validator = \Validator::make(['iban' => $this->accountInformation['iban']], [
$validator = Validator::make(['iban' => $this->accountInformation['iban']], [
'iban' => ['required', new UniqueIban($this->account, $this->account->accountType->type)],
]);
if ($validator->fails()) {

View File

@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Factory;
use Carbon\Carbon;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\DuplicateTransactionException;
use FireflyIII\Exceptions\FireflyException;
@@ -101,15 +102,15 @@ class TransactionJournalFactory
*/
public function create(array $data): Collection
{
app('log')->debug('Now in TransactionJournalFactory::create()');
Log::debug('Now in TransactionJournalFactory::create()');
// convert to special object.
$dataObject = new NullArrayObject($data);
app('log')->debug('Start of TransactionJournalFactory::create()');
Log::debug('Start of TransactionJournalFactory::create()');
$collection = new Collection();
$transactions = $dataObject['transactions'] ?? [];
if (0 === count($transactions)) {
app('log')->error('There are no transactions in the array, the TransactionJournalFactory cannot continue.');
Log::error('There are no transactions in the array, the TransactionJournalFactory cannot continue.');
return new Collection();
}
@@ -117,26 +118,26 @@ class TransactionJournalFactory
try {
/** @var array $row */
foreach ($transactions as $index => $row) {
app('log')->debug(sprintf('Now creating journal %d/%d', $index + 1, count($transactions)));
Log::debug(sprintf('Now creating journal %d/%d', $index + 1, count($transactions)));
$journal = $this->createJournal(new NullArrayObject($row));
if (null !== $journal) {
$collection->push($journal);
}
if (null === $journal) {
app('log')->error('The createJournal() method returned NULL. This may indicate an error.');
Log::error('The createJournal() method returned NULL. This may indicate an error.');
}
}
} catch (DuplicateTransactionException $e) {
app('log')->warning('TransactionJournalFactory::create() caught a duplicate journal in createJournal()');
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::warning('TransactionJournalFactory::create() caught a duplicate journal in createJournal()');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
$this->forceDeleteOnError($collection);
throw new DuplicateTransactionException($e->getMessage(), 0, $e);
} catch (FireflyException $e) {
app('log')->warning('TransactionJournalFactory::create() caught an exception.');
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
Log::warning('TransactionJournalFactory::create() caught an exception.');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
$this->forceDeleteOnError($collection);
throw new FireflyException($e->getMessage(), 0, $e);
@@ -156,6 +157,7 @@ class TransactionJournalFactory
*/
private function createJournal(NullArrayObject $row): ?TransactionJournal
{
Log::debug('Now in TransactionJournalFactory::createJournal()');
$row['import_hash_v2'] = $this->hashArray($row);
$this->errorIfDuplicate($row['import_hash_v2']);
@@ -164,7 +166,11 @@ class TransactionJournalFactory
$type = $this->typeRepository->findTransactionType(null, $row['type']);
$carbon = $row['date'] ?? today(config('app.timezone'));
$order = $row['order'] ?? 0;
Log::debug('Find currency or return default.');
$currency = $this->currencyRepository->findCurrency((int) $row['currency_id'], $row['currency_code']);
Log::debug('Find foreign currency or return NULL.');
$foreignCurrency = $this->currencyRepository->findCurrencyNull($row['foreign_currency_id'], $row['foreign_currency_code']);
$bill = $this->billRepository->findBill((int) $row['bill_id'], $row['bill_name']);
$billId = TransactionTypeEnum::WITHDRAWAL->value === $type->type && null !== $bill ? $bill->id : null;
@@ -183,8 +189,8 @@ class TransactionJournalFactory
// validate source and destination using a new Validator.
$this->validateAccounts($row);
} catch (FireflyException $e) {
app('log')->error('Could not validate source or destination.');
app('log')->error($e->getMessage());
Log::error('Could not validate source or destination.');
Log::error($e->getMessage());
return null;
}
@@ -207,11 +213,12 @@ class TransactionJournalFactory
'bic' => $row['destination_bic'],
'currency_id' => $currency->id,
];
app('log')->debug('Source info:', $sourceInfo);
app('log')->debug('Destination info:', $destInfo);
Log::debug('Source info:', $sourceInfo);
Log::debug('Destination info:', $destInfo);
$sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
$destinationAccount = $this->getAccount($type->type, 'destination', $destInfo);
app('log')->debug('Done with getAccount(2x)');
Log::debug('Done with getAccount(2x)');
// this is the moment for a reconciliation sanity check (again).
if (TransactionTypeEnum::RECONCILIATION->value === $type->type) {
@@ -223,7 +230,8 @@ class TransactionJournalFactory
$foreignCurrency = $this->getForeignByAccount($type->type, $foreignCurrency, $destinationAccount);
$description = $this->getDescription($description);
app('log')->debug(sprintf('Date: %s (%s)', $carbon->toW3cString(), $carbon->getTimezone()->getName()));
Log::debug(sprintf('Currency is #%d "%s", foreign currency is #%d "%s"', $currency->id, $currency->code, $foreignCurrency?->id, $foreignCurrency));
Log::debug(sprintf('Date: %s (%s)', $carbon->toW3cString(), $carbon->getTimezone()->getName()));
/** Create a basic journal. */
$journal = TransactionJournal::create(
@@ -241,7 +249,7 @@ class TransactionJournalFactory
'completed' => 0,
]
);
app('log')->debug(sprintf('Created new journal #%d: "%s"', $journal->id, $journal->description));
Log::debug(sprintf('Created new journal #%d: "%s"', $journal->id, $journal->description));
/** Create two transactions. */
$transactionFactory = app(TransactionFactory::class);
@@ -255,7 +263,7 @@ class TransactionJournalFactory
try {
$negative = $transactionFactory->createNegative((string) $row['amount'], (string) $row['foreign_amount']);
} catch (FireflyException $e) {
app('log')->error(sprintf('Exception creating negative transaction: %s', $e->getMessage()));
Log::error(sprintf('Exception creating negative transaction: %s', $e->getMessage()));
$this->forceDeleteOnError(new Collection([$journal]));
throw new FireflyException($e->getMessage(), 0, $e);
@@ -277,7 +285,7 @@ class TransactionJournalFactory
$amount = (string) $row['amount'];
$foreignAmount = (string) $row['foreign_amount'];
if (null !== $foreignCurrency && $foreignCurrency->id !== $currency->id
&& TransactionTypeEnum::TRANSFER->value === $type->type
&& (TransactionTypeEnum::TRANSFER->value === $type->type || $this->isBetweenAssetAndLiability($sourceAccount, $destinationAccount))
) {
$transactionFactory->setCurrency($foreignCurrency);
$transactionFactory->setForeignCurrency($currency);
@@ -289,7 +297,7 @@ class TransactionJournalFactory
try {
$transactionFactory->createPositive($amount, $foreignAmount);
} catch (FireflyException $e) {
app('log')->error(sprintf('Exception creating positive transaction: %s', $e->getMessage()));
Log::error(sprintf('Exception creating positive transaction: %s', $e->getMessage()));
$this->forceTrDelete($negative);
$this->forceDeleteOnError(new Collection([$journal]));
@@ -317,11 +325,11 @@ class TransactionJournalFactory
try {
$json = \Safe\json_encode($dataRow, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
app('log')->error(sprintf('Could not encode dataRow: %s', $e->getMessage()));
Log::error(sprintf('Could not encode dataRow: %s', $e->getMessage()));
$json = microtime();
}
$hash = hash('sha256', $json);
app('log')->debug(sprintf('The hash is: %s', $hash), $dataRow);
Log::debug(sprintf('The hash is: %s', $hash), $dataRow);
return $hash;
}
@@ -333,11 +341,11 @@ class TransactionJournalFactory
*/
private function errorIfDuplicate(string $hash): void
{
app('log')->debug(sprintf('In errorIfDuplicate(%s)', $hash));
Log::debug(sprintf('In errorIfDuplicate(%s)', $hash));
if (false === $this->errorOnHash) {
return;
}
app('log')->debug('Will verify duplicate!');
Log::debug('Will verify duplicate!');
/** @var null|TransactionJournalMeta $result */
$result = TransactionJournalMeta::withTrashed()
@@ -349,7 +357,7 @@ class TransactionJournalFactory
->first(['journal_meta.*'])
;
if (null !== $result) {
app('log')->warning(sprintf('Found a duplicate in errorIfDuplicate because hash %s is not unique!', $hash));
Log::warning(sprintf('Found a duplicate in errorIfDuplicate because hash %s is not unique!', $hash));
$journal = $result->transactionJournal()->withTrashed()->first();
$group = $journal?->transactionGroup()->withTrashed()->first();
$groupId = (int) $group?->id;
@@ -363,7 +371,7 @@ class TransactionJournalFactory
*/
private function validateAccounts(NullArrayObject $data): void
{
app('log')->debug(sprintf('Now in %s', __METHOD__));
Log::debug(sprintf('Now in %s', __METHOD__));
$transactionType = $data['type'] ?? 'invalid';
$this->accountValidator->setUser($this->user);
$this->accountValidator->setTransactionType($transactionType);
@@ -381,7 +389,7 @@ class TransactionJournalFactory
if (false === $validSource) {
throw new FireflyException(sprintf('Source: %s', $this->accountValidator->sourceError));
}
app('log')->debug('Source seems valid.');
Log::debug('Source seems valid.');
// validate destination account
$array = [
@@ -416,28 +424,28 @@ class TransactionJournalFactory
private function reconciliationSanityCheck(?Account $sourceAccount, ?Account $destinationAccount): array
{
app('log')->debug(sprintf('Now in %s', __METHOD__));
Log::debug(sprintf('Now in %s', __METHOD__));
if (null !== $sourceAccount && null !== $destinationAccount) {
app('log')->debug('Both accounts exist, simply return them.');
Log::debug('Both accounts exist, simply return them.');
return [$sourceAccount, $destinationAccount];
}
if (null === $destinationAccount) {
app('log')->debug('Destination account is NULL, source account is not.');
Log::debug('Destination account is NULL, source account is not.');
$account = $this->accountRepository->getReconciliation($sourceAccount);
app('log')->debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type));
Log::debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type));
return [$sourceAccount, $account];
}
if (null === $sourceAccount) { // @phpstan-ignore-line
app('log')->debug('Source account is NULL, destination account is not.');
Log::debug('Source account is NULL, destination account is not.');
$account = $this->accountRepository->getReconciliation($destinationAccount);
app('log')->debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type));
Log::debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type));
return [$account, $destinationAccount];
}
app('log')->debug('Unused fallback'); // @phpstan-ignore-line
Log::debug('Unused fallback'); // @phpstan-ignore-line
return [$sourceAccount, $destinationAccount];
}
@@ -447,7 +455,15 @@ class TransactionJournalFactory
*/
private function getCurrencyByAccount(string $type, ?TransactionCurrency $currency, Account $source, Account $destination): TransactionCurrency
{
app('log')->debug('Now in getCurrencyByAccount()');
Log::debug('Now in getCurrencyByAccount()');
/*
* Deze functie moet bij een transactie van liability naar asset wel degelijk de currency
* van de liability teruggeven en niet die van de destination. Fix voor #10265
*/
if ($this->isBetweenAssetAndLiability($source, $destination) && TransactionTypeEnum::DEPOSIT->value === $type) {
return $this->getCurrency($currency, $source);
}
return match ($type) {
default => $this->getCurrency($currency, $source),
@@ -460,7 +476,7 @@ class TransactionJournalFactory
*/
private function getCurrency(?TransactionCurrency $currency, Account $account): TransactionCurrency
{
app('log')->debug('Now in getCurrency()');
Log::debug(sprintf('Now in getCurrency(#%d, "%s")', $currency?->id, $account->name));
/** @var null|TransactionCurrency $preference */
$preference = $this->accountRepository->getAccountCurrency($account);
@@ -469,7 +485,7 @@ class TransactionJournalFactory
return app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
}
$result = $preference ?? $currency;
app('log')->debug(sprintf('Currency is now #%d (%s) because of account #%d (%s)', $result->id, $result->code, $account->id, $account->name));
Log::debug(sprintf('Currency is now #%d (%s) because of account #%d (%s)', $result->id, $result->code, $account->id, $account->name));
return $result;
}
@@ -479,6 +495,7 @@ class TransactionJournalFactory
*/
private function compareCurrencies(?TransactionCurrency $currency, ?TransactionCurrency $foreignCurrency): ?TransactionCurrency
{
Log::debug(sprintf('Now in compareCurrencies("%s", "%s")', $currency?->code, $foreignCurrency?->code));
if (null === $currency) {
return null;
}
@@ -494,6 +511,7 @@ class TransactionJournalFactory
*/
private function getForeignByAccount(string $type, ?TransactionCurrency $foreignCurrency, Account $destination): ?TransactionCurrency
{
Log::debug(sprintf('Now in getForeignByAccount("%s", #%d, "%s")', $type, $foreignCurrency?->id, $destination->name));
if (TransactionTypeEnum::TRANSFER->value === $type) {
return $this->getCurrency($foreignCurrency, $destination);
}
@@ -514,12 +532,12 @@ class TransactionJournalFactory
*/
private function forceDeleteOnError(Collection $collection): void
{
app('log')->debug(sprintf('forceDeleteOnError on collection size %d item(s)', $collection->count()));
Log::debug(sprintf('forceDeleteOnError on collection size %d item(s)', $collection->count()));
$service = app(JournalDestroyService::class);
/** @var TransactionJournal $journal */
foreach ($collection as $journal) {
app('log')->debug(sprintf('forceDeleteOnError on journal #%d', $journal->id));
Log::debug(sprintf('forceDeleteOnError on journal #%d', $journal->id));
$service->destroy($journal);
}
}
@@ -534,17 +552,17 @@ class TransactionJournalFactory
*/
private function storePiggyEvent(TransactionJournal $journal, NullArrayObject $data): void
{
app('log')->debug('Will now store piggy event.');
Log::debug('Will now store piggy event.');
$piggyBank = $this->piggyRepository->findPiggyBank((int) $data['piggy_bank_id'], $data['piggy_bank_name']);
if (null !== $piggyBank) {
$this->piggyEventFactory->create($journal, $piggyBank);
app('log')->debug('Create piggy event.');
Log::debug('Create piggy event.');
return;
}
app('log')->debug('Create no piggy event');
Log::debug('Create no piggy event');
}
private function storeMetaFields(TransactionJournal $journal, NullArrayObject $transaction): void
@@ -563,11 +581,11 @@ class TransactionJournalFactory
];
if ($data[$field] instanceof Carbon) {
$data[$field]->setTimezone(config('app.timezone'));
app('log')->debug(sprintf('%s Date: %s (%s)', $field, $data[$field], $data[$field]->timezone->getName()));
Log::debug(sprintf('%s Date: %s (%s)', $field, $data[$field], $data[$field]->timezone->getName()));
$set['data'] = $data[$field]->format('Y-m-d H:i:s');
}
app('log')->debug(sprintf('Going to store meta-field "%s", with value "%s".', $set['name'], $set['data']));
Log::debug(sprintf('Going to store meta-field "%s", with value "%s".', $set['name'], $set['data']));
/** @var TransactionJournalMetaFactory $factory */
$factory = app(TransactionJournalMetaFactory::class);
@@ -590,7 +608,7 @@ class TransactionJournalFactory
{
$this->errorOnHash = $errorOnHash;
if (true === $errorOnHash) {
app('log')->info('Will trigger duplication alert for this journal.');
Log::info('Will trigger duplication alert for this journal.');
}
}
@@ -605,4 +623,25 @@ class TransactionJournalFactory
$this->piggyRepository->setUserGroup($userGroup);
$this->accountRepository->setUserGroup($userGroup);
}
private function isBetweenAssetAndLiability(Account $source, Account $destination): bool
{
$sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
// source is liability, destination is asset
if (in_array($source->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $destination->accountType->type) {
Log::debug('Source is a liability account, destination is an asset account, return TRUE.');
return true;
}
// source is asset, destination is liability
if (in_array($destination->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $source->accountType->type) {
Log::debug('Destination is a liability account, source is an asset account, return TRUE.');
return true;
}
Log::debug('Not between asset and liability, return FALSE');
return false;
}
}

View File

@@ -54,8 +54,8 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\User;
use Illuminate\Auth\Events\Login;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Notification;
use Mail;
/**
* Class UserEventHandler.
@@ -266,7 +266,7 @@ class UserEventHandler
$url = route('profile.confirm-email-change', [$token->data]);
try {
\Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $url));
Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $url));
} catch (\Exception $e) {
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
@@ -291,7 +291,7 @@ class UserEventHandler
$url = route('profile.undo-email-change', [$token->data, $hashed]);
try {
\Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $url));
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $url));
} catch (\Exception $e) {
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());
@@ -355,7 +355,7 @@ class UserEventHandler
$url = route('invite', [$event->invitee->invite_code]);
try {
\Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url));
Mail::to($invitee)->send(new InvitationMail($invitee, $admin, $url));
} catch (\Exception $e) {
app('log')->error($e->getMessage());
app('log')->error($e->getTraceAsString());

View File

@@ -73,7 +73,7 @@ class VersionCheckEventHandler
$diff = $now - $lastCheckTime->data;
Log::debug(sprintf('Last check time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
if ($diff < 604800) {
Log::debug(sprintf('Checked for updates less than a week ago (on %s).', \Safe\date('Y-m-d H:i:s', $lastCheckTime->data)));
Log::debug(sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
return;
}
@@ -105,7 +105,7 @@ class VersionCheckEventHandler
$diff = $now - $lastCheckTime->data;
Log::debug(sprintf('Last warning time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
if ($diff < 604800 * 4) {
Log::debug(sprintf('Warned about updates less than four weeks ago (on %s).', \Safe\date('Y-m-d H:i:s', $lastCheckTime->data)));
Log::debug(sprintf('Warned about updates less than four weeks ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
return;
}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Account;
use FireflyIII\Models\Location;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\AccountFormRequest;
@@ -87,11 +88,11 @@ class EditController extends Controller
$roles = $this->getRoles();
$liabilityTypes = $this->getLiabilityTypes();
$location = $repository->getLocation($account);
$latitude = null !== $location ? $location->latitude : config('firefly.default_location.latitude');
$longitude = null !== $location ? $location->longitude : config('firefly.default_location.longitude');
$zoomLevel = null !== $location ? $location->zoom_level : config('firefly.default_location.zoom_level');
$latitude = $location instanceof Location ? $location->latitude : config('firefly.default_location.latitude');
$longitude = $location instanceof Location ? $location->longitude : config('firefly.default_location.longitude');
$zoomLevel = $location instanceof Location ? $location->zoom_level : config('firefly.default_location.zoom_level');
$canEditCurrency = 0 === $account->piggyBanks()->count();
$hasLocation = null !== $location;
$hasLocation = $location instanceof Location;
$locations = [
'location' => [
'latitude' => old('location_latitude') ?? $latitude,

View File

@@ -163,7 +163,9 @@ class IndexController extends Controller
/** @var Carbon $end */
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
$start->subDay();
// 2025-05-11 removed this so start is exactly the start of the month.
// $start->subDay();
$ids = $accounts->pluck('id')->toArray();
Log::debug(sprintf('index start: finalAccountsBalance("%s")', $start->format('Y-m-d H:i:s')));

View File

@@ -94,7 +94,7 @@ class ReconcileController extends Controller
// get start and end
if (null === $start && null === $end) {
if (!$start instanceof Carbon && !$end instanceof Carbon) {
/** @var Carbon $start */
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon(), $range));

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Admin;
use Carbon\Carbon;
use FireflyIII\Helpers\Update\UpdateTrait;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
@@ -96,7 +97,7 @@ class UpdateController extends Controller
$channel = in_array($channel, ['stable', 'beta', 'alpha'], true) ? $channel : 'stable';
app('fireflyconfig')->set('permission_update_check', $checkForUpdates);
app('fireflyconfig')->set('last_update_check', time());
app('fireflyconfig')->set('last_update_check', Carbon::now()->getTimestamp());
app('fireflyconfig')->set('update_channel', $channel);
session()->flash('success', (string) trans('firefly.configuration_updated'));

View File

@@ -34,6 +34,8 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\View\View;
use function Safe\parse_url;
/**
* Class ForgotPasswordController
*/
@@ -101,7 +103,7 @@ class ForgotPasswordController extends Controller
*/
private function validateHost(): void
{
$configuredHost = \Safe\parse_url((string) config('app.url'), PHP_URL_HOST);
$configuredHost = parse_url((string) config('app.url'), PHP_URL_HOST);
if (false === $configuredHost || null === $configuredHost) {
throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.');
}

View File

@@ -23,7 +23,9 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth;
use Cookie;
use Carbon\Carbon;
use FireflyIII\User;
use Illuminate\Support\Facades\Cookie;
use FireflyIII\Events\ActuallyLoggedIn;
use FireflyIII\Events\Security\UnknownUserAttemptedLogin;
use FireflyIII\Events\Security\UserAttemptedLogin;
@@ -44,6 +46,7 @@ use Illuminate\Routing\Redirector;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\ValidationException;
use Symfony\Component\HttpFoundation\Response as ResponseAlias;
/**
* Class LoginController
@@ -130,11 +133,11 @@ class LoginController extends Controller
app('log')->warning('Login attempt failed.');
$username = (string) $request->get($this->username());
$user = $this->repository->findByEmail($username);
if (null === $user) {
if (!$user instanceof User) {
// send event to owner.
event(new UnknownUserAttemptedLogin($username));
}
if (null !== $user) {
if ($user instanceof User) {
event(new UserAttemptedLogin($user));
}
@@ -198,7 +201,7 @@ class LoginController extends Controller
// also logout current 2FA tokens.
$cookieName = config('google2fa.cookie_name', 'google2fa_token');
\Cookie::forget($cookieName);
Cookie::forget($cookieName);
$this->guard()->logout();
@@ -209,7 +212,7 @@ class LoginController extends Controller
$this->loggedOut($request);
return $request->wantsJson()
? new Response('', 204)
? new Response('', ResponseAlias::HTTP_NO_CONTENT)
: redirect('/');
}
@@ -220,7 +223,7 @@ class LoginController extends Controller
*
* @throws FireflyException
*/
public function showLoginForm(Request $request)
public function showLoginForm(?Request $request = null)
{
Log::channel('audit')->info('Show login form (1.1).');
@@ -246,13 +249,13 @@ class LoginController extends Controller
$allowReset = false;
}
$email = $request->old('email');
$remember = $request->old('remember');
$email = $request?->old('email');
$remember = $request?->old('remember');
$storeInCookie = config('google2fa.store_in_cookie', false);
if (false !== $storeInCookie) {
$cookieName = config('google2fa.cookie_name', 'google2fa_token');
\Cookie::queue(\Cookie::make($cookieName, 'invalid-'.time()));
Cookie::queue(Cookie::make($cookieName, 'invalid-'.Carbon::now()->getTimestamp()));
}
$usernameField = $this->username();

View File

@@ -130,7 +130,7 @@ class RegisterController extends Controller
$allowRegistration = false;
}
if ('web' !== $guard) {
$allowRegistration = false;
return false;
}
return $allowRegistration;
@@ -175,7 +175,7 @@ class RegisterController extends Controller
*
* @throws FireflyException
*/
public function showRegistrationForm(Request $request)
public function showRegistrationForm(?Request $request = null)
{
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
$pageTitle = (string) trans('firefly.register_page_title');
@@ -187,7 +187,7 @@ class RegisterController extends Controller
return view('error', compact('message'));
}
$email = $request->old('email');
$email = $request?->old('email');
return view('auth.register', compact('isDemoSite', 'email', 'pageTitle'));
}

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Auth;
use Carbon\Carbon;
use FireflyIII\Events\Security\MFABackupFewLeft;
use FireflyIII\Events\Security\MFABackupNoLeft;
use FireflyIII\Events\Security\MFAManyFailedAttempts;
@@ -129,7 +130,7 @@ class TwoFactorController extends Controller
*/
private function inMFAHistory(string $mfaCode, array $mfaHistory): bool
{
$now = time();
$now = Carbon::now()->getTimestamp();
foreach ($mfaHistory as $entry) {
$time = $entry['time'];
$code = $entry['code'];
@@ -149,7 +150,7 @@ class TwoFactorController extends Controller
/** @var array $mfaHistory */
$mfaHistory = app('preferences')->get('mfa_history', [])->data;
$newHistory = [];
$now = time();
$now = Carbon::now()->getTimestamp();
foreach ($mfaHistory as $entry) {
$time = $entry['time'];
$code = $entry['code'];
@@ -184,7 +185,7 @@ class TwoFactorController extends Controller
/** @var array $mfaHistory */
$mfaHistory = app('preferences')->get('mfa_history', [])->data;
$entry = [
'time' => time(),
'time' => Carbon::now()->getTimestamp(),
'code' => $mfaCode,
];
$mfaHistory[] = $entry;

View File

@@ -143,13 +143,13 @@ class BudgetLimitController extends Controller
// first search for existing one and update it if necessary.
$currency = $this->currencyRepos->find((int) $request->get('transaction_currency_id'));
$budget = $this->repository->find((int) $request->get('budget_id'));
if (null === $currency || null === $budget) {
if (!$currency instanceof TransactionCurrency || !$budget instanceof Budget) {
throw new FireflyException('No valid currency or budget.');
}
$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
if (null === $start || null === $end) {
if (!$start instanceof Carbon || !$end instanceof Carbon) {
return response()->json([]);
}
@@ -167,7 +167,7 @@ class BudgetLimitController extends Controller
// sanity check on amount:
if (0 === bccomp($amount, '0')) {
if (null !== $limit) {
if ($limit instanceof BudgetLimit) {
$this->blRepository->destroyBudgetLimit($limit);
}
@@ -181,11 +181,11 @@ class BudgetLimitController extends Controller
$amount = bcmul($amount, '-1');
}
if (null !== $limit) {
if ($limit instanceof BudgetLimit) {
$limit->amount = $amount;
$limit->save();
}
if (null === $limit) {
if (!$limit instanceof BudgetLimit) {
$limit = $this->blRepository->store(
[
'budget_id' => $request->get('budget_id'),

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Budget;
use FireflyIII\Models\AutoBudget;
use FireflyIII\Enums\AutoBudgetType;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Controllers\Controller;
@@ -95,7 +96,7 @@ class EditController extends Controller
'active' => $hasOldInput ? (bool) $request->old('active') : $budget->active,
'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $this->defaultCurrency->id,
];
if (null !== $autoBudget) {
if ($autoBudget instanceof AutoBudget) {
$amount = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount;
if (is_array($amount)) {
$amount = '0';

View File

@@ -316,7 +316,7 @@ class IndexController extends Controller
foreach ($budgetIds as $index => $budgetId) {
$budgetId = (int) $budgetId;
$budget = $repository->find($budgetId);
if (null !== $budget) {
if ($budget instanceof Budget) {
app('log')->debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1));
$repository->setBudgetOrder($budget, $index + 1);
}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Budget;
use FireflyIII\Models\TransactionJournal;
use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException;
@@ -90,7 +91,7 @@ class ShowController extends Controller
// get first journal ever to set off the budget period overview.
$first = $this->journalRepos->firstNull();
$firstDate = null !== $first ? $first->date : $start;
$firstDate = $first instanceof TransactionJournal ? $first->date : $start;
$periods = $this->getNoBudgetPeriodOverview($firstDate, $end);
$page = (int) $request->get('page');
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
@@ -115,7 +116,7 @@ class ShowController extends Controller
{
$subTitle = (string) trans('firefly.all_journals_without_budget');
$first = $this->journalRepos->firstNull();
$start = null === $first ? new Carbon() : $first->date;
$start = $first instanceof TransactionJournal ? $first->date : new Carbon();
$end = today(config('app.timezone'));
$page = (int) $request->get('page');
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Category;
use FireflyIII\Models\TransactionJournal;
use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Exceptions\FireflyException;
@@ -119,7 +120,7 @@ class NoCategoryController extends Controller
app('log')->debug('Start of noCategory()');
$subTitle = (string) trans('firefly.all_journals_without_category');
$first = $this->journalRepos->firstNull();
$start = null === $first ? new Carbon() : $first->date;
$start = $first instanceof TransactionJournal ? $first->date : new Carbon();
$end = today(config('app.timezone'));
app('log')->debug(sprintf('Start for noCategory() is %s', $start->format('Y-m-d')));
app('log')->debug(sprintf('End for noCategory() is %s', $end->format('Y-m-d')));

View File

@@ -43,6 +43,8 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use function Safe\json_encode;
/**
* Class AccountController.
*/
@@ -468,14 +470,14 @@ class AccountController extends Controller
Log::debug('Balances exist at:');
foreach ($range as $key => $value) {
$newRange[] = ['date' => $key, 'info' => $value];
Log::debug(sprintf('%d - %s (%s)', count($newRange) - 1, $key, \Safe\json_encode($value)));
Log::debug(sprintf('%d - %s (%s)', count($newRange) - 1, $key, json_encode($value)));
}
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[0]['date'])->endOfDay();
Log::debug(sprintf('Start of loop, $carbon is %s', $carbon->format('Y-m-d H:i:s')));
while ($end->gte($current)) {
$momentBalance = $previous;
// $theDate = $current->format('Y-m-d');
Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), \Safe\json_encode($momentBalance)));
Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), json_encode($momentBalance)));
// loop over the array with balances, find one that is earlier or on the same day.
while ($carbon->lte($current) && array_key_exists($expectedIndex, $newRange)) {
@@ -490,7 +492,7 @@ class AccountController extends Controller
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[$expectedIndex]['date'])->endOfDay();
}
}
Log::debug(sprintf('momentBalance is now %s', \Safe\json_encode($momentBalance)));
Log::debug(sprintf('momentBalance is now %s', json_encode($momentBalance)));
$return = $this->updateChartKeys($return, $momentBalance);
$previous = $momentBalance;

View File

@@ -202,7 +202,7 @@ class BudgetController extends Controller
{
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
$budgetLimitId = $budgetLimit instanceof BudgetLimit ? $budgetLimit->id : 0;
$cache = new CacheProperties();
$cache->addProperty($budget->id);
$cache->addProperty($this->convertToNative);
@@ -211,7 +211,7 @@ class BudgetController extends Controller
$start = session('first', today(config('app.timezone'))->startOfYear());
$end = today();
if (null !== $budgetLimit) {
if ($budgetLimit instanceof BudgetLimit) {
$start = $budgetLimit->start_date;
$end = $budgetLimit->end_date;
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date)->setNormalCurrency($budgetLimit->transactionCurrency);
@@ -285,7 +285,7 @@ class BudgetController extends Controller
{
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
$budgetLimitId = $budgetLimit instanceof BudgetLimit ? $budgetLimit->id : 0;
$cache = new CacheProperties();
$cache->addProperty($budget->id);
$cache->addProperty($this->convertToNative);
@@ -293,7 +293,7 @@ class BudgetController extends Controller
$cache->addProperty('chart.budget.expense-category');
$start = session('first', today(config('app.timezone'))->startOfYear());
$end = today();
if (null !== $budgetLimit) {
if ($budgetLimit instanceof BudgetLimit) {
$start = $budgetLimit->start_date;
$end = $budgetLimit->end_date;
$collector->setNormalCurrency($budgetLimit->transactionCurrency);
@@ -367,7 +367,7 @@ class BudgetController extends Controller
{
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$budgetLimitId = null === $budgetLimit ? 0 : $budgetLimit->id;
$budgetLimitId = $budgetLimit instanceof BudgetLimit ? $budgetLimit->id : 0;
$cache = new CacheProperties();
$cache->addProperty($budget->id);
$cache->addProperty($budgetLimitId);
@@ -375,7 +375,7 @@ class BudgetController extends Controller
$cache->addProperty('chart.budget.expense-expense');
$start = session('first', today(config('app.timezone'))->startOfYear());
$end = today();
if (null !== $budgetLimit) {
if ($budgetLimit instanceof BudgetLimit) {
$start = $budgetLimit->start_date;
$end = $budgetLimit->end_date;
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date)->setNormalCurrency($budgetLimit->transactionCurrency);
@@ -529,7 +529,7 @@ class BudgetController extends Controller
// get budget limit in this period for this currency.
$limit = $this->blRepository->find($budget, $currency, $currentStart, $currentEnd);
if (null !== $limit) {
if ($limit instanceof BudgetLimit) {
$chartData[1]['entries'][$title] = app('steam')->bcround($limit->amount, $currency->decimal_places);
}

View File

@@ -159,7 +159,7 @@ class CategoryController extends Controller
$income = [];
$expenses = [];
$categoryId = 0;
if (null === $category) {
if (!$category instanceof Category) {
/** @var NoCategoryRepositoryInterface $noCatRepository */
$noCatRepository = app(NoCategoryRepositoryInterface::class);
@@ -168,7 +168,7 @@ class CategoryController extends Controller
$income = $noCatRepository->listIncome($start, $end, $accounts);
}
if (null !== $category) {
if ($category instanceof Category) {
/** @var OperationsRepositoryInterface $opsRepository */
$opsRepository = app(OperationsRepositoryInterface::class);
$categoryId = $category->id;

View File

@@ -23,6 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use function Safe\realpath;
use function Safe\ini_get;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Facades\Steam;
@@ -34,7 +36,7 @@ use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;
use Route;
use Illuminate\Support\Facades\Route;
/**
* Class Controller.
@@ -83,15 +85,15 @@ abstract class Controller extends BaseController
if ('true' === request()->get('force_default_layout') && 'v2' === config('view.layout')) {
//config('view.layout','v1');
Config::set('view.layout', 'v1');
View::getFinder()->setPaths([\Safe\realpath(base_path('resources/views'))]); // @phpstan-ignore-line
View::getFinder()->setPaths([realpath(base_path('resources/views'))]); // @phpstan-ignore-line
}
View::share('authGuard', $authGuard);
View::share('logoutUrl', $logoutUrl);
// upload size
$maxFileSize = Steam::phpBytes((string) \Safe\ini_get('upload_max_filesize'));
$maxPostSize = Steam::phpBytes((string) \Safe\ini_get('post_max_size'));
$maxFileSize = Steam::phpBytes((string) ini_get('upload_max_filesize'));
$maxPostSize = Steam::phpBytes((string) ini_get('post_max_size'));
$uploadSize = min($maxFileSize, $maxPostSize);
View::share('uploadSize', $uploadSize);

View File

@@ -50,6 +50,9 @@ use Illuminate\View\View;
use Monolog\Handler\RotatingFileHandler;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use function Safe\file_get_contents;
use function Safe\ini_get;
/**
* Class DebugController
*/
@@ -139,7 +142,7 @@ class DebugController extends Controller
if ($handler instanceof RotatingFileHandler) {
$logFile = $handler->getUrl();
if (null !== $logFile && file_exists($logFile)) {
$logContent = \Safe\file_get_contents($logFile);
$logContent = file_get_contents($logFile);
}
}
}
@@ -164,8 +167,8 @@ class DebugController extends Controller
private function getSystemInformation(): array
{
$maxFileSize = Steam::phpBytes((string) \Safe\ini_get('upload_max_filesize'));
$maxPostSize = Steam::phpBytes((string) \Safe\ini_get('post_max_size'));
$maxFileSize = Steam::phpBytes((string) ini_get('upload_max_filesize'));
$maxPostSize = Steam::phpBytes((string) ini_get('post_max_size'));
$drivers = DB::availableDrivers();
$currentDriver = DB::getDriverName();
@@ -177,8 +180,8 @@ class DebugController extends Controller
'interface' => \PHP_SAPI,
'bits' => \PHP_INT_SIZE * 8,
'bcscale' => bcscale(),
'display_errors' => \Safe\ini_get('display_errors'),
'error_reporting' => $this->errorReporting((int) \Safe\ini_get('error_reporting')),
'display_errors' => ini_get('display_errors'),
'error_reporting' => $this->errorReporting((int) ini_get('error_reporting')),
'upload_size' => min($maxFileSize, $maxPostSize),
'all_drivers' => $drivers,
'current_driver' => $currentDriver,
@@ -197,7 +200,7 @@ class DebugController extends Controller
try {
if (file_exists('/var/www/counter-main.txt')) {
$return['build'] = trim((string) \Safe\file_get_contents('/var/www/counter-main.txt'));
$return['build'] = trim((string) file_get_contents('/var/www/counter-main.txt'));
app('log')->debug(sprintf('build is now "%s"', $return['build']));
}
} catch (\Exception $e) {
@@ -207,7 +210,7 @@ class DebugController extends Controller
try {
if (file_exists('/var/www/build-date-main.txt')) {
$return['build_date'] = trim((string) \Safe\file_get_contents('/var/www/build-date-main.txt'));
$return['build_date'] = trim((string) file_get_contents('/var/www/build-date-main.txt'));
}
} catch (\Exception $e) {
app('log')->debug('Could not check build date, but thats ok.');

View File

@@ -24,6 +24,8 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Export;
use Carbon\Carbon;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser;
@@ -84,14 +86,14 @@ class IndexController extends Controller
$firstDate = today(config('app.timezone'));
$firstDate->subYear();
$journal = $this->journalRepository->firstNull();
if (null !== $journal) {
if ($journal instanceof TransactionJournal) {
Log::debug('First journal is NULL, using today() - 1 year.');
$firstDate = clone $journal->date;
}
$generator->setStart($firstDate);
$result = $generator->export();
$name = sprintf('%s_transaction_export.csv', \Safe\date('Y_m_d'));
$name = sprintf('%s_transaction_export.csv', Carbon::now()->format('Y_m_d'));
$quoted = sprintf('"%s"', addcslashes($name, '"\\'));
// headers for CSV file.

View File

@@ -96,7 +96,7 @@ class JavascriptController extends Controller
{
$account = $repository->find((int) $request->get('account'));
$currency = $this->defaultCurrency;
if (null !== $account) {
if ($account instanceof Account) {
$currency = $repository->getAccountCurrency($account) ?? $this->defaultCurrency;
}
$locale = app('steam')->getLocale();

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Json;
use FireflyIII\Models\AvailableBudget;
use Carbon\Carbon;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\TransactionCurrency;
@@ -72,7 +73,7 @@ class BudgetController extends Controller
$available = '0';
$percentage = '0';
if (null !== $availableBudget) {
if ($availableBudget instanceof AvailableBudget) {
$available = $availableBudget->amount;
if (0 !== bccomp($available, '0')) {
$percentage = bcmul(bcdiv($budgeted, $available), '100');

View File

@@ -77,7 +77,7 @@ class ReconcileController extends Controller
$amount = '0';
$clearedAmount = '0';
if (null === $start && null === $end) {
if (!$start instanceof Carbon && !$end instanceof Carbon) {
throw new FireflyException('Invalid dates submitted.');
}
if ($end->lt($start)) {
@@ -183,7 +183,7 @@ class ReconcileController extends Controller
*/
public function transactions(Account $account, ?Carbon $start = null, ?Carbon $end = null)
{
if (null === $start || null === $end) {
if (!$start instanceof Carbon || !$end instanceof Carbon) {
throw new FireflyException('Invalid dates submitted.');
}
if ($end->lt($start)) {

View File

@@ -82,12 +82,12 @@ class RecurrenceController extends Controller
$skip = $skip < 0 || $skip > 31 ? 0 : $skip;
$weekend = $weekend < 1 || $weekend > 4 ? 1 : $weekend;
if (null === $endDate) {
if (!$endDate instanceof Carbon) {
// safety catch:
$endDate = now()->addYear();
}
if (null === $start || null === $end || null === $firstDate) {
if (!$start instanceof Carbon || !$end instanceof Carbon || !$firstDate instanceof Carbon) {
return response()->json();
}
@@ -153,7 +153,7 @@ class RecurrenceController extends Controller
*/
public function suggest(Request $request): JsonResponse
{
$string = '' === (string) $request->get('date') ? \Safe\date('Y-m-d') : (string) $request->get('date');
$string = '' === (string) $request->get('date') ? Carbon::now()->format('Y-m-d') : (string) $request->get('date');
$today = today(config('app.timezone'))->startOfDay();
try {
@@ -161,7 +161,7 @@ class RecurrenceController extends Controller
} catch (InvalidFormatException) {
$date = Carbon::today(config('app.timezone'));
}
if (null === $date) {
if (!$date instanceof Carbon) {
return response()->json();
}
$date->startOfDay();

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Requests\NewUserFormRequest;
@@ -101,7 +102,7 @@ class NewUserController extends Controller
$currency = $currencyRepository->find((int) $request->input('amount_currency_id_bank_balance'));
// if is null, set to EUR:
if (null === $currency) {
if (!$currency instanceof TransactionCurrency) {
$currency = $currencyRepository->findByCode('EUR');
}
$currencyRepository->enable($currency);

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use Carbon\Carbon;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Events\Preferences\UserGroupChangedDefaultCurrency;
use FireflyIII\Events\Test\UserTestNotificationChannel;
@@ -40,6 +41,10 @@ use Illuminate\Routing\Redirector;
use Illuminate\Support\Facades\Log;
use Illuminate\View\View;
use function Safe\json_decode;
use function Safe\file_get_contents;
use function Safe\strtotime;
/**
* Class PreferencesController.
*/
@@ -110,7 +115,7 @@ class PreferencesController extends Controller
if (is_array($fiscalYearStartStr)) {
$fiscalYearStartStr = '01-01';
}
$fiscalYearStart = sprintf('%s-%s', \Safe\date('Y'), (string) $fiscalYearStartStr);
$fiscalYearStart = sprintf('%s-%s', Carbon::now()->format('Y'), (string) $fiscalYearStartStr);
$tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$availableDarkModes = config('firefly.available_dark_modes');
@@ -149,7 +154,7 @@ class PreferencesController extends Controller
// list of locales also has "equal" which makes it equal to whatever the language is.
try {
$locales = \Safe\json_decode((string) \Safe\file_get_contents(resource_path(sprintf('locales/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR);
$locales = json_decode((string) file_get_contents(resource_path(sprintf('locales/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
app('log')->error($e->getMessage());
$locales = [];
@@ -271,9 +276,9 @@ class PreferencesController extends Controller
// custom fiscal year
$customFiscalYear = 1 === (int) $request->get('customFiscalYear');
$string = \Safe\strtotime((string) $request->get('fiscalYearStart'));
$string = strtotime((string) $request->get('fiscalYearStart'));
if (false !== $string) {
$fiscalYearStart = \Safe\date('m-d', $string);
$fiscalYearStart = Carbon::createFromTimestamp($string)->format('m-d');
Preferences::set('customFiscalYear', $customFiscalYear);
Preferences::set('fiscalYearStart', $fiscalYearStart);
}

View File

@@ -24,6 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Profile;
use Illuminate\Support\Facades\Cookie;
use PragmaRX\Google2FALaravel\Facade as Google2FA;
use Carbon\Carbon;
use FireflyIII\Events\Security\DisabledMFA;
use FireflyIII\Events\Security\EnabledMFA;
use FireflyIII\Events\Security\MFANewBackupCodes;
@@ -181,7 +184,7 @@ class MfaController extends Controller
// also logout current 2FA tokens.
$cookieName = config('google2fa.cookie_name', 'google2fa_token');
\Cookie::forget($cookieName);
Cookie::forget($cookieName);
// send user notification.
Log::channel('audit')->info(sprintf('User "%s" has disabled MFA', $user->email));
@@ -214,8 +217,8 @@ class MfaController extends Controller
}
$domain = $this->getDomain();
$secret = \Google2FA::generateSecretKey();
$image = \Google2FA::getQRCodeInline($domain, auth()->user()->email, $secret);
$secret = Google2FA::generateSecretKey();
$image = Google2FA::getQRCodeInline($domain, auth()->user()->email, $secret);
app('preferences')->set('temp-mfa-secret', $secret);
@@ -271,7 +274,7 @@ class MfaController extends Controller
// make sure MFA is logged out.
if ('testing' !== config('app.env')) {
\Google2FA::logout();
Google2FA::logout();
}
// drop all info from session:
@@ -294,7 +297,7 @@ class MfaController extends Controller
/** @var array $mfaHistory */
$mfaHistory = app('preferences')->get('mfa_history', [])->data;
$entry = [
'time' => time(),
'time' => Carbon::now()->getTimestamp(),
'code' => $mfaCode,
];
$mfaHistory[] = $entry;
@@ -311,7 +314,7 @@ class MfaController extends Controller
/** @var array $mfaHistory */
$mfaHistory = app('preferences')->get('mfa_history', [])->data;
$newHistory = [];
$now = time();
$now = Carbon::now()->getTimestamp();
foreach ($mfaHistory as $entry) {
$time = $entry['time'];
$code = $entry['code'];

View File

@@ -23,6 +23,8 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use FireflyIII\Events\UserChangedEmail;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Exceptions\ValidationException;
@@ -154,7 +156,8 @@ class ProfileController extends Controller
if (0 === $count) {
/** @var ClientRepository $repository */
$repository = app(ClientRepository::class);
$repository->createPersonalAccessClient(null, config('app.name').' Personal Access Client', 'http://localhost');
$name = sprintf('%s Personal Access Grant Client', config('app.name'));
$repository->createPersonalAccessClient(null, $name, 'http://localhost');
}
$accessToken = app('preferences')->get('access_token');
@@ -201,9 +204,9 @@ class ProfileController extends Controller
return redirect(route('profile.change-email'))->withInput();
}
$existing = $repository->findByEmail($newEmail);
if (null !== $existing) {
if ($existing instanceof User) {
// force user logout.
\Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
$request->session()->invalidate();
session()->flash('success', (string) trans('firefly.email_changed'));
@@ -217,7 +220,7 @@ class ProfileController extends Controller
event(new UserChangedEmail($user, $newEmail, $oldEmail));
// force user logout.
\Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)
$request->session()->invalidate();
session()->flash('success', (string) trans('firefly.email_changed'));
@@ -310,7 +313,7 @@ class ProfileController extends Controller
return redirect(route('profile.index'));
}
if (!\Hash::check($request->get('password'), auth()->user()->password)) {
if (!Hash::check($request->get('password'), auth()->user()->password)) {
session()->flash('error', (string) trans('firefly.invalid_password'));
return redirect(route('profile.delete-account'));
@@ -343,8 +346,8 @@ class ProfileController extends Controller
'email' => auth()->user()->email,
'password' => $request->get('password'),
];
if (\Auth::once($creds)) {
\Auth::logoutOtherDevices($request->get('password'));
if (Auth::once($creds)) {
Auth::logoutOtherDevices($request->get('password'));
session()->flash('info', (string) trans('firefly.other_sessions_logged_out'));
return redirect(route('profile.index'));

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Rule;
use FireflyIII\Models\Rule;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\RuleFormRequest;
@@ -128,7 +129,7 @@ class CreateController extends Controller
// title depends on whether or not there is a rule group:
$subTitle = (string) trans('firefly.make_new_rule_no_group');
if (null !== $ruleGroup) {
if ($ruleGroup instanceof RuleGroup) {
$subTitle = (string) trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
}
@@ -252,7 +253,7 @@ class CreateController extends Controller
{
$ruleId = (int) $request->get('id');
$rule = $this->ruleRepos->find($ruleId);
if (null !== $rule) {
if ($rule instanceof Rule) {
$this->ruleRepos->duplicate($rule);
}

View File

@@ -91,7 +91,7 @@ class EditController extends Controller
{
$groupId = (int) $request->get('id');
$ruleGroup = $this->repository->find($groupId);
if (null !== $ruleGroup) {
if ($ruleGroup instanceof RuleGroup) {
$direction = $request->get('direction');
if ('down' === $direction) {
$maxOrder = $this->repository->maxOrder();

View File

@@ -24,7 +24,8 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\System;
use Cache;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Cache;
use Exception;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
@@ -36,6 +37,8 @@ use Illuminate\View\View;
use Laravel\Passport\Passport;
use phpseclib3\Crypt\RSA;
use function Safe\file_put_contents;
/**
* Class InstallController
*/
@@ -140,14 +143,14 @@ class InstallController extends Controller
$this->keys();
}
if ('generate-keys' !== $command) {
\Artisan::call($command, $args);
app('log')->debug(\Artisan::output());
Artisan::call($command, $args);
app('log')->debug(Artisan::output());
}
} catch (\Exception $e) { // intentional generic exception
throw new FireflyException($e->getMessage(), 0, $e);
}
// clear cache as well.
\Cache::clear();
Cache::clear();
app('preferences')->mark();
return true;
@@ -169,7 +172,7 @@ class InstallController extends Controller
return;
}
\Safe\file_put_contents($publicKey, (string) $key->getPublicKey());
\Safe\file_put_contents($privateKey, $key->toString('PKCS1'));
file_put_contents($publicKey, (string) $key->getPublicKey());
file_put_contents($privateKey, $key->toString('PKCS1'));
}
}

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers;
use FireflyIII\Models\Location;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
@@ -124,10 +125,10 @@ class TagController extends Controller
$subTitleIcon = 'fa-tag';
$location = $this->repository->getLocation($tag);
$latitude = null !== $location ? $location->latitude : config('firefly.default_location.latitude');
$longitude = null !== $location ? $location->longitude : config('firefly.default_location.longitude');
$zoomLevel = null !== $location ? $location->zoom_level : config('firefly.default_location.zoom_level');
$hasLocation = null !== $location;
$latitude = $location instanceof Location ? $location->latitude : config('firefly.default_location.latitude');
$longitude = $location instanceof Location ? $location->longitude : config('firefly.default_location.longitude');
$zoomLevel = $location instanceof Location ? $location->zoom_level : config('firefly.default_location.zoom_level');
$hasLocation = $location instanceof Location;
$locations = [
'location' => [
'latitude' => old('location_latitude') ?? $latitude,
@@ -155,8 +156,8 @@ class TagController extends Controller
{
// start with oldest tag
$first = session('first', today()) ?? today();
$oldestTagDate = null === $repository->oldestTag() ? clone $first : $repository->oldestTag()->date;
$newestTagDate = null === $repository->newestTag() ? today() : $repository->newestTag()->date;
$oldestTagDate = $repository->oldestTag() instanceof Tag ? $repository->oldestTag()->date : clone $first;
$newestTagDate = $repository->newestTag() instanceof Tag ? $repository->newestTag()->date : today();
$oldestTagDate->startOfYear();
$newestTagDate->endOfYear();
$tags = [];
@@ -184,7 +185,7 @@ class TagController extends Controller
foreach ($tags as $tagId) {
$tagId = (int) $tagId;
$tag = $this->repository->find($tagId);
if (null !== $tag) {
if ($tag instanceof Tag) {
$this->repository->destroy($tag);
++$count;
}

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction;
use FireflyIII\Models\TransactionCurrency;
use Exception;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Enums\TransactionTypeEnum;
@@ -342,7 +343,7 @@ class ConvertController extends Controller
$sourceCurrency = $this->accountRepository->getAccountCurrency($source);
$dest = $this->accountRepository->find((int) $destinationId);
$destCurrency = $this->accountRepository->getAccountCurrency($dest);
if (null !== $sourceCurrency && null !== $destCurrency && $sourceCurrency->code !== $destCurrency->code) {
if ($sourceCurrency instanceof TransactionCurrency && $destCurrency instanceof TransactionCurrency && $sourceCurrency->code !== $destCurrency->code) {
$update['currency_id'] = $sourceCurrency->id;
$update['foreign_currency_id'] = $destCurrency->id;
$update['foreign_amount'] = '1'; // not the best solution but at this point the amount is hard to get.

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction;
use FireflyIII\Models\TransactionGroup;
use FireflyIII\Events\StoredTransactionGroup;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
@@ -35,6 +36,8 @@ use Illuminate\Contracts\View\View;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use function Safe\parse_url;
/**
* Class CreateController
*/
@@ -65,7 +68,7 @@ class CreateController extends Controller
$groupId = (int) $request->get('id');
if (0 !== $groupId) {
$group = $this->repository->find($groupId);
if (null !== $group) {
if ($group instanceof TransactionGroup) {
/** @var GroupCloneService $service */
$service = app(GroupCloneService::class);
$newGroup = $service->cloneGroup($group);
@@ -116,7 +119,7 @@ class CreateController extends Controller
$accountToTypes = config('firefly.account_to_transaction');
$defaultCurrency = $this->defaultCurrency;
$previousUrl = $this->rememberPreviousUrl('transactions.create.url');
$parts = \Safe\parse_url($previousUrl);
$parts = parse_url((string) $previousUrl);
$search = sprintf('?%s', $parts['query'] ?? '');
$previousUrl = str_replace($search, '', $previousUrl);
if (!is_array($optionalFields)) {

View File

@@ -35,6 +35,8 @@ use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Redirector;
use Illuminate\View\View;
use function Safe\parse_url;
/**
* Class EditController
*/
@@ -85,7 +87,7 @@ class EditController extends Controller
$defaultCurrency = $this->defaultCurrency;
$cash = $repository->getCashAccount();
$previousUrl = $this->rememberPreviousUrl('transactions.edit.url');
$parts = \Safe\parse_url($previousUrl);
$parts = parse_url((string) $previousUrl);
$search = sprintf('?%s', $parts['query'] ?? '');
$previousUrl = str_replace($search, '', $previousUrl);

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Transaction;
use FireflyIII\Models\TransactionJournal;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
@@ -81,14 +82,14 @@ class IndexController extends Controller
$page = (int) $request->get('page');
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
if (null === $start) {
if (!$start instanceof Carbon) {
$start = session('start');
$end = session('end');
}
if (null === $end) {
// get last transaction ever?
$last = $this->repository->getLast();
$end = null !== $last ? $last->date : session('end');
$end = $last instanceof TransactionJournal ? $last->date : session('end');
}
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
@@ -97,7 +98,7 @@ class IndexController extends Controller
$subTitle = (string) trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
$path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
$firstJournal = $this->repository->firstNull();
$startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;
$startPeriod = $firstJournal instanceof TransactionJournal ? $firstJournal->date : new Carbon();
$endPeriod = clone $end;
$periods = $this->getTransactionPeriodOverview($objectType, $startPeriod, $endPeriod);
@@ -132,9 +133,9 @@ class IndexController extends Controller
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
$path = route('transactions.index.all', [$objectType]);
$first = $this->repository->firstNull();
$start = null === $first ? new Carbon() : $first->date;
$start = $first instanceof TransactionJournal ? $first->date : new Carbon();
$last = $this->repository->getLast();
$end = null !== $last ? $last->date : today(config('app.timezone'));
$end = $last instanceof TransactionJournal ? $last->date : today(config('app.timezone'));
$subTitle = (string) trans('firefly.all_'.$objectType);
/** @var GroupCollectorInterface $collector */

View File

@@ -113,7 +113,7 @@ class LinkController extends Controller
app('log')->debug('We are here (store)');
$other = $this->journalRepository->find($linkInfo['transaction_journal_id']);
if (null === $other) {
if (!$other instanceof TransactionJournal) {
session()->flash('error', (string) trans('firefly.invalid_link_selection'));
return redirect(route('transactions.show', [$journal->transaction_group_id]));

View File

@@ -191,7 +191,7 @@ class MassController extends Controller
private function updateJournal(int $journalId, MassEditJournalRequest $request): void
{
$journal = $this->repository->find($journalId);
if (null === $journal) {
if (!$journal instanceof TransactionJournal) {
throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId));
}
$service = app(JournalUpdateService::class);

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\TransactionCurrency;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Requests\CurrencyFormRequest;
@@ -122,7 +123,7 @@ class CreateController extends Controller
}
$redirect = redirect($this->getPreviousUrl('currencies.create.url'));
if (null !== $currency) {
if ($currency instanceof TransactionCurrency) {
$request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name]));
Log::channel('audit')->info('Created (POST) currency.', $data);
if (1 === (int) $request->get('create_another')) {

View File

@@ -29,6 +29,8 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use function Safe\preg_match;
class AcceptHeaders
{
/**
@@ -71,7 +73,7 @@ class AcceptHeaders
// throw bad request if trace id is not a UUID
$uuid = $request->header('X-Trace-Id');
if (is_string($uuid) && '' !== trim($uuid) && (1 !== \Safe\preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) {
if (is_string($uuid) && '' !== trim($uuid) && (1 !== preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) {
throw new BadRequestHttpException('Bad X-Trace-Id header.');
}

View File

@@ -114,10 +114,10 @@ class Authenticate
*/
private function validateBlockedUser(?User $user, array $guards): void
{
if (null === $user) {
if (!$user instanceof User) {
app('log')->warning('User is null, throw exception?');
}
if (null !== $user) {
if ($user instanceof User) {
// app('log')->debug(get_class($user));
if (1 === (int) $user->blocked) {
$message = (string) trans('firefly.block_account_logout');

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Middleware;
use Illuminate\Support\Facades\App;
use Carbon\Carbon;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\Facades\Amount;
@@ -101,7 +102,7 @@ class Range
// get locale preference:
$language = app('steam')->getLanguage();
$locale = app('steam')->getLocale();
\App::setLocale($language);
App::setLocale($language);
Carbon::setLocale(substr((string) $locale, 0, 2));
$localeArray = app('steam')->getLocaleArray($locale);

View File

@@ -70,7 +70,7 @@ class CurrencyFormRequest extends FormRequest
$currency = $this->route()->parameter('currency');
if (null !== $currency) {
$rules = [
return [
'name' => 'required|max:48|min:1',
'code' => 'required|min:3|max:51',
'symbol' => 'required|min:1|max:51',

View File

@@ -36,6 +36,8 @@ use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Validation\Validator;
use function Safe\preg_match;
/**
* Class CategoryFormRequest.
*/
@@ -143,7 +145,7 @@ class ReportFormRequest extends FormRequest
// validate as date
// if regex for YYYY-MM-DD:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
$result = \Safe\preg_match($pattern, $string);
$result = preg_match($pattern, $string);
if (false !== $result && 0 !== $result) {
try {
$date = new Carbon($parts[1]);
@@ -181,7 +183,7 @@ class ReportFormRequest extends FormRequest
// validate as date
// if regex for YYYY-MM-DD:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
$result = \Safe\preg_match($pattern, $string);
$result = preg_match($pattern, $string);
if (false !== $result && 0 !== $result) {
try {
$date = new Carbon($parts[0]);

View File

@@ -28,6 +28,7 @@ use Illuminate\Mail\Message;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Symfony\Component\Mailer\Exception\TransportException;
/**
@@ -70,7 +71,7 @@ class MailError extends Job implements ShouldQueue
if ($this->attempts() < 3 && '' !== $email) {
try {
\Mail::send(
Mail::send(
['emails.error-html', 'emails.error-text'],
$args,
static function (Message $message) use ($email): void {

View File

@@ -50,30 +50,36 @@ class ReturnsAvailableChannels
private static function returnOwnerChannels(): array
{
$channels = ['mail'];
$slackUrl = app('fireflyconfig')->getEncrypted('slack_webhook_url', '')->data;
if (UrlValidator::isValidWebhookURL($slackUrl)) {
$channels[] = 'slack';
$channels = ['mail'];
if (true === config('notifications.channels.slack.enabled', false)) {
$slackUrl = app('fireflyconfig')->getEncrypted('slack_webhook_url', '')->data;
if (UrlValidator::isValidWebhookURL($slackUrl)) {
$channels[] = 'slack';
}
}
// validate presence of of Ntfy settings.
if ('' !== (string) app('fireflyconfig')->getEncrypted('ntfy_topic', '')->data) {
Log::debug('Enabled ntfy.');
$channels[] = NtfyChannel::class;
}
if ('' === (string) app('fireflyconfig')->getEncrypted('ntfy_topic', '')->data) {
Log::warning('No topic name for Ntfy, channel is disabled.');
if (true === config('notifications.channels.ntfy.enabled', false)) {
// validate presence of of Ntfy settings.
if ('' !== (string) app('fireflyconfig')->getEncrypted('ntfy_topic', '')->data) {
Log::debug('Enabled ntfy.');
$channels[] = NtfyChannel::class;
}
if ('' === (string) app('fireflyconfig')->getEncrypted('ntfy_topic', '')->data) {
Log::warning('No topic name for Ntfy, channel is disabled.');
}
}
// pushover
$pushoverAppToken = (string) app('fireflyconfig')->getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string) app('fireflyconfig')->getEncrypted('pushover_user_token', '')->data;
if ('' === $pushoverAppToken || '' === $pushoverUserToken) {
Log::warning('[b] No Pushover token, channel is disabled.');
}
if ('' !== $pushoverAppToken && '' !== $pushoverUserToken) {
Log::debug('Enabled pushover.');
$channels[] = PushoverChannel::class;
if (true === config('notifications.channels.pushover.enabled', false)) {
$pushoverAppToken = (string) app('fireflyconfig')->getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string) app('fireflyconfig')->getEncrypted('pushover_user_token', '')->data;
if ('' === $pushoverAppToken || '' === $pushoverUserToken) {
Log::warning('[b] No Pushover token, channel is disabled.');
}
if ('' !== $pushoverAppToken && '' !== $pushoverUserToken) {
Log::debug('Enabled pushover.');
$channels[] = PushoverChannel::class;
}
}
Log::debug(sprintf('Final channel set in ReturnsAvailableChannels: %s ', implode(', ', $channels)));
@@ -84,31 +90,38 @@ class ReturnsAvailableChannels
private static function returnUserChannels(User $user): array
{
Log::debug(sprintf('Checking channels for user #%d', $user->id));
$channels = ['mail'];
$slackUrl = (string) app('preferences')->getEncryptedForUser($user, 'slack_webhook_url', '')->data;
if (UrlValidator::isValidWebhookURL($slackUrl)) {
$channels[] = 'slack';
$channels = ['mail'];
if (true === config('notifications.channels.slack.enabled', false)) {
$slackUrl = (string) app('preferences')->getEncryptedForUser($user, 'slack_webhook_url', '')->data;
if (UrlValidator::isValidWebhookURL($slackUrl)) {
$channels[] = 'slack';
}
}
// validate presence of of Ntfy settings.
$ntfyTopic = (string) app('preferences')->getEncryptedForUser($user, 'ntfy_topic', '')->data;
if ('' !== $ntfyTopic) {
Log::debug(sprintf('Enabled ntfy, "%s"', $ntfyTopic));
$channels[] = NtfyChannel::class;
}
if ('' === (string) app('preferences')->getEncryptedForUser($user, 'ntfy_topic', '')->data) {
Log::warning('No topic name for Ntfy, channel is disabled.');
if (true === config('notifications.channels.nfy.enabled', false)) {
$ntfyTopic = (string) app('preferences')->getEncryptedForUser($user, 'ntfy_topic', '')->data;
if ('' !== $ntfyTopic) {
Log::debug(sprintf('Enabled ntfy, "%s"', $ntfyTopic));
$channels[] = NtfyChannel::class;
}
if ('' === (string) app('preferences')->getEncryptedForUser($user, 'ntfy_topic', '')->data) {
Log::warning('No topic name for Ntfy, channel is disabled.');
}
}
// pushover
$pushoverAppToken = (string) app('preferences')->getEncryptedForUser($user, 'pushover_app_token', '')->data;
$pushoverUserToken = (string) app('preferences')->getEncryptedForUser($user, 'pushover_user_token', '')->data;
if ('' === $pushoverAppToken || '' === $pushoverUserToken) {
Log::warning('[b] No Pushover token, channel is disabled.');
}
if ('' !== $pushoverAppToken && '' !== $pushoverUserToken) {
Log::debug('Enabled pushover.');
$channels[] = PushoverChannel::class;
if (true === config('notifications.channels.slack.enabled', false)) {
$pushoverAppToken = (string) app('preferences')->getEncryptedForUser($user, 'pushover_app_token', '')->data;
$pushoverUserToken = (string) app('preferences')->getEncryptedForUser($user, 'pushover_user_token', '')->data;
if ('' === $pushoverAppToken || '' === $pushoverUserToken) {
Log::warning('[b] No Pushover token, channel is disabled.');
}
if ('' !== $pushoverAppToken && '' !== $pushoverUserToken) {
Log::debug('Enabled pushover.');
$channels[] = PushoverChannel::class;
}
}
Log::debug(sprintf('Final channel set in ReturnsAvailableChannels (user): %s ', implode(', ', $channels)));

View File

@@ -41,6 +41,7 @@ class AppServiceProvider extends ServiceProvider
public function boot(): void
{
Schema::defaultStringLength(191);
// Passport::$clientUuids = false;
Response::macro('api', function (array $value) {
$headers = [
'Cache-Control' => 'no-store',
@@ -58,7 +59,7 @@ class AppServiceProvider extends ServiceProvider
// blade extension
Blade::directive('activeXRoutePartial', function (string $route) {
$name = \Route::getCurrentRoute()->getName() ?? '';
$name = Route::getCurrentRoute()->getName() ?? '';
if (str_contains($name, $route)) {
return 'menu-open';
}

View File

@@ -133,7 +133,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
return $searchResult;
}
}
app('log')->debug('Found nothing');
app('log')->debug('Found no bill in findBill()');
return null;
}

View File

@@ -65,17 +65,17 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
*/
public function currencyInUseAt(TransactionCurrency $currency): ?string
{
app('log')->debug(sprintf('Now in currencyInUse() for #%d ("%s")', $currency->id, $currency->code));
Log::debug(sprintf('Now in currencyInUse() for #%d ("%s")', $currency->id, $currency->code));
$countJournals = $this->countJournals($currency);
if ($countJournals > 0) {
app('log')->info(sprintf('Count journals is %d, return true.', $countJournals));
Log::info(sprintf('Count journals is %d, return true.', $countJournals));
return 'journals';
}
// is the only currency left
if (1 === $this->getAll()->count()) {
app('log')->info('Is the last currency in the system, return true. ');
Log::info('Is the last currency in the system, return true. ');
return 'last_left';
}
@@ -83,7 +83,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
// is being used in accounts:
$meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((string) $currency->id))->count();
if ($meta > 0) {
app('log')->info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
return 'account_meta';
}
@@ -91,7 +91,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
// second search using integer check.
$meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((int) $currency->id))->count();
if ($meta > 0) {
app('log')->info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
return 'account_meta';
}
@@ -99,7 +99,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
// is being used in bills:
$bills = Bill::where('transaction_currency_id', $currency->id)->count();
if ($bills > 0) {
app('log')->info(sprintf('Used in %d bills as currency, return true. ', $bills));
Log::info(sprintf('Used in %d bills as currency, return true. ', $bills));
return 'bills';
}
@@ -109,7 +109,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
$recurringForeign = RecurrenceTransaction::where('foreign_currency_id', $currency->id)->count();
if ($recurringAmount > 0 || $recurringForeign > 0) {
app('log')->info(sprintf('Used in %d recurring transactions as (foreign) currency id, return true. ', $recurringAmount + $recurringForeign));
Log::info(sprintf('Used in %d recurring transactions as (foreign) currency id, return true. ', $recurringAmount + $recurringForeign));
return 'recurring';
}
@@ -120,7 +120,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
->where('account_meta.name', 'currency_id')->where('account_meta.data', \Safe\json_encode($currency->id))->count()
;
if ($meta > 0) {
app('log')->info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
return 'account_meta';
}
@@ -128,7 +128,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
// is being used in available budgets
$availableBudgets = AvailableBudget::where('transaction_currency_id', $currency->id)->count();
if ($availableBudgets > 0) {
app('log')->info(sprintf('Used in %d available budgets as currency, return true. ', $availableBudgets));
Log::info(sprintf('Used in %d available budgets as currency, return true. ', $availableBudgets));
return 'available_budgets';
}
@@ -136,7 +136,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
// is being used in budget limits
$budgetLimit = BudgetLimit::where('transaction_currency_id', $currency->id)->count();
if ($budgetLimit > 0) {
app('log')->info(sprintf('Used in %d budget limits as currency, return true. ', $budgetLimit));
Log::info(sprintf('Used in %d budget limits as currency, return true. ', $budgetLimit));
return 'budget_limits';
}
@@ -144,7 +144,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
// is the default currency for the user or the system
$count = $this->userGroup->currencies()->where('transaction_currencies.id', $currency->id)->wherePivot('group_default', 1)->count();
if ($count > 0) {
app('log')->info('Is the default currency of the user, return true.');
Log::info('Is the default currency of the user, return true.');
return 'current_default';
}
@@ -152,12 +152,12 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
// is the default currency for the user or the system
$count = $this->userGroup->currencies()->where('transaction_currencies.id', $currency->id)->wherePivot('group_default', 1)->count();
if ($count > 0) {
app('log')->info('Is the default currency of the user group, return true.');
Log::info('Is the default currency of the user group, return true.');
return 'current_default';
}
app('log')->debug('Currency is not used, return false.');
Log::debug('Currency is not used, return false.');
return null;
}
@@ -237,15 +237,15 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
$result = $this->findCurrencyNull($currencyId, $currencyCode);
if (null === $result) {
app('log')->debug('Grabbing default currency for this user...');
Log::debug('Grabbing default currency for this user...');
/** @var null|TransactionCurrency $result */
$result = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
}
app('log')->debug(sprintf('Final result: %s', $result->code));
Log::debug(sprintf('Final result: %s', $result->code));
if (false === $result->enabled) {
app('log')->debug(sprintf('Also enabled currency %s', $result->code));
Log::debug(sprintf('Also enabled currency %s', $result->code));
$this->enable($result);
}
@@ -257,16 +257,22 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
*/
public function findCurrencyNull(?int $currencyId, ?string $currencyCode): ?TransactionCurrency
{
app('log')->debug('Now in findCurrencyNull()');
Log::debug(sprintf('Now in findCurrencyNull(%s, "%s")', var_export($currencyId, true), $currencyCode));
$result = $this->find((int) $currencyId);
if (null !== $result) {
Log::debug(sprintf('Found currency by ID: %s', $result->code));
return $result;
}
if (null === $result) {
app('log')->debug(sprintf('Searching for currency with code %s...', $currencyCode));
Log::debug(sprintf('Searching for currency with code "%s"...', $currencyCode));
$result = $this->findByCode((string) $currencyCode);
}
if (null !== $result && false === $result->enabled) {
app('log')->debug(sprintf('Also enabled currency %s', $result->code));
Log::debug(sprintf('Also enabled currency %s', $result->code));
$this->enable($result);
}
Log::debug('Found no currency, returning NULL.');
return $result;
}
@@ -321,7 +327,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
->where('date', $date->format('Y-m-d'))->first()
;
if (null !== $rate) {
app('log')->debug(sprintf('Found cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d')));
Log::debug(sprintf('Found cached exchange rate in database for %s to %s on %s', $fromCurrency->code, $toCurrency->code, $date->format('Y-m-d')));
return $rate;
}
@@ -380,7 +386,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
public function update(TransactionCurrency $currency, array $data): TransactionCurrency
{
app('log')->debug('Now in update()');
Log::debug('Now in update()');
// can be true, false, null
$enabled = array_key_exists('enabled', $data) ? $data['enabled'] : null;
// can be true, false, but method only responds to "true".
@@ -396,12 +402,12 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
// currency is enabled, must be disabled.
if (false === $enabled) {
app('log')->debug(sprintf('Disabled currency %s for user #%d', $currency->code, $this->userGroup->id));
Log::debug(sprintf('Disabled currency %s for user #%d', $currency->code, $this->userGroup->id));
$this->userGroup->currencies()->detach($currency->id);
}
// currency must be enabled
if (true === $enabled) {
app('log')->debug(sprintf('Enabled currency %s for user #%d', $currency->code, $this->userGroup->id));
Log::debug(sprintf('Enabled currency %s for user #%d', $currency->code, $this->userGroup->id));
$this->userGroup->currencies()->detach($currency->id);
$this->userGroup->currencies()->syncWithoutDetaching([$currency->id => ['group_default' => false]]);
}
@@ -420,7 +426,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
public function makeDefault(TransactionCurrency $currency): void
{
$current = app('amount')->getNativeCurrencyByUserGroup($this->userGroup);
app('log')->debug(sprintf('Enabled + made default currency %s for user #%d', $currency->code, $this->userGroup->id));
Log::debug(sprintf('Enabled + made default currency %s for user #%d', $currency->code, $this->userGroup->id));
$this->userGroup->currencies()->detach($currency->id);
foreach ($this->userGroup->currencies()->get() as $item) {
$this->userGroup->currencies()->updateExistingPivot($item->id, ['group_default' => false]);

View File

@@ -82,7 +82,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
return $searchResult;
}
}
app('log')->debug('Found nothing');
app('log')->debug('Found no piggy bank.');
return null;
}

View File

@@ -54,7 +54,7 @@ class UserRepository implements UserRepositoryInterface
// save old email as pref
app('preferences')->setForUser($user, 'previous_email_latest', $oldEmail);
app('preferences')->setForUser($user, 'previous_email_'.\Safe\date('Y-m-d-H-i-s'), $oldEmail);
app('preferences')->setForUser($user, 'previous_email_'.date('Y-m-d-H-i-s'), $oldEmail);
// set undo and confirm token:
app('preferences')->setForUser($user, 'email_change_undo_token', bin2hex(random_bytes(16)));
@@ -389,7 +389,7 @@ class UserRepository implements UserRepositoryInterface
// save old email as pref
app('preferences')->setForUser($user, 'admin_previous_email_latest', $oldEmail);
app('preferences')->setForUser($user, 'admin_previous_email_'.\Safe\date('Y-m-d-H-i-s'), $oldEmail);
app('preferences')->setForUser($user, 'admin_previous_email_'.date('Y-m-d-H-i-s'), $oldEmail);
$user->email = $newEmail;
$user->save();

View File

@@ -65,17 +65,17 @@ class CurrencyRepository implements CurrencyRepositoryInterface
*/
public function currencyInUseAt(TransactionCurrency $currency): ?string
{
app('log')->debug(sprintf('Now in currencyInUse() for #%d ("%s")', $currency->id, $currency->code));
Log::debug(sprintf('Now in currencyInUse() for #%d ("%s")', $currency->id, $currency->code));
$countJournals = $this->countJournals($currency);
if ($countJournals > 0) {
app('log')->info(sprintf('Count journals is %d, return true.', $countJournals));
Log::info(sprintf('Count journals is %d, return true.', $countJournals));
return 'journals';
}
// is the only currency left
if (1 === $this->getAll()->count()) {
app('log')->info('Is the last currency in the system, return true. ');
Log::info('Is the last currency in the system, return true. ');
return 'last_left';
}
@@ -83,7 +83,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// is being used in accounts:
$meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((string) $currency->id))->count();
if ($meta > 0) {
app('log')->info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
return 'account_meta';
}
@@ -91,7 +91,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// second search using integer check.
$meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((int) $currency->id))->count();
if ($meta > 0) {
app('log')->info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
return 'account_meta';
}
@@ -99,7 +99,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// is being used in bills:
$bills = Bill::where('transaction_currency_id', $currency->id)->count();
if ($bills > 0) {
app('log')->info(sprintf('Used in %d bills as currency, return true. ', $bills));
Log::info(sprintf('Used in %d bills as currency, return true. ', $bills));
return 'bills';
}
@@ -109,7 +109,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
$recurringForeign = RecurrenceTransaction::where('foreign_currency_id', $currency->id)->count();
if ($recurringAmount > 0 || $recurringForeign > 0) {
app('log')->info(sprintf('Used in %d recurring transactions as (foreign) currency id, return true. ', $recurringAmount + $recurringForeign));
Log::info(sprintf('Used in %d recurring transactions as (foreign) currency id, return true. ', $recurringAmount + $recurringForeign));
return 'recurring';
}
@@ -120,7 +120,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
->where('account_meta.name', 'currency_id')->where('account_meta.data', \Safe\json_encode($currency->id))->count()
;
if ($meta > 0) {
app('log')->info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
return 'account_meta';
}
@@ -128,7 +128,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// is being used in available budgets
$availableBudgets = AvailableBudget::where('transaction_currency_id', $currency->id)->count();
if ($availableBudgets > 0) {
app('log')->info(sprintf('Used in %d available budgets as currency, return true. ', $availableBudgets));
Log::info(sprintf('Used in %d available budgets as currency, return true. ', $availableBudgets));
return 'available_budgets';
}
@@ -136,7 +136,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// is being used in budget limits
$budgetLimit = BudgetLimit::where('transaction_currency_id', $currency->id)->count();
if ($budgetLimit > 0) {
app('log')->info(sprintf('Used in %d budget limits as currency, return true. ', $budgetLimit));
Log::info(sprintf('Used in %d budget limits as currency, return true. ', $budgetLimit));
return 'budget_limits';
}
@@ -144,7 +144,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// is the default currency for the user or the system
$count = $this->userGroup->currencies()->where('transaction_currencies.id', $currency->id)->wherePivot('group_default', 1)->count();
if ($count > 0) {
app('log')->info('Is the default currency of the user, return true.');
Log::info('Is the default currency of the user, return true.');
return 'current_default';
}
@@ -152,12 +152,12 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// is the default currency for the user or the system
$count = $this->userGroup->currencies()->where('transaction_currencies.id', $currency->id)->wherePivot('group_default', 1)->count();
if ($count > 0) {
app('log')->info('Is the default currency of the user group, return true.');
Log::info('Is the default currency of the user group, return true.');
return 'current_default';
}
app('log')->debug('Currency is not used, return false.');
Log::debug('Currency is not used, return false.');
return null;
}
@@ -240,15 +240,15 @@ class CurrencyRepository implements CurrencyRepositoryInterface
$result = $this->findCurrencyNull($currencyId, $currencyCode);
if (null === $result) {
app('log')->debug('Grabbing default currency for this user...');
Log::debug('Grabbing default currency for this user...');
/** @var null|TransactionCurrency $result */
$result = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
}
app('log')->debug(sprintf('Final result: %s', $result->code));
Log::debug(sprintf('Final result: %s', $result->code));
if (false === $result->enabled) {
app('log')->debug(sprintf('Also enabled currency %s', $result->code));
Log::debug(sprintf('Also enabled currency %s', $result->code));
$this->enable($result);
}
@@ -260,14 +260,14 @@ class CurrencyRepository implements CurrencyRepositoryInterface
*/
public function findCurrencyNull(?int $currencyId, ?string $currencyCode): ?TransactionCurrency
{
app('log')->debug('Now in findCurrencyNull()');
Log::debug(sprintf('Now in findCurrencyNull("%s", "%s")', $currencyId, $currencyCode));
$result = $this->find((int) $currencyId);
if (null === $result) {
app('log')->debug(sprintf('Searching for currency with code %s...', $currencyCode));
Log::debug(sprintf('Searching for currency with code "%s"...', $currencyCode));
$result = $this->findByCode((string) $currencyCode);
}
if (null !== $result && false === $result->enabled) {
app('log')->debug(sprintf('Also enabled currency %s', $result->code));
Log::debug(sprintf('Also enabled currency %s', $result->code));
$this->enable($result);
}
@@ -335,7 +335,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
public function update(TransactionCurrency $currency, array $data): TransactionCurrency
{
app('log')->debug('Now in update()');
Log::debug('Now in update()');
// can be true, false, null
$enabled = array_key_exists('enabled', $data) ? $data['enabled'] : null;
// can be true, false, but method only responds to "true".
@@ -351,12 +351,12 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// currency is enabled, must be disabled.
if (false === $enabled) {
app('log')->debug(sprintf('Disabled currency %s for user #%d', $currency->code, $this->userGroup->id));
Log::debug(sprintf('Disabled currency %s for user #%d', $currency->code, $this->userGroup->id));
$this->userGroup->currencies()->detach($currency->id);
}
// currency must be enabled
if (true === $enabled) {
app('log')->debug(sprintf('Enabled currency %s for user #%d', $currency->code, $this->userGroup->id));
Log::debug(sprintf('Enabled currency %s for user #%d', $currency->code, $this->userGroup->id));
$this->userGroup->currencies()->detach($currency->id);
$this->userGroup->currencies()->syncWithoutDetaching([$currency->id => ['group_default' => false]]);
}
@@ -375,7 +375,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
public function makeDefault(TransactionCurrency $currency): void
{
$current = app('amount')->getNativeCurrencyByUserGroup($this->userGroup);
app('log')->debug(sprintf('Enabled + made default currency %s for user #%d', $currency->code, $this->userGroup->id));
Log::debug(sprintf('Enabled + made default currency %s for user #%d', $currency->code, $this->userGroup->id));
$this->userGroup->currencies()->detach($currency->id);
foreach ($this->userGroup->currencies()->get() as $item) {
$this->userGroup->currencies()->updateExistingPivot($item->id, ['group_default' => false]);

View File

@@ -39,6 +39,7 @@ use FireflyIII\Models\TransactionGroup;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Services\Internal\Destroy\TransactionGroupDestroyService;
use Illuminate\Support\Facades\Validator;
/**
* Trait AccountServiceTrait
@@ -54,7 +55,7 @@ trait AccountServiceTrait
}
$data = ['iban' => $iban];
$rules = ['iban' => 'required|iban'];
$validator = \Validator::make($data, $rules);
$validator = Validator::make($data, $rules);
if ($validator->fails()) {
app('log')->info(sprintf('Detected invalid IBAN ("%s"). Return NULL instead.', $iban));

View File

@@ -27,6 +27,7 @@ namespace FireflyIII\Services\Internal\Update;
use Carbon\Carbon;
use Carbon\Exceptions\InvalidDateException;
use Carbon\Exceptions\InvalidFormatException;
use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Events\TriggeredAuditLog;
use FireflyIII\Exceptions\FireflyException;
@@ -723,14 +724,17 @@ class JournalUpdateService
// the correct fields to update in the destination transaction are NOT the foreign amount and currency
// but rather the normal amount and currency. This is new behavior.
$isTransfer = TransactionTypeEnum::TRANSFER->value === $this->transactionJournal->transactionType->type;
if ($isTransfer) {
// also check if it is not between an asset account and a liability, because then the same rule applies.
$isBetween = $this->isBetweenAssetAndLiability();
if ($isTransfer || $isBetween) {
Log::debug('Switch amounts, store in amount and not foreign_amount');
$dest->transaction_currency_id = $foreignCurrency->id;
$dest->amount = app('steam')->positive($foreignAmount);
$dest->foreign_amount = app('steam')->positive($source->amount);
$dest->foreign_currency_id = $source->transaction_currency_id;
}
if (!$isTransfer) {
if (!$isTransfer && !$isBetween) {
$dest->foreign_currency_id = $foreignCurrency->id;
$dest->foreign_amount = app('steam')->positive($foreignAmount);
}
@@ -768,4 +772,48 @@ class JournalUpdateService
$this->sourceTransaction->refresh();
$this->destinationTransaction->refresh();
}
private function isBetweenAssetAndLiability(): bool
{
/** @var Transaction $sourceTransaction */
$sourceTransaction = $this->transactionJournal->transactions()->where('amount', '<', 0)->first();
/** @var Transaction $destinationTransaction */
$destinationTransaction = $this->transactionJournal->transactions()->where('amount', '>', 0)->first();
if (null === $sourceTransaction || null === $destinationTransaction) {
Log::warning('Either transaction is false, stop.');
return false;
}
if (null === $sourceTransaction->foreign_amount || null === $destinationTransaction->foreign_amount) {
Log::warning('Either foreign amount is false, stop.');
return false;
}
$source = $sourceTransaction->account;
$destination = $destinationTransaction->account;
if (null === $source || null === $destination) {
Log::warning('Either is false, stop.');
return false;
}
$sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];
// source is liability, destination is asset
if (in_array($source->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $destination->accountType->type) {
Log::debug('Source is a liability account, destination is an asset account, return TRUE.');
return true;
}
// source is asset, destination is liability
if (in_array($destination->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $source->accountType->type) {
Log::debug('Destination is a liability account, source is an asset account, return TRUE.');
return true;
}
return false;
}
}

View File

@@ -67,7 +67,7 @@ class RemoteUserGuard implements Guard
if (function_exists('apache_request_headers')) {
Log::debug('Use apache_request_headers to find user ID.');
$userID = request()->server($header) ?? \Safe\apache_request_headers()[$header] ?? null;
$userID = request()->server($header) ?? apache_request_headers()[$header] ?? null;
}
if (null === $userID || '' === $userID) {
@@ -85,7 +85,7 @@ class RemoteUserGuard implements Guard
$header = config('auth.guard_email');
if (null !== $header) {
$emailAddress = (string) (request()->server($header) ?? \Safe\apache_request_headers()[$header] ?? null);
$emailAddress = (string) (request()->server($header) ?? apache_request_headers()[$header] ?? null);
$preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email');
if ('' !== $emailAddress && null === $preference && $emailAddress !== $userID) {

View File

@@ -63,7 +63,7 @@ class UpdateCheckCronjob extends AbstractCronjob
$this->jobFired = false;
$this->jobErrored = false;
$this->jobSucceeded = true;
$this->message = sprintf('Checked for updates less than a week ago (on %s).', \Safe\date('Y-m-d H:i:s', $lastCheckTime->data));
$this->message = sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data));
return;
}

View File

@@ -23,7 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Support;
use Eloquent;
use Illuminate\Database\Eloquent\Model;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Form\FormSupport;
use Illuminate\Support\Collection;
@@ -205,7 +205,7 @@ class ExpandedForm
$selectList[0] = '(none)';
$fields = ['title', 'name', 'description'];
/** @var \Eloquent $entry */
/** @var Model $entry */
foreach ($set as $entry) {
// All Eloquent models have an ID
$entryId = $entry->id;

View File

@@ -28,6 +28,7 @@ use FireflyIII\Models\Configuration;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\EncryptException;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
/**
@@ -38,8 +39,8 @@ class FireflyConfig
public function delete(string $name): void
{
$fullName = 'ff-config-'.$name;
if (\Cache::has($fullName)) {
\Cache::forget($fullName);
if (Cache::has($fullName)) {
Cache::forget($fullName);
}
Configuration::where('name', $name)->forceDelete();
}
@@ -80,8 +81,8 @@ class FireflyConfig
public function get(string $name, mixed $default = null): ?Configuration
{
$fullName = 'ff-config-'.$name;
if (\Cache::has($fullName)) {
return \Cache::get($fullName);
if (Cache::has($fullName)) {
return Cache::get($fullName);
}
try {
@@ -92,7 +93,7 @@ class FireflyConfig
}
if (null !== $config) {
\Cache::forever($fullName, $config);
Cache::forever($fullName, $config);
return $config;
}
@@ -122,13 +123,13 @@ class FireflyConfig
$item->name = $name;
$item->data = $value;
$item->save();
\Cache::forget('ff-config-'.$name);
Cache::forget('ff3-config-'.$name);
return $item;
}
$config->data = $value;
$config->save();
\Cache::forget('ff-config-'.$name);
Cache::forget('ff3-config-'.$name);
return $config;
}

View File

@@ -33,7 +33,7 @@ use FireflyIII\User;
use Illuminate\Contracts\Validation\Validator as ValidatorContract;
use Illuminate\Routing\Route;
use Illuminate\Support\Facades\Validator;
use Route as RouteFacade;
use Illuminate\Support\Facades\Route as RouteFacade;
/**
* Trait RequestInformation

View File

@@ -50,7 +50,7 @@ class AccountEnrichment implements EnrichmentInterface
private array $accountIds;
private array $accountTypeIds;
private array $accountTypes;
private Collection $collection;
private Collection $collection;
private array $currencies;
private array $locations;
private array $meta;
@@ -59,6 +59,7 @@ class AccountEnrichment implements EnrichmentInterface
private array $openingBalances;
private User $user;
private UserGroup $userGroup;
private array $lastActivities;
public function __construct()
{
@@ -69,6 +70,7 @@ class AccountEnrichment implements EnrichmentInterface
$this->accountTypes = [];
$this->meta = [];
$this->notes = [];
$this->lastActivities = [];
$this->locations = [];
// $this->repository = app(AccountRepositoryInterface::class);
// $this->currencyRepository = app(CurrencyRepositoryInterface::class);
@@ -100,6 +102,7 @@ class AccountEnrichment implements EnrichmentInterface
$this->getAccountTypes();
$this->collectMetaData();
$this->collectNotes();
$this->collectLastActivities();
$this->collectLocations();
$this->collectOpeningBalances();
$this->appendCollectedData();
@@ -229,7 +232,8 @@ class AccountEnrichment implements EnrichmentInterface
$notes = $this->notes;
$openingBalances = $this->openingBalances;
$locations = $this->locations;
$this->collection = $this->collection->map(function (Account $item) use ($accountTypes, $meta, $currencies, $notes, $openingBalances, $locations) {
$lastActivities = $this->lastActivities;
$this->collection = $this->collection->map(function (Account $item) use ($accountTypes, $meta, $currencies, $notes, $openingBalances, $locations, $lastActivities) {
$item->full_account_type = $accountTypes[(int) $item->account_type_id] ?? null;
$accountMeta = [
'currency' => null,
@@ -264,6 +268,9 @@ class AccountEnrichment implements EnrichmentInterface
if (array_key_exists($item->id, $locations)) {
$accountMeta['location'] = $locations[$item->id];
}
if (array_key_exists($item->id, $lastActivities)) {
$accountMeta['last_activity'] = $lastActivities[$item->id];
}
$item->meta = $accountMeta;
return $item;
@@ -274,4 +281,9 @@ class AccountEnrichment implements EnrichmentInterface
{
$this->native = $native;
}
private function collectLastActivities(): void
{
$this->lastActivities = Steam::getLastActivities($this->accountIds);
}
}

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Support\System;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Crypt;
use Laravel\Passport\Console\KeysCommand;
use Psr\Container\ContainerExceptionInterface;
@@ -88,8 +89,8 @@ class OAuthKeys
public static function generateKeys(): void
{
\Artisan::registerCommand(new KeysCommand());
\Artisan::call('firefly-iii:laravel-passport-keys');
Artisan::registerCommand(new KeysCommand());
Artisan::call('firefly-iii:laravel-passport-keys');
}
public static function storeKeysInDB(): void

View File

@@ -33,7 +33,7 @@ use FireflyIII\Support\Facades\Steam;
use FireflyIII\Support\Search\OperatorQuerySearch;
use Illuminate\Support\Facades\Log;
use League\CommonMark\GithubFlavoredMarkdownConverter;
use Route;
use Illuminate\Support\Facades\Route;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
@@ -211,7 +211,7 @@ class General extends AbstractExtension
{
return new TwigFunction(
'phpdate',
static fn (string $str): string => \Safe\date($str)
static fn (string $str): string => date($str)
);
}
@@ -247,7 +247,7 @@ class General extends AbstractExtension
static function (): string {
$args = func_get_args();
$route = $args[0]; // name of the route.
$name = \Route::getCurrentRoute()->getName() ?? '';
$name = Route::getCurrentRoute()->getName() ?? '';
if (str_contains($name, $route)) {
return 'active';
}
@@ -271,7 +271,7 @@ class General extends AbstractExtension
if ($objectType === $activeObjectType
&& false !== stripos(
(string) \Route::getCurrentRoute()->getName(),
(string) Route::getCurrentRoute()->getName(),
(string) $route
)) {
return 'active';
@@ -294,7 +294,7 @@ class General extends AbstractExtension
static function (): string {
$args = func_get_args();
$route = $args[0]; // name of the route.
$name = \Route::getCurrentRoute()->getName() ?? '';
$name = Route::getCurrentRoute()->getName() ?? '';
if (str_contains($name, $route)) {
return 'menu-open';
}

View File

@@ -116,6 +116,18 @@ class SetDestinationAccount implements ActionInterface
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
$newAccount = $this->findWithdrawalDestinationAccount($accountName);
}
if (null === $newAccount) {
app('log')->error(
sprintf(
'No destination account found for name "%s".',
$accountName
)
);
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_destination', ['name' => $accountName])));
return false;
}
app('log')->debug(sprintf('New destination account is #%d ("%s").', $newAccount->id, $newAccount->name));

View File

@@ -152,6 +152,7 @@ class AccountTransformer extends AbstractTransformer
'longitude' => $longitude,
'latitude' => $latitude,
'zoom_level' => $zoomLevel,
'last_activity' => array_key_exists('last_activity', $account->meta) ? $account->meta['last_activity']->toAtomString() : null,
'links' => [
[
'rel' => 'self',

View File

@@ -61,6 +61,7 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Str;
use Laravel\Passport\HasApiTokens;
use NotificationChannels\Pushover\PushoverReceiver;
@@ -464,7 +465,7 @@ class User extends Authenticatable
*/
public function sendPasswordResetNotification($token): void
{
$ipAddress = \Request::ip();
$ipAddress = Request::ip();
event(new RequestedNewPassword($this, $token, $ipAddress));
}

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