Compare commits

..

23 Commits

Author SHA1 Message Date
James Cole
0b22b056bc Merge branch 'release/v6.1.0-alpha.1' 2023-12-10 07:05:51 +01:00
James Cole
ce239a5bb1 Update packages. 2023-12-10 07:03:48 +01:00
James Cole
ce023f2580 Always great when using conflicting tools 2023-12-10 06:57:41 +01:00
James Cole
46e130fdfe Clean up code. 2023-12-10 06:51:59 +01:00
James Cole
c2b22a2bac Clean up code. 2023-12-10 06:45:59 +01:00
James Cole
9a807fc215 Merge branch 'main' into develop
# Conflicts:
#	package-lock.json
#	package.json
2023-12-10 06:22:57 +01:00
James Cole
8ef74e9fd2 Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop 2023-12-09 20:15:13 +01:00
James Cole
abd123b1c8 Fix a few null pointers. 2023-12-09 20:12:34 +01:00
James Cole
7e72003984 Merge pull request #8235 from firefly-iii/dependabot/npm_and_yarn/vite-4.5.1 2023-12-06 05:26:37 +01:00
dependabot[bot]
69f653d0c9 chore(deps-dev): bump vite from 4.5.0 to 4.5.1
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/v4.5.1/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v4.5.1/packages/vite)

---
updated-dependencies:
- dependency-name: vite
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-05 23:54:31 +00:00
James Cole
e6e9535509 Update manifest.webmanifest
Signed-off-by: James Cole <james@firefly-iii.org>
2023-12-05 09:25:41 +01:00
James Cole
45787a30de Update manifest.webmanifest
Signed-off-by: James Cole <james@firefly-iii.org>
2023-12-05 09:24:16 +01:00
James Cole
18e4c2ab33 Update manifest.webmanifest
Signed-off-by: James Cole <james@firefly-iii.org>
2023-12-05 09:20:54 +01:00
James Cole
c063bcf80d Merge pull request #8226 from firefly-iii/dependabot/composer/develop/symfony/mailgun-mailer-7.0.0 2023-12-04 06:54:33 +01:00
James Cole
eb8b7af7aa Merge pull request #8227 from firefly-iii/dependabot/composer/develop/guzzlehttp/guzzle-7.8.1 2023-12-04 06:54:21 +01:00
dependabot[bot]
c60fb0c68c chore(deps): bump symfony/mailgun-mailer from 6.4.0 to 7.0.0
Bumps [symfony/mailgun-mailer](https://github.com/symfony/mailgun-mailer) from 6.4.0 to 7.0.0.
- [Release notes](https://github.com/symfony/mailgun-mailer/releases)
- [Changelog](https://github.com/symfony/mailgun-mailer/blob/7.0/CHANGELOG.md)
- [Commits](https://github.com/symfony/mailgun-mailer/compare/v6.4.0...v7.0.0)

---
updated-dependencies:
- dependency-name: symfony/mailgun-mailer
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-04 05:46:13 +00:00
James Cole
84e99a065f Merge pull request #8225 from firefly-iii/dependabot/composer/develop/symfony/http-client-7.0.0 2023-12-04 06:45:39 +01:00
James Cole
369e980466 Merge pull request #8224 from firefly-iii/dependabot/npm_and_yarn/develop/vite-5.0.4 2023-12-04 06:44:11 +01:00
dependabot[bot]
963d4b7345 chore(deps): bump guzzlehttp/guzzle from 7.8.0 to 7.8.1
Bumps [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) from 7.8.0 to 7.8.1.
- [Release notes](https://github.com/guzzle/guzzle/releases)
- [Changelog](https://github.com/guzzle/guzzle/blob/7.8/CHANGELOG.md)
- [Commits](https://github.com/guzzle/guzzle/compare/7.8.0...7.8.1)

---
updated-dependencies:
- dependency-name: guzzlehttp/guzzle
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-04 03:11:07 +00:00
dependabot[bot]
eaf6bd3fa0 chore(deps): bump symfony/http-client from 6.4.0 to 7.0.0
Bumps [symfony/http-client](https://github.com/symfony/http-client) from 6.4.0 to 7.0.0.
- [Release notes](https://github.com/symfony/http-client/releases)
- [Changelog](https://github.com/symfony/http-client/blob/7.0/CHANGELOG.md)
- [Commits](https://github.com/symfony/http-client/compare/v6.4.0...v7.0.0)

---
updated-dependencies:
- dependency-name: symfony/http-client
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-04 03:10:52 +00:00
dependabot[bot]
9b4a30565c chore(deps-dev): bump vite from 4.5.0 to 5.0.4
Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 4.5.0 to 5.0.4.
- [Release notes](https://github.com/vitejs/vite/releases)
- [Changelog](https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md)
- [Commits](https://github.com/vitejs/vite/commits/v5.0.4/packages/vite)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-04 03:03:14 +00:00
James Cole
c37a877f34 Fix phpstan things 2023-12-03 08:28:50 +01:00
James Cole
d2a895ddda Update to PHP 8.3 2023-12-03 08:18:17 +01:00
299 changed files with 1770 additions and 1710 deletions

View File

@@ -36,13 +36,15 @@ $finder = PhpCsFixer\Finder::create()
$config = new PhpCsFixer\Config(); $config = new PhpCsFixer\Config();
return $config->setRules([ return $config->setRules([
'@PHP83Migration' => true,
'@PhpCsFixer:risky' => true, '@PhpCsFixer:risky' => true,
'@PSR12:risky' => true, '@PSR12:risky' => true,
'declare_strict_types' => true, 'declare_strict_types' => true,
'strict_param' => true, 'strict_param' => true,
'comment_to_phpdoc' => false, // breaks phpstan lines in combination with PHPStorm.
'array_syntax' => ['syntax' => 'short'], 'array_syntax' => ['syntax' => 'short'],
'native_function_invocation' => false, // annoying 'native_function_invocation' => false, // annoying
'php_unit_data_provider_name' => false, // bloody annoying long test names 'php_unit_data_provider_name' => false, // bloody annoying long test names
'static_lambda' => false, // breaks the Response macro for API's. 'static_lambda' => false, // breaks the Response macro for API's.
]) ])
->setFinder($finder); ->setFinder($finder);

View File

@@ -226,16 +226,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v3.40.1", "version": "v3.41.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "7002f09c9593f515625a9f9717b10c2ab64dd3d5" "reference": "7d8d18e19095a939b8a3b8046f57108feaad6134"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/7002f09c9593f515625a9f9717b10c2ab64dd3d5", "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/7d8d18e19095a939b8a3b8046f57108feaad6134",
"reference": "7002f09c9593f515625a9f9717b10c2ab64dd3d5", "reference": "7d8d18e19095a939b8a3b8046f57108feaad6134",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -265,8 +265,6 @@
"php-cs-fixer/accessible-object": "^1.1", "php-cs-fixer/accessible-object": "^1.1",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4", "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4",
"phpspec/prophecy": "^1.17",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.6", "phpunit/phpunit": "^9.6",
"symfony/phpunit-bridge": "^6.3.8 || ^7.0", "symfony/phpunit-bridge": "^6.3.8 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0" "symfony/yaml": "^5.4 || ^6.0 || ^7.0"
@@ -307,7 +305,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.40.1" "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.41.0"
}, },
"funding": [ "funding": [
{ {
@@ -315,7 +313,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-12-02T23:18:26+00:00" "time": "2023-12-08T22:54:33+00:00"
}, },
{ {
"name": "psr/container", "name": "psr/container",

View File

@@ -13,6 +13,7 @@ parameters:
- '#is not allowed to extend#' - '#is not allowed to extend#'
- '#switch is forbidden to use#' - '#switch is forbidden to use#'
- '#is neither abstract nor final#' - '#is neither abstract nor final#'
- '#on left side of \?\?\= always exists and is not nullable#'
- '#has a nullable return type declaration#' # perhaps throw errors instead? - '#has a nullable return type declaration#' # perhaps throw errors instead?
- '#with a nullable type declaration#' # decide what action should be if param is null. - '#with a nullable type declaration#' # decide what action should be if param is null.
- '#with null as default value#' - '#with null as default value#'

View File

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

View File

@@ -92,8 +92,8 @@ class AccountController extends Controller
// user's preferences // user's preferences
$defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray(); $defaultSet = $this->repository->getAccountsByType([AccountType::ASSET])->pluck('id')->toArray();
/** @var Preference $frontPage */ /** @var Preference $frontPage */
$frontPage = app('preferences')->get('frontPageAccounts', $defaultSet); $frontPage = app('preferences')->get('frontPageAccounts', $defaultSet);
$default = app('amount')->getDefaultCurrency(); $default = app('amount')->getDefaultCurrency();
if (!(is_array($frontPage->data) && count($frontPage->data) > 0)) { if (!(is_array($frontPage->data) && count($frontPage->data) > 0)) {
$frontPage->data = $defaultSet; $frontPage->data = $defaultSet;

View File

@@ -229,7 +229,7 @@ class ExportController extends Controller
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws FireflyException * @throws FireflyException
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/ */
public function tags(ExportRequest $request): LaravelResponse public function tags(ExportRequest $request): LaravelResponse
{ {

View File

@@ -92,7 +92,7 @@ class BillController extends Controller
$foreignKey = sprintf('%d-%d', $billId, $foreignCurrencyId); $foreignKey = sprintf('%d-%d', $billId, $foreignCurrencyId);
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [ $response[$key] ??= [
'id' => (string)$billId, 'id' => (string)$billId,
'name' => $journal['bill_name'], 'name' => $journal['bill_name'],
'difference' => '0', 'difference' => '0',
@@ -104,7 +104,7 @@ class BillController extends Controller
$response[$key]['difference_float'] = (float)$response[$key]['difference']; // intentional float $response[$key]['difference_float'] = (float)$response[$key]['difference']; // intentional float
} }
if (0 !== $foreignCurrencyId) { if (0 !== $foreignCurrencyId) {
$response[$foreignKey] = $response[$foreignKey] ?? [ $response[$foreignKey] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId, 'currency_id' => (string)$foreignCurrencyId,
@@ -147,7 +147,7 @@ class BillController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id']; $foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [ $response[$currencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
@@ -157,7 +157,7 @@ class BillController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float
} }
if (0 !== $foreignCurrencyId) { if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ $response[$foreignCurrencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId, 'currency_id' => (string)$foreignCurrencyId,

View File

@@ -58,7 +58,7 @@ class PeriodController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id']; $foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [ $response[$currencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
@@ -68,7 +68,7 @@ class PeriodController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float
} }
if (0 !== $foreignCurrencyId) { if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ $response[$foreignCurrencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId, 'currency_id' => (string)$foreignCurrencyId,

View File

@@ -83,7 +83,7 @@ class TagController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id']; $foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [ $response[$currencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
@@ -93,7 +93,7 @@ class TagController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose. $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose.
} }
if (0 !== $foreignCurrencyId) { if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ $response[$foreignCurrencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId, 'currency_id' => (string)$foreignCurrencyId,
@@ -148,7 +148,7 @@ class TagController extends Controller
// on currency ID // on currency ID
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [ $response[$key] ??= [
'id' => (string)$tagId, 'id' => (string)$tagId,
'name' => $tag['name'], 'name' => $tag['name'],
'difference' => '0', 'difference' => '0',

View File

@@ -58,7 +58,7 @@ class PeriodController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id']; $foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [ $response[$currencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
@@ -68,7 +68,7 @@ class PeriodController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose. $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose.
} }
if (0 !== $foreignCurrencyId) { if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ $response[$foreignCurrencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId, 'currency_id' => (string)$foreignCurrencyId,

View File

@@ -84,7 +84,7 @@ class TagController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id']; $foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [ $response[$currencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
@@ -94,7 +94,7 @@ class TagController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
} }
if (0 !== $foreignCurrencyId) { if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ $response[$foreignCurrencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId, 'currency_id' => (string)$foreignCurrencyId,
@@ -152,7 +152,7 @@ class TagController extends Controller
// on currency ID // on currency ID
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [ $response[$key] ??= [
'id' => (string)$tagId, 'id' => (string)$tagId,
'name' => $tag['name'], 'name' => $tag['name'],
'difference' => '0', 'difference' => '0',

View File

@@ -58,7 +58,7 @@ class PeriodController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id']; $foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [ $response[$currencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
@@ -68,7 +68,7 @@ class PeriodController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
} }
if (0 !== $foreignCurrencyId) { if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ $response[$foreignCurrencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId, 'currency_id' => (string)$foreignCurrencyId,

View File

@@ -81,7 +81,7 @@ class TagController extends Controller
$foreignCurrencyId = (int)$journal['foreign_currency_id']; $foreignCurrencyId = (int)$journal['foreign_currency_id'];
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [ $response[$currencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
@@ -91,7 +91,7 @@ class TagController extends Controller
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
} }
if (0 !== $foreignCurrencyId) { if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [ $response[$foreignCurrencyId] ??= [
'difference' => '0', 'difference' => '0',
'difference_float' => 0, 'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId, 'currency_id' => (string)$foreignCurrencyId,
@@ -149,7 +149,7 @@ class TagController extends Controller
// on currency ID // on currency ID
if (0 !== $currencyId) { if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [ $response[$key] ??= [
'id' => (string)$tagId, 'id' => (string)$tagId,
'name' => $tag['name'], 'name' => $tag['name'],
'difference' => '0', 'difference' => '0',

View File

@@ -33,7 +33,6 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Transformers\BudgetLimitTransformer; use FireflyIII\Transformers\BudgetLimitTransformer;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection; use League\Fractal\Resource\Collection as FractalCollection;

View File

@@ -24,13 +24,11 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\ObjectGroup; namespace FireflyIII\Api\V1\Controllers\Models\ObjectGroup;
use FireflyIII\Api\V1\Controllers\Controller; use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\ObjectGroup; use FireflyIII\Models\ObjectGroup;
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface; use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
use FireflyIII\Transformers\ObjectGroupTransformer; use FireflyIII\Transformers\ObjectGroupTransformer;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use League\Fractal\Pagination\IlluminatePaginatorAdapter; use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use League\Fractal\Resource\Collection as FractalCollection; use League\Fractal\Resource\Collection as FractalCollection;

View File

@@ -255,7 +255,7 @@ class ListController extends Controller
$unfiltered = $recurringRepos->getAll(); $unfiltered = $recurringRepos->getAll();
// filter selection // filter selection
$collection = $unfiltered->filter(/** @phpstan-ignore-line */ $collection = $unfiltered->filter( // @phpstan-ignore-line
static function (Recurrence $recurrence) use ($currency) { // @phpstan-ignore-line static function (Recurrence $recurrence) use ($currency) { // @phpstan-ignore-line
/** @var RecurrenceTransaction $transaction */ /** @var RecurrenceTransaction $transaction */
foreach ($recurrence->recurrenceTransactions as $transaction) { foreach ($recurrence->recurrenceTransactions as $transaction) {
@@ -305,7 +305,7 @@ class ListController extends Controller
$ruleRepos = app(RuleRepositoryInterface::class); $ruleRepos = app(RuleRepositoryInterface::class);
$unfiltered = $ruleRepos->getAll(); $unfiltered = $ruleRepos->getAll();
$collection = $unfiltered->filter(/** @phpstan-ignore-line */ $collection = $unfiltered->filter( // @phpstan-ignore-line
static function (Rule $rule) use ($currency) { // @phpstan-ignore-line static function (Rule $rule) use ($currency) { // @phpstan-ignore-line
/** @var RuleTrigger $trigger */ /** @var RuleTrigger $trigger */
foreach ($rule->ruleTriggers as $trigger) { foreach ($rule->ruleTriggers as $trigger) {

View File

@@ -148,12 +148,12 @@ class BasicController extends Controller
/** @var array $transactionJournal */ /** @var array $transactionJournal */
foreach ($set as $transactionJournal) { foreach ($set as $transactionJournal) {
$currencyId = (int)$transactionJournal['currency_id']; $currencyId = (int)$transactionJournal['currency_id'];
$incomes[$currencyId] = $incomes[$currencyId] ?? '0'; $incomes[$currencyId] ??= '0';
$incomes[$currencyId] = bcadd( $incomes[$currencyId] = bcadd(
$incomes[$currencyId], $incomes[$currencyId],
bcmul($transactionJournal['amount'], '-1') bcmul($transactionJournal['amount'], '-1')
); );
$sums[$currencyId] = $sums[$currencyId] ?? '0'; $sums[$currencyId] ??= '0';
$sums[$currencyId] = bcadd($sums[$currencyId], bcmul($transactionJournal['amount'], '-1')); $sums[$currencyId] = bcadd($sums[$currencyId], bcmul($transactionJournal['amount'], '-1'));
} }
@@ -171,9 +171,9 @@ class BasicController extends Controller
/** @var array $transactionJournal */ /** @var array $transactionJournal */
foreach ($set as $transactionJournal) { foreach ($set as $transactionJournal) {
$currencyId = (int)$transactionJournal['currency_id']; $currencyId = (int)$transactionJournal['currency_id'];
$expenses[$currencyId] = $expenses[$currencyId] ?? '0'; $expenses[$currencyId] ??= '0';
$expenses[$currencyId] = bcadd($expenses[$currencyId], $transactionJournal['amount']); $expenses[$currencyId] = bcadd($expenses[$currencyId], $transactionJournal['amount']);
$sums[$currencyId] = $sums[$currencyId] ?? '0'; $sums[$currencyId] ??= '0';
$sums[$currencyId] = bcadd($sums[$currencyId], $transactionJournal['amount']); $sums[$currencyId] = bcadd($sums[$currencyId], $transactionJournal['amount']);
} }

View File

@@ -102,7 +102,7 @@ class AccountController extends Controller
$nameWithBalance = sprintf('%s (%s)', $account->name, app('amount')->formatAnything($currency, $balance, false)); $nameWithBalance = sprintf('%s (%s)', $account->name, app('amount')->formatAnything($currency, $balance, false));
} }
$type = (string)trans(sprintf('firefly.%s', $account->accountType->type)); $type = (string)trans(sprintf('firefly.%s', $account->accountType->type));
$groupedResult[$type] = $groupedResult[$type] ?? [ $groupedResult[$type] ??= [
'group ' => $type, 'group ' => $type,
'items' => [], 'items' => [],
]; ];
@@ -124,8 +124,8 @@ class AccountController extends Controller
usort( usort(
$allItems, $allItems,
static function (array $left, array $right): int { static function (array $left, array $right): int {
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE]; $order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
$posLeft = (int)array_search($left['type'], $order, true); $posLeft = (int)array_search($left['type'], $order, true);
$posRight = (int)array_search($right['type'], $order, true); $posRight = (int)array_search($right['type'], $order, true);
return $posLeft - $posRight; return $posLeft - $posRight;

View File

@@ -27,7 +27,6 @@ namespace FireflyIII\Api\V2\Controllers\Chart;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Api\V2\Controllers\Controller; use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Api\V2\Request\Chart\DashboardChartRequest; use FireflyIII\Api\V2\Request\Chart\DashboardChartRequest;
use FireflyIII\Api\V2\Request\Generic\DateRequest;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
@@ -99,8 +98,8 @@ class AccountController extends Controller
/** @var TransactionCurrency $default */ /** @var TransactionCurrency $default */
$default = app('amount')->getDefaultCurrency(); $default = app('amount')->getDefaultCurrency();
$params = $request->getAll(); $params = $request->getAll();
/** @var Collection $preSet */ /** @var Collection $accounts */
$accounts = $params['accounts']; $accounts = $params['accounts'];
$chartData = []; $chartData = [];
// user's preferences // user's preferences
@@ -117,13 +116,13 @@ class AccountController extends Controller
} }
// both options are overruled by "preselected" // both options are overruled by "preselected"
if('all' === $params['preselected']) { if ('all' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]); $accounts = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
} }
if('assets' === $params['preselected']) { if ('assets' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]); $accounts = $this->repository->getAccountsByType([AccountType::ASSET, AccountType::DEFAULT]);
} }
if('liabilities' === $params['preselected']) { if ('liabilities' === $params['preselected']) {
$accounts = $this->repository->getAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]); $accounts = $this->repository->getAccountsByType([AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
} }

View File

@@ -121,7 +121,7 @@ class BalanceController extends Controller
$currencies[$currencyId] = $currency; // may just re-assign itself, don't mind. $currencies[$currencyId] = $currency; // may just re-assign itself, don't mind.
// set the array with monetary info, if it does not exist. // set the array with monetary info, if it does not exist.
$data[$currencyId] = $data[$currencyId] ?? [ $data[$currencyId] ??= [
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
'currency_symbol' => $journal['currency_symbol'], 'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],
@@ -135,7 +135,7 @@ class BalanceController extends Controller
]; ];
// set the array (in monetary info) with spent/earned in this $period, if it does not exist. // set the array (in monetary info) with spent/earned in this $period, if it does not exist.
$data[$currencyId][$period] = $data[$currencyId][$period] ?? [ $data[$currencyId][$period] ??= [
'period' => $period, 'period' => $period,
'spent' => '0', 'spent' => '0',
'earned' => '0', 'earned' => '0',

View File

@@ -198,8 +198,8 @@ class BudgetController extends Controller
* @var array $block * @var array $block
*/ */
foreach ($array as $currencyId => $block) { foreach ($array as $currencyId => $block) {
$this->currencies[$currencyId] = $this->currencies[$currencyId] ?? TransactionCurrency::find($currencyId); $this->currencies[$currencyId] ??= TransactionCurrency::find($currencyId);
$return[$currencyId] = $return[$currencyId] ?? [ $return[$currencyId] ??= [
'currency_id' => (string)$currencyId, 'currency_id' => (string)$currencyId,
'currency_code' => $block['currency_code'], 'currency_code' => $block['currency_code'],
'currency_name' => $block['currency_name'], 'currency_name' => $block['currency_name'],

View File

@@ -109,7 +109,7 @@ class CategoryController extends Controller
$nativeAmount = app('steam')->positive($journal['foreign_amount']); $nativeAmount = app('steam')->positive($journal['foreign_amount']);
} }
// create arrays // create arrays
$return[$key] = $return[$key] ?? [ $return[$key] ??= [
'label' => $categoryName, 'label' => $categoryName,
'currency_id' => (string)$currency->id, 'currency_id' => (string)$currency->id,
'currency_code' => $currency->code, 'currency_code' => $currency->code,

View File

@@ -28,7 +28,6 @@ use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Transformers\V2\AccountTransformer; use FireflyIII\Transformers\V2\AccountTransformer;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
/** /**
* Show = show a single account. * Show = show a single account.

View File

@@ -30,7 +30,6 @@ use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait; use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\V2\BillTransformer; use FireflyIII\Transformers\V2\BillTransformer;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
/** /**

View File

@@ -31,7 +31,6 @@ use FireflyIII\Repositories\UserGroups\Bill\BillRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait; use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\V2\BillTransformer; use FireflyIII\Transformers\V2\BillTransformer;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
/** /**
* Class ShowController * Class ShowController

View File

@@ -28,7 +28,6 @@ use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Transformers\V2\BudgetTransformer; use FireflyIII\Transformers\V2\BudgetTransformer;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
/** /**

View File

@@ -25,8 +25,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V2\Controllers\Model\BudgetLimit; namespace FireflyIII\Api\V2\Controllers\Model\BudgetLimit;
use FireflyIII\Api\V2\Controllers\Controller; use FireflyIII\Api\V2\Controllers\Controller;
use FireflyIII\Api\V2\Request\Generic\DateRequest;
use FireflyIII\Models\Budget;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
/** /**

View File

@@ -30,7 +30,6 @@ use FireflyIII\Repositories\UserGroups\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait; use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\V2\PiggyBankTransformer; use FireflyIII\Transformers\V2\PiggyBankTransformer;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
/** /**

View File

@@ -169,10 +169,10 @@ class BasicController extends Controller
$nativeAmount = $transactionJournal['foreign_amount']; $nativeAmount = $transactionJournal['foreign_amount'];
} }
// prep the arrays // prep the arrays
$incomes[$currencyId] = $incomes[$currencyId] ?? '0'; $incomes[$currencyId] ??= '0';
$incomes['native'] = $incomes['native'] ?? '0'; $incomes['native'] ??= '0';
$sums[$currencyId] = $sums[$currencyId] ?? '0'; $sums[$currencyId] ??= '0';
$sums['native'] = $sums['native'] ?? '0'; $sums['native'] ??= '0';
// add values: // add values:
$incomes[$currencyId] = bcadd($incomes[$currencyId], $amount); $incomes[$currencyId] = bcadd($incomes[$currencyId], $amount);
@@ -208,10 +208,10 @@ class BasicController extends Controller
} }
// prep arrays // prep arrays
$expenses[$currencyId] = $expenses[$currencyId] ?? '0'; $expenses[$currencyId] ??= '0';
$expenses['native'] = $expenses['native'] ?? '0'; $expenses['native'] ??= '0';
$sums[$currencyId] = $sums[$currencyId] ?? '0'; $sums[$currencyId] ??= '0';
$sums['native'] = $sums['native'] ?? '0'; $sums['native'] ??= '0';
// add values // add values
$expenses[$currencyId] = bcadd($expenses[$currencyId], $amount); $expenses[$currencyId] = bcadd($expenses[$currencyId], $amount);

View File

@@ -31,7 +31,6 @@ use FireflyIII\Models\UserGroup;
use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface; use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**

View File

@@ -30,7 +30,6 @@ use FireflyIII\Models\UserGroup;
use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface; use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface;
use FireflyIII\Transformers\V2\UserGroupTransformer; use FireflyIII\Transformers\V2\UserGroupTransformer;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;

View File

@@ -27,7 +27,6 @@ use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Support\Request\ChecksLogin; use FireflyIII\Support\Request\ChecksLogin;
use FireflyIII\Support\Request\ConvertsDataTypes; use FireflyIII\Support\Request\ConvertsDataTypes;
use FireflyIII\User;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
/** /**

View File

@@ -55,7 +55,7 @@ class AutoSum
/** @var string $amount */ /** @var string $amount */
$amount = $getSum($object); $amount = $getSum($object);
$return[$currency->id] = $return[$currency->id] ?? [ $return[$currency->id] ??= [
'id' => (string)$currency->id, 'id' => (string)$currency->id,
'name' => $currency->name, 'name' => $currency->name,
'symbol' => $currency->symbol, 'symbol' => $currency->symbol,

View File

@@ -59,9 +59,9 @@ class DeleteEmptyJournals extends Command
*/ */
private function deleteUnevenJournals(): void private function deleteUnevenJournals(): void
{ {
$set = Transaction::whereNull('deleted_at') $set = Transaction::whereNull('deleted_at')
->groupBy('transactions.transaction_journal_id') ->groupBy('transactions.transaction_journal_id')
->get([DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']); /** @phpstan-ignore-line */ ->get([DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']); // @phpstan-ignore-line
$total = 0; $total = 0;
/** @var Transaction $row */ /** @var Transaction $row */
foreach ($set as $row) { foreach ($set as $row) {

View File

@@ -28,7 +28,6 @@ use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\AccountType; use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference; use FireflyIII\Models\Preference;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Support\Facades\Preferences;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Console\Command; use Illuminate\Console\Command;

View File

@@ -91,7 +91,7 @@ class FixIbans extends Command
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
$userId = $account->user_id; $userId = $account->user_id;
$set[$userId] = $set[$userId] ?? []; $set[$userId] ??= [];
$iban = (string)$account->iban; $iban = (string)$account->iban;
if ('' === $iban) { if ('' === $iban) {
continue; continue;

View File

@@ -51,7 +51,7 @@ class ExportData extends Command
protected $description = 'Command to export data from Firefly III.'; protected $description = 'Command to export data from Firefly III.';
protected $signature = 'firefly-iii:export-data protected $signature = 'firefly-iii:export-data
{--user=1 : The user ID that the export should run for.} {--user=1 : The user ID that the export should run for.}
{--token= : The user\'s access token.} {--token= : The user\'s access token.}
{--start= : First transaction to export. Defaults to your very first transaction. Only applies to transaction export.} {--start= : First transaction to export. Defaults to your very first transaction. Only applies to transaction export.}

View File

@@ -54,8 +54,8 @@ class CreateDatabase extends Command
return 0; return 0;
} }
// try to set up a raw connection: // try to set up a raw connection:
$exists = false; $exists = false;
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST', 'localhost'), env('DB_PORT', '3306')); $dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST', 'localhost'), env('DB_PORT', '3306'));
if ('' !== env('DB_SOCKET', '')) { if ('' !== env('DB_SOCKET', '')) {
$dsn = sprintf('mysql:unix_socket=%s;charset=utf8mb4', env('DB_SOCKET', '')); $dsn = sprintf('mysql:unix_socket=%s;charset=utf8mb4', env('DB_SOCKET', ''));
@@ -79,7 +79,7 @@ class CreateDatabase extends Command
// only continue when no error. // only continue when no error.
// with PDO, try to list DB's ( // with PDO, try to list DB's (
/** @var array $stmt */ /** @var array $stmt */
$stmt = $pdo->query('SHOW DATABASES;'); $stmt = $pdo->query('SHOW DATABASES;');
// slightly more complex but less error-prone. // slightly more complex but less error-prone.
foreach ($stmt as $row) { foreach ($stmt as $row) {
$name = $row['Database'] ?? false; $name = $row['Database'] ?? false;

View File

@@ -260,7 +260,7 @@ class ForceDecimalSize extends Command
continue; continue;
} }
// fix $field by rounding it down correctly. // fix $field by rounding it down correctly.
$pow = 10** $currency->decimal_places; $pow = 10 ** $currency->decimal_places;
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12); $correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyInfo(sprintf('Account #%d has %s with value "%s", this has been corrected to "%s".', $account->id, $field, $value, $correct)); $this->friendlyInfo(sprintf('Account #%d has %s with value "%s", this has been corrected to "%s".', $account->id, $field, $value, $correct));
Account::find($account->id)->update([$field => $correct]); Account::find($account->id)->update([$field => $correct]);
@@ -313,7 +313,7 @@ class ForceDecimalSize extends Command
continue; continue;
} }
// fix $field by rounding it down correctly. // fix $field by rounding it down correctly.
$pow = 10** $currency->decimal_places; $pow = 10 ** $currency->decimal_places;
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12); $correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyWarning(sprintf('%s #%d has %s with value "%s", this has been corrected to "%s".', $table, $item->id, $field, $value, $correct)); $this->friendlyWarning(sprintf('%s #%d has %s with value "%s", this has been corrected to "%s".', $table, $item->id, $field, $value, $correct));
$class::find($item->id)->update([$field => $correct]); $class::find($item->id)->update([$field => $correct]);
@@ -366,7 +366,7 @@ class ForceDecimalSize extends Command
continue; continue;
} }
// fix $field by rounding it down correctly. // fix $field by rounding it down correctly.
$pow = 10** $currency->decimal_places; $pow = 10 ** $currency->decimal_places;
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12); $correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyWarning( $this->friendlyWarning(
sprintf('Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct) sprintf('Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
@@ -421,7 +421,7 @@ class ForceDecimalSize extends Command
continue; continue;
} }
// fix $field by rounding it down correctly. // fix $field by rounding it down correctly.
$pow = 10** $currency->decimal_places; $pow = 10 ** $currency->decimal_places;
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12); $correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyWarning( $this->friendlyWarning(
sprintf('Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct) sprintf('Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
@@ -475,7 +475,7 @@ class ForceDecimalSize extends Command
continue; continue;
} }
// fix $field by rounding it down correctly. // fix $field by rounding it down correctly.
$pow = 10** $currency->decimal_places; $pow = 10 ** $currency->decimal_places;
$correct = bcdiv((string)round($value * $pow), (string)$pow, 12); $correct = bcdiv((string)round($value * $pow), (string)$pow, 12);
$this->friendlyWarning(sprintf('Piggy bank #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)); $this->friendlyWarning(sprintf('Piggy bank #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));
PiggyBank::find($item->id)->update([$field => $correct]); PiggyBank::find($item->id)->update([$field => $correct]);
@@ -512,7 +512,7 @@ class ForceDecimalSize extends Command
continue; continue;
} }
// fix $field by rounding it down correctly. // fix $field by rounding it down correctly.
$pow = (float)10** $currency->decimal_places; $pow = (float)10 ** $currency->decimal_places;
$correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12); $correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);
$this->friendlyWarning(sprintf('Transaction #%d has amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct)); $this->friendlyWarning(sprintf('Transaction #%d has amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct));
Transaction::find($item->id)->update(['amount' => $correct]); Transaction::find($item->id)->update(['amount' => $correct]);
@@ -539,7 +539,7 @@ class ForceDecimalSize extends Command
continue; continue;
} }
// fix $field by rounding it down correctly. // fix $field by rounding it down correctly.
$pow = (float)10** $currency->decimal_places; $pow = (float)10 ** $currency->decimal_places;
$correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12); $correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);
$this->friendlyWarning( $this->friendlyWarning(
sprintf('Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct) sprintf('Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct)

View File

@@ -67,13 +67,13 @@ class ScanAttachments extends Command
$decryptedContent = $encryptedContent; $decryptedContent = $encryptedContent;
} }
$tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII'); $tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');
if(false === $tempFileName) { if (false === $tempFileName) {
app('log')->error(sprintf('Could not create temporary file for attachment #%d', $attachment->id)); app('log')->error(sprintf('Could not create temporary file for attachment #%d', $attachment->id));
exit(1); exit(1);
} }
file_put_contents($tempFileName, $decryptedContent); file_put_contents($tempFileName, $decryptedContent);
$attachment->md5 = (string) md5_file($tempFileName); $attachment->md5 = (string)md5_file($tempFileName);
$attachment->mime = (string) mime_content_type($tempFileName); $attachment->mime = (string)mime_content_type($tempFileName);
$attachment->save(); $attachment->save();
$this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id)); $this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id));
} }

View File

@@ -61,15 +61,15 @@ class UpgradeFireflyInstructions extends Command
*/ */
private function updateInstructions(): void private function updateInstructions(): void
{ {
$version = (string) config('firefly.version'); $version = (string)config('firefly.version');
/** @var array $config */ /** @var array $config */
$config = config('upgrade.text.upgrade'); $config = config('upgrade.text.upgrade');
$text = ''; $text = '';
/** @var string $compare */ /** @var string $compare */
foreach (array_keys($config) as $compare) { foreach (array_keys($config) as $compare) {
// if string starts with: // if string starts with:
if (str_starts_with($version, $compare)) { if (str_starts_with($version, $compare)) {
$text = (string) $config[$compare]; $text = (string)$config[$compare];
} }
} }
@@ -175,15 +175,15 @@ class UpgradeFireflyInstructions extends Command
*/ */
private function installInstructions(): void private function installInstructions(): void
{ {
$version = (string) config('firefly.version'); $version = (string)config('firefly.version');
/** @var array $config */ /** @var array $config */
$config = config('upgrade.text.install'); $config = config('upgrade.text.install');
$text = ''; $text = '';
/** @var string $compare */ /** @var string $compare */
foreach (array_keys($config) as $compare) { foreach (array_keys($config) as $compare) {
// if string starts with: // if string starts with:
if (str_starts_with($version, $compare)) { if (str_starts_with($version, $compare)) {
$text = (string) $config[$compare]; $text = (string)$config[$compare];
} }
} }
$this->newLine(); $this->newLine();

View File

@@ -27,9 +27,7 @@ namespace FireflyIII\Console\Commands\System;
use FireflyIII\Console\Commands\ShowsFriendlyMessages; use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Filesystem\FilesystemAdapter;
use League\Flysystem\FilesystemException; use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemReader;
use Storage; use Storage;
/** /**

View File

@@ -297,7 +297,7 @@ class ApplyRules extends Command
if (null !== $endString && '' !== $endString) { if (null !== $endString && '' !== $endString) {
$inputEnd = Carbon::createFromFormat('Y-m-d', $endString); $inputEnd = Carbon::createFromFormat('Y-m-d', $endString);
} }
if(false === $inputEnd || false === $inputStart) { if (false === $inputEnd || false === $inputStart) {
Log::error('Could not parse start or end date in verifyInputDate().'); Log::error('Could not parse start or end date in verifyInputDate().');
return; return;
} }

View File

@@ -66,7 +66,7 @@ class Cron extends Command
} catch (InvalidArgumentException $e) { } catch (InvalidArgumentException $e) {
$this->friendlyError(sprintf('"%s" is not a valid date', $this->option('date'))); $this->friendlyError(sprintf('"%s" is not a valid date', $this->option('date')));
} }
$force = (bool) $this->option('force'); // @phpstan-ignore-line $force = (bool)$this->option('force'); // @phpstan-ignore-line
/* /*
* Fire exchange rates cron job. * Fire exchange rates cron job.

View File

@@ -109,14 +109,14 @@ class AccountCurrencies extends Command
*/ */
private function updateAccountCurrencies(): void private function updateAccountCurrencies(): void
{ {
$users = $this->userRepos->all(); $users = $this->userRepos->all();
foreach ($users as $user) { foreach ($users as $user) {
$this->updateCurrenciesForUser($user); $this->updateCurrenciesForUser($user);
} }
} }
/** /**
* @param User $user * @param User $user
* *
* @throws FireflyException * @throws FireflyException
*/ */

View File

@@ -48,7 +48,7 @@ class MigrateToRules extends Command
protected $description = 'Migrate bills to rules.'; protected $description = 'Migrate bills to rules.';
protected $signature = 'firefly-iii:bills-to-rules {--F|force : Force the execution of this command.}'; protected $signature = 'firefly-iii:bills-to-rules {--F|force : Force the execution of this command.}';
private BillRepositoryInterface $billRepository; private BillRepositoryInterface $billRepository;
private int $count; private int $count;
private RuleGroupRepositoryInterface $ruleGroupRepository; private RuleGroupRepositoryInterface $ruleGroupRepository;
@@ -169,7 +169,7 @@ class MigrateToRules extends Command
if ('MIGRATED_TO_RULES' === $bill->match) { if ('MIGRATED_TO_RULES' === $bill->match) {
return; return;
} }
$languageString = null !== $language->data && !is_array($language->data) ? (string)$language->data : 'en_US'; $languageString = null !== $language->data && !is_array($language->data) ? (string)$language->data : 'en_US';
// get match thing: // get match thing:
$match = implode(' ', explode(',', $bill->match)); $match = implode(' ', explode(',', $bill->match));

View File

@@ -33,7 +33,7 @@ class DestroyedTransactionLink extends Event
{ {
use SerializesModels; use SerializesModels;
private TransactionJournalLink $link; /** @phpstan-ignore-line */ private TransactionJournalLink $link; // @phpstan-ignore-line
/** /**
* DestroyedTransactionLink constructor. * DestroyedTransactionLink constructor.

View File

@@ -140,9 +140,9 @@ class GracefulNotFoundHandler extends ExceptionHandler
{ {
app('log')->debug('404 page is probably a deleted account. Redirect to overview of account types.'); app('log')->debug('404 page is probably a deleted account. Redirect to overview of account types.');
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$route = $request->route(); $route = $request->route();
$param = $route->parameter('account'); $param = $route->parameter('account');
$accountId = 0; $accountId = 0;
if ($param instanceof Account) { if ($param instanceof Account) {
$accountId = $param->id; $accountId = $param->id;

View File

@@ -26,15 +26,12 @@ namespace FireflyIII\Exceptions;
use ErrorException; use ErrorException;
use FireflyIII\Jobs\MailError; use FireflyIII\Jobs\MailError;
use FireflyIII\Models\ObjectGroup;
use Illuminate\Auth\AuthenticationException; use Illuminate\Auth\AuthenticationException;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Routing\Redirector;
use Illuminate\Session\TokenMismatchException; use Illuminate\Session\TokenMismatchException;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use Illuminate\Validation\ValidationException as LaravelValidationException; use Illuminate\Validation\ValidationException as LaravelValidationException;
@@ -127,7 +124,7 @@ class Handler extends ExceptionHandler
$errorCode = 500; $errorCode = 500;
$errorCode = $e instanceof MethodNotAllowedHttpException ? 405 : $errorCode; $errorCode = $e instanceof MethodNotAllowedHttpException ? 405 : $errorCode;
$isDebug = (bool) config('app.debug', false); $isDebug = (bool)config('app.debug', false);
if ($isDebug) { if ($isDebug) {
app('log')->debug(sprintf('Return JSON %s with debug.', get_class($e))); app('log')->debug(sprintf('Return JSON %s with debug.', get_class($e)));
return response()->json( return response()->json(
@@ -186,7 +183,7 @@ class Handler extends ExceptionHandler
*/ */
public function report(Throwable $e) public function report(Throwable $e)
{ {
$doMailError = (bool) config('firefly.send_error_message'); $doMailError = (bool)config('firefly.send_error_message');
if ($this->shouldntReportLocal($e) || !$doMailError) { if ($this->shouldntReportLocal($e) || !$doMailError) {
parent::report($e); parent::report($e);
@@ -235,11 +232,11 @@ class Handler extends ExceptionHandler
private function shouldntReportLocal(Throwable $e): bool private function shouldntReportLocal(Throwable $e): bool
{ {
return null !== Arr::first( return null !== Arr::first(
$this->dontReport, $this->dontReport,
static function ($type) use ($e) { static function ($type) use ($e) {
return $e instanceof $type; return $e instanceof $type;
} }
); );
} }
/** /**
@@ -250,7 +247,7 @@ class Handler extends ExceptionHandler
* *
* @return JsonResponse| RedirectResponse |\Illuminate\Http\Response * @return JsonResponse| RedirectResponse |\Illuminate\Http\Response
*/ */
protected function invalid($request, LaravelValidationException $exception): JsonResponse| RedirectResponse |\Illuminate\Http\Response protected function invalid($request, LaravelValidationException $exception): JsonResponse | RedirectResponse | \Illuminate\Http\Response
{ {
// protect against open redirect when submitting invalid forms. // protect against open redirect when submitting invalid forms.
$previous = app('steam')->getSafePreviousUrl(); $previous = app('steam')->getSafePreviousUrl();

View File

@@ -59,7 +59,8 @@ final class IntervalException extends Exception
array $intervals, array $intervals,
int $code = 0, int $code = 0,
?Throwable $previous = null ?Throwable $previous = null
): self { ): self
{
$message = sprintf( $message = sprintf(
'The periodicity %s is unknown. Choose one of available periodicity: %s', 'The periodicity %s is unknown. Choose one of available periodicity: %s',
$periodicity->name, $periodicity->name,

View File

@@ -93,7 +93,7 @@ class TagFactory
'zoomLevel' => null, 'zoomLevel' => null,
]; ];
/** @var Tag|null $tag */ /** @var Tag|null $tag */
$tag = Tag::create($array); $tag = Tag::create($array);
if (null !== $tag && null !== $latitude && null !== $longitude) { if (null !== $tag && null !== $latitude && null !== $longitude) {
// create location object. // create location object.
$location = new Location(); $location = new Location();

View File

@@ -29,7 +29,6 @@ use Exception;
use FireflyIII\Exceptions\DuplicateTransactionException; use FireflyIII\Exceptions\DuplicateTransactionException;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\Preference;
use FireflyIII\Models\Transaction; use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency; use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\TransactionJournal;
@@ -426,20 +425,20 @@ class TransactionJournalFactory
app('log')->debug('Both accounts exist, simply return them.'); app('log')->debug('Both accounts exist, simply return them.');
return [$sourceAccount, $destinationAccount]; return [$sourceAccount, $destinationAccount];
} }
if (null !== $sourceAccount && null === $destinationAccount) { if (null === $destinationAccount) { // @phpstan-ignore-line
app('log')->debug('Destination account is NULL, source account is not.'); app('log')->debug('Destination account is NULL, source account is not.');
$account = $this->accountRepository->getReconciliation($sourceAccount); $account = $this->accountRepository->getReconciliation($sourceAccount);
app('log')->debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type)); app('log')->debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type));
return [$sourceAccount, $account]; return [$sourceAccount, $account];
} }
if (null === $sourceAccount && null !== $destinationAccount) { if (null === $sourceAccount) { // @phpstan-ignore-line
app('log')->debug('Source account is NULL, destination account is not.'); app('log')->debug('Source account is NULL, destination account is not.');
$account = $this->accountRepository->getReconciliation($destinationAccount); $account = $this->accountRepository->getReconciliation($destinationAccount);
app('log')->debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type)); app('log')->debug(sprintf('Will return account #%d ("%s") of type "%s"', $account->id, $account->name, $account->accountType->type));
return [$account, $destinationAccount]; return [$account, $destinationAccount];
} }
app('log')->debug('Unused fallback'); app('log')->debug('Unused fallback'); // @phpstan-ignore-line
return [$sourceAccount, $destinationAccount]; return [$sourceAccount, $destinationAccount];
} }

View File

@@ -50,7 +50,7 @@ class APIEventHandler
if (null !== $user) { if (null !== $user) {
try { try {
Notification::send($user, new NewAccessToken()); Notification::send($user, new NewAccessToken());
} catch (Exception $e) { /** @phpstan-ignore-line */ } catch (Exception $e) { // @phpstan-ignore-line
$message = $e->getMessage(); $message = $e->getMessage();
if (str_contains($message, 'Bcc')) { if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');

View File

@@ -31,7 +31,6 @@ use FireflyIII\Notifications\Admin\TestNotification;
use FireflyIII\Notifications\Admin\UserInvitation; use FireflyIII\Notifications\Admin\UserInvitation;
use FireflyIII\Notifications\Admin\VersionCheckResult; use FireflyIII\Notifications\Admin\VersionCheckResult;
use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Facades\FireflyConfig;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
/** /**
@@ -58,7 +57,7 @@ class AdminEventHandler
if ($repository->hasRole($user, 'owner')) { if ($repository->hasRole($user, 'owner')) {
try { try {
Notification::send($user, new UserInvitation($event->invitee)); Notification::send($user, new UserInvitation($event->invitee));
} catch (Exception $e) { /** @phpstan-ignore-line */ } catch (Exception $e) { // @phpstan-ignore-line
$message = $e->getMessage(); $message = $e->getMessage();
if (str_contains($message, 'Bcc')) { if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
@@ -96,7 +95,7 @@ class AdminEventHandler
if ($repository->hasRole($user, 'owner')) { if ($repository->hasRole($user, 'owner')) {
try { try {
Notification::send($user, new VersionCheckResult($event->message)); Notification::send($user, new VersionCheckResult($event->message));
} catch (Exception $e) { /** @phpstan-ignore-line */ } catch (Exception $e) {// @phpstan-ignore-line
$message = $e->getMessage(); $message = $e->getMessage();
if (str_contains($message, 'Bcc')) { if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
@@ -130,7 +129,7 @@ class AdminEventHandler
} }
try { try {
Notification::send($event->user, new TestNotification($event->user->email)); Notification::send($event->user, new TestNotification($event->user->email));
} catch (Exception $e) { /** @phpstan-ignore-line */ } catch (Exception $e) { // @phpstan-ignore-line
$message = $e->getMessage(); $message = $e->getMessage();
if (str_contains($message, 'Bcc')) { if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');

View File

@@ -75,7 +75,7 @@ class AutomationHandler
} }
try { try {
Notification::send($user, new TransactionCreation($groups)); Notification::send($user, new TransactionCreation($groups));
} catch (Exception $e) { /** @phpstan-ignore-line */ } catch (Exception $e) { // @phpstan-ignore-line
$message = $e->getMessage(); $message = $e->getMessage();
if (str_contains($message, 'Bcc')) { if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');

View File

@@ -51,7 +51,7 @@ class BillEventHandler
app('log')->debug('Bill reminder is true!'); app('log')->debug('Bill reminder is true!');
try { try {
Notification::send($bill->user, new BillReminder($bill, $event->field, $event->diff)); Notification::send($bill->user, new BillReminder($bill, $event->field, $event->diff));
} catch (Exception $e) { /** @phpstan-ignore-line */ } catch (Exception $e) { // @phpstan-ignore-line
$message = $e->getMessage(); $message = $e->getMessage();
if (str_contains($message, 'Bcc')) { if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');

View File

@@ -93,7 +93,7 @@ class BudgetLimitHandler
$viewRange = '1M'; $viewRange = '1M';
} }
// safety catch // safety catch
if(null === $viewRange || is_array($viewRange)){ if (null === $viewRange || is_array($viewRange)) {
$viewRange = '1M'; $viewRange = '1M';
} }
$viewRange = (string)$viewRange; $viewRange = (string)$viewRange;

View File

@@ -131,7 +131,7 @@ class UserEventHandler
$group = null; $group = null;
// create a new group. // create a new group.
while (true === $groupExists) { /** @phpstan-ignore-line */ while (true === $groupExists) { // @phpstan-ignore-line
$groupExists = UserGroup::where('title', $groupTitle)->count() > 0; $groupExists = UserGroup::where('title', $groupTitle)->count() > 0;
if (false === $groupExists) { if (false === $groupExists) {
$group = UserGroup::create(['title' => $groupTitle]); $group = UserGroup::create(['title' => $groupTitle]);
@@ -205,7 +205,7 @@ class UserEventHandler
if (false === $entry['notified']) { if (false === $entry['notified']) {
try { try {
Notification::send($user, new UserLogin($ipAddress)); Notification::send($user, new UserLogin($ipAddress));
} catch (Exception $e) {/** @phpstan-ignore-line */ } catch (Exception $e) { // @phpstan-ignore-line
$message = $e->getMessage(); $message = $e->getMessage();
if (str_contains($message, 'Bcc')) { if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
@@ -239,7 +239,7 @@ class UserEventHandler
if ($repository->hasRole($user, 'owner')) { if ($repository->hasRole($user, 'owner')) {
try { try {
Notification::send($user, new AdminRegistrationNotification($event->user)); Notification::send($user, new AdminRegistrationNotification($event->user));
} catch (Exception $e) { /** @phpstan-ignore-line */ } catch (Exception $e) { // @phpstan-ignore-line
$message = $e->getMessage(); $message = $e->getMessage();
if (str_contains($message, 'Bcc')) { if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
@@ -316,7 +316,7 @@ class UserEventHandler
{ {
try { try {
Notification::send($event->user, new UserNewPassword(route('password.reset', [$event->token]))); Notification::send($event->user, new UserNewPassword(route('password.reset', [$event->token])));
} catch (Exception $e) { /** @phpstan-ignore-line */ } catch (Exception $e) { // @phpstan-ignore-line
$message = $e->getMessage(); $message = $e->getMessage();
if (str_contains($message, 'Bcc')) { if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
@@ -364,7 +364,7 @@ class UserEventHandler
if ($sendMail) { if ($sendMail) {
try { try {
Notification::send($event->user, new UserRegistrationNotification()); Notification::send($event->user, new UserRegistrationNotification());
} catch (Exception $e) { /** @phpstan-ignore-line */ } catch (Exception $e) { // @phpstan-ignore-line
$message = $e->getMessage(); $message = $e->getMessage();
if (str_contains($message, 'Bcc')) { if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.'); app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');

View File

@@ -56,9 +56,9 @@ trait AttachmentCollection
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = str_contains(strtolower($attachment['filename']), strtolower($name)) || str_contains( $result = str_contains(strtolower($attachment['filename']), strtolower($name)) || str_contains(
strtolower($attachment['title']), strtolower($attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {
return true; return true;
} }
@@ -142,9 +142,9 @@ trait AttachmentCollection
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = !str_contains(strtolower($attachment['filename']), strtolower($name)) && !str_contains( $result = !str_contains(strtolower($attachment['filename']), strtolower($name)) && !str_contains(
strtolower($attachment['title']), strtolower($attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {
return true; return true;
} }
@@ -179,9 +179,9 @@ trait AttachmentCollection
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = !str_ends_with(strtolower($attachment['filename']), strtolower($name)) && !str_ends_with( $result = !str_ends_with(strtolower($attachment['filename']), strtolower($name)) && !str_ends_with(
strtolower($attachment['title']), strtolower($attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {
return true; return true;
} }
@@ -216,9 +216,9 @@ trait AttachmentCollection
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = !str_starts_with(strtolower($attachment['filename']), strtolower($name)) && !str_starts_with( $result = !str_starts_with(strtolower($attachment['filename']), strtolower($name)) && !str_starts_with(
strtolower($attachment['title']), strtolower($attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {
return true; return true;
} }
@@ -246,9 +246,9 @@ trait AttachmentCollection
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = str_ends_with(strtolower($attachment['filename']), strtolower($name)) || str_ends_with( $result = str_ends_with(strtolower($attachment['filename']), strtolower($name)) || str_ends_with(
strtolower($attachment['title']), strtolower($attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {
return true; return true;
} }
@@ -330,9 +330,9 @@ trait AttachmentCollection
/** @var array $attachment */ /** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) { foreach ($transaction['attachments'] as $attachment) {
$result = str_starts_with(strtolower($attachment['filename']), strtolower($name)) || str_starts_with( $result = str_starts_with(strtolower($attachment['filename']), strtolower($name)) || str_starts_with(
strtolower($attachment['title']), strtolower($attachment['title']),
strtolower($name) strtolower($name)
); );
if (true === $result) { if (true === $result) {
return true; return true;
} }

View File

@@ -102,7 +102,10 @@ class NetWorth implements NetWorthInterface
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
app('log')->debug(sprintf('Now at account #%d ("%s")', $account->id, $account->name)); app('log')->debug(sprintf('Now at account #%d ("%s")', $account->id, $account->name));
$currency = $this->getRepository()->getAccountCurrency($account); $currency = $this->getRepository()->getAccountCurrency($account);
if (null === $currency) {
$currency = app('amount')->getDefaultCurrency();
}
$currencyId = $currency->id; $currencyId = $currency->id;
$balance = '0'; $balance = '0';
$nativeBalance = '0'; $nativeBalance = '0';
@@ -118,7 +121,7 @@ class NetWorth implements NetWorthInterface
$nativeVirtualBalance = $converter->convert($default, $currency, $account->created_at, $virtualBalance); $nativeVirtualBalance = $converter->convert($default, $currency, $account->created_at, $virtualBalance);
$nativeBalance = bcsub($nativeBalance, $nativeVirtualBalance); $nativeBalance = bcsub($nativeBalance, $nativeVirtualBalance);
} }
$netWorth[$currencyId] = $netWorth[$currencyId] ?? [ $netWorth[$currencyId] ??= [
'balance' => '0', 'balance' => '0',
'native_balance' => '0', 'native_balance' => '0',
'currency_id' => $currencyId, 'currency_id' => $currencyId,
@@ -205,7 +208,7 @@ class NetWorth implements NetWorthInterface
$balance = bcsub($balance, $virtualBalance); $balance = bcsub($balance, $virtualBalance);
} }
$return[$currency->id] = $return[$currency->id] ?? [ $return[$currency->id] ??= [
'id' => (string)$currency->id, 'id' => (string)$currency->id,
'name' => $currency->name, 'name' => $currency->name,
'symbol' => $currency->symbol, 'symbol' => $currency->symbol,

View File

@@ -152,7 +152,7 @@ class CreateController extends Controller
// update preferences if necessary: // update preferences if necessary:
$frontPage = app('preferences')->get('frontPageAccounts', [])->data; $frontPage = app('preferences')->get('frontPageAccounts', [])->data;
if(!is_array($frontPage)) { if (!is_array($frontPage)) {
$frontPage = []; $frontPage = [];
} }
if (AccountType::ASSET === $account->accountType->type) { if (AccountType::ASSET === $account->accountType->type) {

View File

@@ -94,7 +94,7 @@ class EditController extends Controller
$hasLocation = null !== $location; $hasLocation = null !== $location;
$locations = [ $locations = [
'location' => [ 'location' => [
'latitude' => null !== old('location_latitude') ? old('location_latitude'): $latitude, 'latitude' => null !== old('location_latitude') ? old('location_latitude') : $latitude,
'longitude' => null !== old('location_longitude') ? old('location_longitude') : $longitude, 'longitude' => null !== old('location_longitude') ? old('location_longitude') : $longitude,
'zoom_level' => null !== old('location_zoom_level') ? old('location_zoom_level') : $zoomLevel, 'zoom_level' => null !== old('location_zoom_level') ? old('location_zoom_level') : $zoomLevel,
'has_location' => $hasLocation || 'true' === old('location_has_location'), 'has_location' => $hasLocation || 'true' === old('location_has_location'),

View File

@@ -97,9 +97,9 @@ class ShowController extends Controller
} }
/** @var Carbon $start */ /** @var Carbon $start */
$start = $start ?? session('start'); $start ??= session('start');
/** @var Carbon $end */ /** @var Carbon $end */
$end = $end ?? session('end'); $end ??= session('end');
if ($end < $start) { if ($end < $start) {
[$start, $end] = [$end, $start]; [$start, $end] = [$end, $start];

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Http\Controllers\Admin;
use FireflyIII\Events\AdminRequestedTestMessage; use FireflyIII\Events\AdminRequestedTestMessage;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Http\Middleware\IsDemoUser; use FireflyIII\Http\Middleware\IsDemoUser;
use FireflyIII\Support\Facades\FireflyConfig;
use FireflyIII\Support\Notifications\UrlValidator; use FireflyIII\Support\Notifications\UrlValidator;
use FireflyIII\User; use FireflyIII\User;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;

View File

@@ -170,7 +170,7 @@ class UserController extends Controller
$subTitle = (string)trans('firefly.user_administration'); $subTitle = (string)trans('firefly.user_administration');
$subTitleIcon = 'fa-users'; $subTitleIcon = 'fa-users';
$users = $this->repository->all(); $users = $this->repository->all();
$singleUserMode = (bool) app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data; $singleUserMode = (bool)app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;
$allowInvites = false; $allowInvites = false;
if (!$this->externalIdentity && $singleUserMode) { if (!$this->externalIdentity && $singleUserMode) {
// also registration enabled. // also registration enabled.

View File

@@ -127,7 +127,7 @@ class AttachmentController extends Controller
->header('Expires', '0') ->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public') ->header('Pragma', 'public')
->header('Content-Length', (string) strlen($content)); ->header('Content-Length', (string)strlen($content));
return $response; return $response;
} }

View File

@@ -170,7 +170,7 @@ class TwoFactorController extends Controller
private function isBackupCode(string $mfaCode): bool private function isBackupCode(string $mfaCode): bool
{ {
$list = app('preferences')->get('mfa_recovery', [])->data; $list = app('preferences')->get('mfa_recovery', [])->data;
if(!is_array($list)) { if (!is_array($list)) {
$list = []; $list = [];
} }
if (in_array($mfaCode, $list, true)) { if (in_array($mfaCode, $list, true)) {
@@ -187,8 +187,8 @@ class TwoFactorController extends Controller
*/ */
private function removeFromBackupCodes(string $mfaCode): void private function removeFromBackupCodes(string $mfaCode): void
{ {
$list = app('preferences')->get('mfa_recovery', [])->data; $list = app('preferences')->get('mfa_recovery', [])->data;
if(!is_array($list)) { if (!is_array($list)) {
$list = []; $list = [];
} }
$newList = array_values(array_diff($list, [$mfaCode])); $newList = array_values(array_diff($list, [$mfaCode]));

View File

@@ -109,7 +109,7 @@ class IndexController extends Controller
$array = $transformer->transform($bill); $array = $transformer->transform($bill);
$groupOrder = (int)$array['object_group_order']; $groupOrder = (int)$array['object_group_order'];
// make group array if necessary: // make group array if necessary:
$bills[$groupOrder] = $bills[$groupOrder] ?? [ $bills[$groupOrder] ??= [
'object_group_id' => $array['object_group_id'], 'object_group_id' => $array['object_group_id'],
'object_group_title' => $array['object_group_title'], 'object_group_title' => $array['object_group_title'],
'bills' => [], 'bills' => [],
@@ -159,7 +159,7 @@ class IndexController extends Controller
} }
$currencyId = $bill['currency_id']; $currencyId = $bill['currency_id'];
$sums[$groupOrder][$currencyId] = $sums[$groupOrder][$currencyId] ?? [ $sums[$groupOrder][$currencyId] ??= [
'currency_id' => $currencyId, 'currency_id' => $currencyId,
'currency_code' => $bill['currency_code'], 'currency_code' => $bill['currency_code'],
'currency_name' => $bill['currency_name'], 'currency_name' => $bill['currency_name'],
@@ -249,7 +249,7 @@ class IndexController extends Controller
* @var array $entry * @var array $entry
*/ */
foreach ($array as $currencyId => $entry) { foreach ($array as $currencyId => $entry) {
$totals[$currencyId] = $totals[$currencyId] ?? [ $totals[$currencyId] ??= [
'currency_id' => $currencyId, 'currency_id' => $currencyId,
'currency_code' => $entry['currency_code'], 'currency_code' => $entry['currency_code'],
'currency_name' => $entry['currency_name'], 'currency_name' => $entry['currency_name'],

View File

@@ -135,8 +135,8 @@ class BudgetLimitController extends Controller
if (null === $currency || null === $budget) { if (null === $currency || null === $budget) {
throw new FireflyException('No valid currency or budget.'); throw new FireflyException('No valid currency or budget.');
} }
$start = Carbon::createFromFormat('Y-m-d', $request->get('start')); $start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->get('end')); $end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
if (false === $start || false === $end) { if (false === $start || false === $end) {
return response()->json([]); return response()->json([]);

View File

@@ -105,14 +105,14 @@ class IndexController extends Controller
$range = app('navigation')->getViewRange(true); $range = app('navigation')->getViewRange(true);
$isCustomRange = session('is_custom_range', false); $isCustomRange = session('is_custom_range', false);
if (false === $isCustomRange) { if (false === $isCustomRange) {
$start = $start ?? session('start', today(config('app.timezone'))->startOfMonth()); $start ??= session('start', today(config('app.timezone'))->startOfMonth());
$end = $end ?? app('navigation')->endOfPeriod($start, $range); $end ??= app('navigation')->endOfPeriod($start, $range);
} }
// overrule start and end if necessary: // overrule start and end if necessary:
if (true === $isCustomRange) { if (true === $isCustomRange) {
$start = $start ?? session('start', today(config('app.timezone'))->startOfMonth()); $start ??= session('start', today(config('app.timezone'))->startOfMonth());
$end = $end ?? session('end', today(config('app.timezone'))->endOfMonth()); $end ??= session('end', today(config('app.timezone'))->endOfMonth());
} }
@@ -135,7 +135,7 @@ class IndexController extends Controller
// get budgeted for default currency: // get budgeted for default currency:
if (0 === count($availableBudgets)) { if (0 === count($availableBudgets)) {
$budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency,); $budgeted = $this->blRepository->budgeted($start, $end, $defaultCurrency, );
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency); $spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $defaultCurrency);
$spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0'; $spent = $spentArr[$defaultCurrency->id]['sum'] ?? '0';
unset($spentArr); unset($spentArr);
@@ -194,7 +194,7 @@ class IndexController extends Controller
$array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0'; $array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0';
// budgeted in period: // budgeted in period:
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency,); $budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency, );
$array['budgeted'] = $budgeted; $array['budgeted'] = $budgeted;
$availableBudgets[] = $array; $availableBudgets[] = $array;
unset($spentArr); unset($spentArr);
@@ -283,13 +283,12 @@ class IndexController extends Controller
foreach ($budget['spent'] as $spent) { foreach ($budget['spent'] as $spent) {
$currencyId = $spent['currency_id']; $currencyId = $spent['currency_id'];
$sums['spent'][$currencyId] $sums['spent'][$currencyId]
= $sums['spent'][$currencyId] ??= [
?? [ 'amount' => '0',
'amount' => '0', 'currency_id' => $spent['currency_id'],
'currency_id' => $spent['currency_id'], 'currency_symbol' => $spent['currency_symbol'],
'currency_symbol' => $spent['currency_symbol'], 'currency_decimal_places' => $spent['currency_decimal_places'],
'currency_decimal_places' => $spent['currency_decimal_places'], ];
];
$sums['spent'][$currencyId]['amount'] = bcadd($sums['spent'][$currencyId]['amount'], $spent['spent']); $sums['spent'][$currencyId]['amount'] = bcadd($sums['spent'][$currencyId]['amount'], $spent['spent']);
} }
@@ -297,23 +296,22 @@ class IndexController extends Controller
foreach ($budget['budgeted'] as $budgeted) { foreach ($budget['budgeted'] as $budgeted) {
$currencyId = $budgeted['currency_id']; $currencyId = $budgeted['currency_id'];
$sums['budgeted'][$currencyId] $sums['budgeted'][$currencyId]
= $sums['budgeted'][$currencyId] ??= [
?? [ 'amount' => '0',
'amount' => '0', 'currency_id' => $budgeted['currency_id'],
'currency_id' => $budgeted['currency_id'], 'currency_symbol' => $budgeted['currency_symbol'],
'currency_symbol' => $budgeted['currency_symbol'], 'currency_decimal_places' => $budgeted['currency_decimal_places'],
'currency_decimal_places' => $budgeted['currency_decimal_places'], ];
];
$sums['budgeted'][$currencyId]['amount'] = bcadd($sums['budgeted'][$currencyId]['amount'], $budgeted['amount']); $sums['budgeted'][$currencyId]['amount'] = bcadd($sums['budgeted'][$currencyId]['amount'], $budgeted['amount']);
// also calculate how much left from budgeted: // also calculate how much left from budgeted:
$sums['left'][$currencyId] = $sums['left'][$currencyId] $sums['left'][$currencyId]
?? [ ??= [
'amount' => '0', 'amount' => '0',
'currency_id' => $budgeted['currency_id'], 'currency_id' => $budgeted['currency_id'],
'currency_symbol' => $budgeted['currency_symbol'], 'currency_symbol' => $budgeted['currency_symbol'],
'currency_decimal_places' => $budgeted['currency_decimal_places'], 'currency_decimal_places' => $budgeted['currency_decimal_places'],
]; ];
} }
} }
// final calculation for 'left': // final calculation for 'left':

View File

@@ -88,9 +88,9 @@ class ShowController extends Controller
public function noBudget(Request $request, Carbon $start = null, Carbon $end = null) public function noBudget(Request $request, Carbon $start = null, Carbon $end = null)
{ {
/** @var Carbon $start */ /** @var Carbon $start */
$start = $start ?? session('start'); $start ??= session('start');
/** @var Carbon $end */ /** @var Carbon $end */
$end = $end ?? session('end'); $end ??= session('end');
$subTitle = trans( $subTitle = trans(
'firefly.without_budget_between', 'firefly.without_budget_between',
['start' => $start->isoFormat($this->monthAndDayFormat), 'end' => $end->isoFormat($this->monthAndDayFormat)] ['start' => $start->isoFormat($this->monthAndDayFormat), 'end' => $end->isoFormat($this->monthAndDayFormat)]

View File

@@ -84,9 +84,9 @@ class NoCategoryController extends Controller
{ {
app('log')->debug('Start of noCategory()'); app('log')->debug('Start of noCategory()');
/** @var Carbon $start */ /** @var Carbon $start */
$start = $start ?? session('start'); $start ??= session('start');
/** @var Carbon $end */ /** @var Carbon $end */
$end = $end ?? session('end'); $end ??= session('end');
$page = (int)$request->get('page'); $page = (int)$request->get('page');
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data; $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
$subTitle = trans( $subTitle = trans(

View File

@@ -86,9 +86,9 @@ class ShowController extends Controller
public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null) public function show(Request $request, Category $category, Carbon $start = null, Carbon $end = null)
{ {
/** @var Carbon $start */ /** @var Carbon $start */
$start = $start ?? session('start', today(config('app.timezone'))->startOfMonth()); $start ??= session('start', today(config('app.timezone'))->startOfMonth());
/** @var Carbon $end */ /** @var Carbon $end */
$end = $end ?? session('end', today(config('app.timezone'))->endOfMonth()); $end ??= session('end', today(config('app.timezone'))->endOfMonth());
$subTitleIcon = 'fa-bookmark'; $subTitleIcon = 'fa-bookmark';
$page = (int)$request->get('page'); $page = (int)$request->get('page');
$attachments = $this->repository->getAttachments($category); $attachments = $this->repository->getAttachments($category);

View File

@@ -125,7 +125,7 @@ class AccountController extends Controller
// grab the difference and find the currency. // grab the difference and find the currency.
$startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0'); $startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');
$diff = bcsub((string)$endAmount, $startAmount); $diff = bcsub((string)$endAmount, $startAmount);
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId); $currencies[$currencyId] ??= $this->currencyRepository->find($currencyId);
if (0 !== bccomp($diff, '0')) { if (0 !== bccomp($diff, '0')) {
// store the values in a temporary array. // store the values in a temporary array.
$tempData[] = [ $tempData[] = [
@@ -585,7 +585,7 @@ class AccountController extends Controller
// grab the difference and find the currency. // grab the difference and find the currency.
$startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0'); $startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');
$diff = bcsub((string)$endAmount, $startAmount); $diff = bcsub((string)$endAmount, $startAmount);
$currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId); $currencies[$currencyId] ??= $this->currencyRepository->find($currencyId);
if (0 !== bccomp($diff, '0')) { if (0 !== bccomp($diff, '0')) {
// store the values in a temporary array. // store the values in a temporary array.
$tempData[] = [ $tempData[] = [

View File

@@ -117,7 +117,7 @@ class BudgetController extends Controller
foreach ($spent as $row) { foreach ($spent as $row) {
$currencyId = $row['currency_id']; $currencyId = $row['currency_id'];
$currencies[$currencyId] = $currencies[$currencyId] ?? $row; // don't mind the field 'sum' $currencies[$currencyId] ??= $row; // don't mind the field 'sum'
// also store this day's sum: // also store this day's sum:
$currencies[$currencyId]['spent'][$label] = $row['sum']; $currencies[$currencyId]['spent'][$label] = $row['sum'];
} }
@@ -237,7 +237,7 @@ class BudgetController extends Controller
// group by asset account ID: // group by asset account ID:
foreach ($journals as $journal) { foreach ($journals as $journal) {
$key = sprintf('%d-%d', (int)$journal['source_account_id'], $journal['currency_id']); $key = sprintf('%d-%d', (int)$journal['source_account_id'], $journal['currency_id']);
$result[$key] = $result[$key] ?? [ $result[$key] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $journal['currency_symbol'], 'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],
@@ -302,7 +302,7 @@ class BudgetController extends Controller
$chartData = []; $chartData = [];
foreach ($journals as $journal) { foreach ($journals as $journal) {
$key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']); $key = sprintf('%d-%d', $journal['category_id'], $journal['currency_id']);
$result[$key] = $result[$key] ?? [ $result[$key] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $journal['currency_symbol'], 'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],
@@ -367,7 +367,7 @@ class BudgetController extends Controller
/** @var array $journal */ /** @var array $journal */
foreach ($journals as $journal) { foreach ($journals as $journal) {
$key = sprintf('%d-%d', $journal['destination_account_id'], $journal['currency_id']); $key = sprintf('%d-%d', $journal['destination_account_id'], $journal['currency_id']);
$result[$key] = $result[$key] ?? [ $result[$key] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $journal['currency_symbol'], 'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],

View File

@@ -87,7 +87,7 @@ class BudgetReportController extends Controller
foreach ($spent as $currency) { foreach ($spent as $currency) {
foreach ($currency['budgets'] as $budget) { foreach ($currency['budgets'] as $budget) {
$title = sprintf('%s (%s)', $budget['name'], $currency['currency_name']); $title = sprintf('%s (%s)', $budget['name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -124,7 +124,7 @@ class BudgetReportController extends Controller
foreach ($budget['transaction_journals'] as $journal) { foreach ($budget['transaction_journals'] as $journal) {
$categoryName = $journal['category_name'] ?? trans('firefly.no_category'); $categoryName = $journal['category_name'] ?? trans('firefly.no_category');
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']); $title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -161,7 +161,7 @@ class BudgetReportController extends Controller
foreach ($currency['budgets'] as $budget) { foreach ($currency['budgets'] as $budget) {
foreach ($budget['transaction_journals'] as $journal) { foreach ($budget['transaction_journals'] as $journal) {
$title = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']); $title = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -198,7 +198,7 @@ class BudgetReportController extends Controller
foreach ($spent as $currency) { foreach ($spent as $currency) {
// add things to chart Data for each currency: // add things to chart Data for each currency:
$spentKey = sprintf('%d-spent', $currency['currency_id']); $spentKey = sprintf('%d-spent', $currency['currency_id']);
$chartData[$spentKey] = $chartData[$spentKey] ?? [ $chartData[$spentKey] ??= [
'label' => sprintf( 'label' => sprintf(
'%s (%s)', '%s (%s)',
(string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]), (string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),
@@ -215,7 +215,7 @@ class BudgetReportController extends Controller
foreach ($currentBudget['transaction_journals'] as $journal) { foreach ($currentBudget['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format); $key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']); $amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0'; $chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount); $chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
} }
} }
@@ -269,7 +269,7 @@ class BudgetReportController extends Controller
foreach ($currency['budgets'] as $budget) { foreach ($currency['budgets'] as $budget) {
foreach ($budget['transaction_journals'] as $journal) { foreach ($budget['transaction_journals'] as $journal) {
$title = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']); $title = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],

View File

@@ -235,7 +235,7 @@ class CategoryController extends Controller
foreach ($outSet['transaction_journals'] as $journal) { foreach ($outSet['transaction_journals'] as $journal) {
$amount = app('steam')->positive($journal['amount']); $amount = app('steam')->positive($journal['amount']);
$date = $journal['date']->isoFormat($format); $date = $journal['date']->isoFormat($format);
$chartData[$outKey]['entries'][$date] = $chartData[$outKey]['entries'][$date] ?? '0'; $chartData[$outKey]['entries'][$date] ??= '0';
$chartData[$outKey]['entries'][$date] = bcadd($amount, $chartData[$outKey]['entries'][$date]); $chartData[$outKey]['entries'][$date] = bcadd($amount, $chartData[$outKey]['entries'][$date]);
} }
@@ -244,7 +244,7 @@ class CategoryController extends Controller
foreach ($inSet['transaction_journals'] as $journal) { foreach ($inSet['transaction_journals'] as $journal) {
$amount = app('steam')->positive($journal['amount']); $amount = app('steam')->positive($journal['amount']);
$date = $journal['date']->isoFormat($format); $date = $journal['date']->isoFormat($format);
$chartData[$inKey]['entries'][$date] = $chartData[$inKey]['entries'][$date] ?? '0'; $chartData[$inKey]['entries'][$date] ??= '0';
$chartData[$inKey]['entries'][$date] = bcadd($amount, $chartData[$inKey]['entries'][$date]); $chartData[$inKey]['entries'][$date] = bcadd($amount, $chartData[$inKey]['entries'][$date]);
} }
} }

View File

@@ -86,7 +86,7 @@ class CategoryReportController extends Controller
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
$objectName = $journal['budget_name'] ?? trans('firefly.no_budget'); $objectName = $journal['budget_name'] ?? trans('firefly.no_budget');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -120,7 +120,7 @@ class CategoryReportController extends Controller
/** @var array $category */ /** @var array $category */
foreach ($currency['categories'] as $category) { foreach ($currency['categories'] as $category) {
$title = sprintf('%s (%s)', $category['name'], $currency['currency_name']); $title = sprintf('%s (%s)', $category['name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -155,7 +155,7 @@ class CategoryReportController extends Controller
/** @var array $category */ /** @var array $category */
foreach ($currency['categories'] as $category) { foreach ($currency['categories'] as $category) {
$title = sprintf('%s (%s)', $category['name'], $currency['currency_name']); $title = sprintf('%s (%s)', $category['name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -192,7 +192,7 @@ class CategoryReportController extends Controller
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty'); $objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -228,7 +228,7 @@ class CategoryReportController extends Controller
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty'); $objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -264,7 +264,7 @@ class CategoryReportController extends Controller
foreach ($spent as $currency) { foreach ($spent as $currency) {
// add things to chart Data for each currency: // add things to chart Data for each currency:
$spentKey = sprintf('%d-spent', $currency['currency_id']); $spentKey = sprintf('%d-spent', $currency['currency_id']);
$chartData[$spentKey] = $chartData[$spentKey] ?? [ $chartData[$spentKey] ??= [
'label' => sprintf( 'label' => sprintf(
'%s (%s)', '%s (%s)',
(string)trans('firefly.spent_in_specific_category', ['category' => $category->name]), (string)trans('firefly.spent_in_specific_category', ['category' => $category->name]),
@@ -281,7 +281,7 @@ class CategoryReportController extends Controller
foreach ($currentCategory['transaction_journals'] as $journal) { foreach ($currentCategory['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format); $key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']); $amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0'; $chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount); $chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
} }
} }
@@ -291,7 +291,7 @@ class CategoryReportController extends Controller
foreach ($earned as $currency) { foreach ($earned as $currency) {
// add things to chart Data for each currency: // add things to chart Data for each currency:
$spentKey = sprintf('%d-earned', $currency['currency_id']); $spentKey = sprintf('%d-earned', $currency['currency_id']);
$chartData[$spentKey] = $chartData[$spentKey] ?? [ $chartData[$spentKey] ??= [
'label' => sprintf( 'label' => sprintf(
'%s (%s)', '%s (%s)',
(string)trans('firefly.earned_in_specific_category', ['category' => $category->name]), (string)trans('firefly.earned_in_specific_category', ['category' => $category->name]),
@@ -308,7 +308,7 @@ class CategoryReportController extends Controller
foreach ($currentCategory['transaction_journals'] as $journal) { foreach ($currentCategory['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format); $key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']); $amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0'; $chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount); $chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
} }
} }
@@ -364,7 +364,7 @@ class CategoryReportController extends Controller
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
$objectName = $journal['source_account_name'] ?? trans('firefly.empty'); $objectName = $journal['source_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -400,7 +400,7 @@ class CategoryReportController extends Controller
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
$objectName = $journal['source_account_name'] ?? trans('firefly.empty'); $objectName = $journal['source_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],

View File

@@ -85,7 +85,7 @@ class DoubleReportController extends Controller
foreach ($currency['transaction_journals'] as $journal) { foreach ($currency['transaction_journals'] as $journal) {
$categoryName = $journal['budget_name'] ?? trans('firefly.no_budget'); $categoryName = $journal['budget_name'] ?? trans('firefly.no_budget');
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']); $title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -120,7 +120,7 @@ class DoubleReportController extends Controller
foreach ($currency['transaction_journals'] as $journal) { foreach ($currency['transaction_journals'] as $journal) {
$categoryName = $journal['category_name'] ?? trans('firefly.no_category'); $categoryName = $journal['category_name'] ?? trans('firefly.no_category');
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']); $title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -155,7 +155,7 @@ class DoubleReportController extends Controller
foreach ($currency['transaction_journals'] as $journal) { foreach ($currency['transaction_journals'] as $journal) {
$categoryName = $journal['category_name'] ?? trans('firefly.no_category'); $categoryName = $journal['category_name'] ?? trans('firefly.no_category');
$title = sprintf('%s (%s)', $categoryName, $currency['currency_name']); $title = sprintf('%s (%s)', $categoryName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -195,7 +195,7 @@ class DoubleReportController extends Controller
$spentKey = sprintf('%d-spent', $currency['currency_id']); $spentKey = sprintf('%d-spent', $currency['currency_id']);
$name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban); $name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban);
$chartData[$spentKey] = $chartData[$spentKey] ?? [ $chartData[$spentKey] ??= [
'label' => sprintf( 'label' => sprintf(
'%s (%s)', '%s (%s)',
(string)trans('firefly.spent_in_specific_double', ['account' => $name]), (string)trans('firefly.spent_in_specific_double', ['account' => $name]),
@@ -211,7 +211,7 @@ class DoubleReportController extends Controller
foreach ($currency['transaction_journals'] as $journal) { foreach ($currency['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format); $key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']); $amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0'; $chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount); $chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
} }
} }
@@ -221,7 +221,7 @@ class DoubleReportController extends Controller
$earnedKey = sprintf('%d-earned', $currency['currency_id']); $earnedKey = sprintf('%d-earned', $currency['currency_id']);
$name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban); $name = $this->getCounterpartName($accounts, $account->id, $account->name, $account->iban);
$chartData[$earnedKey] = $chartData[$earnedKey] ?? [ $chartData[$earnedKey] ??= [
'label' => sprintf( 'label' => sprintf(
'%s (%s)', '%s (%s)',
(string)trans('firefly.earned_in_specific_double', ['account' => $name]), (string)trans('firefly.earned_in_specific_double', ['account' => $name]),
@@ -237,7 +237,7 @@ class DoubleReportController extends Controller
foreach ($currency['transaction_journals'] as $journal) { foreach ($currency['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format); $key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']); $amount = app('steam')->positive($journal['amount']);
$chartData[$earnedKey]['entries'][$key] = $chartData[$earnedKey]['entries'][$key] ?? '0'; $chartData[$earnedKey]['entries'][$key] ??= '0';
$chartData[$earnedKey]['entries'][$key] = bcadd($chartData[$earnedKey]['entries'][$key], $amount); $chartData[$earnedKey]['entries'][$key] = bcadd($chartData[$earnedKey]['entries'][$key], $amount);
} }
} }
@@ -323,7 +323,7 @@ class DoubleReportController extends Controller
// do something // do something
$tagName = trans('firefly.no_tags'); $tagName = trans('firefly.no_tags');
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']); $title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -341,7 +341,7 @@ class DoubleReportController extends Controller
// do something // do something
$tagName = $tag['name']; $tagName = $tag['name'];
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']); $title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -383,7 +383,7 @@ class DoubleReportController extends Controller
// do something // do something
$tagName = trans('firefly.no_tags'); $tagName = trans('firefly.no_tags');
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']); $title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -401,7 +401,7 @@ class DoubleReportController extends Controller
// do something // do something
$tagName = $tag['name']; $tagName = $tag['name'];
$title = sprintf('%s (%s)', $tagName, $currency['currency_name']); $title = sprintf('%s (%s)', $tagName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],

View File

@@ -147,7 +147,7 @@ class ExpenseReportController extends Controller
while ($currentStart < $end) { while ($currentStart < $end) {
$currentEnd = clone $currentStart; $currentEnd = clone $currentStart;
$currentEnd = $currentEnd->$function(); /** @phpstan-ignore-line */ $currentEnd = $currentEnd->$function(); // @phpstan-ignore-line
// get expenses grouped by opposing name: // get expenses grouped by opposing name:
$expenses = $this->groupByName($this->getExpensesForOpposing($accounts, $all, $currentStart, $currentEnd)); $expenses = $this->groupByName($this->getExpensesForOpposing($accounts, $all, $currentStart, $currentEnd));
@@ -166,8 +166,8 @@ class ExpenseReportController extends Controller
$currentExpense = $expenses[$name] ?? '0'; $currentExpense = $expenses[$name] ?? '0';
// add to sum: // add to sum:
$sumOfIncome[$exp->id] = $sumOfIncome[$exp->id] ?? '0'; $sumOfIncome[$exp->id] ??= '0';
$sumOfExpense[$exp->id] = $sumOfExpense[$exp->id] ?? '0'; $sumOfExpense[$exp->id] ??= '0';
$sumOfIncome[$exp->id] = bcadd($sumOfIncome[$exp->id], $currentIncome); $sumOfIncome[$exp->id] = bcadd($sumOfIncome[$exp->id], $currentIncome);
$sumOfExpense[$exp->id] = bcadd($sumOfExpense[$exp->id], $currentExpense); $sumOfExpense[$exp->id] = bcadd($sumOfExpense[$exp->id], $currentExpense);

View File

@@ -182,14 +182,14 @@ class ReportController extends Controller
foreach ($journals as $journal) { foreach ($journals as $journal) {
$period = $journal['date']->format($format); $period = $journal['date']->format($format);
$currencyId = (int)$journal['currency_id']; $currencyId = (int)$journal['currency_id'];
$data[$currencyId] = $data[$currencyId] ?? [ $data[$currencyId] ??= [
'currency_id' => $currencyId, 'currency_id' => $currencyId,
'currency_symbol' => $journal['currency_symbol'], 'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],
'currency_name' => $journal['currency_name'], 'currency_name' => $journal['currency_name'],
'currency_decimal_places' => (int)$journal['currency_decimal_places'], 'currency_decimal_places' => (int)$journal['currency_decimal_places'],
]; ];
$data[$currencyId][$period] = $data[$currencyId][$period] ?? [ $data[$currencyId][$period] ??= [
'period' => $period, 'period' => $period,
'spent' => '0', 'spent' => '0',
'earned' => '0', 'earned' => '0',

View File

@@ -87,7 +87,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['budget_name'] ?? trans('firefly.no_budget'); $objectName = $journal['budget_name'] ?? trans('firefly.no_budget');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -123,7 +123,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['category_name'] ?? trans('firefly.no_category'); $objectName = $journal['category_name'] ?? trans('firefly.no_category');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -159,7 +159,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['category_name'] ?? trans('firefly.no_category'); $objectName = $journal['category_name'] ?? trans('firefly.no_category');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -195,7 +195,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty'); $objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -231,7 +231,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['destination_account_name'] ?? trans('firefly.empty'); $objectName = $journal['destination_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -269,7 +269,7 @@ class TagReportController extends Controller
foreach ($spent as $currency) { foreach ($spent as $currency) {
// add things to chart Data for each currency: // add things to chart Data for each currency:
$spentKey = sprintf('%d-spent', $currency['currency_id']); $spentKey = sprintf('%d-spent', $currency['currency_id']);
$chartData[$spentKey] = $chartData[$spentKey] ?? [ $chartData[$spentKey] ??= [
'label' => sprintf( 'label' => sprintf(
'%s (%s)', '%s (%s)',
(string)trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]), (string)trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]),
@@ -286,7 +286,7 @@ class TagReportController extends Controller
foreach ($currentTag['transaction_journals'] as $journal) { foreach ($currentTag['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format); $key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']); $amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0'; $chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount); $chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
} }
} }
@@ -296,7 +296,7 @@ class TagReportController extends Controller
foreach ($earned as $currency) { foreach ($earned as $currency) {
// add things to chart Data for each currency: // add things to chart Data for each currency:
$spentKey = sprintf('%d-earned', $currency['currency_id']); $spentKey = sprintf('%d-earned', $currency['currency_id']);
$chartData[$spentKey] = $chartData[$spentKey] ?? [ $chartData[$spentKey] ??= [
'label' => sprintf( 'label' => sprintf(
'%s (%s)', '%s (%s)',
(string)trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]), (string)trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]),
@@ -313,7 +313,7 @@ class TagReportController extends Controller
foreach ($currentTag['transaction_journals'] as $journal) { foreach ($currentTag['transaction_journals'] as $journal) {
$key = $journal['date']->isoFormat($format); $key = $journal['date']->isoFormat($format);
$amount = app('steam')->positive($journal['amount']); $amount = app('steam')->positive($journal['amount']);
$chartData[$spentKey]['entries'][$key] = $chartData[$spentKey]['entries'][$key] ?? '0'; $chartData[$spentKey]['entries'][$key] ??= '0';
$chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount); $chartData[$spentKey]['entries'][$key] = bcadd($chartData[$spentKey]['entries'][$key], $amount);
} }
} }
@@ -369,7 +369,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['source_account_name'] ?? trans('firefly.empty'); $objectName = $journal['source_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -405,7 +405,7 @@ class TagReportController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$objectName = $journal['source_account_name'] ?? trans('firefly.empty'); $objectName = $journal['source_account_name'] ?? trans('firefly.empty');
$title = sprintf('%s (%s)', $objectName, $currency['currency_name']); $title = sprintf('%s (%s)', $objectName, $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -439,7 +439,7 @@ class TagReportController extends Controller
/** @var array $tag */ /** @var array $tag */
foreach ($currency['tags'] as $tag) { foreach ($currency['tags'] as $tag) {
$title = sprintf('%s (%s)', $tag['name'], $currency['currency_name']); $title = sprintf('%s (%s)', $tag['name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],
@@ -473,7 +473,7 @@ class TagReportController extends Controller
/** @var array $tag */ /** @var array $tag */
foreach ($currency['tags'] as $tag) { foreach ($currency['tags'] as $tag) {
$title = sprintf('%s (%s)', $tag['name'], $currency['currency_name']); $title = sprintf('%s (%s)', $tag['name'], $currency['currency_name']);
$result[$title] = $result[$title] ?? [ $result[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'], 'currency_code' => $currency['currency_code'],

View File

@@ -78,7 +78,7 @@ class TransactionController extends Controller
foreach ($result as $journal) { foreach ($result as $journal) {
$budget = $journal['budget_name'] ?? (string)trans('firefly.no_budget'); $budget = $journal['budget_name'] ?? (string)trans('firefly.no_budget');
$title = sprintf('%s (%s)', $budget, $journal['currency_symbol']); $title = sprintf('%s (%s)', $budget, $journal['currency_symbol']);
$data[$title] = $data[$title] ?? [ $data[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $journal['currency_symbol'], 'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],
@@ -131,7 +131,7 @@ class TransactionController extends Controller
foreach ($result as $journal) { foreach ($result as $journal) {
$category = $journal['category_name'] ?? (string)trans('firefly.no_category'); $category = $journal['category_name'] ?? (string)trans('firefly.no_category');
$title = sprintf('%s (%s)', $category, $journal['currency_symbol']); $title = sprintf('%s (%s)', $category, $journal['currency_symbol']);
$data[$title] = $data[$title] ?? [ $data[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $journal['currency_symbol'], 'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],
@@ -184,7 +184,7 @@ class TransactionController extends Controller
foreach ($result as $journal) { foreach ($result as $journal) {
$name = $journal['destination_account_name']; $name = $journal['destination_account_name'];
$title = sprintf('%s (%s)', $name, $journal['currency_symbol']); $title = sprintf('%s (%s)', $name, $journal['currency_symbol']);
$data[$title] = $data[$title] ?? [ $data[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $journal['currency_symbol'], 'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],
@@ -237,7 +237,7 @@ class TransactionController extends Controller
foreach ($result as $journal) { foreach ($result as $journal) {
$name = $journal['source_account_name']; $name = $journal['source_account_name'];
$title = sprintf('%s (%s)', $name, $journal['currency_symbol']); $title = sprintf('%s (%s)', $name, $journal['currency_symbol']);
$data[$title] = $data[$title] ?? [ $data[$title] ??= [
'amount' => '0', 'amount' => '0',
'currency_symbol' => $journal['currency_symbol'], 'currency_symbol' => $journal['currency_symbol'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],

View File

@@ -57,7 +57,7 @@ abstract class Controller extends BaseController
{ {
// is site a demo site? // is site a demo site?
$isDemoSiteConfig = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site', false)); $isDemoSiteConfig = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site', false));
$isDemoSite = (bool) $isDemoSiteConfig->data; $isDemoSite = (bool)$isDemoSiteConfig->data;
app('view')->share('IS_DEMO_SITE', $isDemoSite); app('view')->share('IS_DEMO_SITE', $isDemoSite);
app('view')->share('DEMO_USERNAME', config('firefly.demo_username')); app('view')->share('DEMO_USERNAME', config('firefly.demo_username'));
app('view')->share('DEMO_PASSWORD', config('firefly.demo_password')); app('view')->share('DEMO_PASSWORD', config('firefly.demo_password'));

View File

@@ -42,6 +42,7 @@ use Illuminate\View\View;
use Monolog\Handler\RotatingFileHandler; use Monolog\Handler\RotatingFileHandler;
use Psr\Container\ContainerExceptionInterface; use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface; use Psr\Container\NotFoundExceptionInterface;
use const PHP_SAPI;
/** /**
* Class DebugController * Class DebugController
@@ -127,7 +128,7 @@ class DebugController extends Controller
// get latest log file: // get latest log file:
$logger = Log::driver(); $logger = Log::driver();
// PHPstan doesn't recognize the method because of its polymorphic nature. // PHPstan doesn't recognize the method because of its polymorphic nature.
$handlers = $logger->getHandlers(); /** @phpstan-ignore-line */ $handlers = $logger->getHandlers(); // @phpstan-ignore-line
$logContent = ''; $logContent = '';
foreach ($handlers as $handler) { foreach ($handlers as $handler) {
if ($handler instanceof RotatingFileHandler) { if ($handler instanceof RotatingFileHandler) {
@@ -172,7 +173,7 @@ class DebugController extends Controller
'db_version' => app('fireflyconfig')->get('db_version', 1)->data, 'db_version' => app('fireflyconfig')->get('db_version', 1)->data,
'php_version' => PHP_VERSION, 'php_version' => PHP_VERSION,
'php_os' => PHP_OS, 'php_os' => PHP_OS,
'interface' => \PHP_SAPI, 'interface' => PHP_SAPI,
'bcscale' => bcscale(), 'bcscale' => bcscale(),
'display_errors' => ini_get('display_errors'), 'display_errors' => ini_get('display_errors'),
'error_reporting' => $this->errorReporting((int)ini_get('error_reporting')), 'error_reporting' => $this->errorReporting((int)ini_get('error_reporting')),
@@ -277,7 +278,7 @@ class DebugController extends Controller
$result = setlocale(LC_ALL, $code); $result = setlocale(LC_ALL, $code);
$localeAttempts[$code] = $result === $code; $localeAttempts[$code] = $result === $code;
} }
setlocale(LC_ALL, (string) $original); setlocale(LC_ALL, (string)$original);
return [ return [
'user_id' => auth()->user()->id, 'user_id' => auth()->user()->id,

View File

@@ -102,7 +102,7 @@ class IndexController extends Controller
->header('Expires', '0') ->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0') ->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public') ->header('Pragma', 'public')
->header('Content-Length', (string) strlen($result['transactions'])); ->header('Content-Length', (string)strlen($result['transactions']));
// return CSV file made from 'transactions' array. // return CSV file made from 'transactions' array.
return $response; return $response;

View File

@@ -47,7 +47,7 @@ class JavascriptController extends Controller
/** /**
* Show info about accounts. * Show info about accounts.
* *
* @param AccountRepositoryInterface $repository * @param AccountRepositoryInterface $repository
* *
* @return Response * @return Response
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
@@ -101,8 +101,8 @@ class JavascriptController extends Controller
/** /**
* Show some common variables to be used in scripts. * Show some common variables to be used in scripts.
* *
* @param Request $request * @param Request $request
* @param AccountRepositoryInterface $repository * @param AccountRepositoryInterface $repository
* *
* @return Response * @return Response
* @throws FireflyException * @throws FireflyException

View File

@@ -179,9 +179,9 @@ class BoxController extends Controller
foreach ($set as $journal) { foreach ($set as $journal) {
$currencyId = (int)$journal['currency_id']; $currencyId = (int)$journal['currency_id'];
$amount = $journal['amount'] ?? '0'; $amount = $journal['amount'] ?? '0';
$incomes[$currencyId] = $incomes[$currencyId] ?? '0'; $incomes[$currencyId] ??= '0';
$incomes[$currencyId] = bcadd($incomes[$currencyId], app('steam')->positive($amount)); $incomes[$currencyId] = bcadd($incomes[$currencyId], app('steam')->positive($amount));
$sums[$currencyId] = $sums[$currencyId] ?? '0'; $sums[$currencyId] ??= '0';
$sums[$currencyId] = bcadd($sums[$currencyId], app('steam')->positive($amount)); $sums[$currencyId] = bcadd($sums[$currencyId], app('steam')->positive($amount));
} }
@@ -194,9 +194,9 @@ class BoxController extends Controller
/** @var array $journal */ /** @var array $journal */
foreach ($set as $journal) { foreach ($set as $journal) {
$currencyId = (int)$journal['currency_id']; $currencyId = (int)$journal['currency_id'];
$expenses[$currencyId] = $expenses[$currencyId] ?? '0'; $expenses[$currencyId] ??= '0';
$expenses[$currencyId] = bcadd($expenses[$currencyId], $journal['amount'] ?? '0'); $expenses[$currencyId] = bcadd($expenses[$currencyId], $journal['amount'] ?? '0');
$sums[$currencyId] = $sums[$currencyId] ?? '0'; $sums[$currencyId] ??= '0';
$sums[$currencyId] = bcadd($sums[$currencyId], $journal['amount']); $sums[$currencyId] = bcadd($sums[$currencyId], $journal['amount']);
} }

View File

@@ -46,7 +46,7 @@ class IntroController extends Controller
public function getIntroSteps(string $route, string $specificPage = null): JsonResponse public function getIntroSteps(string $route, string $specificPage = null): JsonResponse
{ {
app('log')->debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage)); app('log')->debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage));
$specificPage = $specificPage ?? ''; $specificPage ??= '';
$steps = $this->getBasicSteps($route); $steps = $this->getBasicSteps($route);
$specificSteps = $this->getSpecificSteps($route, $specificPage); $specificSteps = $this->getSpecificSteps($route, $specificPage);
if (0 === count($specificSteps)) { if (0 === count($specificSteps)) {
@@ -106,7 +106,7 @@ class IntroController extends Controller
*/ */
public function postEnable(string $route, string $specialPage = null): JsonResponse public function postEnable(string $route, string $specialPage = null): JsonResponse
{ {
$specialPage = $specialPage ?? ''; $specialPage ??= '';
$route = str_replace('.', '_', $route); $route = str_replace('.', '_', $route);
$key = 'shown_demo_' . $route; $key = 'shown_demo_' . $route;
if ('' !== $specialPage) { if ('' !== $specialPage) {
@@ -130,7 +130,7 @@ class IntroController extends Controller
*/ */
public function postFinished(string $route, string $specialPage = null): JsonResponse public function postFinished(string $route, string $specialPage = null): JsonResponse
{ {
$specialPage = $specialPage ?? ''; $specialPage ??= '';
$key = 'shown_demo_' . $route; $key = 'shown_demo_' . $route;
if ('' !== $specialPage) { if ('' !== $specialPage) {
$key .= '_' . $specialPage; $key .= '_' . $specialPage;

View File

@@ -80,7 +80,7 @@ class RecurrenceController extends Controller
$repetitions = (int)$request->get('reps'); $repetitions = (int)$request->get('reps');
$repetitionMoment = ''; $repetitionMoment = '';
if(false === $start || false === $end || false === $firstDate || false === $endDate) { if (false === $start || false === $end || false === $firstDate || false === $endDate) {
return response()->json(); return response()->json();
} }
@@ -157,7 +157,7 @@ class RecurrenceController extends Controller
} catch (InvalidFormatException $e) { } catch (InvalidFormatException $e) {
$date = Carbon::today(config('app.timezone')); $date = Carbon::today(config('app.timezone'));
} }
if(false === $date) { if (false === $date) {
return response()->json(); return response()->json();
} }
$date->startOfDay(); $date->startOfDay();

View File

@@ -106,7 +106,7 @@ class IndexController extends Controller
$array = $transformer->transform($piggy); $array = $transformer->transform($piggy);
$groupOrder = (int)$array['object_group_order']; $groupOrder = (int)$array['object_group_order'];
// make group array if necessary: // make group array if necessary:
$piggyBanks[$groupOrder] = $piggyBanks[$groupOrder] ?? [ $piggyBanks[$groupOrder] ??= [
'object_group_id' => $array['object_group_id'] ?? 0, 'object_group_id' => $array['object_group_id'] ?? 0,
'object_group_title' => $array['object_group_title'] ?? trans('firefly.default_group_title_name'), 'object_group_title' => $array['object_group_title'] ?? trans('firefly.default_group_title_name'),
'piggy_banks' => [], 'piggy_banks' => [],
@@ -154,7 +154,7 @@ class IndexController extends Controller
$groupId = $group['object_group_id']; $groupId = $group['object_group_id'];
foreach ($group['piggy_banks'] as $piggy) { foreach ($group['piggy_banks'] as $piggy) {
$currencyId = $piggy['currency_id']; $currencyId = $piggy['currency_id'];
$sums[$groupId][$currencyId] = $sums[$groupId][$currencyId] ?? [ $sums[$groupId][$currencyId] ??= [
'target' => '0', 'target' => '0',
'saved' => '0', 'saved' => '0',
'left_to_save' => '0', 'left_to_save' => '0',

View File

@@ -98,8 +98,8 @@ class PreferencesController extends Controller
/** @var array<int, int> $accountIds */ /** @var array<int, int> $accountIds */
$accountIds = $accounts->pluck('id')->toArray(); $accountIds = $accounts->pluck('id')->toArray();
$viewRange = app('navigation')->getViewRange(false); $viewRange = app('navigation')->getViewRange(false);
$frontPageAccountsPref = app('preferences')->get('frontPageAccounts', $accountIds); $frontPageAccountsPref = app('preferences')->get('frontPageAccounts', $accountIds);
$frontPageAccounts = $frontPageAccountsPref->data; $frontPageAccounts = $frontPageAccountsPref->data;
if (!is_array($frontPageAccounts)) { if (!is_array($frontPageAccounts)) {
$frontPageAccounts = $accountIds; $frontPageAccounts = $accountIds;
} }

View File

@@ -104,7 +104,7 @@ class BalanceController extends Controller
foreach ($journals as $journal) { foreach ($journals as $journal) {
$sourceAccount = $journal['source_account_id']; $sourceAccount = $journal['source_account_id'];
$currencyId = $journal['currency_id']; $currencyId = $journal['currency_id'];
$spent[$sourceAccount] = $spent[$sourceAccount] ?? [ $spent[$sourceAccount] ??= [
'source_account_id' => $sourceAccount, 'source_account_id' => $sourceAccount,
'currency_id' => $journal['currency_id'], 'currency_id' => $journal['currency_id'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],
@@ -116,7 +116,7 @@ class BalanceController extends Controller
$spent[$sourceAccount]['spent'] = bcadd($spent[$sourceAccount]['spent'], $journal['amount']); $spent[$sourceAccount]['spent'] = bcadd($spent[$sourceAccount]['spent'], $journal['amount']);
// also fix sum: // also fix sum:
$report['sums'][$budgetId][$currencyId] = $report['sums'][$budgetId][$currencyId] ?? [ $report['sums'][$budgetId][$currencyId] ??= [
'sum' => '0', 'sum' => '0',
'currency_id' => $journal['currency_id'], 'currency_id' => $journal['currency_id'],
'currency_code' => $journal['currency_code'], 'currency_code' => $journal['currency_code'],

View File

@@ -109,7 +109,7 @@ class BudgetController extends Controller
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
$accountId = $account->id; $accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [ $report[$accountId] ??= [
'name' => $account->name, 'name' => $account->name,
'id' => $account->id, 'id' => $account->id,
'iban' => $account->iban, 'iban' => $account->iban,
@@ -120,7 +120,7 @@ class BudgetController extends Controller
// loop expenses. // loop expenses.
foreach ($spent as $currency) { foreach ($spent as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -130,7 +130,7 @@ class BudgetController extends Controller
foreach ($currency['budgets'] as $budget) { foreach ($currency['budgets'] as $budget) {
foreach ($budget['transaction_journals'] as $journal) { foreach ($budget['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id']; $sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [ $report[$sourceAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -167,7 +167,7 @@ class BudgetController extends Controller
foreach ($budget['transaction_journals'] as $journal) { foreach ($budget['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id']; $destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']); $key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [ $result[$key] ??= [
'transactions' => 0, 'transactions' => 0,
'sum' => '0', 'sum' => '0',
'avg' => '0', 'avg' => '0',
@@ -219,7 +219,7 @@ class BudgetController extends Controller
/** @var Budget $budget */ /** @var Budget $budget */
foreach ($budgets as $budget) { foreach ($budgets as $budget) {
$budgetId = $budget->id; $budgetId = $budget->id;
$report[$budgetId] = $report[$budgetId] ?? [ $report[$budgetId] ??= [
'name' => $budget->name, 'name' => $budget->name,
'id' => $budget->id, 'id' => $budget->id,
'currencies' => [], 'currencies' => [],
@@ -227,7 +227,7 @@ class BudgetController extends Controller
} }
foreach ($spent as $currency) { foreach ($spent as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -240,7 +240,7 @@ class BudgetController extends Controller
foreach ($budget['transaction_journals'] as $journal) { foreach ($budget['transaction_journals'] as $journal) {
// add currency info to report array: // add currency info to report array:
$report[$budgetId]['currencies'][$currencyId] = $report[$budgetId]['currencies'][$currencyId] ?? [ $report[$budgetId]['currencies'][$currencyId] ??= [
'sum' => '0', 'sum' => '0',
'sum_pct' => '0', 'sum_pct' => '0',
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
@@ -332,7 +332,7 @@ class BudgetController extends Controller
$count++; $count++;
$key = sprintf('%d-%d', $budget['id'], $currency['currency_id']); $key = sprintf('%d-%d', $budget['id'], $currency['currency_id']);
$dateKey = $journal['date']->format($keyFormat); $dateKey = $journal['date']->format($keyFormat);
$report[$key] = $report[$key] ?? [ $report[$key] ??= [
'id' => $budget['id'], 'id' => $budget['id'],
'name' => sprintf('%s (%s)', $budget['name'], $currency['currency_name']), 'name' => sprintf('%s (%s)', $budget['name'], $currency['currency_name']),
'sum' => '0', 'sum' => '0',
@@ -343,7 +343,7 @@ class BudgetController extends Controller
'currency_decimal_places' => $currency['currency_decimal_places'], 'currency_decimal_places' => $currency['currency_decimal_places'],
'entries' => [], 'entries' => [],
]; ];
$report[$key]['entries'][$dateKey] = $report[$key] ['entries'][$dateKey] ?? '0'; $report[$key]['entries'][$dateKey] ??= '0';
$report[$key]['entries'][$dateKey] = bcadd($journal['amount'], $report[$key] ['entries'][$dateKey]); $report[$key]['entries'][$dateKey] = bcadd($journal['amount'], $report[$key] ['entries'][$dateKey]);
$report[$key]['sum'] = bcadd($report[$key] ['sum'], $journal['amount']); $report[$key]['sum'] = bcadd($report[$key] ['sum'], $journal['amount']);
$report[$key]['avg'] = bcdiv($report[$key]['sum'], (string)count($periods)); $report[$key]['avg'] = bcdiv($report[$key]['sum'], (string)count($periods));

View File

@@ -82,7 +82,7 @@ class CategoryController extends Controller
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
$accountId = $account->id; $accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [ $report[$accountId] ??= [
'name' => $account->name, 'name' => $account->name,
'id' => $account->id, 'id' => $account->id,
'iban' => $account->iban, 'iban' => $account->iban,
@@ -98,7 +98,7 @@ class CategoryController extends Controller
foreach ($currency['categories'] as $category) { foreach ($currency['categories'] as $category) {
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id']; $sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [ $report[$sourceAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -107,13 +107,11 @@ class CategoryController extends Controller
]; ];
$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']] $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]
= $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']] ??= [
?? 'spent' => '0',
[ 'earned' => '0',
'spent' => '0', 'sum' => '0',
'earned' => '0', ];
'sum' => '0',
];
$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['spent'] = bcadd( $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['spent'] = bcadd(
$report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['spent'], $report[$sourceAccountId]['currencies'][$currencyId]['categories'][$category['id']]['spent'],
$journal['amount'] $journal['amount']
@@ -134,22 +132,19 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id']; $destinationId = $journal['destination_account_id'];
$report[$destinationId]['currencies'][$currencyId] $report[$destinationId]['currencies'][$currencyId]
= $report[$destinationId]['currencies'][$currencyId] ??= [
?? [ 'currency_id' => $currency['currency_id'],
'currency_id' => $currency['currency_id'], 'currency_symbol' => $currency['currency_symbol'],
'currency_symbol' => $currency['currency_symbol'], 'currency_name' => $currency['currency_name'],
'currency_name' => $currency['currency_name'], 'currency_decimal_places' => $currency['currency_decimal_places'],
'currency_decimal_places' => $currency['currency_decimal_places'], 'categories' => [],
'categories' => [], ];
];
$report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']] $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]
= $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']] ??= [
?? 'spent' => '0',
[ 'earned' => '0',
'spent' => '0', 'sum' => '0',
'earned' => '0', ];
'sum' => '0',
];
$report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['earned'] = bcadd( $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['earned'] = bcadd(
$report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['earned'], $report[$destinationId]['currencies'][$currencyId]['categories'][$category['id']]['earned'],
$journal['amount'] $journal['amount']
@@ -182,7 +177,7 @@ class CategoryController extends Controller
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
$accountId = $account->id; $accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [ $report[$accountId] ??= [
'name' => $account->name, 'name' => $account->name,
'id' => $account->id, 'id' => $account->id,
'iban' => $account->iban, 'iban' => $account->iban,
@@ -193,7 +188,7 @@ class CategoryController extends Controller
// loop expenses. // loop expenses.
foreach ($spent as $currency) { foreach ($spent as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -205,7 +200,7 @@ class CategoryController extends Controller
foreach ($currency['categories'] as $category) { foreach ($currency['categories'] as $category) {
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id']; $sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [ $report[$sourceAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -231,7 +226,7 @@ class CategoryController extends Controller
// loop income. // loop income.
foreach ($earned as $currency) { foreach ($earned as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -243,7 +238,7 @@ class CategoryController extends Controller
foreach ($currency['categories'] as $category) { foreach ($currency['categories'] as $category) {
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
$destinationAccountId = $journal['destination_account_id']; $destinationAccountId = $journal['destination_account_id'];
$report[$destinationAccountId]['currencies'][$currencyId] = $report[$destinationAccountId]['currencies'][$currencyId] ?? [ $report[$destinationAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -287,7 +282,7 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id']; $destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']); $key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [ $result[$key] ??= [
'transactions' => 0, 'transactions' => 0,
'sum' => '0', 'sum' => '0',
'avg' => '0', 'avg' => '0',
@@ -340,7 +335,7 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
$sourceId = $journal['source_account_id']; $sourceId = $journal['source_account_id'];
$key = sprintf('%d-%d', $sourceId, $currency['currency_id']); $key = sprintf('%d-%d', $sourceId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [ $result[$key] ??= [
'transactions' => 0, 'transactions' => 0,
'sum' => '0', 'sum' => '0',
'avg' => '0', 'avg' => '0',
@@ -392,7 +387,7 @@ class CategoryController extends Controller
/** @var Category $category */ /** @var Category $category */
foreach ($categories as $category) { foreach ($categories as $category) {
$categoryId = $category->id; $categoryId = $category->id;
$report[$categoryId] = $report[$categoryId] ?? [ $report[$categoryId] ??= [
'name' => $category->name, 'name' => $category->name,
'id' => $category->id, 'id' => $category->id,
'currencies' => [], 'currencies' => [],
@@ -400,7 +395,7 @@ class CategoryController extends Controller
} }
foreach ($spent as $currency) { foreach ($spent as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -415,7 +410,7 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
// add currency info to report array: // add currency info to report array:
$report[$categoryId]['currencies'][$currencyId] = $report[$categoryId]['currencies'][$currencyId] ?? [ $report[$categoryId]['currencies'][$currencyId] ??= [
'spent' => '0', 'spent' => '0',
'earned' => '0', 'earned' => '0',
'sum' => '0', 'sum' => '0',
@@ -441,7 +436,7 @@ class CategoryController extends Controller
foreach ($earned as $currency) { foreach ($earned as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -456,7 +451,7 @@ class CategoryController extends Controller
foreach ($category['transaction_journals'] as $journal) { foreach ($category['transaction_journals'] as $journal) {
// add currency info to report array: // add currency info to report array:
$report[$categoryId]['currencies'][$currencyId] = $report[$categoryId]['currencies'][$currencyId] ?? [ $report[$categoryId]['currencies'][$currencyId] ??= [
'spent' => '0', 'spent' => '0',
'earned' => '0', 'earned' => '0',
'sum' => '0', 'sum' => '0',
@@ -523,7 +518,7 @@ class CategoryController extends Controller
foreach ($set as $currencyId => $currencyRow) { foreach ($set as $currencyId => $currencyRow) {
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) { foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
$key = sprintf('%d-%d', $currencyId, $categoryId); $key = sprintf('%d-%d', $currencyId, $categoryId);
$data[$key] = $data[$key] ?? [ $data[$key] ??= [
'id' => $categoryRow['id'], 'id' => $categoryRow['id'],
'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']), 'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),
'currency_id' => $currencyRow['currency_id'], 'currency_id' => $currencyRow['currency_id'],
@@ -537,7 +532,7 @@ class CategoryController extends Controller
]; ];
foreach ($categoryRow['transaction_journals'] as $journal) { foreach ($categoryRow['transaction_journals'] as $journal) {
$date = $journal['date']->format($format); $date = $journal['date']->format($format);
$data[$key]['entries'][$date] = $data[$key]['entries'][$date] ?? '0'; $data[$key]['entries'][$date] ??= '0';
$data[$key]['entries'][$date] = bcadd($data[$key]['entries'][$date], $journal['amount']); $data[$key]['entries'][$date] = bcadd($data[$key]['entries'][$date], $journal['amount']);
$data[$key]['sum'] = bcadd($data[$key]['sum'], $journal['amount']); $data[$key]['sum'] = bcadd($data[$key]['sum'], $journal['amount']);
} }
@@ -604,7 +599,7 @@ class CategoryController extends Controller
foreach ($set as $currencyId => $currencyRow) { foreach ($set as $currencyId => $currencyRow) {
foreach ($currencyRow['categories'] as $categoryId => $categoryRow) { foreach ($currencyRow['categories'] as $categoryId => $categoryRow) {
$key = sprintf('%d-%d', $currencyId, $categoryId); $key = sprintf('%d-%d', $currencyId, $categoryId);
$data[$key] = $data[$key] ?? [ $data[$key] ??= [
'id' => $categoryRow['id'], 'id' => $categoryRow['id'],
'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']), 'title' => sprintf('%s (%s)', $categoryRow['name'], $currencyRow['currency_name']),
'currency_id' => $currencyRow['currency_id'], 'currency_id' => $currencyRow['currency_id'],
@@ -618,7 +613,7 @@ class CategoryController extends Controller
]; ];
foreach ($categoryRow['transaction_journals'] as $journal) { foreach ($categoryRow['transaction_journals'] as $journal) {
$date = $journal['date']->format($format); $date = $journal['date']->format($format);
$data[$key]['entries'][$date] = $data[$key]['entries'][$date] ?? '0'; $data[$key]['entries'][$date] ??= '0';
$data[$key]['entries'][$date] = bcadd($data[$key]['entries'][$date], $journal['amount']); $data[$key]['entries'][$date] = bcadd($data[$key]['entries'][$date], $journal['amount']);
$data[$key]['sum'] = bcadd($data[$key]['sum'], $journal['amount']); $data[$key]['sum'] = bcadd($data[$key]['sum'], $journal['amount']);
} }

View File

@@ -88,7 +88,7 @@ class DoubleController extends Controller
foreach ($currency['transaction_journals'] as $journal) { foreach ($currency['transaction_journals'] as $journal) {
$sourceId = $journal['source_account_id']; $sourceId = $journal['source_account_id'];
$key = sprintf('%d-%d', $sourceId, $currency['currency_id']); $key = sprintf('%d-%d', $sourceId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [ $result[$key] ??= [
'transactions' => 0, 'transactions' => 0,
'sum' => '0', 'sum' => '0',
'avg' => '0', 'avg' => '0',
@@ -141,7 +141,7 @@ class DoubleController extends Controller
foreach ($currency['transaction_journals'] as $journal) { foreach ($currency['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id']; $destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']); $key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [ $result[$key] ??= [
'transactions' => 0, 'transactions' => 0,
'sum' => '0', 'sum' => '0',
'avg' => '0', 'avg' => '0',
@@ -198,7 +198,7 @@ class DoubleController extends Controller
foreach ($spent as $currency) { foreach ($spent as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'spent' => '0', 'spent' => '0',
'earned' => '0', 'earned' => '0',
'sum' => '0', 'sum' => '0',
@@ -216,7 +216,7 @@ class DoubleController extends Controller
$destIban = $journal['destination_account_iban']; $destIban = $journal['destination_account_iban'];
$genericName = $this->getCounterpartName($withCounterpart, $destId, $destName, $destIban); $genericName = $this->getCounterpartName($withCounterpart, $destId, $destName, $destIban);
$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']); $objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [ $report[$objectName] ??= [
'dest_name' => '', 'dest_name' => '',
'dest_iban' => '', 'dest_iban' => '',
'source_name' => '', 'source_name' => '',
@@ -246,7 +246,7 @@ class DoubleController extends Controller
foreach ($earned as $currency) { foreach ($earned as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'spent' => '0', 'spent' => '0',
'earned' => '0', 'earned' => '0',
'sum' => '0', 'sum' => '0',
@@ -264,7 +264,7 @@ class DoubleController extends Controller
$sourceIban = $journal['source_account_iban']; $sourceIban = $journal['source_account_iban'];
$genericName = $this->getCounterpartName($withCounterpart, $sourceId, $sourceName, $sourceIban); $genericName = $this->getCounterpartName($withCounterpart, $sourceId, $sourceName, $sourceIban);
$objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']); $objectName = sprintf('%s (%s)', $genericName, $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [ $report[$objectName] ??= [
'dest_name' => '', 'dest_name' => '',
'dest_iban' => '', 'dest_iban' => '',
'source_name' => '', 'source_name' => '',
@@ -342,7 +342,7 @@ class DoubleController extends Controller
foreach ($spent as $currency) { foreach ($spent as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'spent' => '0', 'spent' => '0',
'earned' => '0', 'earned' => '0',
'sum' => '0', 'sum' => '0',
@@ -356,7 +356,7 @@ class DoubleController extends Controller
/** @var array $journal */ /** @var array $journal */
foreach ($currency['transaction_journals'] as $journal) { foreach ($currency['transaction_journals'] as $journal) {
$objectName = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']); $objectName = sprintf('%s (%s)', $journal['source_account_name'], $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [ $report[$objectName] ??= [
'account_id' => $journal['source_account_id'], 'account_id' => $journal['source_account_id'],
'account_name' => $objectName, 'account_name' => $objectName,
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
@@ -381,7 +381,7 @@ class DoubleController extends Controller
foreach ($earned as $currency) { foreach ($earned as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'spent' => '0', 'spent' => '0',
'earned' => '0', 'earned' => '0',
'sum' => '0', 'sum' => '0',
@@ -395,7 +395,7 @@ class DoubleController extends Controller
/** @var array $journal */ /** @var array $journal */
foreach ($currency['transaction_journals'] as $journal) { foreach ($currency['transaction_journals'] as $journal) {
$objectName = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']); $objectName = sprintf('%s (%s)', $journal['destination_account_name'], $currency['currency_name']);
$report[$objectName] = $report[$objectName] ?? [ $report[$objectName] ??= [
'account_id' => $journal['destination_account_id'], 'account_id' => $journal['destination_account_id'],
'account_name' => $objectName, 'account_name' => $objectName,
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],

View File

@@ -162,7 +162,7 @@ class OperationsController extends Controller
/** @var int $currencyId */ /** @var int $currencyId */
foreach ($keys as $currencyId) { foreach ($keys as $currencyId) {
$currencyInfo = $incomes['sums'][$currencyId] ?? $expenses['sums'][$currencyId]; $currencyInfo = $incomes['sums'][$currencyId] ?? $expenses['sums'][$currencyId];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'currency_id' => $currencyId, 'currency_id' => $currencyId,
'currency_name' => $currencyInfo['currency_name'], 'currency_name' => $currencyInfo['currency_name'],
'currency_code' => $currencyInfo['currency_code'], 'currency_code' => $currencyInfo['currency_code'],

View File

@@ -75,7 +75,7 @@ class TagController extends Controller
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
$accountId = $account->id; $accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [ $report[$accountId] ??= [
'name' => $account->name, 'name' => $account->name,
'id' => $account->id, 'id' => $account->id,
'iban' => $account->iban, 'iban' => $account->iban,
@@ -91,7 +91,7 @@ class TagController extends Controller
foreach ($currency['tags'] as $tag) { foreach ($currency['tags'] as $tag) {
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id']; $sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [ $report[$sourceAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -100,13 +100,11 @@ class TagController extends Controller
]; ];
$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']] $report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]
= $report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']] ??= [
?? 'spent' => '0',
[ 'earned' => '0',
'spent' => '0', 'sum' => '0',
'earned' => '0', ];
'sum' => '0',
];
$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]['spent'] = bcadd( $report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]['spent'] = bcadd(
$report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]['spent'], $report[$sourceAccountId]['currencies'][$currencyId]['tags'][$tag['id']]['spent'],
$journal['amount'] $journal['amount']
@@ -127,22 +125,19 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id']; $destinationId = $journal['destination_account_id'];
$report[$destinationId]['currencies'][$currencyId] $report[$destinationId]['currencies'][$currencyId]
= $report[$destinationId]['currencies'][$currencyId] ??= [
?? [ 'currency_id' => $currency['currency_id'],
'currency_id' => $currency['currency_id'], 'currency_symbol' => $currency['currency_symbol'],
'currency_symbol' => $currency['currency_symbol'], 'currency_name' => $currency['currency_name'],
'currency_name' => $currency['currency_name'], 'currency_decimal_places' => $currency['currency_decimal_places'],
'currency_decimal_places' => $currency['currency_decimal_places'], 'tags' => [],
'tags' => [], ];
];
$report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']] $report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]
= $report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']] ??= [
?? 'spent' => '0',
[ 'earned' => '0',
'spent' => '0', 'sum' => '0',
'earned' => '0', ];
'sum' => '0',
];
$report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]['earned'] = bcadd( $report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]['earned'] = bcadd(
$report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]['earned'], $report[$destinationId]['currencies'][$currencyId]['tags'][$tag['id']]['earned'],
$journal['amount'] $journal['amount']
@@ -175,7 +170,7 @@ class TagController extends Controller
/** @var Account $account */ /** @var Account $account */
foreach ($accounts as $account) { foreach ($accounts as $account) {
$accountId = $account->id; $accountId = $account->id;
$report[$accountId] = $report[$accountId] ?? [ $report[$accountId] ??= [
'name' => $account->name, 'name' => $account->name,
'id' => $account->id, 'id' => $account->id,
'iban' => $account->iban, 'iban' => $account->iban,
@@ -186,7 +181,7 @@ class TagController extends Controller
// loop expenses. // loop expenses.
foreach ($spent as $currency) { foreach ($spent as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -198,7 +193,7 @@ class TagController extends Controller
foreach ($currency['tags'] as $tag) { foreach ($currency['tags'] as $tag) {
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$sourceAccountId = $journal['source_account_id']; $sourceAccountId = $journal['source_account_id'];
$report[$sourceAccountId]['currencies'][$currencyId] = $report[$sourceAccountId]['currencies'][$currencyId] ?? [ $report[$sourceAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -224,7 +219,7 @@ class TagController extends Controller
// loop income. // loop income.
foreach ($earned as $currency) { foreach ($earned as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -236,7 +231,7 @@ class TagController extends Controller
foreach ($currency['tags'] as $tag) { foreach ($currency['tags'] as $tag) {
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$destinationAccountId = $journal['destination_account_id']; $destinationAccountId = $journal['destination_account_id'];
$report[$destinationAccountId]['currencies'][$currencyId] = $report[$destinationAccountId]['currencies'][$currencyId] ?? [ $report[$destinationAccountId]['currencies'][$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -280,7 +275,7 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$destinationId = $journal['destination_account_id']; $destinationId = $journal['destination_account_id'];
$key = sprintf('%d-%d', $destinationId, $currency['currency_id']); $key = sprintf('%d-%d', $destinationId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [ $result[$key] ??= [
'transactions' => 0, 'transactions' => 0,
'sum' => '0', 'sum' => '0',
'avg' => '0', 'avg' => '0',
@@ -333,7 +328,7 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
$sourceId = $journal['source_account_id']; $sourceId = $journal['source_account_id'];
$key = sprintf('%d-%d', $sourceId, $currency['currency_id']); $key = sprintf('%d-%d', $sourceId, $currency['currency_id']);
$result[$key] = $result[$key] ?? [ $result[$key] ??= [
'transactions' => 0, 'transactions' => 0,
'sum' => '0', 'sum' => '0',
'avg' => '0', 'avg' => '0',
@@ -385,7 +380,7 @@ class TagController extends Controller
/** @var Tag $tag */ /** @var Tag $tag */
foreach ($tags as $tag) { foreach ($tags as $tag) {
$tagId = $tag->id; $tagId = $tag->id;
$report[$tagId] = $report[$tagId] ?? [ $report[$tagId] ??= [
'name' => $tag->tag, 'name' => $tag->tag,
'id' => $tag->id, 'id' => $tag->id,
'currencies' => [], 'currencies' => [],
@@ -393,7 +388,7 @@ class TagController extends Controller
} }
foreach ($spent as $currency) { foreach ($spent as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -408,7 +403,7 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
// add currency info to report array: // add currency info to report array:
$report[$tagId]['currencies'][$currencyId] = $report[$tagId]['currencies'][$currencyId] ?? [ $report[$tagId]['currencies'][$currencyId] ??= [
'spent' => '0', 'spent' => '0',
'earned' => '0', 'earned' => '0',
'sum' => '0', 'sum' => '0',
@@ -434,7 +429,7 @@ class TagController extends Controller
foreach ($earned as $currency) { foreach ($earned as $currency) {
$currencyId = $currency['currency_id']; $currencyId = $currency['currency_id'];
$sums[$currencyId] = $sums[$currencyId] ?? [ $sums[$currencyId] ??= [
'currency_id' => $currency['currency_id'], 'currency_id' => $currency['currency_id'],
'currency_symbol' => $currency['currency_symbol'], 'currency_symbol' => $currency['currency_symbol'],
'currency_name' => $currency['currency_name'], 'currency_name' => $currency['currency_name'],
@@ -449,7 +444,7 @@ class TagController extends Controller
foreach ($tag['transaction_journals'] as $journal) { foreach ($tag['transaction_journals'] as $journal) {
// add currency info to report array: // add currency info to report array:
$report[$tagId]['currencies'][$currencyId] = $report[$tagId]['currencies'][$currencyId] ?? [ $report[$tagId]['currencies'][$currencyId] ??= [
'spent' => '0', 'spent' => '0',
'earned' => '0', 'earned' => '0',
'sum' => '0', 'sum' => '0',

View File

@@ -49,7 +49,8 @@ use Psr\Container\NotFoundExceptionInterface;
class ReportController extends Controller class ReportController extends Controller
{ {
use RenderPartialViews; use RenderPartialViews;
protected ReportHelperInterface $helper;
protected ReportHelperInterface $helper;
private BudgetRepositoryInterface $repository; private BudgetRepositoryInterface $repository;
/** /**
@@ -328,7 +329,7 @@ class ReportController extends Controller
* @throws FireflyException * @throws FireflyException
* *
*/ */
public function postIndex(ReportFormRequest $request): RedirectResponse|Redirector|View public function postIndex(ReportFormRequest $request): RedirectResponse | Redirector | View
{ {
// report type: // report type:
$reportType = $request->get('report_type'); $reportType = $request->get('report_type');

View File

@@ -100,7 +100,7 @@ class CreateController extends Controller
session()->flash('warning', trans('firefly.rule_from_search_words', ['string' => $words])); session()->flash('warning', trans('firefly.rule_from_search_words', ['string' => $words]));
$operators[] = [ $operators[] = [
'type' => 'description_contains', 'type' => 'description_contains',
'value' => $words 'value' => $words,
]; ];
} }
$oldTriggers = $this->parseFromOperators($operators); $oldTriggers = $this->parseFromOperators($operators);

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