Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Code cleanup
James Cole565bd87959b0
diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.phpindex e4f2edf325..586646f804 100644--- a/app/Api/V1/Controllers/Autocomplete/AccountController.php+++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php@@ -78,7 +78,7 @@ class AccountController extends Controller$query = $data['query'];$date = $data['date'] ?? today(config('app.timezone'));$return = [];- $result = $this->repository->searchAccount((string)$query, $types, $this->parameters->get('limit'));+ $result = $this->repository->searchAccount((string) $query, $types, $this->parameters->get('limit'));// TODO this code is duplicated in the V2 Autocomplete controller, which means this code is due to be deprecated.$defaultCurrency = app('amount')->getDefaultCurrency();@@ -98,11 +98,11 @@ class AccountController extends Controller}$return[] = [- 'id' => (string)$account->id,+ 'id' => (string) $account->id,'name' => $account->name,'name_with_balance' => $nameWithBalance,'type' => $account->accountType->type,- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_name' => $currency->name,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,@@ -115,8 +115,8 @@ class AccountController extends Controller$return,static function (array $left, array $right) {$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];- $posA = (int)array_search($left['type'], $order, true);- $posB = (int)array_search($right['type'], $order, true);+ $posA = (int) array_search($left['type'], $order, true);+ $posB = (int) array_search($right['type'], $order, true);return $posA - $posB;}diff --git a/app/Api/V1/Controllers/Autocomplete/BillController.php b/app/Api/V1/Controllers/Autocomplete/BillController.phpindex bb4c63d94b..36904d1a89 100644--- a/app/Api/V1/Controllers/Autocomplete/BillController.php+++ b/app/Api/V1/Controllers/Autocomplete/BillController.php@@ -67,7 +67,7 @@ class BillController extends Controller$filtered = $result->map(static function (Bill $item) {return [- 'id' => (string)$item->id,+ 'id' => (string) $item->id,'name' => $item->name,'active' => $item->active,];diff --git a/app/Api/V1/Controllers/Autocomplete/BudgetController.php b/app/Api/V1/Controllers/Autocomplete/BudgetController.phpindex 1a6e44a5f5..4620955a22 100644--- a/app/Api/V1/Controllers/Autocomplete/BudgetController.php+++ b/app/Api/V1/Controllers/Autocomplete/BudgetController.php@@ -67,7 +67,7 @@ class BudgetController extends Controller$filtered = $result->map(static function (Budget $item) {return [- 'id' => (string)$item->id,+ 'id' => (string) $item->id,'name' => $item->name,];}diff --git a/app/Api/V1/Controllers/Autocomplete/CategoryController.php b/app/Api/V1/Controllers/Autocomplete/CategoryController.phpindex 1213ae002d..a91a2231ed 100644--- a/app/Api/V1/Controllers/Autocomplete/CategoryController.php+++ b/app/Api/V1/Controllers/Autocomplete/CategoryController.php@@ -67,7 +67,7 @@ class CategoryController extends Controller$filtered = $result->map(static function (Category $item) {return [- 'id' => (string)$item->id,+ 'id' => (string) $item->id,'name' => $item->name,];}diff --git a/app/Api/V1/Controllers/Autocomplete/CurrencyController.php b/app/Api/V1/Controllers/Autocomplete/CurrencyController.phpindex 5fe00809e7..2170b5dd5a 100644--- a/app/Api/V1/Controllers/Autocomplete/CurrencyController.php+++ b/app/Api/V1/Controllers/Autocomplete/CurrencyController.php@@ -69,7 +69,7 @@ class CurrencyController extends Controller/** @var TransactionCurrency $currency */foreach ($collection as $currency) {$result[] = [- 'id' => (string)$currency->id,+ 'id' => (string) $currency->id,'name' => $currency->name,'code' => $currency->code,'symbol' => $currency->symbol,@@ -95,7 +95,7 @@ class CurrencyController extends Controller/** @var TransactionCurrency $currency */foreach ($collection as $currency) {$result[] = [- 'id' => (string)$currency->id,+ 'id' => (string) $currency->id,'name' => sprintf('%s (%s)', $currency->name, $currency->code),'code' => $currency->code,'symbol' => $currency->symbol,diff --git a/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php b/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.phpindex cea2a3d9ac..5f1014502b 100644--- a/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php+++ b/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php@@ -69,7 +69,7 @@ class ObjectGroupController extends Controller/** @var ObjectGroup $objectGroup */foreach ($result as $objectGroup) {$return[] = [- 'id' => (string)$objectGroup->id,+ 'id' => (string) $objectGroup->id,'name' => $objectGroup->title,'title' => $objectGroup->title,];diff --git a/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php b/app/Api/V1/Controllers/Autocomplete/PiggyBankController.phpindex 85ad9b69a3..6565ba78f8 100644--- a/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php+++ b/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php@@ -75,14 +75,14 @@ class PiggyBankController extends Controller$currency = $piggy->transactionCurrency;$objectGroup = $piggy->objectGroups()->first();$response[] = [- 'id' => (string)$piggy->id,+ 'id' => (string) $piggy->id,'name' => $piggy->name,- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_name' => $currency->name,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,- 'object_group_id' => null === $objectGroup ? null : (string)$objectGroup->id,+ 'object_group_id' => null === $objectGroup ? null : (string) $objectGroup->id,'object_group_title' => $objectGroup?->title,];}@@ -106,7 +106,7 @@ class PiggyBankController extends Controller$currentAmount = $this->piggyRepository->getCurrentAmount($piggy);$objectGroup = $piggy->objectGroups()->first();$response[] = [- 'id' => (string)$piggy->id,+ 'id' => (string) $piggy->id,'name' => $piggy->name,'name_with_balance' => sprintf('%s (%s / %s)',@@ -114,12 +114,12 @@ class PiggyBankController extends Controllerapp('amount')->formatAnything($currency, $currentAmount, false),app('amount')->formatAnything($currency, $piggy->target_amount, false),),- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_name' => $currency->name,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,- 'object_group_id' => null === $objectGroup ? null : (string)$objectGroup->id,+ 'object_group_id' => null === $objectGroup ? null : (string) $objectGroup->id,'object_group_title' => $objectGroup?->title,];}diff --git a/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php b/app/Api/V1/Controllers/Autocomplete/RecurrenceController.phpindex 032490594d..c9c6f2d4f1 100644--- a/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php+++ b/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php@@ -67,7 +67,7 @@ class RecurrenceController extends Controller/** @var Recurrence $recurrence */foreach ($recurrences as $recurrence) {$response[] = [- 'id' => (string)$recurrence->id,+ 'id' => (string) $recurrence->id,'name' => $recurrence->title,'description' => $recurrence->description,];diff --git a/app/Api/V1/Controllers/Autocomplete/RuleController.php b/app/Api/V1/Controllers/Autocomplete/RuleController.phpindex 2dc08d3847..5a727f0ee9 100644--- a/app/Api/V1/Controllers/Autocomplete/RuleController.php+++ b/app/Api/V1/Controllers/Autocomplete/RuleController.php@@ -66,7 +66,7 @@ class RuleController extends Controller/** @var Rule $rule */foreach ($rules as $rule) {$response[] = [- 'id' => (string)$rule->id,+ 'id' => (string) $rule->id,'name' => $rule->title,'description' => $rule->description,];diff --git a/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php b/app/Api/V1/Controllers/Autocomplete/RuleGroupController.phpindex 918ac5d5de..cd77505b8b 100644--- a/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php+++ b/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php@@ -66,7 +66,7 @@ class RuleGroupController extends Controller/** @var RuleGroup $group */foreach ($groups as $group) {$response[] = [- 'id' => (string)$group->id,+ 'id' => (string) $group->id,'name' => $group->title,'description' => $group->description,];diff --git a/app/Api/V1/Controllers/Autocomplete/TagController.php b/app/Api/V1/Controllers/Autocomplete/TagController.phpindex 4939126241..c086b6b71b 100644--- a/app/Api/V1/Controllers/Autocomplete/TagController.php+++ b/app/Api/V1/Controllers/Autocomplete/TagController.php@@ -69,7 +69,7 @@ class TagController extends Controller/** @var Tag $tag */foreach ($result as $tag) {$array[] = [- 'id' => (string)$tag->id,+ 'id' => (string) $tag->id,'name' => $tag->tag,'tag' => $tag->tag,];diff --git a/app/Api/V1/Controllers/Autocomplete/TransactionController.php b/app/Api/V1/Controllers/Autocomplete/TransactionController.phpindex bed8e6a701..1624d89d47 100644--- a/app/Api/V1/Controllers/Autocomplete/TransactionController.php+++ b/app/Api/V1/Controllers/Autocomplete/TransactionController.php@@ -77,8 +77,8 @@ class TransactionController extends Controller/** @var TransactionJournal $journal */foreach ($filtered as $journal) {$array[] = [- 'id' => (string)$journal->id,- 'transaction_group_id' => (string)$journal->transaction_group_id,+ 'id' => (string) $journal->id,+ 'transaction_group_id' => (string) $journal->transaction_group_id,'name' => $journal->description,'description' => $journal->description,];@@ -97,7 +97,7 @@ class TransactionController extends Controller$result = new Collection();if (is_numeric($data['query'])) {// search for group, not journal.- $firstResult = $this->groupRepository->find((int)$data['query']);+ $firstResult = $this->groupRepository->find((int) $data['query']);if (null !== $firstResult) {// group may contain multiple journals, each a result:foreach ($firstResult->transactionJournals as $journal) {@@ -115,8 +115,8 @@ class TransactionController extends Controller/** @var TransactionJournal $journal */foreach ($result as $journal) {$array[] = [- 'id' => (string)$journal->id,- 'transaction_group_id' => (string)$journal->transaction_group_id,+ 'id' => (string) $journal->id,+ 'transaction_group_id' => (string) $journal->transaction_group_id,'name' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description),'description' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description),];diff --git a/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php b/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.phpindex 1ea77fae38..b34924b6d8 100644--- a/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php+++ b/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php@@ -66,7 +66,7 @@ class TransactionTypeController extends Controllerforeach ($types as $type) {// different key for consistency.$array[] = [- 'id' => (string)$type->id,+ 'id' => (string) $type->id,'name' => $type->type,'type' => $type->type,];diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.phpindex 3d093e0bba..ecbe1521b5 100644--- a/app/Api/V1/Controllers/Chart/AccountController.php+++ b/app/Api/V1/Controllers/Chart/AccountController.php@@ -104,7 +104,7 @@ class AccountController extends Controller}$currentSet = ['label' => $account->name,- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.phpindex 74160af153..e4672dd757 100644--- a/app/Api/V1/Controllers/Controller.php+++ b/app/Api/V1/Controllers/Controller.php@@ -82,7 +82,7 @@ abstract class Controller extends BaseControllerprivate function getParameters(): ParameterBag{$bag = new ParameterBag();- $page = (int)request()->get('page');+ $page = (int) request()->get('page');if ($page < 1) {$page = 1;}@@ -107,13 +107,13 @@ abstract class Controller extends BaseController$obj = null;if (null !== $date) {try {- $obj = Carbon::parse((string)$date);+ $obj = Carbon::parse((string) $date);} catch (InvalidDateException|InvalidFormatException $e) {// don't careapp('log')->warning(sprintf('Ignored invalid date "%s" in API controller parameter check: %s',- substr((string)$date, 0, 20),+ substr((string) $date, 0, 20),$e->getMessage()));@@ -134,7 +134,7 @@ abstract class Controller extends BaseController$value = null;}if (null !== $value) {- $bag->set($integer, (int)$value);+ $bag->set($integer, (int) $value);}if (null === $value&& 'limit' === $integer // @phpstan-ignore-line@@ -144,7 +144,7 @@ abstract class Controller extends BaseController$user = auth()->user();/** @var Preference $pageSize */- $pageSize = (int)app('preferences')->getForUser($user, 'listPageSize', 50)->data;+ $pageSize = (int) app('preferences')->getForUser($user, 'listPageSize', 50)->data;$bag->set($integer, $pageSize);}}@@ -158,7 +158,7 @@ abstract class Controller extends BaseController$sortParameters = [];try {- $param = (string)request()->query->get('sort');+ $param = (string) request()->query->get('sort');} catch (BadRequestException $e) {app('log')->error('Request field "sort" contains a non-scalar value. Value set to NULL.');app('log')->error($e->getMessage());diff --git a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php b/app/Api/V1/Controllers/Data/Bulk/TransactionController.phpindex 869c17ae87..f6ae26a5e2 100644--- a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php+++ b/app/Api/V1/Controllers/Data/Bulk/TransactionController.php@@ -70,8 +70,8 @@ class TransactionController extends Controller// to respond to what is in the $query.// this is OK because only one thing can be in the query at the moment.if ($this->isUpdateTransactionAccount($params)) {- $original = $this->repository->find((int)$params['where']['account_id']);- $destination = $this->repository->find((int)$params['update']['account_id']);+ $original = $this->repository->find((int) $params['where']['account_id']);+ $destination = $this->repository->find((int) $params['update']['account_id']);/** @var AccountDestroyService $service */$service = app(AccountDestroyService::class);diff --git a/app/Api/V1/Controllers/Data/Export/ExportController.php b/app/Api/V1/Controllers/Data/Export/ExportController.phpindex 8eda16cf8f..cfbe4414b1 100644--- a/app/Api/V1/Controllers/Data/Export/ExportController.php+++ b/app/Api/V1/Controllers/Data/Export/ExportController.php@@ -88,7 +88,7 @@ class ExportController extends Controller->header('Expires', '0')->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')->header('Pragma', 'public')- ->header('Content-Length', (string)strlen($data[$key]))+ ->header('Content-Length', (string) strlen($data[$key]));return $response;diff --git a/app/Api/V1/Controllers/Data/PurgeController.php b/app/Api/V1/Controllers/Data/PurgeController.phpindex 39c7826528..baba2f622a 100644--- a/app/Api/V1/Controllers/Data/PurgeController.php+++ b/app/Api/V1/Controllers/Data/PurgeController.php@@ -29,7 +29,6 @@ use FireflyIII\Models\Account;use FireflyIII\Models\Bill;use FireflyIII\Models\Budget;use FireflyIII\Models\Category;-use FireflyIII\Models\PiggyBank;use FireflyIII\Models\Recurrence;use FireflyIII\Models\Rule;use FireflyIII\Models\RuleGroup;diff --git a/app/Api/V1/Controllers/Insight/Expense/AccountController.php b/app/Api/V1/Controllers/Insight/Expense/AccountController.phpindex 6649561c78..323afc1e0f 100644--- a/app/Api/V1/Controllers/Insight/Expense/AccountController.php+++ b/app/Api/V1/Controllers/Insight/Expense/AccountController.php@@ -79,11 +79,11 @@ class AccountController extends Controller/** @var array $expense */foreach ($expenses as $expense) {$result[] = [- 'id' => (string)$expense['id'],+ 'id' => (string) $expense['id'],'name' => $expense['name'],'difference' => $expense['sum'],- 'difference_float' => (float)$expense['sum'], // intentional float- 'currency_id' => (string)$expense['currency_id'],+ 'difference_float' => (float) $expense['sum'], // intentional float+ 'currency_id' => (string) $expense['currency_id'],'currency_code' => $expense['currency_code'],];}@@ -107,11 +107,11 @@ class AccountController extends Controller/** @var array $expense */foreach ($expenses as $expense) {$result[] = [- 'id' => (string)$expense['id'],+ 'id' => (string) $expense['id'],'name' => $expense['name'],'difference' => $expense['sum'],- 'difference_float' => (float)$expense['sum'], // intentional float- 'currency_id' => (string)$expense['currency_id'],+ 'difference_float' => (float) $expense['sum'], // intentional float+ 'currency_id' => (string) $expense['currency_id'],'currency_code' => $expense['currency_code'],];}diff --git a/app/Api/V1/Controllers/Insight/Expense/BillController.php b/app/Api/V1/Controllers/Insight/Expense/BillController.phpindex 2a764e0884..6ff74baef4 100644--- a/app/Api/V1/Controllers/Insight/Expense/BillController.php+++ b/app/Api/V1/Controllers/Insight/Expense/BillController.php@@ -81,33 +81,33 @@ class BillController extends Controller$genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {- $billId = (int)$journal['bill_id'];- $currencyId = (int)$journal['currency_id'];- $foreignCurrencyId = (int)$journal['foreign_currency_id'];+ $billId = (int) $journal['bill_id'];+ $currencyId = (int) $journal['currency_id'];+ $foreignCurrencyId = (int) $journal['foreign_currency_id'];$key = sprintf('%d-%d', $billId, $currencyId);$foreignKey = sprintf('%d-%d', $billId, $foreignCurrencyId);if (0 !== $currencyId) {$response[$key] ??= [- 'id' => (string)$billId,+ 'id' => (string) $billId,'name' => $journal['bill_name'],'difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];$response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']);- $response[$key]['difference_float'] = (float)$response[$key]['difference']; // intentional float+ $response[$key]['difference_float'] = (float) $response[$key]['difference']; // intentional float}if (0 !== $foreignCurrencyId) {$response[$foreignKey] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$foreignCurrencyId,+ 'currency_id' => (string) $foreignCurrencyId,'currency_code' => $journal['foreign_currency_code'],];$response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']);- $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference']; // intentional float+ $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float}}@@ -135,28 +135,28 @@ class BillController extends Controller$genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {- $currencyId = (int)$journal['currency_id'];- $foreignCurrencyId = (int)$journal['foreign_currency_id'];+ $currencyId = (int) $journal['currency_id'];+ $foreignCurrencyId = (int) $journal['foreign_currency_id'];if (0 !== $currencyId) {$response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float}if (0 !== $foreignCurrencyId) {$response[$foreignCurrencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$foreignCurrencyId,+ 'currency_id' => (string) $foreignCurrencyId,'currency_code' => $journal['foreign_currency_code'],];$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);- $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference']; // intentional float+ $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // intentional float}}diff --git a/app/Api/V1/Controllers/Insight/Expense/BudgetController.php b/app/Api/V1/Controllers/Insight/Expense/BudgetController.phpindex 6aab81946a..5795cb114e 100644--- a/app/Api/V1/Controllers/Insight/Expense/BudgetController.php+++ b/app/Api/V1/Controllers/Insight/Expense/BudgetController.php@@ -85,11 +85,11 @@ class BudgetController extends Controller/** @var array $expense */foreach ($expenses as $expense) {$result[] = [- 'id' => (string)$budget->id,+ 'id' => (string) $budget->id,'name' => $budget->name,'difference' => $expense['sum'],- 'difference_float' => (float)$expense['sum'], // intentional float- 'currency_id' => (string)$expense['currency_id'],+ 'difference_float' => (float) $expense['sum'], // intentional float+ 'currency_id' => (string) $expense['currency_id'],'currency_code' => $expense['currency_code'],];}@@ -114,8 +114,8 @@ class BudgetController extends Controllerforeach ($expenses as $expense) {$result[] = ['difference' => $expense['sum'],- 'difference_float' => (float)$expense['sum'], // intentional float- 'currency_id' => (string)$expense['currency_id'],+ 'difference_float' => (float) $expense['sum'], // intentional float+ 'currency_id' => (string) $expense['currency_id'],'currency_code' => $expense['currency_code'],];}diff --git a/app/Api/V1/Controllers/Insight/Expense/CategoryController.php b/app/Api/V1/Controllers/Insight/Expense/CategoryController.phpindex 5ee6e77378..fd96e47ed7 100644--- a/app/Api/V1/Controllers/Insight/Expense/CategoryController.php+++ b/app/Api/V1/Controllers/Insight/Expense/CategoryController.php@@ -85,11 +85,11 @@ class CategoryController extends Controller/** @var array $expense */foreach ($expenses as $expense) {$result[] = [- 'id' => (string)$category->id,+ 'id' => (string) $category->id,'name' => $category->name,'difference' => $expense['sum'],- 'difference_float' => (float)$expense['sum'], // intentional float- 'currency_id' => (string)$expense['currency_id'],+ 'difference_float' => (float) $expense['sum'], // intentional float+ 'currency_id' => (string) $expense['currency_id'],'currency_code' => $expense['currency_code'],];}@@ -114,8 +114,8 @@ class CategoryController extends Controllerforeach ($expenses as $expense) {$result[] = ['difference' => $expense['sum'],- 'difference_float' => (float)$expense['sum'], // intentional float- 'currency_id' => (string)$expense['currency_id'],+ 'difference_float' => (float) $expense['sum'], // intentional float+ 'currency_id' => (string) $expense['currency_id'],'currency_code' => $expense['currency_code'],];}diff --git a/app/Api/V1/Controllers/Insight/Expense/PeriodController.php b/app/Api/V1/Controllers/Insight/Expense/PeriodController.phpindex a9d80e935d..9f091b8501 100644--- a/app/Api/V1/Controllers/Insight/Expense/PeriodController.php+++ b/app/Api/V1/Controllers/Insight/Expense/PeriodController.php@@ -51,28 +51,28 @@ class PeriodController extends Controller$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);$genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {- $currencyId = (int)$journal['currency_id'];- $foreignCurrencyId = (int)$journal['foreign_currency_id'];+ $currencyId = (int) $journal['currency_id'];+ $foreignCurrencyId = (int) $journal['foreign_currency_id'];if (0 !== $currencyId) {$response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float}if (0 !== $foreignCurrencyId) {$response[$foreignCurrencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$foreignCurrencyId,+ 'currency_id' => (string) $foreignCurrencyId,'currency_code' => $journal['foreign_currency_code'],];$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);- $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference']; // intentional float+ $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // intentional float}}diff --git a/app/Api/V1/Controllers/Insight/Expense/TagController.php b/app/Api/V1/Controllers/Insight/Expense/TagController.phpindex 093954ac45..b76dcc776a 100644--- a/app/Api/V1/Controllers/Insight/Expense/TagController.php+++ b/app/Api/V1/Controllers/Insight/Expense/TagController.php@@ -75,28 +75,28 @@ class TagController extends Controller$genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {- $currencyId = (int)$journal['currency_id'];- $foreignCurrencyId = (int)$journal['foreign_currency_id'];+ $currencyId = (int) $journal['currency_id'];+ $foreignCurrencyId = (int) $journal['foreign_currency_id'];if (0 !== $currencyId) {$response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose.+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.}if (0 !== $foreignCurrencyId) {$response[$foreignCurrencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$foreignCurrencyId,+ 'currency_id' => (string) $foreignCurrencyId,'currency_code' => $journal['foreign_currency_code'],];$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);- $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference']; // float but on purpose.+ $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // float but on purpose.}}@@ -130,8 +130,8 @@ class TagController extends Controller/** @var array $journal */foreach ($genericSet as $journal) {- $currencyId = (int)$journal['currency_id'];- $foreignCurrencyId = (int)$journal['foreign_currency_id'];+ $currencyId = (int) $journal['currency_id'];+ $foreignCurrencyId = (int) $journal['foreign_currency_id'];/** @var array $tag */foreach ($journal['tags'] as $tag) {@@ -142,15 +142,15 @@ class TagController extends Controller// on currency IDif (0 !== $currencyId) {$response[$key] ??= [- 'id' => (string)$tagId,+ 'id' => (string) $tagId,'name' => $tag['name'],'difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];$response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']);- $response[$key]['difference_float'] = (float)$response[$key]['difference']; // float but on purpose.+ $response[$key]['difference_float'] = (float) $response[$key]['difference']; // float but on purpose.}// on foreign ID@@ -158,11 +158,11 @@ class TagController extends Controller$response[$foreignKey] = $journal[$foreignKey] ?? ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$foreignCurrencyId,+ 'currency_id' => (string) $foreignCurrencyId,'currency_code' => $journal['foreign_currency_code'],];$response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']);- $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference']; // float but on purpose.+ $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // float but on purpose.}}}diff --git a/app/Api/V1/Controllers/Insight/Income/AccountController.php b/app/Api/V1/Controllers/Insight/Income/AccountController.phpindex 17e9d34205..5c7b28231e 100644--- a/app/Api/V1/Controllers/Insight/Income/AccountController.php+++ b/app/Api/V1/Controllers/Insight/Income/AccountController.php@@ -79,11 +79,11 @@ class AccountController extends Controller/** @var array $entry */foreach ($income as $entry) {$result[] = [- 'id' => (string)$entry['id'],+ 'id' => (string) $entry['id'],'name' => $entry['name'],'difference' => $entry['sum'],- 'difference_float' => (float)$entry['sum'], // float but on purpose.- 'currency_id' => (string)$entry['currency_id'],+ 'difference_float' => (float) $entry['sum'], // float but on purpose.+ 'currency_id' => (string) $entry['currency_id'],'currency_code' => $entry['currency_code'],];}@@ -107,11 +107,11 @@ class AccountController extends Controller/** @var array $entry */foreach ($income as $entry) {$result[] = [- 'id' => (string)$entry['id'],+ 'id' => (string) $entry['id'],'name' => $entry['name'],'difference' => $entry['sum'],- 'difference_float' => (float)$entry['sum'], // float but on purpose.- 'currency_id' => (string)$entry['currency_id'],+ 'difference_float' => (float) $entry['sum'], // float but on purpose.+ 'currency_id' => (string) $entry['currency_id'],'currency_code' => $entry['currency_code'],];}diff --git a/app/Api/V1/Controllers/Insight/Income/CategoryController.php b/app/Api/V1/Controllers/Insight/Income/CategoryController.phpindex 1f989dfe81..d2a1fa9744 100644--- a/app/Api/V1/Controllers/Insight/Income/CategoryController.php+++ b/app/Api/V1/Controllers/Insight/Income/CategoryController.php@@ -85,11 +85,11 @@ class CategoryController extends Controller/** @var array $expense */foreach ($expenses as $expense) {$result[] = [- 'id' => (string)$category->id,+ 'id' => (string) $category->id,'name' => $category->name,'difference' => $expense['sum'],- 'difference_float' => (float)$expense['sum'], // float but on purpose.- 'currency_id' => (string)$expense['currency_id'],+ 'difference_float' => (float) $expense['sum'], // float but on purpose.+ 'currency_id' => (string) $expense['currency_id'],'currency_code' => $expense['currency_code'],];}@@ -114,8 +114,8 @@ class CategoryController extends Controllerforeach ($expenses as $expense) {$result[] = ['difference' => $expense['sum'],- 'difference_float' => (float)$expense['sum'], // float but on purpose.- 'currency_id' => (string)$expense['currency_id'],+ 'difference_float' => (float) $expense['sum'], // float but on purpose.+ 'currency_id' => (string) $expense['currency_id'],'currency_code' => $expense['currency_code'],];}diff --git a/app/Api/V1/Controllers/Insight/Income/PeriodController.php b/app/Api/V1/Controllers/Insight/Income/PeriodController.phpindex f71c21fa14..970ffa2e52 100644--- a/app/Api/V1/Controllers/Insight/Income/PeriodController.php+++ b/app/Api/V1/Controllers/Insight/Income/PeriodController.php@@ -51,31 +51,31 @@ class PeriodController extends Controller$collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts);$genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {- $currencyId = (int)$journal['currency_id'];- $foreignCurrencyId = (int)$journal['foreign_currency_id'];+ $currencyId = (int) $journal['currency_id'];+ $foreignCurrencyId = (int) $journal['foreign_currency_id'];if (0 !== $currencyId) {$response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose.+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.}if (0 !== $foreignCurrencyId) {$response[$foreignCurrencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$foreignCurrencyId,+ 'currency_id' => (string) $foreignCurrencyId,'currency_code' => $journal['foreign_currency_code'],];$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'],app('steam')->positive($journal['foreign_amount']));- $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference']; // float but on purpose.+ $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference']; // float but on purpose.}}diff --git a/app/Api/V1/Controllers/Insight/Income/TagController.php b/app/Api/V1/Controllers/Insight/Income/TagController.phpindex 39dcd4a0f1..e0eece3e90 100644--- a/app/Api/V1/Controllers/Insight/Income/TagController.php+++ b/app/Api/V1/Controllers/Insight/Income/TagController.php@@ -76,31 +76,31 @@ class TagController extends Controller$genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {- $currencyId = (int)$journal['currency_id'];- $foreignCurrencyId = (int)$journal['foreign_currency_id'];+ $currencyId = (int) $journal['currency_id'];+ $foreignCurrencyId = (int) $journal['foreign_currency_id'];if (0 !== $currencyId) {$response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];}if (0 !== $foreignCurrencyId) {$response[$foreignCurrencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$foreignCurrencyId,+ 'currency_id' => (string) $foreignCurrencyId,'currency_code' => $journal['foreign_currency_code'],];$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'],app('steam')->positive($journal['foreign_amount']));- $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];+ $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];}}@@ -134,8 +134,8 @@ class TagController extends Controller/** @var array $journal */foreach ($genericSet as $journal) {- $currencyId = (int)$journal['currency_id'];- $foreignCurrencyId = (int)$journal['foreign_currency_id'];+ $currencyId = (int) $journal['currency_id'];+ $foreignCurrencyId = (int) $journal['foreign_currency_id'];/** @var array $tag */foreach ($journal['tags'] as $tag) {@@ -146,15 +146,15 @@ class TagController extends Controller// on currency IDif (0 !== $currencyId) {$response[$key] ??= [- 'id' => (string)$tagId,+ 'id' => (string) $tagId,'name' => $tag['name'],'difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];$response[$key]['difference'] = bcadd($response[$key]['difference'], app('steam')->positive($journal['amount']));- $response[$key]['difference_float'] = (float)$response[$key]['difference'];+ $response[$key]['difference_float'] = (float) $response[$key]['difference'];}// on foreign ID@@ -162,14 +162,14 @@ class TagController extends Controller$response[$foreignKey] = $journal[$foreignKey] ?? ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$foreignCurrencyId,+ 'currency_id' => (string) $foreignCurrencyId,'currency_code' => $journal['foreign_currency_code'],];$response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'],app('steam')->positive($journal['foreign_amount']));- $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference'];+ $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];}}}diff --git a/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php b/app/Api/V1/Controllers/Insight/Transfer/CategoryController.phpindex 49782d9fbe..6ad2c269df 100644--- a/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php+++ b/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php@@ -85,11 +85,11 @@ class CategoryController extends Controller/** @var array $expense */foreach ($expenses as $expense) {$result[] = [- 'id' => (string)$category->id,+ 'id' => (string) $category->id,'name' => $category->name,'difference' => $expense['sum'],- 'difference_float' => (float)$expense['sum'],- 'currency_id' => (string)$expense['currency_id'],+ 'difference_float' => (float) $expense['sum'],+ 'currency_id' => (string) $expense['currency_id'],'currency_code' => $expense['currency_code'],];}@@ -114,8 +114,8 @@ class CategoryController extends Controllerforeach ($expenses as $expense) {$result[] = ['difference' => $expense['sum'],- 'difference_float' => (float)$expense['sum'],- 'currency_id' => (string)$expense['currency_id'],+ 'difference_float' => (float) $expense['sum'],+ 'currency_id' => (string) $expense['currency_id'],'currency_code' => $expense['currency_code'],];}diff --git a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.phpindex bda338ae4d..f66f9776ee 100644--- a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php+++ b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php@@ -51,31 +51,31 @@ class PeriodController extends Controller$collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts);$genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {- $currencyId = (int)$journal['currency_id'];- $foreignCurrencyId = (int)$journal['foreign_currency_id'];+ $currencyId = (int) $journal['currency_id'];+ $foreignCurrencyId = (int) $journal['foreign_currency_id'];if (0 !== $currencyId) {$response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];}if (0 !== $foreignCurrencyId) {$response[$foreignCurrencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$foreignCurrencyId,+ 'currency_id' => (string) $foreignCurrencyId,'currency_code' => $journal['foreign_currency_code'],];$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'],app('steam')->positive($journal['foreign_amount']));- $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];+ $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];}}diff --git a/app/Api/V1/Controllers/Insight/Transfer/TagController.php b/app/Api/V1/Controllers/Insight/Transfer/TagController.phpindex 986dc6c2cf..6fa1fbdedd 100644--- a/app/Api/V1/Controllers/Insight/Transfer/TagController.php+++ b/app/Api/V1/Controllers/Insight/Transfer/TagController.php@@ -74,31 +74,31 @@ class TagController extends Controller$genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {- $currencyId = (int)$journal['currency_id'];- $foreignCurrencyId = (int)$journal['foreign_currency_id'];+ $currencyId = (int) $journal['currency_id'];+ $foreignCurrencyId = (int) $journal['foreign_currency_id'];if (0 !== $currencyId) {$response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];}if (0 !== $foreignCurrencyId) {$response[$foreignCurrencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$foreignCurrencyId,+ 'currency_id' => (string) $foreignCurrencyId,'currency_code' => $journal['foreign_currency_code'],];$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'],app('steam')->positive($journal['foreign_amount']));- $response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];+ $response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];}}@@ -132,8 +132,8 @@ class TagController extends Controller/** @var array $journal */foreach ($genericSet as $journal) {- $currencyId = (int)$journal['currency_id'];- $foreignCurrencyId = (int)$journal['foreign_currency_id'];+ $currencyId = (int) $journal['currency_id'];+ $foreignCurrencyId = (int) $journal['foreign_currency_id'];/** @var array $tag */foreach ($journal['tags'] as $tag) {@@ -144,15 +144,15 @@ class TagController extends Controller// on currency IDif (0 !== $currencyId) {$response[$key] ??= [- 'id' => (string)$tagId,+ 'id' => (string) $tagId,'name' => $tag['name'],'difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];$response[$key]['difference'] = bcadd($response[$key]['difference'], app('steam')->positive($journal['amount']));- $response[$key]['difference_float'] = (float)$response[$key]['difference'];+ $response[$key]['difference_float'] = (float) $response[$key]['difference'];}// on foreign ID@@ -160,14 +160,14 @@ class TagController extends Controller$response[$foreignKey] = $journal[$foreignKey] ?? ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$foreignCurrencyId,+ 'currency_id' => (string) $foreignCurrencyId,'currency_code' => $journal['foreign_currency_code'],];$response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'],app('steam')->positive($journal['foreign_amount']));- $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference']; // intentional float+ $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float}}}diff --git a/app/Api/V1/Controllers/Models/Attachment/ShowController.php b/app/Api/V1/Controllers/Models/Attachment/ShowController.phpindex c9b0371a0d..bb8e267a11 100644--- a/app/Api/V1/Controllers/Models/Attachment/ShowController.php+++ b/app/Api/V1/Controllers/Models/Attachment/ShowController.php@@ -105,7 +105,7 @@ class ShowController extends Controller->header('Expires', '0')->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')->header('Pragma', 'public')- ->header('Content-Length', (string)strlen($content))+ ->header('Content-Length', (string) strlen($content));return $response;diff --git a/app/Api/V1/Controllers/Models/PiggyBank/ListController.php b/app/Api/V1/Controllers/Models/PiggyBank/ListController.phpindex 8fda63be8e..a0b35ec09a 100644--- a/app/Api/V1/Controllers/Models/PiggyBank/ListController.php+++ b/app/Api/V1/Controllers/Models/PiggyBank/ListController.php@@ -61,28 +61,31 @@ class ListController extends Controller/*** This endpoint is documented at:- * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/piggy_banks/listAttachmentByPiggyBank+ * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/piggy_banks/listAccountByPiggyBank+ *+ * List single resource.** @throws FireflyException*/- public function attachments(PiggyBank $piggyBank): JsonResponse+ public function accounts(PiggyBank $piggyBank): JsonResponse{- $manager = $this->getManager();+ // types to get, page size:$pageSize = $this->parameters->get('limit');- $collection = $this->repository->getAttachments($piggyBank);+ $manager = $this->getManager();+ $collection = $piggyBank->accounts;$count = $collection->count();- $attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.piggy-banks.attachments', [$piggyBank->id]).$this->buildParams());+ $paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.piggy-banks.accounts', [$piggyBank->id]).$this->buildParams());- /** @var AttachmentTransformer $transformer */- $transformer = app(AttachmentTransformer::class);+ /** @var AccountTransformer $transformer */+ $transformer = app(AccountTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($attachments, $transformer, 'attachments');+ $resource = new FractalCollection($events, $transformer, 'accounts');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -90,31 +93,28 @@ class ListController extends Controller/*** This endpoint is documented at:- * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/piggy_banks/listEventByPiggyBank- *- * List single resource.+ * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/piggy_banks/listAttachmentByPiggyBank** @throws FireflyException*/- public function piggyBankEvents(PiggyBank $piggyBank): JsonResponse+ public function attachments(PiggyBank $piggyBank): JsonResponse{- // types to get, page size:- $pageSize = $this->parameters->get('limit');$manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');+ $collection = $this->repository->getAttachments($piggyBank);- $collection = $this->repository->getEvents($piggyBank);$count = $collection->count();- $events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.piggy-banks.events', [$piggyBank->id]).$this->buildParams());+ $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.piggy-banks.attachments', [$piggyBank->id]).$this->buildParams());- /** @var PiggyBankEventTransformer $transformer */- $transformer = app(PiggyBankEventTransformer::class);+ /** @var AttachmentTransformer $transformer */+ $transformer = app(AttachmentTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($events, $transformer, 'piggy_bank_events');+ $resource = new FractalCollection($attachments, $transformer, 'attachments');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -122,31 +122,31 @@ class ListController extends Controller/*** This endpoint is documented at:- * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/piggy_banks/listAccountByPiggyBank+ * https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/piggy_banks/listEventByPiggyBank** List single resource.** @throws FireflyException*/- public function accounts(PiggyBank $piggyBank): JsonResponse+ public function piggyBankEvents(PiggyBank $piggyBank): JsonResponse{// types to get, page size:$pageSize = $this->parameters->get('limit');$manager = $this->getManager();- $collection = $piggyBank->accounts;+ $collection = $this->repository->getEvents($piggyBank);$count = $collection->count();$events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:$paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.piggy-banks.accounts', [$piggyBank->id]).$this->buildParams());+ $paginator->setPath(route('api.v1.piggy-banks.events', [$piggyBank->id]).$this->buildParams());- /** @var AccountTransformer $transformer */- $transformer = app(AccountTransformer::class);+ /** @var PiggyBankEventTransformer $transformer */+ $transformer = app(PiggyBankEventTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($events, $transformer, 'accounts');+ $resource = new FractalCollection($events, $transformer, 'piggy_bank_events');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.phpindex 2607c280de..c96e04ff98 100644--- a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php@@ -91,7 +91,7 @@ class ListController extends Controller// filter list on currency preference:$collection = $unfiltered->filter(static function (Account $account) use ($currency, $accountRepository) {- $currencyId = (int)$accountRepository->getMetaValue($account, 'currency_id');+ $currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id');return $currencyId === $currency->id;}diff --git a/app/Api/V1/Controllers/Search/AccountController.php b/app/Api/V1/Controllers/Search/AccountController.phpindex d0c1ffa435..74ed89c978 100644--- a/app/Api/V1/Controllers/Search/AccountController.php+++ b/app/Api/V1/Controllers/Search/AccountController.php@@ -63,8 +63,8 @@ class AccountController extends Controllerpublic function search(Request $request): JsonResponse|Response{$manager = $this->getManager();- $query = trim((string)$request->get('query'));- $field = trim((string)$request->get('field'));+ $query = trim((string) $request->get('query'));+ $field = trim((string) $request->get('field'));$type = $request->get('type') ?? 'all';if ('' === $query || !in_array($field, $this->validFields, true)) {return response(null, 422);diff --git a/app/Api/V1/Controllers/Search/TransactionController.php b/app/Api/V1/Controllers/Search/TransactionController.phpindex 962a454253..b8a5d450d3 100644--- a/app/Api/V1/Controllers/Search/TransactionController.php+++ b/app/Api/V1/Controllers/Search/TransactionController.php@@ -47,8 +47,8 @@ class TransactionController extends Controllerpublic function search(Request $request, SearchInterface $searcher): JsonResponse{$manager = $this->getManager();- $fullQuery = (string)$request->get('query');- $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');+ $fullQuery = (string) $request->get('query');+ $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');$pageSize = $this->parameters->get('limit');$searcher->parseQuery($fullQuery);$searcher->setPage($page);diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.phpindex f1021ad5ec..a0d874c2b4 100644--- a/app/Api/V1/Controllers/Summary/BasicController.php+++ b/app/Api/V1/Controllers/Summary/BasicController.php@@ -135,7 +135,7 @@ class BasicController extends Controller/** @var array $transactionJournal */foreach ($set as $transactionJournal) {- $currencyId = (int)$transactionJournal['currency_id'];+ $currencyId = (int) $transactionJournal['currency_id'];$incomes[$currencyId] ??= '0';$incomes[$currencyId] = bcadd($incomes[$currencyId],@@ -153,7 +153,7 @@ class BasicController extends Controller/** @var array $transactionJournal */foreach ($set as $transactionJournal) {- $currencyId = (int)$transactionJournal['currency_id'];+ $currencyId = (int) $transactionJournal['currency_id'];$expenses[$currencyId] ??= '0';$expenses[$currencyId] = bcadd($expenses[$currencyId], $transactionJournal['amount']);$sums[$currencyId] ??= '0';@@ -172,7 +172,7 @@ class BasicController extends Controller'key' => sprintf('balance-in-%s', $currency->code),'title' => trans('firefly.box_balance_in_currency', ['currency' => $currency->symbol]),'monetary_value' => $sums[$currencyId] ?? '0',- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,@@ -185,7 +185,7 @@ class BasicController extends Controller'key' => sprintf('spent-in-%s', $currency->code),'title' => trans('firefly.box_spent_in_currency', ['currency' => $currency->symbol]),'monetary_value' => $expenses[$currencyId] ?? '0',- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,@@ -197,7 +197,7 @@ class BasicController extends Controller'key' => sprintf('earned-in-%s', $currency->code),'title' => trans('firefly.box_earned_in_currency', ['currency' => $currency->symbol]),'monetary_value' => $incomes[$currencyId] ?? '0',- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,@@ -231,7 +231,7 @@ class BasicController extends Controller'key' => sprintf('bills-paid-in-%s', $info['code']),'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $info['symbol']]),'monetary_value' => $amount,- 'currency_id' => (string)$info['id'],+ 'currency_id' => (string) $info['id'],'currency_code' => $info['code'],'currency_symbol' => $info['symbol'],'currency_decimal_places' => $info['decimal_places'],@@ -250,7 +250,7 @@ class BasicController extends Controller'key' => sprintf('bills-unpaid-in-%s', $info['code']),'title' => trans('firefly.box_bill_unpaid_in_currency', ['currency' => $info['symbol']]),'monetary_value' => $amount,- 'currency_id' => (string)$info['id'],+ 'currency_id' => (string) $info['id'],'currency_code' => $info['code'],'currency_symbol' => $info['symbol'],'currency_decimal_places' => $info['decimal_places'],@@ -277,21 +277,21 @@ class BasicController extends Controllerforeach ($spent as $row) {// either an amount was budgeted or 0 is available.- $amount = (string)($available[$row['currency_id']] ?? '0');+ $amount = (string) ($available[$row['currency_id']] ?? '0');$spentInCurrency = $row['sum'];$leftToSpend = bcadd($amount, $spentInCurrency);- $days = (int)$today->diffInDays($end, true) + 1;+ $days = (int) $today->diffInDays($end, true) + 1;$perDay = '0';if (0 !== $days && bccomp($leftToSpend, '0') > -1) {- $perDay = bcdiv($leftToSpend, (string)$days);+ $perDay = bcdiv($leftToSpend, (string) $days);}$return[] = ['key' => sprintf('left-to-spend-in-%s', $row['currency_code']),'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $row['currency_symbol']]),'monetary_value' => $leftToSpend,- 'currency_id' => (string)$row['currency_id'],+ 'currency_id' => (string) $row['currency_id'],'currency_code' => $row['currency_code'],'currency_symbol' => $row['currency_symbol'],'currency_decimal_places' => $row['currency_decimal_places'],@@ -351,7 +351,7 @@ class BasicController extends Controller'key' => sprintf('net-worth-in-%s', $data['currency_code']),'title' => trans('firefly.box_net_worth_in_currency', ['currency' => $data['currency_symbol']]),'monetary_value' => $amount,- 'currency_id' => (string)$data['currency_id'],+ 'currency_id' => (string) $data['currency_id'],'currency_code' => $data['currency_code'],'currency_symbol' => $data['currency_symbol'],'currency_decimal_places' => $data['currency_decimal_places'],diff --git a/app/Api/V1/Controllers/System/ConfigurationController.php b/app/Api/V1/Controllers/System/ConfigurationController.phpindex 2a853e95ae..2eb893b96b 100644--- a/app/Api/V1/Controllers/System/ConfigurationController.php+++ b/app/Api/V1/Controllers/System/ConfigurationController.php@@ -101,8 +101,8 @@ class ConfigurationController extends Controllerreturn ['is_demo_site' => $isDemoSite?->data,- 'permission_update_check' => null === $updateCheck ? null : (int)$updateCheck->data,- 'last_update_check' => null === $lastCheck ? null : (int)$lastCheck->data,+ 'permission_update_check' => null === $updateCheck ? null : (int) $updateCheck->data,+ 'last_update_check' => null === $lastCheck ? null : (int) $lastCheck->data,'single_user_mode' => $singleUser?->data,];}diff --git a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.phpindex 4ec6250dd2..f3dacae241 100644--- a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php+++ b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php@@ -83,12 +83,12 @@ class MoveTransactionsRequest extends FormRequest$data = $validator->getData();$repository = app(AccountRepositoryInterface::class);$repository->setUser(auth()->user());- $original = $repository->find((int)$data['original_account']);- $destination = $repository->find((int)$data['destination_account']);+ $original = $repository->find((int) $data['original_account']);+ $destination = $repository->find((int) $data['destination_account']);// not the same type:if ($original->accountType->type !== $destination->accountType->type) {- $validator->errors()->add('title', (string)trans('validation.same_account_type'));+ $validator->errors()->add('title', (string) trans('validation.same_account_type'));return;}@@ -98,7 +98,7 @@ class MoveTransactionsRequest extends FormRequest// check different scenario's.if (null === $originalCurrency xor null === $destinationCurrency) {- $validator->errors()->add('title', (string)trans('validation.same_account_currency'));+ $validator->errors()->add('title', (string) trans('validation.same_account_currency'));return;}@@ -107,7 +107,7 @@ class MoveTransactionsRequest extends FormRequestreturn;}if ($originalCurrency->code !== $destinationCurrency->code) {- $validator->errors()->add('title', (string)trans('validation.same_account_currency'));+ $validator->errors()->add('title', (string) trans('validation.same_account_currency'));}}}diff --git a/app/Api/V1/Requests/Data/Export/ExportRequest.php b/app/Api/V1/Requests/Data/Export/ExportRequest.phpindex f2cf10ce29..82808d78a4 100644--- a/app/Api/V1/Requests/Data/Export/ExportRequest.php+++ b/app/Api/V1/Requests/Data/Export/ExportRequest.php@@ -52,7 +52,7 @@ class ExportRequest extends FormRequest$accounts = new Collection();foreach ($parts as $part) {- $accountId = (int)$part;+ $accountId = (int) $part;if (0 !== $accountId) {$account = $repository->find($accountId);if (null !== $account && AccountType::ASSET === $account->accountType->type) {diff --git a/app/Api/V1/Requests/Insight/GenericRequest.php b/app/Api/V1/Requests/Insight/GenericRequest.phpindex 1bde6efeb7..893789e778 100644--- a/app/Api/V1/Requests/Insight/GenericRequest.php+++ b/app/Api/V1/Requests/Insight/GenericRequest.php@@ -88,7 +88,7 @@ class GenericRequest extends FormRequest$array = $this->get('accounts');if (is_array($array)) {foreach ($array as $accountId) {- $accountId = (int)$accountId;+ $accountId = (int) $accountId;$account = $repository->find($accountId);if (null !== $account) {$this->accounts->push($account);@@ -114,7 +114,7 @@ class GenericRequest extends FormRequest$array = $this->get('bills');if (is_array($array)) {foreach ($array as $billId) {- $billId = (int)$billId;+ $billId = (int) $billId;$bill = $repository->find($billId);if (null !== $bill) {$this->bills->push($bill);@@ -140,7 +140,7 @@ class GenericRequest extends FormRequest$array = $this->get('budgets');if (is_array($array)) {foreach ($array as $budgetId) {- $budgetId = (int)$budgetId;+ $budgetId = (int) $budgetId;$budget = $repository->find($budgetId);if (null !== $budget) {$this->budgets->push($budget);@@ -166,7 +166,7 @@ class GenericRequest extends FormRequest$array = $this->get('categories');if (is_array($array)) {foreach ($array as $categoryId) {- $categoryId = (int)$categoryId;+ $categoryId = (int) $categoryId;$category = $repository->find($categoryId);if (null !== $category) {$this->categories->push($category);@@ -240,7 +240,7 @@ class GenericRequest extends FormRequest$array = $this->get('tags');if (is_array($array)) {foreach ($array as $tagId) {- $tagId = (int)$tagId;+ $tagId = (int) $tagId;$tag = $repository->find($tagId);if (null !== $tag) {$this->tags->push($tag);diff --git a/app/Api/V1/Requests/Models/AvailableBudget/Request.php b/app/Api/V1/Requests/Models/AvailableBudget/Request.phpindex 2b8a6d3b7b..613855646f 100644--- a/app/Api/V1/Requests/Models/AvailableBudget/Request.php+++ b/app/Api/V1/Requests/Models/AvailableBudget/Request.php@@ -84,7 +84,7 @@ class Request extends FormRequest$start = new Carbon($data['start']);$end = new Carbon($data['end']);if ($end->isBefore($start)) {- $validator->errors()->add('end', (string)trans('validation.date_after'));+ $validator->errors()->add('end', (string) trans('validation.date_after'));}}}diff --git a/app/Api/V1/Requests/Models/Bill/StoreRequest.php b/app/Api/V1/Requests/Models/Bill/StoreRequest.phpindex 7884065e97..5966bfbcff 100644--- a/app/Api/V1/Requests/Models/Bill/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Bill/StoreRequest.php@@ -96,11 +96,11 @@ class StoreRequest extends FormRequest$validator->after(static function (Validator $validator): void {$data = $validator->getData();- $min = (string)($data['amount_min'] ?? '0');- $max = (string)($data['amount_max'] ?? '0');+ $min = (string) ($data['amount_min'] ?? '0');+ $max = (string) ($data['amount_max'] ?? '0');if (1 === bccomp($min, $max)) {- $validator->errors()->add('amount_min', (string)trans('validation.amount_min_over_max'));+ $validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max'));}});diff --git a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php b/app/Api/V1/Requests/Models/Bill/UpdateRequest.phpindex 0df5139965..4b666bac4a 100644--- a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php@@ -104,7 +104,7 @@ class UpdateRequest extends FormRequest$max = $data['amount_max'] ?? '0';if (1 === bccomp($min, $max)) {- $validator->errors()->add('amount_min', (string)trans('validation.amount_min_over_max'));+ $validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max'));}}}diff --git a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.phpindex 5b1917d21b..b4c416f1a3 100644--- a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php+++ b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php@@ -65,6 +65,25 @@ class StoreRequest extends FormRequestreturn $data;}+ private function parseAccounts(mixed $array): array+ {+ if (!is_array($array)) {+ return [];+ }+ $return = [];+ foreach ($array as $entry) {+ if (!is_array($entry)) {+ continue;+ }+ $return[] = [+ 'account_id' => $this->integerFromValue((string) ($entry['account_id'] ?? '0')),+ 'current_amount' => $this->clearString((string) ($entry['current_amount'] ?? '0')),+ ];+ }++ return $return;+ }+/*** The rules that the incoming request must be matched against.*/@@ -109,7 +128,7 @@ class StoreRequest extends FormRequest// check currency here.$accountCurrency = $repository->getAccountCurrency($account);$isMultiCurrency = $repository->getMetaValue($account, 'is_multi_currency');- $currentAmount = bcadd($currentAmount, (string)($array['current_amount'] ?? '0'));+ $currentAmount = bcadd($currentAmount, (string) ($array['current_amount'] ?? '0'));if ($accountCurrency->id !== $currency->id && 'true' !== $isMultiCurrency) {$validator->errors()->add(sprintf('accounts.%d', $index), trans('validation.invalid_account_currency'));}@@ -130,25 +149,6 @@ class StoreRequest extends FormRequest}}- private function parseAccounts(mixed $array): array- {- if (!is_array($array)) {- return [];- }- $return = [];- foreach ($array as $entry) {- if (!is_array($entry)) {- continue;- }- $return[] = [- 'account_id' => $this->integerFromValue((string) ($entry['account_id'] ?? '0')),- 'current_amount' => $this->clearString((string) ($entry['current_amount'] ?? '0')),- ];- }-- return $return;- }-private function getCurrencyFromData(array $data): TransactionCurrency{if (array_key_exists('transaction_currency_code', $data) && '' !== (string) $data['transaction_currency_code']) {diff --git a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.phpindex 3a40023f0c..dd2aa5fb82 100644--- a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php@@ -121,10 +121,10 @@ class StoreRequest extends FormRequest$current['moment'] = $repetition['moment'];}if (array_key_exists('skip', $repetition)) {- $current['skip'] = (int)$repetition['skip'];+ $current['skip'] = (int) $repetition['skip'];}if (array_key_exists('weekend', $repetition)) {- $current['weekend'] = (int)$repetition['weekend'];+ $current['weekend'] = (int) $repetition['weekend'];}$return[] = $current;diff --git a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.phpindex 616db3b0e2..8c7ab24f79 100644--- a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php@@ -101,15 +101,15 @@ class UpdateRequest extends FormRequest}if (array_key_exists('moment', $repetition)) {- $current['moment'] = (string)$repetition['moment'];+ $current['moment'] = (string) $repetition['moment'];}if (array_key_exists('skip', $repetition)) {- $current['skip'] = (int)$repetition['skip'];+ $current['skip'] = (int) $repetition['skip'];}if (array_key_exists('weekend', $repetition)) {- $current['weekend'] = (int)$repetition['weekend'];+ $current['weekend'] = (int) $repetition['weekend'];}$return[] = $current;}diff --git a/app/Api/V1/Requests/Models/Rule/StoreRequest.php b/app/Api/V1/Requests/Models/Rule/StoreRequest.phpindex 3975974862..fb5b511f4b 100644--- a/app/Api/V1/Requests/Models/Rule/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Rule/StoreRequest.php@@ -74,9 +74,9 @@ class StoreRequest extends FormRequest$return[] = ['type' => $trigger['type'] ?? '','value' => $trigger['value'] ?? null,- 'prohibited' => $this->convertBoolean((string)($trigger['prohibited'] ?? 'false')),- 'active' => $this->convertBoolean((string)($trigger['active'] ?? 'true')),- 'stop_processing' => $this->convertBoolean((string)($trigger['stop_processing'] ?? 'false')),+ 'prohibited' => $this->convertBoolean((string) ($trigger['prohibited'] ?? 'false')),+ 'active' => $this->convertBoolean((string) ($trigger['active'] ?? 'true')),+ 'stop_processing' => $this->convertBoolean((string) ($trigger['stop_processing'] ?? 'false')),];}}@@ -93,8 +93,8 @@ class StoreRequest extends FormRequest$return[] = ['type' => $action['type'],'value' => $action['value'],- 'active' => $this->convertBoolean((string)($action['active'] ?? 'true')),- 'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')),+ 'active' => $this->convertBoolean((string) ($action['active'] ?? 'true')),+ 'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')),];}}@@ -161,7 +161,7 @@ class StoreRequest extends FormRequest$triggers = $data['triggers'] ?? [];// need at least one triggerif (!is_countable($triggers) || 0 === count($triggers)) {- $validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));+ $validator->errors()->add('title', (string) trans('validation.at_least_one_trigger'));}}@@ -174,7 +174,7 @@ class StoreRequest extends FormRequest$actions = $data['actions'] ?? [];// need at least one triggerif (!is_countable($actions) || 0 === count($actions)) {- $validator->errors()->add('title', (string)trans('validation.at_least_one_action'));+ $validator->errors()->add('title', (string) trans('validation.at_least_one_action'));}}@@ -203,7 +203,7 @@ class StoreRequest extends FormRequest}}if (true === $allInactive) {- $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_trigger'));+ $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger'));}}@@ -232,7 +232,7 @@ class StoreRequest extends FormRequest}}if (true === $allInactive) {- $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_action'));+ $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action'));}}}diff --git a/app/Api/V1/Requests/Models/Rule/TestRequest.php b/app/Api/V1/Requests/Models/Rule/TestRequest.phpindex bed4427932..2703365859 100644--- a/app/Api/V1/Requests/Models/Rule/TestRequest.php+++ b/app/Api/V1/Requests/Models/Rule/TestRequest.php@@ -49,7 +49,7 @@ class TestRequest extends FormRequestprivate function getPage(): int{- return 0 === (int)$this->query('page') ? 1 : (int)$this->query('page');+ return 0 === (int) $this->query('page') ? 1 : (int) $this->query('page');}private function getDate(string $field): ?Carbon@@ -58,7 +58,7 @@ class TestRequest extends FormRequestif (is_array($value)) {return null;}- $value = (string)$value;+ $value = (string) $value;return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));}diff --git a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php b/app/Api/V1/Requests/Models/Rule/TriggerRequest.phpindex d1bc942fae..77f9a9e650 100644--- a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php+++ b/app/Api/V1/Requests/Models/Rule/TriggerRequest.php@@ -52,7 +52,7 @@ class TriggerRequest extends FormRequestif (is_array($value)) {return null;}- $value = (string)$value;+ $value = (string) $value;return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));}diff --git a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php b/app/Api/V1/Requests/Models/Rule/UpdateRequest.phpindex 7bfb395166..d9fecdc314 100644--- a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php@@ -109,8 +109,8 @@ class UpdateRequest extends FormRequest$return[] = ['type' => $action['type'],'value' => $action['value'],- 'active' => $this->convertBoolean((string)($action['active'] ?? 'false')),- 'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')),+ 'active' => $this->convertBoolean((string) ($action['active'] ?? 'false')),+ 'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')),];}}@@ -181,7 +181,7 @@ class UpdateRequest extends FormRequest$triggers = $data['triggers'] ?? null;// need at least one triggerif (is_array($triggers) && 0 === count($triggers)) {- $validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));+ $validator->errors()->add('title', (string) trans('validation.at_least_one_trigger'));}}@@ -208,7 +208,7 @@ class UpdateRequest extends FormRequest}}if (true === $allInactive) {- $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_trigger'));+ $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger'));}}@@ -221,7 +221,7 @@ class UpdateRequest extends FormRequest$actions = $data['actions'] ?? null;// need at least one actionif (is_array($actions) && 0 === count($actions)) {- $validator->errors()->add('title', (string)trans('validation.at_least_one_action'));+ $validator->errors()->add('title', (string) trans('validation.at_least_one_action'));}}@@ -249,7 +249,7 @@ class UpdateRequest extends FormRequest}}if (true === $allInactive) {- $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_action'));+ $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action'));}}}diff --git a/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php b/app/Api/V1/Requests/Models/RuleGroup/TestRequest.phpindex d87b6af6f3..839c6c15ed 100644--- a/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php+++ b/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php@@ -52,7 +52,7 @@ class TestRequest extends FormRequestif (is_array($value)) {return null;}- $value = (string)$value;+ $value = (string) $value;return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));}diff --git a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.phpindex 3e35334e85..fe9d0a002d 100644--- a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php+++ b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php@@ -52,7 +52,7 @@ class TriggerRequest extends FormRequestif (is_array($value)) {return null;}- $value = (string)$value;+ $value = (string) $value;return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));}diff --git a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php b/app/Api/V1/Requests/Models/Transaction/StoreRequest.phpindex 320629f598..9e4f63a05b 100644--- a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php@@ -84,73 +84,73 @@ class StoreRequest extends FormRequest$return[] = ['type' => $this->clearString($object['type']),'date' => $this->dateFromValue($object['date']),- 'order' => $this->integerFromValue((string)$object['order']),+ 'order' => $this->integerFromValue((string) $object['order']),- 'currency_id' => $this->integerFromValue((string)$object['currency_id']),- 'currency_code' => $this->clearString((string)$object['currency_code']),+ 'currency_id' => $this->integerFromValue((string) $object['currency_id']),+ 'currency_code' => $this->clearString((string) $object['currency_code']),// foreign currency info:- 'foreign_currency_id' => $this->integerFromValue((string)$object['foreign_currency_id']),- 'foreign_currency_code' => $this->clearString((string)$object['foreign_currency_code']),+ 'foreign_currency_id' => $this->integerFromValue((string) $object['foreign_currency_id']),+ 'foreign_currency_code' => $this->clearString((string) $object['foreign_currency_code']),// amount and foreign amount. Cannot be 0.- 'amount' => $this->clearString((string)$object['amount']),- 'foreign_amount' => $this->clearString((string)$object['foreign_amount']),+ 'amount' => $this->clearString((string) $object['amount']),+ 'foreign_amount' => $this->clearString((string) $object['foreign_amount']),// description.'description' => $this->clearString($object['description']),// source of transaction. If everything is null, assume cash account.- 'source_id' => $this->integerFromValue((string)$object['source_id']),- 'source_name' => $this->clearString((string)$object['source_name']),- 'source_iban' => $this->clearIban((string)$object['source_iban']),- 'source_number' => $this->clearString((string)$object['source_number']),- 'source_bic' => $this->clearString((string)$object['source_bic']),+ 'source_id' => $this->integerFromValue((string) $object['source_id']),+ 'source_name' => $this->clearString((string) $object['source_name']),+ 'source_iban' => $this->clearIban((string) $object['source_iban']),+ 'source_number' => $this->clearString((string) $object['source_number']),+ 'source_bic' => $this->clearString((string) $object['source_bic']),// destination of transaction. If everything is null, assume cash account.- 'destination_id' => $this->integerFromValue((string)$object['destination_id']),- 'destination_name' => $this->clearString((string)$object['destination_name']),- 'destination_iban' => $this->clearIban((string)$object['destination_iban']),- 'destination_number' => $this->clearString((string)$object['destination_number']),- 'destination_bic' => $this->clearString((string)$object['destination_bic']),+ 'destination_id' => $this->integerFromValue((string) $object['destination_id']),+ 'destination_name' => $this->clearString((string) $object['destination_name']),+ 'destination_iban' => $this->clearIban((string) $object['destination_iban']),+ 'destination_number' => $this->clearString((string) $object['destination_number']),+ 'destination_bic' => $this->clearString((string) $object['destination_bic']),// budget info- 'budget_id' => $this->integerFromValue((string)$object['budget_id']),- 'budget_name' => $this->clearString((string)$object['budget_name']),+ 'budget_id' => $this->integerFromValue((string) $object['budget_id']),+ 'budget_name' => $this->clearString((string) $object['budget_name']),// category info- 'category_id' => $this->integerFromValue((string)$object['category_id']),- 'category_name' => $this->clearString((string)$object['category_name']),+ 'category_id' => $this->integerFromValue((string) $object['category_id']),+ 'category_name' => $this->clearString((string) $object['category_name']),// journal bill reference. Optional. Will only work for withdrawals- 'bill_id' => $this->integerFromValue((string)$object['bill_id']),- 'bill_name' => $this->clearString((string)$object['bill_name']),+ 'bill_id' => $this->integerFromValue((string) $object['bill_id']),+ 'bill_name' => $this->clearString((string) $object['bill_name']),// piggy bank reference. Optional. Will only work for transfers- 'piggy_bank_id' => $this->integerFromValue((string)$object['piggy_bank_id']),- 'piggy_bank_name' => $this->clearString((string)$object['piggy_bank_name']),+ 'piggy_bank_id' => $this->integerFromValue((string) $object['piggy_bank_id']),+ 'piggy_bank_name' => $this->clearString((string) $object['piggy_bank_name']),// some other interesting properties- 'reconciled' => $this->convertBoolean((string)$object['reconciled']),- 'notes' => $this->clearStringKeepNewlines((string)$object['notes']),+ 'reconciled' => $this->convertBoolean((string) $object['reconciled']),+ 'notes' => $this->clearStringKeepNewlines((string) $object['notes']),'tags' => $this->arrayFromValue($object['tags']),// all custom fields:- 'internal_reference' => $this->clearString((string)$object['internal_reference']),- 'external_id' => $this->clearString((string)$object['external_id']),+ 'internal_reference' => $this->clearString((string) $object['internal_reference']),+ 'external_id' => $this->clearString((string) $object['external_id']),'original_source' => sprintf('ff3-v%s', config('firefly.version')),'recurrence_id' => $this->integerFromValue($object['recurrence_id']),- 'bunq_payment_id' => $this->clearString((string)$object['bunq_payment_id']),- 'external_url' => $this->clearString((string)$object['external_url']),-- 'sepa_cc' => $this->clearString((string)$object['sepa_cc']),- 'sepa_ct_op' => $this->clearString((string)$object['sepa_ct_op']),- 'sepa_ct_id' => $this->clearString((string)$object['sepa_ct_id']),- 'sepa_db' => $this->clearString((string)$object['sepa_db']),- 'sepa_country' => $this->clearString((string)$object['sepa_country']),- 'sepa_ep' => $this->clearString((string)$object['sepa_ep']),- 'sepa_ci' => $this->clearString((string)$object['sepa_ci']),- 'sepa_batch_id' => $this->clearString((string)$object['sepa_batch_id']),+ 'bunq_payment_id' => $this->clearString((string) $object['bunq_payment_id']),+ 'external_url' => $this->clearString((string) $object['external_url']),++ 'sepa_cc' => $this->clearString((string) $object['sepa_cc']),+ 'sepa_ct_op' => $this->clearString((string) $object['sepa_ct_op']),+ 'sepa_ct_id' => $this->clearString((string) $object['sepa_ct_id']),+ 'sepa_db' => $this->clearString((string) $object['sepa_db']),+ 'sepa_country' => $this->clearString((string) $object['sepa_country']),+ 'sepa_ep' => $this->clearString((string) $object['sepa_ep']),+ 'sepa_ci' => $this->clearString((string) $object['sepa_ci']),+ 'sepa_batch_id' => $this->clearString((string) $object['sepa_batch_id']),// custom date fields. Must be Carbon objects. Presence is optional.'interest_date' => $this->dateFromValue($object['interest_date']),'book_date' => $this->dateFromValue($object['book_date']),diff --git a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.phpindex b6a3f570b4..2d18b028e3 100644--- a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php@@ -137,7 +137,7 @@ class UpdateRequest extends FormRequest{foreach ($this->integerFields as $fieldName) {if (array_key_exists($fieldName, $transaction)) {- $current[$fieldName] = $this->integerFromValue((string)$transaction[$fieldName]);+ $current[$fieldName] = $this->integerFromValue((string) $transaction[$fieldName]);}}@@ -152,7 +152,7 @@ class UpdateRequest extends FormRequest{foreach ($this->stringFields as $fieldName) {if (array_key_exists($fieldName, $transaction)) {- $current[$fieldName] = $this->clearString((string)$transaction[$fieldName]);+ $current[$fieldName] = $this->clearString((string) $transaction[$fieldName]);}}@@ -167,7 +167,7 @@ class UpdateRequest extends FormRequest{foreach ($this->textareaFields as $fieldName) {if (array_key_exists($fieldName, $transaction)) {- $current[$fieldName] = $this->clearStringKeepNewlines((string)$transaction[$fieldName]); // keep newlines+ $current[$fieldName] = $this->clearStringKeepNewlines((string) $transaction[$fieldName]); // keep newlines}}@@ -183,8 +183,8 @@ class UpdateRequest extends FormRequestforeach ($this->dateFields as $fieldName) {app('log')->debug(sprintf('Now at date field %s', $fieldName));if (array_key_exists($fieldName, $transaction)) {- app('log')->debug(sprintf('New value: "%s"', (string)$transaction[$fieldName]));- $current[$fieldName] = $this->dateFromValue((string)$transaction[$fieldName]);+ app('log')->debug(sprintf('New value: "%s"', (string) $transaction[$fieldName]));+ $current[$fieldName] = $this->dateFromValue((string) $transaction[$fieldName]);}}@@ -199,7 +199,7 @@ class UpdateRequest extends FormRequest{foreach ($this->booleanFields as $fieldName) {if (array_key_exists($fieldName, $transaction)) {- $current[$fieldName] = $this->convertBoolean((string)$transaction[$fieldName]);+ $current[$fieldName] = $this->convertBoolean((string) $transaction[$fieldName]);}}@@ -234,7 +234,7 @@ class UpdateRequest extends FormRequest$current[$fieldName] = sprintf('%.12f', $value);}if (!is_float($value)) {- $current[$fieldName] = (string)$value;+ $current[$fieldName] = (string) $value;}}}diff --git a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.phpindex 61ed0dd4da..d395da5fd8 100644--- a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php+++ b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php@@ -98,8 +98,8 @@ class StoreRequest extends FormRequest$journalRepos->setUser($user);$data = $validator->getData();- $inwardId = (int)($data['inward_id'] ?? 0);- $outwardId = (int)($data['outward_id'] ?? 0);+ $inwardId = (int) ($data['inward_id'] ?? 0);+ $outwardId = (int) ($data['outward_id'] ?? 0);$inward = $journalRepos->find($inwardId);$outward = $journalRepos->find($outwardId);diff --git a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.phpindex 0a889b512e..5aaeb892cb 100644--- a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php@@ -100,8 +100,8 @@ class UpdateRequest extends FormRequest$inwardId = $data['inward_id'] ?? $existing->source_id;$outwardId = $data['outward_id'] ?? $existing->destination_id;- $inward = $journalRepos->find((int)$inwardId);- $outward = $journalRepos->find((int)$outwardId);+ $inward = $journalRepos->find((int) $inwardId);+ $outward = $journalRepos->find((int) $outwardId);if (null === $inward) {$inward = $existing->source;}diff --git a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php b/app/Api/V1/Requests/Models/Webhook/CreateRequest.phpindex 8ec63d234c..03720f9350 100644--- a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php+++ b/app/Api/V1/Requests/Models/Webhook/CreateRequest.php@@ -55,9 +55,9 @@ class CreateRequest extends FormRequest// this is the way.$return = $this->getAllData($fields);- $return['trigger'] = $triggers[$return['trigger']] ?? (int)$return['trigger'];- $return['response'] = $responses[$return['response']] ?? (int)$return['response'];- $return['delivery'] = $deliveries[$return['delivery']] ?? (int)$return['delivery'];+ $return['trigger'] = $triggers[$return['trigger']] ?? (int) $return['trigger'];+ $return['response'] = $responses[$return['response']] ?? (int) $return['response'];+ $return['delivery'] = $deliveries[$return['delivery']] ?? (int) $return['delivery'];return $return;}diff --git a/app/Api/V1/Requests/System/UserUpdateRequest.php b/app/Api/V1/Requests/System/UserUpdateRequest.phpindex 19cda61d3d..1fc0df7bb3 100644--- a/app/Api/V1/Requests/System/UserUpdateRequest.php+++ b/app/Api/V1/Requests/System/UserUpdateRequest.php@@ -94,7 +94,7 @@ class UserUpdateRequest extends FormRequest$isAdmin = auth()->user()->hasRole('owner');// not admin, and not own user?if (auth()->check() && false === $isAdmin && $current?->id !== auth()->user()->id) {- $validator->errors()->add('email', (string)trans('validation.invalid_selection'));+ $validator->errors()->add('email', (string) trans('validation.invalid_selection'));}});diff --git a/app/Api/V1/Requests/User/PreferenceStoreRequest.php b/app/Api/V1/Requests/User/PreferenceStoreRequest.phpindex 98b2ae006b..22ee8ad706 100644--- a/app/Api/V1/Requests/User/PreferenceStoreRequest.php+++ b/app/Api/V1/Requests/User/PreferenceStoreRequest.php@@ -49,7 +49,7 @@ class PreferenceStoreRequest extends FormRequest$array['data'] = false;}if (is_numeric($array['data'])) {- $array['data'] = (float)$array['data']; // intentional float.+ $array['data'] = (float) $array['data']; // intentional float.}return $array;diff --git a/app/Api/V1/Requests/User/PreferenceUpdateRequest.php b/app/Api/V1/Requests/User/PreferenceUpdateRequest.phpindex 3f62c47f87..7489f7e2de 100644--- a/app/Api/V1/Requests/User/PreferenceUpdateRequest.php+++ b/app/Api/V1/Requests/User/PreferenceUpdateRequest.php@@ -49,7 +49,7 @@ class PreferenceUpdateRequest extends FormRequest$array['data'] = false;}if (is_numeric($array['data'])) {- $array['data'] = (float)$array['data']; // intentional float.+ $array['data'] = (float) $array['data']; // intentional float.}return $array;diff --git a/app/Api/V2/Controllers/Autocomplete/AccountController.php b/app/Api/V2/Controllers/Autocomplete/AccountController.phpindex ffe030b4a3..1531c70ae0 100644--- a/app/Api/V2/Controllers/Autocomplete/AccountController.php+++ b/app/Api/V2/Controllers/Autocomplete/AccountController.php@@ -40,9 +40,9 @@ use Illuminate\Support\Facades\Log;*/class AccountController extends Controller{- private AccountRepositoryInterface $repository;- private TransactionCurrency $default;private ExchangeRateConverter $converter;+ private TransactionCurrency $default;+ private AccountRepositoryInterface $repository;/*** AccountController constructor.diff --git a/app/Api/V2/Controllers/Autocomplete/CategoryController.php b/app/Api/V2/Controllers/Autocomplete/CategoryController.phpindex 686e866e86..be81418f58 100644--- a/app/Api/V2/Controllers/Autocomplete/CategoryController.php+++ b/app/Api/V2/Controllers/Autocomplete/CategoryController.php@@ -63,7 +63,7 @@ class CategoryController extends Controller$filtered = $result->map(static function (Category $item) {return [- 'id' => (string)$item->id,+ 'id' => (string) $item->id,'title' => $item->name,'meta' => [],];diff --git a/app/Api/V2/Controllers/Chart/AccountController.php b/app/Api/V2/Controllers/Chart/AccountController.phpindex 9ba3f72b3b..26547af1b3 100644--- a/app/Api/V2/Controllers/Chart/AccountController.php+++ b/app/Api/V2/Controllers/Chart/AccountController.php@@ -45,9 +45,9 @@ class AccountController extends Controlleruse CollectsAccountsFromFilter;use ValidatesUserGroupTrait;- private AccountRepositoryInterface $repository;private ChartData $chartData;private TransactionCurrency $default;+ private AccountRepositoryInterface $repository;public function __construct(){diff --git a/app/Api/V2/Controllers/Chart/BalanceController.php b/app/Api/V2/Controllers/Chart/BalanceController.phpindex 91af9acb40..89a1c9f8cd 100644--- a/app/Api/V2/Controllers/Chart/BalanceController.php+++ b/app/Api/V2/Controllers/Chart/BalanceController.php@@ -45,9 +45,10 @@ class BalanceController extends Controlleruse CleansChartData;use CollectsAccountsFromFilter;- private AccountRepositoryInterface $repository;- private GroupCollectorInterface $collector;private ChartData $chartData;+ private GroupCollectorInterface $collector;+ private AccountRepositoryInterface $repository;+// private TransactionCurrency $default;public function __construct()diff --git a/app/Api/V2/Controllers/Controller.php b/app/Api/V2/Controllers/Controller.phpindex 4717fdae0c..738e0747c6 100644--- a/app/Api/V2/Controllers/Controller.php+++ b/app/Api/V2/Controllers/Controller.php@@ -54,9 +54,9 @@ class Controller extends BaseController{use ValidatesUserGroupTrait;- protected const string CONTENT_TYPE = 'application/vnd.api+json';+ protected const string CONTENT_TYPE = 'application/vnd.api+json';+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];protected ParameterBag $parameters;- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];public function __construct(){@@ -81,7 +81,7 @@ class Controller extends BaseController$bag->set('limit', 50);try {- $page = (int)request()->get('page');+ $page = (int) request()->get('page');} catch (ContainerExceptionInterface|NotFoundExceptionInterface $e) {$page = 1;}@@ -92,8 +92,8 @@ class Controller extends BaseControllerif ($page < 1) {$page = 1;}- if ($page > pow(2,16)) {- $page = pow(2,16);+ if ($page > 2 ** 16) {+ $page = 2 ** 16;}$bag->set('page', $page);@@ -111,10 +111,10 @@ class Controller extends BaseController}if (null !== $date) {try {- $obj = Carbon::parse((string)$date, config('app.timezone'));+ $obj = Carbon::parse((string) $date, config('app.timezone'));} catch (InvalidDateException|InvalidFormatException $e) {// don't care- app('log')->warning(sprintf('Ignored invalid date "%s" in API v2 controller parameter check: %s', substr((string)$date, 0, 20), $e->getMessage()));+ app('log')->warning(sprintf('Ignored invalid date "%s" in API v2 controller parameter check: %s', substr((string) $date, 0, 20), $e->getMessage()));}// out of range? set to null.if (null !== $obj && ($obj->year <= 1900 || $obj->year > 2099)) {@@ -138,11 +138,11 @@ class Controller extends BaseController$value = null;}if (null !== $value) {- $bag->set($integer, (int)$value);+ $bag->set($integer, (int) $value);}if (null === $value && 'limit' === $integer && auth()->check()) {// set default for user:- $pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;+ $pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;$bag->set($integer, $pageSize);}}diff --git a/app/Api/V2/Controllers/JsonApi/AccountController.php b/app/Api/V2/Controllers/JsonApi/AccountController.phpindex 230e4a92cc..e9f2c8bf62 100644--- a/app/Api/V2/Controllers/JsonApi/AccountController.php+++ b/app/Api/V2/Controllers/JsonApi/AccountController.php@@ -48,6 +48,7 @@ class AccountController extends Controlleruse Actions\DetachRelationship;use Actions\FetchMany;+// use Actions\FetchOne;use Actions\FetchRelated;use Actions\FetchRelationship;diff --git a/app/Api/V2/Controllers/Model/Account/IndexController.php b/app/Api/V2/Controllers/Model/Account/IndexController.phpindex 972a211ab2..7fa619db0e 100644--- a/app/Api/V2/Controllers/Model/Account/IndexController.php+++ b/app/Api/V2/Controllers/Model/Account/IndexController.php@@ -36,9 +36,8 @@ use Illuminate\Support\Facades\Log;class IndexController extends Controller{public const string RESOURCE_KEY = 'accounts';-- private AccountRepositoryInterface $repository;protected array $acceptedRoles = [UserRoleEnum::READ_ONLY, UserRoleEnum::MANAGE_TRANSACTIONS];+ private AccountRepositoryInterface $repository;/*** AccountController constructor.diff --git a/app/Api/V2/Controllers/Model/Account/ShowController.php b/app/Api/V2/Controllers/Model/Account/ShowController.phpindex f01efc9e72..4e7cbc218b 100644--- a/app/Api/V2/Controllers/Model/Account/ShowController.php+++ b/app/Api/V2/Controllers/Model/Account/ShowController.php@@ -39,9 +39,8 @@ use Illuminate\Http\JsonResponse;class ShowController extends Controller{public const string RESOURCE_KEY = 'accounts';-- private AccountRepositoryInterface $repository;protected array $acceptedRoles = [UserRoleEnum::READ_ONLY, UserRoleEnum::MANAGE_TRANSACTIONS];+ private AccountRepositoryInterface $repository;/*** AccountController constructor.diff --git a/app/Api/V2/Controllers/Model/ExchangeRate/IndexController.php b/app/Api/V2/Controllers/Model/ExchangeRate/IndexController.phpindex af8a87d432..c01c5a5e7c 100644--- a/app/Api/V2/Controllers/Model/ExchangeRate/IndexController.php+++ b/app/Api/V2/Controllers/Model/ExchangeRate/IndexController.php@@ -36,6 +36,7 @@ use Illuminate\Pagination\LengthAwarePaginator;class IndexController extends Controller{use ValidatesUserGroupTrait;+public const string RESOURCE_KEY = 'exchange-rates';private ExchangeRateRepositoryInterface $repository;diff --git a/app/Api/V2/Controllers/Model/ExchangeRate/ShowController.php b/app/Api/V2/Controllers/Model/ExchangeRate/ShowController.phpindex f67cf912b7..5a4f40c545 100644--- a/app/Api/V2/Controllers/Model/ExchangeRate/ShowController.php+++ b/app/Api/V2/Controllers/Model/ExchangeRate/ShowController.php@@ -38,6 +38,7 @@ use Illuminate\Pagination\LengthAwarePaginator;class ShowController extends Controller{use ValidatesUserGroupTrait;+public const string RESOURCE_KEY = 'exchange-rates';private ExchangeRateRepositoryInterface $repository;@@ -57,12 +58,12 @@ class ShowController extends Controllerpublic function show(TransactionCurrency $from, TransactionCurrency $to): JsonResponse{- $pageSize = $this->parameters->get('limit');- $page = $this->parameters->get('page');- $rates = $this->repository->getRates($from, $to);- $count = $rates->count();- $rates = $rates->slice(($page - 1) * $pageSize, $pageSize);- $paginator = new LengthAwarePaginator($rates, $count, $pageSize, $page);+ $pageSize = $this->parameters->get('limit');+ $page = $this->parameters->get('page');+ $rates = $this->repository->getRates($from, $to);+ $count = $rates->count();+ $rates = $rates->slice(($page - 1) * $pageSize, $pageSize);+ $paginator = new LengthAwarePaginator($rates, $count, $pageSize, $page);$transformer = new ExchangeRateTransformer();$transformer->setParameters($this->parameters); // give params to transformerdiff --git a/app/Api/V2/Controllers/Model/TransactionCurrency/IndexController.php b/app/Api/V2/Controllers/Model/TransactionCurrency/IndexController.phpindex 607a953b2e..a19fc67edf 100644--- a/app/Api/V2/Controllers/Model/TransactionCurrency/IndexController.php+++ b/app/Api/V2/Controllers/Model/TransactionCurrency/IndexController.php@@ -35,9 +35,8 @@ use Illuminate\Pagination\LengthAwarePaginator;class IndexController extends Controller{public const string RESOURCE_KEY = 'transaction-currencies';-- private CurrencyRepositoryInterface $repository;protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];+ private CurrencyRepositoryInterface $repository;public function __construct(){diff --git a/app/Api/V2/Controllers/Summary/BasicController.php b/app/Api/V2/Controllers/Summary/BasicController.phpindex 3d84a3f77b..4cab036873 100644--- a/app/Api/V2/Controllers/Summary/BasicController.php+++ b/app/Api/V2/Controllers/Summary/BasicController.php@@ -179,7 +179,7 @@ class BasicController extends Controller$return[] = ['key' => sprintf('bills-paid-in-%s', $info['currency_code']),'value' => $amount,- 'currency_id' => (string)$info['currency_id'],+ 'currency_id' => (string) $info['currency_id'],'currency_code' => $info['currency_code'],'currency_symbol' => $info['currency_symbol'],'currency_decimal_places' => $info['currency_decimal_places'],@@ -187,7 +187,7 @@ class BasicController extends Controller$return[] = ['key' => 'bills-paid-in-native','value' => $nativeAmount,- 'currency_id' => (string)$info['native_currency_id'],+ 'currency_id' => (string) $info['native_currency_id'],'currency_code' => $info['native_currency_code'],'currency_symbol' => $info['native_currency_symbol'],'currency_decimal_places' => $info['native_currency_decimal_places'],@@ -203,7 +203,7 @@ class BasicController extends Controller$return[] = ['key' => sprintf('bills-unpaid-in-%s', $info['currency_code']),'value' => $amount,- 'currency_id' => (string)$info['currency_id'],+ 'currency_id' => (string) $info['currency_id'],'currency_code' => $info['currency_code'],'currency_symbol' => $info['currency_symbol'],'currency_decimal_places' => $info['currency_decimal_places'],@@ -211,7 +211,7 @@ class BasicController extends Controller$return[] = ['key' => 'bills-unpaid-in-native','value' => $nativeAmount,- 'currency_id' => (string)$info['native_currency_id'],+ 'currency_id' => (string) $info['native_currency_id'],'currency_code' => $info['native_currency_code'],'currency_symbol' => $info['native_currency_symbol'],'currency_decimal_places' => $info['native_currency_decimal_places'],@@ -241,7 +241,7 @@ class BasicController extends Controller$nativeLeft = ['key' => 'left-to-spend-in-native','value' => '0',- 'currency_id' => (string)$default->id,+ 'currency_id' => (string) $default->id,'currency_code' => $default->code,'currency_symbol' => $default->symbol,'currency_decimal_places' => $default->decimal_places,@@ -249,7 +249,7 @@ class BasicController extends Controller$nativePerDay = ['key' => 'left-per-day-to-spend-in-native','value' => '0',- 'currency_id' => (string)$default->id,+ 'currency_id' => (string) $default->id,'currency_code' => $default->code,'currency_symbol' => $default->symbol,'currency_decimal_places' => $default->decimal_places,@@ -276,7 +276,7 @@ class BasicController extends Controller$currencies[$currencyId] = $currency;$amount = app('steam')->negative($journal['amount']);$amountNative = $converter->convert($default, $currency, $start, $amount);- if ((int)$journal['foreign_currency_id'] === $default->id) {+ if ((int) $journal['foreign_currency_id'] === $default->id) {$amountNative = $journal['foreign_amount'];}$spent = bcadd($spent, $amount);@@ -296,24 +296,24 @@ class BasicController extends Controllerapp('log')->debug(sprintf('Amount left is %s', $left));// how much left per day?- $days = (int)$today->diffInDays($end, true) + 1;+ $days = (int) $today->diffInDays($end, true) + 1;$perDay = '0';$perDayNative = '0';if (0 !== $days && bccomp($left, '0') > -1) {- $perDay = bcdiv($left, (string)$days);+ $perDay = bcdiv($left, (string) $days);}if (0 !== $days && bccomp($leftNative, '0') > -1) {- $perDayNative = bcdiv($leftNative, (string)$days);+ $perDayNative = bcdiv($leftNative, (string) $days);}// left$return[] = ['key' => sprintf('left-to-spend-in-%s', $row['currency_code']),'value' => $left,- 'currency_id' => (string)$row['currency_id'],+ 'currency_id' => (string) $row['currency_id'],'currency_code' => $row['currency_code'],'currency_symbol' => $row['currency_symbol'],- 'currency_decimal_places' => (int)$row['currency_decimal_places'],+ 'currency_decimal_places' => (int) $row['currency_decimal_places'],];// left (native)$nativeLeft['value'] = $leftNative;@@ -322,10 +322,10 @@ class BasicController extends Controller$return[] = ['key' => sprintf('left-per-day-to-spend-in-%s', $row['currency_code']),'value' => $perDay,- 'currency_id' => (string)$row['currency_id'],+ 'currency_id' => (string) $row['currency_id'],'currency_code' => $row['currency_code'],'currency_symbol' => $row['currency_symbol'],- 'currency_decimal_places' => (int)$row['currency_decimal_places'],+ 'currency_decimal_places' => (int) $row['currency_decimal_places'],];// left per day (native)@@ -371,7 +371,7 @@ class BasicController extends Controller$return[] = ['key' => 'net-worth-in-native','value' => $netWorthSet['native']['balance'],- 'currency_id' => (string)$netWorthSet['native']['currency_id'],+ 'currency_id' => (string) $netWorthSet['native']['currency_id'],'currency_code' => $netWorthSet['native']['currency_code'],'currency_symbol' => $netWorthSet['native']['currency_symbol'],'currency_decimal_places' => $netWorthSet['native']['currency_decimal_places'],@@ -383,7 +383,7 @@ class BasicController extends Controller$return[] = ['key' => sprintf('net-worth-in-%s', $data['currency_code']),'value' => $data['balance'],- 'currency_id' => (string)$data['currency_id'],+ 'currency_id' => (string) $data['currency_id'],'currency_code' => $data['currency_code'],'currency_symbol' => $data['currency_symbol'],'currency_decimal_places' => $data['currency_decimal_places'],diff --git a/app/Api/V2/Request/Autocomplete/AutocompleteRequest.php b/app/Api/V2/Request/Autocomplete/AutocompleteRequest.phpindex 3c933c5b46..958cf846e3 100644--- a/app/Api/V2/Request/Autocomplete/AutocompleteRequest.php+++ b/app/Api/V2/Request/Autocomplete/AutocompleteRequest.php@@ -73,6 +73,16 @@ class AutocompleteRequest extends FormRequestreturn $array;}+ private function getAccountTypeParameter(array $types): array+ {+ $return = [];+ foreach ($types as $type) {+ $return = array_merge($return, $this->mapAccountTypes($type));+ }++ return array_unique($return);+ }+public function rules(): array{$valid = array_keys($this->types);@@ -86,14 +96,4 @@ class AutocompleteRequest extends FormRequest'transaction_types' => 'nullable|in:todo',];}-- private function getAccountTypeParameter(array $types): array- {- $return = [];- foreach ($types as $type) {- $return = array_merge($return, $this->mapAccountTypes($type));- }-- return array_unique($return);- }}diff --git a/app/Api/V2/Request/Chart/BalanceChartRequest.php b/app/Api/V2/Request/Chart/BalanceChartRequest.phpindex 37322c1ea3..3f60442a89 100644--- a/app/Api/V2/Request/Chart/BalanceChartRequest.php+++ b/app/Api/V2/Request/Chart/BalanceChartRequest.php@@ -40,7 +40,8 @@ class BalanceChartRequest extends FormRequestuse ChecksLogin;use ConvertsDataTypes;use ValidatesUserGroupTrait;- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];++ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];/*** Get all data from the request.diff --git a/app/Api/V2/Request/Model/Transaction/InfiniteListRequest.php b/app/Api/V2/Request/Model/Transaction/InfiniteListRequest.phpindex f012ade56a..51c8b0460c 100644--- a/app/Api/V2/Request/Model/Transaction/InfiniteListRequest.php+++ b/app/Api/V2/Request/Model/Transaction/InfiniteListRequest.php@@ -87,7 +87,7 @@ class InfiniteListRequest extends FormRequestpublic function getAccountTypes(): array{- $type = (string)$this->get('type', 'default');+ $type = (string) $this->get('type', 'default');return $this->mapAccountTypes($type);}@@ -101,7 +101,7 @@ class InfiniteListRequest extends FormRequestpublic function getTransactionTypes(): array{- $type = (string)$this->get('type', 'default');+ $type = (string) $this->get('type', 'default');return $this->mapTransactionTypes($type);}diff --git a/app/Api/V2/Request/Model/Transaction/ListRequest.php b/app/Api/V2/Request/Model/Transaction/ListRequest.phpindex 45286d5cbf..3d72d70a00 100644--- a/app/Api/V2/Request/Model/Transaction/ListRequest.php+++ b/app/Api/V2/Request/Model/Transaction/ListRequest.php@@ -76,7 +76,7 @@ class ListRequest extends FormRequestpublic function getTransactionTypes(): array{- $type = (string)$this->get('type', 'default');+ $type = (string) $this->get('type', 'default');return $this->mapTransactionTypes($type);}diff --git a/app/Api/V2/Request/Model/Transaction/StoreRequest.php b/app/Api/V2/Request/Model/Transaction/StoreRequest.phpindex fcb4d7e206..542fc71f8b 100644--- a/app/Api/V2/Request/Model/Transaction/StoreRequest.php+++ b/app/Api/V2/Request/Model/Transaction/StoreRequest.php@@ -94,73 +94,73 @@ class StoreRequest extends FormRequest$result = ['type' => $this->clearString($object['type']),'date' => $this->dateFromValue($object['date']),- 'order' => $this->integerFromValue((string)$object['order']),+ 'order' => $this->integerFromValue((string) $object['order']),- 'currency_id' => $this->integerFromValue((string)$object['currency_id']),- 'currency_code' => $this->clearString((string)$object['currency_code']),+ 'currency_id' => $this->integerFromValue((string) $object['currency_id']),+ 'currency_code' => $this->clearString((string) $object['currency_code']),// foreign currency info:- 'foreign_currency_id' => $this->integerFromValue((string)$object['foreign_currency_id']),- 'foreign_currency_code' => $this->clearString((string)$object['foreign_currency_code']),+ 'foreign_currency_id' => $this->integerFromValue((string) $object['foreign_currency_id']),+ 'foreign_currency_code' => $this->clearString((string) $object['foreign_currency_code']),// amount and foreign amount. Cannot be 0.- 'amount' => $this->clearString((string)$object['amount']),- 'foreign_amount' => $this->clearString((string)$object['foreign_amount']),+ 'amount' => $this->clearString((string) $object['amount']),+ 'foreign_amount' => $this->clearString((string) $object['foreign_amount']),// description.'description' => $this->clearString($object['description']),// source of transaction. If everything is null, assume cash account.- 'source_id' => $this->integerFromValue((string)$object['source_id']),- 'source_name' => $this->clearString((string)$object['source_name']),- 'source_iban' => $this->clearString((string)$object['source_iban']),- 'source_number' => $this->clearString((string)$object['source_number']),- 'source_bic' => $this->clearString((string)$object['source_bic']),+ 'source_id' => $this->integerFromValue((string) $object['source_id']),+ 'source_name' => $this->clearString((string) $object['source_name']),+ 'source_iban' => $this->clearString((string) $object['source_iban']),+ 'source_number' => $this->clearString((string) $object['source_number']),+ 'source_bic' => $this->clearString((string) $object['source_bic']),// destination of transaction. If everything is null, assume cash account.- 'destination_id' => $this->integerFromValue((string)$object['destination_id']),- 'destination_name' => $this->clearString((string)$object['destination_name']),- 'destination_iban' => $this->clearString((string)$object['destination_iban']),- 'destination_number' => $this->clearString((string)$object['destination_number']),- 'destination_bic' => $this->clearString((string)$object['destination_bic']),+ 'destination_id' => $this->integerFromValue((string) $object['destination_id']),+ 'destination_name' => $this->clearString((string) $object['destination_name']),+ 'destination_iban' => $this->clearString((string) $object['destination_iban']),+ 'destination_number' => $this->clearString((string) $object['destination_number']),+ 'destination_bic' => $this->clearString((string) $object['destination_bic']),// budget info- 'budget_id' => $this->integerFromValue((string)$object['budget_id']),- 'budget_name' => $this->clearString((string)$object['budget_name']),+ 'budget_id' => $this->integerFromValue((string) $object['budget_id']),+ 'budget_name' => $this->clearString((string) $object['budget_name']),// category info- 'category_id' => $this->integerFromValue((string)$object['category_id']),- 'category_name' => $this->clearString((string)$object['category_name']),+ 'category_id' => $this->integerFromValue((string) $object['category_id']),+ 'category_name' => $this->clearString((string) $object['category_name']),// journal bill reference. Optional. Will only work for withdrawals- 'bill_id' => $this->integerFromValue((string)$object['bill_id']),- 'bill_name' => $this->clearString((string)$object['bill_name']),+ 'bill_id' => $this->integerFromValue((string) $object['bill_id']),+ 'bill_name' => $this->clearString((string) $object['bill_name']),// piggy bank reference. Optional. Will only work for transfers- 'piggy_bank_id' => $this->integerFromValue((string)$object['piggy_bank_id']),- 'piggy_bank_name' => $this->clearString((string)$object['piggy_bank_name']),+ 'piggy_bank_id' => $this->integerFromValue((string) $object['piggy_bank_id']),+ 'piggy_bank_name' => $this->clearString((string) $object['piggy_bank_name']),// some other interesting properties- 'reconciled' => $this->convertBoolean((string)$object['reconciled']),- 'notes' => $this->clearStringKeepNewlines((string)$object['notes']),+ 'reconciled' => $this->convertBoolean((string) $object['reconciled']),+ 'notes' => $this->clearStringKeepNewlines((string) $object['notes']),'tags' => $this->arrayFromValue($object['tags']),// all custom fields:- 'internal_reference' => $this->clearString((string)$object['internal_reference']),- 'external_id' => $this->clearString((string)$object['external_id']),+ 'internal_reference' => $this->clearString((string) $object['internal_reference']),+ 'external_id' => $this->clearString((string) $object['external_id']),'original_source' => sprintf('ff3-v%s', config('firefly.version')),'recurrence_id' => $this->integerFromValue($object['recurrence_id']),- 'bunq_payment_id' => $this->clearString((string)$object['bunq_payment_id']),- 'external_url' => $this->clearString((string)$object['external_url']),-- 'sepa_cc' => $this->clearString((string)$object['sepa_cc']),- 'sepa_ct_op' => $this->clearString((string)$object['sepa_ct_op']),- 'sepa_ct_id' => $this->clearString((string)$object['sepa_ct_id']),- 'sepa_db' => $this->clearString((string)$object['sepa_db']),- 'sepa_country' => $this->clearString((string)$object['sepa_country']),- 'sepa_ep' => $this->clearString((string)$object['sepa_ep']),- 'sepa_ci' => $this->clearString((string)$object['sepa_ci']),- 'sepa_batch_id' => $this->clearString((string)$object['sepa_batch_id']),+ 'bunq_payment_id' => $this->clearString((string) $object['bunq_payment_id']),+ 'external_url' => $this->clearString((string) $object['external_url']),++ 'sepa_cc' => $this->clearString((string) $object['sepa_cc']),+ 'sepa_ct_op' => $this->clearString((string) $object['sepa_ct_op']),+ 'sepa_ct_id' => $this->clearString((string) $object['sepa_ct_id']),+ 'sepa_db' => $this->clearString((string) $object['sepa_db']),+ 'sepa_country' => $this->clearString((string) $object['sepa_country']),+ 'sepa_ep' => $this->clearString((string) $object['sepa_ep']),+ 'sepa_ci' => $this->clearString((string) $object['sepa_ci']),+ 'sepa_batch_id' => $this->clearString((string) $object['sepa_batch_id']),// custom date fields. Must be Carbon objects. Presence is optional.'interest_date' => $this->dateFromValue($object['interest_date']),'book_date' => $this->dateFromValue($object['book_date']),diff --git a/app/Api/V2/Request/Model/Transaction/UpdateRequest.php b/app/Api/V2/Request/Model/Transaction/UpdateRequest.phpindex 98211ca0b4..ce5d6a95d3 100644--- a/app/Api/V2/Request/Model/Transaction/UpdateRequest.php+++ b/app/Api/V2/Request/Model/Transaction/UpdateRequest.php@@ -139,7 +139,7 @@ class UpdateRequest extends Request{foreach ($this->integerFields as $fieldName) {if (array_key_exists($fieldName, $transaction)) {- $current[$fieldName] = $this->integerFromValue((string)$transaction[$fieldName]);+ $current[$fieldName] = $this->integerFromValue((string) $transaction[$fieldName]);}}@@ -154,7 +154,7 @@ class UpdateRequest extends Request{foreach ($this->stringFields as $fieldName) {if (array_key_exists($fieldName, $transaction)) {- $current[$fieldName] = $this->clearString((string)$transaction[$fieldName]);+ $current[$fieldName] = $this->clearString((string) $transaction[$fieldName]);}}@@ -169,7 +169,7 @@ class UpdateRequest extends Request{foreach ($this->textareaFields as $fieldName) {if (array_key_exists($fieldName, $transaction)) {- $current[$fieldName] = $this->clearStringKeepNewlines((string)$transaction[$fieldName]); // keep newlines+ $current[$fieldName] = $this->clearStringKeepNewlines((string) $transaction[$fieldName]); // keep newlines}}@@ -185,8 +185,8 @@ class UpdateRequest extends Requestforeach ($this->dateFields as $fieldName) {app('log')->debug(sprintf('Now at date field %s', $fieldName));if (array_key_exists($fieldName, $transaction)) {- app('log')->debug(sprintf('New value: "%s"', (string)$transaction[$fieldName]));- $current[$fieldName] = $this->dateFromValue((string)$transaction[$fieldName]);+ app('log')->debug(sprintf('New value: "%s"', (string) $transaction[$fieldName]));+ $current[$fieldName] = $this->dateFromValue((string) $transaction[$fieldName]);}}@@ -201,7 +201,7 @@ class UpdateRequest extends Request{foreach ($this->booleanFields as $fieldName) {if (array_key_exists($fieldName, $transaction)) {- $current[$fieldName] = $this->convertBoolean((string)$transaction[$fieldName]);+ $current[$fieldName] = $this->convertBoolean((string) $transaction[$fieldName]);}}@@ -236,7 +236,7 @@ class UpdateRequest extends Request$current[$fieldName] = sprintf('%.12f', $value);}if (!is_float($value)) {- $current[$fieldName] = (string)$value;+ $current[$fieldName] = (string) $value;}}}diff --git a/app/Api/V2/Response/Sum/AutoSum.php b/app/Api/V2/Response/Sum/AutoSum.phpindex 6ed1faa73e..c4ca249fbb 100644--- a/app/Api/V2/Response/Sum/AutoSum.php+++ b/app/Api/V2/Response/Sum/AutoSum.php@@ -52,7 +52,7 @@ class AutoSum$amount = $getSum($object);$return[$currency->id] ??= [- 'id' => (string)$currency->id,+ 'id' => (string) $currency->id,'name' => $currency->name,'symbol' => $currency->symbol,'code' => $currency->code,diff --git a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.phpindex a1dcf6c476..da5aa1a66c 100644--- a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php+++ b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php@@ -115,7 +115,7 @@ class CorrectOpeningBalanceCurrencies extends Command{$currency = $this->getCurrency($account);$count = 0;- if ((int)$journal->transaction_currency_id !== $currency->id) {+ if ((int) $journal->transaction_currency_id !== $currency->id) {$journal->transaction_currency_id = $currency->id;$journal->save();$count = 1;diff --git a/app/Console/Commands/Correction/DeleteEmptyJournals.php b/app/Console/Commands/Correction/DeleteEmptyJournals.phpindex 3df105fdf1..a61319a501 100644--- a/app/Console/Commands/Correction/DeleteEmptyJournals.php+++ b/app/Console/Commands/Correction/DeleteEmptyJournals.php@@ -65,7 +65,7 @@ class DeleteEmptyJournals extends Command/** @var Transaction $row */foreach ($set as $row) {- $count = (int)$row->the_count;+ $count = (int) $row->the_count;if (1 === $count % 2) {// uneven number, delete journal and transactions:try {diff --git a/app/Console/Commands/Correction/DeleteOrphanedTransactions.php b/app/Console/Commands/Correction/DeleteOrphanedTransactions.phpindex f0c64e4bf0..ea7ae6481a 100644--- a/app/Console/Commands/Correction/DeleteOrphanedTransactions.php+++ b/app/Console/Commands/Correction/DeleteOrphanedTransactions.php@@ -103,7 +103,7 @@ class DeleteOrphanedTransactions extends Command/** @var \stdClass $entry */foreach ($set as $entry) {- $transaction = Transaction::find((int)$entry->transaction_id);+ $transaction = Transaction::find((int) $entry->transaction_id);if (null !== $transaction) {$transaction->delete();$this->friendlyWarning(diff --git a/app/Console/Commands/Correction/EnableCurrencies.php b/app/Console/Commands/Correction/EnableCurrencies.phpindex 3f7386f625..ee87d2c5f1 100644--- a/app/Console/Commands/Correction/EnableCurrencies.php+++ b/app/Console/Commands/Correction/EnableCurrencies.php@@ -77,7 +77,7 @@ class EnableCurrencies extends Command->where('account_meta.name', 'currency_id')->groupBy('data')->get(['data']);foreach ($meta as $entry) {- $found[] = (int)$entry->data;+ $found[] = (int) $entry->data;}// get all from journals:@@ -85,7 +85,7 @@ class EnableCurrencies extends Command->groupBy('transaction_currency_id')->get(['transaction_currency_id']);foreach ($journals as $entry) {- $found[] = (int)$entry->transaction_currency_id;+ $found[] = (int) $entry->transaction_currency_id;}// get all from transactions@@ -95,8 +95,8 @@ class EnableCurrencies extends Command->get(['transactions.transaction_currency_id', 'transactions.foreign_currency_id']);foreach ($transactions as $entry) {- $found[] = (int)$entry->transaction_currency_id;- $found[] = (int)$entry->foreign_currency_id;+ $found[] = (int) $entry->transaction_currency_id;+ $found[] = (int) $entry->foreign_currency_id;}// get all from budget limitsdiff --git a/app/Console/Commands/Correction/FixFrontpageAccounts.php b/app/Console/Commands/Correction/FixFrontpageAccounts.phpindex 883520e397..61f238b29c 100644--- a/app/Console/Commands/Correction/FixFrontpageAccounts.php+++ b/app/Console/Commands/Correction/FixFrontpageAccounts.php@@ -74,7 +74,7 @@ class FixFrontpageAccounts extends Commandif (is_array($data)) {/** @var string $accountId */foreach ($data as $accountId) {- $accountIdInt = (int)$accountId;+ $accountIdInt = (int) $accountId;$account = $repository->find($accountIdInt);if (null !== $account&& in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true)diff --git a/app/Console/Commands/Correction/FixGroupAccounts.php b/app/Console/Commands/Correction/FixGroupAccounts.phpindex 51847ce2c0..76ee8721dd 100644--- a/app/Console/Commands/Correction/FixGroupAccounts.php+++ b/app/Console/Commands/Correction/FixGroupAccounts.php@@ -53,8 +53,8 @@ class FixGroupAccounts extends Command/** @var TransactionJournal $journal */foreach ($res as $journal) {- if ((int)$journal->the_count > 1) {- $groups[] = (int)$journal->transaction_group_id;+ if ((int) $journal->the_count > 1) {+ $groups[] = (int) $journal->transaction_group_id;}}$handler = new UpdatedGroupEventHandler();diff --git a/app/Console/Commands/Correction/FixLongDescriptions.php b/app/Console/Commands/Correction/FixLongDescriptions.phpindex 6830dd40e9..65068f62d0 100644--- a/app/Console/Commands/Correction/FixLongDescriptions.php+++ b/app/Console/Commands/Correction/FixLongDescriptions.php@@ -62,7 +62,7 @@ class FixLongDescriptions extends Command/** @var TransactionGroup $group */foreach ($groups as $group) {- if (strlen((string)$group->title) > self::MAX_LENGTH) {+ if (strlen((string) $group->title) > self::MAX_LENGTH) {$group->title = substr($group->title, 0, self::MAX_LENGTH);$group->save();$this->friendlyWarning(sprintf('Truncated description of transaction group #%d', $group->id));diff --git a/app/Console/Commands/Correction/FixTransactionTypes.php b/app/Console/Commands/Correction/FixTransactionTypes.phpindex 75059602f7..9b271fb7f4 100644--- a/app/Console/Commands/Correction/FixTransactionTypes.php+++ b/app/Console/Commands/Correction/FixTransactionTypes.php@@ -92,7 +92,7 @@ class FixTransactionTypes extends Commandreturn false;}- $expectedType = (string)config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));+ $expectedType = (string) config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));if ($expectedType !== $type) {$this->friendlyWarning(sprintf(diff --git a/app/Console/Commands/Correction/FixUnevenAmount.php b/app/Console/Commands/Correction/FixUnevenAmount.phpindex fb07972d35..88af6a9a5d 100644--- a/app/Console/Commands/Correction/FixUnevenAmount.php+++ b/app/Console/Commands/Correction/FixUnevenAmount.php@@ -62,72 +62,67 @@ class FixUnevenAmount extends Commandreturn 0;}- private function fixJournal(int $param): void+ private function convertOldStyleTransfers(): void{- // one of the transactions is bad.- $journal = TransactionJournal::find($param);- if (null === $journal) {- return;- }-- /** @var null|Transaction $source */- $source = $journal->transactions()->where('amount', '<', 0)->first();+ Log::debug('convertOldStyleTransfers()');+ // select transactions with a foreign amount and a foreign currency. and it's a transfer. and they are different.+ $transactions = Transaction::distinct()+ ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')+ ->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')+ ->where('transaction_types.type', TransactionTypeEnum::TRANSFER->value)+ ->whereNotNull('foreign_currency_id')+ ->whereNotNull('foreign_amount')->get(['transactions.transaction_journal_id'])+ ;+ $count = 0;- if (null === $source) {- $this->friendlyError(- sprintf(- 'Journal #%d ("%s") has no source transaction. It will be deleted to maintain database consistency.',- $journal->id ?? 0,- $journal->description ?? ''- )- );- Transaction::where('transaction_journal_id', $journal->id ?? 0)->forceDelete();- TransactionJournal::where('id', $journal->id ?? 0)->forceDelete();- ++$this->count;+ Log::debug(sprintf('Found %d potential journal(s)', $transactions->count()));- return;- }+ /** @var Transaction $transaction */+ foreach ($transactions as $transaction) {+ /** @var null|TransactionJournal $journal */+ $journal = TransactionJournal::find($transaction->transaction_journal_id);+ if (null === $journal) {+ Log::debug('Found no journal, continue.');- $amount = bcmul('-1', $source->amount);+ continue;+ }+ // needs to be a transfer.+ if (TransactionType::TRANSFER !== $journal->transactionType->type) {+ Log::debug('Must be a transfer, continue.');- // fix amount of destination:- /** @var null|Transaction $destination */- $destination = $journal->transactions()->where('amount', '>', 0)->first();+ continue;+ }- if (null === $destination) {- $this->friendlyError(- sprintf(- 'Journal #%d ("%s") has no destination transaction. It will be deleted to maintain database consistency.',- $journal->id ?? 0,- $journal->description ?? ''- )- );+ /** @var null|Transaction $destination */+ $destination = $journal->transactions()->where('amount', '>', 0)->first();- Transaction::where('transaction_journal_id', $journal->id ?? 0)->forceDelete();- TransactionJournal::where('id', $journal->id ?? 0)->forceDelete();- ++$this->count;+ /** @var null|Transaction $source */+ $source = $journal->transactions()->where('amount', '<', 0)->first();+ if (null === $destination || null === $source) {+ Log::debug('Source or destination transaction is NULL, continue.');- return;+ // will be picked up later.+ continue;+ }+ if ($source->transaction_currency_id === $destination->transaction_currency_id) {+ Log::debug('Ready to swap data between transactions.');+ $destination->foreign_currency_id = $source->transaction_currency_id;+ $destination->foreign_amount = app('steam')->positive($source->amount);+ $destination->transaction_currency_id = $source->foreign_currency_id;+ $destination->amount = app('steam')->positive($source->foreign_amount);+ $destination->balance_dirty = true;+ $source->balance_dirty = true;+ $destination->save();+ $source->save();+ $this->friendlyWarning(sprintf('Corrected foreign amounts of transfer #%d.', $journal->id));+ ++$count;+ }}-- // may still be able to salvage this journal if it is a transfer with foreign currency info- if ($this->isForeignCurrencyTransfer($journal)) {- Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));+ if (0 === $count) {+ $this->friendlyPositive('No "old style" foreign currency transfers.');return;}-- $message = sprintf('Sum of journal #%d is not zero, journal is broken and now fixed.', $journal->id);-- $this->friendlyWarning($message);- app('log')->warning($message);-- $destination->amount = $amount;- $destination->save();-- $message = sprintf('Corrected amount in transaction journal #%d', $param);- $this->friendlyInfo($message);- ++$this->count;}private function fixUnevenAmounts(): void@@ -174,32 +169,72 @@ class FixUnevenAmount extends Command}}- private function matchCurrencies(): void+ private function fixJournal(int $param): void{- $journals = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', 'transactions.transaction_journal_id')- ->where('transactions.transaction_currency_id', '!=', \DB::raw('transaction_journals.transaction_currency_id'))- ->get(['transaction_journals.*'])- ;+ // one of the transactions is bad.+ $journal = TransactionJournal::find($param);+ if (null === $journal) {+ return;+ }- $count = 0;+ /** @var null|Transaction $source */+ $source = $journal->transactions()->where('amount', '<', 0)->first();- /** @var TransactionJournal $journal */- foreach ($journals as $journal) {- if (!$this->isForeignCurrencyTransfer($journal)) {- Transaction::where('transaction_journal_id', $journal->id)->update(['transaction_currency_id' => $journal->transaction_currency_id]);- ++$count;+ if (null === $source) {+ $this->friendlyError(+ sprintf(+ 'Journal #%d ("%s") has no source transaction. It will be deleted to maintain database consistency.',+ $journal->id ?? 0,+ $journal->description ?? ''+ )+ );+ Transaction::where('transaction_journal_id', $journal->id ?? 0)->forceDelete();+ TransactionJournal::where('id', $journal->id ?? 0)->forceDelete();+ ++$this->count;- continue;- }- Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));+ return;}- if (0 === $count) {- $this->friendlyPositive('Journal currency integrity is OK');++ $amount = bcmul('-1', $source->amount);++ // fix amount of destination:+ /** @var null|Transaction $destination */+ $destination = $journal->transactions()->where('amount', '>', 0)->first();++ if (null === $destination) {+ $this->friendlyError(+ sprintf(+ 'Journal #%d ("%s") has no destination transaction. It will be deleted to maintain database consistency.',+ $journal->id ?? 0,+ $journal->description ?? ''+ )+ );++ Transaction::where('transaction_journal_id', $journal->id ?? 0)->forceDelete();+ TransactionJournal::where('id', $journal->id ?? 0)->forceDelete();+ ++$this->count;return;}- $this->friendlyPositive(sprintf('Fixed %d journal(s) with mismatched currencies.', $journals->count()));+ // may still be able to salvage this journal if it is a transfer with foreign currency info+ if ($this->isForeignCurrencyTransfer($journal)) {+ Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));++ return;+ }++ $message = sprintf('Sum of journal #%d is not zero, journal is broken and now fixed.', $journal->id);++ $this->friendlyWarning($message);+ app('log')->warning($message);++ $destination->amount = $amount;+ $destination->save();++ $message = sprintf('Corrected amount in transaction journal #%d', $param);+ $this->friendlyInfo($message);+ ++$this->count;}private function isForeignCurrencyTransfer(TransactionJournal $journal): bool@@ -236,66 +271,31 @@ class FixUnevenAmount extends Commandreturn false;}- private function convertOldStyleTransfers(): void+ private function matchCurrencies(): void{- Log::debug('convertOldStyleTransfers()');- // select transactions with a foreign amount and a foreign currency. and it's a transfer. and they are different.- $transactions = Transaction::distinct()- ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')- ->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')- ->where('transaction_types.type', TransactionTypeEnum::TRANSFER->value)- ->whereNotNull('foreign_currency_id')- ->whereNotNull('foreign_amount')->get(['transactions.transaction_journal_id'])+ $journals = TransactionJournal::leftJoin('transactions', 'transaction_journals.id', 'transactions.transaction_journal_id')+ ->where('transactions.transaction_currency_id', '!=', \DB::raw('transaction_journals.transaction_currency_id'))+ ->get(['transaction_journals.*']);- $count = 0;-- Log::debug(sprintf('Found %d potential journal(s)', $transactions->count()));-- /** @var Transaction $transaction */- foreach ($transactions as $transaction) {- /** @var null|TransactionJournal $journal */- $journal = TransactionJournal::find($transaction->transaction_journal_id);- if (null === $journal) {- Log::debug('Found no journal, continue.');- continue;- }- // needs to be a transfer.- if (TransactionType::TRANSFER !== $journal->transactionType->type) {- Log::debug('Must be a transfer, continue.');-- continue;- }-- /** @var null|Transaction $destination */- $destination = $journal->transactions()->where('amount', '>', 0)->first();+ $count = 0;- /** @var null|Transaction $source */- $source = $journal->transactions()->where('amount', '<', 0)->first();- if (null === $destination || null === $source) {- Log::debug('Source or destination transaction is NULL, continue.');+ /** @var TransactionJournal $journal */+ foreach ($journals as $journal) {+ if (!$this->isForeignCurrencyTransfer($journal)) {+ Transaction::where('transaction_journal_id', $journal->id)->update(['transaction_currency_id' => $journal->transaction_currency_id]);+ ++$count;- // will be picked up later.continue;}- if ($source->transaction_currency_id === $destination->transaction_currency_id) {- Log::debug('Ready to swap data between transactions.');- $destination->foreign_currency_id = $source->transaction_currency_id;- $destination->foreign_amount = app('steam')->positive($source->amount);- $destination->transaction_currency_id = $source->foreign_currency_id;- $destination->amount = app('steam')->positive($source->foreign_amount);- $destination->balance_dirty = true;- $source->balance_dirty = true;- $destination->save();- $source->save();- $this->friendlyWarning(sprintf('Corrected foreign amounts of transfer #%d.', $journal->id));- ++$count;- }+ Log::debug(sprintf('Can skip foreign currency transfer #%d.', $journal->id));}if (0 === $count) {- $this->friendlyPositive('No "old style" foreign currency transfers.');+ $this->friendlyPositive('Journal currency integrity is OK');return;}++ $this->friendlyPositive(sprintf('Fixed %d journal(s) with mismatched currencies.', $journals->count()));}}diff --git a/app/Console/Commands/Correction/RecalculateNativeAmounts.php b/app/Console/Commands/Correction/RecalculateNativeAmounts.phpindex 0cb73efd05..bb4097a542 100644--- a/app/Console/Commands/Correction/RecalculateNativeAmounts.php+++ b/app/Console/Commands/Correction/RecalculateNativeAmounts.php@@ -181,17 +181,6 @@ class RecalculateNativeAmounts extends CommandLog::debug(sprintf('Recalculated %d auto budgets.', $set->count()));}- private function recalculateBills(UserGroup $userGroup, TransactionCurrency $currency): void- {- $set = $userGroup->bills()->where('transaction_currency_id', '!=', $currency->id)->get();-- /** @var Bill $bill */- foreach ($set as $bill) {- $bill->touch();- }- Log::debug(sprintf('Recalculated %d bills.', $set->count()));- }-private function recalculateAvailableBudgets(UserGroup $userGroup, TransactionCurrency $currency): void{Log::debug('Start with available budgets.');@@ -204,6 +193,17 @@ class RecalculateNativeAmounts extends CommandLog::debug(sprintf('Recalculated %d available budgets.', $set->count()));}+ private function recalculateBills(UserGroup $userGroup, TransactionCurrency $currency): void+ {+ $set = $userGroup->bills()->where('transaction_currency_id', '!=', $currency->id)->get();++ /** @var Bill $bill */+ foreach ($set as $bill) {+ $bill->touch();+ }+ Log::debug(sprintf('Recalculated %d bills.', $set->count()));+ }+private function calculateTransactions(UserGroup $userGroup, TransactionCurrency $currency): void{// custom query because of the potential size of this update.diff --git a/app/Console/Commands/Export/ExportData.php b/app/Console/Commands/Export/ExportData.phpindex 0cd55a9804..e28ffa39a9 100644--- a/app/Console/Commands/Export/ExportData.php+++ b/app/Console/Commands/Export/ExportData.php@@ -231,7 +231,7 @@ class ExportData extends Command{$final = new Collection();$accounts = new Collection();- $accountList = (string)$this->option('accounts');+ $accountList = (string) $this->option('accounts');$types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE];if ('' !== $accountList) {$accountIds = explode(',', $accountList);@@ -260,7 +260,7 @@ class ExportData extends Command*/private function getExportDirectory(): string{- $directory = (string)$this->option('export_directory');+ $directory = (string) $this->option('export_directory');if ('' === $directory) {$directory = './';}diff --git a/app/Console/Commands/Integrity/AddTimezonesToDates.php b/app/Console/Commands/Integrity/AddTimezonesToDates.phpindex cd347bd274..cc8be30011 100644--- a/app/Console/Commands/Integrity/AddTimezonesToDates.php+++ b/app/Console/Commands/Integrity/AddTimezonesToDates.php@@ -45,34 +45,35 @@ class AddTimezonesToDates extends Command{use ShowsFriendlyMessages;+ public static array $models+ = [+ AccountBalance::class => ['date'], // done+ AvailableBudget::class => ['start_date', 'end_date'], // done+ Bill::class => ['date', 'end_date', 'extension_date'], // done+ BudgetLimit::class => ['start_date', 'end_date'], // done+ CurrencyExchangeRate::class => ['date'], // done+ InvitedUser::class => ['expires'],+ PiggyBankEvent::class => ['date'],+ PiggyBankRepetition::class => ['start_date', 'target_date'],+ PiggyBank::class => ['start_date', 'target_date'], // done+ Recurrence::class => ['first_date', 'repeat_until', 'latest_date'],+ Tag::class => ['date'],+ TransactionJournal::class => ['date'],+ ];+/**- * The name and signature of the console command.+ * The console command description.** @var string*/- protected $signature = 'firefly-iii:add-timezones-to-dates';+ protected $description = 'Make sure all dates have a timezone.';/**- * The console command description.+ * The name and signature of the console command.** @var string*/- protected $description = 'Make sure all dates have a timezone.';-- public static array $models = [- AccountBalance::class => ['date'], // done- AvailableBudget::class => ['start_date', 'end_date'], // done- Bill::class => ['date', 'end_date', 'extension_date'], // done- BudgetLimit::class => ['start_date', 'end_date'], // done- CurrencyExchangeRate::class => ['date'], // done- InvitedUser::class => ['expires'],- PiggyBankEvent::class => ['date'],- PiggyBankRepetition::class => ['start_date', 'target_date'],- PiggyBank::class => ['start_date', 'target_date'], // done- Recurrence::class => ['first_date', 'repeat_until', 'latest_date'],- Tag::class => ['date'],- TransactionJournal::class => ['date'],- ];+ protected $signature = 'firefly-iii:add-timezones-to-dates';/*** Execute the console command.diff --git a/app/Console/Commands/Integrity/ConvertDatesToUTC.php b/app/Console/Commands/Integrity/ConvertDatesToUTC.phpindex 6ca496f8b3..454ee8a033 100644--- a/app/Console/Commands/Integrity/ConvertDatesToUTC.php+++ b/app/Console/Commands/Integrity/ConvertDatesToUTC.php@@ -36,18 +36,18 @@ class ConvertDatesToUTC extends Commanduse ShowsFriendlyMessages;/**- * The name and signature of the console command.+ * The console command description.** @var string*/- protected $signature = 'firefly-iii:migrate-to-utc';+ protected $description = 'Convert stored dates to UTC.';/**- * The console command description.+ * The name and signature of the console command.** @var string*/- protected $description = 'Convert stored dates to UTC.';+ protected $signature = 'firefly-iii:migrate-to-utc';/*** Execute the console command.diff --git a/app/Console/Commands/System/ForceDecimalSize.php b/app/Console/Commands/System/ForceDecimalSize.phpindex 9f3c42a12c..2683c7fc01 100644--- a/app/Console/Commands/System/ForceDecimalSize.php+++ b/app/Console/Commands/System/ForceDecimalSize.php@@ -130,17 +130,17 @@ class ForceDecimalSize extends Commandprivate function correctAmounts(): void{// if sqlite, add function?- if ('sqlite' === (string)config('database.default')) {+ if ('sqlite' === (string) config('database.default')) {DB::connection()->getPdo()->sqliteCreateFunction('REGEXP', static function ($pattern, $value) {mb_regex_encoding('UTF-8');$pattern = trim($pattern, '"');- return (false !== mb_ereg($pattern, (string)$value)) ? 1 : 0;+ return (false !== mb_ereg($pattern, (string) $value)) ? 1 : 0;});}- if (!in_array((string)config('database.default'), ['mysql', 'pgsql', 'sqlite'], true)) {- $this->friendlyWarning(sprintf('Skip correcting amounts, does not support "%s"...', (string)config('database.default')));+ if (!in_array((string) config('database.default'), ['mysql', 'pgsql', 'sqlite'], true)) {+ $this->friendlyWarning(sprintf('Skip correcting amounts, does not support "%s"...', (string) config('database.default')));return;}@@ -236,7 +236,7 @@ class ForceDecimalSize extends Command/** @var Builder $query */$query = Account::leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')->where('account_meta.name', 'currency_id')- ->where('account_meta.data', json_encode((string)$currency->id))+ ->where('account_meta.data', json_encode((string) $currency->id));$query->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {foreach ($fields as $field) {@@ -264,7 +264,7 @@ class ForceDecimalSize extends Command}// fix $field by rounding it down correctly.$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));Account::find($account->id)->update([$field => $correct]);}@@ -313,7 +313,7 @@ class ForceDecimalSize extends Command}// fix $field by rounding it down correctly.$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));$class::find($item->id)->update([$field => $correct]);}@@ -334,7 +334,7 @@ class ForceDecimalSize extends Command->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')->where('account_meta.name', 'currency_id')- ->where('account_meta.data', json_encode((string)$currency->id))+ ->where('account_meta.data', json_encode((string) $currency->id))->where(static function (Builder $q) use ($fields, $currency, $cast, $operator, $regularExpression): void {foreach ($fields as $field) {$q->orWhere(@@ -363,7 +363,7 @@ class ForceDecimalSize extends Command}// fix $field by rounding it down correctly.$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 event #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));@@ -387,7 +387,7 @@ class ForceDecimalSize extends Command->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')->where('account_meta.name', 'currency_id')- ->where('account_meta.data', json_encode((string)$currency->id))+ ->where('account_meta.data', json_encode((string) $currency->id))->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {foreach ($fields as $field) {$q->orWhere(@@ -416,7 +416,7 @@ class ForceDecimalSize extends Command}// fix $field by rounding it down correctly.$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 repetition #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct));@@ -438,7 +438,7 @@ class ForceDecimalSize extends Command$query = PiggyBank::leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')->where('account_meta.name', 'currency_id')- ->where('account_meta.data', json_encode((string)$currency->id))+ ->where('account_meta.data', json_encode((string) $currency->id))->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {foreach ($fields as $field) {$q->orWhere(@@ -467,7 +467,7 @@ class ForceDecimalSize extends Command}// fix $field by rounding it down correctly.$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));PiggyBank::find($item->id)->update([$field => $correct]);}@@ -499,8 +499,8 @@ class ForceDecimalSize extends Commandcontinue;}// fix $field by rounding it down correctly.- $pow = (float)10 ** $currency->decimal_places;- $correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);+ $pow = (float) 10 ** $currency->decimal_places;+ $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));Transaction::find($item->id)->update(['amount' => $correct]);}@@ -527,8 +527,8 @@ class ForceDecimalSize extends Commandcontinue;}// fix $field by rounding it down correctly.- $pow = (float)10 ** $currency->decimal_places;- $correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);+ $pow = (float) 10 ** $currency->decimal_places;+ $correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);$this->friendlyWarning(sprintf('Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct));@@ -539,7 +539,7 @@ class ForceDecimalSize extends Commandprivate function updateDecimals(): void{$this->friendlyInfo('Going to force the size of DECIMAL columns. Please hold.');- $type = (string)config('database.default');+ $type = (string) config('database.default');/*** @var string $namediff --git a/app/Console/Commands/System/ScanAttachments.php b/app/Console/Commands/System/ScanAttachments.phpindex 9eb11560da..50f3b96881 100644--- a/app/Console/Commands/System/ScanAttachments.php+++ b/app/Console/Commands/System/ScanAttachments.php@@ -71,8 +71,8 @@ class ScanAttachments extends Commandexit(1);}file_put_contents($tempFileName, $decryptedContent);- $attachment->md5 = (string)md5_file($tempFileName);- $attachment->mime = (string)mime_content_type($tempFileName);+ $attachment->md5 = (string) md5_file($tempFileName);+ $attachment->mime = (string) mime_content_type($tempFileName);$attachment->save();$this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id));}diff --git a/app/Console/Commands/System/UpgradeFireflyInstructions.php b/app/Console/Commands/System/UpgradeFireflyInstructions.phpindex 98816cbdca..bcfaec9fa5 100644--- a/app/Console/Commands/System/UpgradeFireflyInstructions.php+++ b/app/Console/Commands/System/UpgradeFireflyInstructions.php@@ -59,7 +59,7 @@ class UpgradeFireflyInstructions extends Command*/private function updateInstructions(): void{- $version = (string)config('firefly.version');+ $version = (string) config('firefly.version');/** @var array $config */$config = config('upgrade.text.upgrade');@@ -69,12 +69,12 @@ class UpgradeFireflyInstructions extends Commandforeach (array_keys($config) as $compare) {// if string starts with:if (str_starts_with($version, $compare)) {- $text = (string)$config[$compare];+ $text = (string) $config[$compare];}}// validate some settings.- if ('' === $text && 'local' === (string)config('app.env')) {+ if ('' === $text && 'local' === (string) config('app.env')) {$text = 'Please set APP_ENV=production for a safer environment.';}@@ -179,7 +179,7 @@ class UpgradeFireflyInstructions extends Command*/private function installInstructions(): void{- $version = (string)config('firefly.version');+ $version = (string) config('firefly.version');/** @var array $config */$config = config('upgrade.text.install');@@ -189,12 +189,12 @@ class UpgradeFireflyInstructions extends Commandforeach (array_keys($config) as $compare) {// if string starts with:if (str_starts_with($version, $compare)) {- $text = (string)$config[$compare];+ $text = (string) $config[$compare];}}// validate some settings.- if ('' === $text && 'local' === (string)config('app.env')) {+ if ('' === $text && 'local' === (string) config('app.env')) {$text = 'Please set APP_ENV=production for a safer environment.';}diff --git a/app/Console/Commands/Tools/ApplyRules.php b/app/Console/Commands/Tools/ApplyRules.phpindex a27c5643a3..01d2c57a84 100644--- a/app/Console/Commands/Tools/ApplyRules.php+++ b/app/Console/Commands/Tools/ApplyRules.php@@ -201,7 +201,7 @@ class ApplyRules extends Command$accountRepository = app(AccountRepositoryInterface::class);$accountRepository->setUser($this->getUser());foreach ($accountList as $accountId) {- $accountId = (int)$accountId;+ $accountId = (int) $accountId;$account = $accountRepository->find($accountId);if (null !== $account && in_array($account->accountType->type, $this->acceptedAccounts, true)) {$finalList->push($account);@@ -228,7 +228,7 @@ class ApplyRules extends Command$ruleGroupList = explode(',', $ruleGroupString);foreach ($ruleGroupList as $ruleGroupId) {- $ruleGroup = $this->ruleGroupRepository->find((int)$ruleGroupId);+ $ruleGroup = $this->ruleGroupRepository->find((int) $ruleGroupId);if ($ruleGroup->active) {$this->ruleGroupSelection[] = $ruleGroup->id;}@@ -250,7 +250,7 @@ class ApplyRules extends Command$ruleList = explode(',', $ruleString);foreach ($ruleList as $ruleId) {- $rule = $this->ruleRepository->find((int)$ruleId);+ $rule = $this->ruleRepository->find((int) $ruleId);if (null !== $rule && $rule->active) {$this->ruleSelection[] = $rule->id;}diff --git a/app/Console/Commands/Tools/Cron.php b/app/Console/Commands/Tools/Cron.phpindex 8ee4800de8..9481e9dd28 100644--- a/app/Console/Commands/Tools/Cron.php+++ b/app/Console/Commands/Tools/Cron.php@@ -62,7 +62,7 @@ class Cron extends Command} catch (\InvalidArgumentException $e) {$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.if (true === config('cer.download_enabled') && ($doAll || $this->option('download-cer'))) {diff --git a/app/Console/Commands/Upgrade/AccountCurrencies.php b/app/Console/Commands/Upgrade/AccountCurrencies.phpindex 3afe9ec47d..bc4a0780c0 100644--- a/app/Console/Commands/Upgrade/AccountCurrencies.php+++ b/app/Console/Commands/Upgrade/AccountCurrencies.php@@ -93,7 +93,7 @@ class AccountCurrencies extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function updateAccountCurrencies(): void@@ -124,9 +124,9 @@ class AccountCurrencies extends Commandprivate function updateAccount(Account $account, TransactionCurrency $currency): void{$this->accountRepos->setUser($account->user);- $accountCurrency = (int)$this->accountRepos->getMetaValue($account, 'currency_id');+ $accountCurrency = (int) $this->accountRepos->getMetaValue($account, 'currency_id');$openingBalance = $this->accountRepos->getOpeningBalance($account);- $obCurrency = (int)$openingBalance?->transaction_currency_id;+ $obCurrency = (int) $openingBalance?->transaction_currency_id;// both 0? set to default currency:if (0 === $accountCurrency && 0 === $obCurrency) {diff --git a/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php b/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.phpindex 17d7aa221f..83a0d11548 100644--- a/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php+++ b/app/Console/Commands/Upgrade/AppendBudgetLimitPeriods.php@@ -62,7 +62,7 @@ class AppendBudgetLimitPeriods extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);- return (bool)$configVar->data;+ return (bool) $configVar->data;}private function theresNoLimit(): void@@ -111,7 +111,7 @@ class AppendBudgetLimitPeriods extends Commandreturn 'daily';}// is weekly- if ('1' === $limit->start_date->format('N') && '7' === $limit->end_date->format('N') && 6 === (int)$limit->end_date->diffInDays($limit->start_date, true)) {+ if ('1' === $limit->start_date->format('N') && '7' === $limit->end_date->format('N') && 6 === (int) $limit->end_date->diffInDays($limit->start_date, true)) {return 'weekly';}@@ -130,7 +130,7 @@ class AppendBudgetLimitPeriods extends Commandif (in_array($limit->start_date->format('j-n'), $start, true) // start of quarter&& in_array($limit->end_date->format('j-n'), $end, true) // end of quarter- && 2 === (int)$limit->start_date->diffInMonths($limit->end_date, true)+ && 2 === (int) $limit->start_date->diffInMonths($limit->end_date, true)) {return 'quarterly';}@@ -140,7 +140,7 @@ class AppendBudgetLimitPeriods extends Commandif (in_array($limit->start_date->format('j-n'), $start, true) // start of quarter&& in_array($limit->end_date->format('j-n'), $end, true) // end of quarter- && 5 === (int)$limit->start_date->diffInMonths($limit->end_date, true)+ && 5 === (int) $limit->start_date->diffInMonths($limit->end_date, true)) {return 'half_year';}diff --git a/app/Console/Commands/Upgrade/BackToJournals.php b/app/Console/Commands/Upgrade/BackToJournals.phpindex 961c24040d..31f72f2c74 100644--- a/app/Console/Commands/Upgrade/BackToJournals.php+++ b/app/Console/Commands/Upgrade/BackToJournals.php@@ -73,14 +73,14 @@ class BackToJournals extends Command{$configVar = app('fireflyconfig')->get(MigrateToGroups::CONFIG_NAME, false);- return (bool)$configVar->data;+ return (bool) $configVar->data;}private function isExecuted(): bool{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);- return (bool)$configVar->data;+ return (bool) $configVar->data;}private function migrateAll(): voiddiff --git a/app/Console/Commands/Upgrade/BudgetLimitCurrency.php b/app/Console/Commands/Upgrade/BudgetLimitCurrency.phpindex de9de12029..a00cf81e0d 100644--- a/app/Console/Commands/Upgrade/BudgetLimitCurrency.php+++ b/app/Console/Commands/Upgrade/BudgetLimitCurrency.php@@ -92,7 +92,7 @@ class BudgetLimitCurrency extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;diff --git a/app/Console/Commands/Upgrade/CCLiabilities.php b/app/Console/Commands/Upgrade/CCLiabilities.phpindex 201453e66a..f2211fb59a 100644--- a/app/Console/Commands/Upgrade/CCLiabilities.php+++ b/app/Console/Commands/Upgrade/CCLiabilities.php@@ -88,7 +88,7 @@ class CCLiabilities extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): voiddiff --git a/app/Console/Commands/Upgrade/CorrectAccountBalance.php b/app/Console/Commands/Upgrade/CorrectAccountBalance.phpindex b377ae0405..a28ea60737 100644--- a/app/Console/Commands/Upgrade/CorrectAccountBalance.php+++ b/app/Console/Commands/Upgrade/CorrectAccountBalance.php@@ -59,12 +59,6 @@ class CorrectAccountBalance extends Commandreturn 0;}- private function correctBalanceAmounts(): void- {- return;- AccountBalanceCalculator::recalculateAll(true);- }-private function isExecuted(): bool{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);@@ -76,4 +70,10 @@ class CorrectAccountBalance extends Command{app('fireflyconfig')->set(self::CONFIG_NAME, true);}++ private function correctBalanceAmounts(): void+ {+ return;+ AccountBalanceCalculator::recalculateAll(true);+ }}diff --git a/app/Console/Commands/Upgrade/DecryptDatabase.php b/app/Console/Commands/Upgrade/DecryptDatabase.phpindex e4332d5fd5..a7ec4f2efa 100644--- a/app/Console/Commands/Upgrade/DecryptDatabase.php+++ b/app/Console/Commands/Upgrade/DecryptDatabase.php@@ -97,7 +97,7 @@ class DecryptDatabase extends Commandapp('log')->error($e->getMessage());}if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;@@ -119,7 +119,7 @@ class DecryptDatabase extends Commandif (null === $original) {return;}- $id = (int)$row->id;+ $id = (int) $row->id;$value = '';try {diff --git a/app/Console/Commands/Upgrade/MigrateAttachments.php b/app/Console/Commands/Upgrade/MigrateAttachments.phpindex ec0af6a5f8..cb517059fc 100644--- a/app/Console/Commands/Upgrade/MigrateAttachments.php+++ b/app/Console/Commands/Upgrade/MigrateAttachments.php@@ -63,7 +63,7 @@ class MigrateAttachments extends Command/** @var Attachment $att */foreach ($attachments as $att) {// move description:- $attDescription = (string)$att->description;+ $attDescription = (string) $att->description;if ('' !== $attDescription) {// find or create note:$note = $att->notes()->first();@@ -99,7 +99,7 @@ class MigrateAttachments extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;diff --git a/app/Console/Commands/Upgrade/MigrateJournalNotes.php b/app/Console/Commands/Upgrade/MigrateJournalNotes.phpindex 4f472070f1..2434ba4d10 100644--- a/app/Console/Commands/Upgrade/MigrateJournalNotes.php+++ b/app/Console/Commands/Upgrade/MigrateJournalNotes.php@@ -93,7 +93,7 @@ class MigrateJournalNotes extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;diff --git a/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.php b/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.phpindex 207e45d1fa..5b79a96f3c 100644--- a/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.php+++ b/app/Console/Commands/Upgrade/MigrateRecurrenceMeta.php@@ -71,7 +71,7 @@ class MigrateRecurrenceMeta extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;diff --git a/app/Console/Commands/Upgrade/MigrateRecurrenceType.php b/app/Console/Commands/Upgrade/MigrateRecurrenceType.phpindex 7aec519d9c..d8cf398141 100644--- a/app/Console/Commands/Upgrade/MigrateRecurrenceType.php+++ b/app/Console/Commands/Upgrade/MigrateRecurrenceType.php@@ -60,7 +60,7 @@ class MigrateRecurrenceType extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): voiddiff --git a/app/Console/Commands/Upgrade/MigrateRuleActions.php b/app/Console/Commands/Upgrade/MigrateRuleActions.phpindex d6fcd62407..f0c825b40f 100644--- a/app/Console/Commands/Upgrade/MigrateRuleActions.php+++ b/app/Console/Commands/Upgrade/MigrateRuleActions.php@@ -63,7 +63,7 @@ class MigrateRuleActions extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;diff --git a/app/Console/Commands/Upgrade/MigrateTagLocations.php b/app/Console/Commands/Upgrade/MigrateTagLocations.phpindex 76a7f81a9e..7284622067 100644--- a/app/Console/Commands/Upgrade/MigrateTagLocations.php+++ b/app/Console/Commands/Upgrade/MigrateTagLocations.php@@ -62,7 +62,7 @@ class MigrateTagLocations extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;diff --git a/app/Console/Commands/Upgrade/MigrateToGroups.php b/app/Console/Commands/Upgrade/MigrateToGroups.phpindex d19c1bef60..c9b475217a 100644--- a/app/Console/Commands/Upgrade/MigrateToGroups.php+++ b/app/Console/Commands/Upgrade/MigrateToGroups.php@@ -105,7 +105,7 @@ class MigrateToGroups extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;@@ -288,7 +288,7 @@ class MigrateToGroups extends Command{$set = $journal->transactions->filter(static function (Transaction $subject) use ($transaction) {- $amount = (float)$transaction->amount * -1 === (float)$subject->amount; // intentional float+ $amount = (float) $transaction->amount * -1 === (float) $subject->amount; // intentional float$identifier = $transaction->identifier === $subject->identifier;app('log')->debug(sprintf('Amount the same? %s', var_export($amount, true)));app('log')->debug(sprintf('ID the same? %s', var_export($identifier, true)));diff --git a/app/Console/Commands/Upgrade/MigrateToRules.php b/app/Console/Commands/Upgrade/MigrateToRules.phpindex e07100dade..d2fed1a94d 100644--- a/app/Console/Commands/Upgrade/MigrateToRules.php+++ b/app/Console/Commands/Upgrade/MigrateToRules.php@@ -106,7 +106,7 @@ class MigrateToRules extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;@@ -125,15 +125,15 @@ class MigrateToRules extends Command/** @var Preference $lang */$lang = app('preferences')->getForUser($user, 'language', 'en_US');- $language = null !== $lang->data && !is_array($lang->data) ? (string)$lang->data : 'en_US';- $groupTitle = (string)trans('firefly.rulegroup_for_bills_title', [], $language);+ $language = null !== $lang->data && !is_array($lang->data) ? (string) $lang->data : 'en_US';+ $groupTitle = (string) trans('firefly.rulegroup_for_bills_title', [], $language);$ruleGroup = $this->ruleGroupRepository->findByTitle($groupTitle);if (null === $ruleGroup) {$ruleGroup = $this->ruleGroupRepository->store([- 'title' => (string)trans('firefly.rulegroup_for_bills_title', [], $language),- 'description' => (string)trans('firefly.rulegroup_for_bills_description', [], $language),+ 'title' => (string) trans('firefly.rulegroup_for_bills_title', [], $language),+ 'description' => (string) trans('firefly.rulegroup_for_bills_description', [], $language),'active' => true,]);@@ -151,7 +151,7 @@ class MigrateToRules extends Commandif ('MIGRATED_TO_RULES' === $bill->match) {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:$match = implode(' ', explode(',', $bill->match));@@ -160,8 +160,8 @@ class MigrateToRules extends Command'active' => true,'strict' => false,'stop_processing' => false, // field is no longer used.- 'title' => (string)trans('firefly.rule_for_bill_title', ['name' => $bill->name], $languageString),- 'description' => (string)trans('firefly.rule_for_bill_description', ['name' => $bill->name], $languageString),+ 'title' => (string) trans('firefly.rule_for_bill_title', ['name' => $bill->name], $languageString),+ 'description' => (string) trans('firefly.rule_for_bill_description', ['name' => $bill->name], $languageString),'trigger' => 'store-journal','triggers' => [[diff --git a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.phpindex cfff687d28..0f4a601054 100644--- a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php+++ b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php@@ -239,11 +239,6 @@ class OtherCurrenciesCorrections extends Commandreturn $currency;}- private function markAsExecuted(): void- {- app('fireflyconfig')->set(self::CONFIG_NAME, true);- }-private function isMultiCurrency(Account $account): bool{$value = $this->accountRepos->getMetaValue($account, 'is_multi_currency', false);@@ -253,4 +248,9 @@ class OtherCurrenciesCorrections extends Commandreturn '1' === $value;}++ private function markAsExecuted(): void+ {+ app('fireflyconfig')->set(self::CONFIG_NAME, true);+ }}diff --git a/app/Console/Commands/Upgrade/RenameAccountMeta.php b/app/Console/Commands/Upgrade/RenameAccountMeta.phpindex 6602cee886..aba059a38c 100644--- a/app/Console/Commands/Upgrade/RenameAccountMeta.php+++ b/app/Console/Commands/Upgrade/RenameAccountMeta.php@@ -90,7 +90,7 @@ class RenameAccountMeta extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;diff --git a/app/Console/Commands/Upgrade/TransactionIdentifier.php b/app/Console/Commands/Upgrade/TransactionIdentifier.phpindex 1aca9a86f7..da2848ef4f 100644--- a/app/Console/Commands/Upgrade/TransactionIdentifier.php+++ b/app/Console/Commands/Upgrade/TransactionIdentifier.php@@ -106,7 +106,7 @@ class TransactionIdentifier extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;diff --git a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.phpindex fcc30b1079..ea6e4cb8ca 100644--- a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php+++ b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php@@ -114,7 +114,7 @@ class TransferCurrenciesCorrections extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;@@ -320,7 +320,7 @@ class TransferCurrenciesCorrections extends Command{if (null !== $this->sourceCurrency&& null === $this->sourceTransaction->foreign_amount- && (int)$this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id+ && (int) $this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id) {$message = sprintf('Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',@@ -366,7 +366,7 @@ class TransferCurrenciesCorrections extends Command{if (null !== $this->destinationCurrency&& null === $this->destinationTransaction->foreign_amount- && (int)$this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id+ && (int) $this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id) {$message = sprintf('Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',@@ -469,7 +469,7 @@ class TransferCurrenciesCorrections extends Command*/private function fixTransactionJournalCurrency(TransactionJournal $journal): void{- if ((int)$journal->transaction_currency_id !== $this->sourceCurrency->id) {+ if ((int) $journal->transaction_currency_id !== $this->sourceCurrency->id) {$oldCurrencyCode = $journal->transactionCurrency->code ?? '(nothing)';$journal->transaction_currency_id = $this->sourceCurrency->id;$message = sprintf(diff --git a/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.php b/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.phpindex ff59b5169c..1e7cd051dc 100644--- a/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.php+++ b/app/Console/Commands/Upgrade/UpgradeCurrencyPreferences.php@@ -68,7 +68,7 @@ class UpgradeCurrencyPreferences extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;@@ -138,7 +138,7 @@ class UpgradeCurrencyPreferences extends Command}if (null !== $preference->data && !is_array($preference->data)) {- return (string)$preference->data;+ return (string) $preference->data;}return 'EUR';diff --git a/app/Console/Commands/Upgrade/UpgradeDatabase.php b/app/Console/Commands/Upgrade/UpgradeDatabase.phpindex 8090c16c90..3b27f72ebd 100644--- a/app/Console/Commands/Upgrade/UpgradeDatabase.php+++ b/app/Console/Commands/Upgrade/UpgradeDatabase.php@@ -84,9 +84,9 @@ class UpgradeDatabase extends Command$this->call($command, $args);}// set new DB version.- app('fireflyconfig')->set('db_version', (int)config('firefly.db_version'));+ app('fireflyconfig')->set('db_version', (int) config('firefly.db_version'));// index will set FF3 version.- app('fireflyconfig')->set('ff3_version', (string)config('firefly.version'));+ app('fireflyconfig')->set('ff3_version', (string) config('firefly.version'));return 0;}diff --git a/app/Console/Commands/Upgrade/UpgradeLiabilities.php b/app/Console/Commands/Upgrade/UpgradeLiabilities.phpindex 0f36506a8e..66902b171c 100644--- a/app/Console/Commands/Upgrade/UpgradeLiabilities.php+++ b/app/Console/Commands/Upgrade/UpgradeLiabilities.php@@ -66,7 +66,7 @@ class UpgradeLiabilities extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;diff --git a/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php b/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.phpindex 0fb2c9bb84..1422e77363 100644--- a/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php+++ b/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php@@ -66,7 +66,7 @@ class UpgradeLiabilitiesEight extends Command{$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);if (null !== $configVar) {- return (bool)$configVar->data;+ return (bool) $configVar->data;}return false;diff --git a/app/Console/Commands/Upgrade/UpgradeMultiPiggyBanks.php b/app/Console/Commands/Upgrade/UpgradeMultiPiggyBanks.phpindex d48e7441b5..6914bc0919 100644--- a/app/Console/Commands/Upgrade/UpgradeMultiPiggyBanks.php+++ b/app/Console/Commands/Upgrade/UpgradeMultiPiggyBanks.php@@ -39,9 +39,8 @@ class UpgradeMultiPiggyBanks extends Commandprotected $description = 'Upgrade piggybanks so they can use multiple accounts.';protected $signature = 'firefly-iii:upgrade-multi-piggies {--F|force : Force the execution of this command.}';-- private PiggyBankRepositoryInterface $repository;private AccountRepositoryInterface $accountRepository;+ private PiggyBankRepositoryInterface $repository;/*** Execute the console command.@@ -71,11 +70,6 @@ class UpgradeMultiPiggyBanks extends Commandreturn false;}- private function markAsExecuted(): void- {- app('fireflyconfig')->set(self::CONFIG_NAME, true);- }-private function upgradePiggyBanks(): void{$this->repository = app(PiggyBankRepositoryInterface::class);@@ -109,4 +103,9 @@ class UpgradeMultiPiggyBanks extends Command$piggyBank->piggyBankRepetitions()->delete();}++ private function markAsExecuted(): void+ {+ app('fireflyconfig')->set(self::CONFIG_NAME, true);+ }}diff --git a/app/Console/Commands/VerifiesAccessToken.php b/app/Console/Commands/VerifiesAccessToken.phpindex 0602f89683..9b9d3d06c2 100644--- a/app/Console/Commands/VerifiesAccessToken.php+++ b/app/Console/Commands/VerifiesAccessToken.php@@ -40,7 +40,7 @@ trait VerifiesAccessToken*/public function getUser(): User{- $userId = (int)$this->option('user');+ $userId = (int) $this->option('user');/** @var UserRepositoryInterface $repository */$repository = app(UserRepositoryInterface::class);@@ -68,8 +68,8 @@ trait VerifiesAccessToken*/protected function verifyAccessToken(): bool{- $userId = (int)$this->option('user');- $token = (string)$this->option('token');+ $userId = (int) $this->option('user');+ $token = (string) $this->option('token');/** @var UserRepositoryInterface $repository */$repository = app(UserRepositoryInterface::class);diff --git a/app/Entities/AccountBalance.php b/app/Entities/AccountBalance.phpindex 802017cbca..2f27ee183c 100644--- a/app/Entities/AccountBalance.php+++ b/app/Entities/AccountBalance.php@@ -28,9 +28,9 @@ use FireflyIII\Models\Account;class AccountBalance{- public string $id;public string $amount;public string $currencyId;+ public string $id;public static function fromArray(): self{diff --git a/app/Events/DetectedNewIPAddress.php b/app/Events/DetectedNewIPAddress.phpindex 0a9e7ac898..a04d65cb7c 100644--- a/app/Events/DetectedNewIPAddress.php+++ b/app/Events/DetectedNewIPAddress.php@@ -34,7 +34,7 @@ class DetectedNewIPAddress extends Event{use SerializesModels;- public User $user;+ public User $user;/*** Create a new event instance. This event is triggered when a new user registers.diff --git a/app/Events/RegisteredUser.php b/app/Events/RegisteredUser.phpindex 2c5dac36f0..51539a856a 100644--- a/app/Events/RegisteredUser.php+++ b/app/Events/RegisteredUser.php@@ -35,8 +35,8 @@ class RegisteredUser extends Event{use SerializesModels;- public User $user;public OwnerNotifiable $owner;+ public User $user;/*** Create a new event instance. This event is triggered when a new user registers.diff --git a/app/Events/Security/MFABackupFewLeft.php b/app/Events/Security/MFABackupFewLeft.phpindex f992bcae31..dd1129c7d3 100644--- a/app/Events/Security/MFABackupFewLeft.php+++ b/app/Events/Security/MFABackupFewLeft.php@@ -33,8 +33,8 @@ class MFABackupFewLeft extends Event{use SerializesModels;+ public int $count;public User $user;- public int $count;public function __construct(null|Authenticatable|User $user, int $count){diff --git a/app/Events/Security/MFAManyFailedAttempts.php b/app/Events/Security/MFAManyFailedAttempts.phpindex b41f47933f..6363dc3a3d 100644--- a/app/Events/Security/MFAManyFailedAttempts.php+++ b/app/Events/Security/MFAManyFailedAttempts.php@@ -33,8 +33,8 @@ class MFAManyFailedAttempts extends Event{use SerializesModels;+ public int $count;public User $user;- public int $count;public function __construct(null|Authenticatable|User $user, int $count){diff --git a/app/Events/Test/OwnerTestNotificationChannel.php b/app/Events/Test/OwnerTestNotificationChannel.phpindex 75d530e391..c246520c2d 100644--- a/app/Events/Test/OwnerTestNotificationChannel.php+++ b/app/Events/Test/OwnerTestNotificationChannel.php@@ -31,8 +31,8 @@ class OwnerTestNotificationChannel{use SerializesModels;- public OwnerNotifiable $owner;public string $channel;+ public OwnerNotifiable $owner;/*** Create a new event instance.diff --git a/app/Events/Test/UserTestNotificationChannel.php b/app/Events/Test/UserTestNotificationChannel.phpindex 4b219071d9..aff68cc409 100644--- a/app/Events/Test/UserTestNotificationChannel.php+++ b/app/Events/Test/UserTestNotificationChannel.php@@ -31,8 +31,8 @@ class UserTestNotificationChannel{use SerializesModels;- public User $user;public string $channel;+ public User $user;/*** Create a new event instance.diff --git a/app/Exceptions/GracefulNotFoundHandler.php b/app/Exceptions/GracefulNotFoundHandler.phpindex 5eab18f7a1..afc2372ceb 100644--- a/app/Exceptions/GracefulNotFoundHandler.php+++ b/app/Exceptions/GracefulNotFoundHandler.php@@ -158,7 +158,7 @@ class GracefulNotFoundHandler extends ExceptionHandler$accountId = $param->id;}if (!($param instanceof Account) && !is_object($param)) {- $accountId = (int)$param;+ $accountId = (int) $param;}/** @var null|Account $account */@@ -188,7 +188,7 @@ class GracefulNotFoundHandler extends ExceptionHandler$user = auth()->user();$route = $request->route();$param = $route->parameter('transactionGroup');- $groupId = !is_object($param) ? (int)$param : 0;+ $groupId = !is_object($param) ? (int) $param : 0;/** @var null|TransactionGroup $group */$group = $user->transactionGroups()->withTrashed()->find($groupId);@@ -228,7 +228,7 @@ class GracefulNotFoundHandler extends ExceptionHandler$user = auth()->user();$route = $request->route();$param = $route->parameter('attachment');- $attachmentId = is_object($param) ? 0 : (int)$param;+ $attachmentId = is_object($param) ? 0 : (int) $param;/** @var null|Attachment $attachment */$attachment = $user->attachments()->withTrashed()->find($attachmentId);diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.phpindex 0086841f41..1c7c0b5f17 100644--- a/app/Exceptions/Handler.php+++ b/app/Exceptions/Handler.php@@ -157,7 +157,7 @@ class Handler extends ExceptionHandler$errorCode = 500;$errorCode = $e instanceof MethodNotAllowedHttpException ? 405 : $errorCode;- $isDebug = (bool)config('app.debug', false);+ $isDebug = (bool) config('app.debug', false);if ($isDebug) {app('log')->debug(sprintf('Return JSON %s with debug.', get_class($e)));@@ -214,7 +214,7 @@ class Handler extends ExceptionHandler*/public function report(\Throwable $e): void{- $doMailError = (bool)config('firefly.send_error_message');+ $doMailError = (bool) config('firefly.send_error_message');if ($this->shouldntReportLocal($e) || !$doMailError) {parent::report($e);@@ -250,7 +250,7 @@ class Handler extends ExceptionHandler// create job that will mail.$ipAddress = request()->ip() ?? '0.0.0.0';- $job = new MailError($userData, (string)config('firefly.site_owner'), $ipAddress, $data);+ $job = new MailError($userData, (string) config('firefly.site_owner'), $ipAddress, $data);dispatch($job);parent::report($e);diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.phpindex faaaaa6c52..5d6fea36e0 100644--- a/app/Factory/AccountFactory.php+++ b/app/Factory/AccountFactory.php@@ -126,7 +126,7 @@ class AccountFactory*/protected function getAccountType(array $data): ?AccountType{- $accountTypeId = array_key_exists('account_type_id', $data) ? (int)$data['account_type_id'] : 0;+ $accountTypeId = array_key_exists('account_type_id', $data) ? (int) $data['account_type_id'] : 0;$accountTypeName = array_key_exists('account_type_name', $data) ? $data['account_type_name'] : null;$result = null;// find by name or ID@@ -184,7 +184,7 @@ class AccountFactory'iban' => $data['iban'],];// fix virtual balance when it's empty- if ('' === (string)$databaseData['virtual_balance']) {+ if ('' === (string) $databaseData['virtual_balance']) {$databaseData['virtual_balance'] = null;}// remove virtual balance when not an asset account@@ -236,9 +236,9 @@ class AccountFactory*/private function cleanMetaDataArray(Account $account, array $data): array{- $currencyId = array_key_exists('currency_id', $data) ? (int)$data['currency_id'] : 0;- $currencyCode = array_key_exists('currency_code', $data) ? (string)$data['currency_code'] : '';- $accountRole = array_key_exists('account_role', $data) ? (string)$data['account_role'] : null;+ $currencyId = array_key_exists('currency_id', $data) ? (int) $data['currency_id'] : 0;+ $currencyCode = array_key_exists('currency_code', $data) ? (string) $data['currency_code'] : '';+ $accountRole = array_key_exists('account_role', $data) ? (string) $data['account_role'] : null;$currency = $this->getCurrency($currencyId, $currencyCode);// only asset account may have a role:@@ -289,7 +289,7 @@ class AccountFactory$data[$field] = 1;}- $factory->crud($account, $field, (string)$data[$field]);+ $factory->crud($account, $field, (string) $data[$field]);}}}@@ -351,7 +351,7 @@ class AccountFactory$order = $maxOrder + 1;}if (array_key_exists('order', $data)) {- $order = (int)($data['order'] > $maxOrder ? $maxOrder + 1 : $data['order']);+ $order = (int) ($data['order'] > $maxOrder ? $maxOrder + 1 : $data['order']);$order = 0 === $order ? $maxOrder + 1 : $order;}diff --git a/app/Factory/AttachmentFactory.php b/app/Factory/AttachmentFactory.phpindex 44c16afc2a..bd64ea57a8 100644--- a/app/Factory/AttachmentFactory.php+++ b/app/Factory/AttachmentFactory.php@@ -50,7 +50,7 @@ class AttachmentFactory// get journal instead of transaction.if (Transaction::class === $model) {/** @var null|Transaction $transaction */- $transaction = $this->user->transactions()->find((int)$data['attachable_id']);+ $transaction = $this->user->transactions()->find((int) $data['attachable_id']);if (null === $transaction) {throw new FireflyException('Unexpectedly could not find transaction');}@@ -73,7 +73,7 @@ class AttachmentFactory'uploaded' => 0,]);- $notes = (string)($data['notes'] ?? '');+ $notes = (string) ($data['notes'] ?? '');if ('' !== $notes) {$note = new Note();$note->noteable()->associate($attachment);diff --git a/app/Factory/BillFactory.php b/app/Factory/BillFactory.phpindex 9a1b38cd47..ae120c4fdb 100644--- a/app/Factory/BillFactory.php+++ b/app/Factory/BillFactory.php@@ -48,7 +48,7 @@ class BillFactory{app('log')->debug(sprintf('Now in %s', __METHOD__), $data);$factory = app(TransactionCurrencyFactory::class);- $currency = $factory->find((int)($data['currency_id'] ?? null), (string)($data['currency_code'] ?? null)) ??+ $currency = $factory->find((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null)) ??app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);try {@@ -58,23 +58,23 @@ class BillFactory/** @var Bill $bill */$bill = Bill::create([- 'name' => $data['name'],- 'match' => 'MIGRATED_TO_RULES',- 'amount_min' => $data['amount_min'],- 'user_id' => $this->user->id,- 'user_group_id' => $this->user->user_group_id,- 'transaction_currency_id' => $currency->id,- 'amount_max' => $data['amount_max'],- 'date' => $data['date'],- 'date_tz' => $data['date']->format('e'),- 'end_date' => $data['end_date'] ?? null,- 'end_date_tz' => $data['end_date']?->format('e'),- 'extension_date' => $data['extension_date'] ?? null,- 'extension_date_tz' => $data['extension_date']?->format('e'),- 'repeat_freq' => $data['repeat_freq'],- 'skip' => $skip,- 'automatch' => true,- 'active' => $active,+ 'name' => $data['name'],+ 'match' => 'MIGRATED_TO_RULES',+ 'amount_min' => $data['amount_min'],+ 'user_id' => $this->user->id,+ 'user_group_id' => $this->user->user_group_id,+ 'transaction_currency_id' => $currency->id,+ 'amount_max' => $data['amount_max'],+ 'date' => $data['date'],+ 'date_tz' => $data['date']->format('e'),+ 'end_date' => $data['end_date'] ?? null,+ 'end_date_tz' => $data['end_date']?->format('e'),+ 'extension_date' => $data['extension_date'] ?? null,+ 'extension_date_tz' => $data['extension_date']?->format('e'),+ 'repeat_freq' => $data['repeat_freq'],+ 'skip' => $skip,+ 'automatch' => true,+ 'active' => $active,]);} catch (QueryException $e) {@@ -85,7 +85,7 @@ class BillFactory}if (array_key_exists('notes', $data)) {- $this->updateNote($bill, (string)$data['notes']);+ $this->updateNote($bill, (string) $data['notes']);}$objectGroupTitle = $data['object_group_title'] ?? '';if ('' !== $objectGroupTitle) {@@ -96,7 +96,7 @@ class BillFactory}}// try also with ID:- $objectGroupId = (int)($data['object_group_id'] ?? 0);+ $objectGroupId = (int) ($data['object_group_id'] ?? 0);if (0 !== $objectGroupId) {$objectGroup = $this->findObjectGroupById($objectGroupId);if (null !== $objectGroup) {@@ -110,8 +110,8 @@ class BillFactorypublic function find(?int $billId, ?string $billName): ?Bill{- $billId = (int)$billId;- $billName = (string)$billName;+ $billId = (int) $billId;+ $billName = (string) $billName;$bill = null;// first find by ID:if ($billId > 0) {diff --git a/app/Factory/BudgetFactory.php b/app/Factory/BudgetFactory.phpindex f5b438b714..48d424d27d 100644--- a/app/Factory/BudgetFactory.php+++ b/app/Factory/BudgetFactory.php@@ -35,8 +35,8 @@ class BudgetFactorypublic function find(?int $budgetId, ?string $budgetName): ?Budget{- $budgetId = (int)$budgetId;- $budgetName = (string)$budgetName;+ $budgetId = (int) $budgetId;+ $budgetName = (string) $budgetName;if (0 === $budgetId && '' === $budgetName) {return null;diff --git a/app/Factory/CategoryFactory.php b/app/Factory/CategoryFactory.phpindex b5adc0d7e6..91e419d23e 100644--- a/app/Factory/CategoryFactory.php+++ b/app/Factory/CategoryFactory.php@@ -40,8 +40,8 @@ class CategoryFactory*/public function findOrCreate(?int $categoryId, ?string $categoryName): ?Category{- $categoryId = (int)$categoryId;- $categoryName = (string)$categoryName;+ $categoryId = (int) $categoryId;+ $categoryName = (string) $categoryName;app('log')->debug(sprintf('Going to find category with ID %d and name "%s"', $categoryId, $categoryName));diff --git a/app/Factory/PiggyBankFactory.php b/app/Factory/PiggyBankFactory.phpindex a5ddedb090..babb2a0955 100644--- a/app/Factory/PiggyBankFactory.php+++ b/app/Factory/PiggyBankFactory.php@@ -49,8 +49,8 @@ class PiggyBankFactory$this->piggyBankRepository->setUser($value);}}- private CurrencyRepositoryInterface $currencyRepository;private AccountRepositoryInterface $accountRepository;+ private CurrencyRepositoryInterface $currencyRepository;private PiggyBankRepositoryInterface $piggyBankRepository;public function __construct()@@ -120,6 +120,21 @@ class PiggyBankFactoryreturn $piggyBank;}+ private function getCurrency(array $data): TransactionCurrency+ {+ // currency:+ $defaultCurrency = app('amount')->getDefaultCurrency();+ $currency = null;+ if (array_key_exists('transaction_currency_code', $data)) {+ $currency = $this->currencyRepository->findByCode((string) ($data['transaction_currency_code'] ?? ''));+ }+ if (array_key_exists('transaction_currency_id', $data)) {+ $currency = $this->currencyRepository->find((int) ($data['transaction_currency_id'] ?? 0));+ }+ $currency ??= $defaultCurrency;+ return $currency;+ }+public function find(?int $piggyBankId, ?string $piggyBankName): ?PiggyBank{$piggyBankId = (int) $piggyBankId;@@ -162,21 +177,6 @@ class PiggyBankFactory->first(['piggy_banks.*']);}- private function getCurrency(array $data): TransactionCurrency- {- // currency:- $defaultCurrency = app('amount')->getDefaultCurrency();- $currency = null;- if (array_key_exists('transaction_currency_code', $data)) {- $currency = $this->currencyRepository->findByCode((string) ($data['transaction_currency_code'] ?? ''));- }- if (array_key_exists('transaction_currency_id', $data)) {- $currency = $this->currencyRepository->find((int) ($data['transaction_currency_id'] ?? 0));- }- $currency ??= $defaultCurrency;- return $currency;- }-private function setOrder(PiggyBank $piggyBank, array $data): PiggyBank{$this->resetOrder();@@ -227,10 +227,10 @@ class PiggyBankFactory// collect current current_amount so the sync does not remove them.// TODO this is a tedious check. Feels like a hack.$toBeLinked = [];- foreach($piggyBank->accounts as $account) {- foreach($accounts as $info) {- if($account->id === $info['account_id']) {- if(array_key_exists($account->id, $accounts)) {+ foreach ($piggyBank->accounts as $account) {+ foreach ($accounts as $info) {+ if ($account->id === $info['account_id']) {+ if (array_key_exists($account->id, $accounts)) {$toBeLinked[$account->id] = ['current_amount' => $account->pivot->current_amount];Log::debug(sprintf('Prefilled for account #%d with amount %s', $account->id, $account->pivot->current_amount));}diff --git a/app/Factory/RecurrenceFactory.php b/app/Factory/RecurrenceFactory.phpindex ad74dcdec4..e0cf5ce9d7 100644--- a/app/Factory/RecurrenceFactory.php+++ b/app/Factory/RecurrenceFactory.php@@ -80,7 +80,7 @@ class RecurrenceFactory$firstDate = $data['recurrence']['first_date'];}if (array_key_exists('nr_of_repetitions', $data['recurrence'])) {- $repetitions = (int)$data['recurrence']['nr_of_repetitions'];+ $repetitions = (int) $data['recurrence']['nr_of_repetitions'];}if (array_key_exists('repeat_until', $data['recurrence'])) {$repeatUntil = $data['recurrence']['repeat_until'];@@ -117,7 +117,7 @@ class RecurrenceFactory$recurrence->save();if (array_key_exists('notes', $data['recurrence'])) {- $this->updateNote($recurrence, (string)$data['recurrence']['notes']);+ $this->updateNote($recurrence, (string) $data['recurrence']['notes']);}$this->createRepetitions($recurrence, $data['repetitions'] ?? []);diff --git a/app/Factory/TagFactory.php b/app/Factory/TagFactory.phpindex c0defbdd56..36c5a5b50a 100644--- a/app/Factory/TagFactory.php+++ b/app/Factory/TagFactory.php@@ -69,9 +69,9 @@ class TagFactorypublic function create(array $data): ?Tag{- $zoomLevel = 0 === (int)$data['zoom_level'] ? null : (int)$data['zoom_level'];- $latitude = 0.0 === (float)$data['latitude'] ? null : (float)$data['latitude']; // intentional float- $longitude = 0.0 === (float)$data['longitude'] ? null : (float)$data['longitude']; // intentional float+ $zoomLevel = 0 === (int) $data['zoom_level'] ? null : (int) $data['zoom_level'];+ $latitude = 0.0 === (float) $data['latitude'] ? null : (float) $data['latitude']; // intentional float+ $longitude = 0.0 === (float) $data['longitude'] ? null : (float) $data['longitude']; // intentional float$array = ['user_id' => $this->user->id,'user_group_id' => $this->user->user_group_id,diff --git a/app/Factory/TransactionCurrencyFactory.php b/app/Factory/TransactionCurrencyFactory.phpindex 31c14d7e59..b4088e200d 100644--- a/app/Factory/TransactionCurrencyFactory.php+++ b/app/Factory/TransactionCurrencyFactory.php@@ -41,7 +41,7 @@ class TransactionCurrencyFactory$data['code'] = e($data['code']);$data['symbol'] = e($data['symbol']);$data['name'] = e($data['name']);- $data['decimal_places'] = (int)$data['decimal_places'];+ $data['decimal_places'] = (int) $data['decimal_places'];// if the code already exists (deleted)// force delete it and then create the transaction:$count = TransactionCurrency::withTrashed()->whereCode($data['code'])->count();@@ -76,7 +76,7 @@ class TransactionCurrencyFactorypublic function find(?int $currencyId, ?string $currencyCode): ?TransactionCurrency{$currencyCode = e($currencyCode);- $currencyId = (int)$currencyId;+ $currencyId = (int) $currencyId;if ('' === $currencyCode && 0 === $currencyId) {app('log')->debug('Cannot find anything on empty currency code and empty currency ID!');diff --git a/app/Factory/TransactionFactory.php b/app/Factory/TransactionFactory.phpindex 15308c674f..d39f31699b 100644--- a/app/Factory/TransactionFactory.php+++ b/app/Factory/TransactionFactory.php@@ -142,7 +142,7 @@ class TransactionFactoryreturn;}- if ('' !== (string)$this->account->iban) {+ if ('' !== (string) $this->account->iban) {app('log')->debug('Account already has IBAN information, will not update.');return;diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.phpindex 0ad8ef096d..f7db35bc54 100644--- a/app/Factory/TransactionJournalFactory.php+++ b/app/Factory/TransactionJournalFactory.php@@ -163,11 +163,11 @@ class TransactionJournalFactory$type = $this->typeRepository->findTransactionType(null, $row['type']);$carbon = $row['date'] ?? today(config('app.timezone'));$order = $row['order'] ?? 0;- $currency = $this->currencyRepository->findCurrency((int)$row['currency_id'], $row['currency_code']);+ $currency = $this->currencyRepository->findCurrency((int) $row['currency_id'], $row['currency_code']);$foreignCurrency = $this->currencyRepository->findCurrencyNull($row['foreign_currency_id'], $row['foreign_currency_code']);- $bill = $this->billRepository->findBill((int)$row['bill_id'], $row['bill_name']);+ $bill = $this->billRepository->findBill((int) $row['bill_id'], $row['bill_name']);$billId = TransactionType::WITHDRAWAL === $type->type && null !== $bill ? $bill->id : null;- $description = (string)$row['description'];+ $description = (string) $row['description'];// Manipulate basic fields$carbon->setTimezone(config('app.timezone'));@@ -254,7 +254,7 @@ class TransactionJournalFactory$transactionFactory->setReconciled($row['reconciled'] ?? false);try {- $negative = $transactionFactory->createNegative((string)$row['amount'], (string)$row['foreign_amount']);+ $negative = $transactionFactory->createNegative((string) $row['amount'], (string) $row['foreign_amount']);} catch (FireflyException $e) {app('log')->error(sprintf('Exception creating negative transaction: %s', $e->getMessage()));$this->forceDeleteOnError(new Collection([$journal]));@@ -276,15 +276,15 @@ class TransactionJournalFactory// Firefly III will save the foreign currency information in such a way that both// asset accounts can look at the "amount" and "transaction_currency_id" column and// see the currency they expect to see.- $amount = (string)$row['amount'];- $foreignAmount = (string)$row['foreign_amount'];+ $amount = (string) $row['amount'];+ $foreignAmount = (string) $row['foreign_amount'];if (null !== $foreignCurrency && $foreignCurrency->id !== $currency->id- && TransactionType::TRANSFER === $type->type+ && TransactionType::TRANSFER === $type->type) {$transactionFactory->setCurrency($foreignCurrency);$transactionFactory->setForeignCurrency($currency);- $amount = (string)$row['foreign_amount'];- $foreignAmount = (string)$row['amount'];+ $amount = (string) $row['foreign_amount'];+ $foreignAmount = (string) $row['amount'];Log::debug('Swap native/foreign amounts in transfer for new save method.');}@@ -354,7 +354,7 @@ class TransactionJournalFactoryapp('log')->warning(sprintf('Found a duplicate in errorIfDuplicate because hash %s is not unique!', $hash));$journal = $result->transactionJournal()->withTrashed()->first();$group = $journal?->transactionGroup()->withTrashed()->first();- $groupId = (int)$group?->id;+ $groupId = (int) $group?->id;throw new DuplicateTransactionException(sprintf('Duplicate of transaction #%d.', $groupId));}@@ -372,10 +372,10 @@ class TransactionJournalFactory// validate source account.$array = [- 'id' => null !== $data['source_id'] ? (int)$data['source_id'] : null,- 'name' => null !== $data['source_name'] ? (string)$data['source_name'] : null,- 'iban' => null !== $data['source_iban'] ? (string)$data['source_iban'] : null,- 'number' => null !== $data['source_number'] ? (string)$data['source_number'] : null,+ 'id' => null !== $data['source_id'] ? (int) $data['source_id'] : null,+ 'name' => null !== $data['source_name'] ? (string) $data['source_name'] : null,+ 'iban' => null !== $data['source_iban'] ? (string) $data['source_iban'] : null,+ 'number' => null !== $data['source_number'] ? (string) $data['source_number'] : null,];$validSource = $this->accountValidator->validateSource($array);@@ -387,10 +387,10 @@ class TransactionJournalFactory// validate destination account$array = [- 'id' => null !== $data['destination_id'] ? (int)$data['destination_id'] : null,- 'name' => null !== $data['destination_name'] ? (string)$data['destination_name'] : null,- 'iban' => null !== $data['destination_iban'] ? (string)$data['destination_iban'] : null,- 'number' => null !== $data['destination_number'] ? (string)$data['destination_number'] : null,+ 'id' => null !== $data['destination_id'] ? (int) $data['destination_id'] : null,+ 'name' => null !== $data['destination_name'] ? (string) $data['destination_name'] : null,+ 'iban' => null !== $data['destination_iban'] ? (string) $data['destination_iban'] : null,+ 'number' => null !== $data['destination_number'] ? (string) $data['destination_number'] : null,];$validDestination = $this->accountValidator->validateDestination($array);@@ -537,7 +537,7 @@ class TransactionJournalFactory{app('log')->debug('Will now store piggy event.');- $piggyBank = $this->piggyRepository->findPiggyBank((int)$data['piggy_bank_id'], $data['piggy_bank_name']);+ $piggyBank = $this->piggyRepository->findPiggyBank((int) $data['piggy_bank_id'], $data['piggy_bank_name']);if (null !== $piggyBank) {$this->piggyEventFactory->create($journal, $piggyBank);@@ -560,7 +560,7 @@ class TransactionJournalFactory$set = ['journal' => $journal,'name' => $field,- 'data' => (string)($data[$field] ?? ''),+ 'data' => (string) ($data[$field] ?? ''),];if ($data[$field] instanceof Carbon) {$data[$field]->setTimezone(config('app.timezone'));diff --git a/app/Factory/TransactionJournalMetaFactory.php b/app/Factory/TransactionJournalMetaFactory.phpindex 19fe414ecc..56dd79d1e0 100644--- a/app/Factory/TransactionJournalMetaFactory.php+++ b/app/Factory/TransactionJournalMetaFactory.php@@ -50,7 +50,7 @@ class TransactionJournalMetaFactoryapp('log')->debug('Is a carbon object.');$value = $data['data']->toW3cString();}- if ('' === (string)$value) {+ if ('' === (string) $value) {// app('log')->debug('Is an empty string.');// don't store blank strings.if (null !== $entry) {diff --git a/app/Generator/Chart/Basic/ChartJsGenerator.php b/app/Generator/Chart/Basic/ChartJsGenerator.phpindex 3675871dec..4fd3a258e7 100644--- a/app/Generator/Chart/Basic/ChartJsGenerator.php+++ b/app/Generator/Chart/Basic/ChartJsGenerator.php@@ -47,7 +47,7 @@ class ChartJsGenerator implements GeneratorInterface$amounts = array_column($data, 'amount');$next = next($amounts);$sortFlag = SORT_ASC;- if (!is_bool($next) && 1 === bccomp((string)$next, '0')) {+ if (!is_bool($next) && 1 === bccomp((string) $next, '0')) {$sortFlag = SORT_DESC;}array_multisort($amounts, $sortFlag, $data);@@ -56,7 +56,7 @@ class ChartJsGenerator implements GeneratorInterface$index = 0;foreach ($data as $key => $valueArray) {// make larger than 0- $chartData['datasets'][0]['data'][] = app('steam')->positive((string)$valueArray['amount']);+ $chartData['datasets'][0]['data'][] = app('steam')->positive((string) $valueArray['amount']);$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);$chartData['datasets'][0]['currency_symbol'][] = $valueArray['currency_symbol'];$chartData['labels'][] = $key;@@ -154,7 +154,7 @@ class ChartJsGenerator implements GeneratorInterface// different sort when values are positive and when they're negative.asort($data);$next = next($data);- if (!is_bool($next) && 1 === bccomp((string)$next, '0')) {+ if (!is_bool($next) && 1 === bccomp((string) $next, '0')) {// next is positive, sort other way around.arsort($data);}@@ -163,7 +163,7 @@ class ChartJsGenerator implements GeneratorInterface$index = 0;foreach ($data as $key => $value) {// make larger than 0- $chartData['datasets'][0]['data'][] = app('steam')->positive((string)$value);+ $chartData['datasets'][0]['data'][] = app('steam')->positive((string) $value);$chartData['datasets'][0]['backgroundColor'][] = ChartColour::getColour($index);$chartData['labels'][] = $key;diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.phpindex 5872a31fca..c5f65261bd 100644--- a/app/Generator/Report/Audit/MonthReportGenerator.php+++ b/app/Generator/Report/Audit/MonthReportGenerator.php@@ -168,9 +168,9 @@ class MonthReportGenerator implements ReportGeneratorInterface'journals' => $journals,'currency' => $currency,'exists' => 0 !== count($journals),- 'end' => $this->end->isoFormat((string)trans('config.month_and_day_moment_js', [], $locale)),+ 'end' => $this->end->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)),'endBalance' => app('steam')->balance($account, $this->end),- 'dayBefore' => $date->isoFormat((string)trans('config.month_and_day_moment_js', [], $locale)),+ 'dayBefore' => $date->isoFormat((string) trans('config.month_and_day_moment_js', [], $locale)),'dayBeforeBalance' => $dayBeforeBalance,];}diff --git a/app/Handlers/Events/APIEventHandler.php b/app/Handlers/Events/APIEventHandler.phpindex 1770c1a1ca..79f3bfe22e 100644--- a/app/Handlers/Events/APIEventHandler.php+++ b/app/Handlers/Events/APIEventHandler.php@@ -43,7 +43,7 @@ class APIEventHandler/** @var UserRepositoryInterface $repository */$repository = app(UserRepositoryInterface::class);- $user = $repository->find((int)$event->userId);+ $user = $repository->find((int) $event->userId);if (null !== $user) {try {diff --git a/app/Handlers/Events/AdminEventHandler.php b/app/Handlers/Events/AdminEventHandler.phpindex 3674200b34..531d947249 100644--- a/app/Handlers/Events/AdminEventHandler.php+++ b/app/Handlers/Events/AdminEventHandler.php@@ -43,11 +43,16 @@ use Illuminate\Support\Facades\Notification;*/class AdminEventHandler{- public function sendLoginAttemptNotification(UnknownUserAttemptedLogin $event): void+ public function sendInvitationNotification(InvitationCreated $event): void{+ $sendMail = app('fireflyconfig')->get('notification_invite_created', true)->data;+ if (false === $sendMail) {+ return;+ }+try {$owner = new OwnerNotifiable();- Notification::send($owner, new UnknownUserLoginAttempt($event->address));+ Notification::send($owner, new UserInvitation($owner, $event->invitee));} catch (\Exception $e) { // @phpstan-ignore-line$message = $e->getMessage();if (str_contains($message, 'Bcc')) {@@ -65,16 +70,11 @@ class AdminEventHandler}}- public function sendInvitationNotification(InvitationCreated $event): void+ public function sendLoginAttemptNotification(UnknownUserAttemptedLogin $event): void{- $sendMail = app('fireflyconfig')->get('notification_invite_created', true)->data;- if (false === $sendMail) {- return;- }-try {$owner = new OwnerNotifiable();- Notification::send($owner, new UserInvitation($owner, $event->invitee));+ Notification::send($owner, new UnknownUserLoginAttempt($event->address));} catch (\Exception $e) { // @phpstan-ignore-line$message = $e->getMessage();if (str_contains($message, 'Bcc')) {diff --git a/app/Handlers/Events/Model/BudgetLimitHandler.php b/app/Handlers/Events/Model/BudgetLimitHandler.phpindex 71fd12ac60..e1b807d185 100644--- a/app/Handlers/Events/Model/BudgetLimitHandler.php+++ b/app/Handlers/Events/Model/BudgetLimitHandler.php@@ -89,7 +89,7 @@ class BudgetLimitHandlerif (null === $viewRange || is_array($viewRange)) {$viewRange = '1M';}- $viewRange = (string)$viewRange;+ $viewRange = (string) $viewRange;$start = app('navigation')->startOfPeriod($budgetLimit->start_date, $viewRange);$end = app('navigation')->startOfPeriod($budgetLimit->end_date, $viewRange);@@ -119,7 +119,7 @@ class BudgetLimitHandler// if not exists:$currentPeriod = Period::make($current, $currentEnd, precision: Precision::DAY(), boundaries: Boundaries::EXCLUDE_NONE());$daily = $this->getDailyAmount($budgetLimit);- $amount = bcmul($daily, (string)$currentPeriod->length(), 12);+ $amount = bcmul($daily, (string) $currentPeriod->length(), 12);// no need to calculate if period is equal.if ($currentPeriod->equals($limitPeriod)) {@@ -132,14 +132,14 @@ class BudgetLimitHandlerapp('log')->debug(sprintf('Will create AB for period %s to %s', $current->format('Y-m-d'), $currentEnd->format('Y-m-d')));$availableBudget = new AvailableBudget([- 'user_id' => $user->id,- 'user_group_id' => $user->user_group_id,- 'transaction_currency_id' => $budgetLimit->transaction_currency_id,- 'start_date' => $current,- 'start_date_tz' => $current->format('e'),- 'end_date' => $currentEnd,- 'end_date_tz' => $currentEnd->format('e'),- 'amount' => $amount,+ 'user_id' => $user->id,+ 'user_group_id' => $user->user_group_id,+ 'transaction_currency_id' => $budgetLimit->transaction_currency_id,+ 'start_date' => $current,+ 'start_date_tz' => $current->format('e'),+ 'end_date' => $currentEnd,+ 'end_date_tz' => $currentEnd->format('e'),+ 'amount' => $amount,]);$availableBudget->save();@@ -202,7 +202,7 @@ class BudgetLimitHandler$overlap = $abPeriod->overlap($limitPeriod);if (null !== $overlap) {$length = $overlap->length();- $daily = bcmul($this->getDailyAmount($budgetLimit), (string)$length);+ $daily = bcmul($this->getDailyAmount($budgetLimit), (string) $length);$newAmount = bcadd($newAmount, $daily);}}@@ -230,7 +230,7 @@ class BudgetLimitHandlerboundaries: Boundaries::EXCLUDE_NONE());$days = $limitPeriod->length();- $amount = bcdiv($budgetLimit->amount, (string)$days, 12);+ $amount = bcdiv($budgetLimit->amount, (string) $days, 12);app('log')->debug(sprintf('Total amount for budget limit #%d is %s. Nr. of days is %d. Amount per day is %s', $budgetLimit->id, $budgetLimit->amount, $days, $amount));diff --git a/app/Handlers/Events/Security/MFAHandler.php b/app/Handlers/Events/Security/MFAHandler.phpindex 80c3409adf..1320ac2080 100644--- a/app/Handlers/Events/Security/MFAHandler.php+++ b/app/Handlers/Events/Security/MFAHandler.php@@ -42,14 +42,15 @@ use Illuminate\Support\Facades\Notification;class MFAHandler{- public function sendMFAEnabledMail(EnabledMFA $event): void+ public function sendBackupFewLeftMail(MFABackupFewLeft $event): void{app('log')->debug(sprintf('Now in %s', __METHOD__));- $user = $event->user;+ $user = $event->user;+ $count = $event->count;try {- Notification::send($user, new EnabledMFANotification($user));+ Notification::send($user, new MFABackupFewLeftNotification($user, $count));} catch (\Exception $e) { // @phpstan-ignore-line$message = $e->getMessage();if (str_contains($message, 'Bcc')) {@@ -67,14 +68,14 @@ class MFAHandler}}- public function sendNewMFABackupCodesMail(MFANewBackupCodes $event): void+ public function sendBackupNoLeftMail(MFABackupNoLeft $event): void{app('log')->debug(sprintf('Now in %s', __METHOD__));$user = $event->user;try {- Notification::send($user, new NewBackupCodesNotification($user));+ Notification::send($user, new MFABackupNoLeftNotification($user));} catch (\Exception $e) { // @phpstan-ignore-line$message = $e->getMessage();if (str_contains($message, 'Bcc')) {@@ -92,15 +93,14 @@ class MFAHandler}}- public function sendBackupFewLeftMail(MFABackupFewLeft $event): void+ public function sendMFADisabledMail(DisabledMFA $event): void{app('log')->debug(sprintf('Now in %s', __METHOD__));- $user = $event->user;- $count = $event->count;+ $user = $event->user;try {- Notification::send($user, new MFABackupFewLeftNotification($user, $count));+ Notification::send($user, new DisabledMFANotification($user));} catch (\Exception $e) { // @phpstan-ignore-line$message = $e->getMessage();if (str_contains($message, 'Bcc')) {@@ -118,15 +118,14 @@ class MFAHandler}}- public function sendMFAFailedAttemptsMail(MFAManyFailedAttempts $event): void+ public function sendMFAEnabledMail(EnabledMFA $event): void{app('log')->debug(sprintf('Now in %s', __METHOD__));- $user = $event->user;- $count = $event->count;+ $user = $event->user;try {- Notification::send($user, new MFAManyFailedAttemptsNotification($user, $count));+ Notification::send($user, new EnabledMFANotification($user));} catch (\Exception $e) { // @phpstan-ignore-line$message = $e->getMessage();if (str_contains($message, 'Bcc')) {@@ -144,14 +143,15 @@ class MFAHandler}}- public function sendBackupNoLeftMail(MFABackupNoLeft $event): void+ public function sendMFAFailedAttemptsMail(MFAManyFailedAttempts $event): void{app('log')->debug(sprintf('Now in %s', __METHOD__));- $user = $event->user;+ $user = $event->user;+ $count = $event->count;try {- Notification::send($user, new MFABackupNoLeftNotification($user));+ Notification::send($user, new MFAManyFailedAttemptsNotification($user, $count));} catch (\Exception $e) { // @phpstan-ignore-line$message = $e->getMessage();if (str_contains($message, 'Bcc')) {@@ -169,14 +169,14 @@ class MFAHandler}}- public function sendUsedBackupCodeMail(MFAUsedBackupCode $event): void+ public function sendNewMFABackupCodesMail(MFANewBackupCodes $event): void{app('log')->debug(sprintf('Now in %s', __METHOD__));$user = $event->user;try {- Notification::send($user, new MFAUsedBackupCodeNotification($user));+ Notification::send($user, new NewBackupCodesNotification($user));} catch (\Exception $e) { // @phpstan-ignore-line$message = $e->getMessage();if (str_contains($message, 'Bcc')) {@@ -194,14 +194,14 @@ class MFAHandler}}- public function sendMFADisabledMail(DisabledMFA $event): void+ public function sendUsedBackupCodeMail(MFAUsedBackupCode $event): void{app('log')->debug(sprintf('Now in %s', __METHOD__));$user = $event->user;try {- Notification::send($user, new DisabledMFANotification($user));+ Notification::send($user, new MFAUsedBackupCodeNotification($user));} catch (\Exception $e) { // @phpstan-ignore-line$message = $e->getMessage();if (str_contains($message, 'Bcc')) {diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.phpindex 4216169cbb..91efe68017 100644--- a/app/Handlers/Events/UserEventHandler.php+++ b/app/Handlers/Events/UserEventHandler.php@@ -300,6 +300,27 @@ class UserEventHandler}}+ public function sendLoginAttemptNotification(UserAttemptedLogin $event): void+ {+ try {+ Notification::send($event->user, new UserFailedLoginAttempt($event->user));+ } catch (\Exception $e) { // @phpstan-ignore-line+ $message = $e->getMessage();+ 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.');++ return;+ }+ if (str_contains($message, 'RFC 2822')) {+ app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');++ return;+ }+ app('log')->error($e->getMessage());+ app('log')->error($e->getTraceAsString());+ }+ }+/*** Send a new password to the user.*/@@ -371,6 +392,61 @@ class UserEventHandler}}+ /**+ * Sends a test message to an administrator.+ */+ public function sendTestNotification(UserTestNotificationChannel $event): void+ {+ Log::debug(sprintf('Now in (user) sendTestNotification("%s")', $event->channel));++ switch ($event->channel) {+ case 'email':+ $class = UserTestNotificationEmail::class;++ break;++ case 'slack':+ $class = UserTestNotificationSlack::class;++ break;++ case 'ntfy':+ $class = UserTestNotificationNtfy::class;++ break;++ case 'pushover':+ $class = UserTestNotificationPushover::class;++ break;++ default:+ app('log')->error(sprintf('Unknown channel "%s" in (user) sendTestNotification method.', $event->channel));++ return;+ }+ Log::debug(sprintf('Will send %s as a notification.', $class));++ try {+ Notification::send($event->user, new $class($event->user));+ } catch (\Exception $e) { // @phpstan-ignore-line+ $message = $e->getMessage();+ 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.');++ return;+ }+ if (str_contains($message, 'RFC 2822')) {+ app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');++ return;+ }+ app('log')->error($e->getMessage());+ app('log')->error($e->getTraceAsString());+ }+ Log::debug(sprintf('If you see no errors above this line, test notification was sent over channel "%s"', $event->channel));+ }+/*** @throws FireflyException*/@@ -430,80 +506,4 @@ class UserEventHandlerevent(new DetectedNewIPAddress($user));}}-- public function sendLoginAttemptNotification(UserAttemptedLogin $event): void- {- try {- Notification::send($event->user, new UserFailedLoginAttempt($event->user));- } catch (\Exception $e) { // @phpstan-ignore-line- $message = $e->getMessage();- 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.');-- return;- }- if (str_contains($message, 'RFC 2822')) {- app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- app('log')->error($e->getMessage());- app('log')->error($e->getTraceAsString());- }- }-- /**- * Sends a test message to an administrator.- */- public function sendTestNotification(UserTestNotificationChannel $event): void- {- Log::debug(sprintf('Now in (user) sendTestNotification("%s")', $event->channel));-- switch ($event->channel) {- case 'email':- $class = UserTestNotificationEmail::class;-- break;-- case 'slack':- $class = UserTestNotificationSlack::class;-- break;-- case 'ntfy':- $class = UserTestNotificationNtfy::class;-- break;-- case 'pushover':- $class = UserTestNotificationPushover::class;-- break;-- default:- app('log')->error(sprintf('Unknown channel "%s" in (user) sendTestNotification method.', $event->channel));-- return;- }- Log::debug(sprintf('Will send %s as a notification.', $class));-- try {- Notification::send($event->user, new $class($event->user));- } catch (\Exception $e) { // @phpstan-ignore-line- $message = $e->getMessage();- 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.');-- return;- }- if (str_contains($message, 'RFC 2822')) {- app('log')->warning('[RFC] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');-- return;- }- app('log')->error($e->getMessage());- app('log')->error($e->getTraceAsString());- }- Log::debug(sprintf('If you see no errors above this line, test notification was sent over channel "%s"', $event->channel));- }}diff --git a/app/Handlers/Events/VersionCheckEventHandler.php b/app/Handlers/Events/VersionCheckEventHandler.phpindex 70a104ac07..a1e909c68d 100644--- a/app/Handlers/Events/VersionCheckEventHandler.php+++ b/app/Handlers/Events/VersionCheckEventHandler.php@@ -49,7 +49,7 @@ class VersionCheckEventHandler// should not check for updates:$permission = app('fireflyconfig')->get('permission_update_check', -1);- $value = (int)$permission->data;+ $value = (int) $permission->data;if (1 !== $value) {app('log')->debug('Update check is not enabled.');$this->warnToCheckForUpdates($event);@@ -111,7 +111,7 @@ class VersionCheckEventHandler// last check time was more than a week ago.app('log')->debug('Have warned about a new version in four weeks!');- session()->flash('info', (string)trans('firefly.disabled_but_check'));+ session()->flash('info', (string) trans('firefly.disabled_but_check'));app('fireflyconfig')->set('last_update_warning', time());}}diff --git a/app/Handlers/Observer/AccountObserver.php b/app/Handlers/Observer/AccountObserver.phpindex a5ace2c3e8..1ac1f1d27b 100644--- a/app/Handlers/Observer/AccountObserver.php+++ b/app/Handlers/Observer/AccountObserver.php@@ -35,6 +35,31 @@ use Illuminate\Support\Facades\Log;*/class AccountObserver{+ public function created(Account $account): void+ {+ Log::debug('Observe "created" of an account.');+ $this->updateNativeAmount($account);+ }++ private function updateNativeAmount(Account $account): void+ {+ $userCurrency = app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);+ $repository = app(AccountRepositoryInterface::class);+ $currency = $repository->getAccountCurrency($account);+ if (null !== $currency && $currency->id !== $userCurrency->id && '' !== (string) $account->virtual_balance && 0 !== bccomp($account->virtual_balance, '0')) {+ $converter = new ExchangeRateConverter();+ $converter->setIgnoreSettings(true);+ $account->native_virtual_balance = $converter->convert($currency, $userCurrency, today(), $account->virtual_balance);++ }+ if ('' === (string) $account->virtual_balance || ('' !== (string) $account->virtual_balance && 0 === bccomp($account->virtual_balance, '0'))) {+ $account->virtual_balance = null;+ $account->native_virtual_balance = null;+ }+ $account->saveQuietly();+ Log::debug('Account native virtual balance is updated.');+ }+/*** Also delete related objects.*/@@ -57,34 +82,9 @@ class AccountObserver$account->locations()->delete();}- public function created(Account $account): void- {- Log::debug('Observe "created" of an account.');- $this->updateNativeAmount($account);- }-public function updated(Account $account): void{Log::debug('Observe "updated" of an account.');$this->updateNativeAmount($account);}-- private function updateNativeAmount(Account $account): void- {- $userCurrency = app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);- $repository = app(AccountRepositoryInterface::class);- $currency = $repository->getAccountCurrency($account);- if (null !== $currency && $currency->id !== $userCurrency->id && '' !== (string) $account->virtual_balance && 0 !== bccomp($account->virtual_balance, '0')) {- $converter = new ExchangeRateConverter();- $converter->setIgnoreSettings(true);- $account->native_virtual_balance = $converter->convert($currency, $userCurrency, today(), $account->virtual_balance);-- }- if ('' === (string) $account->virtual_balance || ('' !== (string) $account->virtual_balance && 0 === bccomp($account->virtual_balance, '0'))) {- $account->virtual_balance = null;- $account->native_virtual_balance = null;- }- $account->saveQuietly();- Log::debug('Account native virtual balance is updated.');- }}diff --git a/app/Handlers/Observer/AutoBudgetObserver.php b/app/Handlers/Observer/AutoBudgetObserver.phpindex 13b577afb3..9193bc06a9 100644--- a/app/Handlers/Observer/AutoBudgetObserver.php+++ b/app/Handlers/Observer/AutoBudgetObserver.php@@ -30,15 +30,15 @@ use Illuminate\Support\Facades\Log;class AutoBudgetObserver{- public function updated(AutoBudget $autoBudget): void+ public function created(AutoBudget $autoBudget): void{- Log::debug('Observe "updated" of an auto budget.');+ Log::debug('Observe "created" of an auto budget.');$this->updateNativeAmount($autoBudget);}- public function created(AutoBudget $autoBudget): void+ public function updated(AutoBudget $autoBudget): void{- Log::debug('Observe "created" of an auto budget.');+ Log::debug('Observe "updated" of an auto budget.');$this->updateNativeAmount($autoBudget);}diff --git a/app/Handlers/Observer/AvailableBudgetObserver.php b/app/Handlers/Observer/AvailableBudgetObserver.phpindex 0d25f9278c..56a4af3cd8 100644--- a/app/Handlers/Observer/AvailableBudgetObserver.php+++ b/app/Handlers/Observer/AvailableBudgetObserver.php@@ -30,15 +30,15 @@ use Illuminate\Support\Facades\Log;class AvailableBudgetObserver{- public function updated(AvailableBudget $availableBudget): void+ public function created(AvailableBudget $availableBudget): void{- Log::debug('Observe "updated" of an available budget.');+ Log::debug('Observe "created" of an available budget.');$this->updateNativeAmount($availableBudget);}- public function created(AvailableBudget $availableBudget): void+ public function updated(AvailableBudget $availableBudget): void{- Log::debug('Observe "created" of an available budget.');+ Log::debug('Observe "updated" of an available budget.');$this->updateNativeAmount($availableBudget);}diff --git a/app/Handlers/Observer/BillObserver.php b/app/Handlers/Observer/BillObserver.phpindex 2def835fa5..5bcba3cfcf 100644--- a/app/Handlers/Observer/BillObserver.php+++ b/app/Handlers/Observer/BillObserver.php@@ -32,6 +32,12 @@ use Illuminate\Support\Facades\Log;*/class BillObserver{+ public function created(Bill $bill): void+ {+ Log::debug('Observe "created" of a bill.');+ $this->updateNativeAmount($bill);+ }+public function deleting(Bill $bill): void{app('log')->debug('Observe "deleting" of a bill.');@@ -47,12 +53,6 @@ class BillObserver$this->updateNativeAmount($bill);}- public function created(Bill $bill): void- {- Log::debug('Observe "created" of a bill.');- $this->updateNativeAmount($bill);- }-private function updateNativeAmount(Bill $bill): void{$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($bill->user->userGroup);diff --git a/app/Handlers/Observer/BudgetLimitObserver.php b/app/Handlers/Observer/BudgetLimitObserver.phpindex 140490f1db..ec3f49a209 100644--- a/app/Handlers/Observer/BudgetLimitObserver.php+++ b/app/Handlers/Observer/BudgetLimitObserver.php@@ -30,15 +30,15 @@ use Illuminate\Support\Facades\Log;class BudgetLimitObserver{- public function updated(BudgetLimit $budgetLimit): void+ public function created(BudgetLimit $budgetLimit): void{- Log::debug('Observe "updated" of a budget limit.');+ Log::debug('Observe "created" of a budget limit.');$this->updateNativeAmount($budgetLimit);}- public function created(BudgetLimit $budgetLimit): void+ public function updated(BudgetLimit $budgetLimit): void{- Log::debug('Observe "created" of a budget limit.');+ Log::debug('Observe "updated" of a budget limit.');$this->updateNativeAmount($budgetLimit);}diff --git a/app/Handlers/Observer/PiggyBankEventObserver.php b/app/Handlers/Observer/PiggyBankEventObserver.phpindex 5fed2f142b..6afcf69f82 100644--- a/app/Handlers/Observer/PiggyBankEventObserver.php+++ b/app/Handlers/Observer/PiggyBankEventObserver.php@@ -30,15 +30,15 @@ use Illuminate\Support\Facades\Log;class PiggyBankEventObserver{- public function updated(PiggyBankEvent $event): void+ public function created(PiggyBankEvent $event): void{- Log::debug('Observe "updated" of a piggy bank event.');+ Log::debug('Observe "created" of a piggy bank event.');$this->updateNativeAmount($event);}- public function created(PiggyBankEvent $event): void+ public function updated(PiggyBankEvent $event): void{- Log::debug('Observe "created" of a piggy bank event.');+ Log::debug('Observe "updated" of a piggy bank event.');$this->updateNativeAmount($event);}diff --git a/app/Handlers/Observer/PiggyBankObserver.php b/app/Handlers/Observer/PiggyBankObserver.phpindex 3c25633f17..b66d5d7bd0 100644--- a/app/Handlers/Observer/PiggyBankObserver.php+++ b/app/Handlers/Observer/PiggyBankObserver.php@@ -33,15 +33,32 @@ use Illuminate\Support\Facades\Log;*/class PiggyBankObserver{- public function updated(PiggyBank $piggyBank): void+ public function created(PiggyBank $piggyBank): void{- Log::debug('Observe "updated" of a piggy bank.');+ Log::debug('Observe "created" of a piggy bank.');$this->updateNativeAmount($piggyBank);}- public function created(PiggyBank $piggyBank): void+ /**+ * Also delete related objects.+ */+ public function deleting(PiggyBank $piggyBank): void{- Log::debug('Observe "created" of a piggy bank.');+ app('log')->debug('Observe "deleting" of a piggy bank.');++ foreach ($piggyBank->attachments()->get() as $attachment) {+ $attachment->delete();+ }++ $piggyBank->piggyBankEvents()->delete();+ $piggyBank->piggyBankRepetitions()->delete();++ $piggyBank->notes()->delete();+ }++ public function updated(PiggyBank $piggyBank): void+ {+ Log::debug('Observe "updated" of a piggy bank.');$this->updateNativeAmount($piggyBank);}@@ -66,21 +83,4 @@ class PiggyBankObserver$piggyBank->saveQuietly();Log::debug('Piggy bank native target amount is updated.');}-- /**- * Also delete related objects.- */- public function deleting(PiggyBank $piggyBank): void- {- app('log')->debug('Observe "deleting" of a piggy bank.');-- foreach ($piggyBank->attachments()->get() as $attachment) {- $attachment->delete();- }-- $piggyBank->piggyBankEvents()->delete();- $piggyBank->piggyBankRepetitions()->delete();-- $piggyBank->notes()->delete();- }}diff --git a/app/Handlers/Observer/TransactionObserver.php b/app/Handlers/Observer/TransactionObserver.phpindex 10241050dc..51246ec2bc 100644--- a/app/Handlers/Observer/TransactionObserver.php+++ b/app/Handlers/Observer/TransactionObserver.php@@ -35,6 +35,18 @@ class TransactionObserver{public static bool $recalculate = true;+ public function created(Transaction $transaction): void+ {+ Log::debug('Observe "created" of a transaction.');+ if (config('firefly.feature_flags.running_balance_column')) {+ if (1 === bccomp($transaction->amount, '0') && self::$recalculate) {+ Log::debug('Trigger recalculateForJournal');+ AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);+ }+ }+ $this->updateNativeAmount($transaction);+ }+public function deleting(?Transaction $transaction): void{app('log')->debug('Observe "deleting" of a transaction.');@@ -53,18 +65,6 @@ class TransactionObserver$this->updateNativeAmount($transaction);}- public function created(Transaction $transaction): void- {- Log::debug('Observe "created" of a transaction.');- if (config('firefly.feature_flags.running_balance_column')) {- if (1 === bccomp($transaction->amount, '0') && self::$recalculate) {- Log::debug('Trigger recalculateForJournal');- AccountBalanceCalculator::recalculateForJournal($transaction->transactionJournal);- }- }- $this->updateNativeAmount($transaction);- }-private function updateNativeAmount(Transaction $transaction): void{$userCurrency = app('amount')->getDefaultCurrencyByUserGroup($transaction->transactionJournal->user->userGroup);diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.phpindex b0b241a819..42b53f8c56 100644--- a/app/Helpers/Attachments/AttachmentHelper.php+++ b/app/Helpers/Attachments/AttachmentHelper.php@@ -54,8 +54,8 @@ class AttachmentHelper implements AttachmentHelperInterface*/public function __construct(){- $this->maxUploadSize = (int)config('firefly.maxUploadSize');- $this->allowedMimes = (array)config('firefly.allowedMimes');+ $this->maxUploadSize = (int) config('firefly.maxUploadSize');+ $this->allowedMimes = (array) config('firefly.allowedMimes');$this->errors = new MessageBag();$this->messages = new MessageBag();$this->attachments = new Collection();@@ -67,7 +67,7 @@ class AttachmentHelper implements AttachmentHelperInterface*/public function getAttachmentContent(Attachment $attachment): string{- $encryptedData = (string)$this->uploadDisk->get(sprintf('at-%d.data', $attachment->id));+ $encryptedData = (string) $this->uploadDisk->get(sprintf('at-%d.data', $attachment->id));try {$unencryptedData = \Crypt::decrypt($encryptedData); // verified@@ -146,7 +146,7 @@ class AttachmentHelper implements AttachmentHelperInterfacereturn false;}- $mime = (string)finfo_file($finfo, $path);+ $mime = (string) finfo_file($finfo, $path);$allowedMime = config('firefly.allowedMimes');if (!in_array($mime, $allowedMime, true)) {Log::error(sprintf('Mime type %s is not allowed for API file upload.', $mime));@@ -162,7 +162,7 @@ class AttachmentHelper implements AttachmentHelperInterface$this->uploadDisk->put($file, $content);// update attachment.- $attachment->md5 = (string)md5_file($path);+ $attachment->md5 = (string) md5_file($path);$attachment->mime = $mime;$attachment->size = strlen($content);$attachment->uploaded = true;@@ -224,7 +224,7 @@ class AttachmentHelper implements AttachmentHelperInterface$attachment = new Attachment(); // create Attachment object.$attachment->user()->associate($user);$attachment->attachable()->associate($model);- $attachment->md5 = (string)md5_file($file->getRealPath());+ $attachment->md5 = (string) md5_file($file->getRealPath());$attachment->filename = $file->getClientOriginalName();$attachment->mime = $file->getMimeType();$attachment->size = $file->getSize();@@ -241,7 +241,7 @@ class AttachmentHelper implements AttachmentHelperInterfacereturn null;}- $content = (string)$fileObject->fread($file->getSize());+ $content = (string) $fileObject->fread($file->getSize());Log::debug(sprintf('Full file length is %d and upload size is %d.', strlen($content), $file->getSize()));// store it without encryption.@@ -251,7 +251,7 @@ class AttachmentHelper implements AttachmentHelperInterface$this->attachments->push($attachment);$name = e($file->getClientOriginalName()); // add message:- $msg = (string)trans('validation.file_attached', ['name' => $name]);+ $msg = (string) trans('validation.file_attached', ['name' => $name]);$this->messages->add('attachments', $msg);}@@ -298,7 +298,7 @@ class AttachmentHelper implements AttachmentHelperInterface$result = true;if (!in_array($mime, $this->allowedMimes, true)) {- $msg = (string)trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]);+ $msg = (string) trans('validation.file_invalid_mime', ['name' => $name, 'mime' => $mime]);$this->errors->add('attachments', $msg);Log::error($msg);@@ -317,7 +317,7 @@ class AttachmentHelper implements AttachmentHelperInterface$name = e($file->getClientOriginalName());$result = true;if ($size > $this->maxUploadSize) {- $msg = (string)trans('validation.file_too_large', ['name' => $name]);+ $msg = (string) trans('validation.file_too_large', ['name' => $name]);$this->errors->add('attachments', $msg);Log::error($msg);@@ -345,7 +345,7 @@ class AttachmentHelper implements AttachmentHelperInterface}$result = false;if ($count > 0) {- $msg = (string)trans('validation.file_already_attached', ['name' => $name]);+ $msg = (string) trans('validation.file_already_attached', ['name' => $name]);$this->errors->add('attachments', $msg);Log::error($msg);$result = true;diff --git a/app/Helpers/Collector/Extensions/AttachmentCollection.php b/app/Helpers/Collector/Extensions/AttachmentCollection.phpindex 6e93eeed87..ab7e420cd5 100644--- a/app/Helpers/Collector/Extensions/AttachmentCollection.php+++ b/app/Helpers/Collector/Extensions/AttachmentCollection.php@@ -327,7 +327,7 @@ trait AttachmentCollectionforeach ($transaction['attachments'] as $attachment) {/** @var null|Attachment $object */$object = auth()->user()->attachments()->find($attachment['id']);- $notes = (string)$object?->notes()->first()?->text;+ $notes = (string) $object?->notes()->first()?->text;return '' !== $notes && $notes === $value;}@@ -351,7 +351,7 @@ trait AttachmentCollectionforeach ($transaction['attachments'] as $attachment) {/** @var null|Attachment $object */$object = auth()->user()->attachments()->find($attachment['id']);- $notes = (string)$object?->notes()->first()?->text;+ $notes = (string) $object?->notes()->first()?->text;return '' !== $notes && $notes !== $value;}@@ -375,7 +375,7 @@ trait AttachmentCollectionforeach ($transaction['attachments'] as $attachment) {/** @var null|Attachment $object */$object = auth()->user()->attachments()->find($attachment['id']);- $notes = (string)$object?->notes()->first()?->text;+ $notes = (string) $object?->notes()->first()?->text;return '' !== $notes && str_contains(strtolower($notes), strtolower($value));}@@ -399,7 +399,7 @@ trait AttachmentCollectionforeach ($transaction['attachments'] as $attachment) {/** @var null|Attachment $object */$object = auth()->user()->attachments()->find($attachment['id']);- $notes = (string)$object?->notes()->first()?->text;+ $notes = (string) $object?->notes()->first()?->text;return '' !== $notes && !str_contains(strtolower($notes), strtolower($value));}@@ -423,7 +423,7 @@ trait AttachmentCollectionforeach ($transaction['attachments'] as $attachment) {/** @var null|Attachment $object */$object = auth()->user()->attachments()->find($attachment['id']);- $notes = (string)$object?->notes()->first()?->text;+ $notes = (string) $object?->notes()->first()?->text;return '' !== $notes && !str_ends_with(strtolower($notes), strtolower($value));}@@ -447,7 +447,7 @@ trait AttachmentCollectionforeach ($transaction['attachments'] as $attachment) {/** @var null|Attachment $object */$object = auth()->user()->attachments()->find($attachment['id']);- $notes = (string)$object?->notes()->first()?->text;+ $notes = (string) $object?->notes()->first()?->text;return '' !== $notes && !str_starts_with(strtolower($notes), strtolower($value));}@@ -471,7 +471,7 @@ trait AttachmentCollectionforeach ($transaction['attachments'] as $attachment) {/** @var null|Attachment $object */$object = auth()->user()->attachments()->find($attachment['id']);- $notes = (string)$object?->notes()->first()?->text;+ $notes = (string) $object?->notes()->first()?->text;return '' !== $notes && str_ends_with(strtolower($notes), strtolower($value));}@@ -495,7 +495,7 @@ trait AttachmentCollectionforeach ($transaction['attachments'] as $attachment) {/** @var null|Attachment $object */$object = auth()->user()->attachments()->find($attachment['id']);- $notes = (string)$object?->notes()->first()?->text;+ $notes = (string) $object?->notes()->first()?->text;return '' !== $notes && str_starts_with(strtolower($notes), strtolower($value));}diff --git a/app/Helpers/Collector/Extensions/MetaCollection.php b/app/Helpers/Collector/Extensions/MetaCollection.phpindex 2c1bc774e0..5c1ad48277 100644--- a/app/Helpers/Collector/Extensions/MetaCollection.php+++ b/app/Helpers/Collector/Extensions/MetaCollection.php@@ -195,7 +195,7 @@ trait MetaCollectionpublic function excludeInternalReference(string $internalReference): GroupCollectorInterface{- $internalReference = (string)json_encode($internalReference);+ $internalReference = (string) json_encode($internalReference);$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));$this->joinMetaDataTables();@@ -216,7 +216,7 @@ trait MetaCollectionpublic function externalIdContains(string $externalId): GroupCollectorInterface{- $externalId = (string)json_encode($externalId);+ $externalId = (string) json_encode($externalId);$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));$this->joinMetaDataTables();@@ -228,7 +228,7 @@ trait MetaCollectionpublic function externalIdDoesNotContain(string $externalId): GroupCollectorInterface{- $externalId = (string)json_encode($externalId);+ $externalId = (string) json_encode($externalId);$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));$this->joinMetaDataTables();@@ -240,7 +240,7 @@ trait MetaCollectionpublic function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface{- $externalId = (string)json_encode($externalId);+ $externalId = (string) json_encode($externalId);$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));$this->joinMetaDataTables();@@ -252,7 +252,7 @@ trait MetaCollectionpublic function externalIdDoesNotStart(string $externalId): GroupCollectorInterface{- $externalId = (string)json_encode($externalId);+ $externalId = (string) json_encode($externalId);$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));$this->joinMetaDataTables();@@ -264,7 +264,7 @@ trait MetaCollectionpublic function externalIdEnds(string $externalId): GroupCollectorInterface{- $externalId = (string)json_encode($externalId);+ $externalId = (string) json_encode($externalId);$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));$this->joinMetaDataTables();@@ -276,7 +276,7 @@ trait MetaCollectionpublic function externalIdStarts(string $externalId): GroupCollectorInterface{- $externalId = (string)json_encode($externalId);+ $externalId = (string) json_encode($externalId);$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));$this->joinMetaDataTables();@@ -289,7 +289,7 @@ trait MetaCollectionpublic function externalUrlContains(string $url): GroupCollectorInterface{$this->joinMetaDataTables();- $url = (string)json_encode($url);+ $url = (string) json_encode($url);$url = str_replace('\\', '\\\\', trim($url, '"'));$this->query->where('journal_meta.name', '=', 'external_url');$this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $url));@@ -300,7 +300,7 @@ trait MetaCollectionpublic function externalUrlDoesNotContain(string $url): GroupCollectorInterface{$this->joinMetaDataTables();- $url = (string)json_encode($url);+ $url = (string) json_encode($url);$url = str_replace('\\', '\\\\', trim($url, '"'));$this->query->where('journal_meta.name', '=', 'external_url');$this->query->whereNotLike('journal_meta.data', sprintf('%%%s%%', $url));@@ -311,7 +311,7 @@ trait MetaCollectionpublic function externalUrlDoesNotEnd(string $url): GroupCollectorInterface{$this->joinMetaDataTables();- $url = (string)json_encode($url);+ $url = (string) json_encode($url);$url = str_replace('\\', '\\\\', ltrim($url, '"'));$this->query->where('journal_meta.name', '=', 'external_url');$this->query->whereNotLike('journal_meta.data', sprintf('%%%s', $url));@@ -322,7 +322,7 @@ trait MetaCollectionpublic function externalUrlDoesNotStart(string $url): GroupCollectorInterface{$this->joinMetaDataTables();- $url = (string)json_encode($url);+ $url = (string) json_encode($url);$url = str_replace('\\', '\\\\', rtrim($url, '"'));// var_dump($url);@@ -335,7 +335,7 @@ trait MetaCollectionpublic function externalUrlEnds(string $url): GroupCollectorInterface{$this->joinMetaDataTables();- $url = (string)json_encode($url);+ $url = (string) json_encode($url);$url = str_replace('\\', '\\\\', ltrim($url, '"'));$this->query->where('journal_meta.name', '=', 'external_url');$this->query->whereLike('journal_meta.data', sprintf('%%%s', $url));@@ -346,7 +346,7 @@ trait MetaCollectionpublic function externalUrlStarts(string $url): GroupCollectorInterface{$this->joinMetaDataTables();- $url = (string)json_encode($url);+ $url = (string) json_encode($url);$url = str_replace('\\', '\\\\', rtrim($url, '"'));// var_dump($url);@@ -397,7 +397,7 @@ trait MetaCollectionpublic function internalReferenceContains(string $internalReference): GroupCollectorInterface{- $internalReference = (string)json_encode($internalReference);+ $internalReference = (string) json_encode($internalReference);$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));// var_dump($internalReference);// exit;@@ -411,7 +411,7 @@ trait MetaCollectionpublic function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface{- $internalReference = (string)json_encode($internalReference);+ $internalReference = (string) json_encode($internalReference);$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));$this->joinMetaDataTables();@@ -423,7 +423,7 @@ trait MetaCollectionpublic function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface{- $internalReference = (string)json_encode($internalReference);+ $internalReference = (string) json_encode($internalReference);$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));$this->joinMetaDataTables();@@ -435,7 +435,7 @@ trait MetaCollectionpublic function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface{- $internalReference = (string)json_encode($internalReference);+ $internalReference = (string) json_encode($internalReference);$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));$this->joinMetaDataTables();@@ -447,7 +447,7 @@ trait MetaCollectionpublic function internalReferenceEnds(string $internalReference): GroupCollectorInterface{- $internalReference = (string)json_encode($internalReference);+ $internalReference = (string) json_encode($internalReference);$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));$this->joinMetaDataTables();@@ -459,7 +459,7 @@ trait MetaCollectionpublic function internalReferenceStarts(string $internalReference): GroupCollectorInterface{- $internalReference = (string)json_encode($internalReference);+ $internalReference = (string) json_encode($internalReference);$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));$this->joinMetaDataTables();@@ -712,7 +712,7 @@ trait MetaCollectionpublic function setInternalReference(string $internalReference): GroupCollectorInterface{- $internalReference = (string)json_encode($internalReference);+ $internalReference = (string) json_encode($internalReference);$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));$this->joinMetaDataTables();diff --git a/app/Helpers/Collector/Extensions/TimeCollection.php b/app/Helpers/Collector/Extensions/TimeCollection.phpindex c596cfdb77..bb19eb13ae 100644--- a/app/Helpers/Collector/Extensions/TimeCollection.php+++ b/app/Helpers/Collector/Extensions/TimeCollection.php@@ -125,7 +125,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return $transaction[$field]->day >= (int)$day;+ return $transaction[$field]->day >= (int) $day;}}@@ -143,7 +143,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return $transaction[$field]->day <= (int)$day;+ return $transaction[$field]->day <= (int) $day;}}@@ -161,7 +161,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return (int)$day === $transaction[$field]->day;+ return (int) $day === $transaction[$field]->day;}}@@ -179,7 +179,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return (int)$day !== $transaction[$field]->day;+ return (int) $day !== $transaction[$field]->day;}}@@ -197,7 +197,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return $transaction[$field]->month >= (int)$month;+ return $transaction[$field]->month >= (int) $month;}}@@ -215,7 +215,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return $transaction[$field]->month <= (int)$month;+ return $transaction[$field]->month <= (int) $month;}}@@ -233,7 +233,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return (int)$month === $transaction[$field]->month;+ return (int) $month === $transaction[$field]->month;}}@@ -251,7 +251,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return (int)$month !== $transaction[$field]->month;+ return (int) $month !== $transaction[$field]->month;}}@@ -269,7 +269,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return $transaction[$field]->year >= (int)$year;+ return $transaction[$field]->year >= (int) $year;}}@@ -287,7 +287,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return $transaction[$field]->year <= (int)$year;+ return $transaction[$field]->year <= (int) $year;}}@@ -305,7 +305,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return $year === (string)$transaction[$field]->year;+ return $year === (string) $transaction[$field]->year;}}@@ -323,7 +323,7 @@ trait TimeCollectionforeach ($object['transactions'] as $transaction) {if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {- return $year !== (string)$transaction[$field]->year;+ return $year !== (string) $transaction[$field]->year;}}diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.phpindex ce9e16742c..40bb47c704 100644--- a/app/Helpers/Collector/GroupCollector.php+++ b/app/Helpers/Collector/GroupCollector.php@@ -292,7 +292,7 @@ class GroupCollector implements GroupCollectorInterfaceforeach ($params as $param) {$replace = sprintf('"%s"', $param);if (is_int($param)) {- $replace = (string)$param;+ $replace = (string) $param;}$pos = strpos($query, '?');if (false !== $pos) {@@ -503,13 +503,13 @@ class GroupCollector implements GroupCollectorInterface/** @var TransactionJournal $augumentedJournal */foreach ($collection as $augumentedJournal) {- $groupId = (int)$augumentedJournal->transaction_group_id;+ $groupId = (int) $augumentedJournal->transaction_group_id;if (!array_key_exists($groupId, $groups)) {// make new array$parsedGroup = $this->parseAugmentedJournal($augumentedJournal);$groupArray = [- 'id' => (int)$augumentedJournal->transaction_group_id,+ 'id' => (int) $augumentedJournal->transaction_group_id,'user_id' => $augumentedJournal->user_id,'user_group_id' => $augumentedJournal->user_group_id,// Field transaction_group_title was added by the query.@@ -522,7 +522,7 @@ class GroupCollector implements GroupCollectorInterface'transactions' => [],];// Field transaction_journal_id was added by the query.- $journalId = (int)$augumentedJournal->transaction_journal_id; // @phpstan-ignore-line+ $journalId = (int) $augumentedJournal->transaction_journal_id; // @phpstan-ignore-line$groupArray['transactions'][$journalId] = $parsedGroup;$groups[$groupId] = $groupArray;@@ -530,7 +530,7 @@ class GroupCollector implements GroupCollectorInterface}// or parse the rest.// Field transaction_journal_id was added by the query.- $journalId = (int)$augumentedJournal->transaction_journal_id; // @phpstan-ignore-line+ $journalId = (int) $augumentedJournal->transaction_journal_id; // @phpstan-ignore-lineif (array_key_exists($journalId, $groups[$groupId]['transactions'])) {// append data to existing group + journal (for multiple tags or multiple attachments)$groups[$groupId]['transactions'][$journalId] = $this->mergeTags($groups[$groupId]['transactions'][$journalId], $augumentedJournal);@@ -583,7 +583,7 @@ class GroupCollector implements GroupCollectorInterface$dates = ['interest_date', 'payment_date', 'invoice_date', 'book_date', 'due_date', 'process_date'];if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) {$name = $result['meta_name'];- if (array_key_exists('meta_data', $result) && '' !== (string)$result['meta_data']) {+ if (array_key_exists('meta_data', $result) && '' !== (string) $result['meta_data']) {$result[$name] = Carbon::createFromFormat('!Y-m-d', substr(json_decode($result['meta_data']), 0, 10));}}@@ -594,9 +594,9 @@ class GroupCollector implements GroupCollectorInterface// convert back to strings because SQLite is dumb like that.$result = $this->convertToStrings($result);- $result['reconciled'] = 1 === (int)$result['reconciled'];+ $result['reconciled'] = 1 === (int) $result['reconciled'];if (array_key_exists('tag_id', $result) && null !== $result['tag_id']) { // assume the other fields are present as well.- $tagId = (int)$augumentedJournal['tag_id'];+ $tagId = (int) $augumentedJournal['tag_id'];$tagDate = null;try {@@ -606,7 +606,7 @@ class GroupCollector implements GroupCollectorInterface}$result['tags'][$tagId] = [- 'id' => (int)$result['tag_id'],+ 'id' => (int) $result['tag_id'],'name' => $result['tag_name'],'date' => $tagDate,'description' => $result['tag_description'],@@ -615,8 +615,8 @@ class GroupCollector implements GroupCollectorInterface// also merge attachments:if (array_key_exists('attachment_id', $result)) {- $uploaded = 1 === (int)$result['attachment_uploaded'];- $attachmentId = (int)$augumentedJournal['attachment_id'];+ $uploaded = 1 === (int) $result['attachment_uploaded'];+ $attachmentId = (int) $augumentedJournal['attachment_id'];if (0 !== $attachmentId && $uploaded) {$result['attachments'][$attachmentId] = ['id' => $attachmentId,@@ -642,7 +642,7 @@ class GroupCollector implements GroupCollectorInterfaceprivate function convertToInteger(array $array): array{foreach ($this->integerFields as $field) {- $array[$field] = array_key_exists($field, $array) ? (int)$array[$field] : null;+ $array[$field] = array_key_exists($field, $array) ? (int) $array[$field] : null;}return $array;@@ -651,7 +651,7 @@ class GroupCollector implements GroupCollectorInterfaceprivate function convertToStrings(array $array): array{foreach ($this->stringFields as $field) {- $array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (string)$array[$field] : null;+ $array[$field] = array_key_exists($field, $array) && null !== $array[$field] ? (string) $array[$field] : null;}return $array;@@ -661,7 +661,7 @@ class GroupCollector implements GroupCollectorInterface{$newArray = $newJournal->toArray();if (array_key_exists('tag_id', $newArray)) { // assume the other fields are present as well.- $tagId = (int)$newJournal['tag_id'];+ $tagId = (int) $newJournal['tag_id'];$tagDate = null;@@ -672,7 +672,7 @@ class GroupCollector implements GroupCollectorInterface}$existingJournal['tags'][$tagId] = [- 'id' => (int)$newArray['tag_id'],+ 'id' => (int) $newArray['tag_id'],'name' => $newArray['tag_name'],'date' => $tagDate,'description' => $newArray['tag_description'],@@ -686,7 +686,7 @@ class GroupCollector implements GroupCollectorInterface{$newArray = $newJournal->toArray();if (array_key_exists('attachment_id', $newArray)) {- $attachmentId = (int)$newJournal['attachment_id'];+ $attachmentId = (int) $newJournal['attachment_id'];$existingJournal['attachments'][$attachmentId] = ['id' => $attachmentId,@@ -705,7 +705,7 @@ class GroupCollector implements GroupCollectorInterfaceforeach ($groups as $groudId => $group) {/** @var array $transaction */foreach ($group['transactions'] as $transaction) {- $currencyId = (int)$transaction['currency_id'];+ $currencyId = (int) $transaction['currency_id'];if (null === $transaction['amount']) {throw new FireflyException(sprintf('Amount is NULL for a transaction in group #%d, please investigate.', $groudId));}@@ -721,7 +721,7 @@ class GroupCollector implements GroupCollectorInterface$groups[$groudId]['sums'][$currencyId]['amount'] = bcadd($groups[$groudId]['sums'][$currencyId]['amount'], $transaction['amount']);if (null !== $transaction['foreign_amount'] && null !== $transaction['foreign_currency_id']) {- $currencyId = (int)$transaction['foreign_currency_id'];+ $currencyId = (int) $transaction['foreign_currency_id'];// set default:if (!array_key_exists($currencyId, $groups[$groudId]['sums'])) {diff --git a/app/Helpers/Fiscal/FiscalHelper.php b/app/Helpers/Fiscal/FiscalHelper.phpindex c977bc773b..13c9d14bdc 100644--- a/app/Helpers/Fiscal/FiscalHelper.php+++ b/app/Helpers/Fiscal/FiscalHelper.php@@ -38,7 +38,7 @@ class FiscalHelper implements FiscalHelperInterface*/public function __construct(){- $this->useCustomFiscalYear = (bool)app('preferences')->get('customFiscalYear', false)->data;+ $this->useCustomFiscalYear = (bool) app('preferences')->get('customFiscalYear', false)->data;}/**@@ -73,9 +73,9 @@ class FiscalHelper implements FiscalHelperInterfaceif (is_array($prefStartStr)) {$prefStartStr = '01-01';}- $prefStartStr = (string)$prefStartStr;+ $prefStartStr = (string) $prefStartStr;[$mth, $day] = explode('-', $prefStartStr);- $startDate->day((int)$day)->month((int)$mth);+ $startDate->day((int) $day)->month((int) $mth);// if start date is after passed date, sub 1 year.if ($startDate > $date) {diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.phpindex 8e971216a1..c9b52c099a 100644--- a/app/Helpers/Report/NetWorth.php+++ b/app/Helpers/Report/NetWorth.php@@ -122,12 +122,12 @@ class NetWorth implements NetWorthInterface$netWorth[$currencyCode] ??= ['balance' => '0','native_balance' => '0',- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_code' => $currency->code,'currency_name' => $currency->name,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,- 'native_currency_id' => (string)$default->id,+ 'native_currency_id' => (string) $default->id,'native_currency_code' => $default->code,'native_currency_name' => $default->name,'native_currency_symbol' => $default->symbol,@@ -199,7 +199,7 @@ class NetWorth implements NetWorthInterface}$return[$currency->id] ??= [- 'id' => (string)$currency->id,+ 'id' => (string) $currency->id,'name' => $currency->name,'symbol' => $currency->symbol,'code' => $currency->code,@@ -221,7 +221,7 @@ class NetWorth implements NetWorthInterface/** @var Account $account */foreach ($accounts as $account) {- if (1 === (int)$this->getRepository()->getMetaValue($account, 'include_net_worth')) {+ if (1 === (int) $this->getRepository()->getMetaValue($account, 'include_net_worth')) {$filtered->push($account);}}diff --git a/app/Helpers/Report/PopupReport.php b/app/Helpers/Report/PopupReport.phpindex 9860751cfd..b3c027b098 100644--- a/app/Helpers/Report/PopupReport.php+++ b/app/Helpers/Report/PopupReport.php@@ -66,7 +66,7 @@ class PopupReport implements PopupReportInterfaceif (null !== $currencyId) {/** @var CurrencyRepositoryInterface $repos */$repos = app(CurrencyRepositoryInterface::class);- $currency = $repos->find((int)$currencyId);+ $currency = $repos->find((int) $currencyId);}/** @var GroupCollectorInterface $collector */@@ -98,7 +98,7 @@ class PopupReport implements PopupReportInterfaceif (null !== $currencyId) {/** @var CurrencyRepositoryInterface $repos */$repos = app(CurrencyRepositoryInterface::class);- $currency = $repos->find((int)$currencyId);+ $currency = $repos->find((int) $currencyId);}/** @var GroupCollectorInterface $collector */@@ -135,7 +135,7 @@ class PopupReport implements PopupReportInterfaceif (null !== $currencyId) {/** @var CurrencyRepositoryInterface $repos */$repos = app(CurrencyRepositoryInterface::class);- $currency = $repos->find((int)$currencyId);+ $currency = $repos->find((int) $currencyId);}/** @var GroupCollectorInterface $collector */@@ -174,7 +174,7 @@ class PopupReport implements PopupReportInterfaceif (null !== $currencyId) {/** @var CurrencyRepositoryInterface $repos */$repos = app(CurrencyRepositoryInterface::class);- $currency = $repos->find((int)$currencyId);+ $currency = $repos->find((int) $currencyId);}/** @var JournalRepositoryInterface $repository */diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.phpindex 9582c7287d..3fce549ae0 100644--- a/app/Helpers/Report/ReportHelper.php+++ b/app/Helpers/Report/ReportHelper.php@@ -128,7 +128,7 @@ class ReportHelper implements ReportHelperInterface$currentEnd = clone $start;$currentEnd->endOfMonth();$months[$year]['months'][] = [- 'formatted' => $start->isoFormat((string)trans('config.month_js')),+ 'formatted' => $start->isoFormat((string) trans('config.month_js')),'start' => $start->format('Y-m-d'),'end' => $currentEnd->format('Y-m-d'),'month' => $start->month,diff --git a/app/Helpers/Update/UpdateTrait.php b/app/Helpers/Update/UpdateTrait.phpindex e274ccfac7..8a779cdfc2 100644--- a/app/Helpers/Update/UpdateTrait.php+++ b/app/Helpers/Update/UpdateTrait.php@@ -43,7 +43,7 @@ trait UpdateTrait/** @var UpdateRequestInterface $checker */$checker = app(UpdateRequestInterface::class);$channelConfig = app('fireflyconfig')->get('update_channel', 'stable');- $channel = (string)$channelConfig->data;+ $channel = (string) $channelConfig->data;return $checker->getUpdateInformation($channel);}diff --git a/app/Http/Controllers/Account/CreateController.php b/app/Http/Controllers/Account/CreateController.phpindex be7d8fafc0..be9260c369 100644--- a/app/Http/Controllers/Account/CreateController.php+++ b/app/Http/Controllers/Account/CreateController.php@@ -59,7 +59,7 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-credit-card');- app('view')->share('title', (string)trans('firefly.accounts'));+ app('view')->share('title', (string) trans('firefly.accounts'));$this->repository = app(AccountRepositoryInterface::class);$this->attachments = app(AttachmentHelperInterface::class);@@ -78,7 +78,7 @@ class CreateController extends Controller{$defaultCurrency = app('amount')->getDefaultCurrency();$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));- $subTitle = (string)trans(sprintf('firefly.make_new_%s_account', $objectType));+ $subTitle = (string) trans(sprintf('firefly.make_new_%s_account', $objectType));$roles = $this->getRoles();$liabilityTypes = $this->getLiabilityTypes();$hasOldInput = null !== $request->old('_token');@@ -97,9 +97,9 @@ class CreateController extends Controller// interest calculation periods:$interestPeriods = [- 'daily' => (string)trans('firefly.interest_calc_daily'),- 'monthly' => (string)trans('firefly.interest_calc_monthly'),- 'yearly' => (string)trans('firefly.interest_calc_yearly'),+ 'daily' => (string) trans('firefly.interest_calc_daily'),+ 'monthly' => (string) trans('firefly.interest_calc_monthly'),+ 'yearly' => (string) trans('firefly.interest_calc_yearly'),];// pre fill some data@@ -107,7 +107,7 @@ class CreateController extends Controller'preFilled',['currency_id' => $defaultCurrency->id,- 'include_net_worth' => $hasOldInput ? (bool)$request->old('include_net_worth') : true,+ 'include_net_worth' => $hasOldInput ? (bool) $request->old('include_net_worth') : true,]);// issue #8321@@ -140,7 +140,7 @@ class CreateController extends Controller{$data = $request->getAccountData();$account = $this->repository->store($data);- $request->session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));+ $request->session()->flash('success', (string) trans('firefly.stored_new_account', ['name' => $account->name]));app('preferences')->mark();Log::channel('audit')->info('Stored new account.', $data);@@ -163,7 +163,7 @@ class CreateController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {@@ -172,7 +172,7 @@ class CreateController extends Controller// redirect to previous URL.$redirect = redirect($this->getPreviousUrl('accounts.create.url'));- if (1 === (int)$request->get('create_another')) {+ if (1 === (int) $request->get('create_another')) {// set value so create routine will not overwrite URL:$request->session()->put('accounts.create.fromStore', true);diff --git a/app/Http/Controllers/Account/DeleteController.php b/app/Http/Controllers/Account/DeleteController.phpindex 24f1cb4375..0763718cd1 100644--- a/app/Http/Controllers/Account/DeleteController.php+++ b/app/Http/Controllers/Account/DeleteController.php@@ -52,7 +52,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-credit-card');- app('view')->share('title', (string)trans('firefly.accounts'));+ app('view')->share('title', (string) trans('firefly.accounts'));$this->repository = app(AccountRepositoryInterface::class);@@ -73,7 +73,7 @@ class DeleteController extends Controller}$typeName = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));- $subTitle = (string)trans(sprintf('firefly.delete_%s_account', $typeName), ['name' => $account->name]);+ $subTitle = (string) trans(sprintf('firefly.delete_%s_account', $typeName), ['name' => $account->name]);$accountList = app('expandedform')->makeSelectListWithEmpty($this->repository->getAccountsByType([$account->accountType->type]));$objectType = $typeName;unset($accountList[$account->id]);@@ -98,11 +98,11 @@ class DeleteController extends Controller$type = $account->accountType->type;$typeName = config(sprintf('firefly.shortNamesByFullName.%s', $type));$name = $account->name;- $moveTo = $this->repository->find((int)$request->get('move_account_before_delete'));+ $moveTo = $this->repository->find((int) $request->get('move_account_before_delete'));$this->repository->destroy($account, $moveTo);- $request->session()->flash('success', (string)trans(sprintf('firefly.%s_deleted', $typeName), ['name' => $name]));+ $request->session()->flash('success', (string) trans(sprintf('firefly.%s_deleted', $typeName), ['name' => $name]));app('preferences')->mark();return redirect($this->getPreviousUrl('accounts.delete.url'));diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.phpindex e379db4e88..93a1603582 100644--- a/app/Http/Controllers/Account/EditController.php+++ b/app/Http/Controllers/Account/EditController.php@@ -58,7 +58,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-credit-card');- app('view')->share('title', (string)trans('firefly.accounts'));+ app('view')->share('title', (string) trans('firefly.accounts'));$this->repository = app(AccountRepositoryInterface::class);$this->attachments = app(AttachmentHelperInterface::class);@@ -82,7 +82,7 @@ class EditController extends Controller}$objectType = config('firefly.shortNamesByFullName')[$account->accountType->type];- $subTitle = (string)trans(sprintf('firefly.edit_%s_account', $objectType), ['name' => $account->name]);+ $subTitle = (string) trans(sprintf('firefly.edit_%s_account', $objectType), ['name' => $account->name]);$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));$roles = $this->getRoles();$liabilityTypes = $this->getLiabilityTypes();@@ -107,9 +107,9 @@ class EditController extends Controller// interest calculation periods:$interestPeriods = [- 'daily' => (string)trans('firefly.interest_calc_daily'),- 'monthly' => (string)trans('firefly.interest_calc_monthly'),- 'yearly' => (string)trans('firefly.interest_calc_yearly'),+ 'daily' => (string) trans('firefly.interest_calc_daily'),+ 'monthly' => (string) trans('firefly.interest_calc_monthly'),+ 'yearly' => (string) trans('firefly.interest_calc_yearly'),];// put previous url in session if not redirect from store (not "return_to_edit").@@ -118,7 +118,7 @@ class EditController extends Controller}$request->session()->forget('accounts.edit.fromUpdate');- $openingBalanceAmount = (string)$repository->getOpeningBalanceAmount($account);+ $openingBalanceAmount = (string) $repository->getOpeningBalanceAmount($account);if ('0' === $openingBalanceAmount) {$openingBalanceAmount = '';}@@ -144,17 +144,17 @@ class EditController extends Controller'cc_type' => $repository->getMetaValue($account, 'cc_type'),'cc_monthly_payment_date' => $repository->getMetaValue($account, 'cc_monthly_payment_date'),'BIC' => $repository->getMetaValue($account, 'BIC'),- 'opening_balance_date' => substr((string)$openingBalanceDate, 0, 10),+ 'opening_balance_date' => substr((string) $openingBalanceDate, 0, 10),'liability_type_id' => $account->account_type_id,'opening_balance' => app('steam')->bcround($openingBalanceAmount, $currency->decimal_places),'liability_direction' => $this->repository->getMetaValue($account, 'liability_direction'),'virtual_balance' => app('steam')->bcround($virtualBalance, $currency->decimal_places),'currency_id' => $currency->id,- 'include_net_worth' => $hasOldInput ? (bool)$request->old('include_net_worth') : $includeNetWorth,+ 'include_net_worth' => $hasOldInput ? (bool) $request->old('include_net_worth') : $includeNetWorth,'interest' => $repository->getMetaValue($account, 'interest'),'interest_period' => $repository->getMetaValue($account, 'interest_period'),'notes' => $this->repository->getNoteText($account),- 'active' => $hasOldInput ? (bool)$request->old('active') : $account->active,+ 'active' => $hasOldInput ? (bool) $request->old('active') : $account->active,];if ('' === $openingBalanceAmount) {$preFilled['opening_balance'] = '';@@ -179,7 +179,7 @@ class EditController extends Controller$data = $request->getAccountData();$this->repository->update($account, $data);Log::channel('audit')->info(sprintf('Updated account #%d.', $account->id), $data);- $request->session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));+ $request->session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));// store new attachment(s):/** @var null|array $files */@@ -189,7 +189,7 @@ class EditController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {@@ -198,7 +198,7 @@ class EditController extends Controller// redirect$redirect = redirect($this->getPreviousUrl('accounts.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {// set value so edit routine will not overwrite URL:$request->session()->put('accounts.edit.fromUpdate', true);diff --git a/app/Http/Controllers/Account/IndexController.php b/app/Http/Controllers/Account/IndexController.phpindex 870999de13..3dcd49aced 100644--- a/app/Http/Controllers/Account/IndexController.php+++ b/app/Http/Controllers/Account/IndexController.php@@ -54,7 +54,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-credit-card');- app('view')->share('title', (string)trans('firefly.accounts'));+ app('view')->share('title', (string) trans('firefly.accounts'));$this->repository = app(AccountRepositoryInterface::class);@@ -71,13 +71,13 @@ class IndexController extends Controllerpublic function inactive(Request $request, string $objectType){$inactivePage = true;- $subTitle = (string)trans(sprintf('firefly.%s_accounts_inactive', $objectType));+ $subTitle = (string) trans(sprintf('firefly.%s_accounts_inactive', $objectType));$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));$types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType));$collection = $this->repository->getInactiveAccountsByType($types);$total = $collection->count();- $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);unset($collection);@@ -100,10 +100,10 @@ class IndexController extends Controller$account->endBalance = $this->isInArray($endBalances, $account->id);$account->difference = bcsub($account->endBalance, $account->startBalance);$account->interest = app('steam')->bcround($this->repository->getMetaValue($account, 'interest'), 4);- $account->interestPeriod = (string)trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));- $account->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type));+ $account->interestPeriod = (string) trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));+ $account->accountTypeString = (string) trans(sprintf('firefly.account_type_%s', $account->accountType->type));$account->current_debt = '0';- $account->iban = implode(' ', str_split((string)$account->iban, 4));+ $account->iban = implode(' ', str_split((string) $account->iban, 4));});@@ -124,7 +124,7 @@ class IndexController extends Controllerpublic function index(Request $request, string $objectType){app('log')->debug(sprintf('Now at %s', __METHOD__));- $subTitle = (string)trans(sprintf('firefly.%s_accounts', $objectType));+ $subTitle = (string) trans(sprintf('firefly.%s_accounts', $objectType));$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $objectType));$types = config(sprintf('firefly.accountTypesByIdentifier.%s', $objectType));@@ -132,8 +132,8 @@ class IndexController extends Controller$collection = $this->repository->getActiveAccountsByType($types);$total = $collection->count();- $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$accounts = $collection->slice(($page - 1) * $pageSize, $pageSize);$inactiveCount = $this->repository->getInactiveAccountsByType($types)->count();@@ -155,7 +155,7 @@ class IndexController extends Controller$accounts->each(function (Account $account) use ($activities, $startBalances, $endBalances): void {- $interest = (string)$this->repository->getMetaValue($account, 'interest');+ $interest = (string) $this->repository->getMetaValue($account, 'interest');$interest = '' === $interest ? '0' : $interest;// See reference nr. 68@@ -164,14 +164,14 @@ class IndexController extends Controller$account->endBalance = $this->isInArray($endBalances, $account->id);$account->difference = bcsub($account->endBalance, $account->startBalance);$account->interest = app('steam')->bcround($interest, 4);- $account->interestPeriod = (string)trans(+ $account->interestPeriod = (string) trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));- $account->accountTypeString = (string)trans(sprintf('firefly.account_type_%s', $account->accountType->type));+ $account->accountTypeString = (string) trans(sprintf('firefly.account_type_%s', $account->accountType->type));$account->location = $this->repository->getLocation($account);$account->liability_direction = $this->repository->getMetaValue($account, 'liability_direction');$account->current_debt = $this->repository->getMetaValue($account, 'current_debt') ?? '-';- $account->iban = implode(' ', str_split((string)$account->iban, 4));+ $account->iban = implode(' ', str_split((string) $account->iban, 4));});// make paginator:diff --git a/app/Http/Controllers/Account/ReconcileController.php b/app/Http/Controllers/Account/ReconcileController.phpindex a679b69739..7efe4bf057 100644--- a/app/Http/Controllers/Account/ReconcileController.php+++ b/app/Http/Controllers/Account/ReconcileController.php@@ -59,7 +59,7 @@ class ReconcileController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-credit-card');- app('view')->share('title', (string)trans('firefly.accounts'));+ app('view')->share('title', (string) trans('firefly.accounts'));$this->repository = app(JournalRepositoryInterface::class);$this->accountRepos = app(AccountRepositoryInterface::class);@@ -81,7 +81,7 @@ class ReconcileController extends Controllerreturn $this->redirectAccountToAccount($account);}if (AccountType::ASSET !== $account->accountType->type) {- session()->flash('error', (string)trans('firefly.must_be_asset_account'));+ session()->flash('error', (string) trans('firefly.must_be_asset_account'));return redirect(route('accounts.index', [config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type))]));}@@ -113,7 +113,7 @@ class ReconcileController extends Controller$startBalance = app('steam')->bcround(app('steam')->balance($account, $startDate), $currency->decimal_places);$endBalance = app('steam')->bcround(app('steam')->balance($account, $end), $currency->decimal_places);$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));- $subTitle = (string)trans('firefly.reconcile_account', ['account' => $account->name]);+ $subTitle = (string) trans('firefly.reconcile_account', ['account' => $account->name]);// various links$transactionsUrl = route('accounts.reconcile.transactions', [$account->id, '%start%', '%end%']);@@ -158,7 +158,7 @@ class ReconcileController extends Controller/** @var string $journalId */foreach ($data['journals'] as $journalId) {- $this->repository->reconcileById((int)$journalId);+ $this->repository->reconcileById((int) $journalId);}app('log')->debug('Reconciled all transactions.');@@ -175,10 +175,10 @@ class ReconcileController extends Controllerapp('log')->debug('End of routine.');app('preferences')->mark();if ('' === $result) {- session()->flash('success', (string)trans('firefly.reconciliation_stored'));+ session()->flash('success', (string) trans('firefly.reconciliation_stored'));}if ('' !== $result) {- session()->flash('error', (string)trans('firefly.reconciliation_error', ['error' => $result]));+ session()->flash('error', (string) trans('firefly.reconciliation_error', ['error' => $result]));}return redirect(route('accounts.show', [$account->id]));diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.phpindex b4d7b7cc7d..db17a8fec7 100644--- a/app/Http/Controllers/Account/ShowController.php+++ b/app/Http/Controllers/Account/ShowController.php@@ -60,7 +60,7 @@ class ShowController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-credit-card');- app('view')->share('title', (string)trans('firefly.accounts'));+ app('view')->share('title', (string) trans('firefly.accounts'));$this->repository = app(AccountRepositoryInterface::class);@@ -96,19 +96,19 @@ class ShowController extends Controller$attachments = $this->repository->getAttachments($account);$today = today(config('app.timezone'));$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();$fStart = $start->isoFormat($this->monthAndDayFormat);$fEnd = $end->isoFormat($this->monthAndDayFormat);- $subTitle = (string)trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]);+ $subTitle = (string) trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]);$chartUrl = route('chart.account.period', [$account->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);$firstTransaction = $this->repository->oldestJournalDate($account) ?? $start;$periods = $this->getAccountPeriodOverview($account, $firstTransaction, $end);// if layout = v2, overrule the page title.if ('v1' !== config('view.layout')) {- $subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]);+ $subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]);}/** @var GroupCollectorInterface $collector */@@ -172,10 +172,10 @@ class ShowController extends Controller$today = today(config('app.timezone'));$start = $this->repository->oldestJournalDate($account) ?? today(config('app.timezone'))->startOfMonth();$subTitleIcon = config('firefly.subIconsByIdentifier.'.$account->accountType->type);- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$currency = $this->repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrency();- $subTitle = (string)trans('firefly.all_journals_for_account', ['name' => $account->name]);+ $subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]);$periods = new Collection();/** @var GroupCollectorInterface $collector */diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.phpindex 25e810aeab..f5058a1165 100644--- a/app/Http/Controllers/Admin/ConfigurationController.php+++ b/app/Http/Controllers/Admin/ConfigurationController.php@@ -45,7 +45,7 @@ class ConfigurationController extends Controller$this->middleware(static function ($request, $next) {- app('view')->share('title', (string)trans('firefly.administration'));+ app('view')->share('title', (string) trans('firefly.administration'));app('view')->share('mainTitleIcon', 'fa-hand-spock-o');return $next($request);@@ -61,7 +61,7 @@ class ConfigurationController extends Controller*/public function index(){- $subTitle = (string)trans('firefly.instance_configuration');+ $subTitle = (string) trans('firefly.instance_configuration');$subTitleIcon = 'fa-wrench';Log::channel('audit')->info('User visits admin config index.');@@ -93,7 +93,7 @@ class ConfigurationController extends Controllerapp('fireflyconfig')->set('is_demo_site', $data['is_demo_site']);// flash message- session()->flash('success', (string)trans('firefly.configuration_updated'));+ session()->flash('success', (string) trans('firefly.configuration_updated'));app('preferences')->mark();return redirect()->route('admin.configuration.index');diff --git a/app/Http/Controllers/Admin/HomeController.php b/app/Http/Controllers/Admin/HomeController.phpindex ce6ab09cbb..6bfe4159cf 100644--- a/app/Http/Controllers/Admin/HomeController.php+++ b/app/Http/Controllers/Admin/HomeController.php@@ -51,7 +51,7 @@ class HomeController extends Controllerpublic function index(){Log::channel('audit')->info('User visits admin index.');- $title = (string)trans('firefly.administration');+ $title = (string) trans('firefly.administration');$mainTitleIcon = 'fa-hand-spock-o';$email = auth()->user()->email;$pref = app('preferences')->get('remote_guard_alt_email');diff --git a/app/Http/Controllers/Admin/LinkController.php b/app/Http/Controllers/Admin/LinkController.phpindex a2ccd109d8..92dc5ccd53 100644--- a/app/Http/Controllers/Admin/LinkController.php+++ b/app/Http/Controllers/Admin/LinkController.php@@ -51,7 +51,7 @@ class LinkController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.administration'));+ app('view')->share('title', (string) trans('firefly.administration'));app('view')->share('mainTitleIcon', 'fa-hand-spock-o');$this->repository = app(LinkTypeRepositoryInterface::class);@@ -70,7 +70,7 @@ class LinkController extends Controller{Log::channel('audit')->info('User visits link index.');- $subTitle = (string)trans('firefly.create_new_link_type');+ $subTitle = (string) trans('firefly.create_new_link_type');$subTitleIcon = 'fa-link';// put previous url in session if not redirect from store (not "create another").@@ -89,17 +89,17 @@ class LinkController extends Controllerpublic function delete(Request $request, LinkType $linkType){if (!$linkType->editable) {- $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));+ $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));return redirect(route('admin.links.index'));}Log::channel('audit')->info(sprintf('User wants to delete link type #%d', $linkType->id));- $subTitle = (string)trans('firefly.delete_link_type', ['name' => $linkType->name]);+ $subTitle = (string) trans('firefly.delete_link_type', ['name' => $linkType->name]);$otherTypes = $this->repository->get();$count = $this->repository->countJournals($linkType);$moveTo = [];- $moveTo[0] = (string)trans('firefly.do_not_save_connection');+ $moveTo[0] = (string) trans('firefly.do_not_save_connection');/** @var LinkType $otherType */foreach ($otherTypes as $otherType) {@@ -123,10 +123,10 @@ class LinkController extends Controller{Log::channel('audit')->info(sprintf('User destroyed link type #%d', $linkType->id));$name = $linkType->name;- $moveTo = $this->repository->find((int)$request->get('move_link_type_before_delete'));+ $moveTo = $this->repository->find((int) $request->get('move_link_type_before_delete'));$this->repository->destroy($linkType, $moveTo);- $request->session()->flash('success', (string)trans('firefly.deleted_link_type', ['name' => $name]));+ $request->session()->flash('success', (string) trans('firefly.deleted_link_type', ['name' => $name]));app('preferences')->mark();return redirect($this->getPreviousUrl('link-types.delete.url'));@@ -140,11 +140,11 @@ class LinkController extends Controllerpublic function edit(Request $request, LinkType $linkType){if (!$linkType->editable) {- $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));+ $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));return redirect(route('admin.links.index'));}- $subTitle = (string)trans('firefly.edit_link_type', ['name' => $linkType->name]);+ $subTitle = (string) trans('firefly.edit_link_type', ['name' => $linkType->name]);$subTitleIcon = 'fa-link';Log::channel('audit')->info(sprintf('User wants to edit link type #%d', $linkType->id));@@ -165,7 +165,7 @@ class LinkController extends Controller*/public function index(){- $subTitle = (string)trans('firefly.journal_link_configuration');+ $subTitle = (string) trans('firefly.journal_link_configuration');$subTitleIcon = 'fa-link';$linkTypes = $this->repository->get();@@ -186,7 +186,7 @@ class LinkController extends Controller*/public function show(LinkType $linkType){- $subTitle = (string)trans('firefly.overview_for_link', ['name' => $linkType->name]);+ $subTitle = (string) trans('firefly.overview_for_link', ['name' => $linkType->name]);$subTitleIcon = 'fa-link';$links = $this->repository->getJournalLinks($linkType);@@ -211,9 +211,9 @@ class LinkController extends ControllerLog::channel('audit')->info('User stored new link type.', $linkType->toArray());- $request->session()->flash('success', (string)trans('firefly.stored_new_link_type', ['name' => $linkType->name]));+ $request->session()->flash('success', (string) trans('firefly.stored_new_link_type', ['name' => $linkType->name]));$redirect = redirect($this->getPreviousUrl('link-types.create.url'));- if (1 === (int)$request->get('create_another')) {+ if (1 === (int) $request->get('create_another')) {// set value so create routine will not overwrite URL:$request->session()->put('link-types.create.fromStore', true);@@ -232,7 +232,7 @@ class LinkController extends Controllerpublic function update(LinkTypeFormRequest $request, LinkType $linkType){if (!$linkType->editable) {- $request->session()->flash('error', (string)trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));+ $request->session()->flash('error', (string) trans('firefly.cannot_edit_link_type', ['name' => e($linkType->name)]));return redirect(route('admin.links.index'));}@@ -246,10 +246,10 @@ class LinkController extends ControllerLog::channel('audit')->info(sprintf('User update link type #%d.', $linkType->id), $data);- $request->session()->flash('success', (string)trans('firefly.updated_link_type', ['name' => $linkType->name]));+ $request->session()->flash('success', (string) trans('firefly.updated_link_type', ['name' => $linkType->name]));app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('link-types.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {// set value so edit routine will not overwrite URL:$request->session()->put('link-types.edit.fromUpdate', true);diff --git a/app/Http/Controllers/Admin/UpdateController.php b/app/Http/Controllers/Admin/UpdateController.phpindex b335ed9d07..4a83da8ad9 100644--- a/app/Http/Controllers/Admin/UpdateController.php+++ b/app/Http/Controllers/Admin/UpdateController.php@@ -47,7 +47,7 @@ class UpdateController extends Controllerparent::__construct();$this->middleware(static function ($request, $next) {- app('view')->share('title', (string)trans('firefly.administration'));+ app('view')->share('title', (string) trans('firefly.administration'));app('view')->share('mainTitleIcon', 'fa-hand-spock-o');return $next($request);@@ -63,22 +63,22 @@ class UpdateController extends Controller*/public function index(){- $subTitle = (string)trans('firefly.update_check_title');+ $subTitle = (string) trans('firefly.update_check_title');$subTitleIcon = 'fa-star';$permission = app('fireflyconfig')->get('permission_update_check', -1);$channel = app('fireflyconfig')->get('update_channel', 'stable');$selected = $permission->data;$channelSelected = $channel->data;$options = [- -1 => (string)trans('firefly.updates_ask_me_later'),- 0 => (string)trans('firefly.updates_do_not_check'),- 1 => (string)trans('firefly.updates_enable_check'),+ -1 => (string) trans('firefly.updates_ask_me_later'),+ 0 => (string) trans('firefly.updates_do_not_check'),+ 1 => (string) trans('firefly.updates_enable_check'),];$channelOptions = [- 'stable' => (string)trans('firefly.update_channel_stable'),- 'beta' => (string)trans('firefly.update_channel_beta'),- 'alpha' => (string)trans('firefly.update_channel_alpha'),+ 'stable' => (string) trans('firefly.update_channel_stable'),+ 'beta' => (string) trans('firefly.update_channel_beta'),+ 'alpha' => (string) trans('firefly.update_channel_alpha'),];return view('admin.update.index', compact('subTitle', 'subTitleIcon', 'selected', 'options', 'channelSelected', 'channelOptions'));@@ -91,14 +91,14 @@ class UpdateController extends Controller*/public function post(Request $request){- $checkForUpdates = (int)$request->get('check_for_updates');+ $checkForUpdates = (int) $request->get('check_for_updates');$channel = $request->get('update_channel');$channel = in_array($channel, ['stable', 'beta', 'alpha'], true) ? $channel : 'stable';app('fireflyconfig')->set('permission_update_check', $checkForUpdates);app('fireflyconfig')->set('last_update_check', time());app('fireflyconfig')->set('update_channel', $channel);- session()->flash('success', (string)trans('firefly.configuration_updated'));+ session()->flash('success', (string) trans('firefly.configuration_updated'));return redirect(route('admin.update-check'));}diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.phpindex 6c060b3bb5..dc8ed34398 100644--- a/app/Http/Controllers/Admin/UserController.php+++ b/app/Http/Controllers/Admin/UserController.php@@ -55,7 +55,7 @@ class UserController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.administration'));+ app('view')->share('title', (string) trans('firefly.administration'));app('view')->share('mainTitleIcon', 'fa-hand-spock-o');$this->repository = app(UserRepositoryInterface::class);@@ -77,7 +77,7 @@ class UserController extends Controllerreturn redirect(route('admin.users'));}- $subTitle = (string)trans('firefly.delete_user', ['email' => $user->email]);+ $subTitle = (string) trans('firefly.delete_user', ['email' => $user->email]);return view('admin.users.delete', compact('user', 'subTitle'));}@@ -111,7 +111,7 @@ class UserController extends Controllerreturn redirect(route('admin.users'));}$this->repository->destroy($user);- session()->flash('success', (string)trans('firefly.user_deleted'));+ session()->flash('success', (string) trans('firefly.user_deleted'));return redirect(route('admin.users'));}@@ -133,15 +133,15 @@ class UserController extends Controller}session()->forget('users.edit.fromUpdate');- $subTitle = (string)trans('firefly.edit_user', ['email' => $user->email]);+ $subTitle = (string) trans('firefly.edit_user', ['email' => $user->email]);$subTitleIcon = 'fa-user-o';$currentUser = auth()->user();$isAdmin = $this->repository->hasRole($user, 'owner');$codes = [- '' => (string)trans('firefly.no_block_code'),- 'bounced' => (string)trans('firefly.block_code_bounced'),- 'expired' => (string)trans('firefly.block_code_expired'),- 'email_changed' => (string)trans('firefly.block_code_email_changed'),+ '' => (string) trans('firefly.no_block_code'),+ 'bounced' => (string) trans('firefly.block_code_bounced'),+ 'expired' => (string) trans('firefly.block_code_expired'),+ 'email_changed' => (string) trans('firefly.block_code_email_changed'),];return view('admin.users.edit', compact('user', 'canEditDetails', 'subTitle', 'subTitleIcon', 'codes', 'currentUser', 'isAdmin'));@@ -154,10 +154,10 @@ class UserController extends Controller*/public function index(){- $subTitle = (string)trans('firefly.user_administration');+ $subTitle = (string) trans('firefly.user_administration');$subTitleIcon = 'fa-users';$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;if (!$this->externalIdentity && $singleUserMode) {// also registration enabled.@@ -179,7 +179,7 @@ class UserController extends Controllerpublic function invite(InviteUserFormRequest $request): RedirectResponse{- $address = (string)$request->get('invited_user');+ $address = (string) $request->get('invited_user');$invitee = $this->repository->inviteUser(auth()->user(), $address);session()->flash('info', trans('firefly.user_is_invited', ['address' => $address]));@@ -196,9 +196,9 @@ class UserController extends Controller*/public function show(User $user){- $title = (string)trans('firefly.administration');+ $title = (string) trans('firefly.administration');$mainTitleIcon = 'fa-hand-spock-o';- $subTitle = (string)trans('firefly.single_user_administration', ['email' => $user->email]);+ $subTitle = (string) trans('firefly.single_user_administration', ['email' => $user->email]);$subTitleIcon = 'fa-user';$information = $this->repository->getUserData($user);@@ -242,10 +242,10 @@ class UserController extends Controller$this->repository->changeStatus($user, $data['blocked'], $data['blocked_code']);$this->repository->updateEmail($user, $data['email']);- session()->flash('success', (string)trans('firefly.updated_user', ['email' => $user->email]));+ session()->flash('success', (string) trans('firefly.updated_user', ['email' => $user->email]));app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('users.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {session()->put('users.edit.fromUpdate', true);$redirect = redirect(route('admin.users.edit', [$user->id]))->withInput(['return_to_edit' => 1]);diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.phpindex 2ae7fa576a..c45b947126 100644--- a/app/Http/Controllers/AttachmentController.php+++ b/app/Http/Controllers/AttachmentController.php@@ -53,7 +53,7 @@ class AttachmentController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-paperclip');- app('view')->share('title', (string)trans('firefly.attachments'));+ app('view')->share('title', (string) trans('firefly.attachments'));$this->repository = app(AttachmentRepositoryInterface::class);return $next($request);@@ -68,7 +68,7 @@ class AttachmentController extends Controller*/public function delete(Attachment $attachment){- $subTitle = (string)trans('firefly.delete_attachment', ['name' => $attachment->filename]);+ $subTitle = (string) trans('firefly.delete_attachment', ['name' => $attachment->filename]);// put previous url in session$this->rememberPreviousUrl('attachments.delete.url');@@ -87,7 +87,7 @@ class AttachmentController extends Controller$this->repository->destroy($attachment);- $request->session()->flash('success', (string)trans('firefly.attachment_deleted', ['name' => $name]));+ $request->session()->flash('success', (string) trans('firefly.attachment_deleted', ['name' => $name]));app('preferences')->mark();return redirect($this->getPreviousUrl('attachments.delete.url'));@@ -117,7 +117,7 @@ class AttachmentController extends Controller->header('Expires', '0')->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')->header('Pragma', 'public')- ->header('Content-Length', (string)strlen($content))+ ->header('Content-Length', (string) strlen($content));return $response;@@ -134,7 +134,7 @@ class AttachmentController extends Controllerpublic function edit(Request $request, Attachment $attachment){$subTitleIcon = 'fa-pencil';- $subTitle = (string)trans('firefly.edit_attachment', ['name' => $attachment->filename]);+ $subTitle = (string) trans('firefly.edit_attachment', ['name' => $attachment->filename]);// put previous url in session if not redirect from store (not "return_to_edit").if (true !== session('attachments.edit.fromUpdate')) {@@ -176,11 +176,11 @@ class AttachmentController extends Controller$data = $request->getAttachmentData();$this->repository->update($attachment, $data);- $request->session()->flash('success', (string)trans('firefly.attachment_updated', ['name' => $attachment->filename]));+ $request->session()->flash('success', (string) trans('firefly.attachment_updated', ['name' => $attachment->filename]));app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('attachments.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {$request->session()->put('attachments.edit.fromUpdate', true);$redirect = redirect(route('attachments.edit', [$attachment->id]))->withInput(['return_to_edit' => 1]);diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.phpindex 3b04ae1f7a..de924f295b 100644--- a/app/Http/Controllers/Auth/ForgotPasswordController.php+++ b/app/Http/Controllers/Auth/ForgotPasswordController.php@@ -79,7 +79,7 @@ class ForgotPasswordController extends Controller$user = User::where('email', $request->get('email'))->first();if (null !== $user && $repository->hasRole($user, 'demo')) {- return back()->withErrors(['email' => (string)trans('firefly.cannot_reset_demo_user')]);+ return back()->withErrors(['email' => (string) trans('firefly.cannot_reset_demo_user')]);}// We will send the password reset link to this user. Once we have attempted@@ -101,7 +101,7 @@ class ForgotPasswordController extends Controller*/private function validateHost(): void{- $configuredHost = parse_url((string)config('app.url'), PHP_URL_HOST);+ $configuredHost = parse_url((string) config('app.url'), PHP_URL_HOST);if (false === $configuredHost || null === $configuredHost) {throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.');}@@ -132,7 +132,7 @@ class ForgotPasswordController extends Controller$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;$userCount = User::count();$allowRegistration = true;- $pageTitle = (string)trans('firefly.forgot_pw_page_title');+ $pageTitle = (string) trans('firefly.forgot_pw_page_title');if (true === $singleUserMode && $userCount > 0) {$allowRegistration = false;}diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.phpindex 51f8443cd4..6496591e6b 100644--- a/app/Http/Controllers/Auth/LoginController.php+++ b/app/Http/Controllers/Auth/LoginController.php@@ -59,7 +59,7 @@ class LoginController extends Controller/*** Where to redirect users after login.*/- protected string $redirectTo = RouteServiceProvider::HOME;+ protected string $redirectTo = RouteServiceProvider::HOME;private UserRepositoryInterface $repository;private string $username;@@ -225,7 +225,7 @@ class LoginController extends Controller$count = \DB::table('users')->count();$guard = config('auth.defaults.guard');- $title = (string)trans('firefly.login_page_title');+ $title = (string) trans('firefly.login_page_title');if (0 === $count && 'web' === $guard) {return redirect(route('register'));diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.phpindex ba75435e18..effbd4f322 100644--- a/app/Http/Controllers/Auth/RegisterController.php+++ b/app/Http/Controllers/Auth/RegisterController.php@@ -84,7 +84,7 @@ class RegisterController extends Controllerpublic function register(Request $request){$allowRegistration = $this->allowedToRegister();- $inviteCode = (string)$request->get('invite_code');+ $inviteCode = (string) $request->get('invite_code');$repository = app(UserRepositoryInterface::class);$validCode = $repository->validateInviteCode($inviteCode);@@ -100,7 +100,7 @@ class RegisterController extends Controller$this->guard()->login($user);- session()->flash('success', (string)trans('firefly.registered'));+ session()->flash('success', (string) trans('firefly.registered'));$this->registered($request, $user);@@ -146,7 +146,7 @@ class RegisterController extends Controllerpublic function showInviteForm(Request $request, string $code){$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;- $pageTitle = (string)trans('firefly.register_page_title');+ $pageTitle = (string) trans('firefly.register_page_title');$repository = app(UserRepositoryInterface::class);$allowRegistration = $this->allowedToRegister();$inviteCode = $code;@@ -178,7 +178,7 @@ class RegisterController extends Controllerpublic function showRegistrationForm(Request $request){$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;- $pageTitle = (string)trans('firefly.register_page_title');+ $pageTitle = (string) trans('firefly.register_page_title');$allowRegistration = $this->allowedToRegister();if (false === $allowRegistration) {diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.phpindex 09982b2063..442d4956b4 100644--- a/app/Http/Controllers/Auth/ResetPasswordController.php+++ b/app/Http/Controllers/Auth/ResetPasswordController.php@@ -130,7 +130,7 @@ class ResetPasswordController extends Controller$singleUserMode = app('fireflyconfig')->get('single_user_mode', config('firefly.configuration.single_user_mode'))->data;$userCount = User::count();$allowRegistration = true;- $pageTitle = (string)trans('firefly.reset_pw_page_title');+ $pageTitle = (string) trans('firefly.reset_pw_page_title');if (true === $singleUserMode && $userCount > 0) {$allowRegistration = false;}diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.phpindex d868d2823f..b1e7e053a2 100644--- a/app/Http/Controllers/Auth/TwoFactorController.php+++ b/app/Http/Controllers/Auth/TwoFactorController.php@@ -163,6 +163,22 @@ class TwoFactorController extends Controllerapp('preferences')->set('mfa_history', $newHistory);}+ private function addToMFAFailureCounter(): void+ {+ $preference = (int) app('preferences')->get('mfa_failure_count', 0)->data;+ ++$preference;+ Log::channel('audit')->info(sprintf('MFA failure count is set to %d.', $preference));+ app('preferences')->set('mfa_failure_count', $preference);+ }++ private function getMFAFailureCounter(): int+ {+ $value = (int) app('preferences')->get('mfa_failure_count', 0)->data;+ Log::channel('audit')->info(sprintf('MFA failure count is %d.', $value));++ return $value;+ }+private function addToMFAHistory(string $mfaCode): void{/** @var array $mfaHistory */@@ -177,6 +193,12 @@ class TwoFactorController extends Controller$this->filterMFAHistory();}+ private function resetMFAFailureCounter(): void+ {+ app('preferences')->set('mfa_failure_count', 0);+ Log::channel('audit')->info('MFA failure count is set to zero.');+ }+/*** Checks if code is in users backup codes.*/@@ -219,26 +241,4 @@ class TwoFactorController extends Controllerapp('preferences')->set('mfa_recovery', $newList);}-- private function addToMFAFailureCounter(): void- {- $preference = (int) app('preferences')->get('mfa_failure_count', 0)->data;- ++$preference;- Log::channel('audit')->info(sprintf('MFA failure count is set to %d.', $preference));- app('preferences')->set('mfa_failure_count', $preference);- }-- private function getMFAFailureCounter(): int- {- $value = (int) app('preferences')->get('mfa_failure_count', 0)->data;- Log::channel('audit')->info(sprintf('MFA failure count is %d.', $value));-- return $value;- }-- private function resetMFAFailureCounter(): void- {- app('preferences')->set('mfa_failure_count', 0);- Log::channel('audit')->info('MFA failure count is set to zero.');- }}diff --git a/app/Http/Controllers/Bill/CreateController.php b/app/Http/Controllers/Bill/CreateController.phpindex f55075856d..b126273230 100644--- a/app/Http/Controllers/Bill/CreateController.php+++ b/app/Http/Controllers/Bill/CreateController.php@@ -52,7 +52,7 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.bills'));+ app('view')->share('title', (string) trans('firefly.bills'));app('view')->share('mainTitleIcon', 'fa-calendar-o');$this->attachments = app(AttachmentHelperInterface::class);$this->repository = app(BillRepositoryInterface::class);@@ -74,9 +74,9 @@ class CreateController extends Controller/** @var array $billPeriods */$billPeriods = config('firefly.bill_periods');foreach ($billPeriods as $current) {- $periods[$current] = (string)trans('firefly.repeat_freq_'.$current);+ $periods[$current] = (string) trans('firefly.repeat_freq_'.$current);}- $subTitle = (string)trans('firefly.create_new_bill');+ $subTitle = (string) trans('firefly.create_new_bill');$defaultCurrency = app('amount')->getDefaultCurrency();// put previous url in session if not redirect from store (not "create another").@@ -101,13 +101,13 @@ class CreateController extends Controller$bill = $this->repository->store($billData);} catch (FireflyException $e) {app('log')->error($e->getMessage());- $request->session()->flash('error', (string)trans('firefly.bill_store_error'));+ $request->session()->flash('error', (string) trans('firefly.bill_store_error'));return redirect(route('bills.create'))->withInput();}Log::channel('audit')->info('Stored new bill.', $billData);- $request->session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));+ $request->session()->flash('success', (string) trans('firefly.stored_new_bill', ['name' => $bill->name]));app('preferences')->mark();/** @var null|array $files */@@ -117,7 +117,7 @@ class CreateController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {diff --git a/app/Http/Controllers/Bill/DeleteController.php b/app/Http/Controllers/Bill/DeleteController.phpindex c69aa3d22f..6dccb056a6 100644--- a/app/Http/Controllers/Bill/DeleteController.php+++ b/app/Http/Controllers/Bill/DeleteController.php@@ -51,7 +51,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.bills'));+ app('view')->share('title', (string) trans('firefly.bills'));app('view')->share('mainTitleIcon', 'fa-calendar-o');$this->repository = app(BillRepositoryInterface::class);@@ -69,7 +69,7 @@ class DeleteController extends Controller{// put previous url in session$this->rememberPreviousUrl('bills.delete.url');- $subTitle = (string)trans('firefly.delete_bill', ['name' => $bill->name]);+ $subTitle = (string) trans('firefly.delete_bill', ['name' => $bill->name]);return view('bills.delete', compact('bill', 'subTitle'));}@@ -84,7 +84,7 @@ class DeleteController extends Controller$name = $bill->name;$this->repository->destroy($bill);- $request->session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $name]));+ $request->session()->flash('success', (string) trans('firefly.deleted_bill', ['name' => $name]));app('preferences')->mark();return redirect($this->getPreviousUrl('bills.delete.url'));diff --git a/app/Http/Controllers/Bill/EditController.php b/app/Http/Controllers/Bill/EditController.phpindex 73909da27d..abb062e606 100644--- a/app/Http/Controllers/Bill/EditController.php+++ b/app/Http/Controllers/Bill/EditController.php@@ -52,7 +52,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.bills'));+ app('view')->share('title', (string) trans('firefly.bills'));app('view')->share('mainTitleIcon', 'fa-calendar-o');$this->attachments = app(AttachmentHelperInterface::class);$this->repository = app(BillRepositoryInterface::class);@@ -75,10 +75,10 @@ class EditController extends Controller$billPeriods = config('firefly.bill_periods');foreach ($billPeriods as $current) {- $periods[$current] = (string)trans('firefly.'.$current);+ $periods[$current] = (string) trans('firefly.'.$current);}- $subTitle = (string)trans('firefly.edit_bill', ['name' => $bill->name]);+ $subTitle = (string) trans('firefly.edit_bill', ['name' => $bill->name]);// put previous url in session if not redirect from store (not "return_to_edit").if (true !== session('bills.edit.fromUpdate')) {@@ -99,7 +99,7 @@ class EditController extends Controller'extension_date' => $bill->extension_date,'notes' => $this->repository->getNoteText($bill),'transaction_currency_id' => $bill->transaction_currency_id,- 'active' => $hasOldInput ? (bool)$request->old('active') : $bill->active,+ 'active' => $hasOldInput ? (bool) $request->old('active') : $bill->active,'object_group' => null !== $bill->objectGroups->first() ? $bill->objectGroups->first()->title : '',];@@ -119,7 +119,7 @@ class EditController extends ControllerLog::channel('audit')->info(sprintf('Updated bill #%d.', $bill->id), $billData);- $request->session()->flash('success', (string)trans('firefly.updated_bill', ['name' => $bill->name]));+ $request->session()->flash('success', (string) trans('firefly.updated_bill', ['name' => $bill->name]));app('preferences')->mark();/** @var null|array $files */@@ -129,7 +129,7 @@ class EditController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}// flash messages@@ -138,7 +138,7 @@ class EditController extends Controller}$redirect = redirect($this->getPreviousUrl('bills.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {$request->session()->put('bills.edit.fromUpdate', true);$redirect = redirect(route('bills.edit', [$bill->id]))->withInput(['return_to_edit' => 1]);diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.phpindex b78df5289c..871258e1af 100644--- a/app/Http/Controllers/Bill/IndexController.php+++ b/app/Http/Controllers/Bill/IndexController.php@@ -55,7 +55,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.bills'));+ app('view')->share('title', (string) trans('firefly.bills'));app('view')->share('mainTitleIcon', 'fa-calendar-o');$this->repository = app(BillRepositoryInterface::class);@@ -96,7 +96,7 @@ class IndexController extends Controller$bills = [0 => [ // the index is the order, not the ID.'object_group_id' => 0,- 'object_group_title' => (string)trans('firefly.default_group_title_name'),+ 'object_group_title' => (string) trans('firefly.default_group_title_name'),'bills' => [],],];@@ -104,7 +104,7 @@ class IndexController extends Controller/** @var Bill $bill */foreach ($collection as $bill) {$array = $transformer->transform($bill);- $groupOrder = (int)$array['object_group_order'];+ $groupOrder = (int) $array['object_group_order'];// make group array if necessary:$bills[$groupOrder] ??= ['object_group_id' => $array['object_group_id'],@@ -164,8 +164,8 @@ class IndexController extends Controller// only fill in avg when bill is active.if (null !== $bill['next_expected_match']) {- $avg = bcdiv(bcadd((string)$bill['amount_min'], (string)$bill['amount_max']), '2');- $avg = bcmul($avg, (string)count($bill['pay_dates']));+ $avg = bcdiv(bcadd((string) $bill['amount_min'], (string) $bill['amount_max']), '2');+ $avg = bcmul($avg, (string) count($bill['pay_dates']));$sums[$groupOrder][$currencyId]['avg'] = bcadd($sums[$groupOrder][$currencyId]['avg'], $avg);}// fill in per period regardless:@@ -178,7 +178,7 @@ class IndexController extends Controllerprivate function amountPerPeriod(array $bill, string $range): string{- $avg = bcdiv(bcadd((string)$bill['amount_min'], (string)$bill['amount_max']), '2');+ $avg = bcdiv(bcadd((string) $bill['amount_min'], (string) $bill['amount_max']), '2');app('log')->debug(sprintf('Amount per period for bill #%d "%s"', $bill['id'], $bill['name']));app('log')->debug(sprintf('Average is %s', $avg));@@ -191,8 +191,8 @@ class IndexController extends Controller'weekly' => '52.17','daily' => '365.24',];- $yearAmount = bcmul($avg, bcdiv($multiplies[$bill['repeat_freq']], (string)($bill['skip'] + 1)));- app('log')->debug(sprintf('Amount per year is %s (%s * %s / %s)', $yearAmount, $avg, $multiplies[$bill['repeat_freq']], (string)($bill['skip'] + 1)));+ $yearAmount = bcmul($avg, bcdiv($multiplies[$bill['repeat_freq']], (string) ($bill['skip'] + 1)));+ app('log')->debug(sprintf('Amount per year is %s (%s * %s / %s)', $yearAmount, $avg, $multiplies[$bill['repeat_freq']], (string) ($bill['skip'] + 1)));// per period:$division = [@@ -256,8 +256,8 @@ class IndexController extends Controller*/public function setOrder(Request $request, Bill $bill): JsonResponse{- $objectGroupTitle = (string)$request->get('objectGroupTitle');- $newOrder = (int)$request->get('order');+ $objectGroupTitle = (string) $request->get('objectGroupTitle');+ $newOrder = (int) $request->get('order');$this->repository->setOrder($bill, $newOrder);if ('' !== $objectGroupTitle) {$this->repository->setObjectGroup($bill, $objectGroupTitle);diff --git a/app/Http/Controllers/Bill/ShowController.php b/app/Http/Controllers/Bill/ShowController.phpindex 6fcd5b2625..a50540e6b3 100644--- a/app/Http/Controllers/Bill/ShowController.php+++ b/app/Http/Controllers/Bill/ShowController.php@@ -62,7 +62,7 @@ class ShowController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.bills'));+ app('view')->share('title', (string) trans('firefly.bills'));app('view')->share('mainTitleIcon', 'fa-calendar-o');$this->repository = app(BillRepositoryInterface::class);@@ -80,13 +80,13 @@ class ShowController extends Controller{$total = 0;if (false === $bill->active) {- $request->session()->flash('warning', (string)trans('firefly.cannot_scan_inactive_bill'));+ $request->session()->flash('warning', (string) trans('firefly.cannot_scan_inactive_bill'));return redirect(route('bills.show', [$bill->id]));}$set = $this->repository->getRulesForBill($bill);if (0 === $set->count()) {- $request->session()->flash('error', (string)trans('firefly.no_rules_for_bill'));+ $request->session()->flash('error', (string) trans('firefly.no_rules_for_bill'));return redirect(route('bills.show', [$bill->id]));}@@ -125,8 +125,8 @@ class ShowController extends Controller/** @var Carbon $end */$end = session('end');$year = $start->year;- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$yearAverage = $this->repository->getYearAverage($bill, $start);$overallAverage = $this->repository->getOverallAverage($bill);$manager = new Manager();diff --git a/app/Http/Controllers/Budget/BudgetLimitController.php b/app/Http/Controllers/Budget/BudgetLimitController.phpindex 0583d02621..4adc1a76ab 100644--- a/app/Http/Controllers/Budget/BudgetLimitController.php+++ b/app/Http/Controllers/Budget/BudgetLimitController.php@@ -102,13 +102,14 @@ class BudgetLimitController extends Controller}/**- * @return Factory|View+ * @return Redirector|RedirectResponse*/- public function show(BudgetLimit $budgetLimit)+ public function delete(BudgetLimit $budgetLimit){- $notes = $this->blRepository->getNoteText($budgetLimit);+ $this->blRepository->destroyBudgetLimit($budgetLimit);+ session()->flash('success', trans('firefly.deleted_bl'));- return view('budgets.budget-limits.show', compact('budgetLimit', 'notes'));+ return redirect(route('budgets.index'));}/**@@ -122,14 +123,13 @@ class BudgetLimitController extends Controller}/**- * @return Redirector|RedirectResponse+ * @return Factory|View*/- public function delete(BudgetLimit $budgetLimit)+ public function show(BudgetLimit $budgetLimit){- $this->blRepository->destroyBudgetLimit($budgetLimit);- session()->flash('success', trans('firefly.deleted_bl'));+ $notes = $this->blRepository->getNoteText($budgetLimit);- return redirect(route('budgets.index'));+ return view('budgets.budget-limits.show', compact('budgetLimit', 'notes'));}/**@@ -250,7 +250,7 @@ class BudgetLimitController extends Controllerif (-1 === bccomp($amount, '0')) {$amount = bcmul($amount, '-1');}- $notes = (string)$request->get('notes');+ $notes = (string) $request->get('notes');if (strlen($notes) > 32768) {$notes = substr($notes, 0, 32768);}diff --git a/app/Http/Controllers/Budget/CreateController.php b/app/Http/Controllers/Budget/CreateController.phpindex 49548813bc..9bdc298e8f 100644--- a/app/Http/Controllers/Budget/CreateController.php+++ b/app/Http/Controllers/Budget/CreateController.php@@ -52,7 +52,7 @@ class CreateController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.budgets'));+ app('view')->share('title', (string) trans('firefly.budgets'));app('view')->share('mainTitleIcon', 'fa-pie-chart');$this->repository = app(BudgetRepositoryInterface::class);$this->attachments = app(AttachmentHelperInterface::class);@@ -73,24 +73,24 @@ class CreateController extends Controller// auto budget types$autoBudgetTypes = [- 0 => (string)trans('firefly.auto_budget_none'),- AutoBudget::AUTO_BUDGET_RESET => (string)trans('firefly.auto_budget_reset'),- AutoBudget::AUTO_BUDGET_ROLLOVER => (string)trans('firefly.auto_budget_rollover'),- AutoBudget::AUTO_BUDGET_ADJUSTED => (string)trans('firefly.auto_budget_adjusted'),+ 0 => (string) trans('firefly.auto_budget_none'),+ AutoBudget::AUTO_BUDGET_RESET => (string) trans('firefly.auto_budget_reset'),+ AutoBudget::AUTO_BUDGET_ROLLOVER => (string) trans('firefly.auto_budget_rollover'),+ AutoBudget::AUTO_BUDGET_ADJUSTED => (string) trans('firefly.auto_budget_adjusted'),];$autoBudgetPeriods = [- 'daily' => (string)trans('firefly.auto_budget_period_daily'),- 'weekly' => (string)trans('firefly.auto_budget_period_weekly'),- 'monthly' => (string)trans('firefly.auto_budget_period_monthly'),- 'quarterly' => (string)trans('firefly.auto_budget_period_quarterly'),- 'half_year' => (string)trans('firefly.auto_budget_period_half_year'),- 'yearly' => (string)trans('firefly.auto_budget_period_yearly'),+ 'daily' => (string) trans('firefly.auto_budget_period_daily'),+ 'weekly' => (string) trans('firefly.auto_budget_period_weekly'),+ 'monthly' => (string) trans('firefly.auto_budget_period_monthly'),+ 'quarterly' => (string) trans('firefly.auto_budget_period_quarterly'),+ 'half_year' => (string) trans('firefly.auto_budget_period_half_year'),+ 'yearly' => (string) trans('firefly.auto_budget_period_yearly'),];$currency = app('amount')->getDefaultCurrency();$preFilled = [- 'auto_budget_period' => $hasOldInput ? (bool)$request->old('auto_budget_period') : 'monthly',- 'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id,+ 'auto_budget_period' => $hasOldInput ? (bool) $request->old('auto_budget_period') : 'monthly',+ 'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $currency->id,];$request->session()->flash('preFilled', $preFilled);@@ -100,7 +100,7 @@ class CreateController extends Controller$this->rememberPreviousUrl('budgets.create.url');}$request->session()->forget('budgets.create.fromStore');- $subTitle = (string)trans('firefly.create_new_budget');+ $subTitle = (string) trans('firefly.create_new_budget');return view('budgets.create', compact('subTitle', 'autoBudgetTypes', 'autoBudgetPeriods'));}@@ -116,7 +116,7 @@ class CreateController extends Controller$budget = $this->repository->store($data);$this->repository->cleanupBudgets();- $request->session()->flash('success', (string)trans('firefly.stored_new_budget', ['name' => $budget->name]));+ $request->session()->flash('success', (string) trans('firefly.stored_new_budget', ['name' => $budget->name]));app('preferences')->mark();Log::channel('audit')->info('Stored new budget.', $data);@@ -129,7 +129,7 @@ class CreateController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {@@ -138,7 +138,7 @@ class CreateController extends Controller$redirect = redirect($this->getPreviousUrl('budgets.create.url'));- if (1 === (int)$request->get('create_another')) {+ if (1 === (int) $request->get('create_another')) {$request->session()->put('budgets.create.fromStore', true);$redirect = redirect(route('budgets.create'))->withInput();diff --git a/app/Http/Controllers/Budget/DeleteController.php b/app/Http/Controllers/Budget/DeleteController.phpindex ec9e1c538d..a938a06df4 100644--- a/app/Http/Controllers/Budget/DeleteController.php+++ b/app/Http/Controllers/Budget/DeleteController.php@@ -50,7 +50,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.budgets'));+ app('view')->share('title', (string) trans('firefly.budgets'));app('view')->share('mainTitleIcon', 'fa-pie-chart');$this->repository = app(BudgetRepositoryInterface::class);@@ -66,7 +66,7 @@ class DeleteController extends Controller*/public function delete(Budget $budget){- $subTitle = (string)trans('firefly.delete_budget', ['name' => $budget->name]);+ $subTitle = (string) trans('firefly.delete_budget', ['name' => $budget->name]);// put previous url in session$this->rememberPreviousUrl('budgets.delete.url');@@ -83,7 +83,7 @@ class DeleteController extends Controller{$name = $budget->name;$this->repository->destroy($budget);- $request->session()->flash('success', (string)trans('firefly.deleted_budget', ['name' => $name]));+ $request->session()->flash('success', (string) trans('firefly.deleted_budget', ['name' => $name]));app('preferences')->mark();return redirect($this->getPreviousUrl('budgets.delete.url'));diff --git a/app/Http/Controllers/Budget/EditController.php b/app/Http/Controllers/Budget/EditController.phpindex 72b2ff3f79..8729985fac 100644--- a/app/Http/Controllers/Budget/EditController.php+++ b/app/Http/Controllers/Budget/EditController.php@@ -53,7 +53,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.budgets'));+ app('view')->share('title', (string) trans('firefly.budgets'));app('view')->share('mainTitleIcon', 'fa-pie-chart');$this->repository = app(BudgetRepositoryInterface::class);$this->attachments = app(AttachmentHelperInterface::class);@@ -70,38 +70,38 @@ class EditController extends Controller*/public function edit(Request $request, Budget $budget){- $subTitle = (string)trans('firefly.edit_budget', ['name' => $budget->name]);+ $subTitle = (string) trans('firefly.edit_budget', ['name' => $budget->name]);$autoBudget = $this->repository->getAutoBudget($budget);// auto budget types$autoBudgetTypes = [- 0 => (string)trans('firefly.auto_budget_none'),- AutoBudget::AUTO_BUDGET_RESET => (string)trans('firefly.auto_budget_reset'),- AutoBudget::AUTO_BUDGET_ROLLOVER => (string)trans('firefly.auto_budget_rollover'),- AutoBudget::AUTO_BUDGET_ADJUSTED => (string)trans('firefly.auto_budget_adjusted'),+ 0 => (string) trans('firefly.auto_budget_none'),+ AutoBudget::AUTO_BUDGET_RESET => (string) trans('firefly.auto_budget_reset'),+ AutoBudget::AUTO_BUDGET_ROLLOVER => (string) trans('firefly.auto_budget_rollover'),+ AutoBudget::AUTO_BUDGET_ADJUSTED => (string) trans('firefly.auto_budget_adjusted'),];$autoBudgetPeriods = [- 'daily' => (string)trans('firefly.auto_budget_period_daily'),- 'weekly' => (string)trans('firefly.auto_budget_period_weekly'),- 'monthly' => (string)trans('firefly.auto_budget_period_monthly'),- 'quarterly' => (string)trans('firefly.auto_budget_period_quarterly'),- 'half_year' => (string)trans('firefly.auto_budget_period_half_year'),- 'yearly' => (string)trans('firefly.auto_budget_period_yearly'),+ 'daily' => (string) trans('firefly.auto_budget_period_daily'),+ 'weekly' => (string) trans('firefly.auto_budget_period_weekly'),+ 'monthly' => (string) trans('firefly.auto_budget_period_monthly'),+ 'quarterly' => (string) trans('firefly.auto_budget_period_quarterly'),+ 'half_year' => (string) trans('firefly.auto_budget_period_half_year'),+ 'yearly' => (string) trans('firefly.auto_budget_period_yearly'),];// code to handle active-checkboxes$hasOldInput = null !== $request->old('_token');$currency = app('amount')->getDefaultCurrency();$preFilled = [- 'active' => $hasOldInput ? (bool)$request->old('active') : $budget->active,- 'auto_budget_currency_id' => $hasOldInput ? (int)$request->old('auto_budget_currency_id') : $currency->id,+ 'active' => $hasOldInput ? (bool) $request->old('active') : $budget->active,+ 'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $currency->id,];if (null !== $autoBudget) {$amount = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount;if (is_array($amount)) {$amount = '0';}- $amount = (string)$amount;+ $amount = (string) $amount;$preFilled['auto_budget_amount'] = app('steam')->bcround($amount, $autoBudget->transactionCurrency->decimal_places);}@@ -123,7 +123,7 @@ class EditController extends Controller$data = $request->getBudgetData();$this->repository->update($budget, $data);- $request->session()->flash('success', (string)trans('firefly.updated_budget', ['name' => $budget->name]));+ $request->session()->flash('success', (string) trans('firefly.updated_budget', ['name' => $budget->name]));$this->repository->cleanupBudgets();app('preferences')->mark();@@ -139,14 +139,14 @@ class EditController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {$request->session()->flash('info', $this->attachments->getMessages()->get('attachments'));}- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {$request->session()->put('budgets.edit.fromUpdate', true);$redirect = redirect(route('budgets.edit', [$budget->id]))->withInput(['return_to_edit' => 1]);diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.phpindex ec91cfaef8..54163cb469 100644--- a/app/Http/Controllers/Budget/IndexController.php+++ b/app/Http/Controllers/Budget/IndexController.php@@ -65,7 +65,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.budgets'));+ app('view')->share('title', (string) trans('firefly.budgets'));app('view')->share('mainTitleIcon', 'fa-pie-chart');$this->repository = app(BudgetRepositoryInterface::class);$this->opsRepository = app(OperationsRepositoryInterface::class);@@ -306,7 +306,7 @@ class IndexController extends Controller$budgetIds = $request->get('budgetIds');foreach ($budgetIds as $index => $budgetId) {- $budgetId = (int)$budgetId;+ $budgetId = (int) $budgetId;$budget = $repository->find($budgetId);if (null !== $budget) {app('log')->debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1));diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.phpindex 5ed1205eaa..42f2c23ce6 100644--- a/app/Http/Controllers/Budget/ShowController.php+++ b/app/Http/Controllers/Budget/ShowController.php@@ -59,7 +59,7 @@ class ShowController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.budgets'));+ app('view')->share('title', (string) trans('firefly.budgets'));app('view')->share('mainTitleIcon', 'fa-pie-chart');$this->journalRepos = app(JournalRepositoryInterface::class);$this->repository = app(BudgetRepositoryInterface::class);@@ -91,8 +91,8 @@ class ShowController extends Controller$first = $this->journalRepos->firstNull();$firstDate = null !== $first ? $first->date : $start;$periods = $this->getNoBudgetPeriodOverview($firstDate, $end);- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);@@ -112,12 +112,12 @@ class ShowController extends Controller*/public function noBudgetAll(Request $request){- $subTitle = (string)trans('firefly.all_journals_without_budget');+ $subTitle = (string) trans('firefly.all_journals_without_budget');$first = $this->journalRepos->firstNull();$start = null === $first ? new Carbon() : $first->date;$end = today(config('app.timezone'));- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);@@ -140,8 +140,8 @@ class ShowController extends Controller/** @var Carbon $allStart */$allStart = session('first', today(config('app.timezone'))->startOfYear());$allEnd = today();- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$limits = $this->getLimits($budget, $allStart, $allEnd);$repetition = null;$attachments = $this->repository->getAttachments($budget);@@ -156,7 +156,7 @@ class ShowController extends Controller$groups = $collector->getPaginatedGroups();$groups->setPath(route('budgets.show', [$budget->id]));- $subTitle = (string)trans('firefly.all_journals_for_budget', ['name' => $budget->name]);+ $subTitle = (string) trans('firefly.all_journals_for_budget', ['name' => $budget->name]);return view('budgets.show', compact('limits', 'attachments', 'budget', 'repetition', 'groups', 'subTitle'));}@@ -174,8 +174,8 @@ class ShowController extends Controllerthrow new FireflyException('This budget limit is not part of this budget.');}- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$subTitle = trans('firefly.budget_in_period',[diff --git a/app/Http/Controllers/Category/CreateController.php b/app/Http/Controllers/Category/CreateController.phpindex ba0fdee1eb..c9a0e58d1d 100644--- a/app/Http/Controllers/Category/CreateController.php+++ b/app/Http/Controllers/Category/CreateController.php@@ -53,7 +53,7 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.categories'));+ app('view')->share('title', (string) trans('firefly.categories'));app('view')->share('mainTitleIcon', 'fa-bookmark');$this->repository = app(CategoryRepositoryInterface::class);$this->attachments = app(AttachmentHelperInterface::class);@@ -74,7 +74,7 @@ class CreateController extends Controller$this->rememberPreviousUrl('categories.create.url');}$request->session()->forget('categories.create.fromStore');- $subTitle = (string)trans('firefly.create_new_category');+ $subTitle = (string) trans('firefly.create_new_category');return view('categories.create', compact('subTitle'));}@@ -91,7 +91,7 @@ class CreateController extends Controller$data = $request->getCategoryData();$category = $this->repository->store($data);- $request->session()->flash('success', (string)trans('firefly.stored_category', ['name' => $category->name]));+ $request->session()->flash('success', (string) trans('firefly.stored_category', ['name' => $category->name]));app('preferences')->mark();// store attachment(s):@@ -102,7 +102,7 @@ class CreateController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {@@ -110,7 +110,7 @@ class CreateController extends Controller}$redirect = redirect(route('categories.index'));- if (1 === (int)$request->get('create_another')) {+ if (1 === (int) $request->get('create_another')) {$request->session()->put('categories.create.fromStore', true);$redirect = redirect(route('categories.create'))->withInput();diff --git a/app/Http/Controllers/Category/DeleteController.php b/app/Http/Controllers/Category/DeleteController.phpindex fb1c5b83b6..b4968f45ee 100644--- a/app/Http/Controllers/Category/DeleteController.php+++ b/app/Http/Controllers/Category/DeleteController.php@@ -50,7 +50,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.categories'));+ app('view')->share('title', (string) trans('firefly.categories'));app('view')->share('mainTitleIcon', 'fa-bookmark');$this->repository = app(CategoryRepositoryInterface::class);@@ -66,7 +66,7 @@ class DeleteController extends Controller*/public function delete(Category $category){- $subTitle = (string)trans('firefly.delete_category', ['name' => $category->name]);+ $subTitle = (string) trans('firefly.delete_category', ['name' => $category->name]);// put previous url in session$this->rememberPreviousUrl('categories.delete.url');@@ -84,7 +84,7 @@ class DeleteController extends Controller$name = $category->name;$this->repository->destroy($category);- $request->session()->flash('success', (string)trans('firefly.deleted_category', ['name' => $name]));+ $request->session()->flash('success', (string) trans('firefly.deleted_category', ['name' => $name]));app('preferences')->mark();return redirect($this->getPreviousUrl('categories.delete.url'));diff --git a/app/Http/Controllers/Category/EditController.php b/app/Http/Controllers/Category/EditController.phpindex a3f63400a5..cdfa19a3fc 100644--- a/app/Http/Controllers/Category/EditController.php+++ b/app/Http/Controllers/Category/EditController.php@@ -53,7 +53,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.categories'));+ app('view')->share('title', (string) trans('firefly.categories'));app('view')->share('mainTitleIcon', 'fa-bookmark');$this->repository = app(CategoryRepositoryInterface::class);$this->attachments = app(AttachmentHelperInterface::class);@@ -70,7 +70,7 @@ class EditController extends Controller*/public function edit(Request $request, Category $category){- $subTitle = (string)trans('firefly.edit_category', ['name' => $category->name]);+ $subTitle = (string) trans('firefly.edit_category', ['name' => $category->name]);// put previous url in session if not redirect from store (not "return_to_edit").if (true !== session('categories.edit.fromUpdate')) {@@ -95,7 +95,7 @@ class EditController extends Controller$data = $request->getCategoryData();$this->repository->update($category, $data);- $request->session()->flash('success', (string)trans('firefly.updated_category', ['name' => $category->name]));+ $request->session()->flash('success', (string) trans('firefly.updated_category', ['name' => $category->name]));app('preferences')->mark();// store new attachment(s):@@ -106,7 +106,7 @@ class EditController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {@@ -114,7 +114,7 @@ class EditController extends Controller}$redirect = redirect($this->getPreviousUrl('categories.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {$request->session()->put('categories.edit.fromUpdate', true);$redirect = redirect(route('categories.edit', [$category->id]));diff --git a/app/Http/Controllers/Category/IndexController.php b/app/Http/Controllers/Category/IndexController.phpindex 6ee7d6861c..41b85c87a7 100644--- a/app/Http/Controllers/Category/IndexController.php+++ b/app/Http/Controllers/Category/IndexController.php@@ -50,7 +50,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.categories'));+ app('view')->share('title', (string) trans('firefly.categories'));app('view')->share('mainTitleIcon', 'fa-bookmark');$this->repository = app(CategoryRepositoryInterface::class);@@ -66,8 +66,8 @@ class IndexController extends Controller*/public function index(Request $request){- $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$collection = $this->repository->getCategories();$total = $collection->count();$collection = $collection->slice(($page - 1) * $pageSize, $pageSize);diff --git a/app/Http/Controllers/Category/NoCategoryController.php b/app/Http/Controllers/Category/NoCategoryController.phpindex 09b1d67690..d66516ec56 100644--- a/app/Http/Controllers/Category/NoCategoryController.php+++ b/app/Http/Controllers/Category/NoCategoryController.php@@ -55,7 +55,7 @@ class NoCategoryController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.categories'));+ app('view')->share('title', (string) trans('firefly.categories'));app('view')->share('mainTitleIcon', 'fa-bookmark');$this->journalRepos = app(JournalRepositoryInterface::class);@@ -78,8 +78,8 @@ class NoCategoryController extends Controller$start ??= session('start');// @var Carbon $end$end ??= session('end');- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$subTitle = trans('firefly.without_category_between',['start' => $start->isoFormat($this->monthAndDayFormat), 'end' => $end->isoFormat($this->monthAndDayFormat)]@@ -113,10 +113,10 @@ class NoCategoryController extends Controller$start = null;$end = null;$periods = new Collection();- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;app('log')->debug('Start of noCategory()');- $subTitle = (string)trans('firefly.all_journals_without_category');+ $subTitle = (string) trans('firefly.all_journals_without_category');$first = $this->journalRepos->firstNull();$start = null === $first ? new Carbon() : $first->date;$end = today(config('app.timezone'));diff --git a/app/Http/Controllers/Category/ShowController.php b/app/Http/Controllers/Category/ShowController.phpindex 24462817a3..00d6305868 100644--- a/app/Http/Controllers/Category/ShowController.php+++ b/app/Http/Controllers/Category/ShowController.php@@ -56,7 +56,7 @@ class ShowController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.categories'));+ app('view')->share('title', (string) trans('firefly.categories'));app('view')->share('mainTitleIcon', 'fa-bookmark');$this->repository = app(CategoryRepositoryInterface::class);@@ -79,9 +79,9 @@ class ShowController extends Controller// @var Carbon $end$end ??= session('end', today(config('app.timezone'))->endOfMonth());$subTitleIcon = 'fa-bookmark';- $page = (int)$request->get('page');+ $page = (int) $request->get('page');$attachments = $this->repository->getAttachments($category);- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$oldest = $this->repository->firstUseDate($category) ?? today(config('app.timezone'))->startOfYear();$periods = $this->getCategoryPeriodOverview($category, $oldest, $end);$path = route('categories.show', [$category->id, $start->format('Y-m-d'), $end->format('Y-m-d')]);@@ -116,13 +116,13 @@ class ShowController extends Controller{// default values:$subTitleIcon = 'fa-bookmark';- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$start = null;$end = null;$periods = new Collection();- $subTitle = (string)trans('firefly.all_journals_for_category', ['name' => $category->name]);+ $subTitle = (string) trans('firefly.all_journals_for_category', ['name' => $category->name]);$first = $this->repository->firstUseDate($category);/** @var Carbon $start */diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.phpindex aad9c2fb66..aa842a9773 100644--- a/app/Http/Controllers/Chart/AccountController.php+++ b/app/Http/Controllers/Chart/AccountController.php@@ -109,22 +109,22 @@ class AccountController extends Controller// loop the end balances. This is an array for each account ($expenses)foreach ($endBalances as $accountId => $expenses) {- $accountId = (int)$accountId;+ $accountId = (int) $accountId;// loop each expense entry (each entry can be a different currency).foreach ($expenses as $currencyId => $endAmount) {- $currencyId = (int)$currencyId;+ $currencyId = (int) $currencyId;// see if there is an accompanying start amount.// grab the difference and find the currency.- $startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');- $diff = bcsub((string)$endAmount, $startAmount);+ $startAmount = (string) ($startBalances[$accountId][$currencyId] ?? '0');+ $diff = bcsub((string) $endAmount, $startAmount);$currencies[$currencyId] ??= $this->currencyRepository->find($currencyId);if (0 !== bccomp($diff, '0')) {// store the values in a temporary array.$tempData[] = ['name' => $accountNames[$accountId],'difference' => $diff,- 'diff_float' => (float)$diff, // intentional float+ 'diff_float' => (float) $diff, // intentional float'currency_id' => $currencyId,];}@@ -143,7 +143,7 @@ class AccountController extends Controllerforeach ($currencies as $currencyId => $currency) {$dataSet= [- 'label' => (string)trans('firefly.spent'),+ 'label' => (string) trans('firefly.spent'),'type' => 'bar','currency_symbol' => $currency->symbol,'currency_code' => $currency->code,@@ -200,7 +200,7 @@ class AccountController extends Controller/** @var array $journal */foreach ($journals as $journal) {- $budgetId = (int)$journal['budget_id'];+ $budgetId = (int) $journal['budget_id'];$key = sprintf('%d-%d', $budgetId, $journal['currency_id']);$budgetIds[] = $budgetId;if (!array_key_exists($key, $result)) {@@ -220,7 +220,7 @@ class AccountController extends Controllerforeach ($result as $row) {$budgetId = $row['budget_id'];$name = $names[$budgetId];- $label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);+ $label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];}@@ -268,7 +268,7 @@ class AccountController extends Controllerif (!array_key_exists($key, $result)) {$result[$key] = ['total' => '0',- 'category_id' => (int)$journal['category_id'],+ 'category_id' => (int) $journal['category_id'],'currency_name' => $journal['currency_name'],'currency_symbol' => $journal['currency_symbol'],'currency_code' => $journal['currency_code'],@@ -281,7 +281,7 @@ class AccountController extends Controllerforeach ($result as $row) {$categoryId = $row['category_id'];$name = $names[$categoryId] ?? '(unknown)';- $label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);+ $label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];}@@ -367,7 +367,7 @@ class AccountController extends Controllerforeach ($result as $row) {$categoryId = $row['category_id'];$name = $names[$categoryId] ?? '(unknown)';- $label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);+ $label = (string) trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency_name']]);$chartData[$label] = ['amount' => $row['total'], 'currency_symbol' => $row['currency_symbol'], 'currency_code' => $row['currency_code']];}$data = $this->generator->multiCurrencyPieChart($chartData);@@ -434,14 +434,14 @@ class AccountController extends ControllerLog::debug(sprintf('$current date is %s', $current->format('Y-m-d')));if ('1D' === $step) {// per day the entire period, balance for every day.- $format = (string)trans('config.month_and_day_js', [], $locale);+ $format = (string) trans('config.month_and_day_js', [], $locale);$range = app('steam')->balanceInRange($account, $start, $end, $currency);$previous = array_values($range)[0];while ($end >= $current) {$theDate = $current->format('Y-m-d');$balance = $range[$theDate] ?? $previous;$label = $current->isoFormat($format);- $entries[$label] = (float)$balance;+ $entries[$label] = (float) $balance;$previous = $balance;$current->addDay();}@@ -449,7 +449,7 @@ class AccountController extends Controllerif ('1W' === $step || '1M' === $step || '1Y' === $step) {while ($end >= $current) {Log::debug(sprintf('Current is: %s', $current->format('Y-m-d')));- $balance = (float)app('steam')->balance($account, $current, $currency);+ $balance = (float) app('steam')->balance($account, $current, $currency);$label = app('navigation')->periodShow($current, $step);$entries[$label] = $balance;$current = app('navigation')->addPeriod($current, $step, 0);@@ -510,22 +510,22 @@ class AccountController extends Controller// loop the end balances. This is an array for each account ($expenses)foreach ($endBalances as $accountId => $expenses) {- $accountId = (int)$accountId;+ $accountId = (int) $accountId;// loop each expense entry (each entry can be a different currency).foreach ($expenses as $currencyId => $endAmount) {- $currencyId = (int)$currencyId;+ $currencyId = (int) $currencyId;// see if there is an accompanying start amount.// grab the difference and find the currency.- $startAmount = (string)($startBalances[$accountId][$currencyId] ?? '0');- $diff = bcsub((string)$endAmount, $startAmount);+ $startAmount = (string) ($startBalances[$accountId][$currencyId] ?? '0');+ $diff = bcsub((string) $endAmount, $startAmount);$currencies[$currencyId] ??= $this->currencyRepository->find($currencyId);if (0 !== bccomp($diff, '0')) {// store the values in a temporary array.$tempData[] = ['name' => $accountNames[$accountId],'difference' => $diff,- 'diff_float' => (float)$diff, // intentional float+ 'diff_float' => (float) $diff, // intentional float'currency_id' => $currencyId,];}@@ -544,7 +544,7 @@ class AccountController extends Controllerforeach ($currencies as $currencyId => $currency) {$dataSet= [- 'label' => (string)trans('firefly.earned'),+ 'label' => (string) trans('firefly.earned'),'type' => 'bar','currency_symbol' => $currency->symbol,'currency_code' => $currency->code,diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.phpindex 3e8c23c996..bb05755d05 100644--- a/app/Http/Controllers/Chart/BillController.php+++ b/app/Http/Controllers/Chart/BillController.php@@ -72,7 +72,7 @@ class BillController extends Controller*/foreach ($paid as $info) {$amount = $info['sum'];- $label = (string)trans('firefly.paid_in_currency', ['currency' => $info['name']]);+ $label = (string) trans('firefly.paid_in_currency', ['currency' => $info['name']]);$chartData[$label] = ['amount' => $amount,'currency_symbol' => $info['symbol'],@@ -85,7 +85,7 @@ class BillController extends Controller*/foreach ($unpaid as $info) {$amount = $info['sum'];- $label = (string)trans('firefly.unpaid_in_currency', ['currency' => $info['name']]);+ $label = (string) trans('firefly.unpaid_in_currency', ['currency' => $info['name']]);$chartData[$label] = ['amount' => $amount,'currency_symbol' => $info['symbol'],@@ -136,21 +136,21 @@ class BillController extends Controller$chartData = [['type' => 'line',- 'label' => (string)trans('firefly.min-amount'),+ 'label' => (string) trans('firefly.min-amount'),'currency_symbol' => $bill->transactionCurrency->symbol,'currency_code' => $bill->transactionCurrency->code,'entries' => [],],['type' => 'line',- 'label' => (string)trans('firefly.max-amount'),+ 'label' => (string) trans('firefly.max-amount'),'currency_symbol' => $bill->transactionCurrency->symbol,'currency_code' => $bill->transactionCurrency->code,'entries' => [],],['type' => 'bar',- 'label' => (string)trans('firefly.journal-amount'),+ 'label' => (string) trans('firefly.journal-amount'),'currency_symbol' => $bill->transactionCurrency->symbol,'currency_code' => $bill->transactionCurrency->code,'entries' => [],@@ -158,7 +158,7 @@ class BillController extends Controller];$currencyId = $bill->transaction_currency_id;foreach ($journals as $journal) {- $date = $journal['date']->isoFormat((string)trans('config.month_and_day_js', [], $locale));+ $date = $journal['date']->isoFormat((string) trans('config.month_and_day_js', [], $locale));$chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill$chartData[1]['entries'][$date] = $bill->amount_max; // maximum amount of billdiff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.phpindex 63d8051745..cbb14c51ff 100644--- a/app/Http/Controllers/Chart/BudgetController.php+++ b/app/Http/Controllers/Chart/BudgetController.php@@ -172,12 +172,12 @@ class BudgetController extends Controller$expenses = $this->opsRepository->sumExpenses($current, $current, null, $budgetCollection, $currency);$spent = $expenses[$currency->id]['sum'] ?? '0';$amount = bcadd($amount, $spent);- $format = $start->isoFormat((string)trans('config.month_and_day_js', [], $locale));+ $format = $start->isoFormat((string) trans('config.month_and_day_js', [], $locale));$entries[$format] = $amount;$start->addDay();}- $data = $this->generator->singleSet((string)trans('firefly.left'), $entries);+ $data = $this->generator->singleSet((string) trans('firefly.left'), $entries);// add currency symbol from budget limit:$data['datasets'][0]['currency_symbol'] = $budgetLimit->transactionCurrency->symbol;$data['datasets'][0]['currency_code'] = $budgetLimit->transactionCurrency->code;@@ -220,7 +220,7 @@ class BudgetController extends Controller// group by asset account ID: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] ??= ['amount' => '0','currency_symbol' => $journal['currency_symbol'],@@ -233,7 +233,7 @@ class BudgetController extends Controller$names = $this->getAccountNames(array_keys($result));foreach ($result as $combinedId => $info) {$parts = explode('-', $combinedId);- $assetId = (int)$parts[0];+ $assetId = (int) $parts[0];$title = sprintf('%s (%s)', $names[$assetId] ?? '(empty)', $info['currency_name']);$chartData[$title]= [@@ -293,7 +293,7 @@ class BudgetController extends Controller$names = $this->getCategoryNames(array_keys($result));foreach ($result as $combinedId => $info) {$parts = explode('-', $combinedId);- $categoryId = (int)$parts[0];+ $categoryId = (int) $parts[0];$title = sprintf('%s (%s)', $names[$categoryId] ?? '(empty)', $info['currency_name']);$chartData[$title] = ['amount' => $info['amount'],@@ -353,7 +353,7 @@ class BudgetController extends Controller$names = $this->getAccountNames(array_keys($result));foreach ($result as $combinedId => $info) {$parts = explode('-', $combinedId);- $opposingId = (int)$parts[0];+ $opposingId = (int) $parts[0];$name = $names[$opposingId] ?? 'no name';$title = sprintf('%s (%s)', $name, $info['currency_name']);$chartData[$title] = [@@ -422,14 +422,14 @@ class BudgetController extends Controller$preferredRange = app('navigation')->preferredRangeFormat($start, $end);$chartData = [[- 'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $currency->name]),+ 'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency->name]),'type' => 'bar','entries' => [],'currency_symbol' => $currency->symbol,'currency_code' => $currency->code,],[- 'label' => (string)trans('firefly.box_budgeted_in_currency', ['currency' => $currency->name]),+ 'label' => (string) trans('firefly.box_budgeted_in_currency', ['currency' => $currency->name]),'type' => 'bar','currency_symbol' => $currency->symbol,'currency_code' => $currency->code,@@ -500,7 +500,7 @@ class BudgetController extends Controller$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange, 0);}- $data = $this->generator->singleSet((string)trans('firefly.spent'), $chartData);+ $data = $this->generator->singleSet((string) trans('firefly.spent'), $chartData);$cache->store($data);return response()->json($data);diff --git a/app/Http/Controllers/Chart/BudgetReportController.php b/app/Http/Controllers/Chart/BudgetReportController.phpindex c4ea407bb9..89d24d1e02 100644--- a/app/Http/Controllers/Chart/BudgetReportController.php+++ b/app/Http/Controllers/Chart/BudgetReportController.php@@ -171,7 +171,7 @@ class BudgetReportController extends Controller$chartData[$spentKey] ??= ['label' => sprintf('%s (%s)',- (string)trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),+ (string) trans('firefly.spent_in_specific_budget', ['budget' => $budget->name]),$currency['currency_name']),'type' => 'bar',diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.phpindex bef78246ba..1605f164eb 100644--- a/app/Http/Controllers/Chart/CategoryController.php+++ b/app/Http/Controllers/Chart/CategoryController.php@@ -185,7 +185,7 @@ class CategoryController extends Controller$inKey = sprintf('%d-in', $currencyId);$chartData[$outKey]= [- 'label' => sprintf('%s (%s)', (string)trans('firefly.spent'), $currencyInfo['currency_name']),+ 'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currencyInfo['currency_name']),'entries' => [],'type' => 'bar','backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red@@ -193,7 +193,7 @@ class CategoryController extends Controller$chartData[$inKey]= [- 'label' => sprintf('%s (%s)', (string)trans('firefly.earned'), $currencyInfo['currency_name']),+ 'label' => sprintf('%s (%s)', (string) trans('firefly.earned'), $currencyInfo['currency_name']),'entries' => [],'type' => 'bar','backgroundColor' => 'rgba(0, 141, 76, 0.5)', // greendiff --git a/app/Http/Controllers/Chart/CategoryReportController.php b/app/Http/Controllers/Chart/CategoryReportController.phpindex 6c90ed0462..238065a1fc 100644--- a/app/Http/Controllers/Chart/CategoryReportController.php+++ b/app/Http/Controllers/Chart/CategoryReportController.php@@ -218,7 +218,7 @@ class CategoryReportController extends Controller$chartData[$spentKey] ??= ['label' => sprintf('%s (%s)',- (string)trans('firefly.spent_in_specific_category', ['category' => $category->name]),+ (string) trans('firefly.spent_in_specific_category', ['category' => $category->name]),$currency['currency_name']),'type' => 'bar',@@ -245,7 +245,7 @@ class CategoryReportController extends Controller$chartData[$spentKey] ??= ['label' => sprintf('%s (%s)',- (string)trans('firefly.earned_in_specific_category', ['category' => $category->name]),+ (string) trans('firefly.earned_in_specific_category', ['category' => $category->name]),$currency['currency_name']),'type' => 'bar',diff --git a/app/Http/Controllers/Chart/DoubleReportController.php b/app/Http/Controllers/Chart/DoubleReportController.phpindex fd367bcd7c..159b6dfefa 100644--- a/app/Http/Controllers/Chart/DoubleReportController.php+++ b/app/Http/Controllers/Chart/DoubleReportController.php@@ -164,7 +164,7 @@ class DoubleReportController extends Controller$chartData[$spentKey] ??= ['label' => sprintf('%s (%s)',- (string)trans('firefly.spent_in_specific_double', ['account' => $name]),+ (string) trans('firefly.spent_in_specific_double', ['account' => $name]),$currency['currency_name']),'type' => 'bar',@@ -190,7 +190,7 @@ class DoubleReportController extends Controller$chartData[$earnedKey] ??= ['label' => sprintf('%s (%s)',- (string)trans('firefly.earned_in_specific_double', ['account' => $name]),+ (string) trans('firefly.earned_in_specific_double', ['account' => $name]),$currency['currency_name']),'type' => 'bar',diff --git a/app/Http/Controllers/Chart/ExpenseReportController.php b/app/Http/Controllers/Chart/ExpenseReportController.phpindex ec1ff4e84f..7b3997759a 100644--- a/app/Http/Controllers/Chart/ExpenseReportController.php+++ b/app/Http/Controllers/Chart/ExpenseReportController.php@@ -103,27 +103,27 @@ class ExpenseReportController extends Controller/** @var Account $exp */$exp = $combination->first();$chartData[$exp->id.'-in'] = [- 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.income')),+ 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.income')),'type' => 'bar','yAxisID' => 'y-axis-0','entries' => [],];$chartData[$exp->id.'-out'] = [- 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.expenses')),+ 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.expenses')),'type' => 'bar','yAxisID' => 'y-axis-0','entries' => [],];// total in, total out:$chartData[$exp->id.'-total-in'] = [- 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.sum_of_income')),+ 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.sum_of_income')),'type' => 'line','fill' => false,'yAxisID' => 'y-axis-1','entries' => [],];$chartData[$exp->id.'-total-out'] = [- 'label' => sprintf('%s (%s)', $name, (string)trans('firefly.sum_of_expenses')),+ 'label' => sprintf('%s (%s)', $name, (string) trans('firefly.sum_of_expenses')),'type' => 'line','fill' => false,'yAxisID' => 'y-axis-1',diff --git a/app/Http/Controllers/Chart/PiggyBankController.php b/app/Http/Controllers/Chart/PiggyBankController.phpindex 7bbfd0aae0..661c362394 100644--- a/app/Http/Controllers/Chart/PiggyBankController.php+++ b/app/Http/Controllers/Chart/PiggyBankController.php@@ -95,7 +95,7 @@ class PiggyBankController extends Controller});$currentSum = $filtered->sum('amount');- $label = $oldest->isoFormat((string)trans('config.month_and_day_js', [], $locale));+ $label = $oldest->isoFormat((string) trans('config.month_and_day_js', [], $locale));$chartData[$label] = $currentSum;$oldest = app('navigation')->addPeriod($oldest, $step, 0);}@@ -105,7 +105,7 @@ class PiggyBankController extends Controller});$finalSum = $finalFiltered->sum('amount');- $finalLabel = $today->isoFormat((string)trans('config.month_and_day_js', [], $locale));+ $finalLabel = $today->isoFormat((string) trans('config.month_and_day_js', [], $locale));$chartData[$finalLabel] = $finalSum;$data = $this->generator->singleSet($piggyBank->name, $chartData);diff --git a/app/Http/Controllers/Chart/ReportController.php b/app/Http/Controllers/Chart/ReportController.phpindex 7aef5e0a4c..7c5db3052e 100644--- a/app/Http/Controllers/Chart/ReportController.php+++ b/app/Http/Controllers/Chart/ReportController.php@@ -109,7 +109,7 @@ class ReportController extends Controllercontinue;}$currencyId = $netWorthItem['currency_id'];- $label = $current->isoFormat((string)trans('config.month_and_day_js', [], $locale));+ $label = $current->isoFormat((string) trans('config.month_and_day_js', [], $locale));if (!array_key_exists($currencyId, $chartData)) {$chartData[$currencyId] = ['label' => 'Net worth in '.$netWorthItem['currency_name'],@@ -175,13 +175,13 @@ class ReportController extends Controller/** @var array $journal */foreach ($journals as $journal) {$period = $journal['date']->format($format);- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$data[$currencyId] ??= ['currency_id' => $currencyId,'currency_symbol' => $journal['currency_symbol'],'currency_code' => $journal['currency_code'],'currency_name' => $journal['currency_name'],- 'currency_decimal_places' => (int)$journal['currency_decimal_places'],+ 'currency_decimal_places' => (int) $journal['currency_decimal_places'],];$data[$currencyId][$period] ??= ['period' => $period,@@ -198,8 +198,8 @@ class ReportController extends ControllerTransactionTypeEnum::DEPOSIT->value === $journal['transaction_type_type']|| ((TransactionTypeEnum::TRANSFER->value === $journal['transaction_type_type']- || TransactionTypeEnum::RECONCILIATION->value === $journal['transaction_type_type']- || TransactionTypeEnum::OPENING_BALANCE->value === $journal['transaction_type_type']+ || TransactionTypeEnum::RECONCILIATION->value === $journal['transaction_type_type']+ || TransactionTypeEnum::OPENING_BALANCE->value === $journal['transaction_type_type'])&& in_array($journal['destination_account_id'], $ids, true))) {$key = 'earned';@@ -214,7 +214,7 @@ class ReportController extends Controllerforeach ($data as $currency) {Log::debug(sprintf('Now processing currency "%s"', $currency['currency_name']));$income = [- 'label' => (string)trans('firefly.box_earned_in_currency', ['currency' => $currency['currency_name']]),+ 'label' => (string) trans('firefly.box_earned_in_currency', ['currency' => $currency['currency_name']]),'type' => 'bar','backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green'currency_id' => $currency['currency_id'],@@ -223,7 +223,7 @@ class ReportController extends Controller'entries' => [],];$expense = [- 'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),+ 'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $currency['currency_name']]),'type' => 'bar','backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red'currency_id' => $currency['currency_id'],diff --git a/app/Http/Controllers/Chart/TagReportController.php b/app/Http/Controllers/Chart/TagReportController.phpindex 2d12c01539..5bea78116c 100644--- a/app/Http/Controllers/Chart/TagReportController.php+++ b/app/Http/Controllers/Chart/TagReportController.php@@ -222,7 +222,7 @@ class TagReportController extends Controller$chartData[$spentKey] ??= ['label' => sprintf('%s (%s)',- (string)trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]),+ (string) trans('firefly.spent_in_specific_tag', ['tag' => $tag->tag]),$currency['currency_name']),'type' => 'bar',@@ -249,7 +249,7 @@ class TagReportController extends Controller$chartData[$spentKey] ??= ['label' => sprintf('%s (%s)',- (string)trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]),+ (string) trans('firefly.earned_in_specific_tag', ['tag' => $tag->tag]),$currency['currency_name']),'type' => 'bar',diff --git a/app/Http/Controllers/Chart/TransactionController.php b/app/Http/Controllers/Chart/TransactionController.phpindex d587d58024..fad9dc67fe 100644--- a/app/Http/Controllers/Chart/TransactionController.php+++ b/app/Http/Controllers/Chart/TransactionController.php@@ -74,7 +74,7 @@ class TransactionController extends Controller// group by category./** @var array $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']);$data[$title] ??= ['amount' => '0',@@ -124,7 +124,7 @@ class TransactionController extends Controller// group by category./** @var array $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']);$data[$title] ??= ['amount' => '0',diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.phpindex c5db5b85f7..f2677042b2 100644--- a/app/Http/Controllers/Controller.php+++ b/app/Http/Controllers/Controller.php@@ -29,6 +29,7 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;use Illuminate\Foundation\Bus\DispatchesJobs;use Illuminate\Foundation\Validation\ValidatesRequests;use Illuminate\Routing\Controller as BaseController;+use Route;/*** Class Controller.@@ -59,7 +60,7 @@ abstract class Controller extends BaseController{// is site a demo site?$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('DEMO_USERNAME', config('firefly.demo_username'));app('view')->share('DEMO_PASSWORD', config('firefly.demo_password'));@@ -69,8 +70,8 @@ abstract class Controller extends BaseControllerapp('view')->share('featuringWebhooks', true === config('firefly.feature_flags.webhooks') && true === config('firefly.allow_webhooks'));// share custom auth guard info.- $authGuard = config('firefly.authentication_guard');- $logoutUrl = config('firefly.custom_logout_url');+ $authGuard = config('firefly.authentication_guard');+ $logoutUrl = config('firefly.custom_logout_url');// overrule v2 layout back to v1.if ('true' === request()->get('force_default_layout') && 'v2' === config('view.layout')) {@@ -81,18 +82,18 @@ abstract class Controller extends BaseControllerapp('view')->share('logoutUrl', $logoutUrl);// upload size- $maxFileSize = app('steam')->phpBytes((string)ini_get('upload_max_filesize'));- $maxPostSize = app('steam')->phpBytes((string)ini_get('post_max_size'));- $uploadSize = min($maxFileSize, $maxPostSize);+ $maxFileSize = app('steam')->phpBytes((string) ini_get('upload_max_filesize'));+ $maxPostSize = app('steam')->phpBytes((string) ini_get('post_max_size'));+ $uploadSize = min($maxFileSize, $maxPostSize);app('view')->share('uploadSize', $uploadSize);// share is alpha, is beta- $isAlpha = false;+ $isAlpha = false;if (str_contains(config('firefly.version'), 'alpha')) {$isAlpha = true;}- $isBeta = false;+ $isBeta = false;if (str_contains(config('firefly.version'), 'beta')) {$isBeta = true;}@@ -102,11 +103,11 @@ abstract class Controller extends BaseController$this->middleware(function ($request, $next): mixed {- $locale = app('steam')->getLocale();+ $locale = app('steam')->getLocale();// translations for specific strings:- $this->monthFormat = (string)trans('config.month_js', [], $locale);- $this->monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);- $this->dateTimeFormat = (string)trans('config.date_time_js', [], $locale);+ $this->monthFormat = (string) trans('config.month_js', [], $locale);+ $this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);+ $this->dateTimeFormat = (string) trans('config.date_time_js', [], $locale);$darkMode = 'browser';// get shown-intro-preference:if (auth()->check()) {@@ -119,7 +120,7 @@ abstract class Controller extends BaseControllerapp('view')->share('locale', $locale);app('view')->share('shownDemo', $shownDemo);app('view')->share('current_route_name', $page);- app('view')->share('original_route_name', \Route::currentRouteName());+ app('view')->share('original_route_name', Route::currentRouteName());}app('view')->share('darkMode', $darkMode);diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.phpindex 5b082a1981..5ddecb5bca 100644--- a/app/Http/Controllers/DebugController.php+++ b/app/Http/Controllers/DebugController.php@@ -138,7 +138,7 @@ class DebugController extends Controller}if ('' !== $logContent) {// last few lines- $logContent = 'Truncated from this point <----|'.substr((string)$logContent, -16384);+ $logContent = 'Truncated from this point <----|'.substr((string) $logContent, -16384);}return view('debug', compact('table', 'now', 'logContent'));@@ -152,13 +152,13 @@ class DebugController extends Controller$app = $this->getAppInfo();$user = $this->getuserInfo();- return (string)view('partials.debug-table', compact('system', 'docker', 'app', 'user'));+ return (string) view('partials.debug-table', compact('system', 'docker', 'app', 'user'));}private function getSystemInformation(): array{- $maxFileSize = app('steam')->phpBytes((string)ini_get('upload_max_filesize'));- $maxPostSize = app('steam')->phpBytes((string)ini_get('post_max_size'));+ $maxFileSize = app('steam')->phpBytes((string) ini_get('upload_max_filesize'));+ $maxPostSize = app('steam')->phpBytes((string) ini_get('post_max_size'));$drivers = \DB::availableDrivers();$currentDriver = \DB::getDriverName();@@ -171,7 +171,7 @@ class DebugController extends Controller'bits' => \PHP_INT_SIZE * 8,'bcscale' => bcscale(),'display_errors' => ini_get('display_errors'),- 'error_reporting' => $this->errorReporting((int)ini_get('error_reporting')),+ 'error_reporting' => $this->errorReporting((int) ini_get('error_reporting')),'upload_size' => min($maxFileSize, $maxPostSize),'all_drivers' => $drivers,'current_driver' => $currentDriver,@@ -190,7 +190,7 @@ class DebugController extends Controllertry {if (file_exists('/var/www/counter-main.txt')) {- $return['build'] = trim((string)file_get_contents('/var/www/counter-main.txt'));+ $return['build'] = trim((string) file_get_contents('/var/www/counter-main.txt'));app('log')->debug(sprintf('build is now "%s"', $return['build']));}} catch (\Exception $e) { // @phpstan-ignore-line@@ -200,16 +200,16 @@ class DebugController extends Controllertry {if (file_exists('/var/www/build-date-main.txt')) {- $return['build_date'] = trim((string)file_get_contents('/var/www/build-date-main.txt'));+ $return['build_date'] = trim((string) file_get_contents('/var/www/build-date-main.txt'));}} catch (\Exception $e) { // @phpstan-ignore-lineapp('log')->debug('Could not check build date, but thats ok.');app('log')->warning($e->getMessage());}- if ('' !== (string)env('BASE_IMAGE_BUILD')) {+ if ('' !== (string) env('BASE_IMAGE_BUILD')) {$return['base_build'] = env('BASE_IMAGE_BUILD');}- if ('' !== (string)env('BASE_IMAGE_DATE')) {+ if ('' !== (string) env('BASE_IMAGE_DATE')) {$return['base_build_date'] = env('BASE_IMAGE_DATE');}@@ -221,7 +221,7 @@ class DebugController extends Controller$userGuard = config('auth.defaults.guard');$config = app('fireflyconfig')->get('last_rt_job', 0);- $lastTime = (int)$config->data;+ $lastTime = (int) $config->data;$lastCronjob = 'never';$lastCronjobAgo = 'never';if ($lastTime > 0) {@@ -233,8 +233,8 @@ class DebugController extends Controllerreturn ['debug' => var_export(config('app.debug'), true),'audit_log_channel' => envNonEmpty('AUDIT_LOG_CHANNEL', '(empty)'),- 'default_language' => (string)config('firefly.default_language'),- 'default_locale' => (string)config('firefly.default_locale'),+ 'default_language' => (string) config('firefly.default_language'),+ 'default_locale' => (string) config('firefly.default_locale'),'remote_header' => 'remote_user_guard' === $userGuard ? config('auth.guard_header') : 'N/A','remote_mail_header' => 'remote_user_guard' === $userGuard ? config('auth.guard_email') : 'N/A','stateful_domains' => implode(', ', config('sanctum.stateful')),@@ -265,7 +265,7 @@ class DebugController extends Controller$result = setlocale(LC_ALL, $code);$localeAttempts[$code] = $result === $code;}- setlocale(LC_ALL, (string)$original);+ setlocale(LC_ALL, (string) $original);return ['user_id' => auth()->user()->id,diff --git a/app/Http/Controllers/Export/IndexController.php b/app/Http/Controllers/Export/IndexController.phpindex 91da4e515e..267f827a27 100644--- a/app/Http/Controllers/Export/IndexController.php+++ b/app/Http/Controllers/Export/IndexController.php@@ -52,7 +52,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-life-bouy');- app('view')->share('title', (string)trans('firefly.export_data_title'));+ app('view')->share('title', (string) trans('firefly.export_data_title'));$this->journalRepository = app(JournalRepositoryInterface::class);$this->middleware(IsDemoUser::class)->except(['index']);@@ -67,7 +67,7 @@ class IndexController extends Controllerpublic function export(): LaravelResponse|RedirectResponse{if (auth()->user()->hasRole('demo')) {- session()->flash('info', (string)trans('firefly.demo_user_export'));+ session()->flash('info', (string) trans('firefly.demo_user_export'));return redirect(route('export.index'));}@@ -103,7 +103,7 @@ class IndexController extends Controller->header('Expires', '0')->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')->header('Pragma', 'public')- ->header('Content-Length', (string)strlen($result['transactions']))+ ->header('Content-Length', (string) strlen($result['transactions']));// return CSV file made from 'transactions' array.diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.phpindex ec31f0cdb2..3321e37fce 100644--- a/app/Http/Controllers/JavascriptController.php+++ b/app/Http/Controllers/JavascriptController.php@@ -55,7 +55,7 @@ class JavascriptController extends Controller/** @var Account $account */foreach ($accounts as $account) {$accountId = $account->id;- $currency = (int)$repository->getMetaValue($account, 'currency_id');+ $currency = (int) $repository->getMetaValue($account, 'currency_id');$currency = 0 === $currency ? $default->id : $currency;$entry = ['preferredCurrency' => $currency, 'name' => $account->name];$data['accounts'][$accountId] = $entry;@@ -95,7 +95,7 @@ class JavascriptController extends Controller* */public function variables(Request $request, AccountRepositoryInterface $repository): Response{- $account = $repository->find((int)$request->get('account'));+ $account = $repository->find((int) $request->get('account'));$currency = app('amount')->getDefaultCurrency();if (null !== $account) {$currency = $repository->getAccountCurrency($account) ?? $currency;@@ -106,7 +106,7 @@ class JavascriptController extends Controller$pref = app('preferences')->get('language', config('firefly.default_language', 'en_US'));$lang = $pref->data;$dateRange = $this->getDateRangeConfig();- $uid = substr(hash('sha256', sprintf('%s-%s-%s', (string)config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12);+ $uid = substr(hash('sha256', sprintf('%s-%s-%s', (string) config('app.key'), auth()->user()->id, auth()->user()->email)), 0, 12);$data = ['currencyCode' => $currency->code,'currencySymbol' => $currency->symbol,diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.phpindex 4e9ec22d24..4a26d048d0 100644--- a/app/Http/Controllers/Json/BoxController.php+++ b/app/Http/Controllers/Json/BoxController.php@@ -72,7 +72,7 @@ class BoxController extends Controller$end = session('end', today(config('app.timezone'))->endOfMonth());$today = today(config('app.timezone'));$display = 2; // see method docs.- $boxTitle = (string)trans('firefly.spent');+ $boxTitle = (string) trans('firefly.spent');$cache = new CacheProperties();$cache->addProperty($start);@@ -113,24 +113,24 @@ class BoxController extends Controller$spentAmount = $spent[$currency->id]['sum'] ?? '0';app('log')->debug(sprintf('Spent for default currency for all budgets in this period: %s', $spentAmount));- $days = (int)($today->between($start, $end) ? $today->diffInDays($start, true) + 1 : $end->diffInDays($start, true) + 1);+ $days = (int) ($today->between($start, $end) ? $today->diffInDays($start, true) + 1 : $end->diffInDays($start, true) + 1);app('log')->debug(sprintf('Number of days left: %d', $days));- $spentPerDay = bcdiv($spentAmount, (string)$days);+ $spentPerDay = bcdiv($spentAmount, (string) $days);app('log')->debug(sprintf('Available to spend per day: %s', $spentPerDay));if ($availableBudgets->count() > 0) {$display = 0; // assume user overspent- $boxTitle = (string)trans('firefly.overspent');- $totalAvailableSum = (string)$availableBudgets->sum('amount');+ $boxTitle = (string) trans('firefly.overspent');+ $totalAvailableSum = (string) $availableBudgets->sum('amount');app('log')->debug(sprintf('Total available sum is %s', $totalAvailableSum));// calculate with available budget.$leftToSpendAmount = bcadd($totalAvailableSum, $spentAmount);app('log')->debug(sprintf('So left to spend is %s', $leftToSpendAmount));if (bccomp($leftToSpendAmount, '0') >= 0) {app('log')->debug('Left to spend is positive or zero!');- $boxTitle = (string)trans('firefly.left_to_spend');+ $boxTitle = (string) trans('firefly.left_to_spend');$activeDaysLeft = $this->activeDaysLeft($start, $end); // see method description.$display = 1; // not overspent- $leftPerDayAmount = 0 === $activeDaysLeft ? $leftToSpendAmount : bcdiv($leftToSpendAmount, (string)$activeDaysLeft);+ $leftPerDayAmount = 0 === $activeDaysLeft ? $leftToSpendAmount : bcdiv($leftToSpendAmount, (string) $activeDaysLeft);app('log')->debug(sprintf('Left to spend per day is %s', $leftPerDayAmount));}}@@ -185,7 +185,7 @@ class BoxController extends Controller/** @var array $journal */foreach ($set as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$amount = $journal['amount'] ?? '0';$incomes[$currencyId] ??= '0';$incomes[$currencyId] = bcadd($incomes[$currencyId], app('steam')->positive($amount));@@ -203,7 +203,7 @@ class BoxController extends Controller/** @var array $journal */foreach ($set as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$expenses[$currencyId] ??= '0';$expenses[$currencyId] = bcadd($expenses[$currencyId], $journal['amount'] ?? '0');$sums[$currencyId] ??= '0';diff --git a/app/Http/Controllers/Json/BudgetController.php b/app/Http/Controllers/Json/BudgetController.phpindex 10479402f3..ca72b59698 100644--- a/app/Http/Controllers/Json/BudgetController.php+++ b/app/Http/Controllers/Json/BudgetController.php@@ -53,7 +53,7 @@ class BudgetController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.budgets'));+ app('view')->share('title', (string) trans('firefly.budgets'));app('view')->share('mainTitleIcon', 'fa-pie-chart');$this->repository = app(BudgetRepositoryInterface::class);$this->abRepository = app(AvailableBudgetRepositoryInterface::class);diff --git a/app/Http/Controllers/Json/FrontpageController.php b/app/Http/Controllers/Json/FrontpageController.phpindex 959c1ce4e6..8a42fbcf16 100644--- a/app/Http/Controllers/Json/FrontpageController.php+++ b/app/Http/Controllers/Json/FrontpageController.php@@ -51,7 +51,7 @@ class FrontpageController extends Controller// percentage!$pct = 0;if (0 !== bccomp($piggyBank->target_amount, '0')) {- $pct = (int)bcmul(bcdiv($amount, $piggyBank->target_amount), '100');+ $pct = (int) bcmul(bcdiv($amount, $piggyBank->target_amount), '100');}$entry = [diff --git a/app/Http/Controllers/Json/IntroController.php b/app/Http/Controllers/Json/IntroController.phpindex df92e6cf0a..6ea2ca32d2 100644--- a/app/Http/Controllers/Json/IntroController.php+++ b/app/Http/Controllers/Json/IntroController.php@@ -103,7 +103,7 @@ class IntroController extends Controllerapp('preferences')->set($key, false);app('preferences')->mark();- return response()->json(['message' => (string)trans('firefly.intro_boxes_after_refresh')]);+ return response()->json(['message' => (string) trans('firefly.intro_boxes_after_refresh')]);}/**diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.phpindex d6f2408772..3f4c8b90ad 100644--- a/app/Http/Controllers/Json/ReconcileController.php+++ b/app/Http/Controllers/Json/ReconcileController.php@@ -55,7 +55,7 @@ class ReconcileController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-credit-card');- app('view')->share('title', (string)trans('firefly.accounts'));+ app('view')->share('title', (string) trans('firefly.accounts'));$this->accountRepos = app(AccountRepositoryInterface::class);return $next($request);diff --git a/app/Http/Controllers/Json/RecurrenceController.php b/app/Http/Controllers/Json/RecurrenceController.phpindex 41369d0825..b423ec53ea 100644--- a/app/Http/Controllers/Json/RecurrenceController.php+++ b/app/Http/Controllers/Json/RecurrenceController.php@@ -72,13 +72,13 @@ class RecurrenceController extends Controller$start = Carbon::createFromFormat('Y-m-d', $request->get('start'));$end = Carbon::createFromFormat('Y-m-d', $request->get('end'));$firstDate = Carbon::createFromFormat('Y-m-d', $request->get('first_date'));- $endDate = '' !== (string)$request->get('end_date') ? Carbon::createFromFormat('Y-m-d', $request->get('end_date')) : null;- $endsAt = (string)$request->get('ends');+ $endDate = '' !== (string) $request->get('end_date') ? Carbon::createFromFormat('Y-m-d', $request->get('end_date')) : null;+ $endsAt = (string) $request->get('ends');$repetitionType = explode(',', $request->get('type'))[0];- $repetitions = (int)$request->get('reps');- $weekend = (int)$request->get('weekend');+ $repetitions = (int) $request->get('reps');+ $weekend = (int) $request->get('weekend');$repetitionMoment = '';- $skip = (int)$request->get('skip');+ $skip = (int) $request->get('skip');$skip = $skip < 0 || $skip > 31 ? 0 : $skip;$weekend = $weekend < 1 || $weekend > 4 ? 1 : $weekend;@@ -153,7 +153,7 @@ class RecurrenceController extends Controller*/public function suggest(Request $request): JsonResponse{- $string = '' === (string)$request->get('date') ? date('Y-m-d') : (string)$request->get('date');+ $string = '' === (string) $request->get('date') ? date('Y-m-d') : (string) $request->get('date');$today = today(config('app.timezone'))->startOfDay();try {@@ -165,37 +165,37 @@ class RecurrenceController extends Controllerreturn response()->json();}$date->startOfDay();- $preSelected = (string)$request->get('pre_select');+ $preSelected = (string) $request->get('pre_select');$locale = app('steam')->getLocale();app('log')->debug(sprintf('date = %s, today = %s. date > today? %s', $date->toAtomString(), $today->toAtomString(), var_export($date > $today, true)));- app('log')->debug(sprintf('past = true? %s', var_export('true' === (string)$request->get('past'), true)));+ app('log')->debug(sprintf('past = true? %s', var_export('true' === (string) $request->get('past'), true)));$result = [];- if ($date > $today || 'true' === (string)$request->get('past')) {+ if ($date > $today || 'true' === (string) $request->get('past')) {app('log')->debug('Will fill dropdown.');$weekly = sprintf('weekly,%s', $date->dayOfWeekIso);$monthly = sprintf('monthly,%s', $date->day);- $dayOfWeek = (string)trans(sprintf('config.dow_%s', $date->dayOfWeekIso));+ $dayOfWeek = (string) trans(sprintf('config.dow_%s', $date->dayOfWeekIso));$ndom = sprintf('ndom,%s,%s', $date->weekOfMonth, $date->dayOfWeekIso);$yearly = sprintf('yearly,%s', $date->format('Y-m-d'));- $yearlyDate = $date->isoFormat((string)trans('config.month_and_day_no_year_js', [], $locale));+ $yearlyDate = $date->isoFormat((string) trans('config.month_and_day_no_year_js', [], $locale));$result = [- 'daily' => ['label' => (string)trans('firefly.recurring_daily'), 'selected' => str_starts_with($preSelected, 'daily')],+ 'daily' => ['label' => (string) trans('firefly.recurring_daily'), 'selected' => str_starts_with($preSelected, 'daily')],$weekly => [- 'label' => (string)trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]),+ 'label' => (string) trans('firefly.recurring_weekly', ['weekday' => $dayOfWeek]),'selected' => str_starts_with($preSelected, 'weekly'),],$monthly => [- 'label' => (string)trans('firefly.recurring_monthly', ['dayOfMonth' => $date->day]),+ 'label' => (string) trans('firefly.recurring_monthly', ['dayOfMonth' => $date->day]),'selected' => str_starts_with($preSelected, 'monthly'),],$ndom => [- 'label' => (string)trans('firefly.recurring_ndom', ['weekday' => $dayOfWeek, 'dayOfMonth' => $date->weekOfMonth]),+ 'label' => (string) trans('firefly.recurring_ndom', ['weekday' => $dayOfWeek, 'dayOfMonth' => $date->weekOfMonth]),'selected' => str_starts_with($preSelected, 'ndom'),],$yearly => [- 'label' => (string)trans('firefly.recurring_yearly', ['date' => $yearlyDate]),+ 'label' => (string) trans('firefly.recurring_yearly', ['date' => $yearlyDate]),'selected' => str_starts_with($preSelected, 'yearly'),],];diff --git a/app/Http/Controllers/Json/RuleController.php b/app/Http/Controllers/Json/RuleController.phpindex dab72c3cb1..c91fb1c1e3 100644--- a/app/Http/Controllers/Json/RuleController.php+++ b/app/Http/Controllers/Json/RuleController.php@@ -41,11 +41,11 @@ class RuleController extends Controller*/public function action(Request $request): JsonResponse{- $count = (int)$request->get('count') > 0 ? (int)$request->get('count') : 1;+ $count = (int) $request->get('count') > 0 ? (int) $request->get('count') : 1;$keys = array_keys(config('firefly.rule-actions'));$actions = [];foreach ($keys as $key) {- $actions[$key] = (string)trans('firefly.rule_action_'.$key.'_choice');+ $actions[$key] = (string) trans('firefly.rule_action_'.$key.'_choice');}try {@@ -68,12 +68,12 @@ class RuleController extends Controller*/public function trigger(Request $request): JsonResponse{- $count = (int)$request->get('count') > 0 ? (int)$request->get('count') : 1;+ $count = (int) $request->get('count') > 0 ? (int) $request->get('count') : 1;$operators = config('search.operators');$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.phpindex 2fd5e1e70b..08ebad3a43 100644--- a/app/Http/Controllers/NewUserController.php+++ b/app/Http/Controllers/NewUserController.php@@ -66,7 +66,7 @@ class NewUserController extends Controller*/public function index(){- app('view')->share('title', (string)trans('firefly.welcome'));+ app('view')->share('title', (string) trans('firefly.welcome'));app('view')->share('mainTitleIcon', 'fa-fire');$types = config('firefly.accountTypesByIdentifier.asset');@@ -98,7 +98,7 @@ class NewUserController extends Controller// set language preference:app('preferences')->set('language', $language);// Store currency preference from input:- $currency = $currencyRepository->find((int)$request->input('amount_currency_id_bank_balance'));+ $currency = $currencyRepository->find((int) $request->input('amount_currency_id_bank_balance'));// if is null, set to EUR:if (null === $currency) {@@ -134,7 +134,7 @@ class NewUserController extends Controller];app('preferences')->set('transaction_journal_optional_fields', $visibleFields);- session()->flash('success', (string)trans('firefly.stored_new_accounts_new_user'));+ session()->flash('success', (string) trans('firefly.stored_new_accounts_new_user'));app('preferences')->mark();return redirect(route('index'));diff --git a/app/Http/Controllers/ObjectGroup/DeleteController.php b/app/Http/Controllers/ObjectGroup/DeleteController.phpindex f9115ec7f4..4a6c97181c 100644--- a/app/Http/Controllers/ObjectGroup/DeleteController.php+++ b/app/Http/Controllers/ObjectGroup/DeleteController.php@@ -48,7 +48,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-envelope-o');- app('view')->share('title', (string)trans('firefly.object_groups_page_title'));+ app('view')->share('title', (string) trans('firefly.object_groups_page_title'));$this->repository = app(ObjectGroupRepositoryInterface::class);@@ -64,7 +64,7 @@ class DeleteController extends Controller*/public function delete(ObjectGroup $objectGroup){- $subTitle = (string)trans('firefly.delete_object_group', ['title' => $objectGroup->title]);+ $subTitle = (string) trans('firefly.delete_object_group', ['title' => $objectGroup->title]);$piggyBanks = $objectGroup->piggyBanks()->count();// put previous url in session@@ -78,7 +78,7 @@ class DeleteController extends Controller*/public function destroy(ObjectGroup $objectGroup): RedirectResponse{- session()->flash('success', (string)trans('firefly.deleted_object_group', ['title' => $objectGroup->title]));+ session()->flash('success', (string) trans('firefly.deleted_object_group', ['title' => $objectGroup->title]));app('preferences')->mark();$this->repository->destroy($objectGroup);diff --git a/app/Http/Controllers/ObjectGroup/EditController.php b/app/Http/Controllers/ObjectGroup/EditController.phpindex e85ffac6a6..62be1e1edb 100644--- a/app/Http/Controllers/ObjectGroup/EditController.php+++ b/app/Http/Controllers/ObjectGroup/EditController.php@@ -51,7 +51,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-envelope-o');- app('view')->share('title', (string)trans('firefly.object_groups_page_title'));+ app('view')->share('title', (string) trans('firefly.object_groups_page_title'));$this->repository = app(ObjectGroupRepositoryInterface::class);@@ -67,7 +67,7 @@ class EditController extends Controller*/public function edit(ObjectGroup $objectGroup){- $subTitle = (string)trans('firefly.edit_object_group', ['title' => $objectGroup->title]);+ $subTitle = (string) trans('firefly.edit_object_group', ['title' => $objectGroup->title]);$subTitleIcon = 'fa-pencil';if (true !== session('object-groups.edit.fromUpdate')) {@@ -88,12 +88,12 @@ class EditController extends Controller$data = $request->getObjectGroupData();$piggyBank = $this->repository->update($objectGroup, $data);- session()->flash('success', (string)trans('firefly.updated_object_group', ['title' => $objectGroup->title]));+ session()->flash('success', (string) trans('firefly.updated_object_group', ['title' => $objectGroup->title]));app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('object-groups.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {session()->put('object-groups.edit.fromUpdate', true);$redirect = redirect(route('object-groups.edit', [$piggyBank->id]));diff --git a/app/Http/Controllers/ObjectGroup/IndexController.php b/app/Http/Controllers/ObjectGroup/IndexController.phpindex 168b3ea601..6cddb20792 100644--- a/app/Http/Controllers/ObjectGroup/IndexController.php+++ b/app/Http/Controllers/ObjectGroup/IndexController.php@@ -50,7 +50,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-envelope-o');- app('view')->share('title', (string)trans('firefly.object_groups_page_title'));+ app('view')->share('title', (string) trans('firefly.object_groups_page_title'));$this->repository = app(ObjectGroupRepositoryInterface::class);return $next($request);@@ -65,7 +65,7 @@ class IndexController extends Controller{$this->repository->deleteEmpty();$this->repository->resetOrder();- $subTitle = (string)trans('firefly.object_groups_index');+ $subTitle = (string) trans('firefly.object_groups_index');$objectGroups = $this->repository->get();return view('object-groups.index', compact('subTitle', 'objectGroups'));@@ -77,7 +77,7 @@ class IndexController extends Controllerpublic function setOrder(Request $request, ObjectGroup $objectGroup){app('log')->debug(sprintf('Found object group #%d "%s"', $objectGroup->id, $objectGroup->title));- $newOrder = (int)$request->get('order');+ $newOrder = (int) $request->get('order');$this->repository->setOrder($objectGroup, $newOrder);return response()->json([]);diff --git a/app/Http/Controllers/PiggyBank/DeleteController.php b/app/Http/Controllers/PiggyBank/DeleteController.phpindex 754b62f01d..2ac0855b85 100644--- a/app/Http/Controllers/PiggyBank/DeleteController.php+++ b/app/Http/Controllers/PiggyBank/DeleteController.php@@ -47,7 +47,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.piggyBanks'));+ app('view')->share('title', (string) trans('firefly.piggyBanks'));app('view')->share('mainTitleIcon', 'fa-bullseye');$this->piggyRepos = app(PiggyBankRepositoryInterface::class);@@ -64,7 +64,7 @@ class DeleteController extends Controller*/public function delete(PiggyBank $piggyBank){- $subTitle = (string)trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]);+ $subTitle = (string) trans('firefly.delete_piggy_bank', ['name' => $piggyBank->name]);// put previous url in session$this->rememberPreviousUrl('piggy-banks.delete.url');@@ -77,7 +77,7 @@ class DeleteController extends Controller*/public function destroy(PiggyBank $piggyBank): RedirectResponse{- session()->flash('success', (string)trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));+ session()->flash('success', (string) trans('firefly.deleted_piggy_bank', ['name' => $piggyBank->name]));app('preferences')->mark();$this->piggyRepos->destroy($piggyBank);diff --git a/app/Http/Controllers/PiggyBank/EditController.php b/app/Http/Controllers/PiggyBank/EditController.phpindex 2d73e95e09..f7574e59d9 100644--- a/app/Http/Controllers/PiggyBank/EditController.php+++ b/app/Http/Controllers/PiggyBank/EditController.php@@ -54,7 +54,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.piggyBanks'));+ app('view')->share('title', (string) trans('firefly.piggyBanks'));app('view')->share('mainTitleIcon', 'fa-bullseye');$this->attachments = app(AttachmentHelperInterface::class);@@ -73,7 +73,7 @@ class EditController extends Controller*/public function edit(PiggyBank $piggyBank){- $subTitle = (string)trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);+ $subTitle = (string) trans('firefly.update_piggy_title', ['name' => $piggyBank->name]);$subTitleIcon = 'fa-pencil';$note = $piggyBank->notes()->first();// Flash some data to fill the form.@@ -116,7 +116,7 @@ class EditController extends Controller$data = $request->getPiggyBankData();$piggyBank = $this->piggyRepos->update($piggyBank, $data);- session()->flash('success', (string)trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name]));+ session()->flash('success', (string) trans('firefly.updated_piggy_bank', ['name' => $piggyBank->name]));app('preferences')->mark();// store new attachment(s):@@ -127,7 +127,7 @@ class EditController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {@@ -135,7 +135,7 @@ class EditController extends Controller}$redirect = redirect($this->getPreviousUrl('piggy-banks.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {session()->put('piggy-banks.edit.fromUpdate', true);$redirect = redirect(route('piggy-banks.edit', [$piggyBank->id]));diff --git a/app/Http/Controllers/PiggyBank/IndexController.php b/app/Http/Controllers/PiggyBank/IndexController.phpindex 55188f7841..d461ec49b5 100644--- a/app/Http/Controllers/PiggyBank/IndexController.php+++ b/app/Http/Controllers/PiggyBank/IndexController.php@@ -106,59 +106,6 @@ class IndexController extends Controllerreturn view('piggy-banks.index', compact('piggyBanks', 'accounts'));}- private function makeSums(array $piggyBanks): array- {- $sums = [];- foreach ($piggyBanks as $groupOrder => $group) {- $groupId = $group['object_group_id'];- foreach ($group['piggy_banks'] as $piggy) {- $currencyId = $piggy['currency_id'];- $sums[$groupId][$currencyId] ??= [- 'target' => '0',- 'saved' => '0',- 'left_to_save' => '0',- 'save_per_month' => '0',- 'currency_id' => $currencyId,- 'currency_code' => $piggy['currency_code'],- 'currency_symbol' => $piggy['currency_symbol'],- 'currency_decimal_places' => $piggy['currency_decimal_places'],- ];- // target_amount- // current_amount- // left_to_save- // save_per_month- $sums[$groupId][$currencyId]['target'] = bcadd($sums[$groupId][$currencyId]['target'], (string) $piggy['target_amount']);- $sums[$groupId][$currencyId]['saved'] = bcadd($sums[$groupId][$currencyId]['saved'], (string) $piggy['current_amount']);- $sums[$groupId][$currencyId]['left_to_save'] = bcadd($sums[$groupId][$currencyId]['left_to_save'], (string) $piggy['left_to_save']);- $sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string) $piggy['save_per_month']);- }- }- foreach ($piggyBanks as $groupOrder => $group) {- $groupId = $group['object_group_id'];- $piggyBanks[$groupOrder]['sums'] = $sums[$groupId] ?? [];- }-- return $piggyBanks;- }-- /**- * Set the order of a piggy bank.- */- public function setOrder(Request $request, PiggyBank $piggyBank): JsonResponse- {- $objectGroupTitle = (string) $request->get('objectGroupTitle');- $newOrder = (int) $request->get('order');- $this->piggyRepos->setOrder($piggyBank, $newOrder);- if ('' !== $objectGroupTitle) {- $this->piggyRepos->setObjectGroup($piggyBank, $objectGroupTitle);- }- if ('' === $objectGroupTitle) {- $this->piggyRepos->removeObjectGroup($piggyBank);- }-- return response()->json(['data' => 'OK']);- }-private function groupPiggyBanks(Collection $collection): array{/** @var PiggyBankTransformer $transformer */@@ -251,4 +198,57 @@ class IndexController extends Controllerreturn $accounts;}++ private function makeSums(array $piggyBanks): array+ {+ $sums = [];+ foreach ($piggyBanks as $groupOrder => $group) {+ $groupId = $group['object_group_id'];+ foreach ($group['piggy_banks'] as $piggy) {+ $currencyId = $piggy['currency_id'];+ $sums[$groupId][$currencyId] ??= [+ 'target' => '0',+ 'saved' => '0',+ 'left_to_save' => '0',+ 'save_per_month' => '0',+ 'currency_id' => $currencyId,+ 'currency_code' => $piggy['currency_code'],+ 'currency_symbol' => $piggy['currency_symbol'],+ 'currency_decimal_places' => $piggy['currency_decimal_places'],+ ];+ // target_amount+ // current_amount+ // left_to_save+ // save_per_month+ $sums[$groupId][$currencyId]['target'] = bcadd($sums[$groupId][$currencyId]['target'], (string) $piggy['target_amount']);+ $sums[$groupId][$currencyId]['saved'] = bcadd($sums[$groupId][$currencyId]['saved'], (string) $piggy['current_amount']);+ $sums[$groupId][$currencyId]['left_to_save'] = bcadd($sums[$groupId][$currencyId]['left_to_save'], (string) $piggy['left_to_save']);+ $sums[$groupId][$currencyId]['save_per_month'] = bcadd($sums[$groupId][$currencyId]['save_per_month'], (string) $piggy['save_per_month']);+ }+ }+ foreach ($piggyBanks as $groupOrder => $group) {+ $groupId = $group['object_group_id'];+ $piggyBanks[$groupOrder]['sums'] = $sums[$groupId] ?? [];+ }++ return $piggyBanks;+ }++ /**+ * Set the order of a piggy bank.+ */+ public function setOrder(Request $request, PiggyBank $piggyBank): JsonResponse+ {+ $objectGroupTitle = (string) $request->get('objectGroupTitle');+ $newOrder = (int) $request->get('order');+ $this->piggyRepos->setOrder($piggyBank, $newOrder);+ if ('' !== $objectGroupTitle) {+ $this->piggyRepos->setObjectGroup($piggyBank, $objectGroupTitle);+ }+ if ('' === $objectGroupTitle) {+ $this->piggyRepos->removeObjectGroup($piggyBank);+ }++ return response()->json(['data' => 'OK']);+ }}diff --git a/app/Http/Controllers/PiggyBank/ShowController.php b/app/Http/Controllers/PiggyBank/ShowController.phpindex b3bc52bc1c..d1a69a6c1c 100644--- a/app/Http/Controllers/PiggyBank/ShowController.php+++ b/app/Http/Controllers/PiggyBank/ShowController.php@@ -50,7 +50,7 @@ class ShowController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.piggyBanks'));+ app('view')->share('title', (string) trans('firefly.piggyBanks'));app('view')->share('mainTitleIcon', 'fa-bullseye');$this->piggyRepos = app(PiggyBankRepositoryInterface::class);diff --git a/app/Http/Controllers/Profile/MfaController.php b/app/Http/Controllers/Profile/MfaController.phpindex cba791f4fc..340d7240ef 100644--- a/app/Http/Controllers/Profile/MfaController.php+++ b/app/Http/Controllers/Profile/MfaController.php@@ -80,19 +80,59 @@ class MfaController extends Controller}- public function index(): Factory|RedirectResponse|View+ /**+ * @throws FireflyException+ */+ public function backupCodes(Request $request): Factory|RedirectResponse|View{if (!$this->internalAuth) {- request()->session()->flash('error', trans('firefly.external_user_mgt_disabled'));+ $request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));return redirect(route('profile.index'));}+ $enabledMFA = null !== auth()->user()->mfa_secret;+ if (false === $enabledMFA) {+ request()->session()->flash('info', trans('firefly.mfa_not_enabled'));- $subTitle = (string)trans('firefly.mfa_index_title');- $subTitleIcon = 'fa-calculator';- $enabledMFA = null !== auth()->user()->mfa_secret;+ return redirect(route('profile.index'));+ }++ return view('profile.mfa.backup-codes-intro');+ }++ public function backupCodesPost(ExistingTokenFormRequest $request): Redirector|RedirectResponse|View+ {+ if (!$this->internalAuth) {+ $request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));++ return redirect(route('profile.index'));+ }+ $enabledMFA = null !== auth()->user()->mfa_secret;+ if (false === $enabledMFA) {+ request()->session()->flash('info', trans('firefly.mfa_not_enabled'));++ return redirect(route('profile.index'));+ }+ // generate recovery codes:+ $recovery = app(Recovery::class);+ $recoveryCodes = $recovery->lowercase()+ ->setCount(8) // Generate 8 codes+ ->setBlocks(2) // Every code must have 2 blocks+ ->setChars(6) // Each block must have 6 chars+ ->toArray()+ ;+ $codes = implode("\r\n", $recoveryCodes);++ app('preferences')->set('mfa_recovery', $recoveryCodes);+ app('preferences')->mark();++ // send user notification.+ $user = auth()->user();+ Log::channel('audit')->info(sprintf('User "%s" has generated new backup codes.', $user->email));+ event(new MFANewBackupCodes($user));++ return view('profile.mfa.backup-codes-post')->with(compact('codes'));- return view('profile.mfa.index')->with(compact('subTitle', 'subTitleIcon', 'enabledMFA'));}public function disableMFA(Request $request): Factory|RedirectResponse|View@@ -108,7 +148,7 @@ class MfaController extends Controllerreturn redirect(route('profile.index'));}- $subTitle = (string)trans('firefly.mfa_index_title');+ $subTitle = (string) trans('firefly.mfa_index_title');$subTitleIcon = 'fa-calculator';return view('profile.mfa.disable-mfa')->with(compact('subTitle', 'subTitleIcon', 'enabledMFA'));@@ -180,66 +220,10 @@ class MfaController extends Controllerapp('preferences')->set('temp-mfa-secret', $secret);-return view('profile.mfa.enable-mfa', compact('image', 'secret'));}- public function backupCodesPost(ExistingTokenFormRequest $request): Redirector|RedirectResponse|View- {- if (!$this->internalAuth) {- $request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));-- return redirect(route('profile.index'));- }- $enabledMFA = null !== auth()->user()->mfa_secret;- if (false === $enabledMFA) {- request()->session()->flash('info', trans('firefly.mfa_not_enabled'));-- return redirect(route('profile.index'));- }- // generate recovery codes:- $recovery = app(Recovery::class);- $recoveryCodes = $recovery->lowercase()- ->setCount(8) // Generate 8 codes- ->setBlocks(2) // Every code must have 2 blocks- ->setChars(6) // Each block must have 6 chars- ->toArray()- ;- $codes = implode("\r\n", $recoveryCodes);-- app('preferences')->set('mfa_recovery', $recoveryCodes);- app('preferences')->mark();-- // send user notification.- $user = auth()->user();- Log::channel('audit')->info(sprintf('User "%s" has generated new backup codes.', $user->email));- event(new MFANewBackupCodes($user));-- return view('profile.mfa.backup-codes-post')->with(compact('codes'));-- }-- /**- * @throws FireflyException- */- public function backupCodes(Request $request): Factory|RedirectResponse|View- {- if (!$this->internalAuth) {- $request->session()->flash('error', trans('firefly.external_user_mgt_disabled'));-- return redirect(route('profile.index'));- }- $enabledMFA = null !== auth()->user()->mfa_secret;- if (false === $enabledMFA) {- request()->session()->flash('info', trans('firefly.mfa_not_enabled'));-- return redirect(route('profile.index'));- }-- return view('profile.mfa.backup-codes-intro');- }-/*** Submit 2FA for the first time.*@@ -340,4 +324,19 @@ class MfaController extends Controller}app('preferences')->set('mfa_history', $newHistory);}++ public function index(): Factory|RedirectResponse|View+ {+ if (!$this->internalAuth) {+ request()->session()->flash('error', trans('firefly.external_user_mgt_disabled'));++ return redirect(route('profile.index'));+ }++ $subTitle = (string) trans('firefly.mfa_index_title');+ $subTitleIcon = 'fa-calculator';+ $enabledMFA = null !== auth()->user()->mfa_secret;++ return view('profile.mfa.index')->with(compact('subTitle', 'subTitleIcon', 'enabledMFA'));+ }}diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.phpindex b270c86905..95136a1018 100644--- a/app/Http/Controllers/ProfileController.php+++ b/app/Http/Controllers/ProfileController.php@@ -65,7 +65,7 @@ class ProfileController extends Controller$this->middleware(static function ($request, $next) {- app('view')->share('title', (string)trans('firefly.profile'));+ app('view')->share('title', (string) trans('firefly.profile'));app('view')->share('mainTitleIcon', 'fa-user');return $next($request);@@ -107,7 +107,7 @@ class ProfileController extends Controller$repository->unblockUser($user);// return to log in.- session()->flash('success', (string)trans('firefly.login_with_new_email'));+ session()->flash('success', (string) trans('firefly.login_with_new_email'));return redirect(route('login'));}@@ -123,7 +123,7 @@ class ProfileController extends Controllerreturn redirect(route('profile.index'));}$title = auth()->user()->email;- $subTitle = (string)trans('firefly.delete_account');+ $subTitle = (string) trans('firefly.delete_account');$subTitleIcon = 'fa-trash';return view('profile.delete-account', compact('title', 'subTitle', 'subTitleIcon'));@@ -171,7 +171,7 @@ class ProfileController extends Controllerpublic function logoutOtherSessions(): Factory|RedirectResponse|View{if (!$this->internalAuth) {- session()->flash('info', (string)trans('firefly.external_auth_disabled'));+ session()->flash('info', (string) trans('firefly.external_auth_disabled'));return redirect(route('profile.index'));}@@ -195,7 +195,7 @@ class ProfileController extends Controller$newEmail = $request->convertString('email');$oldEmail = $user->email;if ($newEmail === $user->email) {- session()->flash('error', (string)trans('firefly.email_not_changed'));+ session()->flash('error', (string) trans('firefly.email_not_changed'));return redirect(route('profile.change-email'))->withInput();}@@ -205,7 +205,7 @@ class ProfileController extends Controller\Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)$request->session()->invalidate();- session()->flash('success', (string)trans('firefly.email_changed'));+ session()->flash('success', (string) trans('firefly.email_changed'));return redirect(route('index'));}@@ -218,7 +218,7 @@ class ProfileController extends Controller// force user logout.\Auth::guard()->logout(); // @phpstan-ignore-line (does not recognize function)$request->session()->invalidate();- session()->flash('success', (string)trans('firefly.email_changed'));+ session()->flash('success', (string) trans('firefly.email_changed'));return redirect(route('index'));}@@ -236,7 +236,7 @@ class ProfileController extends Controller$title = auth()->user()->email;$email = auth()->user()->email;- $subTitle = (string)trans('firefly.change_your_email');+ $subTitle = (string) trans('firefly.change_your_email');$subTitleIcon = 'fa-envelope';return view('profile.change-email', compact('title', 'subTitle', 'subTitleIcon', 'email'));@@ -271,7 +271,7 @@ class ProfileController extends Controller}$repository->changePassword($user, $request->get('new_password'));- session()->flash('success', (string)trans('firefly.password_changed'));+ session()->flash('success', (string) trans('firefly.password_changed'));return redirect(route('profile.index'));}@@ -290,7 +290,7 @@ class ProfileController extends Controller}$title = auth()->user()->email;- $subTitle = (string)trans('firefly.change_your_password');+ $subTitle = (string) trans('firefly.change_your_password');$subTitleIcon = 'fa-key';return view('profile.change-password', compact('title', 'subTitle', 'subTitleIcon'));@@ -310,7 +310,7 @@ class ProfileController extends Controller}if (!\Hash::check($request->get('password'), auth()->user()->password)) {- session()->flash('error', (string)trans('firefly.invalid_password'));+ session()->flash('error', (string) trans('firefly.invalid_password'));return redirect(route('profile.delete-account'));}@@ -334,7 +334,7 @@ class ProfileController extends Controllerpublic function postLogoutOtherSessions(Request $request){if (!$this->internalAuth) {- session()->flash('info', (string)trans('firefly.external_auth_disabled'));+ session()->flash('info', (string) trans('firefly.external_auth_disabled'));return redirect(route('profile.index'));}@@ -344,11 +344,11 @@ class ProfileController extends Controller];if (\Auth::once($creds)) {\Auth::logoutOtherDevices($request->get('password'));- session()->flash('info', (string)trans('firefly.other_sessions_logged_out'));+ session()->flash('info', (string) trans('firefly.other_sessions_logged_out'));return redirect(route('profile.index'));}- session()->flash('error', (string)trans('auth.failed'));+ session()->flash('error', (string) trans('auth.failed'));return redirect(route('profile.index'));}@@ -372,7 +372,7 @@ class ProfileController extends Controller$user = auth()->user();$token = $user->generateAccessToken();app('preferences')->set('access_token', $token);- session()->flash('success', (string)trans('firefly.token_regenerated'));+ session()->flash('success', (string) trans('firefly.token_regenerated'));return redirect(route('profile.index'));}@@ -410,7 +410,7 @@ class ProfileController extends Controller/** @var string $match */$match = null;foreach ($set as $entry) {- $hashed = hash('sha256', sprintf('%s%s', (string)config('app.key'), $entry->data));+ $hashed = hash('sha256', sprintf('%s%s', (string) config('app.key'), $entry->data));if ($hashed === $hash) {$match = $entry->data;@@ -426,7 +426,7 @@ class ProfileController extends Controller$repository->unblockUser($user);// return to login page.- session()->flash('success', (string)trans('firefly.login_with_old_email'));+ session()->flash('success', (string) trans('firefly.login_with_old_email'));return redirect(route('login'));}diff --git a/app/Http/Controllers/Recurring/CreateController.php b/app/Http/Controllers/Recurring/CreateController.phpindex 1faed7d0c5..c8c91df86b 100644--- a/app/Http/Controllers/Recurring/CreateController.php+++ b/app/Http/Controllers/Recurring/CreateController.php@@ -62,8 +62,8 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-paint-brush');- app('view')->share('title', (string)trans('firefly.recurrences'));- app('view')->share('subTitle', (string)trans('firefly.create_new_recurrence'));+ app('view')->share('title', (string) trans('firefly.recurrences'));+ app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence'));$this->recurring = app(RecurringRepositoryInterface::class);$this->budgetRepos = app(BudgetRepositoryInterface::class);@@ -95,22 +95,22 @@ class CreateController extends Controller}$request->session()->forget('recurring.create.fromStore');$repetitionEnds = [- 'forever' => (string)trans('firefly.repeat_forever'),- 'until_date' => (string)trans('firefly.repeat_until_date'),- 'times' => (string)trans('firefly.repeat_times'),+ 'forever' => (string) trans('firefly.repeat_forever'),+ 'until_date' => (string) trans('firefly.repeat_until_date'),+ 'times' => (string) trans('firefly.repeat_times'),];$weekendResponses = [- RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),- RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),- RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),- RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),+ RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),+ RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),+ RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),+ RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),];$hasOldInput = null !== $request->old('_token'); // flash some data$preFilled = ['first_date' => $tomorrow->format('Y-m-d'),'transaction_type' => $hasOldInput ? $request->old('transaction_type') : 'withdrawal',- 'active' => $hasOldInput ? (bool)$request->old('active') : true,- 'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : true,+ 'active' => $hasOldInput ? (bool) $request->old('active') : true,+ 'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : true,];$request->session()->flash('preFilled', $preFilled);@@ -140,15 +140,15 @@ class CreateController extends Controller}$request->session()->forget('recurring.create.fromStore');$repetitionEnds = [- 'forever' => (string)trans('firefly.repeat_forever'),- 'until_date' => (string)trans('firefly.repeat_until_date'),- 'times' => (string)trans('firefly.repeat_times'),+ 'forever' => (string) trans('firefly.repeat_forever'),+ 'until_date' => (string) trans('firefly.repeat_until_date'),+ 'times' => (string) trans('firefly.repeat_times'),];$weekendResponses = [- RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),- RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),- RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),- RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),+ RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),+ RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),+ RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),+ RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),];// fill prefilled with journal info@@ -181,8 +181,8 @@ class CreateController extends Controller'category' => $request->old('category'),'budget_id' => $request->old('budget_id'),'bill_id' => $request->old('bill_id'),- 'active' => (bool)$request->old('active'),- 'apply_rules' => (bool)$request->old('apply_rules'),+ 'active' => (bool) $request->old('active'),+ 'apply_rules' => (bool) $request->old('apply_rules'),];}if (false === $hasOldInput) {@@ -234,7 +234,7 @@ class CreateController extends Controller}Log::channel('audit')->info('Stored new recurrence.', $data);- $request->session()->flash('success', (string)trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));+ $request->session()->flash('success', (string) trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));app('preferences')->mark();// store attachment(s):@@ -245,7 +245,7 @@ class CreateController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {@@ -253,7 +253,7 @@ class CreateController extends Controller}$redirect = redirect($this->getPreviousUrl('recurring.create.url'));- if (1 === (int)$request->get('create_another')) {+ if (1 === (int) $request->get('create_another')) {// set value so create routine will not overwrite URL:$request->session()->put('recurring.create.fromStore', true);diff --git a/app/Http/Controllers/Recurring/DeleteController.php b/app/Http/Controllers/Recurring/DeleteController.phpindex e70a261e6e..4cdc4c971f 100644--- a/app/Http/Controllers/Recurring/DeleteController.php+++ b/app/Http/Controllers/Recurring/DeleteController.php@@ -52,7 +52,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-paint-brush');- app('view')->share('title', (string)trans('firefly.recurrences'));+ app('view')->share('title', (string) trans('firefly.recurrences'));$this->recurring = app(RecurringRepositoryInterface::class);@@ -68,7 +68,7 @@ class DeleteController extends Controller*/public function delete(Recurrence $recurrence){- $subTitle = (string)trans('firefly.delete_recurring', ['title' => $recurrence->title]);+ $subTitle = (string) trans('firefly.delete_recurring', ['title' => $recurrence->title]);// put previous url in session$this->rememberPreviousUrl('recurrences.delete.url');@@ -85,7 +85,7 @@ class DeleteController extends Controllerpublic function destroy(RecurringRepositoryInterface $repository, Request $request, Recurrence $recurrence){$repository->destroy($recurrence);- $request->session()->flash('success', (string)trans('firefly.recurrence_deleted', ['title' => $recurrence->title]));+ $request->session()->flash('success', (string) trans('firefly.recurrence_deleted', ['title' => $recurrence->title]));app('preferences')->mark();return redirect($this->getPreviousUrl('recurrences.delete.url'));diff --git a/app/Http/Controllers/Recurring/EditController.php b/app/Http/Controllers/Recurring/EditController.phpindex 2a3a37342e..c662ed3d04 100644--- a/app/Http/Controllers/Recurring/EditController.php+++ b/app/Http/Controllers/Recurring/EditController.php@@ -63,8 +63,8 @@ class EditController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-paint-brush');- app('view')->share('title', (string)trans('firefly.recurrences'));- app('view')->share('subTitle', (string)trans('firefly.recurrences'));+ app('view')->share('title', (string) trans('firefly.recurrences'));+ app('view')->share('subTitle', (string) trans('firefly.recurrences'));$this->recurring = app(RecurringRepositoryInterface::class);$this->budgetRepos = app(BudgetRepositoryInterface::class);@@ -114,9 +114,9 @@ class EditController extends Controller$repetitionEnd = 'forever';$repetitionEnds = [- 'forever' => (string)trans('firefly.repeat_forever'),- 'until_date' => (string)trans('firefly.repeat_until_date'),- 'times' => (string)trans('firefly.repeat_times'),+ 'forever' => (string) trans('firefly.repeat_forever'),+ 'until_date' => (string) trans('firefly.repeat_until_date'),+ 'times' => (string) trans('firefly.repeat_times'),];if (null !== $recurrence->repeat_until) {$repetitionEnd = 'until_date';@@ -126,22 +126,22 @@ class EditController extends Controller}$weekendResponses = [- RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),- RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),- RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),- RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),+ RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),+ RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),+ RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),+ RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),];$hasOldInput = null !== $request->old('_token');$preFilled = ['transaction_type' => strtolower($recurrence->transactionType->type),- 'active' => $hasOldInput ? (bool)$request->old('active') : $recurrence->active,- 'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : $recurrence->apply_rules,+ 'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active,+ 'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules,'deposit_source_id' => $array['transactions'][0]['source_id'],'withdrawal_destination_id' => $array['transactions'][0]['destination_id'],];- $array['first_date'] = substr((string)$array['first_date'], 0, 10);- $array['repeat_until'] = substr((string)$array['repeat_until'], 0, 10);+ $array['first_date'] = substr((string) $array['first_date'], 0, 10);+ $array['repeat_until'] = substr((string) $array['repeat_until'], 0, 10);$array['transactions'][0]['tags'] = implode(',', $array['transactions'][0]['tags'] ?? []);return view(@@ -172,7 +172,7 @@ class EditController extends Controller$data = $request->getAll();$this->recurring->update($recurrence, $data);- $request->session()->flash('success', (string)trans('firefly.updated_recurrence', ['title' => $recurrence->title]));+ $request->session()->flash('success', (string) trans('firefly.updated_recurrence', ['title' => $recurrence->title]));Log::channel('audit')->info(sprintf('Updated recurrence #%d.', $recurrence->id), $data);// store new attachment(s):@@ -183,7 +183,7 @@ class EditController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachments->getMessages()->get('attachments')) > 0) {@@ -191,7 +191,7 @@ class EditController extends Controller}app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('recurrences.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {// set value so edit routine will not overwrite URL:$request->session()->put('recurrences.edit.fromUpdate', true);diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.phpindex ed2e3775ba..982e35e878 100644--- a/app/Http/Controllers/Recurring/IndexController.php+++ b/app/Http/Controllers/Recurring/IndexController.php@@ -56,7 +56,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-paint-brush');- app('view')->share('title', (string)trans('firefly.recurrences'));+ app('view')->share('title', (string) trans('firefly.recurrences'));$this->recurringRepos = app(RecurringRepositoryInterface::class);@@ -75,8 +75,8 @@ class IndexController extends Controller*/public function index(Request $request){- $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$collection = $this->recurringRepos->get();$today = today(config('app.timezone'));$year = today(config('app.timezone'));diff --git a/app/Http/Controllers/Recurring/ShowController.php b/app/Http/Controllers/Recurring/ShowController.phpindex bb4c3d82ed..ef4beccd79 100644--- a/app/Http/Controllers/Recurring/ShowController.php+++ b/app/Http/Controllers/Recurring/ShowController.php@@ -60,7 +60,7 @@ class ShowController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-paint-brush');- app('view')->share('title', (string)trans('firefly.recurrences'));+ app('view')->share('title', (string) trans('firefly.recurrences'));$this->recurring = app(RecurringRepositoryInterface::class);@@ -125,7 +125,7 @@ class ShowController extends Controller}}- $subTitle = (string)trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);+ $subTitle = (string) trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);return view('recurring.show', compact('recurrence', 'subTitle', 'array', 'groups', 'today'));}diff --git a/app/Http/Controllers/Recurring/TriggerController.php b/app/Http/Controllers/Recurring/TriggerController.phpindex e1a4c3be79..818f353037 100644--- a/app/Http/Controllers/Recurring/TriggerController.php+++ b/app/Http/Controllers/Recurring/TriggerController.php@@ -74,11 +74,11 @@ class TriggerController extends Controllerapp('preferences')->mark();if (0 === $groups->count()) {- $request->session()->flash('info', (string)trans('firefly.no_new_transaction_in_recurrence'));+ $request->session()->flash('info', (string) trans('firefly.no_new_transaction_in_recurrence'));}if (1 === $groups->count()) {$first = $groups->first();- $request->session()->flash('success', (string)trans('firefly.stored_journal_no_descr'));+ $request->session()->flash('success', (string) trans('firefly.stored_journal_no_descr'));$request->session()->flash('success_url', route('transactions.show', [$first->id]));}diff --git a/app/Http/Controllers/Report/BudgetController.php b/app/Http/Controllers/Report/BudgetController.phpindex 9e95e2ba43..286978f049 100644--- a/app/Http/Controllers/Report/BudgetController.php+++ b/app/Http/Controllers/Report/BudgetController.php@@ -164,8 +164,8 @@ class BudgetController extends Controller];++$result[$key]['transactions'];$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);- $result[$key]['avg_float'] = (float)$result[$key]['avg']; // intentional float+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);+ $result[$key]['avg_float'] = (float) $result[$key]['avg']; // intentional float}}}@@ -242,7 +242,7 @@ class BudgetController extends Controller$total = $sums[$currencyId]['sum'] ?? '0';$pct = '0';if (0 !== bccomp($sum, '0') && 0 !== bccomp($total, '9')) {- $pct = round((float)bcmul(bcdiv($sum, $total), '100')); // intentional float+ $pct = round((float) bcmul(bcdiv($sum, $total), '100')); // intentional float}$report[$budgetId]['currencies'][$currencyId]['sum_pct'] = $pct;}@@ -319,7 +319,7 @@ class BudgetController extends Controller$report[$key]['entries'][$dateKey] ??= '0';$report[$key]['entries'][$dateKey] = bcadd($journal['amount'], $report[$key]['entries'][$dateKey]);$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));}}}@@ -354,7 +354,7 @@ class BudgetController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float)$journal['amount'], // intentional float+ 'amount_float' => (float) $journal['amount'], // intentional float'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),diff --git a/app/Http/Controllers/Report/CategoryController.php b/app/Http/Controllers/Report/CategoryController.phpindex c3560c2219..907525f85f 100644--- a/app/Http/Controllers/Report/CategoryController.php+++ b/app/Http/Controllers/Report/CategoryController.php@@ -283,8 +283,8 @@ class CategoryController extends Controller];++$result[$key]['transactions'];$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);- $result[$key]['avg_float'] = (float)$result[$key]['avg']; // intentional float+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);+ $result[$key]['avg_float'] = (float) $result[$key]['avg']; // intentional float}}}@@ -333,8 +333,8 @@ class CategoryController extends Controller];++$result[$key]['transactions'];$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);- $result[$key]['avg_float'] = (float)$result[$key]['avg'];+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);+ $result[$key]['avg_float'] = (float) $result[$key]['avg'];}}}@@ -664,7 +664,7 @@ class CategoryController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float)$journal['amount'],+ 'amount_float' => (float) $journal['amount'],'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),@@ -712,7 +712,7 @@ class CategoryController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float)$journal['amount'],+ 'amount_float' => (float) $journal['amount'],'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),diff --git a/app/Http/Controllers/Report/DoubleController.php b/app/Http/Controllers/Report/DoubleController.phpindex 9477589868..75840fcef4 100644--- a/app/Http/Controllers/Report/DoubleController.php+++ b/app/Http/Controllers/Report/DoubleController.php@@ -91,8 +91,8 @@ class DoubleController extends Controller];++$result[$key]['transactions'];$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);- $result[$key]['avg_float'] = (float)$result[$key]['avg'];+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);+ $result[$key]['avg_float'] = (float) $result[$key]['avg'];}}// sort by amount_float@@ -141,8 +141,8 @@ class DoubleController extends Controller];++$result[$key]['transactions'];$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);- $result[$key]['avg_float'] = (float)$result[$key]['avg'];+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);+ $result[$key]['avg_float'] = (float) $result[$key]['avg'];}}// sort by amount_float@@ -407,7 +407,7 @@ class DoubleController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float)$journal['amount'],+ 'amount_float' => (float) $journal['amount'],'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),@@ -455,7 +455,7 @@ class DoubleController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float)$journal['amount'],+ 'amount_float' => (float) $journal['amount'],'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),diff --git a/app/Http/Controllers/Report/TagController.php b/app/Http/Controllers/Report/TagController.phpindex 32ff779948..fdae8faec2 100644--- a/app/Http/Controllers/Report/TagController.php+++ b/app/Http/Controllers/Report/TagController.php@@ -280,8 +280,8 @@ class TagController extends Controller];++$result[$key]['transactions'];$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);- $result[$key]['avg_float'] = (float)$result[$key]['avg'];+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);+ $result[$key]['avg_float'] = (float) $result[$key]['avg'];}}}@@ -330,8 +330,8 @@ class TagController extends Controller];++$result[$key]['transactions'];$result[$key]['sum'] = bcadd($journal['amount'], $result[$key]['sum']);- $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string)$result[$key]['transactions']);- $result[$key]['avg_float'] = (float)$result[$key]['avg'];+ $result[$key]['avg'] = bcdiv($result[$key]['sum'], (string) $result[$key]['transactions']);+ $result[$key]['avg_float'] = (float) $result[$key]['avg'];}}}@@ -467,7 +467,7 @@ class TagController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float)$journal['amount'],+ 'amount_float' => (float) $journal['amount'],'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),@@ -515,7 +515,7 @@ class TagController extends Controller$result[] = ['description' => $journal['description'],'transaction_group_id' => $journal['transaction_group_id'],- 'amount_float' => (float)$journal['amount'], // intentional float.+ 'amount_float' => (float) $journal['amount'], // intentional float.'amount' => $journal['amount'],'date' => $journal['date']->isoFormat($this->monthAndDayFormat),'date_sort' => $journal['date']->format('Y-m-d'),diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.phpindex 67d8344fee..eabef2d1c4 100644--- a/app/Http/Controllers/ReportController.php+++ b/app/Http/Controllers/ReportController.php@@ -59,7 +59,7 @@ class ReportController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.reports'));+ app('view')->share('title', (string) trans('firefly.reports'));app('view')->share('mainTitleIcon', 'fa-bar-chart');app('view')->share('subTitleIcon', 'fa-calendar');$this->helper = app(ReportHelperInterface::class);@@ -80,7 +80,7 @@ class ReportController extends Controllerpublic function auditReport(Collection $accounts, Carbon $start, Carbon $end){if ($end < $start) {- return view('error')->with('message', (string)trans('firefly.end_after_start_date'));+ return view('error')->with('message', (string) trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();@@ -111,7 +111,7 @@ class ReportController extends Controllerpublic function budgetReport(Collection $accounts, Collection $budgets, Carbon $start, Carbon $end){if ($end < $start) {- return view('error')->with('message', (string)trans('firefly.end_after_start_date'));+ return view('error')->with('message', (string) trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();@@ -143,7 +143,7 @@ class ReportController extends Controllerpublic function categoryReport(Collection $accounts, Collection $categories, Carbon $start, Carbon $end){if ($end < $start) {- return view('error')->with('message', (string)trans('firefly.end_after_start_date'));+ return view('error')->with('message', (string) trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();@@ -175,7 +175,7 @@ class ReportController extends Controllerpublic function defaultReport(Collection $accounts, Carbon $start, Carbon $end){if ($end < $start) {- return view('error')->with('message', (string)trans('firefly.end_after_start_date'));+ return view('error')->with('message', (string) trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();@@ -250,8 +250,8 @@ class ReportController extends Controller/** @var Account $account */foreach ($accounts as $account) {- $type = $account->accountType->type;- $role = sprintf('opt_group_%s', $repository->getMetaValue($account, 'account_role'));+ $type = $account->accountType->type;+ $role = sprintf('opt_group_%s', $repository->getMetaValue($account, 'account_role'));if (in_array($type, [AccountType::MORTGAGE, AccountType::DEBT, AccountType::LOAN], true)) {$role = sprintf('opt_group_l_%s', $type);@@ -260,7 +260,7 @@ class ReportController extends Controllerif ('opt_group_' === $role) {$role = 'opt_group_defaultAsset';}- $groupedAccounts[(string)trans(sprintf('firefly.%s', $role))][$account->id] = $account;+ $groupedAccounts[(string) trans(sprintf('firefly.%s', $role))][$account->id] = $account;}ksort($groupedAccounts);@@ -309,37 +309,37 @@ class ReportController extends Controllerif (0 === $request->getAccountList()->count()) {app('log')->debug('Account count is zero');- session()->flash('error', (string)trans('firefly.select_at_least_one_account'));+ session()->flash('error', (string) trans('firefly.select_at_least_one_account'));return redirect(route('reports.index'));}if ('category' === $reportType && 0 === $request->getCategoryList()->count()) {- session()->flash('error', (string)trans('firefly.select_at_least_one_category'));+ session()->flash('error', (string) trans('firefly.select_at_least_one_category'));return redirect(route('reports.index'));}if ('budget' === $reportType && 0 === $request->getBudgetList()->count()) {- session()->flash('error', (string)trans('firefly.select_at_least_one_budget'));+ session()->flash('error', (string) trans('firefly.select_at_least_one_budget'));return redirect(route('reports.index'));}if ('tag' === $reportType && 0 === $request->getTagList()->count()) {- session()->flash('error', (string)trans('firefly.select_at_least_one_tag'));+ session()->flash('error', (string) trans('firefly.select_at_least_one_tag'));return redirect(route('reports.index'));}if ('double' === $reportType && 0 === $request->getDoubleList()->count()) {- session()->flash('error', (string)trans('firefly.select_at_least_one_expense'));+ session()->flash('error', (string) trans('firefly.select_at_least_one_expense'));return redirect(route('reports.index'));}if ($request->getEndDate() < $request->getStartDate()) {- return view('error')->with('message', (string)trans('firefly.end_after_start_date'));+ return view('error')->with('message', (string) trans('firefly.end_after_start_date'));}$url = match ($reportType) {@@ -364,7 +364,7 @@ class ReportController extends Controllerpublic function tagReport(Collection $accounts, Collection $tags, Carbon $start, Carbon $end){if ($end < $start) {- return view('error')->with('message', (string)trans('firefly.end_after_start_date'));+ return view('error')->with('message', (string) trans('firefly.end_after_start_date'));}$this->repository->cleanupBudgets();diff --git a/app/Http/Controllers/Rule/CreateController.php b/app/Http/Controllers/Rule/CreateController.phpindex e9468d2ca9..9729dfe015 100644--- a/app/Http/Controllers/Rule/CreateController.php+++ b/app/Http/Controllers/Rule/CreateController.php@@ -60,7 +60,7 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.rules'));+ app('view')->share('title', (string) trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->ruleRepos = app(RuleRepositoryInterface::class);@@ -87,7 +87,7 @@ class CreateController extends Controller$oldActions = [];// build triggers from query, if present.- $query = (string)$request->get('from_query');+ $query = (string) $request->get('from_query');if ('' !== $query) {$search = app(SearchInterface::class);$search->parseQuery($query);@@ -115,9 +115,9 @@ class CreateController extends Controller$subTitleIcon = 'fa-clone';// title depends on whether or not there is a rule group:- $subTitle = (string)trans('firefly.make_new_rule_no_group');+ $subTitle = (string) trans('firefly.make_new_rule_no_group');if (null !== $ruleGroup) {- $subTitle = (string)trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);+ $subTitle = (string) trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);}// flash old data@@ -144,13 +144,13 @@ class CreateController extends Controller*/public function createFromBill(Request $request, Bill $bill){- $request->session()->flash('info', (string)trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)]));+ $request->session()->flash('info', (string) trans('firefly.instructions_rule_from_bill', ['name' => e($bill->name)]));$this->createDefaultRuleGroup();$preFilled = ['strict' => true,- 'title' => (string)trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),- 'description' => (string)trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),+ 'title' => (string) trans('firefly.new_rule_for_bill_title', ['name' => $bill->name]),+ 'description' => (string) trans('firefly.new_rule_for_bill_description', ['name' => $bill->name]),];// make triggers and actions from the bill itself.@@ -170,7 +170,7 @@ class CreateController extends Controller$subTitleIcon = 'fa-clone';// title depends on whether there is a rule group:- $subTitle = (string)trans('firefly.make_new_rule_no_group');+ $subTitle = (string) trans('firefly.make_new_rule_no_group');// flash old data$request->session()->flash('preFilled', $preFilled);@@ -194,10 +194,10 @@ class CreateController extends Controller*/public function createFromJournal(Request $request, TransactionJournal $journal){- $request->session()->flash('info', (string)trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)]));+ $request->session()->flash('info', (string) trans('firefly.instructions_rule_from_journal', ['name' => e($journal->description)]));$subTitleIcon = 'fa-clone';- $subTitle = (string)trans('firefly.make_new_rule_no_group');+ $subTitle = (string) trans('firefly.make_new_rule_no_group');// get triggers and actions for journal.$oldTriggers = $this->getTriggersForJournal($journal);@@ -208,8 +208,8 @@ class CreateController extends Controller// collect pre-filled information:$preFilled = ['strict' => true,- 'title' => (string)trans('firefly.new_rule_for_journal_title', ['description' => $journal->description]),- 'description' => (string)trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),+ 'title' => (string) trans('firefly.new_rule_for_journal_title', ['description' => $journal->description]),+ 'description' => (string) trans('firefly.new_rule_for_journal_description', ['description' => $journal->description]),];// restore actions and triggers from old input:@@ -238,7 +238,7 @@ class CreateController extends Controllerpublic function duplicate(Request $request): JsonResponse{- $ruleId = (int)$request->get('id');+ $ruleId = (int) $request->get('id');$rule = $this->ruleRepos->find($ruleId);if (null !== $rule) {$this->ruleRepos->duplicate($rule);@@ -257,22 +257,22 @@ class CreateController extends Controller$data = $request->getRuleData();$rule = $this->ruleRepos->store($data);- session()->flash('success', (string)trans('firefly.stored_new_rule', ['title' => $rule->title]));+ session()->flash('success', (string) trans('firefly.stored_new_rule', ['title' => $rule->title]));app('preferences')->mark();// redirect to show bill.- if ('true' === $request->get('return_to_bill') && (int)$request->get('bill_id') > 0) {- return redirect(route('bills.show', [(int)$request->get('bill_id')]));+ if ('true' === $request->get('return_to_bill') && (int) $request->get('bill_id') > 0) {+ return redirect(route('bills.show', [(int) $request->get('bill_id')]));}// redirect to new bill creation.- if ((int)$request->get('bill_id') > 0) {+ if ((int) $request->get('bill_id') > 0) {return redirect($this->getPreviousUrl('bills.create.url'));}$redirect = redirect($this->getPreviousUrl('rules.create.url'));- if (1 === (int)$request->get('create_another')) {+ if (1 === (int) $request->get('create_another')) {session()->put('rules.create.fromStore', true);$redirect = redirect(route('rules.create', [$data['rule_group_id']]))->withInput();}diff --git a/app/Http/Controllers/Rule/DeleteController.php b/app/Http/Controllers/Rule/DeleteController.phpindex 9c4fd816b3..d4c6ceb05d 100644--- a/app/Http/Controllers/Rule/DeleteController.php+++ b/app/Http/Controllers/Rule/DeleteController.php@@ -48,7 +48,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.rules'));+ app('view')->share('title', (string) trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->ruleRepos = app(RuleRepositoryInterface::class);@@ -65,7 +65,7 @@ class DeleteController extends Controller*/public function delete(Rule $rule){- $subTitle = (string)trans('firefly.delete_rule', ['title' => $rule->title]);+ $subTitle = (string) trans('firefly.delete_rule', ['title' => $rule->title]);// put previous url in session$this->rememberPreviousUrl('rules.delete.url');@@ -81,7 +81,7 @@ class DeleteController extends Controller$title = $rule->title;$this->ruleRepos->destroy($rule);- session()->flash('success', (string)trans('firefly.deleted_rule', ['title' => $title]));+ session()->flash('success', (string) trans('firefly.deleted_rule', ['title' => $title]));app('preferences')->mark();return redirect($this->getPreviousUrl('rules.delete.url'));diff --git a/app/Http/Controllers/Rule/EditController.php b/app/Http/Controllers/Rule/EditController.phpindex daa7b8bf15..a00df8ef4c 100644--- a/app/Http/Controllers/Rule/EditController.php+++ b/app/Http/Controllers/Rule/EditController.php@@ -58,7 +58,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.rules'));+ app('view')->share('title', (string) trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->ruleRepos = app(RuleRepositoryInterface::class);@@ -83,7 +83,7 @@ class EditController extends Controller$oldTriggers = [];// build triggers from query, if present.- $query = (string)$request->get('from_query');+ $query = (string) $request->get('from_query');if ('' !== $query) {$search = app(SearchInterface::class);$search->parseQuery($query);@@ -113,14 +113,14 @@ class EditController extends Controller$hasOldInput = null !== $request->old('_token');$preFilled = [- 'active' => $hasOldInput ? (bool)$request->old('active') : $rule->active,- 'stop_processing' => $hasOldInput ? (bool)$request->old('stop_processing') : $rule->stop_processing,- 'strict' => $hasOldInput ? (bool)$request->old('strict') : $rule->strict,+ 'active' => $hasOldInput ? (bool) $request->old('active') : $rule->active,+ 'stop_processing' => $hasOldInput ? (bool) $request->old('stop_processing') : $rule->stop_processing,+ 'strict' => $hasOldInput ? (bool) $request->old('strict') : $rule->strict,];// get rule trigger for update / store-journal:$primaryTrigger = $this->ruleRepos->getPrimaryTrigger($rule);- $subTitle = (string)trans('firefly.edit_rule', ['title' => $rule->title]);+ $subTitle = (string) trans('firefly.edit_rule', ['title' => $rule->title]);// put previous url in session if not redirect from store (not "return_to_edit").if (true !== session('rules.edit.fromUpdate')) {@@ -144,7 +144,7 @@ class EditController extends Controller$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);@@ -186,10 +186,10 @@ class EditController extends Controller$this->ruleRepos->update($rule, $data);- session()->flash('success', (string)trans('firefly.updated_rule', ['title' => $rule->title]));+ session()->flash('success', (string) trans('firefly.updated_rule', ['title' => $rule->title]));app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('rules.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {session()->put('rules.edit.fromUpdate', true);$redirect = redirect(route('rules.edit', [$rule->id]))->withInput(['return_to_edit' => 1]);diff --git a/app/Http/Controllers/Rule/IndexController.php b/app/Http/Controllers/Rule/IndexController.phpindex d86f902c36..5d53c38e9c 100644--- a/app/Http/Controllers/Rule/IndexController.php+++ b/app/Http/Controllers/Rule/IndexController.php@@ -53,7 +53,7 @@ class IndexController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.rules'));+ app('view')->share('title', (string) trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->ruleGroupRepos = app(RuleGroupRepositoryInterface::class);$this->ruleRepos = app(RuleRepositoryInterface::class);@@ -79,7 +79,7 @@ class IndexController extends Controllerpublic function moveRule(Request $request, Rule $rule, RuleGroup $ruleGroup): JsonResponse{- $order = (int)$request->get('order');+ $order = (int) $request->get('order');$this->ruleRepos->moveRule($rule, $ruleGroup, $order);return response()->json([]);diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.phpindex a362e955fe..d6dae9d5fa 100644--- a/app/Http/Controllers/Rule/SelectController.php+++ b/app/Http/Controllers/Rule/SelectController.php@@ -56,7 +56,7 @@ class SelectController extends Controller$this->middleware(static function ($request, $next) {- app('view')->share('title', (string)trans('firefly.rules'));+ app('view')->share('title', (string) trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');return $next($request);@@ -108,7 +108,7 @@ class SelectController extends Controller// does the user have shared accounts?$first = session('first', today(config('app.timezone'))->subYear())->format('Y-m-d');$today = today(config('app.timezone'))->format('Y-m-d');- $subTitle = (string)trans('firefly.apply_rule_selection', ['title' => $rule->title]);+ $subTitle = (string) trans('firefly.apply_rule_selection', ['title' => $rule->title]);return view('rules.rule.select-transactions', compact('first', 'today', 'rule', 'subTitle'));}@@ -133,7 +133,7 @@ class SelectController extends Controller// warn if nothing.if (0 === count($textTriggers)) {- return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);+ return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);}foreach ($textTriggers as $textTrigger) {@@ -166,7 +166,7 @@ class SelectController extends Controller// Warn the user if only a subset of transactions is returned$warning = '';if (0 === count($collection)) {- $warning = (string)trans('firefly.warning_no_matching_transactions');+ $warning = (string) trans('firefly.warning_no_matching_transactions');}// Return json response@@ -196,7 +196,7 @@ class SelectController extends Controller$triggers = $rule->ruleTriggers;if (0 === count($triggers)) {- return response()->json(['html' => '', 'warning' => (string)trans('firefly.warning_no_valid_triggers')]);+ return response()->json(['html' => '', 'warning' => (string) trans('firefly.warning_no_valid_triggers')]);}// create new rule engine:$newRuleEngine = app(RuleEngineInterface::class);@@ -208,7 +208,7 @@ class SelectController extends Controller$warning = '';if (0 === count($collection)) {- $warning = (string)trans('firefly.warning_no_matching_transactions');+ $warning = (string) trans('firefly.warning_no_matching_transactions');}// Return json responsediff --git a/app/Http/Controllers/RuleGroup/CreateController.php b/app/Http/Controllers/RuleGroup/CreateController.phpindex 383ece3c70..c269849308 100644--- a/app/Http/Controllers/RuleGroup/CreateController.php+++ b/app/Http/Controllers/RuleGroup/CreateController.php@@ -49,7 +49,7 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.rules'));+ app('view')->share('title', (string) trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->repository = app(RuleGroupRepositoryInterface::class);@@ -67,7 +67,7 @@ class CreateController extends Controllerpublic function create(){$subTitleIcon = 'fa-clone';- $subTitle = (string)trans('firefly.make_new_rule_group');+ $subTitle = (string) trans('firefly.make_new_rule_group');// put previous url in session if not redirect from store (not "create another").if (true !== session('rule-groups.create.fromStore')) {@@ -88,11 +88,11 @@ class CreateController extends Controller$data = $request->getRuleGroupData();$ruleGroup = $this->repository->store($data);- session()->flash('success', (string)trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));+ session()->flash('success', (string) trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]));app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('rule-groups.create.url'));- if (1 === (int)$request->get('create_another')) {+ if (1 === (int) $request->get('create_another')) {session()->put('rule-groups.create.fromStore', true);$redirect = redirect(route('rule-groups.create'))->withInput();diff --git a/app/Http/Controllers/RuleGroup/DeleteController.php b/app/Http/Controllers/RuleGroup/DeleteController.phpindex cfcd8d59d1..8d7bf2fea7 100644--- a/app/Http/Controllers/RuleGroup/DeleteController.php+++ b/app/Http/Controllers/RuleGroup/DeleteController.php@@ -50,7 +50,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.rules'));+ app('view')->share('title', (string) trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->repository = app(RuleGroupRepositoryInterface::class);@@ -67,7 +67,7 @@ class DeleteController extends Controller*/public function delete(RuleGroup $ruleGroup){- $subTitle = (string)trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]);+ $subTitle = (string) trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]);// put previous url in session$this->rememberPreviousUrl('rule-groups.delete.url');@@ -85,10 +85,10 @@ class DeleteController extends Controller$title = $ruleGroup->title;/** @var RuleGroup $moveTo */- $moveTo = $this->repository->find((int)$request->get('move_rules_before_delete'));+ $moveTo = $this->repository->find((int) $request->get('move_rules_before_delete'));$this->repository->destroy($ruleGroup, $moveTo);- session()->flash('success', (string)trans('firefly.deleted_rule_group', ['title' => $title]));+ session()->flash('success', (string) trans('firefly.deleted_rule_group', ['title' => $title]));app('preferences')->mark();return redirect($this->getPreviousUrl('rule-groups.delete.url'));diff --git a/app/Http/Controllers/RuleGroup/EditController.php b/app/Http/Controllers/RuleGroup/EditController.phpindex fc0569fa9c..a1e6f47487 100644--- a/app/Http/Controllers/RuleGroup/EditController.php+++ b/app/Http/Controllers/RuleGroup/EditController.php@@ -51,7 +51,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.rules'));+ app('view')->share('title', (string) trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->repository = app(RuleGroupRepositoryInterface::class);@@ -68,11 +68,11 @@ class EditController extends Controller*/public function edit(Request $request, RuleGroup $ruleGroup){- $subTitle = (string)trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]);+ $subTitle = (string) trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]);$hasOldInput = null !== $request->old('_token');$preFilled = [- 'active' => $hasOldInput ? (bool)$request->old('active') : $ruleGroup->active,+ 'active' => $hasOldInput ? (bool) $request->old('active') : $ruleGroup->active,];// put previous url in session if not redirect from store (not "return_to_edit").if (true !== session('rule-groups.edit.fromUpdate')) {@@ -89,7 +89,7 @@ class EditController extends Controller*/public function moveGroup(Request $request): JsonResponse{- $groupId = (int)$request->get('id');+ $groupId = (int) $request->get('id');$ruleGroup = $this->repository->find($groupId);if (null !== $ruleGroup) {$direction = $request->get('direction');@@ -123,15 +123,15 @@ class EditController extends Controller$data = ['title' => $request->convertString('title'),'description' => $request->stringWithNewlines('description'),- 'active' => 1 === (int)$request->input('active'),+ 'active' => 1 === (int) $request->input('active'),];$this->repository->update($ruleGroup, $data);- session()->flash('success', (string)trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));+ session()->flash('success', (string) trans('firefly.updated_rule_group', ['title' => $ruleGroup->title]));app('preferences')->mark();$redirect = redirect($this->getPreviousUrl('rule-groups.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {session()->put('rule-groups.edit.fromUpdate', true);$redirect = redirect(route('rule-groups.edit', [$ruleGroup->id]))->withInput(['return_to_edit' => 1]);diff --git a/app/Http/Controllers/RuleGroup/ExecutionController.php b/app/Http/Controllers/RuleGroup/ExecutionController.phpindex f2048133e1..542d38d0a7 100644--- a/app/Http/Controllers/RuleGroup/ExecutionController.php+++ b/app/Http/Controllers/RuleGroup/ExecutionController.php@@ -51,7 +51,7 @@ class ExecutionController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.rules'));+ app('view')->share('title', (string) trans('firefly.rules'));app('view')->share('mainTitleIcon', 'fa-random');$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);@@ -89,7 +89,7 @@ class ExecutionController extends Controller$newRuleEngine->fire();// Tell the user that the job is queued- session()->flash('success', (string)trans('firefly.applied_rule_group_selection', ['title' => $ruleGroup->title]));+ session()->flash('success', (string) trans('firefly.applied_rule_group_selection', ['title' => $ruleGroup->title]));return redirect()->route('rules.index');}@@ -103,7 +103,7 @@ class ExecutionController extends Controller{$first = session('first')->format('Y-m-d');$today = today(config('app.timezone'))->format('Y-m-d');- $subTitle = (string)trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);+ $subTitle = (string) trans('firefly.apply_rule_group_selection', ['title' => $ruleGroup->title]);return view('rules.rule-group.select-transactions', compact('first', 'today', 'ruleGroup', 'subTitle'));}diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.phpindex b68d9de8a7..6bf2204c3b 100644--- a/app/Http/Controllers/SearchController.php+++ b/app/Http/Controllers/SearchController.php@@ -46,7 +46,7 @@ class SearchController extends Controller$this->middleware(static function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-search');- app('view')->share('title', (string)trans('firefly.search'));+ app('view')->share('title', (string) trans('firefly.search'));return $next($request);}@@ -65,9 +65,9 @@ class SearchController extends Controllerif (is_array($request->get('search'))) {$fullQuery = '';}- $fullQuery = (string)$fullQuery;- $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');- $ruleId = (int)$request->get('rule');+ $fullQuery = (string) $fullQuery;+ $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');+ $ruleId = (int) $request->get('rule');$ruleChanged = false;// find rule, check if query is different, offer to update.@@ -86,7 +86,7 @@ class SearchController extends Controller$query = $searcher->getWordsAsString();$operators = $searcher->getOperators();$invalidOperators = $searcher->getInvalidOperators();- $subTitle = (string)trans('breadcrumbs.search_result', ['query' => $fullQuery]);+ $subTitle = (string) trans('breadcrumbs.search_result', ['query' => $fullQuery]);return view('search.index', compact('query', 'operators', 'page', 'rule', 'fullQuery', 'subTitle', 'ruleId', 'ruleChanged', 'invalidOperators'));}@@ -102,8 +102,8 @@ class SearchController extends Controllerif (!is_scalar($entry)) {$entry = '';}- $fullQuery = (string)$entry;- $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');+ $fullQuery = (string) $entry;+ $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');$searcher->parseQuery($fullQuery);diff --git a/app/Http/Controllers/System/InstallController.php b/app/Http/Controllers/System/InstallController.phpindex 6bf7858cc4..c40c2a73bc 100644--- a/app/Http/Controllers/System/InstallController.php+++ b/app/Http/Controllers/System/InstallController.php@@ -80,17 +80,17 @@ class InstallController extends Controller{app('view')->share('FF_VERSION', config('firefly.version'));// index will set FF3 version.- app('fireflyconfig')->set('ff3_version', (string)config('firefly.version'));+ app('fireflyconfig')->set('ff3_version', (string) config('firefly.version'));// set new DB version.- app('fireflyconfig')->set('db_version', (int)config('firefly.db_version'));+ app('fireflyconfig')->set('db_version', (int) config('firefly.db_version'));return view('install.index');}public function runCommand(Request $request): JsonResponse{- $requestIndex = (int)$request->get('index');+ $requestIndex = (int) $request->get('index');$response = ['hasNextCommand' => false,'done' => true,@@ -171,7 +171,7 @@ class InstallController extends Controllerreturn;}- file_put_contents($publicKey, (string)$key->getPublicKey());+ file_put_contents($publicKey, (string) $key->getPublicKey());file_put_contents($privateKey, $key->toString('PKCS1'));}}diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.phpindex 832e0069b3..23c45810a0 100644--- a/app/Http/Controllers/TagController.php+++ b/app/Http/Controllers/TagController.php@@ -57,7 +57,7 @@ class TagController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.tags'));+ app('view')->share('title', (string) trans('firefly.tags'));app('view')->share('mainTitleIcon', 'fa-tag');$this->attachmentsHelper = app(AttachmentHelperInterface::class);@@ -75,7 +75,7 @@ class TagController extends Controller*/public function create(Request $request){- $subTitle = (string)trans('firefly.new_tag');+ $subTitle = (string) trans('firefly.new_tag');$subTitleIcon = 'fa-tag';// location info:@@ -105,7 +105,7 @@ class TagController extends Controller*/public function delete(Tag $tag){- $subTitle = (string)trans('breadcrumbs.delete_tag', ['tag' => $tag->tag]);+ $subTitle = (string) trans('breadcrumbs.delete_tag', ['tag' => $tag->tag]);// put previous url in session$this->rememberPreviousUrl('tags.delete.url');@@ -120,7 +120,7 @@ class TagController extends Controller*/public function edit(Tag $tag){- $subTitle = (string)trans('firefly.edit_tag', ['tag' => $tag->tag]);+ $subTitle = (string) trans('firefly.edit_tag', ['tag' => $tag->tag]);$subTitleIcon = 'fa-tag';$location = $this->repository->getLocation($tag);@@ -176,13 +176,13 @@ class TagController extends Controller{$tags = $request->get('tags');if (null === $tags || !is_array($tags)) {- session()->flash('info', (string)trans('firefly.select_tags_to_delete'));+ session()->flash('info', (string) trans('firefly.select_tags_to_delete'));return redirect(route('tags.index'));}$count = 0;foreach ($tags as $tagId) {- $tagId = (int)$tagId;+ $tagId = (int) $tagId;$tag = $this->repository->find($tagId);if (null !== $tag) {$this->repository->destroy($tag);@@ -202,7 +202,7 @@ class TagController extends Controller$tagName = $tag->tag;$this->repository->destroy($tag);- session()->flash('success', (string)trans('firefly.deleted_tag', ['tag' => $tagName]));+ session()->flash('success', (string) trans('firefly.deleted_tag', ['tag' => $tagName]));app('preferences')->mark();return redirect($this->getPreviousUrl('tags.delete.url'));@@ -219,8 +219,8 @@ class TagController extends Controller{// default values:$subTitleIcon = 'fa-tag';- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$start ??= session('start');$end ??= session('end');$location = $this->repository->getLocation($tag);@@ -262,10 +262,10 @@ class TagController extends Controller{// default values:$subTitleIcon = 'fa-tag';- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$periods = [];- $subTitle = (string)trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);+ $subTitle = (string) trans('firefly.all_journals_for_tag', ['tag' => $tag->tag]);$start = $this->repository->firstUseDate($tag) ?? today(config('app.timezone'));$end = $this->repository->lastUseDate($tag) ?? today(config('app.timezone'));$attachments = $this->repository->getAttachments($tag);@@ -295,7 +295,7 @@ class TagController extends Controller$result = $this->repository->store($data);app('log')->debug('Data after storage', $result->toArray());- session()->flash('success', (string)trans('firefly.created_tag', ['tag' => $data['tag']]));+ session()->flash('success', (string) trans('firefly.created_tag', ['tag' => $data['tag']]));app('preferences')->mark();// store attachment(s):@@ -306,7 +306,7 @@ class TagController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {@@ -316,7 +316,7 @@ class TagController extends Controller$request->session()->flash('error', $this->attachmentsHelper->getErrors()->get('attachments'));}$redirect = redirect($this->getPreviousUrl('tags.create.url'));- if (1 === (int)$request->get('create_another')) {+ if (1 === (int) $request->get('create_another')) {session()->put('tags.create.fromStore', true);$redirect = redirect(route('tags.create'))->withInput();@@ -333,7 +333,7 @@ class TagController extends Controller$data = $request->collectTagData();$tag = $this->repository->update($tag, $data);- session()->flash('success', (string)trans('firefly.updated_tag', ['tag' => $data['tag']]));+ session()->flash('success', (string) trans('firefly.updated_tag', ['tag' => $data['tag']]));app('preferences')->mark();// store new attachment(s):@@ -344,7 +344,7 @@ class TagController extends Controller}if (null !== $files && auth()->user()->hasRole('demo')) {Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));- session()->flash('info', (string)trans('firefly.no_att_demo_user'));+ session()->flash('info', (string) trans('firefly.no_att_demo_user'));}if (count($this->attachmentsHelper->getMessages()->get('attachments')) > 0) {@@ -354,7 +354,7 @@ class TagController extends Controller$request->session()->flash('error', $this->attachmentsHelper->getErrors()->get('attachments'));}$redirect = redirect($this->getPreviousUrl('tags.edit.url'));- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {session()->put('tags.edit.fromUpdate', true);$redirect = redirect(route('tags.edit', [$tag->id]))->withInput(['return_to_edit' => 1]);diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.phpindex d6ac70283b..7d48564d4f 100644--- a/app/Http/Controllers/Transaction/BulkController.php+++ b/app/Http/Controllers/Transaction/BulkController.php@@ -55,7 +55,7 @@ class BulkController extends Controller$this->middleware(function ($request, $next) {$this->repository = app(JournalRepositoryInterface::class);- app('view')->share('title', (string)trans('firefly.transactions'));+ app('view')->share('title', (string) trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');return $next($request);@@ -72,7 +72,7 @@ class BulkController extends Controller*/public function edit(array $journals){- $subTitle = (string)trans('firefly.mass_bulk_journals');+ $subTitle = (string) trans('firefly.mass_bulk_journals');$this->rememberPreviousUrl('transactions.bulk-edit.url');@@ -95,14 +95,14 @@ class BulkController extends Controller{$journalIds = $request->get('journals');$journalIds = is_array($journalIds) ? $journalIds : [];- $ignoreCategory = 1 === (int)$request->get('ignore_category');- $ignoreBudget = 1 === (int)$request->get('ignore_budget');+ $ignoreCategory = 1 === (int) $request->get('ignore_category');+ $ignoreBudget = 1 === (int) $request->get('ignore_budget');$tagsAction = $request->get('tags_action');$collection = new Collection();$count = 0;foreach ($journalIds as $journalId) {- $journalId = (int)$journalId;+ $journalId = (int) $journalId;$journal = $this->repository->find($journalId);if (null !== $journal) {$resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id'));diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.phpindex b65208b005..1b3c4287ec 100644--- a/app/Http/Controllers/Transaction/ConvertController.php+++ b/app/Http/Controllers/Transaction/ConvertController.php@@ -23,6 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Transaction;+use Exception;use FireflyIII\Events\UpdatedTransactionGroup;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.phpindex daca5c526b..a1b29b3877 100644--- a/app/Http/Controllers/Transaction/CreateController.php+++ b/app/Http/Controllers/Transaction/CreateController.php@@ -51,7 +51,7 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.transactions'));+ app('view')->share('title', (string) trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');$this->repository = app(TransactionGroupRepositoryInterface::class);@@ -62,7 +62,7 @@ class CreateController extends Controllerpublic function cloneGroup(Request $request): JsonResponse{- $groupId = (int)$request->get('id');+ $groupId = (int) $request->get('id');if (0 !== $groupId) {$group = $this->repository->find($groupId);if (null !== $group) {@@ -102,14 +102,14 @@ class CreateController extends Controller{app('preferences')->mark();- $sourceId = (int)request()->get('source');- $destinationId = (int)request()->get('destination');+ $sourceId = (int) request()->get('source');+ $destinationId = (int) request()->get('destination');/** @var AccountRepositoryInterface $accountRepository */$accountRepository = app(AccountRepositoryInterface::class);$cash = $accountRepository->getCashAccount();$preFilled = session()->has('preFilled') ? session('preFilled') : [];- $subTitle = (string)trans(sprintf('breadcrumbs.create_%s', strtolower((string)$objectType)));+ $subTitle = (string) trans(sprintf('breadcrumbs.create_%s', strtolower((string) $objectType)));$subTitleIcon = 'fa-plus';$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;$allowedOpposingTypes = config('firefly.allowed_opposing_types');diff --git a/app/Http/Controllers/Transaction/DeleteController.php b/app/Http/Controllers/Transaction/DeleteController.phpindex 934605501d..89785805a9 100644--- a/app/Http/Controllers/Transaction/DeleteController.php+++ b/app/Http/Controllers/Transaction/DeleteController.php@@ -54,7 +54,7 @@ class DeleteController extends Controller// translations:$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.transactions'));+ app('view')->share('title', (string) trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');$this->repository = app(TransactionGroupRepositoryInterface::class);@@ -82,7 +82,7 @@ class DeleteController extends Controllerthrow new NotFoundHttpException();}$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);- $subTitle = (string)trans('firefly.delete_'.$objectType, ['description' => $group->title ?? $journal->description]);+ $subTitle = (string) trans('firefly.delete_'.$objectType, ['description' => $group->title ?? $journal->description]);$previous = app('steam')->getSafePreviousUrl();// put previous url in sessionapp('log')->debug('Will try to remember previous URL');@@ -106,7 +106,7 @@ class DeleteController extends Controllerthrow new NotFoundHttpException();}$objectType = strtolower($journal->transaction_type_type ?? $journal->transactionType->type);- session()->flash('success', (string)trans('firefly.deleted_'.strtolower($objectType), ['description' => $group->title ?? $journal->description]));+ session()->flash('success', (string) trans('firefly.deleted_'.strtolower($objectType), ['description' => $group->title ?? $journal->description]));// grab asset account(s) from group:$accounts = [];diff --git a/app/Http/Controllers/Transaction/EditController.php b/app/Http/Controllers/Transaction/EditController.phpindex 35917229e4..9f2da101d2 100644--- a/app/Http/Controllers/Transaction/EditController.php+++ b/app/Http/Controllers/Transaction/EditController.php@@ -52,7 +52,7 @@ class EditController extends Controller// translations:$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.transactions'));+ app('view')->share('title', (string) trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');$this->repository = app(JournalRepositoryInterface::class);@@ -80,7 +80,7 @@ class EditController extends Controller$expectedSourceTypes = config('firefly.expected_source_types');$allowedSourceDests = config('firefly.source_dests');$title = $transactionGroup->transactionJournals()->count() > 1 ? $transactionGroup->title : $transactionGroup->transactionJournals()->first()->description;- $subTitle = (string)trans('firefly.edit_transaction_title', ['description' => $title]);+ $subTitle = (string) trans('firefly.edit_transaction_title', ['description' => $title]);$subTitleIcon = 'fa-plus';$defaultCurrency = app('amount')->getDefaultCurrency();$cash = $repository->getCashAccount();diff --git a/app/Http/Controllers/Transaction/IndexController.php b/app/Http/Controllers/Transaction/IndexController.phpindex 6e4f47df22..7b6ecd2b39 100644--- a/app/Http/Controllers/Transaction/IndexController.php+++ b/app/Http/Controllers/Transaction/IndexController.php@@ -54,7 +54,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-exchange');- app('view')->share('title', (string)trans('firefly.transactions'));+ app('view')->share('title', (string) trans('firefly.transactions'));$this->repository = app(JournalRepositoryInterface::class);@@ -78,8 +78,8 @@ class IndexController extends Controller$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);$types = config('firefly.transactionTypesByType.'.$objectType);- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;if (null === $start) {$start = session('start');@@ -94,7 +94,7 @@ class IndexController extends Controller[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];$startStr = $start->isoFormat($this->monthAndDayFormat);$endStr = $end->isoFormat($this->monthAndDayFormat);- $subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);+ $subTitle = (string) trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);$path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);$firstJournal = $this->repository->firstNull();$startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;@@ -128,14 +128,14 @@ class IndexController extends Controller{$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);$types = config('firefly.transactionTypesByType.'.$objectType);- $page = (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$path = route('transactions.index.all', [$objectType]);$first = $this->repository->firstNull();$start = null === $first ? new Carbon() : $first->date;$last = $this->repository->getLast();$end = null !== $last ? $last->date : today(config('app.timezone'));- $subTitle = (string)trans('firefly.all_'.$objectType);+ $subTitle = (string) trans('firefly.all_'.$objectType);/** @var GroupCollectorInterface $collector */$collector = app(GroupCollectorInterface::class);diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.phpindex 49a2e27dc8..d46fa20eee 100644--- a/app/Http/Controllers/Transaction/LinkController.php+++ b/app/Http/Controllers/Transaction/LinkController.php@@ -52,7 +52,7 @@ class LinkController extends Controller// some useful repositories:$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.transactions'));+ app('view')->share('title', (string) trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');$this->journalRepository = app(JournalRepositoryInterface::class);@@ -71,7 +71,7 @@ class LinkController extends Controllerpublic function delete(TransactionJournalLink $link){$subTitleIcon = 'fa-link';- $subTitle = (string)trans('breadcrumbs.delete_journal_link');+ $subTitle = (string) trans('breadcrumbs.delete_journal_link');$this->rememberPreviousUrl('journal_links.delete.url');return view('transactions.links.delete', compact('link', 'subTitle', 'subTitleIcon'));@@ -86,10 +86,10 @@ class LinkController extends Controller{$this->repository->destroyLink($link);- session()->flash('success', (string)trans('firefly.deleted_link'));+ session()->flash('success', (string) trans('firefly.deleted_link'));app('preferences')->mark();- return redirect((string)session('journal_links.delete.url'));+ return redirect((string) session('journal_links.delete.url'));}/**@@ -114,7 +114,7 @@ class LinkController extends Controllerapp('log')->debug('We are here (store)');$other = $this->journalRepository->find($linkInfo['transaction_journal_id']);if (null === $other) {- session()->flash('error', (string)trans('firefly.invalid_link_selection'));+ session()->flash('error', (string) trans('firefly.invalid_link_selection'));return redirect(route('transactions.show', [$journal->transaction_group_id]));}@@ -122,19 +122,19 @@ class LinkController extends Controller$alreadyLinked = $this->repository->findLink($journal, $other);if ($other->id === $journal->id) {- session()->flash('error', (string)trans('firefly.journals_link_to_self'));+ session()->flash('error', (string) trans('firefly.journals_link_to_self'));return redirect(route('transactions.show', [$journal->transaction_group_id]));}if ($alreadyLinked) {- session()->flash('error', (string)trans('firefly.journals_error_linked'));+ session()->flash('error', (string) trans('firefly.journals_error_linked'));return redirect(route('transactions.show', [$journal->transaction_group_id]));}app('log')->debug(sprintf('Journal is %d, opposing is %d', $journal->id, $other->id));$this->repository->storeLink($linkInfo, $other, $journal);- session()->flash('success', (string)trans('firefly.journals_linked'));+ session()->flash('success', (string) trans('firefly.journals_linked'));return redirect(route('transactions.show', [$journal->transaction_group_id]));}@@ -146,7 +146,7 @@ class LinkController extends Controller*/public function switchLink(Request $request){- $linkId = (int)$request->get('id');+ $linkId = (int) $request->get('id');$this->repository->switchLinkById($linkId);return redirect(app('steam')->getSafePreviousUrl());diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.phpindex af7f14e87e..8278eff521 100644--- a/app/Http/Controllers/Transaction/MassController.php+++ b/app/Http/Controllers/Transaction/MassController.php@@ -58,7 +58,7 @@ class MassController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.transactions'));+ app('view')->share('title', (string) trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');$this->repository = app(JournalRepositoryInterface::class);@@ -72,7 +72,7 @@ class MassController extends Controller*/public function delete(array $journals): IlluminateView{- $subTitle = (string)trans('firefly.mass_delete_journals');+ $subTitle = (string) trans('firefly.mass_delete_journals');// put previous url in session$this->rememberPreviousUrl('transactions.mass-delete.url');@@ -98,8 +98,8 @@ class MassController extends Controllerapp('log')->debug(sprintf('Searching for ID #%d', $journalId));/** @var null|TransactionJournal $journal */- $journal = $this->repository->find((int)$journalId);- if (null !== $journal && (int)$journalId === $journal->id) {+ $journal = $this->repository->find((int) $journalId);+ if (null !== $journal && (int) $journalId === $journal->id) {$this->repository->destroyJournal($journal);++$count;app('log')->debug(sprintf('Deleted transaction journal #%d', $journalId));@@ -121,7 +121,7 @@ class MassController extends Controller*/public function edit(array $journals): IlluminateView{- $subTitle = (string)trans('firefly.mass_edit_journals');+ $subTitle = (string) trans('firefly.mass_edit_journals');/** @var AccountRepositoryInterface $accountRepository */$accountRepository = app(AccountRepositoryInterface::class);@@ -168,7 +168,7 @@ class MassController extends Controller/** @var string $journalId */foreach ($journalIds as $journalId) {- $integer = (int)$journalId;+ $integer = (int) $journalId;try {$this->updateJournal($integer, $request);@@ -251,7 +251,7 @@ class MassController extends Controllerreturn null;}- return (string)$value[$journalId];+ return (string) $value[$journalId];}private function getIntFromRequest(MassEditJournalRequest $request, int $journalId, string $string): ?int@@ -264,6 +264,6 @@ class MassController extends Controllerreturn null;}- return (int)$value[$journalId];+ return (int) $value[$journalId];}}diff --git a/app/Http/Controllers/Transaction/ShowController.php b/app/Http/Controllers/Transaction/ShowController.phpindex 24898e0d6f..2cd234f39a 100644--- a/app/Http/Controllers/Transaction/ShowController.php+++ b/app/Http/Controllers/Transaction/ShowController.php@@ -57,7 +57,7 @@ class ShowController extends Controller$this->repository = app(TransactionGroupRepositoryInterface::class);$this->aleRepository = app(ALERepositoryInterface::class);- app('view')->share('title', (string)trans('firefly.transactions'));+ app('view')->share('title', (string) trans('firefly.transactions'));app('view')->share('mainTitleIcon', 'fa-exchange');return $next($request);@@ -88,7 +88,7 @@ class ShowController extends Controllerthrow new FireflyException('This transaction is broken :(.');}- $type = (string)trans(sprintf('firefly.%s', $first->transactionType->type));+ $type = (string) trans(sprintf('firefly.%s', $first->transactionType->type));$title = 1 === $splits ? $first->description : $transactionGroup->title;$subTitle = sprintf('%s: "%s"', $type, $title);diff --git a/app/Http/Controllers/TransactionCurrency/CreateController.php b/app/Http/Controllers/TransactionCurrency/CreateController.phpindex 75bb2f9cf3..11dd895971 100644--- a/app/Http/Controllers/TransactionCurrency/CreateController.php+++ b/app/Http/Controllers/TransactionCurrency/CreateController.php@@ -54,7 +54,7 @@ class CreateController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.currencies'));+ app('view')->share('title', (string) trans('firefly.currencies'));app('view')->share('mainTitleIcon', 'fa-usd');$this->repository = app(CurrencyRepositoryInterface::class);$this->userRepository = app(UserRepositoryInterface::class);@@ -74,13 +74,13 @@ class CreateController extends Controller/** @var User $user */$user = auth()->user();if (!$this->userRepository->hasRole($user, 'owner')) {- $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));+ $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));return redirect(route('currencies.index'));}$subTitleIcon = 'fa-plus';- $subTitle = (string)trans('firefly.create_currency');+ $subTitle = (string) trans('firefly.create_currency');// put previous url in session if not redirect from store (not "create another").if (true !== session('currencies.create.fromStore')) {@@ -117,15 +117,15 @@ class CreateController extends Controller} catch (FireflyException $e) {app('log')->error($e->getMessage());Log::channel('audit')->warning('Could not store (POST) currency without admin rights.', $data);- $request->session()->flash('error', (string)trans('firefly.could_not_store_currency'));+ $request->session()->flash('error', (string) trans('firefly.could_not_store_currency'));$currency = null;}$redirect = redirect($this->getPreviousUrl('currencies.create.url'));if (null !== $currency) {- $request->session()->flash('success', (string)trans('firefly.created_currency', ['name' => $currency->name]));+ $request->session()->flash('success', (string) trans('firefly.created_currency', ['name' => $currency->name]));Log::channel('audit')->info('Created (POST) currency.', $data);- if (1 === (int)$request->get('create_another')) {+ if (1 === (int) $request->get('create_another')) {$request->session()->put('currencies.create.fromStore', true);$redirect = redirect(route('currencies.create'))->withInput();diff --git a/app/Http/Controllers/TransactionCurrency/DeleteController.php b/app/Http/Controllers/TransactionCurrency/DeleteController.phpindex 5ddecbff90..c2785f2696 100644--- a/app/Http/Controllers/TransactionCurrency/DeleteController.php+++ b/app/Http/Controllers/TransactionCurrency/DeleteController.php@@ -53,7 +53,7 @@ class DeleteController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.currencies'));+ app('view')->share('title', (string) trans('firefly.currencies'));app('view')->share('mainTitleIcon', 'fa-usd');$this->repository = app(CurrencyRepositoryInterface::class);$this->userRepository = app(UserRepositoryInterface::class);@@ -73,7 +73,7 @@ class DeleteController extends Controller/** @var User $user */$user = auth()->user();if (!$this->userRepository->hasRole($user, 'owner')) {- $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));+ $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));Log::channel('audit')->warning(sprintf('Tried to visit page to delete currency %s but is not site owner.', $currency->code));return redirect(route('currencies.index'));@@ -81,7 +81,7 @@ class DeleteController extends Controllerif ($this->repository->currencyInUse($currency)) {$location = $this->repository->currencyInUseAt($currency);- $message = (string)trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]);+ $message = (string) trans(sprintf('firefly.cannot_disable_currency_%s', $location), ['name' => e($currency->name)]);$request->session()->flash('error', $message);Log::channel('audit')->warning(sprintf('Tried to visit page to delete currency %s but currency is in use.', $currency->code));@@ -90,7 +90,7 @@ class DeleteController extends Controller// put previous url in session$this->rememberPreviousUrl('currencies.delete.url');- $subTitle = (string)trans('form.delete_currency', ['name' => $currency->name]);+ $subTitle = (string) trans('form.delete_currency', ['name' => $currency->name]);Log::channel('audit')->info(sprintf('Visit page to delete currency %s.', $currency->code));return view('currencies.delete', compact('currency', 'subTitle'));@@ -106,21 +106,21 @@ class DeleteController extends Controller/** @var User $user */$user = auth()->user();if (!$this->userRepository->hasRole($user, 'owner')) {- $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));+ $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));Log::channel('audit')->warning(sprintf('Tried to delete currency %s but is not site owner.', $currency->code));return redirect(route('currencies.index'));}if ($this->repository->currencyInUse($currency)) {- $request->session()->flash('error', (string)trans('firefly.cannot_delete_currency', ['name' => e($currency->name)]));+ $request->session()->flash('error', (string) trans('firefly.cannot_delete_currency', ['name' => e($currency->name)]));Log::channel('audit')->info(sprintf('Tried to delete currency %s but is in use.', $currency->code));return redirect(route('currencies.index'));}if ($this->repository->isFallbackCurrency($currency)) {- $request->session()->flash('error', (string)trans('firefly.cannot_delete_fallback_currency', ['name' => e($currency->name)]));+ $request->session()->flash('error', (string) trans('firefly.cannot_delete_fallback_currency', ['name' => e($currency->name)]));Log::channel('audit')->info(sprintf('Tried to delete currency %s but is FALLBACK.', $currency->code));return redirect(route('currencies.index'));@@ -129,7 +129,7 @@ class DeleteController extends ControllerLog::channel('audit')->info(sprintf('Deleted currency %s.', $currency->code));$this->repository->destroy($currency);- $request->session()->flash('success', (string)trans('firefly.deleted_currency', ['name' => $currency->name]));+ $request->session()->flash('success', (string) trans('firefly.deleted_currency', ['name' => $currency->name]));return redirect($this->getPreviousUrl('currencies.delete.url'));}diff --git a/app/Http/Controllers/TransactionCurrency/EditController.php b/app/Http/Controllers/TransactionCurrency/EditController.phpindex 75ceb9f539..56ef93ae77 100644--- a/app/Http/Controllers/TransactionCurrency/EditController.php+++ b/app/Http/Controllers/TransactionCurrency/EditController.php@@ -51,7 +51,7 @@ class EditController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.currencies'));+ app('view')->share('title', (string) trans('firefly.currencies'));app('view')->share('mainTitleIcon', 'fa-usd');$this->repository = app(CurrencyRepositoryInterface::class);$this->userRepository = app(UserRepositoryInterface::class);@@ -71,14 +71,14 @@ class EditController extends Controller/** @var User $user */$user = auth()->user();if (!$this->userRepository->hasRole($user, 'owner')) {- $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));+ $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));Log::channel('audit')->warning(sprintf('Tried to edit currency %s but is not owner.', $currency->code));return redirect(route('currencies.index'));}$subTitleIcon = 'fa-pencil';- $subTitle = (string)trans('breadcrumbs.edit_currency', ['name' => $currency->name]);+ $subTitle = (string) trans('breadcrumbs.edit_currency', ['name' => $currency->name]);$currency->symbol = htmlentities($currency->symbol);// is currently enabled (for this user?)@@ -88,7 +88,7 @@ class EditController extends Controller// code to handle active-checkboxes$hasOldInput = null !== $request->old('_token');$preFilled = [- 'enabled' => $hasOldInput ? (bool)$request->old('enabled') : $enabled,+ 'enabled' => $hasOldInput ? (bool) $request->old('enabled') : $enabled,];$request->session()->flash('preFilled', $preFilled);@@ -119,17 +119,17 @@ class EditController extends Controller}if (!$this->userRepository->hasRole($user, 'owner')) {- $request->session()->flash('error', (string)trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));+ $request->session()->flash('error', (string) trans('firefly.ask_site_owner', ['owner' => e(config('firefly.site_owner'))]));Log::channel('audit')->warning('Tried to update (POST) currency without admin rights.', $data);return redirect(route('currencies.index'));}$currency = $this->repository->update($currency, $data);Log::channel('audit')->info('Updated (POST) currency.', $data);- $request->session()->flash('success', (string)trans('firefly.updated_currency', ['name' => $currency->name]));+ $request->session()->flash('success', (string) trans('firefly.updated_currency', ['name' => $currency->name]));app('preferences')->mark();- if (1 === (int)$request->get('return_to_edit')) {+ if (1 === (int) $request->get('return_to_edit')) {$request->session()->put('currencies.edit.fromUpdate', true);return redirect(route('currencies.edit', [$currency->id]));diff --git a/app/Http/Controllers/TransactionCurrency/IndexController.php b/app/Http/Controllers/TransactionCurrency/IndexController.phpindex 2e4314ca9f..0c728a982c 100644--- a/app/Http/Controllers/TransactionCurrency/IndexController.php+++ b/app/Http/Controllers/TransactionCurrency/IndexController.php@@ -48,7 +48,7 @@ class IndexController extends Controller$this->middleware(function ($request, $next) {- app('view')->share('title', (string)trans('firefly.currencies'));+ app('view')->share('title', (string) trans('firefly.currencies'));app('view')->share('mainTitleIcon', 'fa-usd');$this->repository = app(CurrencyRepositoryInterface::class);$this->userRepository = app(UserRepositoryInterface::class);@@ -67,8 +67,8 @@ class IndexController extends Controller{/** @var User $user */$user = auth()->user();- $page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');- $pageSize = (int)app('preferences')->get('listPageSize', 50)->data;+ $page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');+ $pageSize = (int) app('preferences')->get('listPageSize', 50)->data;$collection = $this->repository->getAll();// order so default and enabled are on top:@@ -87,7 +87,7 @@ class IndexController extends Controller$currencies->setPath(route('currencies.index'));$isOwner = true;if (!$this->userRepository->hasRole($user, 'owner')) {- $request->session()->flash('info', (string)trans('firefly.ask_site_owner', ['owner' => config('firefly.site_owner')]));+ $request->session()->flash('info', (string) trans('firefly.ask_site_owner', ['owner' => config('firefly.site_owner')]));$isOwner = false;}diff --git a/app/Http/Controllers/UserGroup/CreateController.php b/app/Http/Controllers/UserGroup/CreateController.phpindex c62367d193..0f20e9e4c2 100644--- a/app/Http/Controllers/UserGroup/CreateController.php+++ b/app/Http/Controllers/UserGroup/CreateController.php@@ -36,8 +36,8 @@ class CreateController extends Controller*/public function create(){- $title = (string)trans('firefly.administrations_page_title');- $subTitle = (string)trans('firefly.administrations_page_create_sub_title');+ $title = (string) trans('firefly.administrations_page_title');+ $subTitle = (string) trans('firefly.administrations_page_create_sub_title');$mainTitleIcon = 'fa-book';app('log')->debug(sprintf('Now at %s', __METHOD__));diff --git a/app/Http/Controllers/UserGroup/EditController.php b/app/Http/Controllers/UserGroup/EditController.phpindex 1e61947ef3..c8d68e991d 100644--- a/app/Http/Controllers/UserGroup/EditController.php+++ b/app/Http/Controllers/UserGroup/EditController.php@@ -37,8 +37,8 @@ class EditController extends Controller*/public function edit(UserGroup $userGroup){- $title = (string)trans('firefly.administrations_page_title');- $subTitle = (string)trans('firefly.administrations_page_edit_sub_title', ['title' => $userGroup->title]);+ $title = (string) trans('firefly.administrations_page_title');+ $subTitle = (string) trans('firefly.administrations_page_edit_sub_title', ['title' => $userGroup->title]);$mainTitleIcon = 'fa-book';app('log')->debug(sprintf('Now at %s', __METHOD__));diff --git a/app/Http/Controllers/UserGroup/IndexController.php b/app/Http/Controllers/UserGroup/IndexController.phpindex 9b0f15c1dd..41c05ad8b1 100644--- a/app/Http/Controllers/UserGroup/IndexController.php+++ b/app/Http/Controllers/UserGroup/IndexController.php@@ -38,8 +38,8 @@ class IndexController extends Controller*/public function index(Request $request){- $title = (string)trans('firefly.administrations_page_title');- $subTitle = (string)trans('firefly.administrations_page_sub_title');+ $title = (string) trans('firefly.administrations_page_title');+ $subTitle = (string) trans('firefly.administrations_page_sub_title');$mainTitleIcon = 'fa-book';app('log')->debug(sprintf('Now at %s', __METHOD__));diff --git a/app/Http/Controllers/Webhooks/CreateController.php b/app/Http/Controllers/Webhooks/CreateController.phpindex b1d06ce1a1..70ac3cbd35 100644--- a/app/Http/Controllers/Webhooks/CreateController.php+++ b/app/Http/Controllers/Webhooks/CreateController.php@@ -44,8 +44,8 @@ class CreateController extends Controllerstatic function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-bolt');app('view')->share('subTitleIcon', 'fa-plus');- app('view')->share('title', (string)trans('firefly.webhooks'));- app('view')->share('subTitle', (string)trans('firefly.create_new_webhook'));+ app('view')->share('title', (string) trans('firefly.webhooks'));+ app('view')->share('subTitle', (string) trans('firefly.create_new_webhook'));return $next($request);}diff --git a/app/Http/Controllers/Webhooks/DeleteController.php b/app/Http/Controllers/Webhooks/DeleteController.phpindex 023016aeb5..4fd33895d1 100644--- a/app/Http/Controllers/Webhooks/DeleteController.php+++ b/app/Http/Controllers/Webhooks/DeleteController.php@@ -49,8 +49,8 @@ class DeleteController extends Controllerstatic function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-bolt');app('view')->share('subTitleIcon', 'fa-trash');- app('view')->share('title', (string)trans('firefly.webhooks'));- app('view')->share('subTitle', (string)trans('firefly.delete_webhook'));+ app('view')->share('title', (string) trans('firefly.webhooks'));+ app('view')->share('subTitle', (string) trans('firefly.delete_webhook'));return $next($request);}@@ -70,7 +70,7 @@ class DeleteController extends Controllerthrow new NotFoundHttpException('Webhooks are not enabled.');}Log::channel('audit')->info('User visits webhook delete page.');- $subTitle = (string)trans('firefly.delete_webhook', ['title' => $webhook->title]);+ $subTitle = (string) trans('firefly.delete_webhook', ['title' => $webhook->title]);$this->rememberPreviousUrl('webhooks.delete.url');return view('webhooks.delete', compact('webhook', 'subTitle'));diff --git a/app/Http/Controllers/Webhooks/EditController.php b/app/Http/Controllers/Webhooks/EditController.phpindex a8ab31b5c1..7ea2b6c63b 100644--- a/app/Http/Controllers/Webhooks/EditController.php+++ b/app/Http/Controllers/Webhooks/EditController.php@@ -49,7 +49,7 @@ class EditController extends Controllerstatic function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-bolt');app('view')->share('subTitleIcon', 'fa-pencil');- app('view')->share('title', (string)trans('firefly.webhooks'));+ app('view')->share('title', (string) trans('firefly.webhooks'));return $next($request);}@@ -69,7 +69,7 @@ class EditController extends Controllerthrow new NotFoundHttpException('Webhooks are not enabled.');}Log::channel('audit')->info('User visits webhook edit page.');- $subTitle = (string)trans('firefly.edit_webhook', ['title' => $webhook->title]);+ $subTitle = (string) trans('firefly.edit_webhook', ['title' => $webhook->title]);$this->rememberPreviousUrl('webhooks.edit.url');return view('webhooks.edit', compact('webhook', 'subTitle'));diff --git a/app/Http/Controllers/Webhooks/IndexController.php b/app/Http/Controllers/Webhooks/IndexController.phpindex c6ee272353..a3ca4790c2 100644--- a/app/Http/Controllers/Webhooks/IndexController.php+++ b/app/Http/Controllers/Webhooks/IndexController.php@@ -43,7 +43,7 @@ class IndexController extends Controller$this->middleware(static function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-bolt');- app('view')->share('title', (string)trans('firefly.webhooks'));+ app('view')->share('title', (string) trans('firefly.webhooks'));return $next($request);}diff --git a/app/Http/Controllers/Webhooks/ShowController.php b/app/Http/Controllers/Webhooks/ShowController.phpindex 46c9121217..37e0e03003 100644--- a/app/Http/Controllers/Webhooks/ShowController.php+++ b/app/Http/Controllers/Webhooks/ShowController.php@@ -49,7 +49,7 @@ class ShowController extends Controllerstatic function ($request, $next) {app('view')->share('mainTitleIcon', 'fa-bolt');app('view')->share('subTitleIcon', 'fa-bolt');- app('view')->share('title', (string)trans('firefly.webhooks'));+ app('view')->share('title', (string) trans('firefly.webhooks'));return $next($request);}@@ -69,7 +69,7 @@ class ShowController extends Controllerthrow new NotFoundHttpException('Webhooks are not enabled.');}Log::channel('audit')->info(sprintf('User visits webhook #%d page.', $webhook->id));- $subTitle = (string)trans('firefly.show_webhook', ['title' => $webhook->title]);+ $subTitle = (string) trans('firefly.show_webhook', ['title' => $webhook->title]);return view('webhooks.show', compact('webhook', 'subTitle'));}diff --git a/app/Http/Middleware/AcceptHeaders.php b/app/Http/Middleware/AcceptHeaders.phpindex 8c525a4a52..e3cd497da4 100644--- a/app/Http/Middleware/AcceptHeaders.php+++ b/app/Http/Middleware/AcceptHeaders.php@@ -43,7 +43,7 @@ class AcceptHeaders$method = $request->getMethod();$accepts = ['application/x-www-form-urlencoded', 'application/json', 'application/vnd.api+json', 'application/octet-stream', '*/*'];$contentTypes = ['application/x-www-form-urlencoded', 'application/json', 'application/vnd.api+json', 'application/octet-stream'];- $submitted = (string)$request->header('Content-Type');+ $submitted = (string) $request->header('Content-Type');// if bad Accept header, send error.if (!$request->accepts($accepts)) {diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.phpindex 400482d09d..eec83beed2 100644--- a/app/Http/Middleware/Authenticate.php+++ b/app/Http/Middleware/Authenticate.php@@ -122,10 +122,10 @@ class Authenticate}if (null !== $user) {// app('log')->debug(get_class($user));- if (1 === (int)$user->blocked) {- $message = (string)trans('firefly.block_account_logout');+ if (1 === (int) $user->blocked) {+ $message = (string) trans('firefly.block_account_logout');if ('email_changed' === $user->blocked_code) {- $message = (string)trans('firefly.email_changed_logout');+ $message = (string) trans('firefly.email_changed_logout');}app('log')->warning('User is blocked, cannot use authentication method.');app('session')->flash('logoutMessage', $message);diff --git a/app/Http/Middleware/Installer.php b/app/Http/Middleware/Installer.phpindex fbaed7f43b..069df131c2 100644--- a/app/Http/Middleware/Installer.php+++ b/app/Http/Middleware/Installer.php@@ -132,8 +132,8 @@ class Installerprivate function oldDBVersion(): bool{// older version in config than database?- $configVersion = (int)config('firefly.db_version');- $dbVersion = (int)app('fireflyconfig')->getFresh('db_version', 1)->data;+ $configVersion = (int) config('firefly.db_version');+ $dbVersion = (int) app('fireflyconfig')->getFresh('db_version', 1)->data;if ($configVersion > $dbVersion) {Log::warning(sprintf(@@ -157,8 +157,8 @@ class Installerprivate function oldVersion(): bool{// version compare thing.- $configVersion = (string)config('firefly.version');- $dbVersion = (string)app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;+ $configVersion = (string) config('firefly.version');+ $dbVersion = (string) app('fireflyconfig')->getFresh('ff3_version', '1.0')->data;if (str_starts_with($configVersion, 'develop')) {Log::debug('Skipping version check for develop version.');diff --git a/app/Http/Middleware/InterestingMessage.php b/app/Http/Middleware/InterestingMessage.phpindex 91a5b1e041..c1fea3583b 100644--- a/app/Http/Middleware/InterestingMessage.php+++ b/app/Http/Middleware/InterestingMessage.php@@ -95,7 +95,7 @@ class InterestingMessage// send message about newly created transaction group./** @var null|TransactionGroup $group */- $group = auth()->user()->transactionGroups()->with(['transactionJournals', 'transactionJournals.transactionType'])->find((int)$transactionGroupId);+ $group = auth()->user()->transactionGroups()->with(['transactionJournals', 'transactionJournals.transactionType'])->find((int) $transactionGroupId);if (null === $group) {return;@@ -111,17 +111,17 @@ class InterestingMessage$title = $count > 1 ? $group->title : $journal->description;if ('created' === $message) {session()->flash('success_url', route('transactions.show', [$transactionGroupId]));- session()->flash('success', (string)trans('firefly.stored_journal', ['description' => $title]));+ session()->flash('success', (string) trans('firefly.stored_journal', ['description' => $title]));}if ('updated' === $message) {$type = strtolower($journal->transactionType->type);session()->flash('success_url', route('transactions.show', [$transactionGroupId]));- session()->flash('success', (string)trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));+ session()->flash('success', (string) trans(sprintf('firefly.updated_%s', $type), ['description' => $title]));}if ('no_change' === $message) {$type = strtolower($journal->transactionType->type);session()->flash('warning_url', route('transactions.show', [$transactionGroupId]));- session()->flash('warning', (string)trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));+ session()->flash('warning', (string) trans(sprintf('firefly.no_changes_%s', $type), ['description' => $title]));}}@@ -147,13 +147,13 @@ class InterestingMessagereturn;}if ('deleted' === $message) {- session()->flash('success', (string)trans('firefly.account_deleted', ['name' => $account->name]));+ session()->flash('success', (string) trans('firefly.account_deleted', ['name' => $account->name]));}if ('created' === $message) {- session()->flash('success', (string)trans('firefly.stored_new_account', ['name' => $account->name]));+ session()->flash('success', (string) trans('firefly.stored_new_account', ['name' => $account->name]));}if ('updated' === $message) {- session()->flash('success', (string)trans('firefly.updated_account', ['name' => $account->name]));+ session()->flash('success', (string) trans('firefly.updated_account', ['name' => $account->name]));}}@@ -179,10 +179,10 @@ class InterestingMessagereturn;}if ('deleted' === $message) {- session()->flash('success', (string)trans('firefly.deleted_bill', ['name' => $bill->name]));+ session()->flash('success', (string) trans('firefly.deleted_bill', ['name' => $bill->name]));}if ('created' === $message) {- session()->flash('success', (string)trans('firefly.stored_new_bill', ['name' => $bill->name]));+ session()->flash('success', (string) trans('firefly.stored_new_bill', ['name' => $bill->name]));}}@@ -208,13 +208,13 @@ class InterestingMessagereturn;}if ('deleted' === $message) {- session()->flash('success', (string)trans('firefly.deleted_webhook', ['title' => $webhook->title]));+ session()->flash('success', (string) trans('firefly.deleted_webhook', ['title' => $webhook->title]));}if ('updated' === $message) {- session()->flash('success', (string)trans('firefly.updated_webhook', ['title' => $webhook->title]));+ session()->flash('success', (string) trans('firefly.updated_webhook', ['title' => $webhook->title]));}if ('created' === $message) {- session()->flash('success', (string)trans('firefly.stored_new_webhook', ['title' => $webhook->title]));+ session()->flash('success', (string) trans('firefly.stored_new_webhook', ['title' => $webhook->title]));}}@@ -241,22 +241,22 @@ class InterestingMessagereturn;}if ('enabled' === $message) {- session()->flash('success', (string)trans('firefly.currency_is_now_enabled', ['name' => $currency->name]));+ session()->flash('success', (string) trans('firefly.currency_is_now_enabled', ['name' => $currency->name]));}if ('enable_failed' === $message) {- session()->flash('error', (string)trans('firefly.could_not_enable_currency', ['name' => $currency->name]));+ session()->flash('error', (string) trans('firefly.could_not_enable_currency', ['name' => $currency->name]));}if ('disabled' === $message) {- session()->flash('success', (string)trans('firefly.currency_is_now_disabled', ['name' => $currency->name]));+ session()->flash('success', (string) trans('firefly.currency_is_now_disabled', ['name' => $currency->name]));}if ('disable_failed' === $message) {- session()->flash('error', (string)trans('firefly.could_not_disable_currency', ['name' => $currency->name]));+ session()->flash('error', (string) trans('firefly.could_not_disable_currency', ['name' => $currency->name]));}if ('default' === $message) {- session()->flash('success', (string)trans('firefly.new_default_currency', ['name' => $currency->name]));+ session()->flash('success', (string) trans('firefly.new_default_currency', ['name' => $currency->name]));}if ('default_failed' === $message) {- session()->flash('error', (string)trans('firefly.default_currency_failed', ['name' => $currency->name]));+ session()->flash('error', (string) trans('firefly.default_currency_failed', ['name' => $currency->name]));}}}diff --git a/app/Http/Middleware/IsDemoUser.php b/app/Http/Middleware/IsDemoUser.phpindex 0cc04ddc18..c984e947a5 100644--- a/app/Http/Middleware/IsDemoUser.php+++ b/app/Http/Middleware/IsDemoUser.php@@ -49,7 +49,7 @@ class IsDemoUser$repository = app(UserRepositoryInterface::class);if ($repository->hasRole($user, 'demo')) {app('log')->info('User is a demo user.');- $request->session()->flash('info', (string)trans('firefly.not_available_demo_user'));+ $request->session()->flash('info', (string) trans('firefly.not_available_demo_user'));$current = $request->url();$previous = $request->session()->previousUrl();if ($current !== $previous) {diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.phpindex 1886600e38..228b4bda88 100644--- a/app/Http/Middleware/Range.php+++ b/app/Http/Middleware/Range.php@@ -71,8 +71,8 @@ class Range}$today = today(config('app.timezone'));- $start = app('navigation')->updateStartDate((string)$viewRange, $today);- $end = app('navigation')->updateEndDate((string)$viewRange, $start);+ $start = app('navigation')->updateStartDate((string) $viewRange, $today);+ $end = app('navigation')->updateEndDate((string) $viewRange, $start);app('session')->put('start', $start);app('session')->put('end', $end);@@ -115,12 +115,12 @@ class Range}// save some formats:- $monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);- $dateTimeFormat = (string)trans('config.date_time_js', [], $locale);+ $monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);+ $dateTimeFormat = (string) trans('config.date_time_js', [], $locale);$defaultCurrency = app('amount')->getDefaultCurrency();// also format for moment JS:- $madMomentJS = (string)trans('config.month_and_day_moment_js', [], $locale);+ $madMomentJS = (string) trans('config.month_and_day_moment_js', [], $locale);app('view')->share('madMomentJS', $madMomentJS);app('view')->share('monthAndDayFormat', $monthAndDayFormat);diff --git a/app/Http/Middleware/SecureHeaders.php b/app/Http/Middleware/SecureHeaders.phpindex d4c749a31c..2220dbfee7 100644--- a/app/Http/Middleware/SecureHeaders.php+++ b/app/Http/Middleware/SecureHeaders.php@@ -24,9 +24,9 @@ declare(strict_types=1);namespace FireflyIII\Http\Middleware;+use Barryvdh\Debugbar\Facades\Debugbar;use Illuminate\Http\Request;use Illuminate\Support\Facades\Vite;-use Barryvdh\Debugbar\Facades\Debugbar;/*** Class SecureHeadersdiff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.phpindex 5b778c0a78..d68f3054be 100644--- a/app/Http/Middleware/TrustProxies.php+++ b/app/Http/Middleware/TrustProxies.php@@ -44,6 +44,6 @@ class TrustProxies extends Middleware*/public function __construct(){- $this->proxies = (string)config('firefly.trusted_proxies');+ $this->proxies = (string) config('firefly.trusted_proxies');}}diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.phpindex beb7146345..748eae98b9 100644--- a/app/Http/Middleware/VerifyCsrfToken.php+++ b/app/Http/Middleware/VerifyCsrfToken.php@@ -30,7 +30,8 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;*/class VerifyCsrfToken extends Middleware{- protected $except = [- 'oauth/token',- ];+ protected $except+ = [+ 'oauth/token',+ ];}diff --git a/app/Http/Requests/JournalLinkRequest.php b/app/Http/Requests/JournalLinkRequest.phpindex 6e2e083f11..f03e2bf323 100644--- a/app/Http/Requests/JournalLinkRequest.php+++ b/app/Http/Requests/JournalLinkRequest.php@@ -46,7 +46,7 @@ class JournalLinkRequest extends FormRequest$return = [];$linkType = $this->get('link_type');$parts = explode('_', $linkType);- $return['link_type_id'] = (int)$parts[0];+ $return['link_type_id'] = (int) $parts[0];$return['transaction_journal_id'] = $this->convertInteger('opposing');$return['notes'] = $this->convertString('notes');$return['direction'] = $parts[1];diff --git a/app/Http/Requests/NotificationRequest.php b/app/Http/Requests/NotificationRequest.phpindex f86016bb43..9ac3569206 100644--- a/app/Http/Requests/NotificationRequest.php+++ b/app/Http/Requests/NotificationRequest.php@@ -64,10 +64,10 @@ class NotificationRequest extends FormRequestpublic function rules(): array{$rules = [- 'slack_webhook_url' => ['nullable', 'url', 'min:1', new IsValidSlackOrDiscordUrl()],- 'ntfy_server' => ['nullable', 'url', 'min:1'],- 'ntfy_user' => ['required_with:ntfy_pass,ntfy_auth', 'nullable', 'string', 'min:1'],- 'ntfy_pass' => ['required_with:ntfy_user,ntfy_auth', 'nullable', 'string', 'min:1'],+ 'slack_webhook_url' => ['nullable', 'url', 'min:1', new IsValidSlackOrDiscordUrl()],+ 'ntfy_server' => ['nullable', 'url', 'min:1'],+ 'ntfy_user' => ['required_with:ntfy_pass,ntfy_auth', 'nullable', 'string', 'min:1'],+ 'ntfy_pass' => ['required_with:ntfy_user,ntfy_auth', 'nullable', 'string', 'min:1'],];foreach (config('notifications.notifications.owner') as $key => $info) {$rules[sprintf('notification_%s', $key)] = 'in:0,1';diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.phpindex 185f610490..dbb4c5d4e4 100644--- a/app/Http/Requests/RecurrenceFormRequest.php+++ b/app/Http/Requests/RecurrenceFormRequest.php@@ -311,18 +311,18 @@ class RecurrenceFormRequest extends FormRequest$throwError = true;if ('withdrawal' === $type) {$throwError = false;- $sourceId = (int)$data['source_id'];- $destinationId = (int)$data['withdrawal_destination_id'];+ $sourceId = (int) $data['source_id'];+ $destinationId = (int) $data['withdrawal_destination_id'];}if ('deposit' === $type) {$throwError = false;- $sourceId = (int)$data['deposit_source_id'];- $destinationId = (int)($data['destination_id'] ?? 0);+ $sourceId = (int) $data['deposit_source_id'];+ $destinationId = (int) ($data['destination_id'] ?? 0);}if ('transfer' === $type) {$throwError = false;- $sourceId = (int)$data['source_id'];- $destinationId = (int)($data['destination_id'] ?? 0);+ $sourceId = (int) $data['source_id'];+ $destinationId = (int) ($data['destination_id'] ?? 0);}if (true === $throwError) {throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type')));@@ -333,7 +333,7 @@ class RecurrenceFormRequest extends FormRequest// do something with result:if (false === $validSource) {- $message = (string)trans('validation.generic_invalid_source');+ $message = (string) trans('validation.generic_invalid_source');$validator->errors()->add('source_id', $message);$validator->errors()->add('deposit_source_id', $message);@@ -344,7 +344,7 @@ class RecurrenceFormRequest extends FormRequest$validDestination = $accountValidator->validateDestination(['id' => $destinationId]);// do something with result:if (false === $validDestination) {- $message = (string)trans('validation.generic_invalid_destination');+ $message = (string) trans('validation.generic_invalid_destination');$validator->errors()->add('destination_id', $message);$validator->errors()->add('withdrawal_destination_id', $message);}diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.phpindex 3a0977bbe7..da6c5e4417 100644--- a/app/Http/Requests/ReportFormRequest.php+++ b/app/Http/Requests/ReportFormRequest.php@@ -55,7 +55,7 @@ class ReportFormRequest extends FormRequest$collection = new Collection();if (is_array($set)) {foreach ($set as $accountId) {- $account = $repository->find((int)$accountId);+ $account = $repository->find((int) $accountId);if (null !== $account) {$collection->push($account);}@@ -76,7 +76,7 @@ class ReportFormRequest extends FormRequest$collection = new Collection();if (is_array($set)) {foreach ($set as $budgetId) {- $budget = $repository->find((int)$budgetId);+ $budget = $repository->find((int) $budgetId);if (null !== $budget) {$collection->push($budget);}@@ -97,7 +97,7 @@ class ReportFormRequest extends FormRequest$collection = new Collection();if (is_array($set)) {foreach ($set as $categoryId) {- $category = $repository->find((int)$categoryId);+ $category = $repository->find((int) $categoryId);if (null !== $category) {$collection->push($category);}@@ -118,7 +118,7 @@ class ReportFormRequest extends FormRequest$collection = new Collection();if (is_array($set)) {foreach ($set as $accountId) {- $account = $repository->find((int)$accountId);+ $account = $repository->find((int) $accountId);if (null !== $account) {$collection->push($account);}@@ -137,7 +137,7 @@ class ReportFormRequest extends FormRequest{$date = today(config('app.timezone'));$range = $this->get('daterange');- $parts = explode(' - ', (string)$range);+ $parts = explode(' - ', (string) $range);if (2 === count($parts)) {$string = $parts[1];// validate as date@@ -175,7 +175,7 @@ class ReportFormRequest extends FormRequest{$date = today(config('app.timezone'));$range = $this->get('daterange');- $parts = explode(' - ', (string)$range);+ $parts = explode(' - ', (string) $range);if (2 === count($parts)) {$string = $parts[0];// validate as date@@ -229,7 +229,7 @@ class ReportFormRequest extends FormRequestcontinue;}- $tag = $repository->find((int)$tagTag);+ $tag = $repository->find((int) $tagTag);if (null !== $tag) {$collection->push($tag);}diff --git a/app/Http/Requests/RuleFormRequest.php b/app/Http/Requests/RuleFormRequest.phpindex e897b1847d..aadf8c7fee 100644--- a/app/Http/Requests/RuleFormRequest.php+++ b/app/Http/Requests/RuleFormRequest.php@@ -70,8 +70,8 @@ class RuleFormRequest extends FormRequest$set = ['type' => $trigger['type'] ?? 'invalid','value' => $trigger['value'] ?? '',- 'stop_processing' => 1 === (int)$stopProcessing,- 'prohibited' => 1 === (int)$prohibited,+ 'stop_processing' => 1 === (int) $stopProcessing,+ 'prohibited' => 1 === (int) $prohibited,];$set = self::replaceAmountTrigger($set);$return[] = $set;@@ -116,7 +116,7 @@ class RuleFormRequest extends FormRequest$return[] = ['type' => $action['type'] ?? 'invalid','value' => $action['value'] ?? '',- 'stop_processing' => 1 === (int)$stopProcessing,+ 'stop_processing' => 1 === (int) $stopProcessing,];}}diff --git a/app/Jobs/CreateAutoBudgetLimits.php b/app/Jobs/CreateAutoBudgetLimits.phpindex ce0c15e173..e781cebb8a 100644--- a/app/Jobs/CreateAutoBudgetLimits.php+++ b/app/Jobs/CreateAutoBudgetLimits.php@@ -126,7 +126,7 @@ class CreateAutoBudgetLimits implements ShouldQueue// find budget limit:$budgetLimit = $this->findBudgetLimit($autoBudget->budget, $start, $end);- if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_RESET === (int)$autoBudget->auto_budget_type) {+ if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_RESET === (int) $autoBudget->auto_budget_type) {// that's easy: create one.// do nothing else.$this->createBudgetLimit($autoBudget, $start, $end);@@ -135,14 +135,14 @@ class CreateAutoBudgetLimits implements ShouldQueuereturn;}- if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ROLLOVER === (int)$autoBudget->auto_budget_type) {+ if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ROLLOVER === (int) $autoBudget->auto_budget_type) {// budget limit exists already,$this->createRollover($autoBudget);app('log')->debug(sprintf('Done with auto budget #%d', $autoBudget->id));return;}- if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ADJUSTED === (int)$autoBudget->auto_budget_type) {+ if (null === $budgetLimit && AutoBudget::AUTO_BUDGET_ADJUSTED === (int) $autoBudget->auto_budget_type) {// budget limit exists already,$this->createAdjustedLimit($autoBudget);app('log')->debug(sprintf('Done with auto budget #%d', $autoBudget->id));diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.phpindex 0efae2a1a9..540eff0ba9 100644--- a/app/Jobs/CreateRecurringTransactions.php+++ b/app/Jobs/CreateRecurringTransactions.php@@ -441,7 +441,7 @@ class CreateRecurringTransactions implements ShouldQueue'identifier' => $index,'recurrence_id' => $recurrence->id,'order' => $index,- 'notes' => (string)trans('firefly.created_from_recurrence', ['id' => $recurrence->id, 'title' => $recurrence->title]),+ 'notes' => (string) trans('firefly.created_from_recurrence', ['id' => $recurrence->id, 'title' => $recurrence->title]),'tags' => $this->repository->getTags($transaction),'piggy_bank_id' => $this->repository->getPiggyBank($transaction),'piggy_bank_name' => null,diff --git a/app/Jobs/DownloadExchangeRates.php b/app/Jobs/DownloadExchangeRates.phpindex e4a45a4bbd..17bf251f1d 100644--- a/app/Jobs/DownloadExchangeRates.php+++ b/app/Jobs/DownloadExchangeRates.php@@ -95,7 +95,7 @@ class DownloadExchangeRates implements ShouldQueueprivate function downloadRates(TransactionCurrency $currency): void{app('log')->debug(sprintf('Now downloading new exchange rates for currency %s.', $currency->code));- $base = sprintf('%s/%s/%s', (string)config('cer.url'), $this->date->year, $this->date->isoWeek);+ $base = sprintf('%s/%s/%s', (string) config('cer.url'), $this->date->year, $this->date->isoWeek);$client = new Client();$url = sprintf('%s/%s.json', $base, $currency->code);@@ -112,7 +112,7 @@ class DownloadExchangeRates implements ShouldQueuereturn;}- $body = (string)$res->getBody();+ $body = (string) $res->getBody();$json = json_decode($body, true);if (false === $json || null === $json) {app('log')->warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url));diff --git a/app/Jobs/MailError.php b/app/Jobs/MailError.phpindex 7d838228f8..16c9ad02a1 100644--- a/app/Jobs/MailError.php+++ b/app/Jobs/MailError.php@@ -63,7 +63,7 @@ class MailError extends Job implements ShouldQueue*/public function handle(): void{- $email = (string)config('firefly.site_owner');+ $email = (string) config('firefly.site_owner');$args = $this->exception;$args['loggedIn'] = $this->userData['id'] > 0;$args['user'] = $this->userData;@@ -84,7 +84,7 @@ class MailError extends Job implements ShouldQueue$args,static function (Message $message) use ($email): void {if ('[email protected]' !== $email) {- $message->to($email, $email)->subject((string)trans('email.error_subject'));+ $message->to($email, $email)->subject((string) trans('email.error_subject'));}});@@ -130,7 +130,7 @@ class MailError extends Job implements ShouldQueue}if (file_exists($file)) {Log::debug(sprintf('Read file in "%s"', $file));- $limits = json_decode((string)file_get_contents($file), true);+ $limits = json_decode((string) file_get_contents($file), true);}// limit reached?foreach ($types as $type => $info) {diff --git a/app/Jobs/WarnAboutBills.php b/app/Jobs/WarnAboutBills.phpindex 086a61407b..e79e05ea58 100644--- a/app/Jobs/WarnAboutBills.php+++ b/app/Jobs/WarnAboutBills.php@@ -128,7 +128,7 @@ class WarnAboutBills implements ShouldQueue$today = clone $this->date;$carbon = clone $bill->{$field};- return (int)$today->diffInDays($carbon);+ return (int) $today->diffInDays($carbon);}private function sendWarning(Bill $bill, string $field): voiddiff --git a/app/JsonApi/V2/AccountBalances/AccountBalanceResource.php b/app/JsonApi/V2/AccountBalances/AccountBalanceResource.phpindex e9d3520556..d4a6841575 100644--- a/app/JsonApi/V2/AccountBalances/AccountBalanceResource.php+++ b/app/JsonApi/V2/AccountBalances/AccountBalanceResource.php@@ -9,14 +9,6 @@ use LaravelJsonApi\Core\Resources\JsonApiResource;class AccountBalanceResource extends JsonApiResource{- /**- * Get the resource id.- */- public function id(): string- {- return $this->resource->id;- }-/*** Get the resource's attributes.*@@ -30,6 +22,14 @@ class AccountBalanceResource extends JsonApiResource];}+ /**+ * Get the resource id.+ */+ public function id(): string+ {+ return $this->resource->id;+ }+/*** Get the resource's relationships.*diff --git a/app/JsonApi/V2/Accounts/AccountCollectionQuery.php b/app/JsonApi/V2/Accounts/AccountCollectionQuery.phpindex f736556a08..e4fac9c4e9 100644--- a/app/JsonApi/V2/Accounts/AccountCollectionQuery.php+++ b/app/JsonApi/V2/Accounts/AccountCollectionQuery.php@@ -24,50 +24,50 @@ class AccountCollectionQuery extends ResourceQuery$validFilters = config('api.valid_api_filters')[Account::class];return [- 'fields' => [+ 'fields' => ['nullable','array',JsonApiRule::fieldSets(),],- 'userGroupId' => [+ 'userGroupId' => ['nullable','integer',new IsAllowedGroupAction(Account::class, request()->method()),],- 'startPeriod' => [+ 'startPeriod' => ['nullable','date',new IsDateOrTime(),new IsValidDateRange(),],- 'endPeriod' => [+ 'endPeriod' => ['nullable','date',new IsDateOrTime(),new IsValidDateRange(),],- 'filter' => [+ 'filter' => ['nullable','array',JsonApiRule::filter($validFilters),new IsValidAccountType(),],- 'include' => [+ 'include' => ['nullable','string',JsonApiRule::includePaths(),],- 'page' => [+ 'page' => ['nullable','array',JsonApiRule::page(),],- 'sort' => [+ 'sort' => ['nullable','string',JsonApiRule::sort(),],- 'withCount' => [+ 'withCount' => ['nullable','string',JsonApiRule::countable(),diff --git a/app/JsonApi/V2/Accounts/AccountRequest.php b/app/JsonApi/V2/Accounts/AccountRequest.phpindex 8926e572bf..faf9cf9b78 100644--- a/app/JsonApi/V2/Accounts/AccountRequest.php+++ b/app/JsonApi/V2/Accounts/AccountRequest.php@@ -4,11 +4,6 @@ declare(strict_types=1);namespace FireflyIII\JsonApi\V2\Accounts;-use FireflyIII\Rules\Account\IsUniqueAccount;-use FireflyIII\Rules\IsBoolean;-use FireflyIII\Rules\IsValidPositiveAmount;-use FireflyIII\Rules\UniqueAccountNumber;-use FireflyIII\Rules\UniqueIban;use FireflyIII\Support\Request\ConvertsDataTypes;use Illuminate\Support\Facades\Log;use LaravelJsonApi\Laravel\Http\Requests\ResourceRequest;@@ -30,8 +25,8 @@ class AccountRequest extends ResourceRequest// var_dump($types);exit;return [- 'name' => ['required', 'max:1024', 'min:1'], // , new IsUniqueAccount()- 'account_type' => ['required', 'max:1024', 'min:1', sprintf('in:%s', $types)],+ 'name' => ['required', 'max:1024', 'min:1'], // , new IsUniqueAccount()+ 'account_type' => ['required', 'max:1024', 'min:1', sprintf('in:%s', $types)],// 'iban' => ['iban', 'nullable', new UniqueIban(null, $type)],// 'bic' => 'bic|nullable',// 'account_number' => ['min:1', 'max:255', 'nullable', new UniqueAccountNumber(null, $type)],diff --git a/app/JsonApi/V2/Accounts/AccountResource.php b/app/JsonApi/V2/Accounts/AccountResource.phpindex 9ffa40aa1a..c88e7405b7 100644--- a/app/JsonApi/V2/Accounts/AccountResource.php+++ b/app/JsonApi/V2/Accounts/AccountResource.php@@ -13,14 +13,6 @@ use LaravelJsonApi\Core\Resources\JsonApiResource;*/class AccountResource extends JsonApiResource{- /**- * Get the resource id.- */- public function id(): string- {- return (string) $this->resource->id;- }-/*** Get the resource's attributes.*@@ -69,6 +61,14 @@ class AccountResource extends JsonApiResource];}+ /**+ * Get the resource id.+ */+ public function id(): string+ {+ return (string) $this->resource->id;+ }+/*** Get the resource's relationships.*diff --git a/app/JsonApi/V2/Accounts/AccountResourceOld.php b/app/JsonApi/V2/Accounts/AccountResourceOld.phpindex b26fb7380f..5e2298b873 100644--- a/app/JsonApi/V2/Accounts/AccountResourceOld.php+++ b/app/JsonApi/V2/Accounts/AccountResourceOld.php@@ -27,9 +27,9 @@ class AccountResourceOld extends JsonApiResource{// fields removed here have been migrated.return [- 'created_at' => $this->resource->created_at,- 'updated_at' => $this->resource->updated_at,- 'name' => $this->resource->name,+ 'created_at' => $this->resource->created_at,+ 'updated_at' => $this->resource->updated_at,+ 'name' => $this->resource->name,// 'virtual_balance' => $this->resource->virtual_balance,// 'native_balance' => $this->resource->native_balance,diff --git a/app/JsonApi/V2/Accounts/AccountSchema.php b/app/JsonApi/V2/Accounts/AccountSchema.phpindex 33a010992c..707b722b1a 100644--- a/app/JsonApi/V2/Accounts/AccountSchema.php+++ b/app/JsonApi/V2/Accounts/AccountSchema.php@@ -91,6 +91,13 @@ class AccountSchema extends Schemareturn $array;}+ public function pagination(): EnumerablePagination+ {+ Log::debug(__METHOD__);++ return EnumerablePagination::make();+ }+public function repository(): AccountRepository{Log::debug(__METHOD__);@@ -102,11 +109,4 @@ class AccountSchema extends Schema->withUserGroup($this->userGroup);}-- public function pagination(): EnumerablePagination- {- Log::debug(__METHOD__);-- return EnumerablePagination::make();- }}diff --git a/app/JsonApi/V2/Accounts/AccountSchemaOld.php b/app/JsonApi/V2/Accounts/AccountSchemaOld.phpindex 748f40891d..9494cb937b 100644--- a/app/JsonApi/V2/Accounts/AccountSchemaOld.php+++ b/app/JsonApi/V2/Accounts/AccountSchemaOld.php@@ -6,11 +6,8 @@ namespace FireflyIII\JsonApi\V2\Accounts;use FireflyIII\Models\Account;use LaravelJsonApi\Eloquent\Contracts\Paginator;-use LaravelJsonApi\Eloquent\Fields\Boolean;use LaravelJsonApi\Eloquent\Fields\DateTime;use LaravelJsonApi\Eloquent\Fields\ID;-use LaravelJsonApi\Eloquent\Fields\Number;-use LaravelJsonApi\Eloquent\Fields\Relations\HasMany;use LaravelJsonApi\Eloquent\Fields\Relations\HasOne;use LaravelJsonApi\Eloquent\Fields\Str;use LaravelJsonApi\Eloquent\Filters\WhereIdIn;diff --git a/app/JsonApi/V2/Accounts/Capabilities/AccountQuery.php b/app/JsonApi/V2/Accounts/Capabilities/AccountQuery.phpindex 65ab00a8ca..efd2dae2de 100644--- a/app/JsonApi/V2/Accounts/Capabilities/AccountQuery.php+++ b/app/JsonApi/V2/Accounts/Capabilities/AccountQuery.php@@ -127,16 +127,16 @@ class AccountQuery extends QueryAll implements HasPagination}#[\Override]- public function paginate(array $page): Page+ public function getOrPaginate(?array $page): iterable{exit('here weare');- // TODO: Implement paginate() method.+ // TODO: Implement getOrPaginate() method.}#[\Override]- public function getOrPaginate(?array $page): iterable+ public function paginate(array $page): Page{exit('here weare');- // TODO: Implement getOrPaginate() method.+ // TODO: Implement paginate() method.}}diff --git a/app/JsonApi/V2/Accounts/Capabilities/CrudAccount.php b/app/JsonApi/V2/Accounts/Capabilities/CrudAccount.phpindex 0c660d1e91..aec8e399dc 100644--- a/app/JsonApi/V2/Accounts/Capabilities/CrudAccount.php+++ b/app/JsonApi/V2/Accounts/Capabilities/CrudAccount.php@@ -34,6 +34,13 @@ class CrudAccount extends CrudResource{use CollectsCustomParameters;+ public function create(array $validatedData): Account+ {+ var_dump($validatedData);++ exit;+ }+/*** Read the supplied site.*/@@ -51,11 +58,4 @@ class CrudAccount extends CrudResourcereturn $enrichment->enrichSingle($account);}-- public function create(array $validatedData): Account- {- var_dump($validatedData);-- exit;- }}diff --git a/app/Mail/AccessTokenCreatedMail.php b/app/Mail/AccessTokenCreatedMail.phpindex a48bbcc900..12deb375c4 100644--- a/app/Mail/AccessTokenCreatedMail.php+++ b/app/Mail/AccessTokenCreatedMail.php@@ -50,7 +50,7 @@ class AccessTokenCreatedMail extends Mailable{return $this->markdown('emails.token-created')- ->subject((string)trans('email.access_token_created_subject'))+ ->subject((string) trans('email.access_token_created_subject'));}}diff --git a/app/Mail/AdminTestMail.php b/app/Mail/AdminTestMail.phpindex 1971dce7dc..a24f87d214 100644--- a/app/Mail/AdminTestMail.php+++ b/app/Mail/AdminTestMail.php@@ -53,7 +53,7 @@ class AdminTestMail extends Mailable{return $this->markdown('emails.admin-test')- ->subject((string)trans('email.admin_test_subject'))+ ->subject((string) trans('email.admin_test_subject'));}}diff --git a/app/Mail/BillWarningMail.php b/app/Mail/BillWarningMail.phpindex 588772148f..ac16d4a1de 100644--- a/app/Mail/BillWarningMail.php+++ b/app/Mail/BillWarningMail.php@@ -58,9 +58,9 @@ class BillWarningMail extends Mailable*/public function build(): self{- $subject = (string)trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);+ $subject = (string) trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);if (0 === $this->diff) {- $subject = (string)trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);+ $subject = (string) trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);}return $thisdiff --git a/app/Mail/ConfirmEmailChangeMail.php b/app/Mail/ConfirmEmailChangeMail.phpindex d4346eff6c..d5161e2a66 100644--- a/app/Mail/ConfirmEmailChangeMail.php+++ b/app/Mail/ConfirmEmailChangeMail.php@@ -62,7 +62,7 @@ class ConfirmEmailChangeMail extends Mailable// ->view('emails.confirm-email-change-html')// ->text('emails.confirm-email-change-text')->markdown('emails.confirm-email-change')- ->subject((string)trans('email.email_change_subject'))+ ->subject((string) trans('email.email_change_subject'));}}diff --git a/app/Mail/InvitationMail.php b/app/Mail/InvitationMail.phpindex 151e7d423a..36bae2e7bb 100644--- a/app/Mail/InvitationMail.php+++ b/app/Mail/InvitationMail.php@@ -49,7 +49,7 @@ class InvitationMail extends Mailable$this->invitee = $invitee;$this->admin = $admin;$this->url = $url;- $this->host = (string)parse_url($url, PHP_URL_HOST);+ $this->host = (string) parse_url($url, PHP_URL_HOST);}/**@@ -61,7 +61,7 @@ class InvitationMail extends Mailable{return $this->markdown('emails.invitation')- ->subject((string)trans('email.invite_user_subject'))+ ->subject((string) trans('email.invite_user_subject'));}}diff --git a/app/Mail/NewIPAddressWarningMail.php b/app/Mail/NewIPAddressWarningMail.phpindex e8fdf5ea86..a1a311977d 100644--- a/app/Mail/NewIPAddressWarningMail.php+++ b/app/Mail/NewIPAddressWarningMail.php@@ -56,7 +56,7 @@ class NewIPAddressWarningMail extends Mailable*/public function build(): self{- $this->time = now(config('app.timezone'))->isoFormat((string)trans('config.date_time_js'));+ $this->time = now(config('app.timezone'))->isoFormat((string) trans('config.date_time_js'));$this->host = '';try {@@ -71,7 +71,7 @@ class NewIPAddressWarningMail extends Mailablereturn $this->markdown('emails.new-ip')- ->subject((string)trans('email.login_from_new_ip'))+ ->subject((string) trans('email.login_from_new_ip'));}}diff --git a/app/Mail/OAuthTokenCreatedMail.php b/app/Mail/OAuthTokenCreatedMail.phpindex e6247d3475..3c252b6ad6 100644--- a/app/Mail/OAuthTokenCreatedMail.php+++ b/app/Mail/OAuthTokenCreatedMail.php@@ -56,7 +56,7 @@ class OAuthTokenCreatedMail extends Mailable{return $this->markdown('emails.oauth-client-created')- ->subject((string)trans('email.oauth_created_subject'))+ ->subject((string) trans('email.oauth_created_subject'));}}diff --git a/app/Mail/RegisteredUser.php b/app/Mail/RegisteredUser.phpindex 8659c8e3f9..fbbe6d2aaa 100644--- a/app/Mail/RegisteredUser.php+++ b/app/Mail/RegisteredUser.php@@ -56,7 +56,7 @@ class RegisteredUser extends Mailable{return $this->markdown('emails.registered')- ->subject((string)trans('email.registered_subject'))+ ->subject((string) trans('email.registered_subject'));}}diff --git a/app/Mail/RequestedNewPassword.php b/app/Mail/RequestedNewPassword.phpindex 0be46c5251..8d1342908e 100644--- a/app/Mail/RequestedNewPassword.php+++ b/app/Mail/RequestedNewPassword.php@@ -55,7 +55,7 @@ class RequestedNewPassword extends Mailable{return $this->markdown('emails.password')- ->subject((string)trans('email.reset_pw_subject'))+ ->subject((string) trans('email.reset_pw_subject'));}}diff --git a/app/Mail/UndoEmailChangeMail.php b/app/Mail/UndoEmailChangeMail.phpindex 70d243685a..5f676b24d3 100644--- a/app/Mail/UndoEmailChangeMail.php+++ b/app/Mail/UndoEmailChangeMail.php@@ -58,7 +58,7 @@ class UndoEmailChangeMail extends Mailable{return $this->markdown('emails.undo-email-change')- ->subject((string)trans('email.email_change_subject'))+ ->subject((string) trans('email.email_change_subject'));}}diff --git a/app/Models/Account.php b/app/Models/Account.phpindex f77143d846..fcb43a5878 100644--- a/app/Models/Account.php+++ b/app/Models/Account.php@@ -94,6 +94,11 @@ class Account extends Modelreturn $this->belongsTo(User::class);}+ public function accountBalances(): HasMany+ {+ return $this->hasMany(AccountBalance::class);+ }+public function accountType(): BelongsTo{return $this->belongsTo(AccountType::class);@@ -123,11 +128,6 @@ class Account extends Modelreturn $this->hasMany(AccountMeta::class);}- public function accountBalances(): HasMany- {- return $this->hasMany(AccountBalance::class);- }-public function getEditNameAttribute(): string{$name = $this->name;diff --git a/app/Models/AccountBalance.php b/app/Models/AccountBalance.phpindex c1d6ccb6e8..10fed8cea3 100644--- a/app/Models/AccountBalance.php+++ b/app/Models/AccountBalance.php@@ -15,15 +15,8 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;class AccountBalance extends Model{use HasFactory;- protected $fillable = ['account_id', 'title', 'transaction_currency_id', 'balance', 'date', 'date_tz'];- protected function casts(): array- {- return [- 'date' => SeparateTimezoneCaster::class,- 'balance' => 'string',- ];- }+ protected $fillable = ['account_id', 'title', 'transaction_currency_id', 'balance', 'date', 'date_tz'];public function account(): BelongsTo{@@ -34,4 +27,12 @@ class AccountBalance extends Model{return $this->belongsTo(TransactionCurrency::class);}++ protected function casts(): array+ {+ return [+ 'date' => SeparateTimezoneCaster::class,+ 'balance' => 'string',+ ];+ }}diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.phpindex 4beb609874..23c2a340d0 100644--- a/app/Models/AccountMeta.php+++ b/app/Models/AccountMeta.php@@ -52,7 +52,7 @@ class AccountMeta extends Modelpublic function getDataAttribute(mixed $value): string{- return (string)json_decode($value, true);+ return (string) json_decode($value, true);}public function setDataAttribute(mixed $value): voiddiff --git a/app/Models/AccountType.php b/app/Models/AccountType.phpindex c8bc76b399..d5eda3c24e 100644--- a/app/Models/AccountType.php+++ b/app/Models/AccountType.php@@ -23,7 +23,7 @@ declare(strict_types=1);namespace FireflyIII\Models;-use FireflyIII\Enums\AccountTypeEnum;+use Deprecated;use FireflyIII\Support\Models\ReturnsIntegerIdTrait;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\HasMany;@@ -35,46 +35,46 @@ class AccountType extends Model{use ReturnsIntegerIdTrait;- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string ASSET = 'Asset account';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string BENEFICIARY = 'Beneficiary account';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string CASH = 'Cash account';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string CREDITCARD = 'Credit card';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string DEBT = 'Debt';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string DEFAULT = 'Default account';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string EXPENSE = 'Expense account';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string IMPORT = 'Import account';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string INITIAL_BALANCE = 'Initial balance account';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string LIABILITY_CREDIT = 'Liability credit account';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string LOAN = 'Loan';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string MORTGAGE = 'Mortgage';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string RECONCILIATION = 'Reconciliation account';- #[\Deprecated] /** @deprecated */+ #[\Deprecated] /** @deprecated */public const string REVENUE = 'Revenue account';protected $castsdiff --git a/app/Models/Attachment.php b/app/Models/Attachment.phpindex 21552e0a19..4b910caf3a 100644--- a/app/Models/Attachment.php+++ b/app/Models/Attachment.php@@ -61,7 +61,7 @@ class Attachment extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $attachmentId = (int)$value;+ $attachmentId = (int) $value;/** @var User $user */$user = auth()->user();@@ -94,7 +94,7 @@ class Attachment extends Model*/public function fileName(): string{- return sprintf('at-%s.data', (string)$this->id);+ return sprintf('at-%s.data', (string) $this->id);}/**@@ -108,7 +108,7 @@ class Attachment extends Modelprotected function attachableId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/AuditLogEntry.php b/app/Models/AuditLogEntry.phpindex 9490d7302e..b754804345 100644--- a/app/Models/AuditLogEntry.php+++ b/app/Models/AuditLogEntry.php@@ -60,14 +60,14 @@ class AuditLogEntry extends Modelprotected function auditableId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function changerId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/AutoBudget.php b/app/Models/AutoBudget.phpindex 4504522edf..5adcd34e4d 100644--- a/app/Models/AutoBudget.php+++ b/app/Models/AutoBudget.php@@ -24,7 +24,6 @@ declare(strict_types=1);namespace FireflyIII\Models;-use FireflyIII\Enums\AutoBudgetType;use FireflyIII\Support\Models\ReturnsIntegerIdTrait;use Illuminate\Database\Eloquent\Casts\Attribute;use Illuminate\Database\Eloquent\Model;@@ -47,12 +46,12 @@ class AutoBudget extends Model#[\Deprecated]public const int AUTO_BUDGET_ROLLOVER = 2;+ protected $casts+ = [+ 'amount' => 'string',+ ];protected $fillable = ['budget_id', 'amount', 'period'];- protected $casts = [- 'amount' => 'string',- ];-public function budget(): BelongsTo{return $this->belongsTo(Budget::class);@@ -63,31 +62,31 @@ class AutoBudget extends Modelreturn $this->belongsTo(TransactionCurrency::class);}- protected function casts(): array- {- return [- // 'auto_budget_type' => AutoBudgetType::class,- ];- }-protected function amount(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}protected function budgetId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}+ protected function casts(): array+ {+ return [+ // 'auto_budget_type' => AutoBudgetType::class,+ ];+ }+protected function transactionCurrencyId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.phpindex 47d149637b..d2b8abc7a1 100644--- a/app/Models/AvailableBudget.php+++ b/app/Models/AvailableBudget.php@@ -62,7 +62,7 @@ class AvailableBudget extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $availableBudgetId = (int)$value;+ $availableBudgetId = (int) $value;/** @var User $user */$user = auth()->user();@@ -90,14 +90,14 @@ class AvailableBudget extends Modelprotected function amount(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}protected function transactionCurrencyId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/Bill.php b/app/Models/Bill.phpindex 9d41b9c5bc..45fc9beb73 100644--- a/app/Models/Bill.php+++ b/app/Models/Bill.php@@ -93,7 +93,7 @@ class Bill extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $billId = (int)$value;+ $billId = (int) $value;/** @var User $user */$user = auth()->user();@@ -139,7 +139,7 @@ class Bill extends Model*/public function setAmountMaxAttribute($value): void{- $this->attributes['amount_max'] = (string)$value;+ $this->attributes['amount_max'] = (string) $value;}/**@@ -147,7 +147,7 @@ class Bill extends Model*/public function setAmountMinAttribute($value): void{- $this->attributes['amount_min'] = (string)$value;+ $this->attributes['amount_min'] = (string) $value;}public function transactionCurrency(): BelongsTo@@ -166,7 +166,7 @@ class Bill extends Modelprotected function amountMax(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}@@ -176,14 +176,14 @@ class Bill extends Modelprotected function amountMin(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}protected function order(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}@@ -193,14 +193,14 @@ class Bill extends Modelprotected function skip(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function transactionCurrencyId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/Budget.php b/app/Models/Budget.phpindex 6293c5de8e..e131aead22 100644--- a/app/Models/Budget.php+++ b/app/Models/Budget.php@@ -65,7 +65,7 @@ class Budget extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $budgetId = (int)$value;+ $budgetId = (int) $value;/** @var User $user */$user = auth()->user();@@ -121,7 +121,7 @@ class Budget extends Modelprotected function order(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.phpindex 1f20c69482..e0adf91345 100644--- a/app/Models/BudgetLimit.php+++ b/app/Models/BudgetLimit.php@@ -67,7 +67,7 @@ class BudgetLimit extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $budgetLimitId = (int)$value;+ $budgetLimitId = (int) $value;$budgetLimit = self::where('budget_limits.id', $budgetLimitId)->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')->where('budgets.user_id', auth()->user()->id)@@ -86,11 +86,6 @@ class BudgetLimit extends Modelreturn $this->belongsTo(Budget::class);}- public function transactionCurrency(): BelongsTo- {- return $this->belongsTo(TransactionCurrency::class);- }-/*** Get all the notes.*/@@ -99,27 +94,32 @@ class BudgetLimit extends Modelreturn $this->morphMany(Note::class, 'noteable');}+ public function transactionCurrency(): BelongsTo+ {+ return $this->belongsTo(TransactionCurrency::class);+ }+/*** Get the amount*/protected function amount(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}protected function budgetId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function transactionCurrencyId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/Category.php b/app/Models/Category.phpindex 2cb4680c7a..11eb99b3ff 100644--- a/app/Models/Category.php+++ b/app/Models/Category.php@@ -63,7 +63,7 @@ class Category extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $categoryId = (int)$value;+ $categoryId = (int) $value;/** @var User $user */$user = auth()->user();diff --git a/app/Models/CurrencyExchangeRate.php b/app/Models/CurrencyExchangeRate.phpindex 2bd2dcbb2f..1bbcee0e15 100644--- a/app/Models/CurrencyExchangeRate.php+++ b/app/Models/CurrencyExchangeRate.php@@ -72,28 +72,28 @@ class CurrencyExchangeRate extends Modelprotected function fromCurrencyId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function rate(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}protected function toCurrencyId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function userRate(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}}diff --git a/app/Models/GroupMembership.php b/app/Models/GroupMembership.phpindex 208476f09d..99bd626cab 100644--- a/app/Models/GroupMembership.php+++ b/app/Models/GroupMembership.php@@ -59,7 +59,7 @@ class GroupMembership extends Modelprotected function userRoleId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/InvitedUser.php b/app/Models/InvitedUser.phpindex f0634c27db..c6ffed23e0 100644--- a/app/Models/InvitedUser.php+++ b/app/Models/InvitedUser.php@@ -53,7 +53,7 @@ class InvitedUser extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $attemptId = (int)$value;+ $attemptId = (int) $value;/** @var null|InvitedUser $attempt */$attempt = self::find($attemptId);diff --git a/app/Models/LinkType.php b/app/Models/LinkType.phpindex 23f4982e08..ce7a0a9558 100644--- a/app/Models/LinkType.php+++ b/app/Models/LinkType.php@@ -55,7 +55,7 @@ class LinkType extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $linkTypeId = (int)$value;+ $linkTypeId = (int) $value;$linkType = self::find($linkTypeId);if (null !== $linkType) {return $linkType;diff --git a/app/Models/Location.php b/app/Models/Location.phpindex fc5d4639c3..31f97af7bb 100644--- a/app/Models/Location.php+++ b/app/Models/Location.php@@ -82,7 +82,7 @@ class Location extends Modelprotected function locatableId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/Note.php b/app/Models/Note.phpindex 5afbfbed76..e0ce8a0e2b 100644--- a/app/Models/Note.php+++ b/app/Models/Note.php@@ -57,7 +57,7 @@ class Note extends Modelprotected function noteableId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/ObjectGroup.php b/app/Models/ObjectGroup.phpindex 7ec9a91ad3..1eebdba7d8 100644--- a/app/Models/ObjectGroup.php+++ b/app/Models/ObjectGroup.php@@ -58,7 +58,7 @@ class ObjectGroup extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $objectGroupId = (int)$value;+ $objectGroupId = (int) $value;/** @var null|ObjectGroup $objectGroup */$objectGroup = self::where('object_groups.id', $objectGroupId)@@ -104,7 +104,7 @@ class ObjectGroup extends Modelprotected function order(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.phpindex a53c5a49dd..7ffa94029d 100644--- a/app/Models/PiggyBank.php+++ b/app/Models/PiggyBank.php@@ -65,7 +65,7 @@ class PiggyBank extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $piggyBankId = (int)$value;+ $piggyBankId = (int) $value;$piggyBank = self::where('piggy_banks.id', $piggyBankId)->leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')@@ -79,14 +79,14 @@ class PiggyBank extends Modelthrow new NotFoundHttpException();}- public function transactionCurrency(): BelongsTo+ public function account(): BelongsTo{- return $this->belongsTo(TransactionCurrency::class);+ return $this->belongsTo(Account::class);}- public function account(): BelongsTo+ public function accounts(): BelongsToMany{- return $this->belongsTo(Account::class);+ return $this->belongsToMany(Account::class)->withPivot(['current_amount', 'native_current_amount']);}public function attachments(): MorphMany@@ -115,11 +115,6 @@ class PiggyBank extends Modelreturn $this->hasMany(PiggyBankEvent::class);}- public function accounts(): BelongsToMany- {- return $this->belongsToMany(Account::class)->withPivot(['current_amount', 'native_current_amount']);- }-public function piggyBankRepetitions(): HasMany{return $this->hasMany(PiggyBankRepetition::class);@@ -130,20 +125,25 @@ class PiggyBank extends Model*/public function setTargetAmountAttribute($value): void{- $this->attributes['target_amount'] = (string)$value;+ $this->attributes['target_amount'] = (string) $value;+ }++ public function transactionCurrency(): BelongsTo+ {+ return $this->belongsTo(TransactionCurrency::class);}protected function accountId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function order(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}@@ -153,7 +153,7 @@ class PiggyBank extends Modelprotected function targetAmount(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}}diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.phpindex f8f5a385a6..41df8cb704 100644--- a/app/Models/PiggyBankEvent.php+++ b/app/Models/PiggyBankEvent.php@@ -58,7 +58,7 @@ class PiggyBankEvent extends Model*/public function setAmountAttribute($value): void{- $this->attributes['amount'] = (string)$value;+ $this->attributes['amount'] = (string) $value;}public function transactionJournal(): BelongsTo@@ -72,14 +72,14 @@ class PiggyBankEvent extends Modelprotected function amount(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}protected function piggyBankId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.phpindex 2d8cd4b013..4a0a79c7cb 100644--- a/app/Models/PiggyBankRepetition.php+++ b/app/Models/PiggyBankRepetition.php@@ -40,11 +40,11 @@ class PiggyBankRepetition extends Modelprotected $casts= [- 'created_at' => 'datetime',- 'updated_at' => 'datetime',- 'start_date' => SeparateTimezoneCaster::class,- 'target_date' => SeparateTimezoneCaster::class,- 'virtual_balance' => 'string',+ 'created_at' => 'datetime',+ 'updated_at' => 'datetime',+ 'start_date' => SeparateTimezoneCaster::class,+ 'target_date' => SeparateTimezoneCaster::class,+ 'virtual_balance' => 'string',];protected $fillable = ['piggy_bank_id', 'start_date', 'start_date_tz', 'target_date', 'target_date_tz', 'current_amount'];@@ -84,7 +84,7 @@ class PiggyBankRepetition extends Model*/public function setCurrentAmountAttribute($value): void{- $this->attributes['current_amount'] = (string)$value;+ $this->attributes['current_amount'] = (string) $value;}/**@@ -93,14 +93,14 @@ class PiggyBankRepetition extends Modelprotected function currentAmount(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}protected function piggyBankId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/Preference.php b/app/Models/Preference.phpindex 233d11dc79..4aecc15d0c 100644--- a/app/Models/Preference.php+++ b/app/Models/Preference.php@@ -60,7 +60,7 @@ class Preference extends Model// some preferences do not have an administration ID.// some need it, to make sure the correct one is selected.- $userGroupId = (int)$user->user_group_id;+ $userGroupId = (int) $user->user_group_id;$userGroupId = 0 === $userGroupId ? null : $userGroupId;/** @var null|Preference $preference */@@ -77,7 +77,7 @@ class Preference extends Model// try again with ID, but this time don't care about the preferred user_group_idif (null === $preference) {- $preference = $user->preferences()->where('id', (int)$value)->first();+ $preference = $user->preferences()->where('id', (int) $value)->first();}if (null !== $preference) {return $preference;@@ -87,7 +87,7 @@ class Preference extends Model$preference = new self();$preference->name = $value;$preference->data = $default[$value];- $preference->user_id = (int)$user->id;+ $preference->user_id = (int) $user->id;$preference->user_group_id = in_array($value, $items, true) ? $userGroupId : null;$preference->save();diff --git a/app/Models/Recurrence.php b/app/Models/Recurrence.phpindex 62b75d3b2e..fdcdbf01db 100644--- a/app/Models/Recurrence.php+++ b/app/Models/Recurrence.php@@ -75,7 +75,7 @@ class Recurrence extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $recurrenceId = (int)$value;+ $recurrenceId = (int) $value;/** @var User $user */$user = auth()->user();@@ -136,7 +136,7 @@ class Recurrence extends Modelprotected function transactionTypeId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/RecurrenceMeta.php b/app/Models/RecurrenceMeta.phpindex 4fa9b14e25..82702a4535 100644--- a/app/Models/RecurrenceMeta.php+++ b/app/Models/RecurrenceMeta.php@@ -60,7 +60,7 @@ class RecurrenceMeta extends Modelprotected function recurrenceId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/RecurrenceRepetition.php b/app/Models/RecurrenceRepetition.phpindex 5680b09c51..f226d184ff 100644--- a/app/Models/RecurrenceRepetition.php+++ b/app/Models/RecurrenceRepetition.php@@ -24,7 +24,6 @@ declare(strict_types=1);namespace FireflyIII\Models;-use FireflyIII\Enums\RecurrenceRepetitionWeekend;use FireflyIII\Support\Models\ReturnsIntegerIdTrait;use Illuminate\Database\Eloquent\Casts\Attribute;use Illuminate\Database\Eloquent\Model;@@ -67,6 +66,11 @@ class RecurrenceRepetition extends Model/** @var string The table to store the data in */protected $table = 'recurrences_repetitions';+ public function recurrence(): BelongsTo+ {+ return $this->belongsTo(Recurrence::class);+ }+protected function casts(): array{return [@@ -74,29 +78,24 @@ class RecurrenceRepetition extends Model];}- public function recurrence(): BelongsTo- {- return $this->belongsTo(Recurrence::class);- }-protected function recurrenceId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function repetitionSkip(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function weekend(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/RecurrenceTransaction.php b/app/Models/RecurrenceTransaction.phpindex 1b7ee27173..777413b1eb 100644--- a/app/Models/RecurrenceTransaction.php+++ b/app/Models/RecurrenceTransaction.php@@ -102,49 +102,49 @@ class RecurrenceTransaction extends Modelprotected function amount(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}protected function destinationId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function foreignAmount(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}protected function recurrenceId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function sourceId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function transactionCurrencyId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function userId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/RecurrenceTransactionMeta.php b/app/Models/RecurrenceTransactionMeta.phpindex e84eb1ccde..7eadb34d98 100644--- a/app/Models/RecurrenceTransactionMeta.php+++ b/app/Models/RecurrenceTransactionMeta.php@@ -60,7 +60,7 @@ class RecurrenceTransactionMeta extends Modelprotected function rtId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/Rule.php b/app/Models/Rule.phpindex 804772e1de..fe1b0ff434 100644--- a/app/Models/Rule.php+++ b/app/Models/Rule.php@@ -64,7 +64,7 @@ class Rule extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $ruleId = (int)$value;+ $ruleId = (int) $value;/** @var User $user */$user = auth()->user();@@ -115,14 +115,14 @@ class Rule extends Modelprotected function order(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function ruleGroupId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/RuleAction.php b/app/Models/RuleAction.phpindex 6e63d55374..69732ce0cf 100644--- a/app/Models/RuleAction.php+++ b/app/Models/RuleAction.php@@ -54,7 +54,7 @@ class RuleAction extends Modelif (false === config('firefly.feature_flags.expression_engine')) {Log::debug('Expression engine is disabled, returning action value as string.');- return (string)$this->action_value;+ return (string) $this->action_value;}if (true === config('firefly.feature_flags.expression_engine') && str_starts_with($this->action_value, '\=')) {// return literal string.@@ -66,7 +66,7 @@ class RuleAction extends Model$result = $expr->evaluate($journal);} catch (SyntaxError $e) {Log::error(sprintf('Expression engine failed to evaluate expression "%s" with error "%s".', $this->action_value, $e->getMessage()));- $result = (string)$this->action_value;+ $result = (string) $this->action_value;}Log::debug(sprintf('Expression engine is enabled, result of expression "%s" is "%s".', $this->action_value, $result));@@ -81,14 +81,14 @@ class RuleAction extends Modelprotected function order(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function ruleId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.phpindex 0e5df95266..753fa95341 100644--- a/app/Models/RuleGroup.php+++ b/app/Models/RuleGroup.php@@ -62,7 +62,7 @@ class RuleGroup extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $ruleGroupId = (int)$value;+ $ruleGroupId = (int) $value;/** @var User $user */$user = auth()->user();@@ -90,7 +90,7 @@ class RuleGroup extends Modelprotected function order(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/RuleTrigger.php b/app/Models/RuleTrigger.phpindex 3a83d72246..3bcfe632a1 100644--- a/app/Models/RuleTrigger.php+++ b/app/Models/RuleTrigger.php@@ -54,14 +54,14 @@ class RuleTrigger extends Modelprotected function order(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function ruleId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/Tag.php b/app/Models/Tag.phpindex fa559ac459..571e15b4ac 100644--- a/app/Models/Tag.php+++ b/app/Models/Tag.php@@ -66,7 +66,7 @@ class Tag extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $tagId = (int)$value;+ $tagId = (int) $value;/** @var User $user */$user = auth()->user();diff --git a/app/Models/Transaction.php b/app/Models/Transaction.phpindex f2640398c2..45071d460f 100644--- a/app/Models/Transaction.php+++ b/app/Models/Transaction.php@@ -163,7 +163,7 @@ class Transaction extends Model*/public function setAmountAttribute($value): void{- $this->attributes['amount'] = (string)$value;+ $this->attributes['amount'] = (string) $value;}public function transactionCurrency(): BelongsTo@@ -179,24 +179,24 @@ class Transaction extends Modelprotected function accountId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}- protected function balanceDirty(): Attribute+ /**+ * Get the amount+ */+ protected function amount(): Attribute{return Attribute::make(- get: static fn ($value) => 1 === (int)$value,+ get: static fn ($value) => (string) $value,);}- /**- * Get the amount- */- protected function amount(): Attribute+ protected function balanceDirty(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => 1 === (int) $value,);}@@ -206,14 +206,14 @@ class Transaction extends Modelprotected function foreignAmount(): Attribute{return Attribute::make(- get: static fn ($value) => (string)$value,+ get: static fn ($value) => (string) $value,);}protected function transactionJournalId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.phpindex 05d9d7e3f9..2b159287dd 100644--- a/app/Models/TransactionCurrency.php+++ b/app/Models/TransactionCurrency.php@@ -61,7 +61,7 @@ class TransactionCurrency extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $currencyId = (int)$value;+ $currencyId = (int) $value;$currency = self::find($currencyId);if (null !== $currency) {$currency->refreshForUser(auth()->user());@@ -115,7 +115,7 @@ class TransactionCurrency extends Modelprotected function decimalPlaces(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.phpindex 36022272df..2e7024da86 100644--- a/app/Models/TransactionGroup.php+++ b/app/Models/TransactionGroup.php@@ -62,7 +62,7 @@ class TransactionGroup extends Model{app('log')->debug(sprintf('Now in %s("%s")', __METHOD__, $value));if (auth()->check()) {- $groupId = (int)$value;+ $groupId = (int) $value;/** @var User $user */$user = auth()->user();diff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.phpindex c50a422b7a..0ddc38d13e 100644--- a/app/Models/TransactionJournalLink.php+++ b/app/Models/TransactionJournalLink.php@@ -54,7 +54,7 @@ class TransactionJournalLink extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $linkId = (int)$value;+ $linkId = (int) $value;$link = self::where('journal_links.id', $linkId)->leftJoin('transaction_journals as t_a', 't_a.id', '=', 'source_id')->leftJoin('transaction_journals as t_b', 't_b.id', '=', 'destination_id')@@ -96,21 +96,21 @@ class TransactionJournalLink extends Modelprotected function destinationId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function linkTypeId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function sourceId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/TransactionJournalMeta.php b/app/Models/TransactionJournalMeta.phpindex cd7608a8e4..7c89f9f4bd 100644--- a/app/Models/TransactionJournalMeta.php+++ b/app/Models/TransactionJournalMeta.php@@ -66,7 +66,7 @@ class TransactionJournalMeta extends Model{$data = json_encode($value);$this->attributes['data'] = $data;- $this->attributes['hash'] = hash('sha256', (string)$data);+ $this->attributes['hash'] = hash('sha256', (string) $data);}public function transactionJournal(): BelongsTo@@ -77,7 +77,7 @@ class TransactionJournalMeta extends Modelprotected function transactionJournalId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.phpindex d0b948a469..ca0db35540 100644--- a/app/Models/TransactionType.php+++ b/app/Models/TransactionType.php@@ -23,7 +23,6 @@ declare(strict_types=1);namespace FireflyIII\Models;-use FireflyIII\Enums\TransactionTypeEnum;use FireflyIII\Support\Models\ReturnsIntegerIdTrait;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\Relations\HasMany;@@ -67,13 +66,6 @@ class TransactionType extends Model];protected $fillable = ['type'];- protected function casts(): array- {- return [- // 'type' => TransactionTypeEnum::class,- ];- }-/*** Route binder. Converts the key in the URL to the specified object (or throw 404).*@@ -116,4 +108,11 @@ class TransactionType extends Model{return $this->hasMany(TransactionJournal::class);}++ protected function casts(): array+ {+ return [+ // 'type' => TransactionTypeEnum::class,+ ];+ }}diff --git a/app/Models/UserGroup.php b/app/Models/UserGroup.phpindex 5019d37965..b3ed2716a9 100644--- a/app/Models/UserGroup.php+++ b/app/Models/UserGroup.php@@ -51,7 +51,7 @@ class UserGroup extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $userGroupId = (int)$value;+ $userGroupId = (int) $value;/** @var User $user */$user = auth()->user();diff --git a/app/Models/Webhook.php b/app/Models/Webhook.phpindex 203f231490..aa957a1220 100644--- a/app/Models/Webhook.php+++ b/app/Models/Webhook.php@@ -54,15 +54,6 @@ class Webhook extends Model];protected $fillable = ['active', 'trigger', 'response', 'delivery', 'user_id', 'user_group_id', 'url', 'title', 'secret'];- protected function casts(): array- {- return [- // 'delivery' => WebhookDelivery::class,- // 'response' => WebhookResponse::class,- // 'trigger' => WebhookTrigger::class,- ];- }-public static function getDeliveries(): array{$array = [];@@ -164,4 +155,13 @@ class Webhook extends Model{return $this->hasMany(WebhookMessage::class);}++ protected function casts(): array+ {+ return [+ // 'delivery' => WebhookDelivery::class,+ // 'response' => WebhookResponse::class,+ // 'trigger' => WebhookTrigger::class,+ ];+ }}diff --git a/app/Models/WebhookAttempt.php b/app/Models/WebhookAttempt.phpindex 7470f3deaf..e2249cd2fb 100644--- a/app/Models/WebhookAttempt.php+++ b/app/Models/WebhookAttempt.php@@ -48,7 +48,7 @@ class WebhookAttempt extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $attemptId = (int)$value;+ $attemptId = (int) $value;/** @var User $user */$user = auth()->user();@@ -71,7 +71,7 @@ class WebhookAttempt extends Modelprotected function webhookMessageId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Models/WebhookMessage.php b/app/Models/WebhookMessage.phpindex fcee310a45..adc5f9de4c 100644--- a/app/Models/WebhookMessage.php+++ b/app/Models/WebhookMessage.php@@ -56,7 +56,7 @@ class WebhookMessage extends Modelpublic static function routeBinder(string $value): self{if (auth()->check()) {- $messageId = (int)$value;+ $messageId = (int) $value;/** @var User $user */$user = auth()->user();@@ -87,14 +87,14 @@ class WebhookMessage extends Modelprotected function sent(): Attribute{return Attribute::make(- get: static fn ($value) => (bool)$value,+ get: static fn ($value) => (bool) $value,);}protected function webhookId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Notifications/Security/MFABackupFewLeftNotification.php b/app/Notifications/Security/MFABackupFewLeftNotification.phpindex 1d2bea958d..60ef94e2f0 100644--- a/app/Notifications/Security/MFABackupFewLeftNotification.php+++ b/app/Notifications/Security/MFABackupFewLeftNotification.php@@ -72,16 +72,6 @@ class MFABackupFewLeftNotification extends Notificationreturn (new MailMessage())->markdown('emails.security.few-backup-codes', ['user' => $this->user, 'count' => $this->count, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);}- /**- * @SuppressWarnings(PHPMD.UnusedFormalParameter)- */- public function toSlack(User $notifiable)- {- $message = (string) trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email, 'count' => $this->count]);-- return new SlackMessage()->content($message);- }-public function toNtfy(User $notifiable): Message{$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);@@ -103,6 +93,16 @@ class MFABackupFewLeftNotification extends Notification;}+ /**+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)+ */+ public function toSlack(User $notifiable)+ {+ $message = (string) trans('email.mfa_few_backups_left_slack', ['email' => $this->user->email, 'count' => $this->count]);++ return new SlackMessage()->content($message);+ }+/*** @SuppressWarnings(PHPMD.UnusedFormalParameter)*/diff --git a/app/Notifications/Security/MFABackupNoLeftNotification.php b/app/Notifications/Security/MFABackupNoLeftNotification.phpindex 3bea79e4ab..7c0344d9ce 100644--- a/app/Notifications/Security/MFABackupNoLeftNotification.php+++ b/app/Notifications/Security/MFABackupNoLeftNotification.php@@ -70,16 +70,6 @@ class MFABackupNoLeftNotification extends Notificationreturn (new MailMessage())->markdown('emails.security.no-backup-codes', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);}- /**- * @SuppressWarnings(PHPMD.UnusedFormalParameter)- */- public function toSlack(User $notifiable)- {- $message = (string) trans('email.mfa_no_backups_left_slack', ['email' => $this->user->email]);-- return new SlackMessage()->content($message);- }-public function toNtfy(User $notifiable): Message{$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);@@ -101,6 +91,16 @@ class MFABackupNoLeftNotification extends Notification;}+ /**+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)+ */+ public function toSlack(User $notifiable)+ {+ $message = (string) trans('email.mfa_no_backups_left_slack', ['email' => $this->user->email]);++ return new SlackMessage()->content($message);+ }+/*** @SuppressWarnings(PHPMD.UnusedFormalParameter)*/diff --git a/app/Notifications/Security/MFAManyFailedAttemptsNotification.php b/app/Notifications/Security/MFAManyFailedAttemptsNotification.phpindex bc867ab4c8..499c4d7ff8 100644--- a/app/Notifications/Security/MFAManyFailedAttemptsNotification.php+++ b/app/Notifications/Security/MFAManyFailedAttemptsNotification.php@@ -69,16 +69,6 @@ class MFAManyFailedAttemptsNotification extends Notificationreturn (new MailMessage())->markdown('emails.security.many-failed-attempts', ['user' => $this->user, 'count' => $this->count, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);}- /**- * @SuppressWarnings(PHPMD.UnusedFormalParameter)- */- public function toSlack(User $notifiable)- {- $message = (string) trans('email.mfa_many_failed_slack', ['email' => $this->user->email, 'count' => $this->count]);-- return new SlackMessage()->content($message);- }-public function toNtfy(User $notifiable): Message{$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);@@ -100,6 +90,16 @@ class MFAManyFailedAttemptsNotification extends Notification;}+ /**+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)+ */+ public function toSlack(User $notifiable)+ {+ $message = (string) trans('email.mfa_many_failed_slack', ['email' => $this->user->email, 'count' => $this->count]);++ return new SlackMessage()->content($message);+ }+/*** @SuppressWarnings(PHPMD.UnusedFormalParameter)*/diff --git a/app/Notifications/Security/MFAUsedBackupCodeNotification.php b/app/Notifications/Security/MFAUsedBackupCodeNotification.phpindex a98939a2b7..7c4b754c5c 100644--- a/app/Notifications/Security/MFAUsedBackupCodeNotification.php+++ b/app/Notifications/Security/MFAUsedBackupCodeNotification.php@@ -70,16 +70,6 @@ class MFAUsedBackupCodeNotification extends Notificationreturn (new MailMessage())->markdown('emails.security.used-backup-code', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);}- /**- * @SuppressWarnings(PHPMD.UnusedFormalParameter)- */- public function toSlack(User $notifiable)- {- $message = (string) trans('email.used_backup_code_slack', ['email' => $this->user->email]);-- return new SlackMessage()->content($message);- }-public function toNtfy(User $notifiable): Message{$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);@@ -101,6 +91,16 @@ class MFAUsedBackupCodeNotification extends Notification;}+ /**+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)+ */+ public function toSlack(User $notifiable)+ {+ $message = (string) trans('email.used_backup_code_slack', ['email' => $this->user->email]);++ return new SlackMessage()->content($message);+ }+/*** @SuppressWarnings(PHPMD.UnusedFormalParameter)*/diff --git a/app/Notifications/Security/NewBackupCodesNotification.php b/app/Notifications/Security/NewBackupCodesNotification.phpindex 43b4903301..c3a7e72144 100644--- a/app/Notifications/Security/NewBackupCodesNotification.php+++ b/app/Notifications/Security/NewBackupCodesNotification.php@@ -70,16 +70,6 @@ class NewBackupCodesNotification extends Notificationreturn (new MailMessage())->markdown('emails.security.new-backup-codes', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);}- /**- * @SuppressWarnings(PHPMD.UnusedFormalParameter)- */- public function toSlack(User $notifiable)- {- $message = (string) trans('email.new_backup_codes_slack', ['email' => $this->user->email]);-- return new SlackMessage()->content($message);- }-public function toNtfy(User $notifiable): Message{$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);@@ -101,6 +91,16 @@ class NewBackupCodesNotification extends Notification;}+ /**+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)+ */+ public function toSlack(User $notifiable)+ {+ $message = (string) trans('email.new_backup_codes_slack', ['email' => $this->user->email]);++ return new SlackMessage()->content($message);+ }+/*** @SuppressWarnings(PHPMD.UnusedFormalParameter)*/diff --git a/app/Notifications/Security/UserFailedLoginAttempt.php b/app/Notifications/Security/UserFailedLoginAttempt.phpindex 017294436a..25d02183e2 100644--- a/app/Notifications/Security/UserFailedLoginAttempt.php+++ b/app/Notifications/Security/UserFailedLoginAttempt.php@@ -67,16 +67,6 @@ class UserFailedLoginAttempt extends Notificationreturn (new MailMessage())->markdown('emails.security.failed-login', ['user' => $this->user, 'ip' => $ip, 'host' => $host, 'userAgent' => $userAgent, 'time' => $time])->subject($subject);}- /**- * @SuppressWarnings(PHPMD.UnusedFormalParameter)- */- public function toSlack(User $notifiable)- {- $message = (string) trans('email.failed_login_message', ['email' => $this->user->email]);-- return new SlackMessage()->content($message);- }-public function toNtfy(User $notifiable): Message{$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);@@ -98,6 +88,16 @@ class UserFailedLoginAttempt extends Notification;}+ /**+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)+ */+ public function toSlack(User $notifiable)+ {+ $message = (string) trans('email.failed_login_message', ['email' => $this->user->email]);++ return new SlackMessage()->content($message);+ }+/*** @SuppressWarnings(PHPMD.UnusedFormalParameter)*/diff --git a/app/Notifications/User/BillReminder.php b/app/Notifications/User/BillReminder.phpindex 94d2988b8f..4e65a0b55b 100644--- a/app/Notifications/User/BillReminder.php+++ b/app/Notifications/User/BillReminder.php@@ -73,21 +73,14 @@ class BillReminder extends Notification;}- /**- * @SuppressWarnings(PHPMD.UnusedFormalParameter)- */- public function toSlack(User $notifiable)+ private function getSubject(): string{- $bill = $this->bill;- $url = route('bills.show', [$bill->id]);+ $message = (string) trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);+ if (0 === $this->diff) {+ $message = (string) trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);+ }- return new SlackMessage()- ->warning()- ->attachment(static function ($attachment) use ($bill, $url): void {- $attachment->title((string) trans('firefly.visit_bill', ['name' => $bill->name]), $url);- })- ->content($this->getSubject())- ;+ return $message;}public function toNtfy(User $notifiable): Message@@ -111,14 +104,21 @@ class BillReminder extends Notification;}- private function getSubject(): string+ /**+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)+ */+ public function toSlack(User $notifiable){- $message = (string) trans(sprintf('email.bill_warning_subject_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);- if (0 === $this->diff) {- $message = (string) trans(sprintf('email.bill_warning_subject_now_%s', $this->field), ['diff' => $this->diff, 'name' => $this->bill->name]);- }+ $bill = $this->bill;+ $url = route('bills.show', [$bill->id]);- return $message;+ return new SlackMessage()+ ->warning()+ ->attachment(static function ($attachment) use ($bill, $url): void {+ $attachment->title((string) trans('firefly.visit_bill', ['name' => $bill->name]), $url);+ })+ ->content($this->getSubject())+ ;}/**diff --git a/app/Notifications/User/NewAccessToken.php b/app/Notifications/User/NewAccessToken.phpindex 02624b317d..dd8873fb43 100644--- a/app/Notifications/User/NewAccessToken.php+++ b/app/Notifications/User/NewAccessToken.php@@ -67,14 +67,6 @@ class NewAccessToken extends Notification;}- /**- * @SuppressWarnings(PHPMD.UnusedFormalParameter)- */- public function toSlack(User $notifiable)- {- return new SlackMessage()->content((string) trans('email.access_token_created_body'));- }-public function toNtfy(User $notifiable): Message{$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);@@ -96,6 +88,14 @@ class NewAccessToken extends Notification;}+ /**+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)+ */+ public function toSlack(User $notifiable)+ {+ return new SlackMessage()->content((string) trans('email.access_token_created_body'));+ }+/*** @SuppressWarnings(PHPMD.UnusedFormalParameter)*/diff --git a/app/Notifications/User/RuleActionFailed.php b/app/Notifications/User/RuleActionFailed.phpindex 253847cbfd..d798ff666f 100644--- a/app/Notifications/User/RuleActionFailed.php+++ b/app/Notifications/User/RuleActionFailed.php@@ -65,23 +65,6 @@ class RuleActionFailed extends Notification];}- /**- * @SuppressWarnings(PHPMD.UnusedFormalParameter)- */- public function toSlack(User $notifiable)- {- $groupTitle = $this->groupTitle;- $groupLink = $this->groupLink;- $ruleTitle = $this->ruleTitle;- $ruleLink = $this->ruleLink;-- return new SlackMessage()->content($this->message)->attachment(static function ($attachment) use ($groupTitle, $groupLink): void {- $attachment->title((string) trans('rules.inspect_transaction', ['title' => $groupTitle]), $groupLink);- })->attachment(static function ($attachment) use ($ruleTitle, $ruleLink): void {- $attachment->title((string) trans('rules.inspect_rule', ['title' => $ruleTitle]), $ruleLink);- });- }-public function toNtfy(User $notifiable): Message{$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);@@ -100,6 +83,23 @@ class RuleActionFailed extends Notificationreturn PushoverMessage::create($this->message);}+ /**+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)+ */+ public function toSlack(User $notifiable)+ {+ $groupTitle = $this->groupTitle;+ $groupLink = $this->groupLink;+ $ruleTitle = $this->ruleTitle;+ $ruleLink = $this->ruleLink;++ return new SlackMessage()->content($this->message)->attachment(static function ($attachment) use ($groupTitle, $groupLink): void {+ $attachment->title((string) trans('rules.inspect_transaction', ['title' => $groupTitle]), $groupLink);+ })->attachment(static function ($attachment) use ($ruleTitle, $ruleLink): void {+ $attachment->title((string) trans('rules.inspect_rule', ['title' => $ruleTitle]), $ruleLink);+ });+ }+/*** @SuppressWarnings(PHPMD.UnusedFormalParameter)*/diff --git a/app/Notifications/User/UserNewPassword.php b/app/Notifications/User/UserNewPassword.phpindex 8d649bae1b..ca14855de5 100644--- a/app/Notifications/User/UserNewPassword.php+++ b/app/Notifications/User/UserNewPassword.php@@ -75,14 +75,6 @@ class UserNewPassword extends Notification;}- /**- * @SuppressWarnings(PHPMD.UnusedFormalParameter)- */- public function toSlack(User $notifiable)- {- return new SlackMessage()->content((string) trans('email.reset_pw_message'));- }-public function toNtfy(User $notifiable): Message{$settings = ReturnsSettings::getSettings('ntfy', 'user', $notifiable);@@ -101,6 +93,14 @@ class UserNewPassword extends Notificationreturn PushoverMessage::create((string) trans('email.reset_pw_message'));}+ /**+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)+ */+ public function toSlack(User $notifiable)+ {+ return new SlackMessage()->content((string) trans('email.reset_pw_message'));+ }+public function via(User $notifiable){return ReturnsAvailableChannels::returnChannels('user', $notifiable);diff --git a/app/Policies/AccountPolicy.php b/app/Policies/AccountPolicy.phpindex 3f2851707c..6f6044fa1a 100644--- a/app/Policies/AccountPolicy.php+++ b/app/Policies/AccountPolicy.php@@ -30,17 +30,14 @@ use Illuminate\Support\Facades\Log;class AccountPolicy{- /**- * TODO needs better authentication, also for group.- */- public function view(User $user, Account $account): bool+ public function create(): bool{- return auth()->check() && $user->id === $account->user_id;+ return auth()->check();}- public function create(): bool+ public function viewAccountBalances(User $user, Account $account): bool{- return auth()->check();+ return $this->view($user, $account);}/**@@ -65,8 +62,11 @@ class AccountPolicyreturn $this->view($user, $account);}- public function viewAccountBalances(User $user, Account $account): bool+ /**+ * TODO needs better authentication, also for group.+ */+ public function view(User $user, Account $account): bool{- return $this->view($user, $account);+ return auth()->check() && $user->id === $account->user_id;}}diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.phpindex ecc0526c91..5f71cfa585 100644--- a/app/Policies/UserPolicy.php+++ b/app/Policies/UserPolicy.php@@ -38,19 +38,19 @@ class UserPolicyreturn auth()->check() && $user->id === $account->user_id;}- /**- * Everybody can do this, but selection should limit to user.- *- * @return true- */- public function viewAny(): bool+ public function viewAccounts(User $user): bool{return true;return auth()->check();}- public function viewAccounts(User $user): bool+ /**+ * Everybody can do this, but selection should limit to user.+ *+ * @return true+ */+ public function viewAny(): bool{return true;diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.phpindex c8ffb3bde2..ca3b82710a 100644--- a/app/Providers/AppServiceProvider.php+++ b/app/Providers/AppServiceProvider.php@@ -45,7 +45,7 @@ class AppServiceProvider extends ServiceProvider$headers = ['Cache-Control' => 'no-store',];- $uuid = (string)request()->header('X-Trace-Id');+ $uuid = (string) request()->header('X-Trace-Id');if ('' !== trim($uuid) && (1 === preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) {$headers['X-Trace-Id'] = $uuid;}diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.phpindex f6c646d424..d66b6d8ca5 100644--- a/app/Providers/EventServiceProvider.php+++ b/app/Providers/EventServiceProvider.php@@ -112,152 +112,152 @@ class EventServiceProvider extends ServiceProviderprotected $listen= [// is a User related event.- RegisteredUser::class => [+ RegisteredUser::class => ['FireflyIII\Handlers\Events\UserEventHandler@sendRegistrationMail','FireflyIII\Handlers\Events\UserEventHandler@sendAdminRegistrationNotification','FireflyIII\Handlers\Events\UserEventHandler@attachUserRole','FireflyIII\Handlers\Events\UserEventHandler@createGroupMembership','FireflyIII\Handlers\Events\UserEventHandler@createExchangeRates',],- UserAttemptedLogin::class => [+ UserAttemptedLogin::class => ['FireflyIII\Handlers\Events\UserEventHandler@sendLoginAttemptNotification',],// is a User related event.- Login::class => [+ Login::class => ['FireflyIII\Handlers\Events\UserEventHandler@checkSingleUserIsAdmin','FireflyIII\Handlers\Events\UserEventHandler@demoUserBackToEnglish',],- ActuallyLoggedIn::class => [+ ActuallyLoggedIn::class => ['FireflyIII\Handlers\Events\UserEventHandler@storeUserIPAddress',],- DetectedNewIPAddress::class => [+ DetectedNewIPAddress::class => ['FireflyIII\Handlers\Events\UserEventHandler@notifyNewIPAddress',],- RequestedVersionCheckStatus::class => [+ RequestedVersionCheckStatus::class => ['FireflyIII\Handlers\Events\VersionCheckEventHandler@checkForUpdates',],- RequestedReportOnJournals::class => [+ RequestedReportOnJournals::class => ['FireflyIII\Handlers\Events\AutomationHandler@reportJournals',],// is a User related event.- RequestedNewPassword::class => [+ RequestedNewPassword::class => ['FireflyIII\Handlers\Events\UserEventHandler@sendNewPassword',],- UserTestNotificationChannel::class => [+ UserTestNotificationChannel::class => ['FireflyIII\Handlers\Events\UserEventHandler@sendTestNotification',],// is a User related event.- UserChangedEmail::class => [+ UserChangedEmail::class => ['FireflyIII\Handlers\Events\UserEventHandler@sendEmailChangeConfirmMail','FireflyIII\Handlers\Events\UserEventHandler@sendEmailChangeUndoMail',],// admin related- OwnerTestNotificationChannel::class => [+ OwnerTestNotificationChannel::class => ['FireflyIII\Handlers\Events\AdminEventHandler@sendTestNotification',],- NewVersionAvailable::class => [+ NewVersionAvailable::class => ['FireflyIII\Handlers\Events\AdminEventHandler@sendNewVersion',],- InvitationCreated::class => [+ InvitationCreated::class => ['FireflyIII\Handlers\Events\AdminEventHandler@sendInvitationNotification','FireflyIII\Handlers\Events\UserEventHandler@sendRegistrationInvite',],- UnknownUserAttemptedLogin::class => [+ UnknownUserAttemptedLogin::class => ['FireflyIII\Handlers\Events\AdminEventHandler@sendLoginAttemptNotification',],// is a Transaction Journal related event.- StoredTransactionGroup::class => [+ StoredTransactionGroup::class => ['FireflyIII\Handlers\Events\StoredGroupEventHandler@processRules','FireflyIII\Handlers\Events\StoredGroupEventHandler@recalculateCredit','FireflyIII\Handlers\Events\StoredGroupEventHandler@triggerWebhooks',],// is a Transaction Journal related event.- UpdatedTransactionGroup::class => [+ UpdatedTransactionGroup::class => ['FireflyIII\Handlers\Events\UpdatedGroupEventHandler@unifyAccounts','FireflyIII\Handlers\Events\UpdatedGroupEventHandler@processRules','FireflyIII\Handlers\Events\UpdatedGroupEventHandler@recalculateCredit','FireflyIII\Handlers\Events\UpdatedGroupEventHandler@triggerWebhooks',],- DestroyedTransactionGroup::class => [+ DestroyedTransactionGroup::class => ['FireflyIII\Handlers\Events\DestroyedGroupEventHandler@triggerWebhooks',],// API related events:- AccessTokenCreated::class => [+ AccessTokenCreated::class => ['FireflyIII\Handlers\Events\APIEventHandler@accessTokenCreated',],// Webhook related event:- RequestedSendWebhookMessages::class => [+ RequestedSendWebhookMessages::class => ['FireflyIII\Handlers\Events\WebhookEventHandler@sendWebhookMessages',],// account related events:- StoredAccount::class => [+ StoredAccount::class => ['FireflyIII\Handlers\Events\StoredAccountEventHandler@recalculateCredit',],- UpdatedAccount::class => [+ UpdatedAccount::class => ['FireflyIII\Handlers\Events\UpdatedAccountEventHandler@recalculateCredit',],// bill related events:- WarnUserAboutBill::class => [+ WarnUserAboutBill::class => ['FireflyIII\Handlers\Events\BillEventHandler@warnAboutBill',],// audit log events:- TriggeredAuditLog::class => [+ TriggeredAuditLog::class => ['FireflyIII\Handlers\Events\AuditEventHandler@storeAuditEvent',],// piggy bank related events:- ChangedAmount::class => [+ ChangedAmount::class => ['FireflyIII\Handlers\Events\Model\PiggyBankEventHandler@changePiggyAmount',],// budget related events: CRUD budget limit- Created::class => [+ Created::class => ['FireflyIII\Handlers\Events\Model\BudgetLimitHandler@created',],- Updated::class => [+ Updated::class => ['FireflyIII\Handlers\Events\Model\BudgetLimitHandler@updated',],- Deleted::class => [+ Deleted::class => ['FireflyIII\Handlers\Events\Model\BudgetLimitHandler@deleted',],// rule actions- RuleActionFailedOnArray::class => [+ RuleActionFailedOnArray::class => ['FireflyIII\Handlers\Events\Model\RuleHandler@ruleActionFailedOnArray',],- RuleActionFailedOnObject::class => [+ RuleActionFailedOnObject::class => ['FireflyIII\Handlers\Events\Model\RuleHandler@ruleActionFailedOnObject',],// security related- EnabledMFA::class => [+ EnabledMFA::class => ['FireflyIII\Handlers\Events\Security\MFAHandler@sendMFAEnabledMail',],- DisabledMFA::class => [+ DisabledMFA::class => ['FireflyIII\Handlers\Events\Security\MFAHandler@sendMFADisabledMail',],- MFANewBackupCodes::class => [+ MFANewBackupCodes::class => ['FireflyIII\Handlers\Events\Security\MFAHandler@sendNewMFABackupCodesMail',],- MFAUsedBackupCode::class => [+ MFAUsedBackupCode::class => ['FireflyIII\Handlers\Events\Security\MFAHandler@sendUsedBackupCodeMail',],- MFABackupFewLeft::class => [+ MFABackupFewLeft::class => ['FireflyIII\Handlers\Events\Security\MFAHandler@sendBackupFewLeftMail',],- MFABackupNoLeft::class => [+ MFABackupNoLeft::class => ['FireflyIII\Handlers\Events\Security\MFAHandler@sendBackupNoLeftMail',],- MFAManyFailedAttempts::class => [+ MFAManyFailedAttempts::class => ['FireflyIII\Handlers\Events\Security\MFAHandler@sendMFAFailedAttemptsMail',],// preferences- UserGroupChangedDefaultCurrency::class => [+ UserGroupChangedDefaultCurrency::class => ['FireflyIII\Handlers\Events\PreferencesEventHandler@resetNativeAmounts',],];diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex cfe2e325d4..ea1e44f940 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -391,7 +391,7 @@ class AccountRepository implements AccountRepositoryInterfaceif (!in_array($type, $list, true)) {return null;}- $currencyId = (int)$this->getMetaValue($account, 'currency_id');+ $currencyId = (int) $this->getMetaValue($account, 'currency_id');if ($currencyId > 0) {return TransactionCurrency::find($currencyId);}@@ -413,7 +413,7 @@ class AccountRepository implements AccountRepositoryInterfacereturn null;}if (1 === $result->count()) {- return (string)$result->first()->data;+ return (string) $result->first()->data;}return null;@@ -434,8 +434,8 @@ class AccountRepository implements AccountRepositoryInterface$info = $account->transactions()->get(['transaction_currency_id', 'foreign_currency_id'])->toArray();$currencyIds = [];foreach ($info as $entry) {- $currencyIds[] = (int)$entry['transaction_currency_id'];- $currencyIds[] = (int)$entry['foreign_currency_id'];+ $currencyIds[] = (int) $entry['transaction_currency_id'];+ $currencyIds[] = (int) $entry['foreign_currency_id'];}$currencyIds = array_unique($currencyIds);@@ -458,14 +458,14 @@ class AccountRepository implements AccountRepositoryInterfaceAccountType::MORTGAGE => [AccountType::LOAN, AccountType::DEBT, AccountType::CREDITCARD, AccountType::MORTGAGE],];if (array_key_exists(ucfirst($type), $sets)) {- $order = (int)$this->getAccountsByType($sets[ucfirst($type)])->max('order');+ $order = (int) $this->getAccountsByType($sets[ucfirst($type)])->max('order');app('log')->debug(sprintf('Return max order of "%s" set: %d', $type, $order));return $order;}$specials = [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION];- $order = (int)$this->getAccountsByType($specials)->max('order');+ $order = (int) $this->getAccountsByType($specials)->max('order');app('log')->debug(sprintf('Return max order of "%s" set (specials!): %d', $type, $order));return $order;@@ -546,7 +546,7 @@ class AccountRepository implements AccountRepositoryInterfacecontinue;}- if ($index !== (int)$account->order) {+ if ($index !== (int) $account->order) {app('log')->debug(sprintf('Account #%d ("%s"): order should %d be but is %d.', $account->id, $account->name, $index, $account->order));$account->order = $index;$account->save();@@ -562,6 +562,17 @@ class AccountRepository implements AccountRepositoryInterface;}+ /**+ * @throws FireflyException+ */+ public function update(Account $account, array $data): Account+ {+ /** @var AccountUpdateService $service */+ $service = app(AccountUpdateService::class);++ return $service->update($account, $data);+ }+public function searchAccount(string $query, array $types, int $limit): Collection{$dbQuery = $this->user->accounts()@@ -634,15 +645,4 @@ class AccountRepository implements AccountRepositoryInterfacereturn $factory->create($data);}-- /**- * @throws FireflyException- */- public function update(Account $account, array $data): Account- {- /** @var AccountUpdateService $service */- $service = app(AccountUpdateService::class);-- return $service->update($account, $data);- }}diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.phpindex 000d4a0589..24eb61213d 100644--- a/app/Repositories/Account/AccountTasker.php+++ b/app/Repositories/Account/AccountTasker.php@@ -130,7 +130,7 @@ class AccountTasker implements AccountTaskerInterface// Obtain a list of columns$sum = [];foreach ($report['accounts'] as $accountId => $row) {- $sum[$accountId] = (float)$row['sum']; // intentional float+ $sum[$accountId] = (float) $row['sum']; // intentional float}array_multisort($sum, SORT_ASC, $report['accounts']);@@ -155,8 +155,8 @@ class AccountTasker implements AccountTaskerInterface/** @var array $journal */foreach ($array as $journal) {- $sourceId = (int)$journal['destination_account_id'];- $currencyId = (int)$journal['currency_id'];+ $sourceId = (int) $journal['destination_account_id'];+ $currencyId = (int) $journal['currency_id'];$key = sprintf('%s-%s', $sourceId, $currencyId);$currencies[$currencyId] ??= $currencyRepos->find($currencyId);$report['accounts'][$key] ??= [@@ -181,7 +181,7 @@ class AccountTasker implements AccountTaskerInterface// do averages and sums.foreach (array_keys($report['accounts']) as $key) {if ($report['accounts'][$key]['count'] > 1) {- $report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string)$report['accounts'][$key]['count']);+ $report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string) $report['accounts'][$key]['count']);}$currencyId = $report['accounts'][$key]['currency_id'];$report['sums'][$currencyId] ??= [@@ -218,7 +218,7 @@ class AccountTasker implements AccountTaskerInterface// Obtain a list of columns$sum = [];foreach ($report['accounts'] as $accountId => $row) {- $sum[$accountId] = (float)$row['sum']; // intentional float+ $sum[$accountId] = (float) $row['sum']; // intentional float}array_multisort($sum, SORT_DESC, $report['accounts']);@@ -243,8 +243,8 @@ class AccountTasker implements AccountTaskerInterface/** @var array $journal */foreach ($array as $journal) {- $sourceId = (int)$journal['source_account_id'];- $currencyId = (int)$journal['currency_id'];+ $sourceId = (int) $journal['source_account_id'];+ $currencyId = (int) $journal['currency_id'];$key = sprintf('%s-%s', $sourceId, $currencyId);if (!array_key_exists($key, $report['accounts'])) {$currencies[$currencyId] ??= $currencyRepos->find($currencyId);@@ -268,7 +268,7 @@ class AccountTasker implements AccountTaskerInterface// do averages and sums.foreach (array_keys($report['accounts']) as $key) {if ($report['accounts'][$key]['count'] > 1) {- $report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string)$report['accounts'][$key]['count']);+ $report['accounts'][$key]['average'] = bcdiv($report['accounts'][$key]['sum'], (string) $report['accounts'][$key]['count']);}$currencyId = $report['accounts'][$key]['currency_id'];$report['sums'][$currencyId] ??= [diff --git a/app/Repositories/Account/OperationsRepository.php b/app/Repositories/Account/OperationsRepository.phpindex 5beaa5a49f..9902a5778a 100644--- a/app/Repositories/Account/OperationsRepository.php+++ b/app/Repositories/Account/OperationsRepository.php@@ -76,8 +76,8 @@ class OperationsRepository implements OperationsRepositoryInterface{$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];- $journalId = (int)$journal['transaction_journal_id'];+ $currencyId = (int) $journal['currency_id'];+ $journalId = (int) $journal['transaction_journal_id'];$array[$currencyId] ??= ['currency_id' => $journal['currency_id'],'currency_name' => $journal['currency_name'],@@ -88,7 +88,7 @@ class OperationsRepository implements OperationsRepositoryInterface];$array[$currencyId]['transaction_journals'][$journalId] = [- 'amount' => app('steam')->{$direction}((string)$journal['amount']), // @phpstan-ignore-line+ 'amount' => app('steam')->{$direction}((string) $journal['amount']), // @phpstan-ignore-line'date' => $journal['date'],'transaction_journal_id' => $journalId,'budget_name' => $journal['budget_name'],@@ -219,7 +219,7 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['sum' => '0','currency_id' => $currencyId,@@ -231,7 +231,7 @@ class OperationsRepository implements OperationsRepositoryInterface$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->{$direction}($journal['amount'])); // @phpstan-ignore-line// also do foreign amount:- $foreignId = (int)$journal['foreign_currency_id'];+ $foreignId = (int) $journal['foreign_currency_id'];if (0 !== $foreignId) {$array[$foreignId] ??= ['sum' => '0',@@ -281,10 +281,10 @@ class OperationsRepository implements OperationsRepositoryInterface'currency_code' => $journal['currency_code'],'currency_decimal_places' => $journal['currency_decimal_places'],];- $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->{$method}((string)$journal['amount'])); // @phpstan-ignore-line+ $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->{$method}((string) $journal['amount'])); // @phpstan-ignore-line// also do foreign amount:- if (0 !== (int)$journal['foreign_currency_id']) {+ if (0 !== (int) $journal['foreign_currency_id']) {$key = sprintf('%s-%s', $journal[$idKey], $journal['foreign_currency_id']);$array[$key] ??= ['id' => $journal[$idKey],@@ -296,7 +296,7 @@ class OperationsRepository implements OperationsRepositoryInterface'currency_code' => $journal['foreign_currency_code'],'currency_decimal_places' => $journal['foreign_currency_decimal_places'],];- $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->{$method}((string)$journal['foreign_amount'])); // @phpstan-ignore-line+ $array[$key]['sum'] = bcadd($array[$key]['sum'], app('steam')->{$method}((string) $journal['foreign_amount'])); // @phpstan-ignore-line}}@@ -380,9 +380,9 @@ class OperationsRepository implements OperationsRepositoryInterface}$final = [];foreach ($return as $array) {- $array['difference_float'] = (float)$array['difference'];- $array['in_float'] = (float)$array['in'];- $array['out_float'] = (float)$array['out'];+ $array['difference_float'] = (float) $array['difference'];+ $array['in_float'] = (float) $array['in'];+ $array['out_float'] = (float) $array['out'];$final[] = $array;}@@ -400,7 +400,7 @@ class OperationsRepository implements OperationsRepositoryInterface// source first$return[$sourceKey] ??= [- 'id' => (string)$sourceId,+ 'id' => (string) $sourceId,'name' => $journal['source_account_name'],'difference' => '0','difference_float' => 0,@@ -408,13 +408,13 @@ class OperationsRepository implements OperationsRepositoryInterface'in_float' => 0,'out' => '0','out_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];// dest next:$return[$destKey] ??= [- 'id' => (string)$destinationId,+ 'id' => (string) $destinationId,'name' => $journal['destination_account_name'],'difference' => '0','difference_float' => 0,@@ -422,7 +422,7 @@ class OperationsRepository implements OperationsRepositoryInterface'in_float' => 0,'out' => '0','out_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['currency_code'],];@@ -444,7 +444,7 @@ class OperationsRepository implements OperationsRepositoryInterface// same as above:// source first$return[$sourceKey] ??= [- 'id' => (string)$sourceId,+ 'id' => (string) $sourceId,'name' => $journal['source_account_name'],'difference' => '0','difference_float' => 0,@@ -452,13 +452,13 @@ class OperationsRepository implements OperationsRepositoryInterface'in_float' => 0,'out' => '0','out_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['foreign_currency_code'],];// dest next:$return[$destKey] ??= [- 'id' => (string)$destinationId,+ 'id' => (string) $destinationId,'name' => $journal['destination_account_name'],'difference' => '0','difference_float' => 0,@@ -466,7 +466,7 @@ class OperationsRepository implements OperationsRepositoryInterface'in_float' => 0,'out' => '0','out_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $journal['foreign_currency_code'],];// source account? money goes out! (same as above)diff --git a/app/Repositories/Attachment/AttachmentRepository.php b/app/Repositories/Attachment/AttachmentRepository.phpindex e9e69d1f1d..a1744a3dac 100644--- a/app/Repositories/Attachment/AttachmentRepository.php+++ b/app/Repositories/Attachment/AttachmentRepository.php@@ -71,7 +71,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface$unencryptedContent = '';if ($disk->exists($file)) {- $encryptedContent = (string)$disk->get($file);+ $encryptedContent = (string) $disk->get($file);try {$unencryptedContent = \Crypt::decrypt($encryptedContent); // verified@@ -104,7 +104,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface{$note = $attachment->notes()->first();if (null !== $note) {- return (string)$note->text;+ return (string) $note->text;}return null;@@ -139,20 +139,20 @@ class AttachmentRepository implements AttachmentRepositoryInterface$attachment->title = $data['title'];}- if (array_key_exists('filename', $data) && '' !== (string)$data['filename'] && $data['filename'] !== $attachment->filename) {+ if (array_key_exists('filename', $data) && '' !== (string) $data['filename'] && $data['filename'] !== $attachment->filename) {$attachment->filename = $data['filename'];}// update model (move attachment)// should be validated already:if (array_key_exists('attachable_type', $data) && array_key_exists('attachable_id', $data)) {- $attachment->attachable_id = (int)$data['attachable_id'];+ $attachment->attachable_id = (int) $data['attachable_id'];$attachment->attachable_type = sprintf('FireflyIII\Models\%s', $data['attachable_type']);}$attachment->save();$attachment->refresh();if (array_key_exists('notes', $data)) {- $this->updateNote($attachment, (string)$data['notes']);+ $this->updateNote($attachment, (string) $data['notes']);}return $attachment;diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.phpindex 28b4dae6f1..21e6d36914 100644--- a/app/Repositories/Bill/BillRepository.php+++ b/app/Repositories/Bill/BillRepository.php@@ -240,7 +240,7 @@ class BillRepository implements BillRepositoryInterface/** @var null|Note $note */$note = $bill->notes()->first();- return (string)$note?->text;+ return (string) $note?->text;}public function getOverallAverage(Bill $bill): array@@ -257,7 +257,7 @@ class BillRepository implements BillRepositoryInterfaceforeach ($journals as $journal) {/** @var Transaction $transaction */$transaction = $journal->transactions()->where('amount', '<', 0)->first();- $currencyId = (int)$journal->transaction_currency_id;+ $currencyId = (int) $journal->transaction_currency_id;$currency = $journal->transactionCurrency;$result[$currencyId] ??= ['sum' => '0',@@ -278,7 +278,7 @@ class BillRepository implements BillRepositoryInterface* @var array $arr*/foreach ($result as $currencyId => $arr) {- $result[$currencyId]['avg'] = bcdiv($arr['sum'], (string)$arr['count']);+ $result[$currencyId]['avg'] = bcdiv($arr['sum'], (string) $arr['count']);}return $result;@@ -382,7 +382,7 @@ class BillRepository implements BillRepositoryInterfaceif (null === $transaction) {continue;}- $currencyId = (int)$journal->transaction_currency_id;+ $currencyId = (int) $journal->transaction_currency_id;$currency = $journal->transactionCurrency;$result[$currencyId] ??= ['sum' => '0',@@ -403,7 +403,7 @@ class BillRepository implements BillRepositoryInterface* @var array $arr*/foreach ($result as $currencyId => $arr) {- $result[$currencyId]['avg'] = bcdiv($arr['sum'], (string)$arr['count']);+ $result[$currencyId]['avg'] = bcdiv($arr['sum'], (string) $arr['count']);}return $result;@@ -416,7 +416,7 @@ class BillRepository implements BillRepositoryInterface{/** @var Transaction $transaction */foreach ($transactions as $transaction) {- $journal = $bill->user->transactionJournals()->find((int)$transaction['transaction_journal_id']);+ $journal = $bill->user->transactionJournals()->find((int) $transaction['transaction_journal_id']);$journal->bill_id = $bill->id;$journal->save();app('log')->debug(sprintf('Linked journal #%d to bill #%d', $journal->id, $bill->id));@@ -520,7 +520,7 @@ class BillRepository implements BillRepositoryInterface$currency = $bill->transactionCurrency;$return[$currency->id] ??= [- 'id' => (string)$currency->id,+ 'id' => (string) $currency->id,'name' => $currency->name,'symbol' => $currency->symbol,'code' => $currency->code,@@ -534,9 +534,9 @@ class BillRepository implements BillRepositoryInterface$sourceTransaction = $transactionJournal->transactions()->where('amount', '<', 0)->first();if (null !== $sourceTransaction) {$amount = $sourceTransaction->amount;- if ((int)$sourceTransaction->foreign_currency_id === $currency->id) {+ if ((int) $sourceTransaction->foreign_currency_id === $currency->id) {// use foreign amount instead!- $amount = (string)$sourceTransaction->foreign_amount;+ $amount = (string) $sourceTransaction->foreign_amount;}$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);}@@ -574,14 +574,14 @@ class BillRepository implements BillRepositoryInterface$currency = $bill->transactionCurrency;$average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');$return[$currency->id] ??= [- 'id' => (string)$currency->id,+ 'id' => (string) $currency->id,'name' => $currency->name,'symbol' => $currency->symbol,'code' => $currency->code,'decimal_places' => $currency->decimal_places,'sum' => '0',];- $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], bcmul($average, (string)$total));+ $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], bcmul($average, (string) $total));}}diff --git a/app/Repositories/Budget/BudgetLimitRepository.php b/app/Repositories/Budget/BudgetLimitRepository.phpindex 8efff4bf73..c976bb6941 100644--- a/app/Repositories/Budget/BudgetLimitRepository.php+++ b/app/Repositories/Budget/BudgetLimitRepository.php@@ -256,6 +256,12 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface;}+ #[\Override]+ public function getNoteText(BudgetLimit $budgetLimit): string+ {+ return (string) $budgetLimit->notes()->first()?->text;+ }+public function setUser(null|Authenticatable|User $user): void{if ($user instanceof User) {@@ -324,6 +330,23 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface;}+ #[\Override]+ public function setNoteText(BudgetLimit $budgetLimit, string $text): void+ {+ $dbNote = $budgetLimit->notes()->first();+ if ('' !== $text) {+ if (null === $dbNote) {+ $dbNote = new Note();+ $dbNote->noteable()->associate($budgetLimit);+ }+ $dbNote->text = trim($text);+ $dbNote->save();++ return;+ }+ $dbNote?->delete();+ }+/*** @throws FireflyException*/@@ -362,7 +385,7 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterface// update notes if they exist.if (array_key_exists('notes', $data)) {- $this->setNoteText($budgetLimit, (string)$data['notes']);+ $this->setNoteText($budgetLimit, (string) $data['notes']);}return $budgetLimit;@@ -427,27 +450,4 @@ class BudgetLimitRepository implements BudgetLimitRepositoryInterfacereturn $limit;}-- #[\Override]- public function getNoteText(BudgetLimit $budgetLimit): string- {- return (string) $budgetLimit->notes()->first()?->text;- }-- #[\Override]- public function setNoteText(BudgetLimit $budgetLimit, string $text): void- {- $dbNote = $budgetLimit->notes()->first();- if ('' !== $text) {- if (null === $dbNote) {- $dbNote = new Note();- $dbNote->noteable()->associate($budgetLimit);- }- $dbNote->text = trim($text);- $dbNote->save();-- return;- }- $dbNote?->delete();- }}diff --git a/app/Repositories/Budget/BudgetLimitRepositoryInterface.php b/app/Repositories/Budget/BudgetLimitRepositoryInterface.phpindex 7eafcfd149..bb101e2068 100644--- a/app/Repositories/Budget/BudgetLimitRepositoryInterface.php+++ b/app/Repositories/Budget/BudgetLimitRepositoryInterface.php@@ -48,10 +48,6 @@ interface BudgetLimitRepositoryInterface*/public function destroyAll(): void;- public function getNoteText(BudgetLimit $budgetLimit): string;-- public function setNoteText(BudgetLimit $budgetLimit, string $text): void;-/*** Destroy a budget limit.*/@@ -68,6 +64,10 @@ interface BudgetLimitRepositoryInterfacepublic function getBudgetLimits(Budget $budget, ?Carbon $start = null, ?Carbon $end = null): Collection;+ public function getNoteText(BudgetLimit $budgetLimit): string;++ public function setNoteText(BudgetLimit $budgetLimit, string $text): void;+public function setUser(null|Authenticatable|User $user): void;public function store(array $data): BudgetLimit;diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.phpindex 6a5369a350..ea9c4f3586 100644--- a/app/Repositories/Budget/BudgetRepository.php+++ b/app/Repositories/Budget/BudgetRepository.php@@ -103,12 +103,12 @@ class BudgetRepository implements BudgetRepositoryInterface$rate = $converter->getCurrencyRate($currency, $defaultCurrency, $end);$currencyCode = $currency->code;$return[$currencyCode] ??= [- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_name' => $currency->name,'currency_symbol' => $currency->symbol,'currency_code' => $currency->code,'currency_decimal_places' => $currency->decimal_places,- 'native_currency_id' => (string)$defaultCurrency->id,+ 'native_currency_id' => (string) $defaultCurrency->id,'native_currency_name' => $defaultCurrency->name,'native_currency_symbol' => $defaultCurrency->symbol,'native_currency_code' => $defaultCurrency->code,@@ -134,13 +134,13 @@ class BudgetRepository implements BudgetRepositoryInterface}$total = $limit->start_date->diffInDays($limit->end_date, true) + 1; // include the day itself.$days = $this->daysInOverlap($limit, $start, $end);- $amount = bcmul(bcdiv($limit->amount, (string)$total), (string)$days);+ $amount = bcmul(bcdiv($limit->amount, (string) $total), (string) $days);$return[$currencyCode]['sum'] = bcadd($return[$currencyCode]['sum'], $amount);$return[$currencyCode]['native_sum'] = bcmul($rate, $return[$currencyCode]['sum']);app('log')->debug(sprintf('Amount per day: %s (%s over %d days). Total amount for %d days: %s',- bcdiv($limit->amount, (string)$total),+ bcdiv($limit->amount, (string) $total),$limit->amount,$total,$days,@@ -183,21 +183,21 @@ class BudgetRepository implements BudgetRepositoryInterface// |-----------|// |----------------|if ($start->gte($limit->start_date) && $end->lte($limit->end_date)) {- return (int)$start->diffInDays($end, true) + 1; // add one day+ return (int) $start->diffInDays($end, true) + 1; // add one day}// limit starts earlier and limit ends first:// |-----------|// |-------|if ($limit->start_date->lte($start) && $limit->end_date->lte($end)) {// return days in the range $start-$limit_end- return (int)$start->diffInDays($limit->end_date, true) + 1; // add one day, the day itself+ return (int) $start->diffInDays($limit->end_date, true) + 1; // add one day, the day itself}// limit starts later and limit ends earlier// |-----------|// |-------|if ($limit->start_date->gte($start) && $limit->end_date->gte($end)) {// return days in the range $limit_start - $end- return (int)$limit->start_date->diffInDays($end, true) + 1; // add one day, the day itself+ return (int) $limit->start_date->diffInDays($end, true) + 1; // add one day, the day itself}return 0;@@ -220,7 +220,7 @@ class BudgetRepository implements BudgetRepositoryInterfaceapp('log')->debug(sprintf('Budget limit #%d', $limit->id));$currency = $limit->transactionCurrency;$return[$currency->id] ??= [- 'id' => (string)$currency->id,+ 'id' => (string) $currency->id,'name' => $currency->name,'symbol' => $currency->symbol,'code' => $currency->code,@@ -243,12 +243,12 @@ class BudgetRepository implements BudgetRepositoryInterface}$total = $limit->start_date->diffInDays($limit->end_date) + 1; // include the day itself.$days = $this->daysInOverlap($limit, $start, $end);- $amount = bcmul(bcdiv($limit->amount, (string)$total), (string)$days);+ $amount = bcmul(bcdiv($limit->amount, (string) $total), (string) $days);$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);app('log')->debug(sprintf('Amount per day: %s (%s over %d days). Total amount for %d days: %s',- bcdiv($limit->amount, (string)$total),+ bcdiv($limit->amount, (string) $total),$limit->amount,$total,$days,@@ -297,7 +297,7 @@ class BudgetRepository implements BudgetRepositoryInterface$budget->active = $data['active'];}if (array_key_exists('notes', $data)) {- $this->setNoteText($budget, (string)$data['notes']);+ $this->setNoteText($budget, (string) $data['notes']);}$budget->save();@@ -408,8 +408,8 @@ class BudgetRepository implements BudgetRepositoryInterfaceif (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {/** @var CurrencyRepositoryInterface $repos */$repos = app(CurrencyRepositoryInterface::class);- $currencyId = (int)($data['currency_id'] ?? 0);- $currencyCode = (string)($data['currency_code'] ?? '');+ $currencyId = (int) ($data['currency_id'] ?? 0);+ $currencyCode = (string) ($data['currency_code'] ?? '');$currency = $repos->find($currencyId);if (null === $currency) {$currency = $repos->findByCode($currencyCode);@@ -463,8 +463,8 @@ class BudgetRepository implements BudgetRepositoryInterfaceforeach ($budgets as $budget) {\DB::table('budget_transaction')->where('budget_id', $budget->id)->delete();\DB::table('budget_transaction_journal')->where('budget_id', $budget->id)->delete();- RecurrenceTransactionMeta::where('name', 'budget_id')->where('value', (string)$budget->id)->delete();- RuleAction::where('action_type', 'set_budget')->where('action_value', (string)$budget->id)->delete();+ RecurrenceTransactionMeta::where('name', 'budget_id')->where('value', (string) $budget->id)->delete();+ RuleAction::where('action_type', 'set_budget')->where('action_value', (string) $budget->id)->delete();$budget->delete();}Log::channel('audit')->info('Delete all budgets through destroyAll');@@ -489,7 +489,7 @@ class BudgetRepository implements BudgetRepositoryInterface{app('log')->debug('Now in findBudget()');app('log')->debug(sprintf('Searching for budget with ID #%d...', $budgetId));- $result = $this->find((int)$budgetId);+ $result = $this->find((int) $budgetId);if (null === $result && null !== $budgetName && '' !== $budgetName) {app('log')->debug(sprintf('Searching for budget with name %s...', $budgetName));$result = $this->findByName($budgetName);@@ -625,9 +625,9 @@ class BudgetRepository implements BudgetRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= [- 'id' => (string)$currencyId,+ 'id' => (string) $currencyId,'name' => $journal['currency_name'],'symbol' => $journal['currency_symbol'],'code' => $journal['currency_code'],@@ -637,10 +637,10 @@ class BudgetRepository implements BudgetRepositoryInterface$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount']));// also do foreign amount:- $foreignId = (int)$journal['foreign_currency_id'];+ $foreignId = (int) $journal['foreign_currency_id'];if (0 !== $foreignId) {$array[$foreignId] ??= [- 'id' => (string)$foreignId,+ 'id' => (string) $foreignId,'name' => $journal['foreign_currency_name'],'symbol' => $journal['foreign_currency_symbol'],'code' => $journal['foreign_currency_code'],@@ -687,9 +687,9 @@ class BudgetRepository implements BudgetRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= [- 'id' => (string)$currencyId,+ 'id' => (string) $currencyId,'name' => $journal['currency_name'],'symbol' => $journal['currency_symbol'],'code' => $journal['currency_code'],@@ -699,10 +699,10 @@ class BudgetRepository implements BudgetRepositoryInterface$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount']));// also do foreign amount:- $foreignId = (int)$journal['foreign_currency_id'];+ $foreignId = (int) $journal['foreign_currency_id'];if (0 !== $foreignId) {$array[$foreignId] ??= [- 'id' => (string)$foreignId,+ 'id' => (string) $foreignId,'name' => $journal['foreign_currency_name'],'symbol' => $journal['foreign_currency_symbol'],'code' => $journal['foreign_currency_code'],@@ -744,7 +744,7 @@ class BudgetRepository implements BudgetRepositoryInterface// set notesif (array_key_exists('notes', $data)) {- $this->setNoteText($newBudget, (string)$data['notes']);+ $this->setNoteText($newBudget, (string) $data['notes']);}if (!array_key_exists('auto_budget_type', $data) || !array_key_exists('auto_budget_amount', $data) || !array_key_exists('auto_budget_period', $data)) {@@ -772,10 +772,10 @@ class BudgetRepository implements BudgetRepositoryInterface$repos = app(CurrencyRepositoryInterface::class);$currency = null;if (array_key_exists('currency_id', $data)) {- $currency = $repos->find((int)$data['currency_id']);+ $currency = $repos->find((int) $data['currency_id']);}if (array_key_exists('currency_code', $data)) {- $currency = $repos->findByCode((string)$data['currency_code']);+ $currency = $repos->findByCode((string) $data['currency_code']);}if (null === $currency) {$currency = app('amount')->getDefaultCurrencyByUserGroup($this->user->userGroup);@@ -811,6 +811,6 @@ class BudgetRepository implements BudgetRepositoryInterfacepublic function getMaxOrder(): int{- return (int)$this->user->budgets()->max('order');+ return (int) $this->user->budgets()->max('order');}}diff --git a/app/Repositories/Budget/NoBudgetRepository.php b/app/Repositories/Budget/NoBudgetRepository.phpindex 9708913db4..ebe62ac894 100644--- a/app/Repositories/Budget/NoBudgetRepository.php+++ b/app/Repositories/Budget/NoBudgetRepository.php@@ -55,7 +55,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface/** @var array $journal */foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$data[$currencyId] ??= ['id' => 0,@@ -115,7 +115,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface/** @var TransactionCurrency $currency */$currency = $currencies[$code];$return[] = [- 'currency_id' => (string)$currency['id'],+ 'currency_id' => (string) $currency['id'],'currency_code' => $code,'currency_name' => $currency['name'],'currency_symbol' => $currency['symbol'],@@ -156,7 +156,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['sum' => '0','currency_id' => $currencyId,diff --git a/app/Repositories/Budget/OperationsRepository.php b/app/Repositories/Budget/OperationsRepository.phpindex af1095f878..153bb0a9f5 100644--- a/app/Repositories/Budget/OperationsRepository.php+++ b/app/Repositories/Budget/OperationsRepository.php@@ -52,17 +52,17 @@ class OperationsRepository implements OperationsRepositoryInterface$total = '0';$count = 0;foreach ($budget->budgetlimits as $limit) {- $diff = (int)$limit->start_date->diffInDays($limit->end_date, true);+ $diff = (int) $limit->start_date->diffInDays($limit->end_date, true);$diff = 0 === $diff ? 1 : $diff;$amount = $limit->amount;- $perDay = bcdiv($amount, (string)$diff);+ $perDay = bcdiv($amount, (string) $diff);$total = bcadd($total, $perDay);++$count;app('log')->debug(sprintf('Found %d budget limits. Per day is %s, total is %s', $count, $perDay, $total));}$avg = $total;if ($count > 0) {- $avg = bcdiv($total, (string)$count);+ $avg = bcdiv($total, (string) $count);}app('log')->debug(sprintf('%s / %d = %s = average.', $total, $count, $avg));@@ -91,9 +91,9 @@ class OperationsRepository implements OperationsRepositoryInterface/** @var array $journal */foreach ($journals as $journal) {// prep data array for currency:- $budgetId = (int)$journal['budget_id'];+ $budgetId = (int) $journal['budget_id'];$budgetName = $journal['budget_name'];- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$key = sprintf('%d-%d', $budgetId, $currencyId);$data[$key] ??= [@@ -138,9 +138,9 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];- $budgetId = (int)$journal['budget_id'];- $budgetName = (string)$journal['budget_name'];+ $currencyId = (int) $journal['currency_id'];+ $budgetId = (int) $journal['budget_id'];+ $budgetName = (string) $journal['budget_name'];// catch "no category" entries.if (0 === $budgetId) {@@ -166,7 +166,7 @@ class OperationsRepository implements OperationsRepositoryInterface// add journal to array:// only a subset of the fields.- $journalId = (int)$journal['transaction_journal_id'];+ $journalId = (int) $journal['transaction_journal_id'];$array[$currencyId]['budgets'][$budgetId]['transaction_journals'][$journalId] = ['amount' => app('steam')->negative($journal['amount']),'destination_account_id' => $journal['destination_account_id'],@@ -269,7 +269,7 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['sum' => '0','currency_id' => $currencyId,@@ -281,7 +281,7 @@ class OperationsRepository implements OperationsRepositoryInterface$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount']));// also do foreign amount:- $foreignId = (int)$journal['foreign_currency_id'];+ $foreignId = (int) $journal['foreign_currency_id'];if (0 !== $foreignId) {$array[$foreignId] ??= ['sum' => '0',diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.phpindex 86ad7e3f24..7501fcbdde 100644--- a/app/Repositories/Category/CategoryRepository.php+++ b/app/Repositories/Category/CategoryRepository.php@@ -107,11 +107,11 @@ class CategoryRepository implements CategoryRepositoryInterface{app('log')->debug('Now in findCategory()');app('log')->debug(sprintf('Searching for category with ID #%d...', $categoryId));- $result = $this->find((int)$categoryId);+ $result = $this->find((int) $categoryId);if (null === $result) {app('log')->debug(sprintf('Searching for category with name %s...', $categoryName));- $result = $this->findByName((string)$categoryName);- if (null === $result && '' !== (string)$categoryName) {+ $result = $this->findByName((string) $categoryName);+ if (null === $result && '' !== (string) $categoryName) {// create it!$result = $this->store(['name' => $categoryName]);}diff --git a/app/Repositories/Category/NoCategoryRepository.php b/app/Repositories/Category/NoCategoryRepository.phpindex b4d8a0b417..5f879700b4 100644--- a/app/Repositories/Category/NoCategoryRepository.php+++ b/app/Repositories/Category/NoCategoryRepository.php@@ -55,7 +55,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['categories' => [],'currency_id' => $currencyId,@@ -67,13 +67,13 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface// info about the non-existent category:$array[$currencyId]['categories'][0] ??= ['id' => 0,- 'name' => (string)trans('firefly.noCategory'),+ 'name' => (string) trans('firefly.noCategory'),'transaction_journals' => [],];// add journal to array:// only a subset of the fields.- $journalId = (int)$journal['transaction_journal_id'];+ $journalId = (int) $journal['transaction_journal_id'];$array[$currencyId]['categories'][0]['transaction_journals'][$journalId]= ['amount' => app('steam')->negative($journal['amount']),@@ -108,7 +108,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['categories' => [],'currency_id' => $currencyId,@@ -121,12 +121,12 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface// info about the non-existent category:$array[$currencyId]['categories'][0] ??= ['id' => 0,- 'name' => (string)trans('firefly.noCategory'),+ 'name' => (string) trans('firefly.noCategory'),'transaction_journals' => [],];// add journal to array:// only a subset of the fields.- $journalId = (int)$journal['transaction_journal_id'];+ $journalId = (int) $journal['transaction_journal_id'];$array[$currencyId]['categories'][0]['transaction_journals'][$journalId]= ['amount' => app('steam')->positive($journal['amount']),@@ -153,7 +153,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['sum' => '0','currency_id' => $currencyId,@@ -184,7 +184,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['sum' => '0','currency_id' => $currencyId,@@ -212,7 +212,7 @@ class NoCategoryRepository implements NoCategoryRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['sum' => '0','currency_id' => $currencyId,diff --git a/app/Repositories/Category/OperationsRepository.php b/app/Repositories/Category/OperationsRepository.phpindex 33c9cc7240..73028534e4 100644--- a/app/Repositories/Category/OperationsRepository.php+++ b/app/Repositories/Category/OperationsRepository.php@@ -64,9 +64,9 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];- $categoryId = (int)$journal['category_id'];- $categoryName = (string)$journal['category_name'];+ $currencyId = (int) $journal['currency_id'];+ $categoryId = (int) $journal['category_id'];+ $categoryName = (string) $journal['category_name'];// catch "no category" entries.if (0 === $categoryId) {@@ -76,7 +76,7 @@ class OperationsRepository implements OperationsRepositoryInterface// info about the currency:$array[$currencyId] ??= ['categories' => [],- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_name' => $journal['currency_name'],'currency_symbol' => $journal['currency_symbol'],'currency_code' => $journal['currency_code'],@@ -85,24 +85,24 @@ class OperationsRepository implements OperationsRepositoryInterface// info about the categories:$array[$currencyId]['categories'][$categoryId] ??= [- 'id' => (string)$categoryId,+ 'id' => (string) $categoryId,'name' => $categoryName,'transaction_journals' => [],];// add journal to array:// only a subset of the fields.- $journalId = (int)$journal['transaction_journal_id'];+ $journalId = (int) $journal['transaction_journal_id'];$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = ['amount' => app('steam')->negative($journal['amount']),'date' => $journal['date'],- 'source_account_id' => (string)$journal['source_account_id'],+ 'source_account_id' => (string) $journal['source_account_id'],'budget_name' => $journal['budget_name'],'source_account_name' => $journal['source_account_name'],- 'destination_account_id' => (string)$journal['destination_account_id'],+ 'destination_account_id' => (string) $journal['destination_account_id'],'destination_account_name' => $journal['destination_account_name'],'description' => $journal['description'],- 'transaction_group_id' => (string)$journal['transaction_group_id'],+ 'transaction_group_id' => (string) $journal['transaction_group_id'],];}@@ -148,19 +148,19 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];- $categoryId = (int)$journal['category_id'];- $categoryName = (string)$journal['category_name'];+ $currencyId = (int) $journal['currency_id'];+ $categoryId = (int) $journal['category_id'];+ $categoryName = (string) $journal['category_name'];// catch "no category" entries.if (0 === $categoryId) {- $categoryName = (string)trans('firefly.no_category');+ $categoryName = (string) trans('firefly.no_category');}// info about the currency:$array[$currencyId] ??= ['categories' => [],- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_name' => $journal['currency_name'],'currency_symbol' => $journal['currency_symbol'],'currency_code' => $journal['currency_code'],@@ -169,23 +169,23 @@ class OperationsRepository implements OperationsRepositoryInterface// info about the categories:$array[$currencyId]['categories'][$categoryId] ??= [- 'id' => (string)$categoryId,+ 'id' => (string) $categoryId,'name' => $categoryName,'transaction_journals' => [],];// add journal to array:// only a subset of the fields.- $journalId = (int)$journal['transaction_journal_id'];+ $journalId = (int) $journal['transaction_journal_id'];$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = ['amount' => app('steam')->positive($journal['amount']),'date' => $journal['date'],- 'source_account_id' => (string)$journal['source_account_id'],- 'destination_account_id' => (string)$journal['destination_account_id'],+ 'source_account_id' => (string) $journal['source_account_id'],+ 'destination_account_id' => (string) $journal['destination_account_id'],'source_account_name' => $journal['source_account_name'],'destination_account_name' => $journal['destination_account_name'],'description' => $journal['description'],- 'transaction_group_id' => (string)$journal['transaction_group_id'],+ 'transaction_group_id' => (string) $journal['transaction_group_id'],];}@@ -210,9 +210,9 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];- $categoryId = (int)$journal['category_id'];- $categoryName = (string)$journal['category_name'];+ $currencyId = (int) $journal['currency_id'];+ $categoryId = (int) $journal['category_id'];+ $categoryName = (string) $journal['category_name'];// catch "no category" entries.if (0 === $categoryId) {@@ -222,7 +222,7 @@ class OperationsRepository implements OperationsRepositoryInterface// info about the currency:$array[$currencyId] ??= ['categories' => [],- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_name' => $journal['currency_name'],'currency_symbol' => $journal['currency_symbol'],'currency_code' => $journal['currency_code'],@@ -231,24 +231,24 @@ class OperationsRepository implements OperationsRepositoryInterface// info about the categories:$array[$currencyId]['categories'][$categoryId] ??= [- 'id' => (string)$categoryId,+ 'id' => (string) $categoryId,'name' => $categoryName,'transaction_journals' => [],];// add journal to array:// only a subset of the fields.- $journalId = (int)$journal['transaction_journal_id'];+ $journalId = (int) $journal['transaction_journal_id'];$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = ['amount' => app('steam')->positive($journal['amount']),'date' => $journal['date'],- 'source_account_id' => (string)$journal['source_account_id'],+ 'source_account_id' => (string) $journal['source_account_id'],'category_name' => $journal['category_name'],'source_account_name' => $journal['source_account_name'],- 'destination_account_id' => (string)$journal['destination_account_id'],+ 'destination_account_id' => (string) $journal['destination_account_id'],'destination_account_name' => $journal['destination_account_name'],'description' => $journal['description'],- 'transaction_group_id' => (string)$journal['transaction_group_id'],+ 'transaction_group_id' => (string) $journal['transaction_group_id'],];}@@ -273,9 +273,9 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];- $categoryId = (int)$journal['category_id'];- $categoryName = (string)$journal['category_name'];+ $currencyId = (int) $journal['currency_id'];+ $categoryId = (int) $journal['category_id'];+ $categoryName = (string) $journal['category_name'];// catch "no category" entries.if (0 === $categoryId) {@@ -285,7 +285,7 @@ class OperationsRepository implements OperationsRepositoryInterface// info about the currency:$array[$currencyId] ??= ['categories' => [],- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_name' => $journal['currency_name'],'currency_symbol' => $journal['currency_symbol'],'currency_code' => $journal['currency_code'],@@ -294,24 +294,24 @@ class OperationsRepository implements OperationsRepositoryInterface// info about the categories:$array[$currencyId]['categories'][$categoryId] ??= [- 'id' => (string)$categoryId,+ 'id' => (string) $categoryId,'name' => $categoryName,'transaction_journals' => [],];// add journal to array:// only a subset of the fields.- $journalId = (int)$journal['transaction_journal_id'];+ $journalId = (int) $journal['transaction_journal_id'];$array[$currencyId]['categories'][$categoryId]['transaction_journals'][$journalId] = ['amount' => app('steam')->negative($journal['amount']),'date' => $journal['date'],- 'source_account_id' => (string)$journal['source_account_id'],+ 'source_account_id' => (string) $journal['source_account_id'],'category_name' => $journal['category_name'],'source_account_name' => $journal['source_account_name'],- 'destination_account_id' => (string)$journal['destination_account_id'],+ 'destination_account_id' => (string) $journal['destination_account_id'],'destination_account_name' => $journal['destination_account_name'],'description' => $journal['description'],- 'transaction_group_id' => (string)$journal['transaction_group_id'],+ 'transaction_group_id' => (string) $journal['transaction_group_id'],];}@@ -341,14 +341,14 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['sum' => '0',- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_name' => $journal['currency_name'],'currency_symbol' => $journal['currency_symbol'],'currency_code' => $journal['currency_code'],- 'currency_decimal_places' => (int)$journal['currency_decimal_places'],+ 'currency_decimal_places' => (int) $journal['currency_decimal_places'],];$array[$currencyId]['sum'] = bcadd($array[$currencyId]['sum'], app('steam')->negative($journal['amount']));}@@ -378,10 +378,10 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['sum' => '0',- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_name' => $journal['currency_name'],'currency_symbol' => $journal['currency_symbol'],'currency_code' => $journal['currency_code'],@@ -415,10 +415,10 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['sum' => '0',- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_name' => $journal['currency_name'],'currency_symbol' => $journal['currency_symbol'],'currency_code' => $journal['currency_code'],diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.phpindex f66fc0dbd2..438354f4a5 100644--- a/app/Repositories/Currency/CurrencyRepository.php+++ b/app/Repositories/Currency/CurrencyRepository.php@@ -37,6 +37,12 @@ class CurrencyRepository implements CurrencyRepositoryInterface{private User $user;+ #[\Override]+ public function find(int $currencyId): ?TransactionCurrency+ {+ return TransactionCurrency::find($currencyId);+ }+/*** Find by currency code, return NULL if unfound.*/@@ -89,13 +95,13 @@ class CurrencyRepository implements CurrencyRepositoryInterface{return CurrencyExchangeRate::create([- 'user_id' => $this->user->id,- 'user_group_id' => $this->user->user_group_id,- 'from_currency_id' => $fromCurrency->id,- 'to_currency_id' => $toCurrency->id,- 'date' => $date,- 'date_tz' => $date->format('e'),- 'rate' => $rate,+ 'user_id' => $this->user->id,+ 'user_group_id' => $this->user->user_group_id,+ 'from_currency_id' => $fromCurrency->id,+ 'to_currency_id' => $toCurrency->id,+ 'date' => $date,+ 'date_tz' => $date->format('e'),+ 'rate' => $rate,]);}@@ -106,10 +112,4 @@ class CurrencyRepository implements CurrencyRepositoryInterface$this->user = $user;}}-- #[\Override]- public function find(int $currencyId): ?TransactionCurrency- {- return TransactionCurrency::find($currencyId);- }}diff --git a/app/Repositories/Currency/CurrencyRepositoryInterface.php b/app/Repositories/Currency/CurrencyRepositoryInterface.phpindex b5fb7d7acb..09258197fd 100644--- a/app/Repositories/Currency/CurrencyRepositoryInterface.php+++ b/app/Repositories/Currency/CurrencyRepositoryInterface.php@@ -35,6 +35,8 @@ use Illuminate\Support\Collection;*/interface CurrencyRepositoryInterface{+ public function find(int $currencyId): ?TransactionCurrency;+/*** Find by currency code, return NULL if unfound.*@@ -42,8 +44,6 @@ interface CurrencyRepositoryInterface*/public function findByCode(string $currencyCode): ?TransactionCurrency;- public function find(int $currencyId): ?TransactionCurrency;-/*** Returns the complete set of transactions but needs* no user object.diff --git a/app/Repositories/Journal/JournalCLIRepository.php b/app/Repositories/Journal/JournalCLIRepository.phpindex 9960cb8ac5..53543eb70b 100644--- a/app/Repositories/Journal/JournalCLIRepository.php+++ b/app/Repositories/Journal/JournalCLIRepository.php@@ -143,7 +143,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface}// return when something else:- $return = (string)$value;+ $return = (string) $value;$cache->store($return);return $return;@@ -176,8 +176,8 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface/** @var \stdClass $row */foreach ($result as $row) {- if ((int)$row->transaction_count > 2) {- $journalIds[] = (int)$row->id;+ if ((int) $row->transaction_count > 2) {+ $journalIds[] = (int) $row->id;}}$journalIds = array_unique($journalIds);diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.phpindex e8d19790cb..cac96ff771 100644--- a/app/Repositories/Journal/JournalRepository.php+++ b/app/Repositories/Journal/JournalRepository.php@@ -111,7 +111,7 @@ class JournalRepository implements JournalRepositoryInterface// saves on queries:$amount = $journal->transactions()->where('amount', '>', 0)->get()->sum('amount');- $amount = (string)$amount;+ $amount = (string) $amount;$cache->store($amount);return $amount;@@ -134,7 +134,7 @@ class JournalRepository implements JournalRepositoryInterface/** @var null|Note $note */$note = $link->notes()->first();- return (string)$note?->text;+ return (string) $note?->text;}/**diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.phpindex 7f49ab5211..f42ece55ca 100644--- a/app/Repositories/LinkType/LinkTypeRepository.php+++ b/app/Repositories/LinkType/LinkTypeRepository.php@@ -56,13 +56,13 @@ class LinkTypeRepository implements LinkTypeRepositoryInterfacepublic function update(LinkType $linkType, array $data): LinkType{- if (array_key_exists('name', $data) && '' !== (string)$data['name']) {+ if (array_key_exists('name', $data) && '' !== (string) $data['name']) {$linkType->name = $data['name'];}- if (array_key_exists('inward', $data) && '' !== (string)$data['inward']) {+ if (array_key_exists('inward', $data) && '' !== (string) $data['inward']) {$linkType->inward = $data['inward'];}- if (array_key_exists('outward', $data) && '' !== (string)$data['outward']) {+ if (array_key_exists('outward', $data) && '' !== (string) $data['outward']) {$linkType->outward = $data['outward'];}$linkType->save();@@ -183,7 +183,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface*/public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink{- $linkType = $this->find((int)($information['link_type_id'] ?? 0));+ $linkType = $this->find((int) ($information['link_type_id'] ?? 0));if (null === $linkType) {$linkType = $this->findByName($information['link_type_name']);@@ -215,7 +215,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface$link->save();// make note in noteable:- $this->setNoteText($link, (string)$information['notes']);+ $this->setNoteText($link, (string) $information['notes']);return $link;}diff --git a/app/Repositories/ObjectGroup/CreatesObjectGroups.php b/app/Repositories/ObjectGroup/CreatesObjectGroups.phpindex dc843cc2c2..767416456a 100644--- a/app/Repositories/ObjectGroup/CreatesObjectGroups.php+++ b/app/Repositories/ObjectGroup/CreatesObjectGroups.php@@ -56,7 +56,7 @@ trait CreatesObjectGroupsprotected function getObjectGroupMaxOrder(): int{- return (int)$this->user->objectGroups()->max('order');+ return (int) $this->user->objectGroups()->max('order');}protected function hasObjectGroup(string $title): booldiff --git a/app/Repositories/ObjectGroup/ObjectGroupRepository.php b/app/Repositories/ObjectGroup/ObjectGroupRepository.phpindex 7bb97a861d..e9d880d56a 100644--- a/app/Repositories/ObjectGroup/ObjectGroupRepository.php+++ b/app/Repositories/ObjectGroup/ObjectGroupRepository.php@@ -141,7 +141,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface}if (array_key_exists('order', $data)) {- $this->setOrder($objectGroup, (int)$data['order']);+ $this->setOrder($objectGroup, (int) $data['order']);}$objectGroup->save();diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.phpindex e3575f2189..b3b13cc049 100644--- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php+++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php@@ -80,24 +80,6 @@ trait ModifiesPiggyBanksreturn true;}- public function removeAmountFromAll(PiggyBank $piggyBank, string $amount): void- {- foreach ($piggyBank->accounts as $account) {- $current = $account->pivot->current_amount;- // if this account contains more than the amount, remove the amount and return.- if (1 === bccomp($current, $amount)) {- $this->removeAmount($piggyBank, $account, $amount);-- return;- }- // if this account contains less than the amount, remove the current amount, update the amount and continue.- if (bccomp($current, $amount) < 1) {- $this->removeAmount($piggyBank, $account, $current);- $amount = bcsub($amount, $current);- }- }- }-public function addAmount(PiggyBank $piggyBank, Account $account, string $amount, ?TransactionJournal $journal = null): bool{$currentAmount = $this->getCurrentAmount($piggyBank, $account);@@ -220,57 +202,6 @@ trait ModifiesPiggyBanksreturn $factory->store($data);}- public function setOrder(PiggyBank $piggyBank, int $newOrder): bool- {- $oldOrder = $piggyBank->order;- // Log::debug(sprintf('Will move piggy bank #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));- if ($newOrder > $oldOrder) {- PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')- ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')- ->where('accounts.user_id', $this->user->id)- ->where('piggy_banks.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder)- ->where('piggy_banks.id', '!=', $piggyBank->id)- ->distinct()->decrement('piggy_banks.order')- ;-- $piggyBank->order = $newOrder;- Log::debug(sprintf('[1] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));- $piggyBank->save();-- return true;- }- PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')- ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')- ->where('accounts.user_id', $this->user->id)- ->where('piggy_banks.order', '>=', $newOrder)->where('piggy_banks.order', '<', $oldOrder)- ->where('piggy_banks.id', '!=', $piggyBank->id)- ->distinct()->increment('piggy_banks.order')- ;-- $piggyBank->order = $newOrder;- Log::debug(sprintf('[2] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));- $piggyBank->save();-- return true;- }-- public function updateNote(PiggyBank $piggyBank, string $note): void- {- if ('' === $note) {- $dbNote = $piggyBank->notes()->first();- $dbNote?->delete();-- return;- }- $dbNote = $piggyBank->notes()->first();- if (null === $dbNote) {- $dbNote = new Note();- $dbNote->noteable()->associate($piggyBank);- }- $dbNote->text = trim($note);- $dbNote->save();- }-public function update(PiggyBank $piggyBank, array $data): PiggyBank{$piggyBank = $this->updateProperties($piggyBank, $data);@@ -363,4 +294,73 @@ trait ModifiesPiggyBanksreturn $piggyBank;}++ public function updateNote(PiggyBank $piggyBank, string $note): void+ {+ if ('' === $note) {+ $dbNote = $piggyBank->notes()->first();+ $dbNote?->delete();++ return;+ }+ $dbNote = $piggyBank->notes()->first();+ if (null === $dbNote) {+ $dbNote = new Note();+ $dbNote->noteable()->associate($piggyBank);+ }+ $dbNote->text = trim($note);+ $dbNote->save();+ }++ public function setOrder(PiggyBank $piggyBank, int $newOrder): bool+ {+ $oldOrder = $piggyBank->order;+ // Log::debug(sprintf('Will move piggy bank #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));+ if ($newOrder > $oldOrder) {+ PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')+ ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')+ ->where('accounts.user_id', $this->user->id)+ ->where('piggy_banks.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder)+ ->where('piggy_banks.id', '!=', $piggyBank->id)+ ->distinct()->decrement('piggy_banks.order')+ ;++ $piggyBank->order = $newOrder;+ Log::debug(sprintf('[1] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));+ $piggyBank->save();++ return true;+ }+ PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')+ ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')+ ->where('accounts.user_id', $this->user->id)+ ->where('piggy_banks.order', '>=', $newOrder)->where('piggy_banks.order', '<', $oldOrder)+ ->where('piggy_banks.id', '!=', $piggyBank->id)+ ->distinct()->increment('piggy_banks.order')+ ;++ $piggyBank->order = $newOrder;+ Log::debug(sprintf('[2] Order of piggy #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));+ $piggyBank->save();++ return true;+ }++ public function removeAmountFromAll(PiggyBank $piggyBank, string $amount): void+ {+ foreach ($piggyBank->accounts as $account) {+ $current = $account->pivot->current_amount;+ // if this account contains more than the amount, remove the amount and return.+ if (1 === bccomp($current, $amount)) {+ $this->removeAmount($piggyBank, $account, $amount);++ return;+ }+ // if this account contains less than the amount, remove the current amount, update the amount and continue.+ if (bccomp($current, $amount) < 1) {+ $this->removeAmount($piggyBank, $account, $current);+ $amount = bcsub($amount, $current);+ }+ }+ }}diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.phpindex 1de3cb857c..37862c0a3c 100644--- a/app/Repositories/PiggyBank/PiggyBankRepository.php+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php@@ -119,35 +119,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface);}- /**- * Get current amount saved in piggy bank.- */- public function getCurrentAmount(PiggyBank $piggyBank, ?Account $account = null): string- {- $sum = '0';- foreach ($piggyBank->accounts as $current) {- if (null !== $account && $account->id !== $current->id) {- continue;- }- $amount = (string) $current->pivot->current_amount;- $amount = '' === $amount ? '0' : $amount;- $sum = bcadd($sum, $amount);- }- Log::debug(sprintf('Current amount in piggy bank #%d ("%s") is %s', $piggyBank->id, $piggyBank->name, $sum));-- return $sum;- }-- public function getRepetition(PiggyBank $piggyBank, bool $overrule = false): ?PiggyBankRepetition- {- if (false === $overrule) {- throw new FireflyException('[b] Piggy bank repetitions are EOL.');- }- Log::warning('Piggy bank repetitions are EOL.');-- return $piggyBank->piggyBankRepetitions()->first();- }-public function getEvents(PiggyBank $piggyBank): Collection{return $piggyBank->piggyBankEvents()->orderBy('date', 'DESC')->orderBy('id', 'DESC')->get();@@ -302,6 +273,35 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface;}+ /**+ * Get current amount saved in piggy bank.+ */+ public function getCurrentAmount(PiggyBank $piggyBank, ?Account $account = null): string+ {+ $sum = '0';+ foreach ($piggyBank->accounts as $current) {+ if (null !== $account && $account->id !== $current->id) {+ continue;+ }+ $amount = (string) $current->pivot->current_amount;+ $amount = '' === $amount ? '0' : $amount;+ $sum = bcadd($sum, $amount);+ }+ Log::debug(sprintf('Current amount in piggy bank #%d ("%s") is %s', $piggyBank->id, $piggyBank->name, $sum));++ return $sum;+ }++ public function getRepetition(PiggyBank $piggyBank, bool $overrule = false): ?PiggyBankRepetition+ {+ if (false === $overrule) {+ throw new FireflyException('[b] Piggy bank repetitions are EOL.');+ }+ Log::warning('Piggy bank repetitions are EOL.');++ return $piggyBank->piggyBankRepetitions()->first();+ }+/*** Returns the suggested amount the user should save per month, or "".*/@@ -352,28 +352,6 @@ class PiggyBankRepository implements PiggyBankRepositoryInterfacereturn $balance;}- public function searchPiggyBank(string $query, int $limit): Collection- {- $search = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')- ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')- ->where('accounts.user_id', $this->user->id)- ->with(- [- 'objectGroups',- ]- )- ->orderBy('piggy_banks.order', 'ASC')->distinct()- ;- if ('' !== $query) {- $search->whereLike('piggy_banks.name', sprintf('%%%s%%', $query));- }- $search->orderBy('piggy_banks.order', 'ASC')- ->orderBy('piggy_banks.name', 'ASC')- ;-- return $search->take($limit)->get(['piggy_banks.*']);- }-#[\Override]public function purgeAll(): void{@@ -398,4 +376,26 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface$factory->user = $this->user;$factory->resetOrder();}++ public function searchPiggyBank(string $query, int $limit): Collection+ {+ $search = PiggyBank::leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')+ ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')+ ->where('accounts.user_id', $this->user->id)+ ->with(+ [+ 'objectGroups',+ ]+ )+ ->orderBy('piggy_banks.order', 'ASC')->distinct()+ ;+ if ('' !== $query) {+ $search->whereLike('piggy_banks.name', sprintf('%%%s%%', $query));+ }+ $search->orderBy('piggy_banks.order', 'ASC')+ ->orderBy('piggy_banks.name', 'ASC')+ ;++ return $search->take($limit)->get(['piggy_banks.*']);+ }}diff --git a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.phpindex fedc772ebe..739a830c8b 100644--- a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php+++ b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php@@ -53,8 +53,6 @@ interface PiggyBankRepositoryInterfacepublic function destroyAll(): void;- public function purgeAll(): void;-public function find(int $piggyBankId): ?PiggyBank;/**@@ -70,22 +68,20 @@ interface PiggyBankRepositoryInterface* Get current amount saved in piggy bank.*/public function getCurrentAmount(PiggyBank $piggyBank, ?Account $account = null): string;- /**- * Get current amount saved in piggy bank.- *//*** Get all events.*/public function getEvents(PiggyBank $piggyBank): Collection;+ /**+ * Get current amount saved in piggy bank.+ *//*** Used for connecting to a piggy bank.*/public function getExactAmount(PiggyBank $piggyBank, PiggyBankRepetition $repetition, TransactionJournal $journal): string;- public function updateNote(PiggyBank $piggyBank, string $note): void;-/*** Return note for piggy bank.*/@@ -113,6 +109,8 @@ interface PiggyBankRepositoryInterface*/public function leftOnAccount(PiggyBank $piggyBank, Account $account, Carbon $date): string;+ public function purgeAll(): void;+public function removeAmount(PiggyBank $piggyBank, Account $account, string $amount, ?TransactionJournal $journal = null): bool;public function removeAmountFromAll(PiggyBank $piggyBank, string $amount): void;@@ -148,4 +146,6 @@ interface PiggyBankRepositoryInterface* Update existing piggy bank.*/public function update(PiggyBank $piggyBank, array $data): PiggyBank;++ public function updateNote(PiggyBank $piggyBank, string $note): void;}diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.phpindex da014f3143..05758578a7 100644--- a/app/Repositories/Rule/RuleRepository.php+++ b/app/Repositories/Rule/RuleRepository.php@@ -61,7 +61,7 @@ class RuleRepository implements RuleRepositoryInterfacepublic function duplicate(Rule $rule): Rule{$newRule = $rule->replicate();- $newRule->title = (string)trans('firefly.rule_copy_of', ['title' => $rule->title]);+ $newRule->title = (string) trans('firefly.rule_copy_of', ['title' => $rule->title]);$newRule->save();// replicate all triggers@@ -101,7 +101,7 @@ class RuleRepository implements RuleRepositoryInterfacepublic function getHighestOrderInRuleGroup(RuleGroup $ruleGroup): int{- return (int)$ruleGroup->rules()->max('order');+ return (int) $ruleGroup->rules()->max('order');}/**@@ -352,7 +352,7 @@ class RuleRepository implements RuleRepositoryInterfacepublic function maxOrder(RuleGroup $ruleGroup): int{- return (int)$ruleGroup->rules()->max('order');+ return (int) $ruleGroup->rules()->max('order');}private function storeTriggers(Rule $rule, array $data): void@@ -477,7 +477,7 @@ class RuleRepository implements RuleRepositoryInterface// update the order:$this->resetRuleOrder($group);if (array_key_exists('order', $data)) {- $this->moveRule($rule, $group, (int)$data['order']);+ $this->moveRule($rule, $group, (int) $data['order']);}// update the triggers:diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.phpindex 84d485c651..a5d6b57b78 100644--- a/app/Repositories/RuleGroup/RuleGroupRepository.php+++ b/app/Repositories/RuleGroup/RuleGroupRepository.php@@ -303,7 +303,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface{$entry = $this->user->ruleGroups()->max('order');- return (int)$entry;+ return (int) $entry;}public function getRuleGroupsWithRules(?string $filter): Collection@@ -364,7 +364,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterfacepublic function maxOrder(): int{- return (int)$this->user->ruleGroups()->where('active', true)->max('order');+ return (int) $this->user->ruleGroups()->where('active', true)->max('order');}public function searchRuleGroup(string $query, int $limit): Collection@@ -448,7 +448,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface// orderif (array_key_exists('order', $data) && $ruleGroup->order !== $data['order']) {$this->resetOrder();- $this->setOrder($ruleGroup, (int)$data['order']);+ $this->setOrder($ruleGroup, (int) $data['order']);}$ruleGroup->save();diff --git a/app/Repositories/Tag/OperationsRepository.php b/app/Repositories/Tag/OperationsRepository.phpindex c1cfa72963..32ae337473 100644--- a/app/Repositories/Tag/OperationsRepository.php+++ b/app/Repositories/Tag/OperationsRepository.php@@ -66,7 +66,7 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];$listedJournals = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['tags' => [],'currency_id' => $currencyId,@@ -78,9 +78,9 @@ class OperationsRepository implements OperationsRepositoryInterface// may have multiple tags:foreach ($journal['tags'] as $tag) {- $tagId = (int)$tag['id'];- $tagName = (string)$tag['name'];- $journalId = (int)$journal['transaction_journal_id'];+ $tagId = (int) $tag['id'];+ $tagName = (string) $tag['name'];+ $journalId = (int) $journal['transaction_journal_id'];if (!in_array($tagId, $tagIds, true)) {continue;}@@ -157,7 +157,7 @@ class OperationsRepository implements OperationsRepositoryInterface$listedJournals = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$array[$currencyId] ??= ['tags' => [],'currency_id' => $currencyId,@@ -169,9 +169,9 @@ class OperationsRepository implements OperationsRepositoryInterface// may have multiple tags:foreach ($journal['tags'] as $tag) {- $tagId = (int)$tag['id'];- $tagName = (string)$tag['name'];- $journalId = (int)$journal['transaction_journal_id'];+ $tagId = (int) $tag['id'];+ $tagName = (string) $tag['name'];+ $journalId = (int) $journal['transaction_journal_id'];if (!in_array($tagId, $tagIds, true)) {continue;@@ -187,7 +187,7 @@ class OperationsRepository implements OperationsRepositoryInterface'name' => $tagName,'transaction_journals' => [],];- $journalId = (int)$journal['transaction_journal_id'];+ $journalId = (int) $journal['transaction_journal_id'];$array[$currencyId]['tags'][$tagId]['transaction_journals'][$journalId] = ['amount' => app('steam')->positive($journal['amount']),'date' => $journal['date'],diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.phpindex 756ca3d738..e81173b003 100644--- a/app/Repositories/Tag/TagRepository.php+++ b/app/Repositories/Tag/TagRepository.php@@ -259,7 +259,7 @@ class TagRepository implements TagRepositoryInterfaceif (false === $found) {continue;}- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$sums[$currencyId] ??= ['currency_id' => $currencyId,'currency_name' => $journal['currency_name'],@@ -273,7 +273,7 @@ class TagRepository implements TagRepositoryInterface];// add amount to correct type:- $amount = app('steam')->positive((string)$journal['amount']);+ $amount = app('steam')->positive((string) $journal['amount']);$type = $journal['transaction_type_type'];if (TransactionType::WITHDRAWAL === $type) {$amount = bcmul($amount, '-1');@@ -294,7 +294,7 @@ class TagRepository implements TagRepositoryInterfaceTransactionType::OPENING_BALANCE => '0',];// add foreign amount to correct type:- $amount = app('steam')->positive((string)$journal['foreign_amount']);+ $amount = app('steam')->positive((string) $journal['foreign_amount']);if (TransactionType::WITHDRAWAL === $type) {$amount = bcmul($amount, '-1');}diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.phpindex 0e55f25dc1..531c36a46a 100644--- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php+++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php@@ -219,7 +219,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface'link' => $entry->outward,'group' => $entry->destination->transaction_group_id,'description' => $entry->destination->description,- 'editable' => 1 === (int)$entry->editable, // @phpstan-ignore-line+ 'editable' => 1 === (int) $entry->editable, // @phpstan-ignore-line'amount' => $amount,'foreign_amount' => $foreignAmount,];@@ -232,7 +232,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface'link' => $entry->inward,'group' => $entry->source->transaction_group_id,'description' => $entry->source->description,- 'editable' => 1 === (int)$entry->editable, // @phpstan-ignore-line+ 'editable' => 1 === (int) $entry->editable, // @phpstan-ignore-line'amount' => $amount,'foreign_amount' => $foreignAmount,];diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.phpindex 59b96f40a6..ef8b158831 100644--- a/app/Repositories/User/UserRepository.php+++ b/app/Repositories/User/UserRepository.php@@ -201,7 +201,7 @@ class UserRepository implements UserRepositoryInterface// two factor:$return['has_2fa'] = null !== $user->mfa_secret;$return['is_admin'] = $this->hasRole($user, 'owner');- $return['blocked'] = 1 === (int)$user->blocked;+ $return['blocked'] = 1 === (int) $user->blocked;$return['blocked_code'] = $user->blocked_code;$return['accounts'] = $user->accounts()->count();$return['journals'] = $user->transactionJournals()->count();diff --git a/app/Repositories/UserGroup/UserGroupRepository.php b/app/Repositories/UserGroup/UserGroupRepository.phpindex 8ed4f51d83..89baea8799 100644--- a/app/Repositories/UserGroup/UserGroupRepository.php+++ b/app/Repositories/UserGroup/UserGroupRepository.php@@ -174,6 +174,18 @@ class UserGroupRepository implements UserGroupRepositoryInterfacereturn UserGroup::all();}+ #[\Override]+ public function getById(int $id): ?UserGroup+ {+ return UserGroup::find($id);+ }++ #[\Override]+ public function getMembershipsFromGroupId(int $groupId): Collection+ {+ return $this->user->groupMemberships()->where('user_group_id', $groupId)->get();+ }+public function setUser(null|Authenticatable|User $user): void{app('log')->debug(sprintf('Now in %s', __METHOD__));@@ -207,7 +219,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface$user = User::find($data['id']);app('log')->debug('Found user by ID');}- if (array_key_exists('email', $data) && '' !== (string)$data['email']) {+ if (array_key_exists('email', $data) && '' !== (string) $data['email']) {/** @var null|User $user */$user = User::whereEmail($data['email'])->first();app('log')->debug('Found user by email');@@ -225,13 +237,13 @@ class UserGroupRepository implements UserGroupRepositoryInterfaceif (1 === $membershipCount) {$lastUserId = $userGroup->groupMemberships()->distinct()->first(['group_memberships.user_id'])->user_id;// if this is also the user we're editing right now, and we remove all of their roles:- if ($lastUserId === (int)$user->id && 0 === count($data['roles'])) {+ if ($lastUserId === (int) $user->id && 0 === count($data['roles'])) {app('log')->debug('User is last in this group, refuse to act');throw new FireflyException('You cannot remove the last member from this user group. Delete the user group instead.');}// if this is also the user we're editing right now, and do not grant them the owner role:- if ($lastUserId === (int)$user->id && count($data['roles']) > 0 && !in_array(UserRoleEnum::OWNER->value, $data['roles'], true)) {+ if ($lastUserId === (int) $user->id && count($data['roles']) > 0 && !in_array(UserRoleEnum::OWNER->value, $data['roles'], true)) {app('log')->debug('User needs to have owner role in this group, refuse to act');throw new FireflyException('The last member in this user group must get or keep the "owner" role.');@@ -295,16 +307,4 @@ class UserGroupRepository implements UserGroupRepositoryInterface$this->user->user_group_id = $userGroup->id;$this->user->save();}-- #[\Override]- public function getMembershipsFromGroupId(int $groupId): Collection- {- return $this->user->groupMemberships()->where('user_group_id', $groupId)->get();- }-- #[\Override]- public function getById(int $id): ?UserGroup- {- return UserGroup::find($id);- }}diff --git a/app/Repositories/UserGroup/UserGroupRepositoryInterface.php b/app/Repositories/UserGroup/UserGroupRepositoryInterface.phpindex 5a22f89d63..0bbeddf828 100644--- a/app/Repositories/UserGroup/UserGroupRepositoryInterface.php+++ b/app/Repositories/UserGroup/UserGroupRepositoryInterface.php@@ -36,13 +36,13 @@ interface UserGroupRepositoryInterface{public function destroy(UserGroup $userGroup): void;- public function getMembershipsFromGroupId(int $groupId): Collection;-public function get(): Collection;+ public function getAll(): Collection;+public function getById(int $id): ?UserGroup;- public function getAll(): Collection;+ public function getMembershipsFromGroupId(int $groupId): Collection;public function setUser(null|Authenticatable|User $user): void;diff --git a/app/Repositories/UserGroups/Account/AccountRepository.php b/app/Repositories/UserGroups/Account/AccountRepository.phpindex 7cfe21d561..bc66665c98 100644--- a/app/Repositories/UserGroups/Account/AccountRepository.php+++ b/app/Repositories/UserGroups/Account/AccountRepository.php@@ -117,6 +117,12 @@ class AccountRepository implements AccountRepositoryInterfacereturn $account;}+ #[\Override]+ public function getAccountBalances(Account $account): Collection+ {+ return $account->accountBalances;+ }+public function getAccountCurrency(Account $account): ?TransactionCurrency{$type = $account->accountType->type;@@ -164,6 +170,15 @@ class AccountRepository implements AccountRepositoryInterfacereturn $account;}+ #[\Override]+ public function getAccountTypes(Collection $accounts): Collection+ {+ return AccountType::leftJoin('accounts', 'accounts.account_type_id', '=', 'account_types.id')+ ->whereIn('accounts.id', $accounts->pluck('id')->toArray())+ ->get(['accounts.id', 'account_types.type'])+ ;+ }+public function getAccountsById(array $accountIds): Collection{$query = $this->userGroup->accounts();@@ -218,6 +233,57 @@ class AccountRepository implements AccountRepositoryInterfacereturn $query->get(['accounts.*']);}+ #[\Override]+ public function getLastActivity(Collection $accounts): array+ {+ return Transaction::whereIn('account_id', $accounts->pluck('id')->toArray())+ ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')+ ->groupBy('transactions.account_id')+ ->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) as date_max')])->toArray() // @phpstan-ignore-line+ ;+ }++ #[\Override]+ public function getMetaValues(Collection $accounts, array $fields): Collection+ {+ $query = AccountMeta::whereIn('account_id', $accounts->pluck('id')->toArray());+ if (count($fields) > 0) {+ $query->whereIn('name', $fields);+ }++ return $query->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data']);+ }++ #[\Override]+ public function getObjectGroups(Collection $accounts): array+ {+ $groupIds = [];+ $return = [];+ $set = DB::table('object_groupables')->where('object_groupable_type', Account::class)+ ->whereIn('object_groupable_id', $accounts->pluck('id')->toArray())->get()+ ;++ /** @var \stdClass $row */+ foreach ($set as $row) {+ $groupIds[] = $row->object_group_id;+ }+ $groupIds = array_unique($groupIds);+ $groups = ObjectGroup::whereIn('id', $groupIds)->get();++ /** @var \stdClass $row */+ foreach ($set as $row) {+ if (!array_key_exists($row->object_groupable_id, $return)) {+ /** @var null|ObjectGroup $group */+ $group = $groups->firstWhere('id', '=', $row->object_group_id);+ if (null !== $group) {+ $return[$row->object_groupable_id] = ['title' => $group->title, 'order' => $group->order, 'id' => $group->id];+ }+ }+ }++ return $return;+ }+public function resetAccountOrder(): void{$sets = [@@ -298,6 +364,15 @@ class AccountRepository implements AccountRepositoryInterfacereturn $query->get(['accounts.*']);}+ #[\Override]+ public function update(Account $account, array $data): Account+ {+ /** @var AccountUpdateService $service */+ $service = app(AccountUpdateService::class);++ return $service->update($account, $data);+ }+public function searchAccount(string $query, array $types, int $page, int $limit): Collection{// search by group, not by user@@ -331,79 +406,4 @@ class AccountRepository implements AccountRepositoryInterfacereturn $dbQuery->get(['accounts.*']);}-- #[\Override]- public function update(Account $account, array $data): Account- {- /** @var AccountUpdateService $service */- $service = app(AccountUpdateService::class);-- return $service->update($account, $data);- }-- #[\Override]- public function getMetaValues(Collection $accounts, array $fields): Collection- {- $query = AccountMeta::whereIn('account_id', $accounts->pluck('id')->toArray());- if (count($fields) > 0) {- $query->whereIn('name', $fields);- }-- return $query->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data']);- }-- #[\Override]- public function getAccountTypes(Collection $accounts): Collection- {- return AccountType::leftJoin('accounts', 'accounts.account_type_id', '=', 'account_types.id')- ->whereIn('accounts.id', $accounts->pluck('id')->toArray())- ->get(['accounts.id', 'account_types.type'])- ;- }-- #[\Override]- public function getLastActivity(Collection $accounts): array- {- return Transaction::whereIn('account_id', $accounts->pluck('id')->toArray())- ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')- ->groupBy('transactions.account_id')- ->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) as date_max')])->toArray() // @phpstan-ignore-line- ;- }-- #[\Override]- public function getObjectGroups(Collection $accounts): array- {- $groupIds = [];- $return = [];- $set = DB::table('object_groupables')->where('object_groupable_type', Account::class)- ->whereIn('object_groupable_id', $accounts->pluck('id')->toArray())->get()- ;-- /** @var \stdClass $row */- foreach ($set as $row) {- $groupIds[] = $row->object_group_id;- }- $groupIds = array_unique($groupIds);- $groups = ObjectGroup::whereIn('id', $groupIds)->get();-- /** @var \stdClass $row */- foreach ($set as $row) {- if (!array_key_exists($row->object_groupable_id, $return)) {- /** @var null|ObjectGroup $group */- $group = $groups->firstWhere('id', '=', $row->object_group_id);- if (null !== $group) {- $return[$row->object_groupable_id] = ['title' => $group->title, 'order' => $group->order, 'id' => $group->id];- }- }- }-- return $return;- }-- #[\Override]- public function getAccountBalances(Account $account): Collection- {- return $account->accountBalances;- }}diff --git a/app/Repositories/UserGroups/Account/AccountRepositoryInterface.php b/app/Repositories/UserGroups/Account/AccountRepositoryInterface.phpindex b10a26f267..17b3fad59b 100644--- a/app/Repositories/UserGroups/Account/AccountRepositoryInterface.php+++ b/app/Repositories/UserGroups/Account/AccountRepositoryInterface.php@@ -37,12 +37,6 @@ interface AccountRepositoryInterface{public function countAccounts(array $types): int;- public function getAccountTypes(Collection $accounts): Collection;-- public function getLastActivity(Collection $accounts): array;-- public function getMetaValues(Collection $accounts, array $fields): Collection;-public function find(int $accountId): ?Account;public function findByAccountNumber(string $number, array $types): ?Account;@@ -51,9 +45,11 @@ interface AccountRepositoryInterfacepublic function findByName(string $name, array $types): ?Account;+ public function getAccountBalances(Account $account): Collection;+public function getAccountCurrency(Account $account): ?TransactionCurrency;- public function getAccountBalances(Account $account): Collection;+ public function getAccountTypes(Collection $accounts): Collection;public function getAccountsById(array $accountIds): Collection;@@ -66,11 +62,15 @@ interface AccountRepositoryInterfacepublic function getActiveAccountsByType(array $types): Collection;+ public function getLastActivity(Collection $accounts): array;+/*** Return meta value for account. Null if not found.*/public function getMetaValue(Account $account, string $field): ?string;+ public function getMetaValues(Collection $accounts, array $fields): Collection;+public function getObjectGroups(Collection $accounts): array;public function getUserGroup(): UserGroup;diff --git a/app/Repositories/UserGroups/Bill/BillRepository.php b/app/Repositories/UserGroups/Bill/BillRepository.phpindex a6d2be535b..a6fc1e71b2 100644--- a/app/Repositories/UserGroups/Bill/BillRepository.php+++ b/app/Repositories/UserGroups/Bill/BillRepository.php@@ -81,12 +81,12 @@ class BillRepository implements BillRepositoryInterface$currencyId = $bill->transaction_currency_id;$return[$currencyId] ??= [- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_name' => $currency->name,'currency_symbol' => $currency->symbol,'currency_code' => $currency->code,'currency_decimal_places' => $currency->decimal_places,- 'native_currency_id' => (string)$default->id,+ 'native_currency_id' => (string) $default->id,'native_currency_name' => $default->name,'native_currency_symbol' => $default->symbol,'native_currency_code' => $default->code,@@ -101,9 +101,9 @@ class BillRepository implements BillRepositoryInterface$sourceTransaction = $transactionJournal->transactions()->where('amount', '<', 0)->first();if (null !== $sourceTransaction) {$amount = $sourceTransaction->amount;- if ((int)$sourceTransaction->foreign_currency_id === $currency->id) {+ if ((int) $sourceTransaction->foreign_currency_id === $currency->id) {// use foreign amount instead!- $amount = (string)$sourceTransaction->foreign_amount;+ $amount = (string) $sourceTransaction->foreign_amount;}// convert to native currency$nativeAmount = $amount;@@ -111,9 +111,9 @@ class BillRepository implements BillRepositoryInterface// get rate and convert.$nativeAmount = $converter->convert($currency, $default, $transactionJournal->date, $amount);}- if ((int)$sourceTransaction->foreign_currency_id === $default->id) {+ if ((int) $sourceTransaction->foreign_currency_id === $default->id) {// ignore conversion, use foreign amount- $nativeAmount = (string)$sourceTransaction->foreign_amount;+ $nativeAmount = (string) $sourceTransaction->foreign_amount;}$return[$currencyId]['sum'] = bcadd($return[$currencyId]['sum'], $amount);$return[$currencyId]['native_sum'] = bcadd($return[$currencyId]['native_sum'], $nativeAmount);@@ -154,12 +154,12 @@ class BillRepository implements BillRepositoryInterface$average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');$nativeAverage = $converter->convert($currency, $default, $start, $average);$return[$currencyId] ??= [- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_name' => $currency->name,'currency_symbol' => $currency->symbol,'currency_code' => $currency->code,'currency_decimal_places' => $currency->decimal_places,- 'native_currency_id' => (string)$default->id,+ 'native_currency_id' => (string) $default->id,'native_currency_name' => $default->name,'native_currency_symbol' => $default->symbol,'native_currency_code' => $default->code,@@ -167,8 +167,8 @@ class BillRepository implements BillRepositoryInterface'sum' => '0','native_sum' => '0',];- $return[$currencyId]['sum'] = bcadd($return[$currencyId]['sum'], bcmul($average, (string)$total));- $return[$currencyId]['native_sum'] = bcadd($return[$currencyId]['native_sum'], bcmul($nativeAverage, (string)$total));+ $return[$currencyId]['sum'] = bcadd($return[$currencyId]['sum'], bcmul($average, (string) $total));+ $return[$currencyId]['native_sum'] = bcadd($return[$currencyId]['native_sum'], bcmul($nativeAverage, (string) $total));}}$converter->summarize();diff --git a/app/Repositories/UserGroups/Budget/OperationsRepository.php b/app/Repositories/UserGroups/Budget/OperationsRepository.phpindex 1b115e1aba..3d4c5f0108 100644--- a/app/Repositories/UserGroups/Budget/OperationsRepository.php+++ b/app/Repositories/UserGroups/Budget/OperationsRepository.php@@ -60,9 +60,9 @@ class OperationsRepository implements OperationsRepositoryInterface$array = [];foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];- $budgetId = (int)$journal['budget_id'];- $budgetName = (string)$journal['budget_name'];+ $currencyId = (int) $journal['currency_id'];+ $budgetId = (int) $journal['budget_id'];+ $budgetName = (string) $journal['budget_name'];// catch "no budget" entries.if (0 === $budgetId) {@@ -88,7 +88,7 @@ class OperationsRepository implements OperationsRepositoryInterface// add journal to array:// only a subset of the fields.- $journalId = (int)$journal['transaction_journal_id'];+ $journalId = (int) $journal['transaction_journal_id'];$final = ['amount' => app('steam')->negative($journal['amount']),'currency_id' => $journal['currency_id'],diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepository.php b/app/Repositories/UserGroups/Currency/CurrencyRepository.phpindex fbdc2b8298..147e6599da 100644--- a/app/Repositories/UserGroups/Currency/CurrencyRepository.php+++ b/app/Repositories/UserGroups/Currency/CurrencyRepository.php@@ -308,22 +308,6 @@ class CurrencyRepository implements CurrencyRepositoryInterfacereturn $currency->code === config('firefly.default_currency', 'EUR');}- public function makeDefault(TransactionCurrency $currency): void- {- $current = app('amount')->getDefaultCurrencyByUserGroup($this->userGroup);- app('log')->debug(sprintf('Enabled + made default currency %s for user #%d', $currency->code, $this->userGroup->id));- $this->userGroup->currencies()->detach($currency->id);- foreach ($this->userGroup->currencies()->get() as $item) {- $this->userGroup->currencies()->updateExistingPivot($item->id, ['group_default' => false]);- }- $this->userGroup->currencies()->syncWithoutDetaching([$currency->id => ['group_default' => true]]);- if ($current->id !== $currency->id) {- Log::debug('Trigger on a different default currency.');- // clear all native amounts through an event.- event(new UserGroupChangedDefaultCurrency($this->userGroup));- }- }-public function searchCurrency(string $search, int $limit): Collection{$query = TransactionCurrency::where('enabled', true);@@ -388,4 +372,20 @@ class CurrencyRepository implements CurrencyRepositoryInterfacereturn $service->update($currency, $data);}++ public function makeDefault(TransactionCurrency $currency): void+ {+ $current = app('amount')->getDefaultCurrencyByUserGroup($this->userGroup);+ app('log')->debug(sprintf('Enabled + made default currency %s for user #%d', $currency->code, $this->userGroup->id));+ $this->userGroup->currencies()->detach($currency->id);+ foreach ($this->userGroup->currencies()->get() as $item) {+ $this->userGroup->currencies()->updateExistingPivot($item->id, ['group_default' => false]);+ }+ $this->userGroup->currencies()->syncWithoutDetaching([$currency->id => ['group_default' => true]]);+ if ($current->id !== $currency->id) {+ Log::debug('Trigger on a different default currency.');+ // clear all native amounts through an event.+ event(new UserGroupChangedDefaultCurrency($this->userGroup));+ }+ }}diff --git a/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php b/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.phpindex 8c0d6621db..a528cddb88 100644--- a/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php+++ b/app/Repositories/UserGroups/ExchangeRate/ExchangeRateRepository.php@@ -39,16 +39,19 @@ class ExchangeRateRepository implements ExchangeRateRepositoryInterface// orderBy('date', 'DESC')->toRawSql();return$this->userGroup->currencyExchangeRates()- ->where(function (Builder $q1) use ($from, $to) {- $q1->where(function (Builder $q) use ($from, $to) {- $q->where('from_currency_id', $from->id)- ->where('to_currency_id', $to->id);- })->orWhere(function (Builder $q) use ($from, $to) {- $q->where('from_currency_id', $to->id)- ->where('to_currency_id', $from->id);- });- })- ->orderBy('date', 'DESC')->get(['currency_exchange_rates.*']);+ ->where(function (Builder $q1) use ($from, $to): void {+ $q1->where(function (Builder $q) use ($from, $to): void {+ $q->where('from_currency_id', $from->id)+ ->where('to_currency_id', $to->id)+ ;+ })->orWhere(function (Builder $q) use ($from, $to): void {+ $q->where('from_currency_id', $to->id)+ ->where('to_currency_id', $from->id)+ ;+ });+ })+ ->orderBy('date', 'DESC')->get(['currency_exchange_rates.*'])+ ;}}diff --git a/app/Rules/Account/IsUniqueAccount.php b/app/Rules/Account/IsUniqueAccount.phpindex bc9bf925ff..5a3fa3db9b 100644--- a/app/Rules/Account/IsUniqueAccount.php+++ b/app/Rules/Account/IsUniqueAccount.php@@ -35,8 +35,14 @@ use Illuminate\Contracts\Validation\ValidationRule;*/class IsUniqueAccount implements ValidationRule, DataAwareRule{+ protected array $data = [];protected \Closure $fail;- protected array $data = [];++ #[\Override]+ public function setData(array $data): void+ {+ $this->data = $data;+ }#[\Override]public function validate(string $attribute, mixed $value, \Closure $fail): void@@ -103,28 +109,6 @@ class IsUniqueAccount implements ValidationRule, DataAwareRulereturn null === $result;}- /**- * TODO duplicate from old validation class.- */- private function validateAccountAnonymously(): bool- {- if (!array_key_exists('user_id', $this->data)) {- $this->fail('No user ID provided.');-- return false;- }-- /** @var User $user */- $user = User::find($this->data['user_id']);- $type = AccountType::find($this->data['account_type_id'])->first();- $value = $this->data['name'];-- /** @var null|Account $result */- $result = $user->accounts()->where('account_type_id', $type->id)->where('name', $value)->first();-- return null === $result;- }-/*** TODO Duplicate from old validation class.*@@ -196,9 +180,25 @@ class IsUniqueAccount implements ValidationRule, DataAwareRulereturn 0 === auth()->user()->accounts()->where('name', $value)->count();}- #[\Override]- public function setData(array $data): void+ /**+ * TODO duplicate from old validation class.+ */+ private function validateAccountAnonymously(): bool{- $this->data = $data;+ if (!array_key_exists('user_id', $this->data)) {+ $this->fail('No user ID provided.');++ return false;+ }++ /** @var User $user */+ $user = User::find($this->data['user_id']);+ $type = AccountType::find($this->data['account_type_id'])->first();+ $value = $this->data['name'];++ /** @var null|Account $result */+ $result = $user->accounts()->where('account_type_id', $type->id)->where('name', $value)->first();++ return null === $result;}}diff --git a/app/Rules/Admin/IsValidDiscordUrl.php b/app/Rules/Admin/IsValidDiscordUrl.phpindex 633efb4671..45603fa93d 100644--- a/app/Rules/Admin/IsValidDiscordUrl.php+++ b/app/Rules/Admin/IsValidDiscordUrl.php@@ -17,7 +17,7 @@ class IsValidDiscordUrl implements ValidationRule*/public function validate(string $attribute, mixed $value, \Closure $fail): void{- $value = (string)$value;+ $value = (string) $value;if ('' === $value) {return;}diff --git a/app/Rules/Admin/IsValidSlackOrDiscordUrl.php b/app/Rules/Admin/IsValidSlackOrDiscordUrl.phpindex b3c8967d5b..936063e9d3 100644--- a/app/Rules/Admin/IsValidSlackOrDiscordUrl.php+++ b/app/Rules/Admin/IsValidSlackOrDiscordUrl.php@@ -17,7 +17,7 @@ class IsValidSlackOrDiscordUrl implements ValidationRule*/public function validate(string $attribute, mixed $value, \Closure $fail): void{- $value = (string)$value;+ $value = (string) $value;if ('' === $value) {return;}diff --git a/app/Rules/Admin/IsValidSlackUrl.php b/app/Rules/Admin/IsValidSlackUrl.phpindex 4851dab73f..938e330c4a 100644--- a/app/Rules/Admin/IsValidSlackUrl.php+++ b/app/Rules/Admin/IsValidSlackUrl.php@@ -17,7 +17,7 @@ class IsValidSlackUrl implements ValidationRule*/public function validate(string $attribute, mixed $value, \Closure $fail): void{- $value = (string)$value;+ $value = (string) $value;if ('' === $value) {return;}diff --git a/app/Rules/BelongsUser.php b/app/Rules/BelongsUser.phpindex 06e250cf63..b223de2165 100644--- a/app/Rules/BelongsUser.php+++ b/app/Rules/BelongsUser.php@@ -49,15 +49,15 @@ class BelongsUser implements ValidationRuleapp('log')->debug(sprintf('Going to validate %s', $attribute));$result = match ($attribute) {- 'piggy_bank_id' => $this->validatePiggyBankId((int)$value),+ 'piggy_bank_id' => $this->validatePiggyBankId((int) $value),'piggy_bank_name' => $this->validatePiggyBankName($value),- 'bill_id' => $this->validateBillId((int)$value),- 'transaction_journal_id' => $this->validateJournalId((int)$value),+ 'bill_id' => $this->validateBillId((int) $value),+ 'transaction_journal_id' => $this->validateJournalId((int) $value),'bill_name' => $this->validateBillName($value),- 'budget_id' => $this->validateBudgetId((int)$value),- 'category_id' => $this->validateCategoryId((int)$value),+ 'budget_id' => $this->validateBudgetId((int) $value),+ 'category_id' => $this->validateCategoryId((int) $value),'budget_name' => $this->validateBudgetName($value),- 'source_id', 'destination_id' => $this->validateAccountId((int)$value),+ 'source_id', 'destination_id' => $this->validateAccountId((int) $value),default => throw new FireflyException(sprintf('Rule BelongsUser cannot handle "%s"', $attribute)),};if (false === $result) {@@ -110,7 +110,7 @@ class BelongsUser implements ValidationRule}$count = 0;foreach ($objects as $object) {- $objectValue = trim((string)$object->{$field}); // @phpstan-ignore-line+ $objectValue = trim((string) $object->{$field}); // @phpstan-ignore-lineapp('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value));if ($objectValue === $value) {++$count;diff --git a/app/Rules/BelongsUserGroup.php b/app/Rules/BelongsUserGroup.phpindex a6e5e2c4a7..dc30295e27 100644--- a/app/Rules/BelongsUserGroup.php+++ b/app/Rules/BelongsUserGroup.php@@ -63,15 +63,15 @@ class BelongsUserGroup implements ValidationRuleapp('log')->debug(sprintf('Group: Going to validate "%s"', $attribute));$result = match ($attribute) {- 'piggy_bank_id' => $this->validatePiggyBankId((int)$value),+ 'piggy_bank_id' => $this->validatePiggyBankId((int) $value),'piggy_bank_name' => $this->validatePiggyBankName($value),- 'bill_id' => $this->validateBillId((int)$value),- 'transaction_journal_id' => $this->validateJournalId((int)$value),+ 'bill_id' => $this->validateBillId((int) $value),+ 'transaction_journal_id' => $this->validateJournalId((int) $value),'bill_name' => $this->validateBillName($value),- 'budget_id' => $this->validateBudgetId((int)$value),- 'category_id' => $this->validateCategoryId((int)$value),+ 'budget_id' => $this->validateBudgetId((int) $value),+ 'category_id' => $this->validateCategoryId((int) $value),'budget_name' => $this->validateBudgetName($value),- 'source_id', 'destination_id' => $this->validateAccountId((int)$value),+ 'source_id', 'destination_id' => $this->validateAccountId((int) $value),default => throw new FireflyException(sprintf('Rule BelongsUser cannot handle "%s"', $attribute)),};if (false === $result) {@@ -124,7 +124,7 @@ class BelongsUserGroup implements ValidationRule}$count = 0;foreach ($objects as $object) {- $objectValue = trim((string)$object->{$field}); // @phpstan-ignore-line+ $objectValue = trim((string) $object->{$field}); // @phpstan-ignore-lineapp('log')->debug(sprintf('Comparing object "%s" with value "%s"', $objectValue, $value));if ($objectValue === $value) {++$count;diff --git a/app/Rules/IsAllowedGroupAction.php b/app/Rules/IsAllowedGroupAction.phpindex d79c9564b1..383edce267 100644--- a/app/Rules/IsAllowedGroupAction.php+++ b/app/Rules/IsAllowedGroupAction.php@@ -28,16 +28,15 @@ use FireflyIII\Enums\UserRoleEnum;use FireflyIII\Models\Account;use FireflyIII\Repositories\UserGroup\UserGroupRepositoryInterface;use FireflyIII\User;-use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Auth\Access\AuthorizationException;+use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Log;class IsAllowedGroupAction implements ValidationRule{+ private array $acceptedRoles;private string $className;private string $methodName;-- private array $acceptedRoles;private UserGroupRepositoryInterface $repository;public function __construct(string $className, string $methodName)@@ -71,7 +70,7 @@ class IsAllowedGroupAction implements ValidationRulebreak;}}- $this->validateUserGroup((int)$value, $fail);+ $this->validateUserGroup((int) $value, $fail);}private function validateUserGroup(int $userGroupId, \Closure $fail): voiddiff --git a/app/Rules/IsAssetAccountId.php b/app/Rules/IsAssetAccountId.phpindex 5c4e715f36..20e2458fae 100644--- a/app/Rules/IsAssetAccountId.php+++ b/app/Rules/IsAssetAccountId.php@@ -37,7 +37,7 @@ class IsAssetAccountId implements ValidationRule*/public function validate(string $attribute, mixed $value, \Closure $fail): void{- $accountId = (int)$value;+ $accountId = (int) $value;/** @var null|Account $account */$account = Account::with('accountType')->find($accountId);diff --git a/app/Rules/IsDateOrTime.php b/app/Rules/IsDateOrTime.phpindex 60ccb3a963..32d0176aad 100644--- a/app/Rules/IsDateOrTime.php+++ b/app/Rules/IsDateOrTime.php@@ -39,7 +39,7 @@ class IsDateOrTime implements ValidationRule*/public function validate(string $attribute, mixed $value, \Closure $fail): void{- $value = (string)$value;+ $value = (string) $value;if ('' === $value) {$fail('validation.date_or_time')->translate();diff --git a/app/Rules/IsFilterValueIn.php b/app/Rules/IsFilterValueIn.phpindex 8601007a68..2e4b92d0d6 100644--- a/app/Rules/IsFilterValueIn.php+++ b/app/Rules/IsFilterValueIn.php@@ -29,7 +29,7 @@ use Illuminate\Contracts\Validation\ValidationRule;class IsFilterValueIn implements ValidationRule{private string $key;- private array $values;+ private array $values;public function __construct(string $key, array $values){diff --git a/app/Rules/IsTransferAccount.php b/app/Rules/IsTransferAccount.phpindex e61b07ee47..8c255d5405 100644--- a/app/Rules/IsTransferAccount.php+++ b/app/Rules/IsTransferAccount.php@@ -45,15 +45,15 @@ class IsTransferAccount implements ValidationRule$validator->setTransactionType(TransactionType::TRANSFER);$validator->setUser(auth()->user());- $validAccount = $validator->validateSource(['name' => (string)$value]);+ $validAccount = $validator->validateSource(['name' => (string) $value]);if (true === $validAccount) {app('log')->debug('Found account based on name. Return true.');// found by name, use repos to return.return;}- $validAccount = $validator->validateSource(['id' => (int)$value]);- app('log')->debug(sprintf('Search by id (%d), result is %s.', (int)$value, var_export($validAccount, true)));+ $validAccount = $validator->validateSource(['id' => (int) $value]);+ app('log')->debug(sprintf('Search by id (%d), result is %s.', (int) $value, var_export($validAccount, true)));if (false === $validAccount) {$fail('validation.not_transfer_account')->translate();diff --git a/app/Rules/IsValidAmount.php b/app/Rules/IsValidAmount.phpindex 598dec8965..c3bfa2f371 100644--- a/app/Rules/IsValidAmount.php+++ b/app/Rules/IsValidAmount.php@@ -17,7 +17,7 @@ class IsValidAmount implements ValidationRule*/public function validate(string $attribute, mixed $value, \Closure $fail): void{- $value = (string)$value;+ $value = (string) $value;// must not be empty:if ($this->emptyString($value)) {diff --git a/app/Rules/IsValidAttachmentModel.php b/app/Rules/IsValidAttachmentModel.phpindex 11dda64a16..dcdec6409f 100644--- a/app/Rules/IsValidAttachmentModel.php+++ b/app/Rules/IsValidAttachmentModel.php@@ -78,14 +78,14 @@ class IsValidAttachmentModel implements ValidationRulereturn;}$result = match ($this->model) {- Account::class => $this->validateAccount((int)$value),- Bill::class => $this->validateBill((int)$value),- Budget::class => $this->validateBudget((int)$value),- Category::class => $this->validateCategory((int)$value),- PiggyBank::class => $this->validatePiggyBank((int)$value),- Tag::class => $this->validateTag((int)$value),- Transaction::class => $this->validateTransaction((int)$value),- TransactionJournal::class => $this->validateJournal((int)$value),+ Account::class => $this->validateAccount((int) $value),+ Bill::class => $this->validateBill((int) $value),+ Budget::class => $this->validateBudget((int) $value),+ Category::class => $this->validateCategory((int) $value),+ PiggyBank::class => $this->validatePiggyBank((int) $value),+ Tag::class => $this->validateTag((int) $value),+ Transaction::class => $this->validateTransaction((int) $value),+ TransactionJournal::class => $this->validateJournal((int) $value),default => false,};diff --git a/app/Rules/IsValidBulkClause.php b/app/Rules/IsValidBulkClause.phpindex 1a79add025..8250c169ac 100644--- a/app/Rules/IsValidBulkClause.php+++ b/app/Rules/IsValidBulkClause.php@@ -38,7 +38,7 @@ class IsValidBulkClause implements ValidationRulepublic function __construct(string $type){$this->rules = config(sprintf('bulk.%s', $type));- $this->error = (string)trans('firefly.belongs_user');+ $this->error = (string) trans('firefly.belongs_user');}public function message(): string@@ -51,7 +51,7 @@ class IsValidBulkClause implements ValidationRule*/public function validate(string $attribute, mixed $value, \Closure $fail): void{- $result = $this->basicValidation((string)$value);+ $result = $this->basicValidation((string) $value);if (false === $result) {$fail($this->error);}@@ -65,14 +65,14 @@ class IsValidBulkClause implements ValidationRuletry {$array = json_decode($value, true, 8, JSON_THROW_ON_ERROR);} catch (\JsonException $e) {- $this->error = (string)trans('validation.json');+ $this->error = (string) trans('validation.json');return false;}$clauses = ['where', 'update'];foreach ($clauses as $clause) {if (!array_key_exists($clause, $array)) {- $this->error = (string)trans(sprintf('validation.missing_%s', $clause));+ $this->error = (string) trans(sprintf('validation.missing_%s', $clause));return false;}@@ -83,7 +83,7 @@ class IsValidBulkClause implements ValidationRule*/foreach ($array[$clause] as $arrayKey => $arrayValue) {if (!array_key_exists($arrayKey, $this->rules[$clause])) {- $this->error = (string)trans(sprintf('validation.invalid_%s_key', $clause));+ $this->error = (string) trans(sprintf('validation.invalid_%s_key', $clause));return false;}diff --git a/app/Rules/IsValidPositiveAmount.php b/app/Rules/IsValidPositiveAmount.phpindex 7a6b559c7f..94a0524737 100644--- a/app/Rules/IsValidPositiveAmount.php+++ b/app/Rules/IsValidPositiveAmount.php@@ -17,7 +17,7 @@ class IsValidPositiveAmount implements ValidationRule*/public function validate(string $attribute, mixed $value, \Closure $fail): void{- $value = (string)$value;+ $value = (string) $value;// must not be empty:if ($this->emptyString($value)) {$fail('validation.filled')->translate();diff --git a/app/Rules/IsValidZeroOrMoreAmount.php b/app/Rules/IsValidZeroOrMoreAmount.phpindex 1d2866d06f..15e1f2ce08 100644--- a/app/Rules/IsValidZeroOrMoreAmount.php+++ b/app/Rules/IsValidZeroOrMoreAmount.php@@ -17,7 +17,7 @@ class IsValidZeroOrMoreAmount implements ValidationRule*/public function validate(string $attribute, mixed $value, \Closure $fail): void{- $value = (string)$value;+ $value = (string) $value;// must not be empty:if ($this->emptyString($value)) {$fail('validation.filled')->translate();diff --git a/app/Rules/LessThanPiggyTarget.php b/app/Rules/LessThanPiggyTarget.phpindex 433d02dd2e..a0fc41c38c 100644--- a/app/Rules/LessThanPiggyTarget.php+++ b/app/Rules/LessThanPiggyTarget.php@@ -36,7 +36,7 @@ class LessThanPiggyTarget implements ValidationRule*/public function message(): string{- return (string)trans('validation.current_target_amount');+ return (string) trans('validation.current_target_amount');}/**diff --git a/app/Rules/UniqueAccountNumber.php b/app/Rules/UniqueAccountNumber.phpindex c641f2c48f..e2e22592ca 100644--- a/app/Rules/UniqueAccountNumber.php+++ b/app/Rules/UniqueAccountNumber.php@@ -65,7 +65,7 @@ class UniqueAccountNumber implements ValidationRule*/public function message(): string{- return (string)trans('validation.unique_account_number_for_user');+ return (string) trans('validation.unique_account_number_for_user');}/**diff --git a/app/Rules/UniqueIban.php b/app/Rules/UniqueIban.phpindex b19e8caaa5..4991d0f37a 100644--- a/app/Rules/UniqueIban.php+++ b/app/Rules/UniqueIban.php@@ -68,13 +68,13 @@ class UniqueIban implements ValidationRule*/public function message(): string{- return (string)trans('validation.unique_iban_for_user');+ return (string) trans('validation.unique_iban_for_user');}public function validate(string $attribute, mixed $value, \Closure $fail): void{if (!$this->passes($attribute, $value)) {- $fail((string)trans('validation.unique_iban_for_user'));+ $fail((string) trans('validation.unique_iban_for_user'));}}diff --git a/app/Rules/ValidRecurrenceRepetitionType.php b/app/Rules/ValidRecurrenceRepetitionType.phpindex 9e0d39a2a7..06a762cc15 100644--- a/app/Rules/ValidRecurrenceRepetitionType.php+++ b/app/Rules/ValidRecurrenceRepetitionType.php@@ -38,7 +38,7 @@ class ValidRecurrenceRepetitionType implements ValidationRule*/public function validate(string $attribute, mixed $value, \Closure $fail): void{- $value = (string)$value;+ $value = (string) $value;if ('daily' === $value) {return;}diff --git a/app/Rules/ValidRecurrenceRepetitionValue.php b/app/Rules/ValidRecurrenceRepetitionValue.phpindex 0d1ff35948..046d7bcf8d 100644--- a/app/Rules/ValidRecurrenceRepetitionValue.php+++ b/app/Rules/ValidRecurrenceRepetitionValue.php@@ -37,7 +37,7 @@ class ValidRecurrenceRepetitionValue implements ValidationRule*/public function validate(string $attribute, mixed $value, \Closure $fail): void{- $value = (string)$value;+ $value = (string) $value;if ('daily' === $value) {return;@@ -68,7 +68,7 @@ class ValidRecurrenceRepetitionValue implements ValidationRuleprivate function validateMonthly(string $value): bool{- $dayOfMonth = (int)substr($value, 8);+ $dayOfMonth = (int) substr($value, 8);return $dayOfMonth > 0 && $dayOfMonth < 32;}@@ -79,8 +79,8 @@ class ValidRecurrenceRepetitionValue implements ValidationRuleif (2 !== count($parameters)) {return false;}- $nthDay = (int)($parameters[0] ?? 0.0);- $dayOfWeek = (int)($parameters[1] ?? 0.0);+ $nthDay = (int) ($parameters[0] ?? 0.0);+ $dayOfWeek = (int) ($parameters[1] ?? 0.0);if ($nthDay < 1 || $nthDay > 5) {return false;}@@ -90,7 +90,7 @@ class ValidRecurrenceRepetitionValue implements ValidationRuleprivate function validateWeekly(string $value): bool{- $dayOfWeek = (int)substr($value, 7);+ $dayOfWeek = (int) substr($value, 7);return $dayOfWeek > 0 && $dayOfWeek < 8;}diff --git a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php b/app/Services/FireflyIIIOrg/Update/UpdateRequest.phpindex 196643dc19..1e46bdc273 100644--- a/app/Services/FireflyIIIOrg/Update/UpdateRequest.php+++ b/app/Services/FireflyIIIOrg/Update/UpdateRequest.php@@ -40,7 +40,7 @@ class UpdateRequest implements UpdateRequestInterfaceapp('log')->debug(sprintf('Now in getUpdateInformation(%s)', $channel));$information = ['level' => 'error',- 'message' => (string)trans('firefly.unknown_error'),+ 'message' => (string) trans('firefly.unknown_error'),];// try to get array from update server:@@ -65,7 +65,7 @@ class UpdateRequest implements UpdateRequestInterface'version' => config('firefly.version'),'date' => today(config('app.timezone'))->startOfDay(),'level' => 'error',- 'message' => (string)trans('firefly.unknown_error'),+ 'message' => (string) trans('firefly.unknown_error'),];$url = config('firefly.update_endpoint');@@ -91,12 +91,12 @@ class UpdateRequest implements UpdateRequestInterfaceif (200 !== $res->getStatusCode()) {app('log')->error(sprintf('Response status from server is %d.', $res->getStatusCode()));- app('log')->error((string)$res->getBody());+ app('log')->error((string) $res->getBody());$return['message'] = sprintf('Error: %d', $res->getStatusCode());return $return;}- $body = (string)$res->getBody();+ $body = (string) $res->getBody();try {$json = json_decode($body, true, 512, JSON_THROW_ON_ERROR);@@ -135,8 +135,8 @@ class UpdateRequest implements UpdateRequestInterfaceprivate function parseResult(array $information): array{app('log')->debug('Now in parseResult()', $information);- $current = (string)config('firefly.version');- $latest = (string)$information['version'];+ $current = (string) config('firefly.version');+ $latest = (string) $information['version'];// strip the 'v' from the version if it's there.if (str_starts_with($latest, 'v')) {@@ -189,13 +189,13 @@ class UpdateRequest implements UpdateRequestInterfaceif ($devDate->lte($information['date'])) {Log::debug(sprintf('This development release is older, release = %s, latest version %s = %s', $devDate->format('Y-m-d'), $latest, $information['date']->format('Y-m-d')));$return['level'] = 'info';- $return['message'] = (string)trans('firefly.update_current_dev_older', ['version' => $current, 'new_version' => $latest]);+ $return['message'] = (string) trans('firefly.update_current_dev_older', ['version' => $current, 'new_version' => $latest]);return $return;}Log::debug(sprintf('This development release is newer, release = %s, latest version %s = %s', $devDate->format('Y-m-d'), $latest, $information['date']->format('Y-m-d')));$return['level'] = 'info';- $return['message'] = (string)trans('firefly.update_current_dev_newer', ['version' => $current, 'new_version' => $latest]);+ $return['message'] = (string) trans('firefly.update_current_dev_newer', ['version' => $current, 'new_version' => $latest]);return $return;}@@ -204,7 +204,7 @@ class UpdateRequest implements UpdateRequestInterface{$return = ['level' => 'info',- 'message' => (string)trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $latest]),+ 'message' => (string) trans('firefly.update_newer_version_alert', ['your_version' => $current, 'new_version' => $latest]),];app('log')->debug('User is running a newer version', $return);@@ -215,7 +215,7 @@ class UpdateRequest implements UpdateRequestInterface{$return = ['level' => 'info',- 'message' => (string)trans('firefly.update_current_version_alert', ['version' => $current]),+ 'message' => (string) trans('firefly.update_current_version_alert', ['version' => $current]),];app('log')->debug('User is the current version.', $return);@@ -225,12 +225,12 @@ class UpdateRequest implements UpdateRequestInterfaceprivate function releasedNewAlpha(string $current, string $latest, Carbon $date): array{app('log')->debug('New release is also a alpha!');- $message = (string)trans(+ $message = (string) trans('firefly.update_new_version_alert',['your_version' => $current,'new_version' => $latest,- 'date' => $date->isoFormat((string)trans('config.month_and_day_js')),+ 'date' => $date->isoFormat((string) trans('config.month_and_day_js')),]);@@ -243,12 +243,12 @@ class UpdateRequest implements UpdateRequestInterfaceprivate function releasedNewBeta(string $current, string $latest, Carbon $date): array{app('log')->debug('New release is also a beta!');- $message = (string)trans(+ $message = (string) trans('firefly.update_new_version_alert',['your_version' => $current,'new_version' => $latest,- 'date' => $date->isoFormat((string)trans('config.month_and_day_js')),+ 'date' => $date->isoFormat((string) trans('config.month_and_day_js')),]);@@ -261,12 +261,12 @@ class UpdateRequest implements UpdateRequestInterfaceprivate function releasedNewVersion(string $current, string $latest, Carbon $date): array{app('log')->debug('New release is old enough.');- $message = (string)trans(+ $message = (string) trans('firefly.update_new_version_alert',['your_version' => $current,'new_version' => $latest,- 'date' => $date->isoFormat((string)trans('config.month_and_day_js')),+ 'date' => $date->isoFormat((string) trans('config.month_and_day_js')),]);app('log')->debug('New release is here!', [$message]);diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.phpindex 71f3965404..f07c1f3e4f 100644--- a/app/Services/Internal/Destroy/AccountDestroyService.php+++ b/app/Services/Internal/Destroy/AccountDestroyService.php@@ -119,7 +119,7 @@ class AccountDestroyService/** @var \stdClass $row */foreach ($collection as $row) {- if ((int)$row->the_count > 1) {+ if ((int) $row->the_count > 1) {$journalId = $row->transaction_journal_id;$journal = $user->transactionJournals()->find($journalId);if (null !== $journal) {@@ -168,7 +168,7 @@ class AccountDestroyService/** @var RecurrenceDestroyService $destroyService */$destroyService = app(RecurrenceDestroyService::class);foreach ($recurrences as $recurrenceId) {- $destroyService->destroyById((int)$recurrenceId);+ $destroyService->destroyById((int) $recurrenceId);}}}diff --git a/app/Services/Internal/Support/AccountServiceTrait.php b/app/Services/Internal/Support/AccountServiceTrait.phpindex b0dc70c13d..868ffd8b27 100644--- a/app/Services/Internal/Support/AccountServiceTrait.php+++ b/app/Services/Internal/Support/AccountServiceTrait.php@@ -144,7 +144,7 @@ trait AccountServiceTrait$data[$field] = $data[$field]->toAtomString();}- $factory->crud($account, $field, (string)$data[$field]);+ $factory->crud($account, $field, (string) $data[$field]);}}}@@ -174,7 +174,7 @@ trait AccountServiceTrait*/public function validOBData(array $data): bool{- $data['opening_balance'] = (string)($data['opening_balance'] ?? '');+ $data['opening_balance'] = (string) ($data['opening_balance'] ?? '');if ('' !== $data['opening_balance'] && 0 === bccomp($data['opening_balance'], '0')) {$data['opening_balance'] = '';}@@ -201,7 +201,7 @@ trait AccountServiceTraitif (is_array($language)) {$language = 'en_US';}- $language = (string)$language;+ $language = (string) $language;$sourceId = null;$sourceName = null;$destId = null;@@ -434,7 +434,7 @@ trait AccountServiceTraitif (is_array($language)) {$language = 'en_US';}- $language = (string)$language;+ $language = (string) $language;// set source and/or destination based on whether the amount is positive or negative.// first, assume the amount is positive and go from there:@@ -623,7 +623,7 @@ trait AccountServiceTraitif (is_array($language)) {$language = 'en_US';}- $language = (string)$language;+ $language = (string) $language;$sourceId = null;$sourceName = null;$destId = null;diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.phpindex f9f113c25f..90091b8477 100644--- a/app/Services/Internal/Support/JournalServiceTrait.php+++ b/app/Services/Internal/Support/JournalServiceTrait.php@@ -75,7 +75,7 @@ trait JournalServiceTrait// if $result (find by name) is NULL, but IBAN is set, any result of the search by NAME can't overrule// this account. In such a case, the name search must be retried with a new name.- if (null !== $nameResult && null === $numberResult && null === $ibanResult && '' !== (string)$data['iban'] && '' !== (string)$nameResult->iban) {+ if (null !== $nameResult && null === $numberResult && null === $ibanResult && '' !== (string) $data['iban'] && '' !== (string) $nameResult->iban) {$data['name'] = sprintf('%s (%s)', $data['name'], $data['iban']);app('log')->debug(sprintf('Search again using the new name, "%s".', $data['name']));$result = $this->findAccountByName(null, $data, $expectedTypes[$transactionType]);@@ -115,7 +115,7 @@ trait JournalServiceTrait{// first attempt, find by ID.if (null !== $data['id']) {- $search = $this->accountRepository->find((int)$data['id']);+ $search = $this->accountRepository->find((int) $data['id']);if (null !== $search && in_array($search->accountType->type, $types, true)) {app('log')->debug(sprintf('Found "account_id" object: #%d, "%s" of type %s (1)', $search->id, $search->name, $search->accountType->type)@@ -176,10 +176,10 @@ trait JournalServiceTraitreturn null;}// find by preferred type.- $source = $this->accountRepository->findByAccountNumber((string)$data['number'], [$types[0]]);+ $source = $this->accountRepository->findByAccountNumber((string) $data['number'], [$types[0]]);// or any expected type.- $source ??= $this->accountRepository->findByAccountNumber((string)$data['number'], $types);+ $source ??= $this->accountRepository->findByAccountNumber((string) $data['number'], $types);if (null !== $source) {app('log')->debug(sprintf('Found account: #%d, %s', $source->id, $source->name));@@ -261,17 +261,17 @@ trait JournalServiceTraitthrow new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', json_encode($data)));}// fix name of account if only IBAN is given:- if ('' === (string)$data['name'] && '' !== (string)$data['iban']) {+ if ('' === (string) $data['name'] && '' !== (string) $data['iban']) {app('log')->debug(sprintf('Account name is now IBAN ("%s")', $data['iban']));$data['name'] = $data['iban'];}// fix name of account if only number is given:- if ('' === (string)$data['name'] && '' !== (string)$data['number']) {+ if ('' === (string) $data['name'] && '' !== (string) $data['number']) {app('log')->debug(sprintf('Account name is now account number ("%s")', $data['number']));$data['name'] = $data['number'];}// if name is still NULL, return NULL.- if ('' === (string)$data['name']) {+ if ('' === (string) $data['name']) {app('log')->debug('Account name is still NULL, return NULL.');return null;@@ -310,7 +310,7 @@ trait JournalServiceTraitprivate function getCashAccount(?Account $account, array $data, array $types): ?Account{// return cash account.- if (null === $account && '' === (string)$data['name']+ if (null === $account && '' === (string) $data['name']&& in_array(AccountType::CASH, $types, true)) {$account = $this->accountRepository->getCashAccount();}@@ -390,7 +390,7 @@ trait JournalServiceTraitprotected function storeNotes(TransactionJournal $journal, ?string $notes): void{- $notes = (string)$notes;+ $notes = (string) $notes;$note = $journal->notes()->first();if ('' !== $notes) {if (null === $note) {@@ -422,7 +422,7 @@ trait JournalServiceTrait}app('log')->debug('Start of loop.');foreach ($tags as $string) {- $string = (string)$string;+ $string = (string) $string;app('log')->debug(sprintf('Now at tag "%s"', $string));if ('' !== $string) {$tag = $this->tagFactory->findOrCreate($string);diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.phpindex 1ca7f701c2..e9ba8437f0 100644--- a/app/Services/Internal/Support/RecurringTransactionTrait.php+++ b/app/Services/Internal/Support/RecurringTransactionTrait.php@@ -127,7 +127,7 @@ trait RecurringTransactionTraitif (!$validator->validateDestination(['id' => $destination->id])) {throw new FireflyException(sprintf('Destination invalid: %s', $validator->destError));}- if (array_key_exists('foreign_amount', $array) && '' === (string)$array['foreign_amount']) {+ if (array_key_exists('foreign_amount', $array) && '' === (string) $array['foreign_amount']) {unset($array['foreign_amount']);}// TODO typeOverrule. The account validator may have a different opinion on the type of the transaction.@@ -139,25 +139,25 @@ trait RecurringTransactionTrait'source_id' => $source->id,'destination_id' => $destination->id,'amount' => $array['amount'],- 'foreign_amount' => array_key_exists('foreign_amount', $array) ? (string)$array['foreign_amount'] : null,+ 'foreign_amount' => array_key_exists('foreign_amount', $array) ? (string) $array['foreign_amount'] : null,'description' => $array['description'],]);$transaction->save();if (array_key_exists('budget_id', $array)) {- $this->setBudget($transaction, (int)$array['budget_id']);+ $this->setBudget($transaction, (int) $array['budget_id']);}if (array_key_exists('bill_id', $array)) {- $this->setBill($transaction, (int)$array['bill_id']);+ $this->setBill($transaction, (int) $array['bill_id']);}if (array_key_exists('category_id', $array)) {- $this->setCategory($transaction, (int)$array['category_id']);+ $this->setCategory($transaction, (int) $array['category_id']);}// same for piggy bankif (array_key_exists('piggy_bank_id', $array)) {- $this->updatePiggyBank($transaction, (int)$array['piggy_bank_id']);+ $this->updatePiggyBank($transaction, (int) $array['piggy_bank_id']);}if (array_key_exists('tags', $array) && is_array($array['tags'])) {@@ -169,8 +169,8 @@ trait RecurringTransactionTraitprotected function findAccount(array $expectedTypes, ?int $accountId, ?string $accountName): Account{$result = null;- $accountId = (int)$accountId;- $accountName = (string)$accountName;+ $accountId = (int) $accountId;+ $accountName = (string) $accountName;/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.phpindex 3026d8acd7..44b0a89d51 100644--- a/app/Services/Internal/Update/AccountUpdateService.php+++ b/app/Services/Internal/Update/AccountUpdateService.php@@ -75,7 +75,7 @@ class AccountUpdateService// find currency, or use default currency instead.if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {- $currency = $this->getCurrency((int)($data['currency_id'] ?? null), (string)($data['currency_code'] ?? null));+ $currency = $this->getCurrency((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null));unset($data['currency_code'], $data['currency_id']);$data['currency_id'] = $currency->id;}@@ -94,7 +94,7 @@ class AccountUpdateService// update note:if (array_key_exists('notes', $data) && null !== $data['notes']) {- $this->updateNote($account, (string)$data['notes']);+ $this->updateNote($account, (string) $data['notes']);}// update preferences if inactive:@@ -120,7 +120,7 @@ class AccountUpdateService$account->active = $data['active'];}if (array_key_exists('iban', $data)) {- $account->iban = app('steam')->filterSpaces((string)$data['iban']);+ $account->iban = app('steam')->filterSpaces((string) $data['iban']);}// set liability, but account must already be a liability.@@ -132,7 +132,7 @@ class AccountUpdateService// set liability, alternative method used in v1 layout:if ($this->isLiability($account) && array_key_exists('account_type_id', $data)) {- $type = AccountType::find((int)$data['account_type_id']);+ $type = AccountType::find((int) $data['account_type_id']);if (null !== $type && in_array($type->type, config('firefly.valid_liabilities'), true)) {$account->account_type_id = $type->id;@@ -305,9 +305,9 @@ class AccountUpdateService$removeAccountId = $account->id;$new = [];foreach ($array as $value) {- if ((int)$value !== $removeAccountId) {+ if ((int) $value !== $removeAccountId) {app('log')->debug(sprintf('Will include: %d', $value));- $new[] = (int)$value;+ $new[] = (int) $value;}}app('log')->debug('Final new array is', $new);diff --git a/app/Services/Internal/Update/BillUpdateService.php b/app/Services/Internal/Update/BillUpdateService.phpindex 25a9054dd7..ddd23ddcd1 100644--- a/app/Services/Internal/Update/BillUpdateService.php+++ b/app/Services/Internal/Update/BillUpdateService.php@@ -54,7 +54,7 @@ class BillUpdateServiceif (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {$factory = app(TransactionCurrencyFactory::class);- $currency = $factory->find((int)($data['currency_id'] ?? null), $data['currency_code'] ?? null) ??+ $currency = $factory->find((int) ($data['currency_id'] ?? null), $data['currency_code'] ?? null) ??app('amount')->getDefaultCurrencyByUserGroup($bill->user->userGroup);// enable the currency if it isn't.@@ -76,14 +76,14 @@ class BillUpdateService];// update note:if (array_key_exists('notes', $data)) {- $this->updateNote($bill, (string)$data['notes']);+ $this->updateNote($bill, (string) $data['notes']);}// update order.if (array_key_exists('order', $data)) {// update the order of the piggy bank:$oldOrder = $bill->order;- $newOrder = (int)($data['order'] ?? $oldOrder);+ $newOrder = (int) ($data['order'] ?? $oldOrder);if ($oldOrder !== $newOrder) {$this->updateOrder($bill, $oldOrder, $newOrder);}@@ -113,7 +113,7 @@ class BillUpdateService}if (array_key_exists('object_group_id', $data)) {// try also with ID:- $objectGroupId = (int)($data['object_group_id'] ?? 0);+ $objectGroupId = (int) ($data['object_group_id'] ?? 0);if (0 !== $objectGroupId) {$objectGroup = $this->findObjectGroupById($objectGroupId);if (null !== $objectGroup) {@@ -135,21 +135,21 @@ class BillUpdateService*/private function updateBillProperties(Bill $bill, array $data): Bill{- if (array_key_exists('name', $data) && '' !== (string)$data['name']) {+ if (array_key_exists('name', $data) && '' !== (string) $data['name']) {$bill->name = $data['name'];}- if (array_key_exists('amount_min', $data) && '' !== (string)$data['amount_min']) {+ if (array_key_exists('amount_min', $data) && '' !== (string) $data['amount_min']) {$bill->amount_min = $data['amount_min'];}- if (array_key_exists('amount_max', $data) && '' !== (string)$data['amount_max']) {+ if (array_key_exists('amount_max', $data) && '' !== (string) $data['amount_max']) {$bill->amount_max = $data['amount_max'];}- if (array_key_exists('date', $data) && '' !== (string)$data['date']) {+ if (array_key_exists('date', $data) && '' !== (string) $data['date']) {$bill->date = $data['date'];$bill->date_tz = $data['date']->format('e');}- if (array_key_exists('repeat_freq', $data) && '' !== (string)$data['repeat_freq']) {+ if (array_key_exists('repeat_freq', $data) && '' !== (string) $data['repeat_freq']) {$bill->repeat_freq = $data['repeat_freq'];}if (array_key_exists('skip', $data)) {diff --git a/app/Services/Internal/Update/CurrencyUpdateService.php b/app/Services/Internal/Update/CurrencyUpdateService.phpindex f116bebf97..1ef57f722c 100644--- a/app/Services/Internal/Update/CurrencyUpdateService.php+++ b/app/Services/Internal/Update/CurrencyUpdateService.php@@ -33,15 +33,15 @@ class CurrencyUpdateService{public function update(TransactionCurrency $currency, array $data): TransactionCurrency{- if (array_key_exists('code', $data) && '' !== (string)$data['code']) {+ if (array_key_exists('code', $data) && '' !== (string) $data['code']) {$currency->code = e($data['code']);}- if (array_key_exists('symbol', $data) && '' !== (string)$data['symbol']) {+ if (array_key_exists('symbol', $data) && '' !== (string) $data['symbol']) {$currency->symbol = e($data['symbol']);}- if (array_key_exists('name', $data) && '' !== (string)$data['name']) {+ if (array_key_exists('name', $data) && '' !== (string) $data['name']) {$currency->name = e($data['name']);}diff --git a/app/Services/Internal/Update/GroupUpdateService.php b/app/Services/Internal/Update/GroupUpdateService.phpindex 49ec44aacd..2d30599e54 100644--- a/app/Services/Internal/Update/GroupUpdateService.php+++ b/app/Services/Internal/Update/GroupUpdateService.php@@ -108,7 +108,7 @@ class GroupUpdateService/** @var string $deletedId */foreach ($result as $deletedId) {/** @var TransactionJournal $journal */- $journal = $transactionGroup->transactionJournals()->find((int)$deletedId);+ $journal = $transactionGroup->transactionJournals()->find((int) $deletedId);/** @var JournalDestroyService $service */$service = app(JournalDestroyService::class);@@ -163,7 +163,7 @@ class GroupUpdateService*/foreach ($transactions as $index => $transaction) {app('log')->debug(sprintf('Now at #%d of %d', $index + 1, count($transactions)), $transaction);- $journalId = (int)($transaction['transaction_journal_id'] ?? 0);+ $journalId = (int) ($transaction['transaction_journal_id'] ?? 0);/** @var null|TransactionJournal $journal */$journal = $transactionGroup->transactionJournals()->find($journalId);diff --git a/app/Services/Internal/Update/RecurrenceUpdateService.php b/app/Services/Internal/Update/RecurrenceUpdateService.phpindex 4686b350c5..90575b664d 100644--- a/app/Services/Internal/Update/RecurrenceUpdateService.php+++ b/app/Services/Internal/Update/RecurrenceUpdateService.php@@ -74,7 +74,7 @@ class RecurrenceUpdateService$recurrence->repetitions = 0;}if (array_key_exists('nr_of_repetitions', $info)) {- if (0 !== (int)$info['nr_of_repetitions']) {+ if (0 !== (int) $info['nr_of_repetitions']) {$recurrence->repeat_until = null;}$recurrence->repetitions = $info['nr_of_repetitions'];@@ -212,7 +212,7 @@ class RecurrenceUpdateService// First, make sure to loop all existing transactions and match them to a counterpart in the submitted transactions array.foreach ($originalTransactions as $i => $originalTransaction) {foreach ($transactions as $ii => $submittedTransaction) {- if (array_key_exists('id', $submittedTransaction) && (int)$originalTransaction['id'] === (int)$submittedTransaction['id']) {+ if (array_key_exists('id', $submittedTransaction) && (int) $originalTransaction['id'] === (int) $submittedTransaction['id']) {app('log')->debug(sprintf('Match original transaction #%d with an entry in the submitted array.', $originalTransaction['id']));$combinations[] = ['original' => $originalTransaction,@@ -241,7 +241,7 @@ class RecurrenceUpdateService// anything left in the original transactions array can be deleted.foreach ($originalTransactions as $original) {app('log')->debug(sprintf('Original transaction #%d is unmatched, delete it!', $original['id']));- $this->deleteTransaction($recurrence, (int)$original['id']);+ $this->deleteTransaction($recurrence, (int) $original['id']);}// anything left is new.$this->createTransactions($recurrence, $transactions);@@ -268,7 +268,7 @@ class RecurrenceUpdateService$foreignCurrency = null;if (array_key_exists('currency_id', $submitted) || array_key_exists('currency_code', $submitted)) {$currency = $currencyFactory->find(- array_key_exists('currency_id', $submitted) ? (int)$submitted['currency_id'] : null,+ array_key_exists('currency_id', $submitted) ? (int) $submitted['currency_id'] : null,array_key_exists('currency_code', $submitted) ? $submitted['currency_code'] : null);}@@ -280,7 +280,7 @@ class RecurrenceUpdateService}if (array_key_exists('foreign_currency_id', $submitted) || array_key_exists('foreign_currency_code', $submitted)) {$foreignCurrency = $currencyFactory->find(- array_key_exists('foreign_currency_id', $submitted) ? (int)$submitted['foreign_currency_id'] : null,+ array_key_exists('foreign_currency_id', $submitted) ? (int) $submitted['foreign_currency_id'] : null,array_key_exists('foreign_currency_code', $submitted) ? $submitted['foreign_currency_code'] : null);}@@ -309,29 +309,29 @@ class RecurrenceUpdateService}// update meta dataif (array_key_exists('budget_id', $submitted)) {- $this->setBudget($transaction, (int)$submitted['budget_id']);+ $this->setBudget($transaction, (int) $submitted['budget_id']);}if (array_key_exists('bill_id', $submitted)) {- $this->setBill($transaction, (int)$submitted['bill_id']);+ $this->setBill($transaction, (int) $submitted['bill_id']);}// reset category if name is set but empty:// can be removed when v1 is retired.- if (array_key_exists('category_name', $submitted) && '' === (string)$submitted['category_name']) {+ if (array_key_exists('category_name', $submitted) && '' === (string) $submitted['category_name']) {app('log')->debug('Category name is submitted but is empty. Set category to be empty.');$submitted['category_name'] = null;$submitted['category_id'] = 0;}if (array_key_exists('category_id', $submitted)) {- app('log')->debug(sprintf('Category ID is submitted, set category to be %d.', (int)$submitted['category_id']));- $this->setCategory($transaction, (int)$submitted['category_id']);+ app('log')->debug(sprintf('Category ID is submitted, set category to be %d.', (int) $submitted['category_id']));+ $this->setCategory($transaction, (int) $submitted['category_id']);}if (array_key_exists('tags', $submitted) && is_array($submitted['tags'])) {$this->updateTags($transaction, $submitted['tags']);}if (array_key_exists('piggy_bank_id', $submitted)) {- $this->updatePiggyBank($transaction, (int)$submitted['piggy_bank_id']);+ $this->updatePiggyBank($transaction, (int) $submitted['piggy_bank_id']);}}diff --git a/app/Services/Webhook/StandardWebhookSender.php b/app/Services/Webhook/StandardWebhookSender.phpindex 76533dbbd4..720d9bea8e 100644--- a/app/Services/Webhook/StandardWebhookSender.php+++ b/app/Services/Webhook/StandardWebhookSender.php@@ -128,7 +128,7 @@ class StandardWebhookSender implements WebhookSenderInterfaceif (method_exists($e, 'hasResponse') && method_exists($e, 'getResponse')) {$attempt->status_code = $e->hasResponse() ? $e->getResponse()->getStatusCode() : 0;app('log')->error(sprintf('The status code of the error response is: %d', $attempt->status_code));- $body = (string)($e->hasResponse() ? $e->getResponse()->getBody() : '');+ $body = (string) ($e->hasResponse() ? $e->getResponse()->getBody() : '');app('log')->error(sprintf('The body of the error response is: %s', $body));}$attempt->logs = $logs;diff --git a/app/Support/Amount.php b/app/Support/Amount.phpindex 28c96c93d7..cff9e3989d 100644--- a/app/Support/Amount.php+++ b/app/Support/Amount.php@@ -45,13 +45,6 @@ class Amountreturn $this->formatFlat($format->symbol, $format->decimal_places, $amount, $coloured);}- public function formatByCurrencyId(int $currencyId, string $amount, ?bool $coloured = null): string- {- $format = TransactionCurrency::find($currencyId);-- return $this->formatFlat($format->symbol, $format->decimal_places, $amount, $coloured);- }-/*** This method will properly format the given number, in color or "black and white",* as a currency, given two things: the currency required and the current locale.@@ -70,7 +63,7 @@ class Amount$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $symbol);$fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $decimalPlaces);$fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $decimalPlaces);- $result = (string)$fmt->format((float)$rounded); // intentional float+ $result = (string) $fmt->format((float) $rounded); // intentional floatif (true === $coloured) {if (1 === bccomp($rounded, '0')) {@@ -86,6 +79,13 @@ class Amountreturn $result;}+ public function formatByCurrencyId(int $currencyId, string $amount, ?bool $coloured = null): string+ {+ $format = TransactionCurrency::find($currencyId);++ return $this->formatFlat($format->symbol, $format->decimal_places, $amount, $coloured);+ }+public function getAllCurrencies(): Collection{return TransactionCurrency::orderBy('code', 'ASC')->get();diff --git a/app/Support/Authentication/RemoteUserGuard.php b/app/Support/Authentication/RemoteUserGuard.phpindex e20faac9b2..61b6d4c88b 100644--- a/app/Support/Authentication/RemoteUserGuard.php+++ b/app/Support/Authentication/RemoteUserGuard.php@@ -86,7 +86,7 @@ class RemoteUserGuard implements Guard$header = config('auth.guard_email');if (null !== $header) {- $emailAddress = (string)(request()->server($header) ?? apache_request_headers()[$header] ?? null);+ $emailAddress = (string) (request()->server($header) ?? apache_request_headers()[$header] ?? null);$preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email');if ('' !== $emailAddress && null === $preference && $emailAddress !== $userID) {diff --git a/app/Support/Binder/TagList.php b/app/Support/Binder/TagList.phpindex d87c8c69b9..3dd4835f54 100644--- a/app/Support/Binder/TagList.php+++ b/app/Support/Binder/TagList.php@@ -68,7 +68,7 @@ class TagList implements BinderInterfacereturn true;}- if (in_array((string)$tag->id, $list, true)) {+ if (in_array((string) $tag->id, $list, true)) {Log::debug(sprintf('TagList: (id) found tag #%d ("%s") in list.', $tag->id, $tag->tag));return true;diff --git a/app/Support/Binder/TagOrId.php b/app/Support/Binder/TagOrId.phpindex e742fb674d..bc511e5018 100644--- a/app/Support/Binder/TagOrId.php+++ b/app/Support/Binder/TagOrId.php@@ -42,7 +42,7 @@ class TagOrId implements BinderInterface$result = $repository->findByTag($value);if (null === $result) {- $result = $repository->find((int)$value);+ $result = $repository->find((int) $value);}if (null !== $result) {return $result;diff --git a/app/Support/Binder/UserGroupAccount.php b/app/Support/Binder/UserGroupAccount.phpindex c395655e87..12d7eff4a2 100644--- a/app/Support/Binder/UserGroupAccount.php+++ b/app/Support/Binder/UserGroupAccount.php@@ -41,7 +41,7 @@ class UserGroupAccount implements BinderInterfaceif (auth()->check()) {/** @var User $user */$user = auth()->user();- $account = Account::where('id', (int)$value)+ $account = Account::where('id', (int) $value)->where('user_group_id', $user->user_group_id)->first();diff --git a/app/Support/Binder/UserGroupBill.php b/app/Support/Binder/UserGroupBill.phpindex bd2489965e..551846d693 100644--- a/app/Support/Binder/UserGroupBill.php+++ b/app/Support/Binder/UserGroupBill.php@@ -41,7 +41,7 @@ class UserGroupBill implements BinderInterfaceif (auth()->check()) {/** @var User $user */$user = auth()->user();- $currency = Bill::where('id', (int)$value)+ $currency = Bill::where('id', (int) $value)->where('user_group_id', $user->user_group_id)->first();diff --git a/app/Support/Binder/UserGroupTransaction.php b/app/Support/Binder/UserGroupTransaction.phpindex fbbf5c1f43..d9131400f3 100644--- a/app/Support/Binder/UserGroupTransaction.php+++ b/app/Support/Binder/UserGroupTransaction.php@@ -38,7 +38,7 @@ class UserGroupTransaction implements BinderInterfaceif (auth()->check()) {/** @var User $user */$user = auth()->user();- $group = TransactionGroup::where('id', (int)$value)+ $group = TransactionGroup::where('id', (int) $value)->where('user_group_id', $user->user_group_id)->first();diff --git a/app/Support/CacheProperties.php b/app/Support/CacheProperties.phpindex dc1619bddf..8a8ba020b7 100644--- a/app/Support/CacheProperties.php+++ b/app/Support/CacheProperties.php@@ -81,7 +81,7 @@ class CacheProperties$content .= json_encode($property, JSON_THROW_ON_ERROR);} catch (\JsonException $e) {// @ignoreException- $content .= hash('sha256', (string)time());+ $content .= hash('sha256', (string) time());}}$this->hash = substr(hash('sha256', $content), 0, 16);diff --git a/app/Support/Chart/Budget/FrontpageChartGenerator.php b/app/Support/Chart/Budget/FrontpageChartGenerator.phpindex 2e09e909a0..5c08cb03d2 100644--- a/app/Support/Chart/Budget/FrontpageChartGenerator.php+++ b/app/Support/Chart/Budget/FrontpageChartGenerator.php@@ -64,9 +64,9 @@ class FrontpageChartGenerator{$budgets = $this->budgetRepository->getActiveBudgets();$data = [- ['label' => (string)trans('firefly.spent_in_budget'), 'entries' => [], 'type' => 'bar'],- ['label' => (string)trans('firefly.left_to_spend'), 'entries' => [], 'type' => 'bar'],- ['label' => (string)trans('firefly.overspent'), 'entries' => [], 'type' => 'bar'],+ ['label' => (string) trans('firefly.spent_in_budget'), 'entries' => [], 'type' => 'bar'],+ ['label' => (string) trans('firefly.left_to_spend'), 'entries' => [], 'type' => 'bar'],+ ['label' => (string) trans('firefly.overspent'), 'entries' => [], 'type' => 'bar'],];// loop al budgets:@@ -194,6 +194,6 @@ class FrontpageChartGenerator$this->opsRepository->setUser($user);$locale = app('steam')->getLocale();- $this->monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);+ $this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);}}diff --git a/app/Support/Chart/Category/FrontpageChartGenerator.php b/app/Support/Chart/Category/FrontpageChartGenerator.phpindex b570dd7552..3951673950 100644--- a/app/Support/Chart/Category/FrontpageChartGenerator.php+++ b/app/Support/Chart/Category/FrontpageChartGenerator.php@@ -102,8 +102,8 @@ class FrontpageChartGenerator$tempData[] = ['name' => $category->name,'sum' => $currency['sum'],- 'sum_float' => round((float)$currency['sum'], $currency['currency_decimal_places']),- 'currency_id' => (int)$currency['currency_id'],+ 'sum_float' => round((float) $currency['sum'], $currency['currency_decimal_places']),+ 'currency_id' => (int) $currency['currency_id'],];}@@ -112,7 +112,7 @@ class FrontpageChartGeneratorprivate function addCurrency(array $currency): void{- $currencyId = (int)$currency['currency_id'];+ $currencyId = (int) $currency['currency_id'];$this->currencies[$currencyId] ??= ['currency_id' => $currencyId,@@ -132,8 +132,8 @@ class FrontpageChartGenerator$tempData[] = ['name' => trans('firefly.no_category'),'sum' => $currency['sum'],- 'sum_float' => round((float)$currency['sum'], $currency['currency_decimal_places'] ?? 2), // intentional float- 'currency_id' => (int)$currency['currency_id'],+ 'sum_float' => round((float) $currency['sum'], $currency['currency_decimal_places'] ?? 2), // intentional float+ 'currency_id' => (int) $currency['currency_id'],];}@@ -151,7 +151,7 @@ class FrontpageChartGeneratorforeach ($this->currencies as $currencyId => $currency) {$key = sprintf('spent-%d', $currencyId);$return[$key] = [- 'label' => sprintf('%s (%s)', (string)trans('firefly.spent'), $currency['currency_name']),+ 'label' => sprintf('%s (%s)', (string) trans('firefly.spent'), $currency['currency_name']),'type' => 'bar','currency_symbol' => $currency['currency_symbol'],'entries' => $names,diff --git a/app/Support/Chart/Category/WholePeriodChartGenerator.php b/app/Support/Chart/Category/WholePeriodChartGenerator.phpindex b64448cd88..1a562aa370 100644--- a/app/Support/Chart/Category/WholePeriodChartGenerator.php+++ b/app/Support/Chart/Category/WholePeriodChartGenerator.php@@ -71,14 +71,14 @@ class WholePeriodChartGenerator$code = $currency['currency_code'];$name = $currency['currency_name'];$chartData[sprintf('spent-in-%s', $code)] = [- 'label' => (string)trans('firefly.box_spent_in_currency', ['currency' => $name]),+ 'label' => (string) trans('firefly.box_spent_in_currency', ['currency' => $name]),'entries' => [],'type' => 'bar','backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red];$chartData[sprintf('earned-in-%s', $code)] = [- 'label' => (string)trans('firefly.box_earned_in_currency', ['currency' => $name]),+ 'label' => (string) trans('firefly.box_earned_in_currency', ['currency' => $name]),'entries' => [],'type' => 'bar','backgroundColor' => 'rgba(0, 141, 76, 0.5)', // greendiff --git a/app/Support/Chart/ChartData.php b/app/Support/Chart/ChartData.phpindex 966f003203..66585c415f 100644--- a/app/Support/Chart/ChartData.php+++ b/app/Support/Chart/ChartData.php@@ -35,15 +35,6 @@ class ChartData$this->series = [];}- public function render(): array- {- if (0 === count($this->series)) {- throw new FireflyException('No series added to chart');- }-- return $this->series;- }-/*** @throws FireflyException*/@@ -64,4 +55,13 @@ class ChartData$this->series[] = $data;}++ public function render(): array+ {+ if (0 === count($this->series)) {+ throw new FireflyException('No series added to chart');+ }++ return $this->series;+ }}diff --git a/app/Support/Cronjobs/AutoBudgetCronjob.php b/app/Support/Cronjobs/AutoBudgetCronjob.phpindex 6ac8d0440a..a2889ddc06 100644--- a/app/Support/Cronjobs/AutoBudgetCronjob.php+++ b/app/Support/Cronjobs/AutoBudgetCronjob.php@@ -37,7 +37,7 @@ class AutoBudgetCronjob extends AbstractCronjob{/** @var Configuration $config */$config = app('fireflyconfig')->get('last_ab_job', 0);- $lastTime = (int)$config->data;+ $lastTime = (int) $config->data;$diff = time() - $lastTime;$diffForHumans = today(config('app.timezone'))->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);if (0 === $lastTime) {@@ -78,7 +78,7 @@ class AutoBudgetCronjob extends AbstractCronjob$this->jobSucceeded = true;$this->message = 'Auto-budget cron job fired successfully.';- app('fireflyconfig')->set('last_ab_job', (int)$this->date->format('U'));+ app('fireflyconfig')->set('last_ab_job', (int) $this->date->format('U'));app('log')->info('Done with auto budget cron job task.');}}diff --git a/app/Support/Cronjobs/BillWarningCronjob.php b/app/Support/Cronjobs/BillWarningCronjob.phpindex 364a144c28..720ca72c6a 100644--- a/app/Support/Cronjobs/BillWarningCronjob.php+++ b/app/Support/Cronjobs/BillWarningCronjob.php@@ -43,7 +43,7 @@ class BillWarningCronjob extends AbstractCronjob/** @var Configuration $config */$config = app('fireflyconfig')->get('last_bw_job', 0);- $lastTime = (int)$config->data;+ $lastTime = (int) $config->data;$diff = time() - $lastTime;$diffForHumans = today(config('app.timezone'))->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);@@ -91,8 +91,8 @@ class BillWarningCronjob extends AbstractCronjob$this->jobSucceeded = true;$this->message = 'Bill warning cron job fired successfully.';- app('fireflyconfig')->set('last_bw_job', (int)$this->date->format('U'));- app('log')->info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int)$this->date->format('U')));+ app('fireflyconfig')->set('last_bw_job', (int) $this->date->format('U'));+ app('log')->info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int) $this->date->format('U')));app('log')->info('Done with bill warning cron job task.');}}diff --git a/app/Support/Cronjobs/ExchangeRatesCronjob.php b/app/Support/Cronjobs/ExchangeRatesCronjob.phpindex 2572b8ba1e..fd2c90a473 100644--- a/app/Support/Cronjobs/ExchangeRatesCronjob.php+++ b/app/Support/Cronjobs/ExchangeRatesCronjob.php@@ -37,7 +37,7 @@ class ExchangeRatesCronjob extends AbstractCronjob{/** @var Configuration $config */$config = app('fireflyconfig')->get('last_cer_job', 0);- $lastTime = (int)$config->data;+ $lastTime = (int) $config->data;$diff = time() - $lastTime;$diffForHumans = today(config('app.timezone'))->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);if (0 === $lastTime) {@@ -79,7 +79,7 @@ class ExchangeRatesCronjob extends AbstractCronjob$this->jobSucceeded = true;$this->message = 'Exchange rates cron job fired successfully.';- app('fireflyconfig')->set('last_cer_job', (int)$this->date->format('U'));+ app('fireflyconfig')->set('last_cer_job', (int) $this->date->format('U'));app('log')->info('Done with exchange rates job task.');}}diff --git a/app/Support/Cronjobs/RecurringCronjob.php b/app/Support/Cronjobs/RecurringCronjob.phpindex 3b78a941de..2379b937c2 100644--- a/app/Support/Cronjobs/RecurringCronjob.php+++ b/app/Support/Cronjobs/RecurringCronjob.php@@ -43,7 +43,7 @@ class RecurringCronjob extends AbstractCronjob/** @var Configuration $config */$config = app('fireflyconfig')->get('last_rt_job', 0);- $lastTime = (int)$config->data;+ $lastTime = (int) $config->data;$diff = time() - $lastTime;$diffForHumans = today(config('app.timezone'))->diffForHumans(Carbon::createFromTimestamp($lastTime), null, true);@@ -88,8 +88,8 @@ class RecurringCronjob extends AbstractCronjob$this->jobSucceeded = true;$this->message = 'Recurring transactions cron job fired successfully.';- app('fireflyconfig')->set('last_rt_job', (int)$this->date->format('U'));- app('log')->info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int)$this->date->format('U')));+ app('fireflyconfig')->set('last_rt_job', (int) $this->date->format('U'));+ app('log')->info(sprintf('Marked the last time this job has run as "%s" (%d)', $this->date->format('Y-m-d H:i:s'), (int) $this->date->format('U')));app('log')->info('Done with recurring cron job task.');}}diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.phpindex 094ca4b684..e44549dbd7 100644--- a/app/Support/FireflyConfig.php+++ b/app/Support/FireflyConfig.php@@ -104,19 +104,6 @@ class FireflyConfigreturn $this->set($name, $default);}- public function setEncrypted(string $name, mixed $value): Configuration- {- try {- $encrypted = encrypt($value);- } catch (EncryptException $e) {- Log::error(sprintf('Could not encrypt configuration value "%s": %s', $name, $e->getMessage()));-- throw new FireflyException(sprintf('Could not encrypt configuration value "%s". Cowardly refuse to continue.', $name));- }-- return $this->set($name, $encrypted);- }-public function set(string $name, mixed $value): Configuration{try {@@ -170,4 +157,17 @@ class FireflyConfig{return $this->set($name, $value);}++ public function setEncrypted(string $name, mixed $value): Configuration+ {+ try {+ $encrypted = encrypt($value);+ } catch (EncryptException $e) {+ Log::error(sprintf('Could not encrypt configuration value "%s": %s', $name, $e->getMessage()));++ throw new FireflyException(sprintf('Could not encrypt configuration value "%s". Cowardly refuse to continue.', $name));+ }++ return $this->set($name, $encrypted);+ }}diff --git a/app/Support/Form/AccountForm.php b/app/Support/Form/AccountForm.phpindex a0df5ef405..912861010d 100644--- a/app/Support/Form/AccountForm.php+++ b/app/Support/Form/AccountForm.php@@ -51,8 +51,8 @@ class AccountForm$repository = $this->getAccountRepository();$grouped = $this->getAccountsGrouped($types, $repository);$cash = $repository->getCashAccount();- $key = (string)trans('firefly.cash_account_type');- $grouped[$key][$cash->id] = sprintf('(%s)', (string)trans('firefly.cash'));+ $key = (string) trans('firefly.cash_account_type');+ $grouped[$key][$cash->id] = sprintf('(%s)', (string) trans('firefly.cash'));return $this->select($name, $grouped, $value, $options);}@@ -68,7 +68,7 @@ class AccountForm/** @var Account $account */foreach ($accountList as $account) {- $role = (string)$repository->getMetaValue($account, 'account_role');+ $role = (string) $repository->getMetaValue($account, 'account_role');if (in_array($account->accountType->type, $liabilityTypes, true)) {$role = sprintf('l_%s', $account->accountType->type);}@@ -81,7 +81,7 @@ class AccountForm$role = 'revenue_account';}}- $key = (string)trans(sprintf('firefly.opt_group_%s', $role));+ $key = (string) trans(sprintf('firefly.opt_group_%s', $role));$grouped[$key][$account->id] = $account->name;}@@ -98,8 +98,8 @@ class AccountForm$grouped = $this->getAccountsGrouped($types, $repository);$cash = $repository->getCashAccount();- $key = (string)trans('firefly.cash_account_type');- $grouped[$key][$cash->id] = sprintf('(%s)', (string)trans('firefly.cash'));+ $key = (string) trans('firefly.cash_account_type');+ $grouped[$key][$cash->id] = sprintf('(%s)', (string) trans('firefly.cash'));return $this->select($name, $grouped, $value, $options);}diff --git a/app/Support/Form/CurrencyForm.php b/app/Support/Form/CurrencyForm.phpindex 16cc72b0d8..7115f25fd3 100644--- a/app/Support/Form/CurrencyForm.php+++ b/app/Support/Form/CurrencyForm.php@@ -69,7 +69,7 @@ class CurrencyForm$preFilled = [];}$key = 'amount_currency_id_'.$name;- $sentCurrencyId = array_key_exists($key, $preFilled) ? (int)$preFilled[$key] : $defaultCurrency->id;+ $sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $defaultCurrency->id;app('log')->debug(sprintf('Sent currency ID is %d', $sentCurrencyId));@@ -138,7 +138,7 @@ class CurrencyForm$preFilled = [];}$key = 'amount_currency_id_'.$name;- $sentCurrencyId = array_key_exists($key, $preFilled) ? (int)$preFilled[$key] : $defaultCurrency->id;+ $sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $defaultCurrency->id;app('log')->debug(sprintf('Sent currency ID is %d', $sentCurrencyId));@@ -204,7 +204,7 @@ class CurrencyForm// get all currencies:$list = $currencyRepos->get();$array = [- 0 => (string)trans('firefly.no_currency'),+ 0 => (string) trans('firefly.no_currency'),];/** @var TransactionCurrency $currency */diff --git a/app/Support/Form/FormSupport.php b/app/Support/Form/FormSupport.phpindex 4ba51bb046..5336fb95b3 100644--- a/app/Support/Form/FormSupport.php+++ b/app/Support/Form/FormSupport.php@@ -34,43 +34,43 @@ use Illuminate\Support\MessageBag;*/trait FormSupport{- /**- * @param mixed $selected- */- public function select(string $name, ?array $list = null, $selected = null, ?array $options = null): string+ public function multiSelect(string $name, ?array $list = null, $selected = null, ?array $options = null): string{$list ??= [];$label = $this->label($name, $options);$options = $this->expandOptionArray($name, $label, $options);$classes = $this->getHolderClasses($name);$selected = $this->fillFieldValue($name, $selected);+unset($options['autocomplete'], $options['placeholder']);try {- $html = view('form.select', compact('classes', 'name', 'label', 'selected', 'options', 'list'))->render();+ $html = view('form.multi-select', compact('classes', 'name', 'label', 'selected', 'options', 'list'))->render();} catch (\Throwable $e) {- app('log')->debug(sprintf('Could not render select(): %s', $e->getMessage()));- $html = 'Could not render select.';+ app('log')->debug(sprintf('Could not render multi-select(): %s', $e->getMessage()));+ $html = 'Could not render multi-select.';}return $html;}- public function multiSelect(string $name, ?array $list = null, $selected = null, ?array $options = null): string+ /**+ * @param mixed $selected+ */+ public function select(string $name, ?array $list = null, $selected = null, ?array $options = null): string{$list ??= [];$label = $this->label($name, $options);$options = $this->expandOptionArray($name, $label, $options);$classes = $this->getHolderClasses($name);$selected = $this->fillFieldValue($name, $selected);-unset($options['autocomplete'], $options['placeholder']);try {- $html = view('form.multi-select', compact('classes', 'name', 'label', 'selected', 'options', 'list'))->render();+ $html = view('form.select', compact('classes', 'name', 'label', 'selected', 'options', 'list'))->render();} catch (\Throwable $e) {- app('log')->debug(sprintf('Could not render multi-select(): %s', $e->getMessage()));- $html = 'Could not render multi-select.';+ app('log')->debug(sprintf('Could not render select(): %s', $e->getMessage()));+ $html = 'Could not render select.';}return $html;@@ -84,7 +84,7 @@ trait FormSupport}$name = str_replace('[]', '', $name);- return (string)trans('form.'.$name);+ return (string) trans('form.'.$name);}/**diff --git a/app/Support/Form/PiggyBankForm.php b/app/Support/Form/PiggyBankForm.phpindex 0818d96157..78919b30bf 100644--- a/app/Support/Form/PiggyBankForm.php+++ b/app/Support/Form/PiggyBankForm.php@@ -47,7 +47,7 @@ class PiggyBankForm/** @var PiggyBankRepositoryInterface $repository */$repository = app(PiggyBankRepositoryInterface::class);$piggyBanks = $repository->getPiggyBanksWithAmount();- $title = (string)trans('firefly.default_group_title_name');+ $title = (string) trans('firefly.default_group_title_name');$array = [];$subList = [0 => [@@ -55,7 +55,7 @@ class PiggyBankForm'title' => $title,],'piggies' => [- (string)trans('firefly.none_in_select_list'),+ (string) trans('firefly.none_in_select_list'),],],];diff --git a/app/Support/Form/RuleForm.php b/app/Support/Form/RuleForm.phpindex 9566f0301f..6baee553be 100644--- a/app/Support/Form/RuleForm.php+++ b/app/Support/Form/RuleForm.php@@ -66,12 +66,12 @@ class RuleForm// get all currencies:$list = $groupRepos->get();$array = [- 0 => (string)trans('firefly.none_in_select_list'),+ 0 => (string) trans('firefly.none_in_select_list'),];/** @var RuleGroup $group */foreach ($list as $group) {- if (array_key_exists('hidden', $options) && (int)$options['hidden'] !== $group->id) {+ if (array_key_exists('hidden', $options) && (int) $options['hidden'] !== $group->id) {$array[$group->id] = $group->title;}}diff --git a/app/Support/Http/Api/AccountBalanceGrouped.php b/app/Support/Http/Api/AccountBalanceGrouped.phpindex 8d59995b2f..b1c97d0883 100644--- a/app/Support/Http/Api/AccountBalanceGrouped.php+++ b/app/Support/Http/Api/AccountBalanceGrouped.php@@ -38,6 +38,7 @@ class AccountBalanceGrouped{private array $accountIds;private string $carbonFormat;+ private ExchangeRateConverter $converter;private array $currencies = [];private array $data = [];private TransactionCurrency $default;@@ -45,7 +46,6 @@ class AccountBalanceGroupedprivate array $journals = [];private string $preferredRange;private Carbon $start;- private ExchangeRateConverter $converter;public function __construct(){@@ -139,51 +139,6 @@ class AccountBalanceGrouped$converter->summarize();}- public function setAccounts(Collection $accounts): void- {- $this->accountIds = $accounts->pluck('id')->toArray();- }-- public function setDefault(TransactionCurrency $default): void- {- $this->default = $default;- $defaultCurrencyId = $default->id;- $this->currencies = [$default->id => $default]; // currency cache- $this->data[$defaultCurrencyId] = [- 'currency_id' => (string) $defaultCurrencyId,- 'currency_symbol' => $default->symbol,- 'currency_code' => $default->code,- 'currency_name' => $default->name,- 'currency_decimal_places' => $default->decimal_places,- 'native_currency_id' => (string) $defaultCurrencyId,- 'native_currency_symbol' => $default->symbol,- 'native_currency_code' => $default->code,- 'native_currency_name' => $default->name,- 'native_currency_decimal_places' => $default->decimal_places,- ];- }-- public function setEnd(Carbon $end): void- {- $this->end = $end;- }-- public function setJournals(array $journals): void- {- $this->journals = $journals;- }-- public function setPreferredRange(string $preferredRange): void- {- $this->preferredRange = $preferredRange;- $this->carbonFormat = app('navigation')->preferredCarbonFormatByPeriod($preferredRange);- }-- public function setStart(Carbon $start): void- {- $this->start = $start;- }-private function processJournal(array $journal): void{// format the date according to the period@@ -292,4 +247,49 @@ class AccountBalanceGroupedreturn $rate;}++ public function setAccounts(Collection $accounts): void+ {+ $this->accountIds = $accounts->pluck('id')->toArray();+ }++ public function setDefault(TransactionCurrency $default): void+ {+ $this->default = $default;+ $defaultCurrencyId = $default->id;+ $this->currencies = [$default->id => $default]; // currency cache+ $this->data[$defaultCurrencyId] = [+ 'currency_id' => (string) $defaultCurrencyId,+ 'currency_symbol' => $default->symbol,+ 'currency_code' => $default->code,+ 'currency_name' => $default->name,+ 'currency_decimal_places' => $default->decimal_places,+ 'native_currency_id' => (string) $defaultCurrencyId,+ 'native_currency_symbol' => $default->symbol,+ 'native_currency_code' => $default->code,+ 'native_currency_name' => $default->name,+ 'native_currency_decimal_places' => $default->decimal_places,+ ];+ }++ public function setEnd(Carbon $end): void+ {+ $this->end = $end;+ }++ public function setJournals(array $journals): void+ {+ $this->journals = $journals;+ }++ public function setPreferredRange(string $preferredRange): void+ {+ $this->preferredRange = $preferredRange;+ $this->carbonFormat = app('navigation')->preferredCarbonFormatByPeriod($preferredRange);+ }++ public function setStart(Carbon $start): void+ {+ $this->start = $start;+ }}diff --git a/app/Support/Http/Api/AccountFilter.php b/app/Support/Http/Api/AccountFilter.phpindex cb8e510b1f..75c69eb13f 100644--- a/app/Support/Http/Api/AccountFilter.php+++ b/app/Support/Http/Api/AccountFilter.php@@ -32,57 +32,58 @@ use FireflyIII\Models\AccountType;*/trait AccountFilter{- protected array $types = [- 'all' => [- AccountTypeEnum::DEFAULT->value,- AccountType::CASH,- AccountType::ASSET,- AccountType::EXPENSE,- AccountType::REVENUE,- AccountType::INITIAL_BALANCE,- AccountType::BENEFICIARY,- AccountType::IMPORT,- AccountType::RECONCILIATION,- AccountType::LOAN,- AccountType::DEBT,- AccountType::MORTGAGE,- ],- 'asset' => [AccountType::DEFAULT, AccountType::ASSET],- 'cash' => [AccountType::CASH],- 'expense' => [AccountType::EXPENSE, AccountType::BENEFICIARY],- 'revenue' => [AccountType::REVENUE],- 'special' => [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],- 'hidden' => [AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],- 'liability' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],- 'liabilities' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],- AccountType::DEFAULT => [AccountType::DEFAULT],- AccountType::CASH => [AccountType::CASH],- AccountType::ASSET => [AccountType::ASSET],- AccountType::EXPENSE => [AccountType::EXPENSE],- AccountType::REVENUE => [AccountType::REVENUE],- AccountType::INITIAL_BALANCE => [AccountType::INITIAL_BALANCE],- AccountType::BENEFICIARY => [AccountType::BENEFICIARY],- AccountType::IMPORT => [AccountType::IMPORT],- AccountType::RECONCILIATION => [AccountType::RECONCILIATION],- AccountType::LOAN => [AccountType::LOAN],- AccountType::MORTGAGE => [AccountType::MORTGAGE],- AccountType::DEBT => [AccountType::DEBT],- AccountType::CREDITCARD => [AccountType::CREDITCARD],- 'default account' => [AccountType::DEFAULT],- 'cash account' => [AccountType::CASH],- 'asset account' => [AccountType::ASSET],- 'expense account' => [AccountType::EXPENSE],- 'revenue account' => [AccountType::REVENUE],- 'initial balance account' => [AccountType::INITIAL_BALANCE],- 'reconciliation' => [AccountType::RECONCILIATION],- 'loan' => [AccountType::LOAN],- 'mortgage' => [AccountType::MORTGAGE],- 'debt' => [AccountType::DEBT],- 'credit card' => [AccountType::CREDITCARD],- 'credit-card' => [AccountType::CREDITCARD],- 'creditcard' => [AccountType::CREDITCARD],- 'cc' => [AccountType::CREDITCARD],- ];+ protected array $types+ = [+ 'all' => [+ AccountTypeEnum::DEFAULT->value,+ AccountType::CASH,+ AccountType::ASSET,+ AccountType::EXPENSE,+ AccountType::REVENUE,+ AccountType::INITIAL_BALANCE,+ AccountType::BENEFICIARY,+ AccountType::IMPORT,+ AccountType::RECONCILIATION,+ AccountType::LOAN,+ AccountType::DEBT,+ AccountType::MORTGAGE,+ ],+ 'asset' => [AccountType::DEFAULT, AccountType::ASSET],+ 'cash' => [AccountType::CASH],+ 'expense' => [AccountType::EXPENSE, AccountType::BENEFICIARY],+ 'revenue' => [AccountType::REVENUE],+ 'special' => [AccountType::CASH, AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],+ 'hidden' => [AccountType::INITIAL_BALANCE, AccountType::IMPORT, AccountType::RECONCILIATION],+ 'liability' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],+ 'liabilities' => [AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD],+ AccountType::DEFAULT => [AccountType::DEFAULT],+ AccountType::CASH => [AccountType::CASH],+ AccountType::ASSET => [AccountType::ASSET],+ AccountType::EXPENSE => [AccountType::EXPENSE],+ AccountType::REVENUE => [AccountType::REVENUE],+ AccountType::INITIAL_BALANCE => [AccountType::INITIAL_BALANCE],+ AccountType::BENEFICIARY => [AccountType::BENEFICIARY],+ AccountType::IMPORT => [AccountType::IMPORT],+ AccountType::RECONCILIATION => [AccountType::RECONCILIATION],+ AccountType::LOAN => [AccountType::LOAN],+ AccountType::MORTGAGE => [AccountType::MORTGAGE],+ AccountType::DEBT => [AccountType::DEBT],+ AccountType::CREDITCARD => [AccountType::CREDITCARD],+ 'default account' => [AccountType::DEFAULT],+ 'cash account' => [AccountType::CASH],+ 'asset account' => [AccountType::ASSET],+ 'expense account' => [AccountType::EXPENSE],+ 'revenue account' => [AccountType::REVENUE],+ 'initial balance account' => [AccountType::INITIAL_BALANCE],+ 'reconciliation' => [AccountType::RECONCILIATION],+ 'loan' => [AccountType::LOAN],+ 'mortgage' => [AccountType::MORTGAGE],+ 'debt' => [AccountType::DEBT],+ 'credit card' => [AccountType::CREDITCARD],+ 'credit-card' => [AccountType::CREDITCARD],+ 'creditcard' => [AccountType::CREDITCARD],+ 'cc' => [AccountType::CREDITCARD],+ ];/*** All the available types.diff --git a/app/Support/Http/Api/CleansChartData.php b/app/Support/Http/Api/CleansChartData.phpindex b4f1bb2bfe..c3938bf413 100644--- a/app/Support/Http/Api/CleansChartData.php+++ b/app/Support/Http/Api/CleansChartData.php@@ -48,10 +48,10 @@ trait CleansChartData*/foreach ($data as $index => $array) {if (array_key_exists('currency_id', $array)) {- $array['currency_id'] = (string)$array['currency_id'];+ $array['currency_id'] = (string) $array['currency_id'];}if (array_key_exists('native_currency_id', $array)) {- $array['native_currency_id'] = (string)$array['native_currency_id'];+ $array['native_currency_id'] = (string) $array['native_currency_id'];}if (!array_key_exists('start', $array)) {throw new FireflyException(sprintf('Data-set "%s" is missing the "start"-variable.', $index));diff --git a/app/Support/Http/Api/ConvertsExchangeRates.php b/app/Support/Http/Api/ConvertsExchangeRates.phpindex 465de66dc8..cd0141171b 100644--- a/app/Support/Http/Api/ConvertsExchangeRates.php+++ b/app/Support/Http/Api/ConvertsExchangeRates.php@@ -56,9 +56,9 @@ trait ConvertsExchangeRates/** @var TransactionCurrency $native */$native = app('amount')->getDefaultCurrency();- $currency = $this->getCurrency((int)$set['currency_id']);+ $currency = $this->getCurrency((int) $set['currency_id']);if ($native->id === $currency->id) {- $set['native_currency_id'] = (string)$currency->id;+ $set['native_currency_id'] = (string) $currency->id;$set['native_currency_code'] = $currency->code;$set['native_currency_symbol'] = $currency->symbol;$set['native_currency_decimal_places'] = $currency->decimal_places;@@ -69,8 +69,8 @@ trait ConvertsExchangeRates$carbon = Carbon::createFromFormat(\DateTimeInterface::ATOM, $date);$rate = $this->getRate($currency, $native, $carbon);$rate = '0' === $rate ? '1' : $rate;- app('log')->debug(sprintf('bcmul("%s", "%s")', (string)$entry, $rate));- $set['entries'][$date] = (float)bcmul((string)$entry, $rate);+ app('log')->debug(sprintf('bcmul("%s", "%s")', (string) $entry, $rate));+ $set['entries'][$date] = (float) bcmul((string) $entry, $rate);}return $set;@@ -128,12 +128,12 @@ trait ConvertsExchangeRates/** @var array $entry */foreach ($entries as $entry) {- $currency = $this->getCurrency((int)$entry['id']);+ $currency = $this->getCurrency((int) $entry['id']);if ($currency->id !== $native->id) {$amount = $this->convertAmount($entry['sum'], $currency, $native);$entry['converted'] = true;$entry['native_sum'] = $amount;- $entry['native_currency_id'] = (string)$native->id;+ $entry['native_currency_id'] = (string) $native->id;$entry['native_currency_name'] = $native->name;$entry['native_currency_symbol'] = $native->symbol;$entry['native_currency_code'] = $native->code;@@ -142,7 +142,7 @@ trait ConvertsExchangeRatesif ($currency->id === $native->id) {$entry['converted'] = false;$entry['native_sum'] = $entry['sum'];- $entry['native_currency_id'] = (string)$native->id;+ $entry['native_currency_id'] = (string) $native->id;$entry['native_currency_name'] = $native->name;$entry['native_currency_symbol'] = $native->symbol;$entry['native_currency_code'] = $native->code;diff --git a/app/Support/Http/Api/ExchangeRateConverter.php b/app/Support/Http/Api/ExchangeRateConverter.phpindex 683e03013c..b63f0acad3 100644--- a/app/Support/Http/Api/ExchangeRateConverter.php+++ b/app/Support/Http/Api/ExchangeRateConverter.php@@ -39,21 +39,11 @@ class ExchangeRateConverter{// use ConvertsExchangeRates;private array $fallback = [];+ private bool $ignoreSettings = false;private bool $isPrepared = false;private bool $noPreparedRates = false;private array $prepared = [];private int $queryCount = 0;- private bool $ignoreSettings = false;-- public function setIgnoreSettings(bool $ignoreSettings): void- {- $this->ignoreSettings = $ignoreSettings;- }-- public function enabled(): bool- {- return false !== config('cer.enabled') || true === $this->ignoreSettings;- }/*** @throws FireflyException@@ -70,6 +60,11 @@ class ExchangeRateConverterreturn bcmul($amount, $rate);}+ public function enabled(): bool+ {+ return false !== config('cer.enabled') || true === $this->ignoreSettings;+ }+/*** @throws FireflyException*/@@ -138,6 +133,11 @@ class ExchangeRateConverterreturn $rate;}+ private function getCacheKey(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): string+ {+ return sprintf('cer-%d-%d-%s', $from->id, $to->id, $date->format('Y-m-d'));+ }+private function getFromDB(int $from, int $to, string $date): ?string{if ($from === $to) {@@ -338,6 +338,11 @@ class ExchangeRateConverterLog::debug(sprintf('Fallback rate %s > %s = %s', $to->code, $from->code, bcdiv('1', $fallback)));}+ public function setIgnoreSettings(bool $ignoreSettings): void+ {+ $this->ignoreSettings = $ignoreSettings;+ }+public function summarize(): void{if (false === $this->enabled()) {@@ -345,9 +350,4 @@ class ExchangeRateConverter}Log::debug(sprintf('ExchangeRateConverter ran %d queries.', $this->queryCount));}-- private function getCacheKey(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): string- {- return sprintf('cer-%d-%d-%s', $from->id, $to->id, $date->format('Y-m-d'));- }}diff --git a/app/Support/Http/Api/ParsesQueryFilters.php b/app/Support/Http/Api/ParsesQueryFilters.phpindex d59e0fd6a6..a3252eebee 100644--- a/app/Support/Http/Api/ParsesQueryFilters.php+++ b/app/Support/Http/Api/ParsesQueryFilters.php@@ -31,6 +31,13 @@ use LaravelJsonApi\Core\Query\QueryParameters;trait ParsesQueryFilters{+ private function arrayOfStrings(QueryParameters $parameters, string $field): array+ {+ $array = $parameters->filter()?->value($field, []) ?? [];++ return is_string($array) ? [$array] : $array;+ }+private function dateOrToday(QueryParameters $parameters, string $field): Carbon{$date = today();@@ -51,25 +58,18 @@ trait ParsesQueryFiltersreturn $date;}- private function arrayOfStrings(QueryParameters $parameters, string $field): array- {- $array = $parameters->filter()?->value($field, []) ?? [];-- return is_string($array) ? [$array] : $array;- }-private function integerFromQueryParams(QueryParameters $parameters, string $field, int $default): int{return (int) ($parameters->page()[$field] ?? $default);}- private function stringFromQueryParams(QueryParameters $parameters, string $field, string $default): string+ private function stringFromFilterParams(QueryParameters $parameters, string $field, string $default): string{- return (string) ($parameters->page()[$field] ?? $default);+ return (string) $parameters->filter()?->value($field, $default) ?? $default;}- private function stringFromFilterParams(QueryParameters $parameters, string $field, string $default): string+ private function stringFromQueryParams(QueryParameters $parameters, string $field, string $default): string{- return (string)$parameters->filter()?->value($field, $default) ?? $default;+ return (string) ($parameters->page()[$field] ?? $default);}}diff --git a/app/Support/Http/Api/SummaryBalanceGrouped.php b/app/Support/Http/Api/SummaryBalanceGrouped.phpindex ce8e8a1ce6..f415075e73 100644--- a/app/Support/Http/Api/SummaryBalanceGrouped.php+++ b/app/Support/Http/Api/SummaryBalanceGrouped.php@@ -59,7 +59,7 @@ class SummaryBalanceGrouped$return[] = ['key' => sprintf('%s-in-native', $title),'value' => $this->amounts[$key]['native'] ?? '0',- 'currency_id' => (string)$this->default->id,+ 'currency_id' => (string) $this->default->id,'currency_code' => $this->default->code,'currency_symbol' => $this->default->symbol,'currency_decimal_places' => $this->default->decimal_places,@@ -72,7 +72,7 @@ class SummaryBalanceGrouped// skip native entries.continue;}- $currencyId = (int)$currencyId;+ $currencyId = (int) $currencyId;$currency = $this->currencies[$currencyId] ?? $this->currencyRepository->find($currencyId);$this->currencies[$currencyId] = $currency;// create objects for big array.@@ -86,7 +86,7 @@ class SummaryBalanceGrouped$return[] = ['key' => sprintf('%s-in-%s', $title, $currency->code),'value' => $this->amounts[$key][$currencyId] ?? '0',- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,@@ -108,12 +108,12 @@ class SummaryBalanceGrouped/** @var array $journal */foreach ($journals as $journal) {// transaction info:- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$amount = bcmul($journal['amount'], $multiplier);$currency = $this->currencies[$currencyId] ?? TransactionCurrency::find($currencyId);$this->currencies[$currencyId] = $currency;$nativeAmount = $converter->convert($currency, $this->default, $journal['date'], $amount);- if ((int)$journal['foreign_currency_id'] === $this->default->id) {+ if ((int) $journal['foreign_currency_id'] === $this->default->id) {// use foreign amount instead$nativeAmount = $journal['foreign_amount'];}diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.phpindex 6064fee9a2..89277778ab 100644--- a/app/Support/Http/Controllers/AugumentData.php+++ b/app/Support/Http/Controllers/AugumentData.php@@ -110,7 +110,7 @@ trait AugumentData$return = [];foreach ($accountIds as $combinedId) {$parts = explode('-', $combinedId);- $accountId = (int)$parts[0];+ $accountId = (int) $parts[0];if (array_key_exists($accountId, $grouped)) {$return[$accountId] = $grouped[$accountId][0]['name'];}@@ -135,7 +135,7 @@ trait AugumentData$return[$budgetId] = $grouped[$budgetId][0]['name'];}}- $return[0] = (string)trans('firefly.no_budget');+ $return[0] = (string) trans('firefly.no_budget');return $return;}@@ -152,12 +152,12 @@ trait AugumentData$return = [];foreach ($categoryIds as $combinedId) {$parts = explode('-', $combinedId);- $categoryId = (int)$parts[0];+ $categoryId = (int) $parts[0];if (array_key_exists($categoryId, $grouped)) {$return[$categoryId] = $grouped[$categoryId][0]['name'];}}- $return[0] = (string)trans('firefly.no_category');+ $return[0] = (string) trans('firefly.no_category');return $return;}@@ -259,7 +259,7 @@ trait AugumentData];// loop to support multi currencyforeach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];// if not set, set to zero:if (!array_key_exists($currencyId, $sum['per_currency'])) {diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.phpindex a5df295ee4..c62d796619 100644--- a/app/Support/Http/Controllers/ChartGeneration.php+++ b/app/Support/Http/Controllers/ChartGeneration.php@@ -83,7 +83,7 @@ trait ChartGeneration$previous = array_values($range)[0];while ($currentStart <= $end) {$format = $currentStart->format('Y-m-d');- $label = trim($currentStart->isoFormat((string)trans('config.month_and_day_js', [], $locale)));+ $label = trim($currentStart->isoFormat((string) trans('config.month_and_day_js', [], $locale)));$balance = $range[$format] ?? $previous;$previous = $balance;$currentStart->addDay();diff --git a/app/Support/Http/Controllers/CreateStuff.php b/app/Support/Http/Controllers/CreateStuff.phpindex 06832c32c5..59fe677edd 100644--- a/app/Support/Http/Controllers/CreateStuff.php+++ b/app/Support/Http/Controllers/CreateStuff.php@@ -71,7 +71,7 @@ trait CreateStuff/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);$assetAccount = [- 'name' => (string)trans('firefly.cash_wallet', [], $language),+ 'name' => (string) trans('firefly.cash_wallet', [], $language),'iban' => null,'account_type_name' => 'asset','virtual_balance' => 0,@@ -106,7 +106,7 @@ trait CreateStuffLog::alert('NO OAuth keys were found. They have been created.');- file_put_contents($publicKey, (string)$key->getPublicKey());+ file_put_contents($publicKey, (string) $key->getPublicKey());file_put_contents($privateKey, $key->toString('PKCS1'));}@@ -118,7 +118,7 @@ trait CreateStuff/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);$savingsAccount = [- 'name' => (string)trans('firefly.new_savings_account', ['bank_name' => $request->get('bank_name')], $language),+ 'name' => (string) trans('firefly.new_savings_account', ['bank_name' => $request->get('bank_name')], $language),'iban' => null,'account_type_name' => 'asset','account_type_id' => null,diff --git a/app/Support/Http/Controllers/DateCalculation.php b/app/Support/Http/Controllers/DateCalculation.phpindex 9dc319cb47..32a4c58841 100644--- a/app/Support/Http/Controllers/DateCalculation.php+++ b/app/Support/Http/Controllers/DateCalculation.php@@ -40,13 +40,13 @@ trait DateCalculation*/public function activeDaysLeft(Carbon $start, Carbon $end): int{- $difference = (int)($start->diffInDays($end, true) + 1);+ $difference = (int) ($start->diffInDays($end, true) + 1);$today = today(config('app.timezone'))->startOfDay();if ($start->lte($today) && $end->gte($today)) {$difference = $today->diffInDays($end) + 1;}- return (int)(0 === $difference ? 1 : $difference);+ return (int) (0 === $difference ? 1 : $difference);}/**@@ -63,7 +63,7 @@ trait DateCalculation$difference = $start->diffInDays($today, true) + 1;}- return (int)$difference;+ return (int) $difference;}protected function calculateStep(Carbon $start, Carbon $end): stringdiff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.phpindex a66f937d62..5619de0ef0 100644--- a/app/Support/Http/Controllers/GetConfigurationData.php+++ b/app/Support/Http/Controllers/GetConfigurationData.php@@ -48,7 +48,7 @@ trait GetConfigurationDataE_COMPILE_ERROR | E_RECOVERABLE_ERROR | E_ERROR | E_CORE_ERROR => 'E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR',];- return $array[$value] ?? (string)$value;+ return $array[$value] ?? (string) $value;}/**@@ -64,7 +64,7 @@ trait GetConfigurationData$currentStep = $options;// get the text:- $currentStep['intro'] = (string)trans('intro.'.$route.'_'.$key);+ $currentStep['intro'] = (string) trans('intro.'.$route.'_'.$key);// save in array:$steps[] = $currentStep;@@ -133,41 +133,41 @@ trait GetConfigurationData$todayEnd = app('navigation')->endOfPeriod($todayStart, $viewRange);if ($todayStart->ne($start) || $todayEnd->ne($end)) {- $ranges[ucfirst((string)trans('firefly.today'))] = [$todayStart, $todayEnd];+ $ranges[ucfirst((string) trans('firefly.today'))] = [$todayStart, $todayEnd];}// last seven days:$seven = today(config('app.timezone'))->subDays(7);- $index = (string)trans('firefly.last_seven_days');+ $index = (string) trans('firefly.last_seven_days');$ranges[$index] = [$seven, new Carbon()];// last 30 days:$thirty = today(config('app.timezone'))->subDays(30);- $index = (string)trans('firefly.last_thirty_days');+ $index = (string) trans('firefly.last_thirty_days');$ranges[$index] = [$thirty, new Carbon()];// month to date:$monthBegin = today(config('app.timezone'))->startOfMonth();- $index = (string)trans('firefly.month_to_date');+ $index = (string) trans('firefly.month_to_date');$ranges[$index] = [$monthBegin, new Carbon()];// year to date:$yearBegin = today(config('app.timezone'))->startOfYear();- $index = (string)trans('firefly.year_to_date');+ $index = (string) trans('firefly.year_to_date');$ranges[$index] = [$yearBegin, new Carbon()];// everything- $index = (string)trans('firefly.everything');+ $index = (string) trans('firefly.everything');$ranges[$index] = [$first, new Carbon()];return ['title' => $title,'configuration' => [- 'apply' => (string)trans('firefly.apply'),- 'cancel' => (string)trans('firefly.cancel'),- 'from' => (string)trans('firefly.from'),- 'to' => (string)trans('firefly.to'),- 'customRange' => (string)trans('firefly.customRange'),+ 'apply' => (string) trans('firefly.apply'),+ 'cancel' => (string) trans('firefly.cancel'),+ 'from' => (string) trans('firefly.from'),+ 'to' => (string) trans('firefly.to'),+ 'customRange' => (string) trans('firefly.customRange'),'start' => $start->format('Y-m-d'),'end' => $end->format('Y-m-d'),'ranges' => $ranges,@@ -192,7 +192,7 @@ trait GetConfigurationData$currentStep = $options;// get the text:- $currentStep['intro'] = (string)trans('intro.'.$route.'_'.$specificPage.'_'.$key);+ $currentStep['intro'] = (string) trans('intro.'.$route.'_'.$specificPage.'_'.$key);// save in array:$steps[] = $currentStep;@@ -207,7 +207,7 @@ trait GetConfigurationDataprotected function verifyRecurringCronJob(): void{$config = app('fireflyconfig')->get('last_rt_job', 0);- $lastTime = (int)$config?->data;+ $lastTime = (int) $config?->data;$now = time();app('log')->debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config?->data, $now));if (0 === $lastTime) {diff --git a/app/Support/Http/Controllers/ModelInformation.php b/app/Support/Http/Controllers/ModelInformation.phpindex fbd1524b4f..d1a96aa307 100644--- a/app/Support/Http/Controllers/ModelInformation.php+++ b/app/Support/Http/Controllers/ModelInformation.php@@ -86,9 +86,9 @@ trait ModelInformation/** @var AccountType $mortgage */$mortgage = $repository->getAccountTypeByType(AccountType::MORTGAGE);$liabilityTypes = [- $debt->id => (string)trans(sprintf('firefly.account_type_%s', AccountTypeEnum::DEBT->value)),- $loan->id => (string)trans(sprintf('firefly.account_type_%s', AccountTypeEnum::LOAN->value)),- $mortgage->id => (string)trans(sprintf('firefly.account_type_%s', AccountTypeEnum::MORTGAGE->value)),+ $debt->id => (string) trans(sprintf('firefly.account_type_%s', AccountTypeEnum::DEBT->value)),+ $loan->id => (string) trans(sprintf('firefly.account_type_%s', AccountTypeEnum::LOAN->value)),+ $mortgage->id => (string) trans(sprintf('firefly.account_type_%s', AccountTypeEnum::MORTGAGE->value)),];asort($liabilityTypes);@@ -99,7 +99,7 @@ trait ModelInformation{$roles = [];foreach (config('firefly.accountRoles') as $role) {- $roles[$role] = (string)trans(sprintf('firefly.account_role_%s', $role));+ $roles[$role] = (string) trans(sprintf('firefly.account_role_%s', $role));}return $roles;@@ -117,7 +117,7 @@ trait ModelInformation$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);@@ -168,7 +168,7 @@ trait ModelInformation$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);diff --git a/app/Support/Http/Controllers/PeriodOverview.php b/app/Support/Http/Controllers/PeriodOverview.phpindex 0563b94750..319cd37f55 100644--- a/app/Support/Http/Controllers/PeriodOverview.php+++ b/app/Support/Http/Controllers/PeriodOverview.php@@ -166,7 +166,7 @@ trait PeriodOverview/** @var array $journal */foreach ($journals as $journal) {- if ($account->id === (int)$journal['source_account_id']) {+ if ($account->id === (int) $journal['source_account_id']) {$return[] = $journal;}}@@ -183,7 +183,7 @@ trait PeriodOverview/** @var array $journal */foreach ($journals as $journal) {- if ($account->id === (int)$journal['destination_account_id']) {+ if ($account->id === (int) $journal['destination_account_id']) {$return[] = $journal;}}@@ -197,7 +197,7 @@ trait PeriodOverview/** @var array $journal */foreach ($journals as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$foreignCurrencyId = $journal['foreign_currency_id'];if (!array_key_exists($currencyId, $return)) {$return[$currencyId] = [@@ -218,7 +218,7 @@ trait PeriodOverview$return[$foreignCurrencyId] = ['amount' => '0','count' => 0,- 'currency_id' => (int)$foreignCurrencyId,+ 'currency_id' => (int) $foreignCurrencyId,'currency_name' => $journal['foreign_currency_name'],'currency_code' => $journal['foreign_currency_code'],'currency_symbol' => $journal['foreign_currency_symbol'],diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.phpindex b49be23a08..b4764dd024 100644--- a/app/Support/Http/Controllers/RenderPartialViews.php+++ b/app/Support/Http/Controllers/RenderPartialViews.php@@ -55,10 +55,10 @@ trait RenderPartialViews/** @var BudgetRepositoryInterface $budgetRepository */$budgetRepository = app(BudgetRepositoryInterface::class);- $budget = $budgetRepository->find((int)$attributes['budgetId']);+ $budget = $budgetRepository->find((int) $attributes['budgetId']);$accountRepos = app(AccountRepositoryInterface::class);- $account = $accountRepos->find((int)$attributes['accountId']);+ $account = $accountRepos->find((int) $attributes['accountId']);if (null === $budget || null === $account) {throw new FireflyException('Could not render popup.report.balance-amount because budget or account is null.');@@ -114,7 +114,7 @@ trait RenderPartialViews/** @var PopupReportInterface $popupHelper */$popupHelper = app(PopupReportInterface::class);- $budget = $budgetRepository->find((int)$attributes['budgetId']);+ $budget = $budgetRepository->find((int) $attributes['budgetId']);if (null === $budget) {// transactions without a budget.$budget = new Budget();@@ -145,7 +145,7 @@ trait RenderPartialViews/** @var CategoryRepositoryInterface $categoryRepository */$categoryRepository = app(CategoryRepositoryInterface::class);- $category = $categoryRepository->find((int)$attributes['categoryId']);+ $category = $categoryRepository->find((int) $attributes['categoryId']);$journals = $popupHelper->byCategory($category, $attributes);try {@@ -238,7 +238,7 @@ trait RenderPartialViews/** @var PopupReportInterface $popupHelper */$popupHelper = app(PopupReportInterface::class);- $account = $accountRepository->find((int)$attributes['accountId']);+ $account = $accountRepository->find((int) $attributes['accountId']);if (null === $account) {return 'This is an unknown account. Apologies.';@@ -309,7 +309,7 @@ trait RenderPartialViews$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);@@ -324,7 +324,7 @@ trait RenderPartialViews$count = ($index + 1);try {- $rootOperator = OperatorQuerySearch::getRootOperator((string)$entry->trigger_type);+ $rootOperator = OperatorQuerySearch::getRootOperator((string) $entry->trigger_type);if (str_starts_with($rootOperator, '-')) {$rootOperator = substr($rootOperator, 1);}@@ -334,7 +334,7 @@ trait RenderPartialViews'oldTrigger' => $rootOperator,'oldValue' => $entry->trigger_value,'oldChecked' => $entry->stop_processing,- 'oldProhibited' => str_starts_with((string)$entry->trigger_type, '-'),+ 'oldProhibited' => str_starts_with((string) $entry->trigger_type, '-'),'count' => $count,'triggers' => $triggers,]@@ -365,7 +365,7 @@ trait RenderPartialViews/** @var PopupReportInterface $popupHelper */$popupHelper = app(PopupReportInterface::class);- $account = $accountRepository->find((int)$attributes['accountId']);+ $account = $accountRepository->find((int) $attributes['accountId']);if (null === $account) {return 'This is an unknown category. Apologies.';diff --git a/app/Support/Http/Controllers/RequestInformation.php b/app/Support/Http/Controllers/RequestInformation.phpindex 5466ed5242..7307496f2e 100644--- a/app/Support/Http/Controllers/RequestInformation.php+++ b/app/Support/Http/Controllers/RequestInformation.php@@ -64,7 +64,7 @@ trait RequestInformation'type' => $triggerInfo['type'] ?? '','value' => $triggerInfo['value'] ?? '','prohibited' => $triggerInfo['prohibited'] ?? false,- 'stop_processing' => 1 === (int)($triggerInfo['stop_processing'] ?? '0'),+ 'stop_processing' => 1 === (int) ($triggerInfo['stop_processing'] ?? '0'),];$current = RuleFormRequest::replaceAmountTrigger($current);$triggers[] = $current;@@ -170,11 +170,11 @@ trait RequestInformationfinal protected function validatePassword(User $user, string $current, string $new): bool // get request info{if (!\Hash::check($current, $user->password)) {- throw new ValidationException((string)trans('firefly.invalid_current_password'));+ throw new ValidationException((string) trans('firefly.invalid_current_password'));}if ($current === $new) {- throw new ValidationException((string)trans('firefly.should_change'));+ throw new ValidationException((string) trans('firefly.should_change'));}return true;diff --git a/app/Support/Http/Controllers/RuleManagement.php b/app/Support/Http/Controllers/RuleManagement.phpindex 91331bfe49..a334161ee0 100644--- a/app/Support/Http/Controllers/RuleManagement.php+++ b/app/Support/Http/Controllers/RuleManagement.php@@ -50,7 +50,7 @@ trait RuleManagement['oldAction' => $oldAction['type'],'oldValue' => $oldAction['value'] ?? '',- 'oldChecked' => 1 === (int)($oldAction['stop_processing'] ?? '0'),+ 'oldChecked' => 1 === (int) ($oldAction['stop_processing'] ?? '0'),'count' => $index + 1,])->render();@@ -77,7 +77,7 @@ trait RuleManagement$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);@@ -93,8 +93,8 @@ trait RuleManagement['oldTrigger' => OperatorQuerySearch::getRootOperator($oldTrigger['type']),'oldValue' => $oldTrigger['value'] ?? '',- 'oldChecked' => 1 === (int)($oldTrigger['stop_processing'] ?? '0'),- 'oldProhibited' => 1 === (int)($oldTrigger['prohibited'] ?? '0'),+ 'oldChecked' => 1 === (int) ($oldTrigger['stop_processing'] ?? '0'),+ 'oldProhibited' => 1 === (int) ($oldTrigger['prohibited'] ?? '0'),'count' => $index + 1,'triggers' => $triggers,]@@ -123,7 +123,7 @@ trait RuleManagement$triggers = [];foreach ($operators as $key => $operator) {if ('user_action' !== $key && false === $operator['alias']) {- $triggers[$key] = (string)trans(sprintf('firefly.rule_trigger_%s_choice', $key));+ $triggers[$key] = (string) trans(sprintf('firefly.rule_trigger_%s_choice', $key));}}asort($triggers);@@ -131,7 +131,7 @@ trait RuleManagement$index = 0;foreach ($submittedOperators as $operator) {$rootOperator = OperatorQuerySearch::getRootOperator($operator['type']);- $needsContext = (bool)config(sprintf('search.operators.%s.needs_context', $rootOperator));+ $needsContext = (bool) config(sprintf('search.operators.%s.needs_context', $rootOperator));try {$renderedEntries[] = view(@@ -163,8 +163,8 @@ trait RuleManagement$repository = app(RuleGroupRepositoryInterface::class);if (0 === $repository->count()) {$data = [- 'title' => (string)trans('firefly.default_rule_group_name'),- 'description' => (string)trans('firefly.default_rule_group_description'),+ 'title' => (string) trans('firefly.default_rule_group_name'),+ 'description' => (string) trans('firefly.default_rule_group_description'),'active' => true,];diff --git a/app/Support/Http/Controllers/UserNavigation.php b/app/Support/Http/Controllers/UserNavigation.phpindex 9a62ee092d..f9f2bc4091 100644--- a/app/Support/Http/Controllers/UserNavigation.php+++ b/app/Support/Http/Controllers/UserNavigation.php@@ -49,7 +49,7 @@ trait UserNavigationfinal protected function getPreviousUrl(string $identifier): string{app('log')->debug(sprintf('Trying to retrieve URL stored under "%s"', $identifier));- $url = (string)session($identifier);+ $url = (string) session($identifier);app('log')->debug(sprintf('The URL is %s', $url));return app('steam')->getSafeUrl($url, route('index'));diff --git a/app/Support/JsonApi/Concerns/UserGroupDetectable.php b/app/Support/JsonApi/Concerns/UserGroupDetectable.phpindex 3648053d77..e3c081bab2 100644--- a/app/Support/JsonApi/Concerns/UserGroupDetectable.php+++ b/app/Support/JsonApi/Concerns/UserGroupDetectable.php@@ -44,10 +44,10 @@ trait UserGroupDetectable$userGroup = request()->route()?->parameter('userGroup');if (null === $userGroup) {app('log')->debug('Request class has no userGroup parameter, but perhaps there is a parameter.');- $userGroupId = (int)request()->get('user_group_id');+ $userGroupId = (int) request()->get('user_group_id');if (0 === $userGroupId) {app('log')->debug(sprintf('Request class has no user_group_id parameter, grab default from user (group #%d).', $user->user_group_id));- $userGroupId = (int)$user->user_group_id;+ $userGroupId = (int) $user->user_group_id;}$userGroup = UserGroup::find($userGroupId);if (null === $userGroup) {diff --git a/app/Support/JsonApi/Enrichments/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.phpindex 940e528806..bb84f2373c 100644--- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php+++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php@@ -44,17 +44,16 @@ use Illuminate\Support\Facades\Log;*/class AccountEnrichment implements EnrichmentInterface{+ private array $balances;private Collection $collection;private array $currencies;- private array $objectGroups;- private array $grouped;- private array $balances;+ private CurrencyRepositoryInterface $currencyRepository;private TransactionCurrency $default;- private ?Carbon $start;private ?Carbon $end;-+ private array $grouped;+ private array $objectGroups;private AccountRepositoryInterface $repository;- private CurrencyRepositoryInterface $currencyRepository;+ private ?Carbon $start;public function __construct(){@@ -64,6 +63,16 @@ class AccountEnrichment implements EnrichmentInterface$this->end = null;}+ #[\Override]+ public function enrichSingle(Model $model): Account+ {+ Log::debug(__METHOD__);+ $collection = new Collection([$model]);+ $collection = $this->enrich($collection);++ return $collection->first();+ }+#[\Override]/*** Do the actual enrichment.@@ -111,6 +120,53 @@ class AccountEnrichment implements EnrichmentInterface}}+ /**+ * TODO this method refers to a single-use method inside Steam that could be moved here.+ */+ private function collectAccountTypes(): void+ {+ $accountTypes = $this->repository->getAccountTypes($this->collection);+ $types = [];++ /** @var AccountType $row */+ foreach ($accountTypes as $row) {+ $types[$row->id] = $row->type;+ }+ $this->collection->transform(function (Account $account) use ($types) {+ $account->account_type_string = $types[$account->id];++ return $account;+ });+ }++ private function collectMetaData(): void+ {+ $metaFields = $this->repository->getMetaValues($this->collection, ['is_multi_currency', 'currency_id', 'account_role', 'account_number', 'liability_direction', 'interest', 'interest_period', 'current_debt']);+ $currencyIds = $metaFields->where('name', 'currency_id')->pluck('data')->toArray();++ $currencies = [];+ foreach ($this->currencyRepository->getByIds($currencyIds) as $currency) {+ $id = $currency->id;+ $currencies[$id] = $currency;+ }++ $this->collection->transform(function (Account $account) use ($metaFields, $currencies) {+ $set = $metaFields->where('account_id', $account->id);+ foreach ($set as $entry) {+ $account->{$entry->name} = $entry->data;+ if ('currency_id' === $entry->name) {+ $id = (int) $entry->data;+ $account->currency_name = $currencies[$id]?->name;+ $account->currency_code = $currencies[$id]?->code;+ $account->currency_symbol = $currencies[$id]?->symbol;+ $account->currency_decimal_places = $currencies[$id]?->decimal_places;+ }+ }++ return $account;+ });+ }+private function getMetaBalances(): void{$this->balances = Balance::getAccountBalances($this->collection, today());@@ -181,73 +237,6 @@ class AccountEnrichment implements EnrichmentInterface});}- /**- * TODO this method refers to a single-use method inside Steam that could be moved here.- */- private function collectAccountTypes(): void- {- $accountTypes = $this->repository->getAccountTypes($this->collection);- $types = [];-- /** @var AccountType $row */- foreach ($accountTypes as $row) {- $types[$row->id] = $row->type;- }- $this->collection->transform(function (Account $account) use ($types) {- $account->account_type_string = $types[$account->id];-- return $account;- });- }-- private function collectMetaData(): void- {- $metaFields = $this->repository->getMetaValues($this->collection, ['is_multi_currency', 'currency_id', 'account_role', 'account_number', 'liability_direction', 'interest', 'interest_period', 'current_debt']);- $currencyIds = $metaFields->where('name', 'currency_id')->pluck('data')->toArray();-- $currencies = [];- foreach ($this->currencyRepository->getByIds($currencyIds) as $currency) {- $id = $currency->id;- $currencies[$id] = $currency;- }-- $this->collection->transform(function (Account $account) use ($metaFields, $currencies) {- $set = $metaFields->where('account_id', $account->id);- foreach ($set as $entry) {- $account->{$entry->name} = $entry->data;- if ('currency_id' === $entry->name) {- $id = (int) $entry->data;- $account->currency_name = $currencies[$id]?->name;- $account->currency_code = $currencies[$id]?->code;- $account->currency_symbol = $currencies[$id]?->symbol;- $account->currency_decimal_places = $currencies[$id]?->decimal_places;- }- }-- return $account;- });- }-- #[\Override]- public function enrichSingle(Model $model): Account- {- Log::debug(__METHOD__);- $collection = new Collection([$model]);- $collection = $this->enrich($collection);-- return $collection->first();- }-- public function setStart(?Carbon $start): void- {- $this->start = $start;- }-- public function setEnd(?Carbon $end): void- {- $this->end = $end;- }-private function getObjectGroups(): void{$set = \DB::table('object_groupables')@@ -279,4 +268,14 @@ class AccountEnrichment implements EnrichmentInterfacereturn $account;});}++ public function setEnd(?Carbon $end): void+ {+ $this->end = $end;+ }++ public function setStart(?Carbon $start): void+ {+ $this->start = $start;+ }}diff --git a/app/Support/JsonApi/ExpandsQuery.php b/app/Support/JsonApi/ExpandsQuery.phpindex a45c2c6ed3..5599efae5e 100644--- a/app/Support/JsonApi/ExpandsQuery.php+++ b/app/Support/JsonApi/ExpandsQuery.php@@ -35,36 +35,41 @@ trait ExpandsQuery{use AccountFilter;- final protected function addPagination(Builder $query, array $pagination): Builder- {- $skip = ($pagination['number'] - 1) * $pagination['size'];-- return $query->skip($skip)->take($pagination['size']);- }-- final protected function addSortParams(string $class, Builder $query, ?SortFields $sort): Builder+ final protected function addFilterParams(string $class, Builder $query, ?FilterParameters $filters): Builder{- $config = config('api.valid_query_sort')[$class] ?? [];- if (null === $sort) {+ Log::debug(__METHOD__);+ if (null === $filters) {return $query;}- foreach ($sort->all() as $sortField) {- if (in_array($sortField->name(), $config, true)) {- $query->orderBy($sortField->name(), $sortField->isAscending() ? 'ASC' : 'DESC');- }+ if (0 === count($filters->all())) {+ return $query;}+ // parse filters valid for this class.+ $parsed = $this->parseAllFilters($class, $filters);- return $query;- }+ // expand query for each query filter+ $config = config('api.valid_query_filters')[$class];+ $query->where(function (Builder $q) use ($config, $parsed): void {+ foreach ($parsed as $key => $filter) {+ if (in_array($key, $config, true)) {+ Log::debug(sprintf('Add query filter "%s"', $key));+ // add type to query:+ foreach ($filter as $value) {+ $q->whereLike($key, sprintf('%%%s%%', $value));+ }+ }+ }+ });- private function parseAccountTypeFilter(array $value): array- {- $return = [];- foreach ($value as $entry) {- $return = array_merge($return, $this->mapAccountTypes($entry));+ // TODO this is special treatment, but alas, unavoidable right now.+ if (Account::class === $class && array_key_exists('type', $parsed)) {+ if (count($parsed['type']) > 0) {+ $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');+ $query->whereIn('account_types.type', $parsed['type']);+ }}- return array_unique($return);+ return $query;}private function parseAllFilters(string $class, FilterParameters $filters): array@@ -101,37 +106,32 @@ trait ExpandsQueryreturn $parsed;}- final protected function addFilterParams(string $class, Builder $query, ?FilterParameters $filters): Builder+ private function parseAccountTypeFilter(array $value): array{- Log::debug(__METHOD__);- if (null === $filters) {- return $query;- }- if (0 === count($filters->all())) {- return $query;+ $return = [];+ foreach ($value as $entry) {+ $return = array_merge($return, $this->mapAccountTypes($entry));}- // parse filters valid for this class.- $parsed = $this->parseAllFilters($class, $filters);- // expand query for each query filter- $config = config('api.valid_query_filters')[$class];- $query->where(function (Builder $q) use ($config, $parsed): void {- foreach ($parsed as $key => $filter) {- if (in_array($key, $config, true)) {- Log::debug(sprintf('Add query filter "%s"', $key));- // add type to query:- foreach ($filter as $value) {- $q->whereLike($key, sprintf('%%%s%%', $value));- }- }- }- });+ return array_unique($return);+ }- // TODO this is special treatment, but alas, unavoidable right now.- if (Account::class === $class && array_key_exists('type', $parsed)) {- if (count($parsed['type']) > 0) {- $query->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id');- $query->whereIn('account_types.type', $parsed['type']);+ final protected function addPagination(Builder $query, array $pagination): Builder+ {+ $skip = ($pagination['number'] - 1) * $pagination['size'];++ return $query->skip($skip)->take($pagination['size']);+ }++ final protected function addSortParams(string $class, Builder $query, ?SortFields $sort): Builder+ {+ $config = config('api.valid_query_sort')[$class] ?? [];+ if (null === $sort) {+ return $query;+ }+ foreach ($sort->all() as $sortField) {+ if (in_array($sortField->name(), $config, true)) {+ $query->orderBy($sortField->name(), $sortField->isAscending() ? 'ASC' : 'DESC');}}diff --git a/app/Support/JsonApi/SortsQueryResults.php b/app/Support/JsonApi/SortsQueryResults.phpindex d9bf99b666..9c5539aa3b 100644--- a/app/Support/JsonApi/SortsQueryResults.php+++ b/app/Support/JsonApi/SortsQueryResults.php@@ -82,8 +82,8 @@ trait SortsQueryResultsif (Account::class === $class && 'last_activity' === $field->name()) {$ascending = $field->isAscending();$collection = $collection->sort(function (Account $left, Account $right) use ($ascending): int {- $leftNr = (int)$left->last_activity?->format('U');- $rightNr = (int)$right->last_activity?->format('U');+ $leftNr = (int) $left->last_activity?->format('U');+ $rightNr = (int) $right->last_activity?->format('U');if ($ascending) {return $leftNr <=> $rightNr;}diff --git a/app/Support/Models/AccountBalanceCalculator.php b/app/Support/Models/AccountBalanceCalculator.phpindex 9f379e7f6f..dab18b9699 100644--- a/app/Support/Models/AccountBalanceCalculator.php+++ b/app/Support/Models/AccountBalanceCalculator.php@@ -61,68 +61,6 @@ class AccountBalanceCalculator$object->optimizedCalculation(new Collection());}- public static function recalculateForJournal(TransactionJournal $transactionJournal): void- {- Log::debug(__METHOD__);- $object = new self();-- // recalculate the involved accounts:- $accounts = new Collection();- foreach ($transactionJournal->transactions as $transaction) {- $accounts->push($transaction->account);- }- $object->optimizedCalculation($accounts, $transactionJournal->date);- }-- private function getLatestBalance(int $accountId, int $currencyId, ?Carbon $notBefore): string- {- if (null === $notBefore) {- return '0';- }- Log::debug(sprintf('getLatestBalance: notBefore date is "%s", calculating', $notBefore->format('Y-m-d')));- $query = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->whereNull('transactions.deleted_at')- ->where('transaction_journals.transaction_currency_id', $currencyId)- ->whereNull('transaction_journals.deleted_at')- // this order is the same as GroupCollector- ->orderBy('transaction_journals.date', 'DESC')- ->orderBy('transaction_journals.order', 'ASC')- ->orderBy('transaction_journals.id', 'DESC')- ->orderBy('transaction_journals.description', 'DESC')- ->orderBy('transactions.amount', 'DESC')- ->where('transactions.account_id', $accountId)- ;- $notBefore->startOfDay();- $query->where('transaction_journals.date', '<', $notBefore);-- $first = $query->first(['transactions.id', 'transactions.balance_dirty', 'transactions.transaction_currency_id', 'transaction_journals.date', 'transactions.account_id', 'transactions.amount', 'transactions.balance_after']);- $balance = (string) ($first->balance_after ?? '0');- Log::debug(sprintf('getLatestBalance: found balance: %s in transaction #%d', $balance, $first->id ?? 0));-- return $balance;- }-- private function getAccountBalanceByAccount(int $account, int $currency): AccountBalance- {- $query = AccountBalance::where('title', 'balance')->where('account_id', $account)->where('transaction_currency_id', $currency);-- $entry = $query->first();- if (null !== $entry) {- // Log::debug(sprintf('Found account balance "balance" for account #%d and currency #%d: %s', $account, $currency, $entry->balance));-- return $entry;- }- $entry = new AccountBalance();- $entry->title = 'balance';- $entry->account_id = $account;- $entry->transaction_currency_id = $currency;- $entry->balance = '0';- $entry->save();- // Log::debug(sprintf('Created new account balance for account #%d and currency #%d: %s', $account, $currency, $entry->balance));-- return $entry;- }-private function optimizedCalculation(Collection $accounts, ?Carbon $notBefore = null): void{Log::debug('start of optimizedCalculation');@@ -183,23 +121,32 @@ class AccountBalanceCalculator$this->storeAccountBalances($balances);}- private function getAccountBalanceByJournal(string $title, int $account, int $journal, int $currency): AccountBalance+ private function getLatestBalance(int $accountId, int $currencyId, ?Carbon $notBefore): string{- $query = AccountBalance::where('title', $title)->where('account_id', $account)->where('transaction_journal_id', $journal)->where('transaction_currency_id', $currency);-- $entry = $query->first();- if (null !== $entry) {- return $entry;+ if (null === $notBefore) {+ return '0';}- $entry = new AccountBalance();- $entry->title = $title;- $entry->account_id = $account;- $entry->transaction_journal_id = $journal;- $entry->transaction_currency_id = $currency;- $entry->balance = '0';- $entry->save();+ Log::debug(sprintf('getLatestBalance: notBefore date is "%s", calculating', $notBefore->format('Y-m-d')));+ $query = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->whereNull('transactions.deleted_at')+ ->where('transaction_journals.transaction_currency_id', $currencyId)+ ->whereNull('transaction_journals.deleted_at')+ // this order is the same as GroupCollector+ ->orderBy('transaction_journals.date', 'DESC')+ ->orderBy('transaction_journals.order', 'ASC')+ ->orderBy('transaction_journals.id', 'DESC')+ ->orderBy('transaction_journals.description', 'DESC')+ ->orderBy('transactions.amount', 'DESC')+ ->where('transactions.account_id', $accountId)+ ;+ $notBefore->startOfDay();+ $query->where('transaction_journals.date', '<', $notBefore);- return $entry;+ $first = $query->first(['transactions.id', 'transactions.balance_dirty', 'transactions.transaction_currency_id', 'transaction_journals.date', 'transactions.account_id', 'transactions.amount', 'transactions.balance_after']);+ $balance = (string) ($first->balance_after ?? '0');+ Log::debug(sprintf('getLatestBalance: found balance: %s in transaction #%d', $balance, $first->id ?? 0));++ return $balance;}private function storeAccountBalances(array $balances): void@@ -247,4 +194,57 @@ class AccountBalanceCalculator}}}++ public static function recalculateForJournal(TransactionJournal $transactionJournal): void+ {+ Log::debug(__METHOD__);+ $object = new self();++ // recalculate the involved accounts:+ $accounts = new Collection();+ foreach ($transactionJournal->transactions as $transaction) {+ $accounts->push($transaction->account);+ }+ $object->optimizedCalculation($accounts, $transactionJournal->date);+ }++ private function getAccountBalanceByAccount(int $account, int $currency): AccountBalance+ {+ $query = AccountBalance::where('title', 'balance')->where('account_id', $account)->where('transaction_currency_id', $currency);++ $entry = $query->first();+ if (null !== $entry) {+ // Log::debug(sprintf('Found account balance "balance" for account #%d and currency #%d: %s', $account, $currency, $entry->balance));++ return $entry;+ }+ $entry = new AccountBalance();+ $entry->title = 'balance';+ $entry->account_id = $account;+ $entry->transaction_currency_id = $currency;+ $entry->balance = '0';+ $entry->save();+ // Log::debug(sprintf('Created new account balance for account #%d and currency #%d: %s', $account, $currency, $entry->balance));++ return $entry;+ }++ private function getAccountBalanceByJournal(string $title, int $account, int $journal, int $currency): AccountBalance+ {+ $query = AccountBalance::where('title', $title)->where('account_id', $account)->where('transaction_journal_id', $journal)->where('transaction_currency_id', $currency);++ $entry = $query->first();+ if (null !== $entry) {+ return $entry;+ }+ $entry = new AccountBalance();+ $entry->title = $title;+ $entry->account_id = $account;+ $entry->transaction_journal_id = $journal;+ $entry->transaction_currency_id = $currency;+ $entry->balance = '0';+ $entry->save();++ return $entry;+ }}diff --git a/app/Support/Models/ReturnsIntegerIdTrait.php b/app/Support/Models/ReturnsIntegerIdTrait.phpindex 3432772855..4b1fe3affc 100644--- a/app/Support/Models/ReturnsIntegerIdTrait.php+++ b/app/Support/Models/ReturnsIntegerIdTrait.php@@ -39,7 +39,7 @@ trait ReturnsIntegerIdTraitprotected function id(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Support/Models/ReturnsIntegerUserIdTrait.php b/app/Support/Models/ReturnsIntegerUserIdTrait.phpindex 3f1808923d..a0d2bc79e9 100644--- a/app/Support/Models/ReturnsIntegerUserIdTrait.php+++ b/app/Support/Models/ReturnsIntegerUserIdTrait.php@@ -37,14 +37,14 @@ trait ReturnsIntegerUserIdTraitprotected function userGroupId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}protected function userId(): Attribute{return Attribute::make(- get: static fn ($value) => (int)$value,+ get: static fn ($value) => (int) $value,);}}diff --git a/app/Support/ParseDateString.php b/app/Support/ParseDateString.phpindex e747f81175..9919f9fb0e 100644--- a/app/Support/ParseDateString.php+++ b/app/Support/ParseDateString.php@@ -112,7 +112,7 @@ class ParseDateStringreturn new Carbon('1984-09-17');}// maybe a year, nothing else?- if (4 === strlen($date) && is_numeric($date) && (int)$date > 1000 && (int)$date <= 3000) {+ if (4 === strlen($date) && is_numeric($date) && (int) $date > 1000 && (int) $date <= 3000) {return new Carbon(sprintf('%d-01-01', $date));}@@ -190,7 +190,7 @@ class ParseDateString}$direction = str_starts_with($part, '+') ? 1 : 0;$period = $part[strlen($part) - 1];- $number = (int)substr($part, 1, -1);+ $number = (int) substr($part, 1, -1);if (!array_key_exists($period, $functions[$direction])) {app('log')->error(sprintf('No method for direction %d and period "%s".', $direction, $period));diff --git a/app/Support/Preferences.php b/app/Support/Preferences.phpindex ab8c4ba5f1..4bc5127e7e 100644--- a/app/Support/Preferences.php+++ b/app/Support/Preferences.php@@ -56,42 +56,6 @@ class Preferences;}- public function getEncrypted(string $name, $default = null): ?Preference- {- $result = $this->get($name, $default);- if (null === $result) {- return null;- }- if ('' === $result->data) {- Log::warning(sprintf('Empty encrypted preference found: "%s"', $name));-- return $result;- }-- try {- $result->data = decrypt($result->data);- } catch (DecryptException $e) {- Log::error(sprintf('Could not decrypt preference "%s": %s', $name, $e->getMessage()));-- return $result;- }-- return $result;- }-- public function setEncrypted(string $name, mixed $value): Preference- {- try {- $encrypted = encrypt($value);- } catch (EncryptException $e) {- Log::error(sprintf('Could not encrypt preference "%s": %s', $name, $e->getMessage()));-- throw new FireflyException(sprintf('Could not encrypt preference "%s". Cowardly refuse to continue.', $name));- }-- return $this->set($name, $encrypted);- }-public function get(string $name, null|array|bool|int|string $default = null): ?Preference{/** @var null|User $user */@@ -106,27 +70,6 @@ class Preferencesreturn $this->getForUser($user, $name, $default);}- public function getEncryptedForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference- {- $result = $this->getForUser($user, $name, $default);- if ('' === $result->data) {- Log::warning(sprintf('Empty encrypted preference found: "%s"', $name));-- return $result;- }-- try {- $result->data = decrypt($result->data);- } catch (DecryptException $e) {- Log::error(sprintf('Could not decrypt preference "%s": %s', $name, $e->getMessage()));-- return $result;- }--- return $result;- }-public function getForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference{// don't care about user group ID, except for some specific preferences.@@ -155,7 +98,7 @@ class Preferences$groupId = null;$items = config('firefly.admin_specific_prefs') ?? [];if (in_array($preferenceName, $items, true)) {- $groupId = (int)$user->user_group_id;+ $groupId = (int) $user->user_group_id;}return $groupId;@@ -198,7 +141,7 @@ class Preferences}if (null === $pref) {$pref = new Preference();- $pref->user_id = (int)$user->id;+ $pref->user_id = (int) $user->id;$pref->user_group_id = $groupId;$pref->name = $name;}@@ -249,6 +192,50 @@ class Preferencesreturn $result;}+ public function getEncrypted(string $name, $default = null): ?Preference+ {+ $result = $this->get($name, $default);+ if (null === $result) {+ return null;+ }+ if ('' === $result->data) {+ Log::warning(sprintf('Empty encrypted preference found: "%s"', $name));++ return $result;+ }++ try {+ $result->data = decrypt($result->data);+ } catch (DecryptException $e) {+ Log::error(sprintf('Could not decrypt preference "%s": %s', $name, $e->getMessage()));++ return $result;+ }++ return $result;+ }++ public function getEncryptedForUser(User $user, string $name, null|array|bool|int|string $default = null): ?Preference+ {+ $result = $this->getForUser($user, $name, $default);+ if ('' === $result->data) {+ Log::warning(sprintf('Empty encrypted preference found: "%s"', $name));++ return $result;+ }++ try {+ $result->data = decrypt($result->data);+ } catch (DecryptException $e) {+ Log::error(sprintf('Could not decrypt preference "%s": %s', $name, $e->getMessage()));++ return $result;+ }+++ return $result;+ }+public function getFresh(string $name, null|array|bool|int|string $default = null): ?Preference{/** @var null|User $user */@@ -278,7 +265,7 @@ class Preferences$lastActivity = implode(',', $lastActivity);}- return hash('sha256', (string)$lastActivity);+ return hash('sha256', (string) $lastActivity);}public function mark(): void@@ -287,6 +274,19 @@ class PreferencesSession::forget('first');}+ public function setEncrypted(string $name, mixed $value): Preference+ {+ try {+ $encrypted = encrypt($value);+ } catch (EncryptException $e) {+ Log::error(sprintf('Could not encrypt preference "%s": %s', $name, $e->getMessage()));++ throw new FireflyException(sprintf('Could not encrypt preference "%s". Cowardly refuse to continue.', $name));+ }++ return $this->set($name, $encrypted);+ }+public function set(string $name, null|array|bool|int|string $value): Preference{/** @var null|User $user */diff --git a/app/Support/Report/Budget/BudgetReportGenerator.php b/app/Support/Report/Budget/BudgetReportGenerator.phpindex 7059886943..2de00d88c0 100644--- a/app/Support/Report/Budget/BudgetReportGenerator.php+++ b/app/Support/Report/Budget/BudgetReportGenerator.php@@ -106,8 +106,8 @@ class BudgetReportGenerator*/private function processBudgetExpenses(array $expenses, array $budget): void{- $budgetId = (int)$budget['id'];- $currencyId = (int)$expenses['currency_id'];+ $budgetId = (int) $budget['id'];+ $currencyId = (int) $expenses['currency_id'];foreach ($budget['transaction_journals'] as $journal) {$sourceAccountId = $journal['source_account_id'];@@ -245,7 +245,7 @@ class BudgetReportGenerator$noBudget = $this->nbRepository->sumExpenses($this->start, $this->end, $this->accounts);foreach ($noBudget as $noBudgetEntry) {// currency information:- $nbCurrencyId = (int)($noBudgetEntry['currency_id'] ?? $this->currency->id);+ $nbCurrencyId = (int) ($noBudgetEntry['currency_id'] ?? $this->currency->id);$nbCurrencyCode = $noBudgetEntry['currency_code'] ?? $this->currency->code;$nbCurrencyName = $noBudgetEntry['currency_name'] ?? $this->currency->name;$nbCurrencySymbol = $noBudgetEntry['currency_symbol'] ?? $this->currency->symbol;@@ -290,9 +290,9 @@ class BudgetReportGenerator// make percentages based on total amount.foreach ($this->report['budgets'] as $budgetId => $data) {foreach ($data['budget_limits'] as $limitId => $entry) {- $budgetId = (int)$budgetId;- $limitId = (int)$limitId;- $currencyId = (int)$entry['currency_id'];+ $budgetId = (int) $budgetId;+ $limitId = (int) $limitId;+ $currencyId = (int) $entry['currency_id'];$spent = $entry['spent'];$totalSpent = $this->report['sums'][$currencyId]['spent'] ?? '0';$spentPct = '0';@@ -301,10 +301,10 @@ class BudgetReportGenerator$budgetedPct = '0';if (0 !== bccomp($spent, '0') && 0 !== bccomp($totalSpent, '0')) {- $spentPct = round((float)bcmul(bcdiv($spent, $totalSpent), '100'));+ $spentPct = round((float) bcmul(bcdiv($spent, $totalSpent), '100'));}if (0 !== bccomp($budgeted, '0') && 0 !== bccomp($totalBudgeted, '0')) {- $budgetedPct = round((float)bcmul(bcdiv($budgeted, $totalBudgeted), '100'));+ $budgetedPct = round((float) bcmul(bcdiv($budgeted, $totalBudgeted), '100'));}$this->report['sums'][$currencyId]['budgeted'] ??= '0';$this->report['budgets'][$budgetId]['budget_limits'][$limitId]['spent_pct'] = $spentPct;diff --git a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.phpindex df73a72f60..439fd1f50a 100644--- a/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php+++ b/app/Support/Repositories/Recurring/CalculateRangeOccurrences.php@@ -58,7 +58,7 @@ trait CalculateRangeOccurrences{$return = [];$attempts = 0;- $dayOfMonth = (int)$moment;+ $dayOfMonth = (int) $moment;if ($start->day > $dayOfMonth) {// day has passed already, add a month.$start->addMonth();@@ -113,7 +113,7 @@ trait CalculateRangeOccurrencesapp('log')->debug('Rep is weekly.');// monday = 1// sunday = 7- $dayOfWeek = (int)$moment;+ $dayOfWeek = (int) $moment;app('log')->debug(sprintf('DoW in repetition is %d, in mutator is %d', $dayOfWeek, $start->dayOfWeekIso));if ($start->dayOfWeekIso > $dayOfWeek) {// day has already passed this week, add one week:diff --git a/app/Support/Repositories/Recurring/CalculateXOccurrences.php b/app/Support/Repositories/Recurring/CalculateXOccurrences.phpindex f31171810f..04f07046d4 100644--- a/app/Support/Repositories/Recurring/CalculateXOccurrences.php+++ b/app/Support/Repositories/Recurring/CalculateXOccurrences.php@@ -63,7 +63,7 @@ trait CalculateXOccurrences$mutator = clone $date;$total = 0;$attempts = 0;- $dayOfMonth = (int)$moment;+ $dayOfMonth = (int) $moment;if ($mutator->day > $dayOfMonth) {// day has passed already, add a month.$mutator->addMonth();@@ -127,7 +127,7 @@ trait CalculateXOccurrences// monday = 1// sunday = 7$mutator->addDay(); // always assume today has passed.- $dayOfWeek = (int)$moment;+ $dayOfWeek = (int) $moment;if ($mutator->dayOfWeekIso > $dayOfWeek) {// day has already passed this week, add one week:$mutator->addWeek();diff --git a/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php b/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.phpindex 4b766a0f47..45a246f9cc 100644--- a/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php+++ b/app/Support/Repositories/Recurring/CalculateXOccurrencesSince.php@@ -67,7 +67,7 @@ trait CalculateXOccurrencesSince$mutator = clone $date;$total = 0;$attempts = 0;- $dayOfMonth = (int)$moment;+ $dayOfMonth = (int) $moment;$dayOfMonth = 0 === $dayOfMonth ? 1 : $dayOfMonth;if ($mutator->day > $dayOfMonth) {app('log')->debug(sprintf('%d is after %d, add a month. Mutator is now', $mutator->day, $dayOfMonth));@@ -143,7 +143,7 @@ trait CalculateXOccurrencesSince// sunday = 7// Removed assumption today has passed, see issue https://github.com/firefly-iii/firefly-iii/issues/4798// $mutator->addDay(); // always assume today has passed.- $dayOfWeek = (int)$moment;+ $dayOfWeek = (int) $moment;if ($mutator->dayOfWeekIso > $dayOfWeek) {// day has already passed this week, add one week:$mutator->addWeek();diff --git a/app/Support/Request/AppendsLocationData.php b/app/Support/Request/AppendsLocationData.phpindex c1cffa5e5d..4329f865bb 100644--- a/app/Support/Request/AppendsLocationData.php+++ b/app/Support/Request/AppendsLocationData.php@@ -48,14 +48,14 @@ trait AppendsLocationDataprivate function validLongitude(string $longitude): bool{- $number = (float)$longitude;+ $number = (float) $longitude;return $number >= -180 && $number <= 180;}private function validLatitude(string $latitude): bool{- $number = (float)$latitude;+ $number = (float) $latitude;return $number >= -90 && $number <= 90;}diff --git a/app/Support/Request/ChecksLogin.php b/app/Support/Request/ChecksLogin.phpindex 0f9753ee62..9fd2e11883 100644--- a/app/Support/Request/ChecksLogin.php+++ b/app/Support/Request/ChecksLogin.php@@ -86,10 +86,10 @@ trait ChecksLogin$userGroup = $this->route()?->parameter('userGroup');if (null === $userGroup) {app('log')->debug('Request class has no userGroup parameter, but perhaps there is a parameter.');- $userGroupId = (int)$this->get('user_group_id');+ $userGroupId = (int) $this->get('user_group_id');if (0 === $userGroupId) {app('log')->debug(sprintf('Request class has no user_group_id parameter, grab default from user (group #%d).', $user->user_group_id));- $userGroupId = (int)$user->user_group_id;+ $userGroupId = (int) $user->user_group_id;}$userGroup = UserGroup::find($userGroupId);if (null === $userGroup) {diff --git a/app/Support/Request/ConvertsDataTypes.php b/app/Support/Request/ConvertsDataTypes.phpindex ecca196381..14a6aef79d 100644--- a/app/Support/Request/ConvertsDataTypes.php+++ b/app/Support/Request/ConvertsDataTypes.php@@ -89,19 +89,17 @@ trait ConvertsDataTypes"\r", // carriage return];- /**- * Return integer value.- */- public function convertInteger(string $field): int+ public function clearIban(?string $string): ?string{- return (int)$this->get($field);+ $string = $this->clearString($string);++ return Steam::filterSpaces($string);}- /**- * Abstract method that always exists in the Request classes that use this- * trait, OR a stub needs to be added by any other class that uses this train.- */- abstract public function get(string $key, mixed $default = null): mixed;+ public function convertIban(string $field): string+ {+ return Steam::filterSpaces($this->convertString($field));+ }/*** Return string value.@@ -113,12 +111,7 @@ trait ConvertsDataTypesreturn $default;}- return (string)$this->clearString((string)$entry);- }-- public function convertIban(string $field): string- {- return Steam::filterSpaces($this->convertString($field));+ return (string) $this->clearString((string) $entry);}public function clearString(?string $string): ?string@@ -138,13 +131,6 @@ trait ConvertsDataTypesreturn trim($string);}- public function clearIban(?string $string): ?string- {- $string = $this->clearString($string);-- return Steam::filterSpaces($string);- }-public function clearStringKeepNewlines(?string $string): ?string{if (null === $string) {@@ -158,9 +144,23 @@ trait ConvertsDataTypes// clear zalgo text (TODO also in API v2)$string = preg_replace('/(\pM{2})\pM+/u', '\1', $string);- return trim((string)$string);+ return trim((string) $string);}+ /**+ * Return integer value.+ */+ public function convertInteger(string $field): int+ {+ return (int) $this->get($field);+ }++ /**+ * Abstract method that always exists in the Request classes that use this+ * trait, OR a stub needs to be added by any other class that uses this train.+ */+ abstract public function get(string $key, mixed $default = null): mixed;+/*** TODO duplicate, see SelectTransactionsRequest*@@ -183,7 +183,7 @@ trait ConvertsDataTypes$collection = new Collection();if (is_array($set)) {foreach ($set as $accountId) {- $account = $repository->find((int)$accountId);+ $account = $repository->find((int) $accountId);if (null !== $account) {$collection->push($account);}@@ -198,7 +198,7 @@ trait ConvertsDataTypes*/public function stringWithNewlines(string $field): string{- return (string)$this->clearStringKeepNewlines((string)($this->get($field) ?? ''));+ return (string) $this->clearStringKeepNewlines((string) ($this->get($field) ?? ''));}/**@@ -242,7 +242,7 @@ trait ConvertsDataTypesprotected function convertDateTime(?string $string): ?Carbon{- $value = $this->get((string)$string);+ $value = $this->get((string) $string);if (null === $value) {return null;}@@ -297,7 +297,7 @@ trait ConvertsDataTypesreturn null;}- return (float)$res;+ return (float) $res;}protected function dateFromValue(?string $string): ?Carbon@@ -360,7 +360,7 @@ trait ConvertsDataTypes$result = null;try {- $result = '' !== (string)$this->get($field) ? new Carbon((string)$this->get($field), config('app.timezone')) : null;+ $result = '' !== (string) $this->get($field) ? new Carbon((string) $this->get($field), config('app.timezone')) : null;} catch (InvalidFormatException $e) {// @ignoreException}@@ -383,7 +383,7 @@ trait ConvertsDataTypesreturn null;}- return (int)$string;+ return (int) $string;}/**@@ -395,11 +395,11 @@ trait ConvertsDataTypesreturn null;}- $value = (string)$this->get($field);+ $value = (string) $this->get($field);if ('' === $value) {return null;}- return (int)$value;+ return (int) $value;}}diff --git a/app/Support/Request/GetRecurrenceData.php b/app/Support/Request/GetRecurrenceData.phpindex 40f23738dd..50dc0cd8f2 100644--- a/app/Support/Request/GetRecurrenceData.php+++ b/app/Support/Request/GetRecurrenceData.php@@ -38,12 +38,12 @@ trait GetRecurrenceDataforeach ($stringKeys as $key) {if (array_key_exists($key, $transaction)) {- $return[$key] = (string)$transaction[$key];+ $return[$key] = (string) $transaction[$key];}}foreach ($intKeys as $key) {if (array_key_exists($key, $transaction)) {- $return[$key] = (int)$transaction[$key];+ $return[$key] = (int) $transaction[$key];}}foreach ($keys as $key) {diff --git a/app/Support/Search/AccountSearch.php b/app/Support/Search/AccountSearch.phpindex 1cdc88e430..6ff1a42d0c 100644--- a/app/Support/Search/AccountSearch.php+++ b/app/Support/Search/AccountSearch.php@@ -90,7 +90,7 @@ class AccountSearch implements GenericSearchInterfacebreak;case self::SEARCH_ID:- $searchQuery->where('accounts.id', '=', (int)$originalQuery);+ $searchQuery->where('accounts.id', '=', (int) $originalQuery);break;diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.phpindex aa69994a8e..48d0739a14 100644--- a/app/Support/Search/OperatorQuerySearch.php+++ b/app/Support/Search/OperatorQuerySearch.php@@ -201,7 +201,7 @@ class OperatorQuerySearch implements SearchInterfacecase Emoticon::class:case Emoji::class:case Mention::class:- $allWords = (string)$searchNode->getValue();+ $allWords = (string) $searchNode->getValue();app('log')->debug(sprintf('Add words "%s" to search string, because Node class is "%s"', $allWords, $class));$this->words[] = $allWords;@@ -231,11 +231,11 @@ class OperatorQuerySearch implements SearchInterface// must be valid operator:if (in_array($operator, $this->validOperators, true)- && $this->updateCollector($operator, (string)$value, $prohibited)) {+ && $this->updateCollector($operator, (string) $value, $prohibited)) {$this->operators->push(['type' => self::getRootOperator($operator),- 'value' => (string)$value,+ 'value' => (string) $value,'prohibited' => $prohibited,]);@@ -245,7 +245,7 @@ class OperatorQuerySearch implements SearchInterfaceapp('log')->debug(sprintf('Added INVALID operator type "%s"', $operator));$this->invalidOperators[] = ['type' => $operator,- 'value' => (string)$value,+ 'value' => (string) $value,];}}@@ -445,7 +445,7 @@ class OperatorQuerySearch implements SearchInterfacebreak;case 'source_account_id':- $account = $this->accountRepository->find((int)$value);+ $account = $this->accountRepository->find((int) $value);if (null !== $account) {$this->collector->setSourceAccounts(new Collection([$account]));}@@ -457,7 +457,7 @@ class OperatorQuerySearch implements SearchInterfacebreak;case '-source_account_id':- $account = $this->accountRepository->find((int)$value);+ $account = $this->accountRepository->find((int) $value);if (null !== $account) {$this->collector->excludeSourceAccounts(new Collection([$account]));}@@ -573,7 +573,7 @@ class OperatorQuerySearch implements SearchInterfacebreak;case 'destination_account_id':- $account = $this->accountRepository->find((int)$value);+ $account = $this->accountRepository->find((int) $value);if (null !== $account) {$this->collector->setDestinationAccounts(new Collection([$account]));}@@ -584,7 +584,7 @@ class OperatorQuerySearch implements SearchInterfacebreak;case '-destination_account_id':- $account = $this->accountRepository->find((int)$value);+ $account = $this->accountRepository->find((int) $value);if (null !== $account) {$this->collector->excludeDestinationAccounts(new Collection([$account]));}@@ -598,7 +598,7 @@ class OperatorQuerySearch implements SearchInterface$parts = explode(',', $value);$collection = new Collection();foreach ($parts as $accountId) {- $account = $this->accountRepository->find((int)$accountId);+ $account = $this->accountRepository->find((int) $accountId);if (null !== $account) {$collection->push($account);}@@ -616,7 +616,7 @@ class OperatorQuerySearch implements SearchInterface$parts = explode(',', $value);$collection = new Collection();foreach ($parts as $accountId) {- $account = $this->accountRepository->find((int)$accountId);+ $account = $this->accountRepository->find((int) $accountId);if (null !== $account) {$collection->push($account);}@@ -2003,7 +2003,7 @@ class OperatorQuerySearch implements SearchInterface$filtered = $accounts->filter(static function (Account $account) use ($value, $stringMethod) {// either IBAN or account number- $ibanMatch = $stringMethod(strtolower((string)$account->iban), strtolower($value));+ $ibanMatch = $stringMethod(strtolower((string) $account->iban), strtolower($value));$accountNrMatch = false;/** @var AccountMeta $meta */@@ -2777,7 +2777,7 @@ class OperatorQuerySearch implements SearchInterface$this->collector->setUser($user);$this->collector->withAccountInformation()->withCategoryInformation()->withBudgetInformation();- $this->setLimit((int)app('preferences')->getForUser($user, 'listPageSize', 50)->data);+ $this->setLimit((int) app('preferences')->getForUser($user, 'listPageSize', 50)->data);}public function setLimit(int $limit): voiddiff --git a/app/Support/Steam.php b/app/Support/Steam.phpindex 1ecd94e121..c84e67b28a 100644--- a/app/Support/Steam.php+++ b/app/Support/Steam.php@@ -39,6 +39,276 @@ use Illuminate\Support\Facades\Log;*/class Steam{+ public function balanceByTransactions(Account $account, Carbon $date, ?TransactionCurrency $currency): array+ {+ $cache = new CacheProperties();+ $cache->addProperty($account->id);+ $cache->addProperty('balance-by-transactions');+ $cache->addProperty($date);+ $cache->addProperty(null !== $currency ? $currency->id : 0);+ if ($cache->has()) {+ return $cache->get();+ }++ $query = $account->transactions()+ ->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')+ ->orderBy('transaction_journals.date', 'desc')+ ->orderBy('transaction_journals.order', 'asc')+ ->orderBy('transaction_journals.description', 'desc')+ ->orderBy('transactions.amount', 'desc')+ ;+ if (null !== $currency) {+ $query->where('transactions.transaction_currency_id', $currency->id);+ $query->limit(1);+ $result = $query->get(['transactions.transaction_currency_id', 'transactions.balance_after'])->first();+ $key = (int) $result->transaction_currency_id;+ $return = [$key => $result->balance_after];+ $cache->store($return);++ return $return;+ }++ $return = [];+ $result = $query->get(['transactions.transaction_currency_id', 'transactions.balance_after']);+ foreach ($result as $entry) {+ $key = (int) $entry->transaction_currency_id;+ if (array_key_exists($key, $return)) {+ continue;+ }+ $return[$key] = $entry->balance_after;+ }++ return $return;+ }++ public function balanceConvertedIgnoreVirtual(Account $account, Carbon $date, TransactionCurrency $currency): string+ {+ $balance = $this->balanceConverted($account, $date, $currency);+ $virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;++ // currency of account+ $repository = app(AccountRepositoryInterface::class);+ $repository->setUser($account->user);+ $accountCurrency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);+ if ($accountCurrency->id !== $currency->id && 0 !== bccomp($virtual, '0')) {+ // convert amount to given currency.+ Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));+ $converter = new ExchangeRateConverter();+ $virtual = $converter->convert($accountCurrency, $currency, $date, $virtual);+ }++ return bcsub($balance, $virtual);+ }++ /**+ * selection of transactions+ * 1: all normal transactions. No foreign currency info. In $currency. Need conversion.+ * 2: all normal transactions. No foreign currency info. In $native. Need NO conversion.+ * 3: all normal transactions. No foreign currency info. In neither currency. Need conversion.+ * Then, select everything with foreign currency info:+ * 4. All transactions with foreign currency info in $native. Normal currency value is ignored. Do not need+ * conversion.+ * 5. All transactions with foreign currency info NOT in $native, but currency info in $currency. Need conversion.+ * 6. All transactions with foreign currency info NOT in $native, and currency info NOT in $currency. Need+ * conversion.+ *+ * Gets balance at the end of current month by default. Returns the balance converted+ * to the indicated currency ($native).+ *+ * @throws FireflyException+ *+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)+ */+ public function balanceConverted(Account $account, Carbon $date, TransactionCurrency $native): string+ {+ // Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));+ Log::debug(sprintf('Now in balanceConverted (%s) for account #%d, converting to %s', $date->format('Y-m-d'), $account->id, $native->code));+ $cache = new CacheProperties();+ $cache->addProperty($account->id);+ $cache->addProperty('balance');+ $cache->addProperty($date);+ $cache->addProperty($native->id);+ if ($cache->has()) {+ Log::debug('Cached!');++ return $cache->get();+ }++ /** @var AccountRepositoryInterface $repository */+ $repository = app(AccountRepositoryInterface::class);+ $currency = $repository->getAccountCurrency($account);+ $currency = null === $currency ? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup) : $currency;+ if ($native->id === $currency->id) {+ Log::debug('No conversion necessary!');++ return $this->balance($account, $date);+ }++ $new = [];+ $existing = [];+ $new[] = $account->transactions() // 1+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))+ ->where('transactions.transaction_currency_id', $currency->id)+ ->whereNull('transactions.foreign_currency_id')+ ->get(['transaction_journals.date', 'transactions.amount'])->toArray()+ ;+ Log::debug(sprintf('%d transaction(s) in set #1', count($new[0])));+ $existing[] = $account->transactions() // 2+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))+ ->where('transactions.transaction_currency_id', $native->id)+ ->whereNull('transactions.foreign_currency_id')+ ->get(['transactions.amount'])->toArray()+ ;+ Log::debug(sprintf('%d transaction(s) in set #2', count($existing[0])));+ $new[] = $account->transactions() // 3+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))+ ->where('transactions.transaction_currency_id', '!=', $currency->id)+ ->where('transactions.transaction_currency_id', '!=', $native->id)+ ->whereNull('transactions.foreign_currency_id')+ ->get(['transaction_journals.date', 'transactions.amount'])->toArray()+ ;+ Log::debug(sprintf('%d transactions in set #3', count($new[1])));+ $existing[] = $account->transactions() // 4+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))+ ->where('transactions.foreign_currency_id', $native->id)+ ->whereNotNull('transactions.foreign_amount')+ ->get(['transactions.foreign_amount'])->toArray()+ ;+ Log::debug(sprintf('%d transactions in set #4', count($existing[1])));+ $new[] = $account->transactions()// 5+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))+ ->where('transactions.transaction_currency_id', $currency->id)+ ->where('transactions.foreign_currency_id', '!=', $native->id)+ ->whereNotNull('transactions.foreign_amount')+ ->get(['transaction_journals.date', 'transactions.amount'])->toArray()+ ;+ Log::debug(sprintf('%d transactions in set #5', count($new[2])));+ $new[] = $account->transactions()// 6+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))+ ->where('transactions.transaction_currency_id', '!=', $currency->id)+ ->where('transactions.foreign_currency_id', '!=', $native->id)+ ->whereNotNull('transactions.foreign_amount')+ ->get(['transaction_journals.date', 'transactions.amount'])->toArray()+ ;+ Log::debug(sprintf('%d transactions in set #6', count($new[3])));++ // process both sets of transactions. Of course, no need to convert set "existing".+ $balance = $this->sumTransactions($existing[0], 'amount');+ $balance = bcadd($balance, $this->sumTransactions($existing[1], 'foreign_amount'));+ Log::debug(sprintf('Balance from set #2 and #4 is %f', $balance));++ // need to convert the others. All sets use the "amount" value as their base (that's easy)+ // but we need to convert each transaction separately because the date difference may+ // incur huge currency changes.+ Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));+ $start = clone $date;+ $end = clone $date;+ $converter = new ExchangeRateConverter();+ foreach ($new as $set) {+ foreach ($set as $transaction) {+ $currentDate = false;++ try {+ $currentDate = Carbon::parse($transaction['date'], config('app.timezone'));+ } catch (InvalidFormatException $e) {+ Log::error(sprintf('Could not parse date "%s" in %s', $transaction['date'], __METHOD__));+ }+ if (false === $currentDate) {+ $currentDate = today(config('app.timezone'));+ }+ if ($currentDate->lte($start)) {+ $start = clone $currentDate;+ }+ }+ }+ unset($currentDate);+ $converter->prepare($currency, $native, $start, $end);++ foreach ($new as $set) {+ foreach ($set as $transaction) {+ $currentDate = false;++ try {+ $currentDate = Carbon::parse($transaction['date'], config('app.timezone'));+ } catch (InvalidFormatException $e) {+ Log::error(sprintf('Could not parse date "%s" in %s', $transaction['date'], __METHOD__));+ }+ if (false === $currentDate) {+ $currentDate = today(config('app.timezone'));+ }+ $rate = $converter->getCurrencyRate($currency, $native, $currentDate);+ $convertedAmount = bcmul($transaction['amount'], $rate);+ $balance = bcadd($balance, $convertedAmount);+ }+ }++ // add virtual balance (also needs conversion)+ $virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;+ $virtual = $converter->convert($currency, $native, $account->created_at, $virtual);+ $balance = bcadd($balance, $virtual);+ $converter->summarize();++ $cache->store($balance);+ $converter->summarize();++ return $balance;+ }++ /**+ * Gets balance at the end of current month by default+ *+ * @throws FireflyException+ */+ public function balance(Account $account, Carbon $date, ?TransactionCurrency $currency = null): string+ {+ // Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));+ // abuse chart properties:+ $cache = new CacheProperties();+ $cache->addProperty($account->id);+ $cache->addProperty('balance');+ $cache->addProperty($date);+ $cache->addProperty(null !== $currency ? $currency->id : 0);+ if ($cache->has()) {+ return $cache->get();+ }++ /** @var AccountRepositoryInterface $repository */+ $repository = app(AccountRepositoryInterface::class);+ if (null === $currency) {+ $currency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);+ }+ // first part: get all balances in own currency:+ $transactions = $account->transactions()+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))+ ->where('transactions.transaction_currency_id', $currency->id)+ ->get(['transactions.amount'])->toArray()+ ;+ $nativeBalance = $this->sumTransactions($transactions, 'amount');+ // get all balances in foreign currency:+ $transactions = $account->transactions()+ ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))+ ->where('transactions.foreign_currency_id', $currency->id)+ ->where('transactions.transaction_currency_id', '!=', $currency->id)+ ->get(['transactions.foreign_amount'])->toArray()+ ;+ $foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');+ $balance = bcadd($nativeBalance, $foreignBalance);+ $virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;+ $balance = bcadd($balance, $virtual);++ $cache->store($balance);++ return $balance;+ }+/*** @deprecated*/@@ -66,30 +336,11 @@ class Steam->where('transactions.foreign_currency_id', $currencyId)->where('transactions.transaction_currency_id', '!=', $currencyId)->get(['transactions.foreign_amount'])->toArray()- ;-- $foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');-- return bcadd($nativeBalance, $foreignBalance);- }-- public function balanceConvertedIgnoreVirtual(Account $account, Carbon $date, TransactionCurrency $currency): string- {- $balance = $this->balanceConverted($account, $date, $currency);- $virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;-- // currency of account- $repository = app(AccountRepositoryInterface::class);- $repository->setUser($account->user);- $accountCurrency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);- if ($accountCurrency->id !== $currency->id && 0 !== bccomp($virtual, '0')) {- // convert amount to given currency.- Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));- $converter = new ExchangeRateConverter();- $virtual = $converter->convert($accountCurrency, $currency, $date, $virtual);- }+ ;- return bcsub($balance, $virtual);+ $foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');++ return bcadd($nativeBalance, $foreignBalance);}public function sumTransactions(array $transactions, string $key): string@@ -191,97 +442,6 @@ class Steamreturn $balances;}- public function balanceByTransactions(Account $account, Carbon $date, ?TransactionCurrency $currency): array- {- $cache = new CacheProperties();- $cache->addProperty($account->id);- $cache->addProperty('balance-by-transactions');- $cache->addProperty($date);- $cache->addProperty(null !== $currency ? $currency->id : 0);- if ($cache->has()) {- return $cache->get();- }-- $query = $account->transactions()- ->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->orderBy('transaction_journals.date', 'desc')- ->orderBy('transaction_journals.order', 'asc')- ->orderBy('transaction_journals.description', 'desc')- ->orderBy('transactions.amount', 'desc')- ;- if (null !== $currency) {- $query->where('transactions.transaction_currency_id', $currency->id);- $query->limit(1);- $result = $query->get(['transactions.transaction_currency_id', 'transactions.balance_after'])->first();- $key = (int) $result->transaction_currency_id;- $return = [$key => $result->balance_after];- $cache->store($return);-- return $return;- }-- $return = [];- $result = $query->get(['transactions.transaction_currency_id', 'transactions.balance_after']);- foreach ($result as $entry) {- $key = (int) $entry->transaction_currency_id;- if (array_key_exists($key, $return)) {- continue;- }- $return[$key] = $entry->balance_after;- }-- return $return;- }-- /**- * Gets balance at the end of current month by default- *- * @throws FireflyException- */- public function balance(Account $account, Carbon $date, ?TransactionCurrency $currency = null): string- {- // Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));- // abuse chart properties:- $cache = new CacheProperties();- $cache->addProperty($account->id);- $cache->addProperty('balance');- $cache->addProperty($date);- $cache->addProperty(null !== $currency ? $currency->id : 0);- if ($cache->has()) {- return $cache->get();- }-- /** @var AccountRepositoryInterface $repository */- $repository = app(AccountRepositoryInterface::class);- if (null === $currency) {- $currency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);- }- // first part: get all balances in own currency:- $transactions = $account->transactions()- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))- ->where('transactions.transaction_currency_id', $currency->id)- ->get(['transactions.amount'])->toArray()- ;- $nativeBalance = $this->sumTransactions($transactions, 'amount');- // get all balances in foreign currency:- $transactions = $account->transactions()- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))- ->where('transactions.foreign_currency_id', $currency->id)- ->where('transactions.transaction_currency_id', '!=', $currency->id)- ->get(['transactions.foreign_amount'])->toArray()- ;- $foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');- $balance = bcadd($nativeBalance, $foreignBalance);- $virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;- $balance = bcadd($balance, $virtual);-- $cache->store($balance);-- return $balance;- }-/*** @throws FireflyException*@@ -394,166 +554,6 @@ class Steamreturn $balances;}- /**- * selection of transactions- * 1: all normal transactions. No foreign currency info. In $currency. Need conversion.- * 2: all normal transactions. No foreign currency info. In $native. Need NO conversion.- * 3: all normal transactions. No foreign currency info. In neither currency. Need conversion.- * Then, select everything with foreign currency info:- * 4. All transactions with foreign currency info in $native. Normal currency value is ignored. Do not need- * conversion.- * 5. All transactions with foreign currency info NOT in $native, but currency info in $currency. Need conversion.- * 6. All transactions with foreign currency info NOT in $native, and currency info NOT in $currency. Need- * conversion.- *- * Gets balance at the end of current month by default. Returns the balance converted- * to the indicated currency ($native).- *- * @throws FireflyException- *- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)- */- public function balanceConverted(Account $account, Carbon $date, TransactionCurrency $native): string- {- // Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));- Log::debug(sprintf('Now in balanceConverted (%s) for account #%d, converting to %s', $date->format('Y-m-d'), $account->id, $native->code));- $cache = new CacheProperties();- $cache->addProperty($account->id);- $cache->addProperty('balance');- $cache->addProperty($date);- $cache->addProperty($native->id);- if ($cache->has()) {- Log::debug('Cached!');-- return $cache->get();- }-- /** @var AccountRepositoryInterface $repository */- $repository = app(AccountRepositoryInterface::class);- $currency = $repository->getAccountCurrency($account);- $currency = null === $currency ? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup) : $currency;- if ($native->id === $currency->id) {- Log::debug('No conversion necessary!');-- return $this->balance($account, $date);- }-- $new = [];- $existing = [];- $new[] = $account->transactions() // 1- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))- ->where('transactions.transaction_currency_id', $currency->id)- ->whereNull('transactions.foreign_currency_id')- ->get(['transaction_journals.date', 'transactions.amount'])->toArray()- ;- Log::debug(sprintf('%d transaction(s) in set #1', count($new[0])));- $existing[] = $account->transactions() // 2- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))- ->where('transactions.transaction_currency_id', $native->id)- ->whereNull('transactions.foreign_currency_id')- ->get(['transactions.amount'])->toArray()- ;- Log::debug(sprintf('%d transaction(s) in set #2', count($existing[0])));- $new[] = $account->transactions() // 3- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))- ->where('transactions.transaction_currency_id', '!=', $currency->id)- ->where('transactions.transaction_currency_id', '!=', $native->id)- ->whereNull('transactions.foreign_currency_id')- ->get(['transaction_journals.date', 'transactions.amount'])->toArray()- ;- Log::debug(sprintf('%d transactions in set #3', count($new[1])));- $existing[] = $account->transactions() // 4- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))- ->where('transactions.foreign_currency_id', $native->id)- ->whereNotNull('transactions.foreign_amount')- ->get(['transactions.foreign_amount'])->toArray()- ;- Log::debug(sprintf('%d transactions in set #4', count($existing[1])));- $new[] = $account->transactions()// 5- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))- ->where('transactions.transaction_currency_id', $currency->id)- ->where('transactions.foreign_currency_id', '!=', $native->id)- ->whereNotNull('transactions.foreign_amount')- ->get(['transaction_journals.date', 'transactions.amount'])->toArray()- ;- Log::debug(sprintf('%d transactions in set #5', count($new[2])));- $new[] = $account->transactions()// 6- ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))- ->where('transactions.transaction_currency_id', '!=', $currency->id)- ->where('transactions.foreign_currency_id', '!=', $native->id)- ->whereNotNull('transactions.foreign_amount')- ->get(['transaction_journals.date', 'transactions.amount'])->toArray()- ;- Log::debug(sprintf('%d transactions in set #6', count($new[3])));-- // process both sets of transactions. Of course, no need to convert set "existing".- $balance = $this->sumTransactions($existing[0], 'amount');- $balance = bcadd($balance, $this->sumTransactions($existing[1], 'foreign_amount'));- Log::debug(sprintf('Balance from set #2 and #4 is %f', $balance));-- // need to convert the others. All sets use the "amount" value as their base (that's easy)- // but we need to convert each transaction separately because the date difference may- // incur huge currency changes.- Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));- $start = clone $date;- $end = clone $date;- $converter = new ExchangeRateConverter();- foreach ($new as $set) {- foreach ($set as $transaction) {- $currentDate = false;-- try {- $currentDate = Carbon::parse($transaction['date'], config('app.timezone'));- } catch (InvalidFormatException $e) {- Log::error(sprintf('Could not parse date "%s" in %s', $transaction['date'], __METHOD__));- }- if (false === $currentDate) {- $currentDate = today(config('app.timezone'));- }- if ($currentDate->lte($start)) {- $start = clone $currentDate;- }- }- }- unset($currentDate);- $converter->prepare($currency, $native, $start, $end);-- foreach ($new as $set) {- foreach ($set as $transaction) {- $currentDate = false;-- try {- $currentDate = Carbon::parse($transaction['date'], config('app.timezone'));- } catch (InvalidFormatException $e) {- Log::error(sprintf('Could not parse date "%s" in %s', $transaction['date'], __METHOD__));- }- if (false === $currentDate) {- $currentDate = today(config('app.timezone'));- }- $rate = $converter->getCurrencyRate($currency, $native, $currentDate);- $convertedAmount = bcmul($transaction['amount'], $rate);- $balance = bcadd($balance, $convertedAmount);- }- }-- // add virtual balance (also needs conversion)- $virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;- $virtual = $converter->convert($currency, $native, $account->created_at, $virtual);- $balance = bcadd($balance, $virtual);- $converter->summarize();-- $cache->store($balance);- $converter->summarize();-- return $balance;- }-/*** This method always ignores the virtual balance.*diff --git a/app/Support/System/GeneratesInstallationId.php b/app/Support/System/GeneratesInstallationId.phpindex bd017f4f5a..e3dde0e793 100644--- a/app/Support/System/GeneratesInstallationId.php+++ b/app/Support/System/GeneratesInstallationId.php@@ -49,7 +49,7 @@ trait GeneratesInstallationIdif (null === $config) {$uuid4 = Uuid::uuid4();- $uniqueId = (string)$uuid4;+ $uniqueId = (string) $uuid4;app('log')->info(sprintf('Created Firefly III installation ID %s', $uniqueId));app('fireflyconfig')->set('installation_id', $uniqueId);}diff --git a/app/Support/System/OAuthKeys.php b/app/Support/System/OAuthKeys.phpindex 5a7501dd03..641a561f7a 100644--- a/app/Support/System/OAuthKeys.php+++ b/app/Support/System/OAuthKeys.php@@ -63,8 +63,8 @@ class OAuthKeys// better check if keys are in the database:if (app('fireflyconfig')->has(self::PRIVATE_KEY) && app('fireflyconfig')->has(self::PUBLIC_KEY)) {try {- $privateKey = (string)app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;- $publicKey = (string)app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;+ $privateKey = (string) app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;+ $publicKey = (string) app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;} catch (ContainerExceptionInterface|FireflyException|NotFoundExceptionInterface $e) {app('log')->error(sprintf('Could not validate keysInDatabase(): %s', $e->getMessage()));app('log')->error($e->getTraceAsString());@@ -104,8 +104,8 @@ class OAuthKeys*/public static function restoreKeysFromDB(): bool{- $privateKey = (string)app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;- $publicKey = (string)app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;+ $privateKey = (string) app('fireflyconfig')->get(self::PRIVATE_KEY)?->data;+ $publicKey = (string) app('fireflyconfig')->get(self::PUBLIC_KEY)?->data;try {$privateContent = \Crypt::decrypt($privateKey);diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.phpindex 4568cf7fbc..0a30779bb0 100644--- a/app/Support/Twig/General.php+++ b/app/Support/Twig/General.php@@ -29,6 +29,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\User\UserRepositoryInterface;use FireflyIII\Support\Search\OperatorQuerySearch;use League\CommonMark\GithubFlavoredMarkdownConverter;+use Route;use Twig\Extension\AbstractExtension;use Twig\TwigFilter;use Twig\TwigFunction;diff --git a/app/Support/Twig/Rule.php b/app/Support/Twig/Rule.phpindex 88b28da4ec..42ef0f6ff9 100644--- a/app/Support/Twig/Rule.php+++ b/app/Support/Twig/Rule.php@@ -46,9 +46,9 @@ class Rule extends AbstractExtension'allJournalTriggers',static function () {return [- 'store-journal' => (string)trans('firefly.rule_trigger_store_journal'),- 'update-journal' => (string)trans('firefly.rule_trigger_update_journal'),- 'manual-activation' => (string)trans('firefly.rule_trigger_manual'),+ 'store-journal' => (string) trans('firefly.rule_trigger_store_journal'),+ 'update-journal' => (string) trans('firefly.rule_trigger_update_journal'),+ 'manual-activation' => (string) trans('firefly.rule_trigger_manual'),];});@@ -63,7 +63,7 @@ class Rule extends AbstractExtension$possibleTriggers = [];foreach ($ruleTriggers as $key) {if ('user_action' !== $key) {- $possibleTriggers[$key] = (string)trans('firefly.rule_trigger_'.$key.'_choice');+ $possibleTriggers[$key] = (string) trans('firefly.rule_trigger_'.$key.'_choice');}}unset($ruleTriggers);@@ -83,7 +83,7 @@ class Rule extends AbstractExtension$ruleActions = array_keys(\Config::get('firefly.rule-actions'));$possibleActions = [];foreach ($ruleActions as $key) {- $possibleActions[$key] = (string)trans('firefly.rule_action_'.$key.'_choice');+ $possibleActions[$key] = (string) trans('firefly.rule_action_'.$key.'_choice');}unset($ruleActions);asort($possibleActions);diff --git a/app/Support/Twig/TransactionGroupTwig.php b/app/Support/Twig/TransactionGroupTwig.phpindex dc4cd7812a..4f13658810 100644--- a/app/Support/Twig/TransactionGroupTwig.php+++ b/app/Support/Twig/TransactionGroupTwig.php@@ -86,7 +86,7 @@ class TransactionGroupTwig extends AbstractExtension$colored = false;}- $result = app('amount')->formatFlat($array['currency_symbol'], (int)$array['currency_decimal_places'], $amount, $colored);+ $result = app('amount')->formatFlat($array['currency_symbol'], (int) $array['currency_decimal_places'], $amount, $colored);if (TransactionType::TRANSFER === $type) {$result = sprintf('<span class="text-info money-transfer">%s</span>', $result);}@@ -129,7 +129,7 @@ class TransactionGroupTwig extends AbstractExtensionif (TransactionType::TRANSFER === $type) {$colored = false;}- $result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int)$array['foreign_currency_decimal_places'], $amount, $colored);+ $result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int) $array['foreign_currency_decimal_places'], $amount, $colored);if (TransactionType::TRANSFER === $type) {$result = sprintf('<span class="text-info money-transfer">%s</span>', $result);}diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.phpindex 4167f64c31..706dd74221 100644--- a/app/Support/Twig/Translation.php+++ b/app/Support/Twig/Translation.php@@ -38,7 +38,7 @@ class Translation extends AbstractExtensionnew TwigFilter('_',static function ($name) {- return (string)trans(sprintf('firefly.%s', $name));+ return (string) trans(sprintf('firefly.%s', $name));},['is_safe' => ['html']]),diff --git a/app/TransactionRules/Actions/AppendDescriptionToNotes.php b/app/TransactionRules/Actions/AppendDescriptionToNotes.phpindex ae4c3866fd..5ca9f9214f 100644--- a/app/TransactionRules/Actions/AppendDescriptionToNotes.php+++ b/app/TransactionRules/Actions/AppendDescriptionToNotes.php@@ -57,7 +57,7 @@ class AppendDescriptionToNotes implements ActionInterface$object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']);if (null === $object) {app('log')->error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id']));- event(new RuleActionFailedOnArray($this->action, $journal, (string)trans('rules.journal_other_user')));+ event(new RuleActionFailedOnArray($this->action, $journal, (string) trans('rules.journal_other_user')));return false;}@@ -72,7 +72,7 @@ class AppendDescriptionToNotes implements ActionInterface$note->text = trim(sprintf("%s \n%s", $note->text, $object->description));}if ('' === $note->text) {- $note->text = (string)$object->description;+ $note->text = (string) $object->description;}$after = $note->text;diff --git a/app/TransactionRules/Actions/AppendNotes.php b/app/TransactionRules/Actions/AppendNotes.phpindex a097811ea0..c3f06b8ada 100644--- a/app/TransactionRules/Actions/AppendNotes.php+++ b/app/TransactionRules/Actions/AppendNotes.php@@ -50,13 +50,13 @@ class AppendNotes implements ActionInterfacepublic function actOnArray(array $journal): bool{$this->refreshNotes($journal);- $dbNote = Note::where('noteable_id', (int)$journal['transaction_journal_id'])+ $dbNote = Note::where('noteable_id', (int) $journal['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(['notes.*']);if (null === $dbNote) {$dbNote = new Note();- $dbNote->noteable_id = (int)$journal['transaction_journal_id'];+ $dbNote->noteable_id = (int) $journal['transaction_journal_id'];$dbNote->noteable_type = TransactionJournal::class;$dbNote->text = '';}diff --git a/app/TransactionRules/Actions/AppendNotesToDescription.php b/app/TransactionRules/Actions/AppendNotesToDescription.phpindex 235808f1ce..3402a6e8a8 100644--- a/app/TransactionRules/Actions/AppendNotesToDescription.php+++ b/app/TransactionRules/Actions/AppendNotesToDescription.php@@ -74,7 +74,7 @@ class AppendNotesToDescription implements ActionInterface// only append if there is something to appendif ('' !== $note->text) {$before = $object->description;- $object->description = trim(sprintf('%s %s', $object->description, (string)$this->clearString($note->text)));+ $object->description = trim(sprintf('%s %s', $object->description, (string) $this->clearString($note->text)));$object->save();app('log')->debug(sprintf('Journal description is updated to "%s".', $object->description));diff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.phpindex 7793d60188..b743736468 100644--- a/app/TransactionRules/Actions/ConvertToTransfer.php+++ b/app/TransactionRules/Actions/ConvertToTransfer.php@@ -169,7 +169,7 @@ class ConvertToTransfer implements ActionInterfacereturn '';}- return (string)$journal->transactions()->where('amount', '<', 0)->first()?->account?->accountType?->type;+ return (string) $journal->transactions()->where('amount', '<', 0)->first()?->account?->accountType?->type;}private function getDestinationType(int $journalId): string@@ -182,7 +182,7 @@ class ConvertToTransfer implements ActionInterfacereturn '';}- return (string)$journal->transactions()->where('amount', '>', 0)->first()?->account?->accountType?->type;+ return (string) $journal->transactions()->where('amount', '>', 0)->first()?->account?->accountType?->type;}/**diff --git a/app/TransactionRules/Actions/MoveDescriptionToNotes.php b/app/TransactionRules/Actions/MoveDescriptionToNotes.phpindex be168448f5..6dae68c34d 100644--- a/app/TransactionRules/Actions/MoveDescriptionToNotes.php+++ b/app/TransactionRules/Actions/MoveDescriptionToNotes.php@@ -71,7 +71,7 @@ class MoveDescriptionToNotes implements ActionInterface$object->description = '(no description)';}if ('' === $note->text) {- $note->text = (string)$object->description;+ $note->text = (string) $object->description;$object->description = '(no description)';}$after = $note->text;diff --git a/app/TransactionRules/Actions/MoveNotesToDescription.php b/app/TransactionRules/Actions/MoveNotesToDescription.phpindex 8687d9b614..d073cce16b 100644--- a/app/TransactionRules/Actions/MoveNotesToDescription.php+++ b/app/TransactionRules/Actions/MoveNotesToDescription.php@@ -78,7 +78,7 @@ class MoveNotesToDescription implements ActionInterface}$before = $object->description;$beforeNote = $note->text;- $object->description = (string)$this->clearString($note->text);+ $object->description = (string) $this->clearString($note->text);$object->save();$note->delete();diff --git a/app/TransactionRules/Actions/PrependNotes.php b/app/TransactionRules/Actions/PrependNotes.phpindex f04fe0ffd4..12cdacf466 100644--- a/app/TransactionRules/Actions/PrependNotes.php+++ b/app/TransactionRules/Actions/PrependNotes.php@@ -46,13 +46,13 @@ class PrependNotes implements ActionInterfacepublic function actOnArray(array $journal): bool{- $dbNote = Note::where('noteable_id', (int)$journal['transaction_journal_id'])+ $dbNote = Note::where('noteable_id', (int) $journal['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(['notes.*']);if (null === $dbNote) {$dbNote = new Note();- $dbNote->noteable_id = (int)$journal['transaction_journal_id'];+ $dbNote->noteable_id = (int) $journal['transaction_journal_id'];$dbNote->noteable_type = TransactionJournal::class;$dbNote->text = '';}diff --git a/app/TransactionRules/Actions/SetBudget.php b/app/TransactionRules/Actions/SetBudget.phpindex 067dc93a49..3063efc414 100644--- a/app/TransactionRules/Actions/SetBudget.php+++ b/app/TransactionRules/Actions/SetBudget.php@@ -84,7 +84,7 @@ class SetBudget implements ActionInterface$object = $user->transactionJournals()->find($journal['transaction_journal_id']);$oldBudget = $object->budgets()->first();$oldBudgetName = $oldBudget?->name;- if ((int)$oldBudget?->id === $budget->id) {+ if ((int) $oldBudget?->id === $budget->id) {event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.already_linked_to_budget', ['name' => $budget->name])));return false;diff --git a/app/TransactionRules/Actions/SetCategory.php b/app/TransactionRules/Actions/SetCategory.phpindex 760f0e01d5..edf0176cd0 100644--- a/app/TransactionRules/Actions/SetCategory.php+++ b/app/TransactionRules/Actions/SetCategory.php@@ -88,7 +88,7 @@ class SetCategory implements ActionInterface$object = $user->transactionJournals()->find($journal['transaction_journal_id']);$oldCategory = $object->categories()->first();$oldCategoryName = $oldCategory?->name;- if ((int)$oldCategory?->id === $category->id) {+ if ((int) $oldCategory?->id === $category->id) {// event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.already_linked_to_category', ['name' => $category->name])));return false;diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.phpindex 4b8498de8d..8dd35245bc 100644--- a/app/TransactionRules/Actions/SetDestinationAccount.php+++ b/app/TransactionRules/Actions/SetDestinationAccount.php@@ -57,7 +57,7 @@ class SetDestinationAccount implements ActionInterface$user = User::find($journal['user_id']);/** @var null|TransactionJournal $object */- $object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);+ $object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);$this->repository = app(AccountRepositoryInterface::class);if (null === $object) {diff --git a/app/TransactionRules/Actions/SetDestinationToCashAccount.php b/app/TransactionRules/Actions/SetDestinationToCashAccount.phpindex ac985eb0f1..9ebcef779f 100644--- a/app/TransactionRules/Actions/SetDestinationToCashAccount.php+++ b/app/TransactionRules/Actions/SetDestinationToCashAccount.php@@ -54,7 +54,7 @@ class SetDestinationToCashAccount implements ActionInterface$user = User::find($journal['user_id']);/** @var null|TransactionJournal $object */- $object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);+ $object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);$repository = app(AccountRepositoryInterface::class);if (null === $object) {diff --git a/app/TransactionRules/Actions/SetSourceAccount.php b/app/TransactionRules/Actions/SetSourceAccount.phpindex 9da778d2a6..dd0d5a671f 100644--- a/app/TransactionRules/Actions/SetSourceAccount.php+++ b/app/TransactionRules/Actions/SetSourceAccount.php@@ -57,7 +57,7 @@ class SetSourceAccount implements ActionInterface$user = User::find($journal['user_id']);/** @var null|TransactionJournal $object */- $object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);+ $object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);$this->repository = app(AccountRepositoryInterface::class);if (null === $object) {app('log')->error('Could not find journal.');diff --git a/app/TransactionRules/Actions/SetSourceToCashAccount.php b/app/TransactionRules/Actions/SetSourceToCashAccount.phpindex f011fc3f76..f8e8175320 100644--- a/app/TransactionRules/Actions/SetSourceToCashAccount.php+++ b/app/TransactionRules/Actions/SetSourceToCashAccount.php@@ -54,7 +54,7 @@ class SetSourceToCashAccount implements ActionInterface$user = User::find($journal['user_id']);/** @var null|TransactionJournal $object */- $object = $user->transactionJournals()->find((int)$journal['transaction_journal_id']);+ $object = $user->transactionJournals()->find((int) $journal['transaction_journal_id']);$repository = app(AccountRepositoryInterface::class);if (null === $object) {diff --git a/app/TransactionRules/Actions/UpdatePiggybank.php b/app/TransactionRules/Actions/UpdatePiggybank.phpindex 4cef91a8df..37f4db13a4 100644--- a/app/TransactionRules/Actions/UpdatePiggybank.php+++ b/app/TransactionRules/Actions/UpdatePiggybank.php@@ -114,11 +114,11 @@ class UpdatePiggybank implements ActionInterface'add_to_piggy',null,[- 'currency_symbol' => $journalObj->transactionCurrency->symbol,- 'decimal_places' => $journalObj->transactionCurrency->decimal_places,- 'amount' => $destination->amount,- 'piggy' => $piggyBank->name,- 'piggy_id' => $piggyBank->id,+ 'currency_symbol' => $journalObj->transactionCurrency->symbol,+ 'decimal_places' => $journalObj->transactionCurrency->decimal_places,+ 'amount' => $destination->amount,+ 'piggy' => $piggyBank->name,+ 'piggy_id' => $piggyBank->id,]));diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.phpindex d0c7025ebd..d06a20de72 100644--- a/app/TransactionRules/Engine/SearchRuleEngine.php+++ b/app/TransactionRules/Engine/SearchRuleEngine.php@@ -114,7 +114,7 @@ class SearchRuleEngine implements RuleEngineInterface}// if the trigger needs no context, value is different:- $needsContext = (bool)(config(sprintf('search.operators.%s.needs_context', $contextSearch)) ?? true);+ $needsContext = (bool) (config(sprintf('search.operators.%s.needs_context', $contextSearch)) ?? true);if (false === $needsContext) {app('log')->debug(sprintf('SearchRuleEngine:: add a rule trigger (no context): %s:true', $ruleTrigger->trigger_type));$searchArray[$ruleTrigger->trigger_type][] = 'true';@@ -187,7 +187,7 @@ class SearchRuleEngine implements RuleEngineInterface$journalId = 0;foreach ($array as $triggerName => $values) {if ('journal_id' === $triggerName && is_array($values) && 1 === count($values)) {- $journalId = (int)trim($values[0] ?? '"0"', '"'); // follows format "123".+ $journalId = (int) trim($values[0] ?? '"0"', '"'); // follows format "123".app('log')->debug(sprintf('Found journal ID #%d', $journalId));}}@@ -476,7 +476,7 @@ class SearchRuleEngine implements RuleEngineInterfaceprivate function addNotes(array $transaction): array{$transaction['notes'] = '';- $dbNote = Note::where('noteable_id', (int)$transaction['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(['notes.*']);+ $dbNote = Note::where('noteable_id', (int) $transaction['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(['notes.*']);if (null !== $dbNote) {$transaction['notes'] = $dbNote->text;}diff --git a/app/TransactionRules/Expressions/ActionExpression.php b/app/TransactionRules/Expressions/ActionExpression.phpindex ec73675d1d..fbabc1a3eb 100644--- a/app/TransactionRules/Expressions/ActionExpression.php+++ b/app/TransactionRules/Expressions/ActionExpression.php@@ -144,7 +144,7 @@ class ActionExpression{$result = $this->expressionLanguage->evaluate($expr, $journal);- return (string)$result;+ return (string) $result;}public function evaluate(array $journal): stringdiff --git a/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.php b/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.phpindex 678b54ee2e..f871b3390a 100644--- a/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.php+++ b/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.php@@ -36,7 +36,7 @@ class ActionExpressionLanguageProvider implements ExpressionFunctionProviderInte{$function = function ($arguments, $str): string {if (!is_string($str)) {- return (string)$str;+ return (string) $str;}return strtolower($str.'!');diff --git a/app/TransactionRules/Traits/RefreshNotesTrait.php b/app/TransactionRules/Traits/RefreshNotesTrait.phpindex 37355b9602..a9ab866a8c 100644--- a/app/TransactionRules/Traits/RefreshNotesTrait.php+++ b/app/TransactionRules/Traits/RefreshNotesTrait.php@@ -33,7 +33,7 @@ trait RefreshNotesTraitfinal protected function refreshNotes(array $transaction): array{$transaction['notes'] = '';- $dbNote = Note::where('noteable_id', (int)$transaction['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(['notes.*']);+ $dbNote = Note::where('noteable_id', (int) $transaction['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(['notes.*']);if (null !== $dbNote) {$transaction['notes'] = $dbNote->text;}diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.phpindex 609e26cefc..a411953edf 100644--- a/app/Transformers/AccountTransformer.php+++ b/app/Transformers/AccountTransformer.php@@ -57,8 +57,8 @@ class AccountTransformer extends AbstractTransformer// get account type:$fullType = $account->accountType->type;- $accountType = (string)config(sprintf('firefly.shortNamesByFullName.%s', $fullType));- $liabilityType = (string)config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));+ $accountType = (string) config(sprintf('firefly.shortNamesByFullName.%s', $fullType));+ $liabilityType = (string) config(sprintf('firefly.shortLiabilityNameByFullName.%s', $fullType));$liabilityType = '' === $liabilityType ? null : strtolower($liabilityType);$liabilityDirection = $this->repository->getMetaValue($account, 'liability_direction');@@ -81,7 +81,7 @@ class AccountTransformer extends AbstractTransformerif (null !== $location) {$longitude = $location->longitude;$latitude = $location->latitude;- $zoomLevel = (int)$location->zoom_level;+ $zoomLevel = (int) $location->zoom_level;}// no order for some accounts:@@ -91,7 +91,7 @@ class AccountTransformer extends AbstractTransformer}return [- 'id' => (string)$account->id,+ 'id' => (string) $account->id,'created_at' => $account->created_at->toAtomString(),'updated_at' => $account->updated_at->toAtomString(),'active' => $account->active,@@ -135,7 +135,7 @@ class AccountTransformer extends AbstractTransformerprivate function getAccountRole(Account $account, string $accountType): ?string{$accountRole = $this->repository->getMetaValue($account, 'account_role');- if ('asset' !== $accountType || '' === (string)$accountRole) {+ if ('asset' !== $accountType || '' === (string) $accountRole) {$accountRole = null;}@@ -166,7 +166,7 @@ class AccountTransformer extends AbstractTransformerif (null === $currency) {$currency = app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);}- $currencyId = (string)$currency->id;+ $currencyId = (string) $currency->id;$currencyCode = $currency->code;$decimalPlaces = $currency->decimal_places;$currencySymbol = $currency->symbol;diff --git a/app/Transformers/AttachmentTransformer.php b/app/Transformers/AttachmentTransformer.phpindex 0125c08afc..208487459b 100644--- a/app/Transformers/AttachmentTransformer.php+++ b/app/Transformers/AttachmentTransformer.php@@ -50,10 +50,10 @@ class AttachmentTransformer extends AbstractTransformer$this->repository->setUser($attachment->user);return [- 'id' => (string)$attachment->id,+ 'id' => (string) $attachment->id,'created_at' => $attachment->created_at->toAtomString(),'updated_at' => $attachment->updated_at->toAtomString(),- 'attachable_id' => (string)$attachment->attachable_id,+ 'attachable_id' => (string) $attachment->attachable_id,'attachable_type' => str_replace('FireflyIII\Models\\', '', $attachment->attachable_type),'md5' => $attachment->md5,'filename' => $attachment->filename,@@ -62,7 +62,7 @@ class AttachmentTransformer extends AbstractTransformer'title' => $attachment->title,'notes' => $this->repository->getNoteText($attachment),'mime' => $attachment->mime,- 'size' => (int)$attachment->size,+ 'size' => (int) $attachment->size,'links' => [['rel' => 'self',diff --git a/app/Transformers/AvailableBudgetTransformer.php b/app/Transformers/AvailableBudgetTransformer.phpindex dbbc91b8ee..d58a6bebd6 100644--- a/app/Transformers/AvailableBudgetTransformer.php+++ b/app/Transformers/AvailableBudgetTransformer.php@@ -57,10 +57,10 @@ class AvailableBudgetTransformer extends AbstractTransformer$currency = $availableBudget->transactionCurrency;$data = [- 'id' => (string)$availableBudget->id,+ 'id' => (string) $availableBudget->id,'created_at' => $availableBudget->created_at->toAtomString(),'updated_at' => $availableBudget->updated_at->toAtomString(),- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.phpindex 375a1e6bec..f9a29a79db 100644--- a/app/Transformers/BillTransformer.php+++ b/app/Transformers/BillTransformer.php@@ -142,7 +142,7 @@ class BillTransformer extends AbstractTransformer'id' => $bill->id,'created_at' => $bill->created_at->toAtomString(),'updated_at' => $bill->updated_at->toAtomString(),- 'currency_id' => (string)$bill->transaction_currency_id,+ 'currency_id' => (string) $bill->transaction_currency_id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,@@ -157,7 +157,7 @@ class BillTransformer extends AbstractTransformer'active' => $bill->active,'order' => $bill->order,'notes' => $notes,- 'object_group_id' => null !== $objectGroupId ? (string)$objectGroupId : null,+ 'object_group_id' => null !== $objectGroupId ? (string) $objectGroupId : null,'object_group_order' => $objectGroupOrder,'object_group_title' => $objectGroupTitle,@@ -219,8 +219,8 @@ class BillTransformer extends AbstractTransformer$result = [];foreach ($set as $entry) {$result[] = [- 'transaction_group_id' => (string)$entry->transaction_group_id,- 'transaction_journal_id' => (string)$entry->id,+ 'transaction_group_id' => (string) $entry->transaction_group_id,+ 'transaction_journal_id' => (string) $entry->id,'date' => $entry->date->format('Y-m-d'),'date_object' => $entry->date,];diff --git a/app/Transformers/BudgetTransformer.php b/app/Transformers/BudgetTransformer.phpindex a88a54cc2d..da818c671a 100644--- a/app/Transformers/BudgetTransformer.php+++ b/app/Transformers/BudgetTransformer.php@@ -77,7 +77,7 @@ class BudgetTransformer extends AbstractTransformer];if (null !== $autoBudget) {- $abCurrencyId = (string)$autoBudget->transactionCurrency->id;+ $abCurrencyId = (string) $autoBudget->transactionCurrency->id;$abCurrencyCode = $autoBudget->transactionCurrency->code;$abType = $types[$autoBudget->auto_budget_type];$abAmount = app('steam')->bcround($autoBudget->amount, $autoBudget->transactionCurrency->decimal_places);@@ -85,7 +85,7 @@ class BudgetTransformer extends AbstractTransformer}return [- 'id' => (string)$budget->id,+ 'id' => (string) $budget->id,'created_at' => $budget->created_at->toAtomString(),'updated_at' => $budget->updated_at->toAtomString(),'active' => $budget->active,@@ -111,7 +111,7 @@ class BudgetTransformer extends AbstractTransformer{$return = [];foreach ($array as $data) {- $data['sum'] = app('steam')->bcround($data['sum'], (int)$data['currency_decimal_places']);+ $data['sum'] = app('steam')->bcround($data['sum'], (int) $data['currency_decimal_places']);$return[] = $data;}diff --git a/app/Transformers/CategoryTransformer.php b/app/Transformers/CategoryTransformer.phpindex 64337993e2..bc6fa8f64e 100644--- a/app/Transformers/CategoryTransformer.php+++ b/app/Transformers/CategoryTransformer.php@@ -85,7 +85,7 @@ class CategoryTransformer extends AbstractTransformer{$return = [];foreach ($array as $data) {- $data['sum'] = app('steam')->bcround($data['sum'], (int)$data['currency_decimal_places']);+ $data['sum'] = app('steam')->bcround($data['sum'], (int) $data['currency_decimal_places']);$return[] = $data;}diff --git a/app/Transformers/ObjectGroupTransformer.php b/app/Transformers/ObjectGroupTransformer.phpindex 7fc833fdb0..fa38e1d819 100644--- a/app/Transformers/ObjectGroupTransformer.php+++ b/app/Transformers/ObjectGroupTransformer.php@@ -50,7 +50,7 @@ class ObjectGroupTransformer extends AbstractTransformer$this->repository->setUser($objectGroup->user);return [- 'id' => (string)$objectGroup->id,+ 'id' => (string) $objectGroup->id,'created_at' => $objectGroup->created_at?->toAtomString(),'updated_at' => $objectGroup->updated_at?->toAtomString(),'title' => $objectGroup->title,diff --git a/app/Transformers/PiggyBankEventTransformer.php b/app/Transformers/PiggyBankEventTransformer.phpindex db39d8cb3b..657fb7b560 100644--- a/app/Transformers/PiggyBankEventTransformer.php+++ b/app/Transformers/PiggyBankEventTransformer.php@@ -66,22 +66,22 @@ class PiggyBankEventTransformer extends AbstractTransformer// get associated journal and transaction, if any:$journalId = $event->transaction_journal_id;$groupId = null;- if (0 !== (int)$journalId) {- $groupId = (int)$event->transactionJournal->transaction_group_id;- $journalId = (int)$journalId;+ if (0 !== (int) $journalId) {+ $groupId = (int) $event->transactionJournal->transaction_group_id;+ $journalId = (int) $journalId;}return [- 'id' => (string)$event->id,+ 'id' => (string) $event->id,'created_at' => $event->created_at->toAtomString(),'updated_at' => $event->updated_at->toAtomString(),'amount' => app('steam')->bcround($event->amount, $currency->decimal_places),- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,- 'transaction_journal_id' => null !== $journalId ? (string)$journalId : null,- 'transaction_group_id' => null !== $groupId ? (string)$groupId : null,+ 'transaction_journal_id' => null !== $journalId ? (string) $journalId : null,+ 'transaction_group_id' => null !== $groupId ? (string) $groupId : null,'links' => [['rel' => 'self',diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.phpindex 5739406b8d..8eecfbcf3e 100644--- a/app/Transformers/RecurrenceTransformer.php+++ b/app/Transformers/RecurrenceTransformer.php@@ -74,14 +74,14 @@ class RecurrenceTransformer extends AbstractTransformer$this->budgetRepos->setUser($recurrence->user);app('log')->debug('Set user.');- $shortType = (string)config(sprintf('firefly.transactionTypesToShort.%s', $recurrence->transactionType->type));+ $shortType = (string) config(sprintf('firefly.transactionTypesToShort.%s', $recurrence->transactionType->type));$notes = $this->repository->getNoteText($recurrence);- $reps = 0 === (int)$recurrence->repetitions ? null : (int)$recurrence->repetitions;+ $reps = 0 === (int) $recurrence->repetitions ? null : (int) $recurrence->repetitions;app('log')->debug('Get basic data.');// basic data.return [- 'id' => (string)$recurrence->id,+ 'id' => (string) $recurrence->id,'created_at' => $recurrence->created_at->toAtomString(),'updated_at' => $recurrence->updated_at->toAtomString(),'type' => $shortType,@@ -117,7 +117,7 @@ class RecurrenceTransformer extends AbstractTransformer/** @var RecurrenceRepetition $repetition */foreach ($recurrence->recurrenceRepetitions as $repetition) {$repetitionArray = [- 'id' => (string)$repetition->id,+ 'id' => (string) $repetition->id,'created_at' => $repetition->created_at->toAtomString(),'updated_at' => $repetition->updated_at->toAtomString(),'type' => $repetition->repetition_type,@@ -164,7 +164,7 @@ class RecurrenceTransformer extends AbstractTransformer$foreignCurrencyDp = null;$foreignCurrencyId = null;if (null !== $transaction->foreign_currency_id) {- $foreignCurrencyId = (int)$transaction->foreign_currency_id;+ $foreignCurrencyId = (int) $transaction->foreign_currency_id;$foreignCurrencyCode = $transaction->foreignCurrency->code;$foreignCurrencySymbol = $transaction->foreignCurrency->symbol;$foreignCurrencyDp = $transaction->foreignCurrency->decimal_places;@@ -197,20 +197,20 @@ class RecurrenceTransformer extends AbstractTransformer$foreignAmount = app('steam')->bcround($transaction->foreign_amount, $foreignCurrencyDp);}$transactionArray = [- 'id' => (string)$transaction->id,- 'currency_id' => (string)$transaction->transaction_currency_id,+ 'id' => (string) $transaction->id,+ 'currency_id' => (string) $transaction->transaction_currency_id,'currency_code' => $transaction->transactionCurrency->code,'currency_symbol' => $transaction->transactionCurrency->symbol,'currency_decimal_places' => $transaction->transactionCurrency->decimal_places,- 'foreign_currency_id' => null === $foreignCurrencyId ? null : (string)$foreignCurrencyId,+ 'foreign_currency_id' => null === $foreignCurrencyId ? null : (string) $foreignCurrencyId,'foreign_currency_code' => $foreignCurrencyCode,'foreign_currency_symbol' => $foreignCurrencySymbol,'foreign_currency_decimal_places' => $foreignCurrencyDp,- 'source_id' => (string)$sourceId,+ 'source_id' => (string) $sourceId,'source_name' => $sourceName,'source_iban' => $sourceIban,'source_type' => $sourceType,- 'destination_id' => (string)$destinationId,+ 'destination_id' => (string) $destinationId,'destination_name' => $destinationName,'destination_iban' => $destinationIban,'destination_type' => $destinationType,@@ -255,9 +255,9 @@ class RecurrenceTransformer extends AbstractTransformerthrow new FireflyException(sprintf('Recurrence transformer cant handle field "%s"', $transactionMeta->name));case 'bill_id':- $bill = $this->billRepos->find((int)$transactionMeta->value);+ $bill = $this->billRepos->find((int) $transactionMeta->value);if (null !== $bill) {- $array['bill_id'] = (string)$bill->id;+ $array['bill_id'] = (string) $bill->id;$array['bill_name'] = $bill->name;}@@ -269,18 +269,18 @@ class RecurrenceTransformer extends AbstractTransformerbreak;case 'piggy_bank_id':- $piggy = $this->piggyRepos->find((int)$transactionMeta->value);+ $piggy = $this->piggyRepos->find((int) $transactionMeta->value);if (null !== $piggy) {- $array['piggy_bank_id'] = (string)$piggy->id;+ $array['piggy_bank_id'] = (string) $piggy->id;$array['piggy_bank_name'] = $piggy->name;}break;case 'category_id':- $category = $this->factory->findOrCreate((int)$transactionMeta->value, null);+ $category = $this->factory->findOrCreate((int) $transactionMeta->value, null);if (null !== $category) {- $array['category_id'] = (string)$category->id;+ $array['category_id'] = (string) $category->id;$array['category_name'] = $category->name;}@@ -289,16 +289,16 @@ class RecurrenceTransformer extends AbstractTransformercase 'category_name':$category = $this->factory->findOrCreate(null, $transactionMeta->value);if (null !== $category) {- $array['category_id'] = (string)$category->id;+ $array['category_id'] = (string) $category->id;$array['category_name'] = $category->name;}break;case 'budget_id':- $budget = $this->budgetRepos->find((int)$transactionMeta->value);+ $budget = $this->budgetRepos->find((int) $transactionMeta->value);if (null !== $budget) {- $array['budget_id'] = (string)$budget->id;+ $array['budget_id'] = (string) $budget->id;$array['budget_name'] = $budget->name;}diff --git a/app/Transformers/RuleTransformer.php b/app/Transformers/RuleTransformer.phpindex b98d2e727f..313521ce50 100644--- a/app/Transformers/RuleTransformer.php+++ b/app/Transformers/RuleTransformer.php@@ -55,11 +55,11 @@ class RuleTransformer extends AbstractTransformer$this->ruleRepository->setUser($rule->user);return [- 'id' => (string)$rule->id,+ 'id' => (string) $rule->id,'created_at' => $rule->created_at->toAtomString(),'updated_at' => $rule->updated_at->toAtomString(),- 'rule_group_id' => (string)$rule->rule_group_id,- 'rule_group_title' => (string)$rule->ruleGroup->title,+ 'rule_group_id' => (string) $rule->rule_group_id,+ 'rule_group_title' => (string) $rule->ruleGroup->title,'title' => $rule->title,'description' => $rule->description,'order' => $rule->order,@@ -110,7 +110,7 @@ class RuleTransformer extends AbstractTransformercontinue;}$triggerType = (string) $ruleTrigger->trigger_type;- $triggerValue = (string)$ruleTrigger->trigger_value;+ $triggerValue = (string) $ruleTrigger->trigger_value;$prohibited = false;if (str_starts_with($triggerType, '-')) {@@ -124,7 +124,7 @@ class RuleTransformer extends AbstractTransformer}$result[] = [- 'id' => (string)$ruleTrigger->id,+ 'id' => (string) $ruleTrigger->id,'created_at' => $ruleTrigger->created_at->toAtomString(),'updated_at' => $ruleTrigger->updated_at->toAtomString(),'type' => $triggerType,@@ -147,7 +147,7 @@ class RuleTransformer extends AbstractTransformer/** @var RuleAction $ruleAction */foreach ($actions as $ruleAction) {$result[] = [- 'id' => (string)$ruleAction->id,+ 'id' => (string) $ruleAction->id,'created_at' => $ruleAction->created_at->toAtomString(),'updated_at' => $ruleAction->updated_at->toAtomString(),'type' => $ruleAction->action_type,diff --git a/app/Transformers/TagTransformer.php b/app/Transformers/TagTransformer.phpindex 4b4acf81e8..d9222069e9 100644--- a/app/Transformers/TagTransformer.php+++ b/app/Transformers/TagTransformer.php@@ -49,7 +49,7 @@ class TagTransformer extends AbstractTransformerif (null !== $location) {$latitude = $location->latitude;$longitude = $location->longitude;- $zoomLevel = (int)$location->zoom_level;+ $zoomLevel = (int) $location->zoom_level;}return [diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.phpindex 94c8ea2280..b5a66b4458 100644--- a/app/Transformers/TransactionGroupTransformer.php+++ b/app/Transformers/TransactionGroupTransformer.php@@ -81,10 +81,10 @@ class TransactionGroupTransformer extends AbstractTransformer$first = new NullArrayObject(reset($group['transactions']));return [- 'id' => (int)$first['transaction_group_id'],+ 'id' => (int) $first['transaction_group_id'],'created_at' => $first['created_at']->toAtomString(),'updated_at' => $first['updated_at']->toAtomString(),- 'user' => (string)$data['user_id'],+ 'user' => (string) $data['user_id'],'group_title' => $data['title'],'transactions' => $this->transformTransactions($data),'links' => [@@ -115,20 +115,20 @@ class TransactionGroupTransformer extends AbstractTransformer$row = new NullArrayObject($transaction);// amount:- $amount = app('steam')->positive((string)($row['amount'] ?? '0'));+ $amount = app('steam')->positive((string) ($row['amount'] ?? '0'));$foreignAmount = null;if (null !== $row['foreign_amount'] && '' !== $row['foreign_amount'] && 0 !== bccomp('0', $row['foreign_amount'])) {$foreignAmount = app('steam')->positive($row['foreign_amount']);}- $metaFieldData = $this->groupRepos->getMetaFields((int)$row['transaction_journal_id'], $this->metaFields);- $metaDateData = $this->groupRepos->getMetaDateFields((int)$row['transaction_journal_id'], $this->metaDateFields);+ $metaFieldData = $this->groupRepos->getMetaFields((int) $row['transaction_journal_id'], $this->metaFields);+ $metaDateData = $this->groupRepos->getMetaDateFields((int) $row['transaction_journal_id'], $this->metaDateFields);$type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionType::WITHDRAWAL);$longitude = null;$latitude = null;$zoomLevel = null;- $location = $this->getLocationById((int)$row['transaction_journal_id']);+ $location = $this->getLocationById((int) $row['transaction_journal_id']);if (null !== $location) {$longitude = $location->longitude;$latitude = $location->latitude;@@ -136,17 +136,17 @@ class TransactionGroupTransformer extends AbstractTransformer}return [- 'user' => (string)$row['user_id'],- 'transaction_journal_id' => (string)$row['transaction_journal_id'],+ 'user' => (string) $row['user_id'],+ 'transaction_journal_id' => (string) $row['transaction_journal_id'],'type' => strtolower($type),'date' => $row['date']->toAtomString(),'order' => $row['order'],- 'currency_id' => (string)$row['currency_id'],+ 'currency_id' => (string) $row['currency_id'],'currency_code' => $row['currency_code'],'currency_name' => $row['currency_name'],'currency_symbol' => $row['currency_symbol'],- 'currency_decimal_places' => (int)$row['currency_decimal_places'],+ 'currency_decimal_places' => (int) $row['currency_decimal_places'],'foreign_currency_id' => $this->stringFromArray($transaction, 'foreign_currency_id', null),'foreign_currency_code' => $row['foreign_currency_code'],@@ -158,12 +158,12 @@ class TransactionGroupTransformer extends AbstractTransformer'description' => $row['description'],- 'source_id' => (string)$row['source_account_id'],+ 'source_id' => (string) $row['source_account_id'],'source_name' => $row['source_account_name'],'source_iban' => $row['source_account_iban'],'source_type' => $row['source_account_type'],- 'destination_id' => (string)$row['destination_account_id'],+ 'destination_id' => (string) $row['destination_account_id'],'destination_name' => $row['destination_account_name'],'destination_iban' => $row['destination_account_iban'],'destination_type' => $row['destination_account_type'],@@ -178,8 +178,8 @@ class TransactionGroupTransformer extends AbstractTransformer'bill_name' => $row['bill_name'],'reconciled' => $row['reconciled'],- 'notes' => $this->groupRepos->getNoteText((int)$row['transaction_journal_id']),- 'tags' => $this->groupRepos->getTags((int)$row['transaction_journal_id']),+ 'notes' => $this->groupRepos->getNoteText((int) $row['transaction_journal_id']),+ 'tags' => $this->groupRepos->getTags((int) $row['transaction_journal_id']),'internal_reference' => $metaFieldData['internal_reference'],'external_id' => $metaFieldData['external_id'],@@ -212,7 +212,7 @@ class TransactionGroupTransformer extends AbstractTransformer'latitude' => $latitude,'zoom_level' => $zoomLevel,- 'has_attachments' => $this->hasAttachments((int)$row['transaction_journal_id']),+ 'has_attachments' => $this->hasAttachments((int) $row['transaction_journal_id']),];}@@ -229,7 +229,7 @@ class TransactionGroupTransformer extends AbstractTransformerreturn $default;}- return (string)$array[$key];+ return (string) $array[$key];}if (null !== $default) {@@ -252,7 +252,7 @@ class TransactionGroupTransformer extends AbstractTransformerprivate function integerFromArray(array $array, string $key): ?int{if (array_key_exists($key, $array)) {- return (int)$array[$key];+ return (int) $array[$key];}return null;@@ -435,7 +435,7 @@ class TransactionGroupTransformer extends AbstractTransformer{$result = $journal->transactions->first(static function (Transaction $transaction) {- return (float)$transaction->amount < 0; // lame but it works.+ return (float) $transaction->amount < 0; // lame but it works.});if (null === $result) {@@ -452,7 +452,7 @@ class TransactionGroupTransformer extends AbstractTransformer{$result = $journal->transactions->first(static function (Transaction $transaction) {- return (float)$transaction->amount > 0; // lame but it works+ return (float) $transaction->amount > 0; // lame but it works});if (null === $result) {@@ -556,7 +556,7 @@ class TransactionGroupTransformer extends AbstractTransformerif (null === $bill) {return $array;}- $array['id'] = (string)$bill->id;+ $array['id'] = (string) $bill->id;$array['name'] = $bill->name;return $array;diff --git a/app/Transformers/TransactionLinkTransformer.php b/app/Transformers/TransactionLinkTransformer.phpindex 9b68d11a03..25b83f8597 100644--- a/app/Transformers/TransactionLinkTransformer.php+++ b/app/Transformers/TransactionLinkTransformer.php@@ -48,12 +48,12 @@ class TransactionLinkTransformer extends AbstractTransformer$notes = $this->repository->getLinkNoteText($link);return [- 'id' => (string)$link->id,+ 'id' => (string) $link->id,'created_at' => $link->created_at->toAtomString(),'updated_at' => $link->updated_at->toAtomString(),- 'inward_id' => (string)$link->source_id,- 'outward_id' => (string)$link->destination_id,- 'link_type_id' => (string)$link->link_type_id,+ 'inward_id' => (string) $link->source_id,+ 'outward_id' => (string) $link->destination_id,+ 'link_type_id' => (string) $link->link_type_id,'notes' => '' === $notes ? null : $notes,'links' => [[diff --git a/app/Transformers/UserTransformer.php b/app/Transformers/UserTransformer.phpindex e1662b749e..18dc74d4b6 100644--- a/app/Transformers/UserTransformer.php+++ b/app/Transformers/UserTransformer.php@@ -45,11 +45,11 @@ class UserTransformer extends AbstractTransformer$this->repository ??= app(UserRepositoryInterface::class);return [- 'id' => (int)$user->id,+ 'id' => (int) $user->id,'created_at' => $user->created_at->toAtomString(),'updated_at' => $user->updated_at->toAtomString(),'email' => $user->email,- 'blocked' => 1 === (int)$user->blocked,+ 'blocked' => 1 === (int) $user->blocked,'blocked_code' => '' === $user->blocked_code ? null : $user->blocked_code,'role' => $this->repository->getRoleByUser($user),'links' => [diff --git a/app/Transformers/V2/AccountTransformer.php b/app/Transformers/V2/AccountTransformer.phpindex 18eb6eb5fb..a02ff243db 100644--- a/app/Transformers/V2/AccountTransformer.php+++ b/app/Transformers/V2/AccountTransformer.php@@ -41,11 +41,11 @@ class AccountTransformer extends AbstractTransformer{private array $accountMeta;private array $accountTypes;- private array $fullTypes;private array $balanceDifferences;private array $convertedBalances;private array $currencies;private TransactionCurrency $default;+ private array $fullTypes;private array $lastActivity;private array $objectGroups;@@ -102,131 +102,14 @@ class AccountTransformer extends AbstractTransformerreturn $objects;}- private function getDate(): Carbon- {- $date = today(config('app.timezone'));- if (null !== $this->parameters->get('date')) {- $date = $this->parameters->get('date');- }-- return $date;- }-- /**- * Transform the account.- */- public function transform(Account $account): array+ private function getLastActivity(Collection $accounts): void{- $id = $account->id;-- // various meta- $accountRole = $this->accountMeta[$id]['account_role'] ?? null;- $accountType = $this->accountTypes[$id];- $order = $account->order;-- // liability type- $liabilityType = 'liabilities' === $accountType ? $this->fullTypes[$id] : null;- $liabilityDirection = $this->accountMeta[$id]['liability_direction'] ?? null;- $interest = $this->accountMeta[$id]['interest'] ?? null;- $interestPeriod = $this->accountMeta[$id]['interest_period'] ?? null;- $currentDebt = $this->accountMeta[$id]['current_debt'] ?? null;-- // no currency? use default- $currency = $this->default;- if (array_key_exists($id, $this->accountMeta) && 0 !== (int) ($this->accountMeta[$id]['currency_id'] ?? 0)) {- $currency = $this->currencies[(int) $this->accountMeta[$id]['currency_id']];- }- // amounts and calculation.- $balance = $this->balances[$id]['balance'] ?? null;- $nativeBalance = $this->convertedBalances[$id]['native_balance'] ?? null;-- // no order for some accounts:- if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'], true)) {- $order = null;- }-- // object group- $objectGroupId = $this->objectGroups[$id]['id'] ?? null;- $objectGroupOrder = $this->objectGroups[$id]['order'] ?? null;- $objectGroupTitle = $this->objectGroups[$id]['title'] ?? null;-- // balance difference- $diffStart = null;- $diffEnd = null;- $balanceDiff = null;- $nativeBalanceDiff = null;- if (null !== $this->parameters->get('start') && null !== $this->parameters->get('end')) {- $diffStart = $this->parameters->get('start')->toAtomString();- $diffEnd = $this->parameters->get('end')->toAtomString();- $balanceDiff = $this->balanceDifferences[$id]['balance'] ?? null;- $nativeBalanceDiff = $this->balanceDifferences[$id]['native_balance'] ?? null;+ /** @var AccountRepositoryInterface $accountRepository */+ $accountRepository = app(AccountRepositoryInterface::class);+ $lastActivity = $accountRepository->getLastActivity($accounts);+ foreach ($lastActivity as $row) {+ $this->lastActivity[(int) $row['account_id']] = Carbon::parse($row['date_max'], config('app.timezone'));}-- return [- 'id' => (string) $account->id,- 'created_at' => $account->created_at->toAtomString(),- 'updated_at' => $account->updated_at->toAtomString(),- 'active' => $account->active,- 'order' => $order,- 'name' => $account->name,- 'iban' => '' === (string) $account->iban ? null : $account->iban,- 'account_number' => $this->accountMeta[$id]['account_number'] ?? null,- 'type' => strtolower($accountType),- 'account_role' => $accountRole,- 'currency_id' => (string) $currency->id,- 'currency_code' => $currency->code,- 'currency_symbol' => $currency->symbol,- 'currency_decimal_places' => $currency->decimal_places,-- 'native_currency_id' => (string) $this->default->id,- 'native_currency_code' => $this->default->code,- 'native_currency_symbol' => $this->default->symbol,- 'native_currency_decimal_places' => $this->default->decimal_places,-- // balance:- 'current_balance' => $balance,- 'native_current_balance' => $nativeBalance,- 'current_balance_date' => $this->getDate()->endOfDay()->toAtomString(),-- // balance difference- 'balance_difference' => $balanceDiff,- 'native_balance_difference' => $nativeBalanceDiff,- 'balance_difference_start' => $diffStart,- 'balance_difference_end' => $diffEnd,-- // more meta- 'last_activity' => array_key_exists($id, $this->lastActivity) ? $this->lastActivity[$id]->toAtomString() : null,-- // liability stuff- 'liability_type' => $liabilityType,- 'liability_direction' => $liabilityDirection,- 'interest' => $interest,- 'interest_period' => $interestPeriod,- 'current_debt' => $currentDebt,-- // object group- 'object_group_id' => null !== $objectGroupId ? (string) $objectGroupId : null,- 'object_group_order' => $objectGroupOrder,- 'object_group_title' => $objectGroupTitle,-- // 'notes' => $this->repository->getNoteText($account),- // 'monthly_payment_date' => $monthlyPaymentDate,- // 'credit_card_type' => $creditCardType,- // 'bic' => $this->repository->getMetaValue($account, 'BIC'),- // 'virtual_balance' => number_format((float) $account->virtual_balance, $decimalPlaces, '.', ''),- // 'opening_balance' => $openingBalance,- // 'opening_balance_date' => $openingBalanceDate,- // 'include_net_worth' => $includeNetWorth,- // 'longitude' => $longitude,- // 'latitude' => $latitude,- // 'zoom_level' => $zoomLevel,- 'links' => [- [- 'rel' => 'self',- 'uri' => '/accounts/'.$account->id,- ],- ],- ];}private function getMetaBalances(Collection $accounts): void@@ -238,6 +121,16 @@ class AccountTransformer extends AbstractTransformer}}+ private function getDate(): Carbon+ {+ $date = today(config('app.timezone'));+ if (null !== $this->parameters->get('date')) {+ $date = $this->parameters->get('date');+ }++ return $date;+ }+private function getDefaultCurrency(): void{$this->default = app('amount')->getDefaultCurrency();@@ -277,16 +170,39 @@ class AccountTransformer extends AbstractTransformer}}- private function getLastActivity(Collection $accounts): void+ private function getBalanceDifference(Collection $accounts, Carbon $start, Carbon $end): void{- /** @var AccountRepositoryInterface $accountRepository */- $accountRepository = app(AccountRepositoryInterface::class);- $lastActivity = $accountRepository->getLastActivity($accounts);- foreach ($lastActivity as $row) {- $this->lastActivity[(int) $row['account_id']] = Carbon::parse($row['date_max'], config('app.timezone'));+ // collect balances, start and end for both native and converted.+ // yes the b is usually used for boolean by idiots but here it's for balance.+ $bStart = [];+ $bEnd = [];++ try {+ $bStart = app('steam')->balancesByAccountsConverted($accounts, $start);+ $bEnd = app('steam')->balancesByAccountsConverted($accounts, $end);+ } catch (FireflyException $e) {+ Log::error($e->getMessage());+ }++ /** @var Account $account */+ foreach ($accounts as $account) {+ $id = $account->id;+ if (array_key_exists($id, $bStart) && array_key_exists($id, $bEnd)) {+ $this->balanceDifferences[$id] = [+ 'balance' => bcsub($bEnd[$id]['balance'], $bStart[$id]['balance']),+ 'native_balance' => bcsub($bEnd[$id]['native_balance'], $bStart[$id]['native_balance']),+ ];+ }}}+ private function getObjectGroups(Collection $accounts): void+ {+ /** @var AccountRepositoryInterface $accountRepository */+ $accountRepository = app(AccountRepositoryInterface::class);+ $this->objectGroups = $accountRepository->getObjectGroups($accounts);+ }+private function sortAccounts(Collection $accounts): Collection{/** @var null|array $sort */@@ -367,32 +283,6 @@ class AccountTransformer extends AbstractTransformer});}- private function getBalanceDifference(Collection $accounts, Carbon $start, Carbon $end): void- {- // collect balances, start and end for both native and converted.- // yes the b is usually used for boolean by idiots but here it's for balance.- $bStart = [];- $bEnd = [];-- try {- $bStart = app('steam')->balancesByAccountsConverted($accounts, $start);- $bEnd = app('steam')->balancesByAccountsConverted($accounts, $end);- } catch (FireflyException $e) {- Log::error($e->getMessage());- }-- /** @var Account $account */- foreach ($accounts as $account) {- $id = $account->id;- if (array_key_exists($id, $bStart) && array_key_exists($id, $bEnd)) {- $this->balanceDifferences[$id] = [- 'balance' => bcsub($bEnd[$id]['balance'], $bStart[$id]['balance']),- 'native_balance' => bcsub($bEnd[$id]['native_balance'], $bStart[$id]['native_balance']),- ];- }- }- }-private function sortByBalanceDifference(Collection $accounts, string $direction): Collection{$balances = $this->balanceDifferences;@@ -423,10 +313,120 @@ class AccountTransformer extends AbstractTransformer});}- private function getObjectGroups(Collection $accounts): void+ /**+ * Transform the account.+ */+ public function transform(Account $account): array{- /** @var AccountRepositoryInterface $accountRepository */- $accountRepository = app(AccountRepositoryInterface::class);- $this->objectGroups = $accountRepository->getObjectGroups($accounts);+ $id = $account->id;++ // various meta+ $accountRole = $this->accountMeta[$id]['account_role'] ?? null;+ $accountType = $this->accountTypes[$id];+ $order = $account->order;++ // liability type+ $liabilityType = 'liabilities' === $accountType ? $this->fullTypes[$id] : null;+ $liabilityDirection = $this->accountMeta[$id]['liability_direction'] ?? null;+ $interest = $this->accountMeta[$id]['interest'] ?? null;+ $interestPeriod = $this->accountMeta[$id]['interest_period'] ?? null;+ $currentDebt = $this->accountMeta[$id]['current_debt'] ?? null;++ // no currency? use default+ $currency = $this->default;+ if (array_key_exists($id, $this->accountMeta) && 0 !== (int) ($this->accountMeta[$id]['currency_id'] ?? 0)) {+ $currency = $this->currencies[(int) $this->accountMeta[$id]['currency_id']];+ }+ // amounts and calculation.+ $balance = $this->balances[$id]['balance'] ?? null;+ $nativeBalance = $this->convertedBalances[$id]['native_balance'] ?? null;++ // no order for some accounts:+ if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'], true)) {+ $order = null;+ }++ // object group+ $objectGroupId = $this->objectGroups[$id]['id'] ?? null;+ $objectGroupOrder = $this->objectGroups[$id]['order'] ?? null;+ $objectGroupTitle = $this->objectGroups[$id]['title'] ?? null;++ // balance difference+ $diffStart = null;+ $diffEnd = null;+ $balanceDiff = null;+ $nativeBalanceDiff = null;+ if (null !== $this->parameters->get('start') && null !== $this->parameters->get('end')) {+ $diffStart = $this->parameters->get('start')->toAtomString();+ $diffEnd = $this->parameters->get('end')->toAtomString();+ $balanceDiff = $this->balanceDifferences[$id]['balance'] ?? null;+ $nativeBalanceDiff = $this->balanceDifferences[$id]['native_balance'] ?? null;+ }++ return [+ 'id' => (string) $account->id,+ 'created_at' => $account->created_at->toAtomString(),+ 'updated_at' => $account->updated_at->toAtomString(),+ 'active' => $account->active,+ 'order' => $order,+ 'name' => $account->name,+ 'iban' => '' === (string) $account->iban ? null : $account->iban,+ 'account_number' => $this->accountMeta[$id]['account_number'] ?? null,+ 'type' => strtolower($accountType),+ 'account_role' => $accountRole,+ 'currency_id' => (string) $currency->id,+ 'currency_code' => $currency->code,+ 'currency_symbol' => $currency->symbol,+ 'currency_decimal_places' => $currency->decimal_places,++ 'native_currency_id' => (string) $this->default->id,+ 'native_currency_code' => $this->default->code,+ 'native_currency_symbol' => $this->default->symbol,+ 'native_currency_decimal_places' => $this->default->decimal_places,++ // balance:+ 'current_balance' => $balance,+ 'native_current_balance' => $nativeBalance,+ 'current_balance_date' => $this->getDate()->endOfDay()->toAtomString(),++ // balance difference+ 'balance_difference' => $balanceDiff,+ 'native_balance_difference' => $nativeBalanceDiff,+ 'balance_difference_start' => $diffStart,+ 'balance_difference_end' => $diffEnd,++ // more meta+ 'last_activity' => array_key_exists($id, $this->lastActivity) ? $this->lastActivity[$id]->toAtomString() : null,++ // liability stuff+ 'liability_type' => $liabilityType,+ 'liability_direction' => $liabilityDirection,+ 'interest' => $interest,+ 'interest_period' => $interestPeriod,+ 'current_debt' => $currentDebt,++ // object group+ 'object_group_id' => null !== $objectGroupId ? (string) $objectGroupId : null,+ 'object_group_order' => $objectGroupOrder,+ 'object_group_title' => $objectGroupTitle,++ // 'notes' => $this->repository->getNoteText($account),+ // 'monthly_payment_date' => $monthlyPaymentDate,+ // 'credit_card_type' => $creditCardType,+ // 'bic' => $this->repository->getMetaValue($account, 'BIC'),+ // 'virtual_balance' => number_format((float) $account->virtual_balance, $decimalPlaces, '.', ''),+ // 'opening_balance' => $openingBalance,+ // 'opening_balance_date' => $openingBalanceDate,+ // 'include_net_worth' => $includeNetWorth,+ // 'longitude' => $longitude,+ // 'latitude' => $latitude,+ // 'zoom_level' => $zoomLevel,+ 'links' => [+ [+ 'rel' => 'self',+ 'uri' => '/accounts/'.$account->id,+ ],+ ],+ ];}}diff --git a/app/Transformers/V2/BillTransformer.php b/app/Transformers/V2/BillTransformer.phpindex 6425ec5b16..76f58e2e34 100644--- a/app/Transformers/V2/BillTransformer.php+++ b/app/Transformers/V2/BillTransformer.php@@ -86,8 +86,8 @@ class BillTransformer extends AbstractTransformer/** @var ObjectGroup $entry */foreach ($set as $entry) {- $billId = (int)$entry->object_groupable_id;- $id = (int)$entry->object_group_id;+ $billId = (int) $entry->object_groupable_id;+ $id = (int) $entry->object_group_id;$order = $entry->order;$this->groups[$billId] = ['object_group_id' => $id,@@ -125,8 +125,8 @@ class BillTransformer extends AbstractTransformerforeach ($journals as $journal) {app('log')->debug(sprintf('Processing journal #%d', $journal->id));$transaction = $transactions[$journal->id] ?? [];- $billId = (int)$journal->bill_id;- $currencyId = (int)($transaction['transaction_currency_id'] ?? 0);+ $billId = (int) $journal->bill_id;+ $currencyId = (int) ($transaction['transaction_currency_id'] ?? 0);$currencies[$currencyId] ??= TransactionCurrency::find($currencyId);// foreign currency@@ -138,7 +138,7 @@ class BillTransformer extends AbstractTransformerapp('log')->debug('Foreign currency is NULL');if (null !== $transaction['foreign_currency_id']) {app('log')->debug(sprintf('Foreign currency is #%d', $transaction['foreign_currency_id']));- $foreignCurrencyId = (int)$transaction['foreign_currency_id'];+ $foreignCurrencyId = (int) $transaction['foreign_currency_id'];$currencies[$foreignCurrencyId] ??= TransactionCurrency::find($foreignCurrencyId);$foreignCurrencyCode = $currencies[$foreignCurrencyId]->code;$foreignCurrencyName = $currencies[$foreignCurrencyId]->name;@@ -147,8 +147,8 @@ class BillTransformer extends AbstractTransformer}$this->paidDates[$billId][] = [- 'transaction_group_id' => (string)$journal->id,- 'transaction_journal_id' => (string)$journal->transaction_group_id,+ 'transaction_group_id' => (string) $journal->id,+ 'transaction_journal_id' => (string) $journal->transaction_group_id,'date' => $journal->date->toAtomString(),'currency_id' => $currencies[$currencyId]->id,'currency_code' => $currencies[$currencyId]->code,@@ -167,7 +167,7 @@ class BillTransformer extends AbstractTransformer'amount' => $transaction['amount'],'foreign_amount' => $transaction['foreign_amount'],'native_amount' => $this->converter->convert($currencies[$currencyId], $this->default, $journal->date, $transaction['amount']),- 'foreign_native_amount' => '' === (string)$transaction['foreign_amount'] ? null : $this->converter->convert(+ 'foreign_native_amount' => '' === (string) $transaction['foreign_amount'] ? null : $this->converter->convert($currencies[$foreignCurrencyId],$this->default,$journal->date,@@ -210,7 +210,7 @@ class BillTransformer extends AbstractTransformer'amount_max' => app('steam')->bcround($bill->amount_max, $currency->decimal_places),'native_amount_min' => $this->converter->convert($currency, $this->default, $date, $bill->amount_min),'native_amount_max' => $this->converter->convert($currency, $this->default, $date, $bill->amount_max),- 'currency_id' => (string)$bill->transaction_currency_id,+ 'currency_id' => (string) $bill->transaction_currency_id,'currency_code' => $currency->code,'currency_name' => $currency->name,'currency_symbol' => $currency->symbol,diff --git a/app/Transformers/V2/BudgetLimitTransformer.php b/app/Transformers/V2/BudgetLimitTransformer.phpindex 26d4be0072..192d095c04 100644--- a/app/Transformers/V2/BudgetLimitTransformer.php+++ b/app/Transformers/V2/BudgetLimitTransformer.php@@ -79,16 +79,16 @@ class BudgetLimitTransformer extends AbstractTransformer$currencySymbol = $currency->symbol;$currencyDecimalPlaces = $currency->decimal_places;}- $amount = number_format((float)$amount, $currencyDecimalPlaces, '.', '');+ $amount = number_format((float) $amount, $currencyDecimalPlaces, '.', '');return [- 'id' => (string)$budgetLimit->id,+ 'id' => (string) $budgetLimit->id,'created_at' => $budgetLimit->created_at->toAtomString(),'updated_at' => $budgetLimit->updated_at->toAtomString(),'start' => $budgetLimit->start_date->toAtomString(),'end' => $budgetLimit->end_date->endOfDay()->toAtomString(),- 'budget_id' => (string)$budgetLimit->budget_id,- 'currency_id' => (string)$currencyId,+ 'budget_id' => (string) $budgetLimit->budget_id,+ 'currency_id' => (string) $currencyId,'currency_code' => $currencyCode,'currency_name' => $currencyName,'currency_decimal_places' => $currencyDecimalPlaces,diff --git a/app/Transformers/V2/BudgetTransformer.php b/app/Transformers/V2/BudgetTransformer.phpindex 2c17883a31..aca7ed8758 100644--- a/app/Transformers/V2/BudgetTransformer.php+++ b/app/Transformers/V2/BudgetTransformer.php@@ -87,7 +87,7 @@ class BudgetTransformer extends AbstractTransformer// }return [- 'id' => (string)$budget->id,+ 'id' => (string) $budget->id,'created_at' => $budget->created_at->toAtomString(),'updated_at' => $budget->updated_at->toAtomString(),'name' => $budget->name,diff --git a/app/Transformers/V2/PiggyBankTransformer.php b/app/Transformers/V2/PiggyBankTransformer.phpindex bdb2b37895..e48c48be28 100644--- a/app/Transformers/V2/PiggyBankTransformer.php+++ b/app/Transformers/V2/PiggyBankTransformer.php@@ -88,7 +88,7 @@ class PiggyBankTransformer extends AbstractTransformer/** @var AccountMeta $preference */foreach ($currencyPreferences as $preference) {- $currencyId = (int)$preference->data;+ $currencyId = (int) $preference->data;$accountId = $preference->account_id;$currencies[$currencyId] ??= TransactionJournal::find($currencyId);$this->currencies[$accountId] = $currencies[$currencyId];@@ -103,11 +103,11 @@ class PiggyBankTransformer extends AbstractTransformer/** @var ObjectGroup $entry */foreach ($set as $entry) {- $piggyBankId = (int)$entry->object_groupable_id;- $id = (int)$entry->object_group_id;+ $piggyBankId = (int) $entry->object_groupable_id;+ $id = (int) $entry->object_group_id;$order = $entry->order;$this->groups[$piggyBankId] = [- 'object_group_id' => (string)$id,+ 'object_group_id' => (string) $id,'object_group_title' => $entry->title,'object_group_order' => $order,];@@ -195,24 +195,24 @@ class PiggyBankTransformer extends AbstractTransformerif (0 !== bccomp($targetAmount, '0')) { // target amount is not 0.00$leftToSave = bcsub($targetAmount, $currentAmount);$nativeLeftToSave = $this->converter->convert($this->default, $currency, today(), $leftToSave);- $percentage = (int)bcmul(bcdiv($currentAmount, $targetAmount), '100');+ $percentage = (int) bcmul(bcdiv($currentAmount, $targetAmount), '100');$savePerMonth = $this->getSuggestedMonthlyAmount($currentAmount, $targetAmount, $piggyBank->start_date, $piggyBank->target_date);$nativeSavePerMonth = $this->converter->convert($this->default, $currency, today(), $savePerMonth);}$this->converter->summarize();return [- 'id' => (string)$piggyBank->id,+ 'id' => (string) $piggyBank->id,'created_at' => $piggyBank->created_at->toAtomString(),'updated_at' => $piggyBank->updated_at->toAtomString(),- 'account_id' => (string)$piggyBank->account_id,+ 'account_id' => (string) $piggyBank->account_id,'account_name' => $accountName,'name' => $piggyBank->name,- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_code' => $currency->code,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,- 'native_currency_id' => (string)$this->default->id,+ 'native_currency_id' => (string) $this->default->id,'native_currency_code' => $this->default->code,'native_currency_symbol' => $this->default->symbol,'native_currency_decimal_places' => $this->default->decimal_places,@@ -251,12 +251,12 @@ class PiggyBankTransformer extends AbstractTransformerif (bccomp($currentAmount, $targetAmount) < 1) {$now = today(config('app.timezone'));$startDate = null !== $startDate && $startDate->gte($now) ? $startDate : $now;- $diffInMonths = (int)$startDate->diffInMonths($targetDate);+ $diffInMonths = (int) $startDate->diffInMonths($targetDate);$remainingAmount = bcsub($targetAmount, $currentAmount);// more than 1 month to go and still need money to save:if ($diffInMonths > 0 && 1 === bccomp($remainingAmount, '0')) {- $savePerMonth = bcdiv($remainingAmount, (string)$diffInMonths);+ $savePerMonth = bcdiv($remainingAmount, (string) $diffInMonths);}// less than 1 month to go but still need money to save:diff --git a/app/Transformers/V2/TransactionGroupTransformer.php b/app/Transformers/V2/TransactionGroupTransformer.phpindex 806b47f6ea..37b777aac5 100644--- a/app/Transformers/V2/TransactionGroupTransformer.php+++ b/app/Transformers/V2/TransactionGroupTransformer.php@@ -101,12 +101,12 @@ class TransactionGroupTransformer extends AbstractTransformerprivate function collectForArray(array $object): void{foreach ($object['sums'] as $sum) {- $this->currencies[(int)$sum['currency_id']] ??= TransactionCurrency::find($sum['currency_id']);+ $this->currencies[(int) $sum['currency_id']] ??= TransactionCurrency::find($sum['currency_id']);}/** @var array $transaction */foreach ($object['transactions'] as $transaction) {- $this->journals[(int)$transaction['transaction_journal_id']] = [];+ $this->journals[(int) $transaction['transaction_journal_id']] = [];}}@@ -169,7 +169,7 @@ class TransactionGroupTransformer extends AbstractTransformer/** @var \stdClass $tag */foreach ($tags as $tag) {- $id = (int)$tag->transaction_journal_id;+ $id = (int) $tag->transaction_journal_id;$this->journals[$id]['tags'][] = $tag->tag;}}@@ -196,7 +196,7 @@ class TransactionGroupTransformer extends AbstractTransformer/** @var null|Budget $budget */$budget = $journal->budgets()->first();if (null !== $budget) {- $this->journals[$id]['budget_id'] = (string)$budget->id;+ $this->journals[$id]['budget_id'] = (string) $budget->id;$this->journals[$id]['budget_name'] = $budget->name;}@@ -204,14 +204,14 @@ class TransactionGroupTransformer extends AbstractTransformer/** @var null|Category $category */$category = $journal->categories()->first();if (null !== $category) {- $this->journals[$id]['category_id'] = (string)$category->id;+ $this->journals[$id]['category_id'] = (string) $category->id;$this->journals[$id]['category_name'] = $category->name;}// collect bill:if (null !== $journal->bill_id) {$bill = $journal->bill;- $this->journals[$id]['bill_id'] = (string)$bill->id;+ $this->journals[$id]['bill_id'] = (string) $bill->id;$this->journals[$id]['bill_name'] = $bill->name;}@@ -262,11 +262,11 @@ class TransactionGroupTransformer extends AbstractTransformer$first = reset($group['transactions']);return [- 'id' => (string)$group['id'],+ 'id' => (string) $group['id'],'created_at' => $group['created_at']->toAtomString(),'updated_at' => $group['updated_at']->toAtomString(),- 'user' => (string)$first['user_id'],- 'user_group' => (string)$first['user_group_id'],+ 'user' => (string) $first['user_id'],+ 'user_group' => (string) $first['user_group_id'],'group_title' => $group['title'] ?? null,'transactions' => $this->transformTransactions($group['transactions'] ?? []),'links' => [@@ -279,11 +279,11 @@ class TransactionGroupTransformer extends AbstractTransformer}return [- 'id' => (string)$group->id,+ 'id' => (string) $group->id,'created_at' => $group->created_at->toAtomString(),'updated_at' => $group->created_at->toAtomString(),- 'user' => (string)$group->user_id,- 'user_group' => (string)$group->user_group_id,+ 'user' => (string) $group->user_id,+ 'user_group' => (string) $group->user_group_id,'group_title' => $group->title ?? null,'transactions' => $this->transformJournals($group),'links' => [@@ -316,19 +316,19 @@ class TransactionGroupTransformer extends AbstractTransformer{$transaction = new NullArrayObject($transaction);$type = $this->stringFromArray($transaction, 'transaction_type_type', TransactionType::WITHDRAWAL);- $journalId = (int)$transaction['transaction_journal_id'];+ $journalId = (int) $transaction['transaction_journal_id'];$meta = new NullArrayObject($this->meta[$journalId] ?? []);/*** Convert and use amount:*/- $amount = app('steam')->positive((string)($transaction['amount'] ?? '0'));- $currencyId = (int)$transaction['currency_id'];+ $amount = app('steam')->positive((string) ($transaction['amount'] ?? '0'));+ $currencyId = (int) $transaction['currency_id'];$nativeAmount = $this->converter->convert($this->default, $this->currencies[$currencyId], $transaction['date'], $amount);$foreignAmount = null;$nativeForeignAmount = null;if (null !== $transaction['foreign_amount']) {- $foreignCurrencyId = (int)$transaction['foreign_currency_id'];+ $foreignCurrencyId = (int) $transaction['foreign_currency_id'];$foreignAmount = app('steam')->positive($transaction['foreign_amount']);$nativeForeignAmount = $this->converter->convert($this->default, $this->currencies[$foreignCurrencyId], $transaction['date'], $foreignAmount);}@@ -338,15 +338,15 @@ class TransactionGroupTransformer extends AbstractTransformer$latitude = null;$zoomLevel = null;if (array_key_exists('location', $this->journals[$journalId])) {- $latitude = (string)$this->journals[$journalId]['location']['latitude'];- $longitude = (string)$this->journals[$journalId]['location']['longitude'];+ $latitude = (string) $this->journals[$journalId]['location']['latitude'];+ $longitude = (string) $this->journals[$journalId]['location']['longitude'];$zoomLevel = $this->journals[$journalId]['location']['zoom_level'];}return [- 'user' => (string)$transaction['user_id'],- 'user_group' => (string)$transaction['user_group_id'],- 'transaction_journal_id' => (string)$transaction['transaction_journal_id'],+ 'user' => (string) $transaction['user_id'],+ 'user_group' => (string) $transaction['user_group_id'],+ 'transaction_journal_id' => (string) $transaction['transaction_journal_id'],'type' => strtolower($type),'date' => $transaction['date']->toAtomString(),'order' => $transaction['order'],@@ -354,14 +354,14 @@ class TransactionGroupTransformer extends AbstractTransformer'native_amount' => $nativeAmount,'foreign_amount' => $foreignAmount,'native_foreign_amount' => $nativeForeignAmount,- 'currency_id' => (string)$transaction['currency_id'],+ 'currency_id' => (string) $transaction['currency_id'],'currency_code' => $transaction['currency_code'],'currency_name' => $transaction['currency_name'],'currency_symbol' => $transaction['currency_symbol'],- 'currency_decimal_places' => (int)$transaction['currency_decimal_places'],+ 'currency_decimal_places' => (int) $transaction['currency_decimal_places'],// converted to native currency- 'native_currency_id' => (string)$this->default->id,+ 'native_currency_id' => (string) $this->default->id,'native_currency_code' => $this->default->code,'native_currency_name' => $this->default->name,'native_currency_symbol' => $this->default->symbol,@@ -376,11 +376,11 @@ class TransactionGroupTransformer extends AbstractTransformer// foreign converted to native:'description' => $transaction['description'],- 'source_id' => (string)$transaction['source_account_id'],+ 'source_id' => (string) $transaction['source_account_id'],'source_name' => $transaction['source_account_name'],'source_iban' => $transaction['source_account_iban'],'source_type' => $transaction['source_account_type'],- 'destination_id' => (string)$transaction['destination_account_id'],+ 'destination_id' => (string) $transaction['destination_account_id'],'destination_name' => $transaction['destination_account_name'],'destination_iban' => $transaction['destination_account_iban'],'destination_type' => $transaction['destination_account_type'],@@ -444,7 +444,7 @@ class TransactionGroupTransformer extends AbstractTransformerreturn $default;}if (null !== $array[$key]) {- return (string)$array[$key];+ return (string) $array[$key];}if (null !== $default) {@@ -532,15 +532,15 @@ class TransactionGroupTransformer extends AbstractTransformer$latitude = null;$zoomLevel = null;if (array_key_exists('location', $this->journals[$id])) {- $latitude = (string)$this->journals[$id]['location']['latitude'];- $longitude = (string)$this->journals[$id]['location']['longitude'];+ $latitude = (string) $this->journals[$id]['location']['latitude'];+ $longitude = (string) $this->journals[$id]['location']['longitude'];$zoomLevel = $this->journals[$id]['location']['zoom_level'];}return [- 'user' => (string)$journal->user_id,- 'user_group' => (string)$journal->user_group_id,- 'transaction_journal_id' => (string)$journal->id,+ 'user' => (string) $journal->user_id,+ 'user_group' => (string) $journal->user_group_id,+ 'transaction_journal_id' => (string) $journal->id,'type' => $this->journals[$journal->id]['type'],'date' => $journal->date->toAtomString(),'order' => $journal->order,@@ -548,14 +548,14 @@ class TransactionGroupTransformer extends AbstractTransformer'native_amount' => $nativeAmount,'foreign_amount' => $foreignAmount,'native_foreign_amount' => $nativeForeignAmount,- 'currency_id' => (string)$currency->id,+ 'currency_id' => (string) $currency->id,'currency_code' => $currency->code,'currency_name' => $currency->name,'currency_symbol' => $currency->symbol,'currency_decimal_places' => $currency->decimal_places,// converted to native currency- 'native_currency_id' => (string)$this->default->id,+ 'native_currency_id' => (string) $this->default->id,'native_currency_code' => $this->default->code,'native_currency_name' => $this->default->name,'native_currency_symbol' => $this->default->symbol,@@ -569,12 +569,12 @@ class TransactionGroupTransformer extends AbstractTransformer'foreign_currency_decimal_places' => $foreignCurrency?->decimal_places,'description' => $journal->description,- 'source_id' => (string)$this->journals[$id]['source_account_id'],+ 'source_id' => (string) $this->journals[$id]['source_account_id'],'source_name' => $this->journals[$id]['source_account_name'],'source_iban' => $this->journals[$id]['source_account_iban'],'source_type' => $this->journals[$id]['source_account_type'],- 'destination_id' => (string)$this->journals[$id]['destination_account_id'],+ 'destination_id' => (string) $this->journals[$id]['destination_account_id'],'destination_name' => $this->journals[$id]['destination_account_name'],'destination_iban' => $this->journals[$id]['destination_account_iban'],'destination_type' => $this->journals[$id]['destination_account_type'],diff --git a/app/Transformers/V2/UserGroupTransformer.php b/app/Transformers/V2/UserGroupTransformer.phpindex 41ac5ce8b6..2a33edd6b9 100644--- a/app/Transformers/V2/UserGroupTransformer.php+++ b/app/Transformers/V2/UserGroupTransformer.php@@ -79,23 +79,6 @@ class UserGroupTransformer extends AbstractTransformerreturn $objects;}- /**- * Transform the user group.- */- public function transform(UserGroup $userGroup): array- {- return [- 'id' => $userGroup->id,- 'created_at' => $userGroup->created_at->toAtomString(),- 'updated_at' => $userGroup->updated_at->toAtomString(),- 'in_use' => $this->inUse[$userGroup->id] ?? false,- 'title' => $userGroup->title,- 'can_see_members' => $this->membershipsVisible[$userGroup->id] ?? false,- 'members' => array_values($this->memberships[$userGroup->id] ?? []),- ];- // if the user has a specific role in this group, then collect the memberships.- }-private function mergeMemberships(): void{$new = [];@@ -115,4 +98,21 @@ class UserGroupTransformer extends AbstractTransformer}$this->memberships = $new;}++ /**+ * Transform the user group.+ */+ public function transform(UserGroup $userGroup): array+ {+ return [+ 'id' => $userGroup->id,+ 'created_at' => $userGroup->created_at->toAtomString(),+ 'updated_at' => $userGroup->updated_at->toAtomString(),+ 'in_use' => $this->inUse[$userGroup->id] ?? false,+ 'title' => $userGroup->title,+ 'can_see_members' => $this->membershipsVisible[$userGroup->id] ?? false,+ 'members' => array_values($this->memberships[$userGroup->id] ?? []),+ ];+ // if the user has a specific role in this group, then collect the memberships.+ }}diff --git a/app/Transformers/WebhookAttemptTransformer.php b/app/Transformers/WebhookAttemptTransformer.phpindex 95d2c425a3..2ab04f184a 100644--- a/app/Transformers/WebhookAttemptTransformer.php+++ b/app/Transformers/WebhookAttemptTransformer.php@@ -37,11 +37,11 @@ class WebhookAttemptTransformer extends AbstractTransformerpublic function transform(WebhookAttempt $attempt): array{return [- 'id' => (string)$attempt->id,+ 'id' => (string) $attempt->id,'created_at' => $attempt->created_at->toAtomString(),'updated_at' => $attempt->updated_at->toAtomString(),- 'webhook_message_id' => (string)$attempt->webhook_message_id,- 'status_code' => (int)$attempt->status_code,+ 'webhook_message_id' => (string) $attempt->webhook_message_id,+ 'status_code' => (int) $attempt->status_code,'logs' => $attempt->logs,'response' => $attempt->response,];diff --git a/app/Transformers/WebhookMessageTransformer.php b/app/Transformers/WebhookMessageTransformer.phpindex 18acaf9532..f0fd5c056d 100644--- a/app/Transformers/WebhookMessageTransformer.php+++ b/app/Transformers/WebhookMessageTransformer.php@@ -45,12 +45,12 @@ class WebhookMessageTransformer extends AbstractTransformer}return [- 'id' => (string)$message->id,+ 'id' => (string) $message->id,'created_at' => $message->created_at->toAtomString(),'updated_at' => $message->updated_at->toAtomString(),'sent' => $message->sent,'errored' => $message->errored,- 'webhook_id' => (string)$message->webhook_id,+ 'webhook_id' => (string) $message->webhook_id,'uuid' => $message->uuid,'message' => $json,];diff --git a/app/User.php b/app/User.phpindex 2d2c142129..c4fa2727b1 100644--- a/app/User.php+++ b/app/User.php@@ -106,11 +106,6 @@ class User extends Authenticatablereturn $this->hasMany(Account::class);}- public function piggyBanks(): void- {- throw new FireflyException('Method no longer supported.');- }-/*** Link to attachments*/@@ -334,6 +329,11 @@ class User extends Authenticatablereturn $this->hasMany(ObjectGroup::class);}+ public function piggyBanks(): void+ {+ throw new FireflyException('Method no longer supported.');+ }+/*** Link to preferences.*/diff --git a/app/Validation/Account/DepositValidation.php b/app/Validation/Account/DepositValidation.phpindex f91c99abd8..961e709503 100644--- a/app/Validation/Account/DepositValidation.php+++ b/app/Validation/Account/DepositValidation.php@@ -46,7 +46,7 @@ trait DepositValidationif (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {// if both values are NULL we return false,// because the destination of a deposit can't be created.- $this->destError = (string)trans('validation.deposit_dest_need_data');+ $this->destError = (string) trans('validation.deposit_dest_need_data');app('log')->error('Both values are NULL, cant create deposit destination.');$result = false;}@@ -61,7 +61,7 @@ trait DepositValidation$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {app('log')->debug('findExistingAccount() returned NULL, so the result is false.');- $this->destError = (string)trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);+ $this->destError = (string) trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);$result = false;}if (null !== $search) {@@ -107,7 +107,7 @@ trait DepositValidation// if both values are NULL return false,// because the source of a deposit can't be created.// (this never happens).- $this->sourceError = (string)trans('validation.deposit_source_need_data');+ $this->sourceError = (string) trans('validation.deposit_source_need_data');$result = false;}@@ -116,7 +116,7 @@ trait DepositValidationapp('log')->debug('Check if there is not already another account with this IBAN');$existing = $this->findExistingAccount($validTypes, ['iban' => $accountIban], true);if (null !== $existing) {- $this->sourceError = (string)trans('validation.deposit_src_iban_exists');+ $this->sourceError = (string) trans('validation.deposit_src_iban_exists');return false;}diff --git a/app/Validation/Account/OBValidation.php b/app/Validation/Account/OBValidation.phpindex de2dc2c11d..30c2e65cb2 100644--- a/app/Validation/Account/OBValidation.php+++ b/app/Validation/Account/OBValidation.php@@ -44,7 +44,7 @@ trait OBValidationif (null === $accountId && null === $accountName && false === $this->canCreateTypes($validTypes)) {// if both values are NULL we return false,// because the destination of a deposit can't be created.- $this->destError = (string)trans('validation.ob_dest_need_data');+ $this->destError = (string) trans('validation.ob_dest_need_data');app('log')->error('Both values are NULL, cant create OB destination.');$result = false;}@@ -59,7 +59,7 @@ trait OBValidation$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {app('log')->debug('findExistingAccount() returned NULL, so the result is false.', $validTypes);- $this->destError = (string)trans('validation.ob_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);+ $this->destError = (string) trans('validation.ob_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);$result = false;}if (null !== $search) {@@ -92,7 +92,7 @@ trait OBValidation// if both values are NULL return false,// because the source of a deposit can't be created.// (this never happens).- $this->sourceError = (string)trans('validation.ob_source_need_data');+ $this->sourceError = (string) trans('validation.ob_source_need_data');$result = false;}diff --git a/app/Validation/Account/ReconciliationValidation.php b/app/Validation/Account/ReconciliationValidation.phpindex be3695eef3..52b97201d4 100644--- a/app/Validation/Account/ReconciliationValidation.php+++ b/app/Validation/Account/ReconciliationValidation.php@@ -53,7 +53,7 @@ trait ReconciliationValidation$validTypes = array_keys($this->combinations[$this->transactionType]);$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {- $this->sourceError = (string)trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]);+ $this->sourceError = (string) trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]);app('log')->warning('Not a valid source. Cant find it.', $validTypes);return false;@@ -88,7 +88,7 @@ trait ReconciliationValidation$validTypes = array_keys($this->combinations[$this->transactionType]);$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {- $this->sourceError = (string)trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]);+ $this->sourceError = (string) trans('validation.reconciliation_source_bad_data', ['id' => $accountId, 'name' => $accountName]);app('log')->warning('Not a valid source. Cant find it.', $validTypes);return false;diff --git a/app/Validation/Account/TransferValidation.php b/app/Validation/Account/TransferValidation.phpindex 91a1ae7e39..ff01b7eab6 100644--- a/app/Validation/Account/TransferValidation.php+++ b/app/Validation/Account/TransferValidation.php@@ -42,7 +42,7 @@ trait TransferValidationif (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {// if both values are NULL we return false,// because the destination of a transfer can't be created.- $this->destError = (string)trans('validation.transfer_dest_need_data');+ $this->destError = (string) trans('validation.transfer_dest_need_data');app('log')->error('Both values are NULL, cant create transfer destination.');return false;@@ -51,7 +51,7 @@ trait TransferValidation// or try to find the account:$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {- $this->destError = (string)trans('validation.transfer_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);+ $this->destError = (string) trans('validation.transfer_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);return false;}@@ -86,7 +86,7 @@ trait TransferValidation&& false === $this->canCreateTypes($validTypes)) {// if both values are NULL we return false,// because the source of a withdrawal can't be created.- $this->sourceError = (string)trans('validation.transfer_source_need_data');+ $this->sourceError = (string) trans('validation.transfer_source_need_data');app('log')->warning('Not a valid source, need more data.');return false;@@ -95,7 +95,7 @@ trait TransferValidation// otherwise try to find the account:$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {- $this->sourceError = (string)trans('validation.transfer_source_bad_data', ['id' => $accountId, 'name' => $accountName]);+ $this->sourceError = (string) trans('validation.transfer_source_bad_data', ['id' => $accountId, 'name' => $accountName]);app('log')->warning('Not a valid source, cant find it.', $validTypes);return false;diff --git a/app/Validation/Account/WithdrawalValidation.php b/app/Validation/Account/WithdrawalValidation.phpindex aea6884db9..630d8f8b66 100644--- a/app/Validation/Account/WithdrawalValidation.php+++ b/app/Validation/Account/WithdrawalValidation.php@@ -43,7 +43,7 @@ trait WithdrawalValidationif (null === $accountId && null === $accountName && null === $accountIban && false === $this->canCreateTypes($validTypes)) {// if both values are NULL we return TRUE// because we assume the user doesn't want to submit / change anything.- $this->sourceError = (string)trans('validation.withdrawal_source_need_data');+ $this->sourceError = (string) trans('validation.withdrawal_source_need_data');app('log')->warning('[a] Not a valid source. Need more data.');return false;@@ -52,7 +52,7 @@ trait WithdrawalValidation// otherwise try to find the account:$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {- $this->sourceError = (string)trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);+ $this->sourceError = (string) trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);app('log')->warning('Not a valid source. Cant find it.', $validTypes);return false;@@ -80,7 +80,7 @@ trait WithdrawalValidationif (null === $accountId && null === $accountName && null === $accountIban && null === $accountNumber && false === $this->canCreateTypes($validTypes)) {// if both values are NULL return false,// because the destination of a withdrawal can never be created automatically.- $this->destError = (string)trans('validation.withdrawal_dest_need_data');+ $this->destError = (string) trans('validation.withdrawal_dest_need_data');return false;}@@ -96,7 +96,7 @@ trait WithdrawalValidationreturn true;}// todo explain error in log message.- $this->destError = (string)trans('validation.withdrawal_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);+ $this->destError = (string) trans('validation.withdrawal_dest_bad_data', ['id' => $accountId, 'name' => $accountName]);return false;}@@ -108,7 +108,7 @@ trait WithdrawalValidation// the inverse flag reverses the search, searching for everything that is NOT a valid type.$existing = $this->findExistingAccount($validTypes, ['iban' => $accountIban], true);if (null !== $existing) {- $this->destError = (string)trans('validation.withdrawal_dest_iban_exists');+ $this->destError = (string) trans('validation.withdrawal_dest_iban_exists');return false;}@@ -131,7 +131,7 @@ trait WithdrawalValidationif (null === $accountId && null === $accountName && null === $accountNumber && null === $accountIban && false === $this->canCreateTypes($validTypes)) {// if both values are NULL we return false,// because the source of a withdrawal can't be created.- $this->sourceError = (string)trans('validation.withdrawal_source_need_data');+ $this->sourceError = (string) trans('validation.withdrawal_source_need_data');app('log')->warning('[b] Not a valid source. Need more data.');return false;@@ -140,7 +140,7 @@ trait WithdrawalValidation// otherwise try to find the account:$search = $this->findExistingAccount($validTypes, $array);if (null === $search) {- $this->sourceError = (string)trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);+ $this->sourceError = (string) trans('validation.withdrawal_source_bad_data', ['id' => $accountId, 'name' => $accountName]);app('log')->warning('Not a valid source. Cant find it.', $validTypes);return false;diff --git a/app/Validation/AccountValidator.php b/app/Validation/AccountValidator.phpindex 6e05fa2e53..da47855d40 100644--- a/app/Validation/AccountValidator.php+++ b/app/Validation/AccountValidator.php@@ -277,7 +277,7 @@ class AccountValidator}// find by iban- if (null !== $accountIban && '' !== (string)$accountIban) {+ if (null !== $accountIban && '' !== (string) $accountIban) {$first = $this->getRepository()->findByIbanNull($accountIban, $validTypes);$accountType = null === $first ? 'invalid' : $first->accountType->type;$check = in_array($accountType, $validTypes, true);@@ -290,7 +290,7 @@ class AccountValidator}// find by number- if (null !== $accountNumber && '' !== (string)$accountNumber) {+ if (null !== $accountNumber && '' !== (string) $accountNumber) {$first = $this->getRepository()->findByAccountNumber($accountNumber, $validTypes);$accountType = null === $first ? 'invalid' : $first->accountType->type;$check = in_array($accountType, $validTypes, true);@@ -303,7 +303,7 @@ class AccountValidator}// find by name:- if ('' !== (string)$accountName) {+ if ('' !== (string) $accountName) {$first = $this->getRepository()->findByName($accountName, $validTypes);if (null !== $first) {app('log')->debug(sprintf('Name: Found %s account #%d ("%s", IBAN "%s")', $first->accountType->type, $first->id, $first->name, $first->iban ?? 'no iban'));diff --git a/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php b/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.phpindex 6494d4d05a..bef98c6709 100644--- a/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php+++ b/app/Validation/Api/Data/Bulk/ValidatesBulkTransactionQuery.php@@ -41,20 +41,20 @@ trait ValidatesBulkTransactionQuery// find both accounts, must be same type.// already validated: belongs to this user.$repository = app(AccountRepositoryInterface::class);- $source = $repository->find((int)$json['where']['account_id']);- $dest = $repository->find((int)$json['update']['account_id']);+ $source = $repository->find((int) $json['where']['account_id']);+ $dest = $repository->find((int) $json['update']['account_id']);if (null === $source) {- $validator->errors()->add('query', sprintf((string)trans('validation.invalid_query_data'), 'where', 'account_id'));+ $validator->errors()->add('query', sprintf((string) trans('validation.invalid_query_data'), 'where', 'account_id'));return;}if (null === $dest) {- $validator->errors()->add('query', sprintf((string)trans('validation.invalid_query_data'), 'update', 'account_id'));+ $validator->errors()->add('query', sprintf((string) trans('validation.invalid_query_data'), 'update', 'account_id'));return;}if ($source->accountType->type !== $dest->accountType->type) {- $validator->errors()->add('query', (string)trans('validation.invalid_query_account_type'));+ $validator->errors()->add('query', (string) trans('validation.invalid_query_account_type'));return;}@@ -68,7 +68,7 @@ trait ValidatesBulkTransactionQuery&& null !== $destCurrency&& $sourceCurrency->id !== $destCurrency->id) {- $validator->errors()->add('query', (string)trans('validation.invalid_query_currency'));+ $validator->errors()->add('query', (string) trans('validation.invalid_query_currency'));}}}diff --git a/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php b/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.phpindex d417061c3e..493c0d03ac 100644--- a/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php+++ b/app/Validation/AutoBudget/ValidatesAutoBudgetRequest.php@@ -42,38 +42,38 @@ trait ValidatesAutoBudgetRequest/** @var null|float|int|string $amount */$amount = array_key_exists('auto_budget_amount', $data) ? $data['auto_budget_amount'] : null;$period = array_key_exists('auto_budget_period', $data) ? $data['auto_budget_period'] : null;- $currencyId = array_key_exists('auto_budget_currency_id', $data) ? (int)$data['auto_budget_currency_id'] : null;+ $currencyId = array_key_exists('auto_budget_currency_id', $data) ? (int) $data['auto_budget_currency_id'] : null;$currencyCode = array_key_exists('auto_budget_currency_code', $data) ? $data['auto_budget_currency_code'] : null;if (is_numeric($type)) {- $type = (int)$type;+ $type = (int) $type;}if ('' === $type || 0 === $type) {return;}// TODO lots of duplicates with number validator.// TODO should be present at more places, stop scientific notification- if (str_contains(strtoupper((string)$amount), 'E')) {+ if (str_contains(strtoupper((string) $amount), 'E')) {$amount = '';}// basic float check:if (!is_numeric($amount)) {- $validator->errors()->add('auto_budget_amount', (string)trans('validation.amount_required_for_auto_budget'));+ $validator->errors()->add('auto_budget_amount', (string) trans('validation.amount_required_for_auto_budget'));return;}- if (1 !== bccomp((string)$amount, '0')) {- $validator->errors()->add('auto_budget_amount', (string)trans('validation.auto_budget_amount_positive'));+ if (1 !== bccomp((string) $amount, '0')) {+ $validator->errors()->add('auto_budget_amount', (string) trans('validation.auto_budget_amount_positive'));}if ('' === $period) {- $validator->errors()->add('auto_budget_period', (string)trans('validation.auto_budget_period_mandatory'));+ $validator->errors()->add('auto_budget_period', (string) trans('validation.auto_budget_period_mandatory'));}if (null !== $currencyId && null !== $currencyCode && '' === $currencyCode && 0 === $currencyId) {- $validator->errors()->add('auto_budget_amount', (string)trans('validation.require_currency_info'));+ $validator->errors()->add('auto_budget_amount', (string) trans('validation.require_currency_info'));}// too big amount- if ((int)$amount > 268435456) {- $validator->errors()->add('auto_budget_amount', (string)trans('validation.amount_required_for_auto_budget'));+ if ((int) $amount > 268435456) {+ $validator->errors()->add('auto_budget_amount', (string) trans('validation.amount_required_for_auto_budget'));}}}diff --git a/app/Validation/CurrencyValidation.php b/app/Validation/CurrencyValidation.phpindex c792b0a866..52bad8ff61 100644--- a/app/Validation/CurrencyValidation.php+++ b/app/Validation/CurrencyValidation.php@@ -57,7 +57,7 @@ trait CurrencyValidationcontinue;}- $foreignAmount = (string)($transaction['foreign_amount'] ?? '');+ $foreignAmount = (string) ($transaction['foreign_amount'] ?? '');$foreignId = $transaction['foreign_currency_id'] ?? null;$foreignCode = $transaction['foreign_currency_code'] ?? null;if ('' === $foreignAmount) {@@ -66,9 +66,9 @@ trait CurrencyValidation(array_key_exists('foreign_currency_id', $transaction) || array_key_exists('foreign_currency_code', $transaction))&& (null !== $foreignId || null !== $foreignCode)) {- $validator->errors()->add('transactions.'.$index.'.foreign_amount', (string)trans('validation.require_currency_amount'));- $validator->errors()->add('transactions.'.$index.'.foreign_currency_id', (string)trans('validation.require_currency_amount'));- $validator->errors()->add('transactions.'.$index.'.foreign_currency_code', (string)trans('validation.require_currency_amount'));+ $validator->errors()->add('transactions.'.$index.'.foreign_amount', (string) trans('validation.require_currency_amount'));+ $validator->errors()->add('transactions.'.$index.'.foreign_currency_id', (string) trans('validation.require_currency_amount'));+ $validator->errors()->add('transactions.'.$index.'.foreign_currency_code', (string) trans('validation.require_currency_amount'));}continue;@@ -79,14 +79,14 @@ trait CurrencyValidationLog::debug('validateForeignCurrencyInformation: array contains foreign amount info.');if (!array_key_exists('foreign_currency_id', $transaction) && !array_key_exists('foreign_currency_code', $transaction)) {Log::debug('validateForeignCurrencyInformation: array contains NO foreign currency info.');- $validator->errors()->add('transactions.'.$index.'.foreign_amount', (string)trans('validation.require_currency_info'));+ $validator->errors()->add('transactions.'.$index.'.foreign_amount', (string) trans('validation.require_currency_info'));}}- if (0 === $compare && ('' !== (string)$foreignId || '' !== (string)$foreignCode)) {+ if (0 === $compare && ('' !== (string) $foreignId || '' !== (string) $foreignCode)) {Log::debug('validateForeignCurrencyInformation: array contains foreign currency info, but zero amount.');- $validator->errors()->add('transactions.'.$index.'.foreign_currency_id', (string)trans('validation.require_currency_amount'));- $validator->errors()->add('transactions.'.$index.'.foreign_currency_code', (string)trans('validation.require_currency_amount'));- $validator->errors()->add('transactions.'.$index.'.foreign_amount', (string)trans('validation.require_currency_amount'));+ $validator->errors()->add('transactions.'.$index.'.foreign_currency_id', (string) trans('validation.require_currency_amount'));+ $validator->errors()->add('transactions.'.$index.'.foreign_currency_code', (string) trans('validation.require_currency_amount'));+ $validator->errors()->add('transactions.'.$index.'.foreign_amount', (string) trans('validation.require_currency_amount'));}}}diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.phpindex 88e746bdb7..5c5a19f9a7 100644--- a/app/Validation/FireflyValidator.php+++ b/app/Validation/FireflyValidator.php@@ -79,22 +79,6 @@ class FireflyValidator extends Validatorreturn (bool) \Google2FA::verifyKey((string) $secret, $value);}- public function validateExistingMfaCode($attribute, $value): bool- {- if (!is_string($value) || 6 !== strlen($value)) {- return false;- }- $user = auth()->user();- if (null === $user) {- app('log')->error('No user during validate2faCode');-- return false;- }- $secret = (string)$user->mfa_secret;-- return (bool) \Google2FA::verifyKey($secret, $value);- }-/*** @param mixed $attribute* @param mixed $value@@ -131,6 +115,22 @@ class FireflyValidator extends Validatorreturn true;}+ public function validateExistingMfaCode($attribute, $value): bool+ {+ if (!is_string($value) || 6 !== strlen($value)) {+ return false;+ }+ $user = auth()->user();+ if (null === $user) {+ app('log')->error('No user during validate2faCode');++ return false;+ }+ $secret = (string) $user->mfa_secret;++ return (bool) \Google2FA::verifyKey($secret, $value);+ }+/*** @SuppressWarnings(PHPMD.UnusedFormalParameter)* @SuppressWarnings(PHPMD.ExcessiveMethodLength)diff --git a/app/Validation/GroupValidation.php b/app/Validation/GroupValidation.phpindex 581c7a239a..84c32cfc90 100644--- a/app/Validation/GroupValidation.php+++ b/app/Validation/GroupValidation.php@@ -66,7 +66,7 @@ trait GroupValidation$hasAccountInfo = false;$hasJournalId = array_key_exists('transaction_journal_id', $transaction);foreach ($keys as $key) {- if (array_key_exists($key, $transaction) && '' !== (string)$transaction[$key]) {+ if (array_key_exists($key, $transaction) && '' !== (string) $transaction[$key]) {$hasAccountInfo = true;}}@@ -74,11 +74,11 @@ trait GroupValidationif (false === $hasAccountInfo && !$hasJournalId) {$validator->errors()->add(sprintf('transactions.%d.source_id', $index),- (string)trans('validation.generic_no_source')+ (string) trans('validation.generic_no_source'));$validator->errors()->add(sprintf('transactions.%d.destination_id', $index),- (string)trans('validation.generic_no_destination')+ (string) trans('validation.generic_no_destination'));}}@@ -117,7 +117,7 @@ trait GroupValidationif (array_key_exists($key, $row)) {$validator->errors()->add(sprintf('transactions.%d.%s', $index, $key),- (string)trans('validation.reconciled_forbidden_field', ['field' => $key])+ (string) trans('validation.reconciled_forbidden_field', ['field' => $key]));}}@@ -139,7 +139,7 @@ trait GroupValidation$transactions = $this->getTransactionsArray($validator);$validDescriptions = 0;foreach ($transactions as $transaction) {- if ('' !== (string)($transaction['description'] ?? null)) {+ if ('' !== (string) ($transaction['description'] ?? null)) {++$validDescriptions;}}@@ -148,7 +148,7 @@ trait GroupValidationif (0 === $validDescriptions) {$validator->errors()->add('transactions.0.description',- (string)trans('validation.filled', ['attribute' => (string)trans('validation.attributes.description')])+ (string) trans('validation.filled', ['attribute' => (string) trans('validation.attributes.description')]));}}@@ -164,7 +164,7 @@ trait GroupValidation$groupTitle = $data['group_title'] ?? '';if ('' === $groupTitle && count($transactions) > 1) {- $validator->errors()->add('group_title', (string)trans('validation.group_title_mandatory'));+ $validator->errors()->add('group_title', (string) trans('validation.group_title_mandatory'));}}@@ -210,12 +210,12 @@ trait GroupValidationreturn;}- $journalId = (int)$journalId;+ $journalId = (int) $journalId;$count = $transactionGroup->transactionJournals()->where('transaction_journals.id', $journalId)->count();if (0 === $journalId || 0 === $count) {app('log')->warning(sprintf('Transaction group #%d has %d journals with ID %d', $transactionGroup->id, $count, $journalId));app('log')->warning('Invalid submission: Each split must have transaction_journal_id (either valid ID or 0).');- $validator->errors()->add(sprintf('transactions.%d.source_name', $index), (string)trans('validation.need_id_in_edit'));+ $validator->errors()->add(sprintf('transactions.%d.source_name', $index), (string) trans('validation.need_id_in_edit'));}}}diff --git a/app/Validation/RecurrenceValidation.php b/app/Validation/RecurrenceValidation.phpindex 166ac36c02..81d74cae6a 100644--- a/app/Validation/RecurrenceValidation.php+++ b/app/Validation/RecurrenceValidation.php@@ -89,7 +89,7 @@ trait RecurrenceValidationcontinue;}// validate source account.- $sourceId = array_key_exists('source_id', $transaction) ? (int)$transaction['source_id'] : null;+ $sourceId = array_key_exists('source_id', $transaction) ? (int) $transaction['source_id'] : null;$sourceName = $transaction['source_name'] ?? null;$validSource = $accountValidator->validateSource(['id' => $sourceId, 'name' => $sourceName]);@@ -101,7 +101,7 @@ trait RecurrenceValidationreturn;}// validate destination account- $destinationId = array_key_exists('destination_id', $transaction) ? (int)$transaction['destination_id'] : null;+ $destinationId = array_key_exists('destination_id', $transaction) ? (int) $transaction['destination_id'] : null;$destinationName = $transaction['destination_name'] ?? null;$validDestination = $accountValidator->validateDestination(['id' => $destinationId, 'name' => $destinationName]);// do something with result:@@ -123,7 +123,7 @@ trait RecurrenceValidation$repetitions = $data['repetitions'] ?? [];// need at least one transactionif (!is_countable($repetitions) || 0 === count($repetitions)) {- $validator->errors()->add('repetitions', (string)trans('validation.at_least_one_repetition'));+ $validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition'));}}@@ -139,7 +139,7 @@ trait RecurrenceValidation}// need at least one transactionif (0 === count($repetitions)) {- $validator->errors()->add('repetitions', (string)trans('validation.at_least_one_repetition'));+ $validator->errors()->add('repetitions', (string) trans('validation.at_least_one_repetition'));}}@@ -154,15 +154,15 @@ trait RecurrenceValidation$repeatUntil = $data['repeat_until'] ?? null;if (null !== $repetitions && null !== $repeatUntil) {// expect a date OR count:- $validator->errors()->add('repeat_until', (string)trans('validation.require_repeat_until'));- $validator->errors()->add('nr_of_repetitions', (string)trans('validation.require_repeat_until'));+ $validator->errors()->add('repeat_until', (string) trans('validation.require_repeat_until'));+ $validator->errors()->add('nr_of_repetitions', (string) trans('validation.require_repeat_until'));}}public function validateRecurringConfig(Validator $validator): void{$data = $validator->getData();- $reps = array_key_exists('nr_of_repetitions', $data) ? (int)$data['nr_of_repetitions'] : null;+ $reps = array_key_exists('nr_of_repetitions', $data) ? (int) $data['nr_of_repetitions'] : null;$repeatUntil = array_key_exists('repeat_until', $data) ? new Carbon($data['repeat_until']) : null;if (null === $reps && null === $repeatUntil) {@@ -182,7 +182,7 @@ trait RecurrenceValidation$data = $validator->getData();$repetitions = $data['repetitions'] ?? [];if (!is_array($repetitions)) {- $validator->errors()->add(sprintf('repetitions.%d.type', 0), (string)trans('validation.valid_recurrence_rep_type'));+ $validator->errors()->add(sprintf('repetitions.%d.type', 0), (string) trans('validation.valid_recurrence_rep_type'));return;}@@ -201,32 +201,32 @@ trait RecurrenceValidationswitch ($repetition['type'] ?? 'empty') {default:- $validator->errors()->add(sprintf('repetitions.%d.type', $index), (string)trans('validation.valid_recurrence_rep_type'));+ $validator->errors()->add(sprintf('repetitions.%d.type', $index), (string) trans('validation.valid_recurrence_rep_type'));return;case 'daily':- $this->validateDaily($validator, $index, (string)$repetition['moment']);+ $this->validateDaily($validator, $index, (string) $repetition['moment']);break;case 'monthly':- $this->validateMonthly($validator, $index, (int)$repetition['moment']);+ $this->validateMonthly($validator, $index, (int) $repetition['moment']);break;case 'ndom':- $this->validateNdom($validator, $index, (string)$repetition['moment']);+ $this->validateNdom($validator, $index, (string) $repetition['moment']);break;case 'weekly':- $this->validateWeekly($validator, $index, (int)$repetition['moment']);+ $this->validateWeekly($validator, $index, (int) $repetition['moment']);break;case 'yearly':- $this->validateYearly($validator, $index, (string)$repetition['moment']);+ $this->validateYearly($validator, $index, (string) $repetition['moment']);break;}@@ -239,7 +239,7 @@ trait RecurrenceValidationprotected function validateDaily(Validator $validator, int $index, string $moment): void{if ('' !== $moment) {- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));}}@@ -249,7 +249,7 @@ trait RecurrenceValidationprotected function validateMonthly(Validator $validator, int $index, int $dayOfMonth): void{if ($dayOfMonth < 1 || $dayOfMonth > 31) {- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));}}@@ -261,19 +261,19 @@ trait RecurrenceValidation{$parameters = explode(',', $moment);if (2 !== count($parameters)) {- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));return;}- $nthDay = (int)($parameters[0] ?? 0.0);- $dayOfWeek = (int)($parameters[1] ?? 0.0);+ $nthDay = (int) ($parameters[0] ?? 0.0);+ $dayOfWeek = (int) ($parameters[1] ?? 0.0);if ($nthDay < 1 || $nthDay > 5) {- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));return;}if ($dayOfWeek < 1 || $dayOfWeek > 7) {- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));}}@@ -283,7 +283,7 @@ trait RecurrenceValidationprotected function validateWeekly(Validator $validator, int $index, int $dayOfWeek): void{if ($dayOfWeek < 1 || $dayOfWeek > 7) {- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));}}@@ -296,7 +296,7 @@ trait RecurrenceValidationCarbon::createFromFormat('Y-m-d', $moment);} catch (\InvalidArgumentException $e) { // @phpstan-ignore-lineapp('log')->debug(sprintf('Invalid argument for Carbon: %s', $e->getMessage()));- $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string)trans('validation.valid_recurrence_rep_moment'));+ $validator->errors()->add(sprintf('repetitions.%d.moment', $index), (string) trans('validation.valid_recurrence_rep_moment'));}}@@ -311,7 +311,7 @@ trait RecurrenceValidationif (0 === $submittedTrCount) {app('log')->warning('[b] User submitted no transactions.');- $validator->errors()->add('transactions', (string)trans('validation.at_least_one_transaction'));+ $validator->errors()->add('transactions', (string) trans('validation.at_least_one_transaction'));return;}@@ -324,16 +324,16 @@ trait RecurrenceValidationreturn; // home safe!}$id = $first['id'];- if ('' === (string)$id) {+ if ('' === (string) $id) {app('log')->debug('Single count and empty ID, done.');return; // home safe!}- $integer = (int)$id;+ $integer = (int) $id;$secondCount = $recurrence->recurrenceTransactions()->where('recurrences_transactions.id', $integer)->count();app('log')->debug(sprintf('Result of ID count: %d', $secondCount));if (0 === $secondCount) {- $validator->errors()->add('transactions.0.id', (string)trans('validation.id_does_not_match', ['id' => $integer]));+ $validator->errors()->add('transactions.0.id', (string) trans('validation.id_does_not_match', ['id' => $integer]));}app('log')->debug('Single ID validation done.');@@ -364,19 +364,19 @@ trait RecurrenceValidationapp('log')->debug(sprintf('Now at %d/%d', $index + 1, $submittedTrCount));if (!is_array($transaction)) {app('log')->warning('Not an array. Give error.');- $validator->errors()->add(sprintf('transactions.%d.id', $index), (string)trans('validation.at_least_one_transaction'));+ $validator->errors()->add(sprintf('transactions.%d.id', $index), (string) trans('validation.at_least_one_transaction'));return;}if (!array_key_exists('id', $transaction) && $idsMandatory) {app('log')->warning('ID is mandatory but array has no ID.');- $validator->errors()->add(sprintf('transactions.%d.id', $index), (string)trans('validation.need_id_to_match'));+ $validator->errors()->add(sprintf('transactions.%d.id', $index), (string) trans('validation.need_id_to_match'));return;}if (array_key_exists('id', $transaction)) { // don't matter if $idsMandatoryapp('log')->debug('Array has ID.');- $idCount = $recurrence->recurrenceTransactions()->where('recurrences_transactions.id', (int)$transaction['id'])->count();+ $idCount = $recurrence->recurrenceTransactions()->where('recurrences_transactions.id', (int) $transaction['id'])->count();if (0 === $idCount) {app('log')->debug('ID does not exist or no match. Count another unmatched ID.');++$unmatchedIds;@@ -392,7 +392,7 @@ trait RecurrenceValidationapp('log')->debug(sprintf('Submitted: %d. Original: %d. User can submit %d unmatched transactions.', $submittedTrCount, $originalTrCount, $maxUnmatched));if ($unmatchedIds > $maxUnmatched) {app('log')->warning(sprintf('Too many unmatched transactions (%d).', $unmatchedIds));- $validator->errors()->add('transactions.0.id', (string)trans('validation.too_many_unmatched'));+ $validator->errors()->add('transactions.0.id', (string) trans('validation.too_many_unmatched'));return;}diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.phpindex 8cb6224894..81f77a0c1c 100644--- a/app/Validation/TransactionValidation.php+++ b/app/Validation/TransactionValidation.php@@ -109,10 +109,10 @@ trait TransactionValidation$accountValidator->setTransactionType($transactionType);// validate source account.- $sourceId = array_key_exists('source_id', $transaction) ? (int)$transaction['source_id'] : null;- $sourceName = array_key_exists('source_name', $transaction) ? (string)$transaction['source_name'] : null;- $sourceIban = array_key_exists('source_iban', $transaction) ? (string)$transaction['source_iban'] : null;- $sourceNumber = array_key_exists('source_number', $transaction) ? (string)$transaction['source_number'] : null;+ $sourceId = array_key_exists('source_id', $transaction) ? (int) $transaction['source_id'] : null;+ $sourceName = array_key_exists('source_name', $transaction) ? (string) $transaction['source_name'] : null;+ $sourceIban = array_key_exists('source_iban', $transaction) ? (string) $transaction['source_iban'] : null;+ $sourceNumber = array_key_exists('source_number', $transaction) ? (string) $transaction['source_number'] : null;$source = ['id' => $sourceId,'name' => $sourceName,@@ -129,10 +129,10 @@ trait TransactionValidationreturn;}// validate destination account- $destinationId = array_key_exists('destination_id', $transaction) ? (int)$transaction['destination_id'] : null;- $destinationName = array_key_exists('destination_name', $transaction) ? (string)$transaction['destination_name'] : null;- $destinationIban = array_key_exists('destination_iban', $transaction) ? (string)$transaction['destination_iban'] : null;- $destinationNumber = array_key_exists('destination_number', $transaction) ? (string)$transaction['destination_number'] : null;+ $destinationId = array_key_exists('destination_id', $transaction) ? (int) $transaction['destination_id'] : null;+ $destinationName = array_key_exists('destination_name', $transaction) ? (string) $transaction['destination_name'] : null;+ $destinationIban = array_key_exists('destination_iban', $transaction) ? (string) $transaction['destination_iban'] : null;+ $destinationNumber = array_key_exists('destination_number', $transaction) ? (string) $transaction['destination_number'] : null;$destination = ['id' => $destinationId,'name' => $destinationName,@@ -244,17 +244,17 @@ trait TransactionValidation// no foreign currency information is present:if (!$this->hasForeignCurrencyInfo($transaction)) {- $validator->errors()->add(sprintf('transactions.%d.foreign_amount', $index), (string)trans('validation.require_foreign_currency'));+ $validator->errors()->add(sprintf('transactions.%d.foreign_amount', $index), (string) trans('validation.require_foreign_currency'));return;}// wrong currency information is present$foreignCurrencyCode = $transaction['foreign_currency_code'] ?? false;- $foreignCurrencyId = (int)($transaction['foreign_currency_id'] ?? 0);+ $foreignCurrencyId = (int) ($transaction['foreign_currency_id'] ?? 0);app('log')->debug(sprintf('Foreign currency code seems to be #%d "%s"', $foreignCurrencyId, $foreignCurrencyCode), $transaction);if ($foreignCurrencyCode !== $sourceCurrency->code && $foreignCurrencyId !== $sourceCurrency->id) {- $validator->errors()->add(sprintf('transactions.%d.foreign_currency_code', $index), (string)trans('validation.require_foreign_src'));+ $validator->errors()->add(sprintf('transactions.%d.foreign_currency_code', $index), (string) trans('validation.require_foreign_src'));return;}@@ -271,19 +271,19 @@ trait TransactionValidation// no foreign currency information is present:if (!$this->hasForeignCurrencyInfo($transaction)) {- $validator->errors()->add(sprintf('transactions.%d.foreign_amount', $index), (string)trans('validation.require_foreign_currency'));+ $validator->errors()->add(sprintf('transactions.%d.foreign_amount', $index), (string) trans('validation.require_foreign_currency'));return;}// wrong currency information is present$foreignCurrencyCode = $transaction['foreign_currency_code'] ?? false;- $foreignCurrencyId = (int)($transaction['foreign_currency_id'] ?? 0);+ $foreignCurrencyId = (int) ($transaction['foreign_currency_id'] ?? 0);app('log')->debug(sprintf('Foreign currency code seems to be #%d "%s"', $foreignCurrencyId, $foreignCurrencyCode), $transaction);if ($foreignCurrencyCode !== $destinationCurrency->code && $foreignCurrencyId !== $destinationCurrency->id) {app('log')->debug(sprintf('No match on code, "%s" vs "%s"', $foreignCurrencyCode, $destinationCurrency->code));app('log')->debug(sprintf('No match on ID, #%d vs #%d', $foreignCurrencyId, $destinationCurrency->id));- $validator->errors()->add(sprintf('transactions.%d.foreign_amount', $index), (string)trans('validation.require_foreign_dest'));+ $validator->errors()->add(sprintf('transactions.%d.foreign_amount', $index), (string) trans('validation.require_foreign_dest'));}}}@@ -321,7 +321,7 @@ trait TransactionValidationif ('' === $transaction['foreign_amount']) {return false;}- if (0 === bccomp('0', (string)$transaction['foreign_amount'])) {+ if (0 === bccomp('0', (string) $transaction['foreign_amount'])) {return false;}@@ -386,7 +386,7 @@ trait TransactionValidation|| array_key_exists('source_number', $transaction)) {app('log')->debug('Will try to validate source account information.');- $sourceId = (int)($transaction['source_id'] ?? 0);+ $sourceId = (int) ($transaction['source_id'] ?? 0);$sourceName = $transaction['source_name'] ?? null;$sourceIban = $transaction['source_iban'] ?? null;$sourceNumber = $transaction['source_number'] ?? null;@@ -425,7 +425,7 @@ trait TransactionValidation$accountValidator->source = $source;}}- $destinationId = (int)($transaction['destination_id'] ?? 0);+ $destinationId = (int) ($transaction['destination_id'] ?? 0);$destinationName = $transaction['destination_name'] ?? null;$destinationIban = $transaction['destination_iban'] ?? null;$destinationNumber = $transaction['destination_number'] ?? null;@@ -444,7 +444,7 @@ trait TransactionValidationprivate function getTransactionType(TransactionGroup $group, array $transactions): string{- return $transactions[0]['type'] ?? strtolower((string)$group->transactionJournals()->first()?->transactionType->type);+ return $transactions[0]['type'] ?? strtolower((string) $group->transactionJournals()->first()?->transactionType->type);}private function getOriginalSource(array $transaction, TransactionGroup $transactionGroup): ?Account@@ -457,7 +457,7 @@ trait TransactionValidation/** @var TransactionJournal $journal */foreach ($transactionGroup->transactionJournals as $journal) {- $journalId = (int)($transaction['transaction_journal_id'] ?? 0);+ $journalId = (int) ($transaction['transaction_journal_id'] ?? 0);if ($journal->id === $journalId) {return $journal->transactions()->where('amount', '<', 0)->first()?->account;}@@ -476,7 +476,7 @@ trait TransactionValidation// need at least one transactionif (0 === count($transactions)) {- $validator->errors()->add('transactions', (string)trans('validation.at_least_one_transaction'));+ $validator->errors()->add('transactions', (string) trans('validation.at_least_one_transaction'));}}@@ -494,7 +494,7 @@ trait TransactionValidation$transactions = $this->getTransactionsArray($validator);// need at least one transactionif (0 === count($transactions)) {- $validator->errors()->add('transactions.0.description', (string)trans('validation.at_least_one_transaction'));+ $validator->errors()->add('transactions.0.description', (string) trans('validation.at_least_one_transaction'));app('log')->debug('Added error: at_least_one_transaction.');return;@@ -510,7 +510,7 @@ trait TransactionValidation$transactions = $this->getTransactionsArray($validator);foreach (array_keys($transactions) as $key) {if (!is_int($key)) {- $validator->errors()->add('transactions.0.description', (string)trans('validation.at_least_one_transaction'));+ $validator->errors()->add('transactions.0.description', (string) trans('validation.at_least_one_transaction'));app('log')->debug('Added error: at_least_one_transaction.');return;@@ -535,13 +535,13 @@ trait TransactionValidation}$unique = array_unique($types);if (count($unique) > 1) {- $validator->errors()->add('transactions.0.type', (string)trans('validation.transaction_types_equal'));+ $validator->errors()->add('transactions.0.type', (string) trans('validation.transaction_types_equal'));return;}$first = $unique[0] ?? 'invalid';if ('invalid' === $first) {- $validator->errors()->add('transactions.0.type', (string)trans('validation.invalid_transaction_type'));+ $validator->errors()->add('transactions.0.type', (string) trans('validation.invalid_transaction_type'));}}@@ -554,14 +554,14 @@ trait TransactionValidation$transactions = $this->getTransactionsArray($validator);$types = [];foreach ($transactions as $transaction) {- $originalType = $this->getOriginalType((int)($transaction['transaction_journal_id'] ?? 0));+ $originalType = $this->getOriginalType((int) ($transaction['transaction_journal_id'] ?? 0));// if type is not set, fall back to the type of the journal, if one is given.$types[] = $transaction['type'] ?? $originalType;}$unique = array_unique($types);if (count($unique) > 1) {app('log')->warning('Add error for mismatch transaction types.');- $validator->errors()->add('transactions.0.type', (string)trans('validation.transaction_types_equal'));+ $validator->errors()->add('transactions.0.type', (string) trans('validation.transaction_types_equal'));return;}@@ -609,22 +609,22 @@ trait TransactionValidationdefault:case 'withdrawal':if (count($sources) > 1) {- $validator->errors()->add('transactions.0.source_id', (string)trans('validation.all_accounts_equal'));+ $validator->errors()->add('transactions.0.source_id', (string) trans('validation.all_accounts_equal'));}break;case 'deposit':if (count($dests) > 1) {- $validator->errors()->add('transactions.0.destination_id', (string)trans('validation.all_accounts_equal'));+ $validator->errors()->add('transactions.0.destination_id', (string) trans('validation.all_accounts_equal'));}break;case 'transfer':if (count($sources) > 1 || count($dests) > 1) {- $validator->errors()->add('transactions.0.source_id', (string)trans('validation.all_accounts_equal'));- $validator->errors()->add('transactions.0.destination_id', (string)trans('validation.all_accounts_equal'));+ $validator->errors()->add('transactions.0.source_id', (string) trans('validation.all_accounts_equal'));+ $validator->errors()->add('transactions.0.destination_id', (string) trans('validation.all_accounts_equal'));}break;@@ -658,14 +658,14 @@ trait TransactionValidation$result = $this->compareAccountData($type, $comparison);if (false === $result) {if ('withdrawal' === $type) {- $validator->errors()->add('transactions.0.source_id', (string)trans('validation.all_accounts_equal'));+ $validator->errors()->add('transactions.0.source_id', (string) trans('validation.all_accounts_equal'));}if ('deposit' === $type) {- $validator->errors()->add('transactions.0.destination_id', (string)trans('validation.all_accounts_equal'));+ $validator->errors()->add('transactions.0.destination_id', (string) trans('validation.all_accounts_equal'));}if ('transfer' === $type) {- $validator->errors()->add('transactions.0.source_id', (string)trans('validation.all_accounts_equal'));- $validator->errors()->add('transactions.0.destination_id', (string)trans('validation.all_accounts_equal'));+ $validator->errors()->add('transactions.0.source_id', (string) trans('validation.all_accounts_equal'));+ $validator->errors()->add('transactions.0.destination_id', (string) trans('validation.all_accounts_equal'));}app('log')->warning('Add error about equal accounts.');@@ -684,7 +684,7 @@ trait TransactionValidation/** @var array $transaction */foreach ($transactions as $transaction) {// source or destination may be omitted. If this is the case, use the original source / destination name + ID.- $originalData = $this->getOriginalData((int)($transaction['transaction_journal_id'] ?? 0));+ $originalData = $this->getOriginalData((int) ($transaction['transaction_journal_id'] ?? 0));// get field.$comparison[$field][] = $transaction[$field] ?? $originalData[$field];diff --git a/config/auth.php b/config/auth.phpindex 6f95c59d94..64c07ce59b 100644--- a/config/auth.php+++ b/config/auth.php@@ -24,7 +24,7 @@ declare(strict_types=1);use FireflyIII\User;-if ('ldap' === strtolower((string)env('AUTHENTICATION_GUARD'))) {+if ('ldap' === strtolower((string) env('AUTHENTICATION_GUARD'))) {exit('LDAP is no longer supported by Firefly III v5.7+. Sorry about that. You will have to switch to "remote_user_guard", and use tools like Authelia or Keycloak to use LDAP together with Firefly III.');}diff --git a/config/cache.php b/config/cache.phpindex 5da5576828..7b0e7d97b5 100644--- a/config/cache.php+++ b/config/cache.php@@ -83,7 +83,7 @@ return ['servers' => [['host' => env('MEMCACHED_HOST', '127.0.0.1'),- 'port' => (int)env('MEMCACHED_PORT', 11211),+ 'port' => (int) env('MEMCACHED_PORT', 11211),'weight' => 100,],],diff --git a/config/firefly.php b/config/firefly.phpindex 66c8ba2a1e..33fd2f4360 100644--- a/config/firefly.php+++ b/config/firefly.php@@ -148,7 +148,6 @@ return ['update_minimum_age' => 7,-// enabled languages'languages' => [// currently enabled languagesdiff --git a/config/logging.php b/config/logging.phpindex 145811d215..707db4249c 100644--- a/config/logging.php+++ b/config/logging.php@@ -34,8 +34,8 @@ $validChannels = ['single', 'papertrail', 'stdout', 'daily', 'syslog', 'err$validAuditChannels = ['audit_papertrail', 'audit_stdout', 'audit_stdout', 'audit_daily', 'audit_syslog', 'audit_errorlog'];// which settings did the user set, if any?-$defaultLogChannel = (string)envNonEmpty('LOG_CHANNEL', 'stack');-$auditLogChannel = (string)envNonEmpty('AUDIT_LOG_CHANNEL', '');+$defaultLogChannel = (string) envNonEmpty('LOG_CHANNEL', 'stack');+$auditLogChannel = (string) envNonEmpty('AUDIT_LOG_CHANNEL', '');if ('stack' === $defaultLogChannel) {$defaultChannels = ['daily', 'stdout'];diff --git a/config/mail.php b/config/mail.phpindex c095afa351..e9742e651a 100644--- a/config/mail.php+++ b/config/mail.php@@ -39,7 +39,7 @@ return ['smtp' => ['transport' => 'smtp','host' => envNonEmpty('MAIL_HOST', 'smtp.mailtrap.io'),- 'port' => (int)env('MAIL_PORT', 2525),+ 'port' => (int) env('MAIL_PORT', 2525),'encryption' => envNonEmpty('MAIL_ENCRYPTION', 'tls'),'username' => envNonEmpty('MAIL_USERNAME', '[email protected]'),'password' => envNonEmpty('MAIL_PASSWORD', 'password'),diff --git a/config/notifications.php b/config/notifications.phpindex 1bfd2988eb..a3e1bd7630 100644--- a/config/notifications.php+++ b/config/notifications.php@@ -24,10 +24,10 @@ declare(strict_types=1);return ['channels' => [- 'email' => ['enabled' => true, 'ui_configurable' => 0],- 'slack' => ['enabled' => true, 'ui_configurable' => 1],- 'ntfy' => ['enabled' => true, 'ui_configurable' => 1],- 'pushover' => ['enabled' => true, 'ui_configurable' => 1],+ 'email' => ['enabled' => true, 'ui_configurable' => 0],+ 'slack' => ['enabled' => true, 'ui_configurable' => 1],+ 'ntfy' => ['enabled' => true, 'ui_configurable' => 1],+ 'pushover' => ['enabled' => true, 'ui_configurable' => 1],// 'gotify' => ['enabled' => false, 'ui_configurable' => 0],// 'pushbullet' => ['enabled' => false, 'ui_configurable' => 0],],diff --git a/database/migrations/2024_12_19_061003_add_native_amount_column.php b/database/migrations/2024_12_19_061003_add_native_amount_column.phpindex 8f754f9d8c..74a738793b 100644--- a/database/migrations/2024_12_19_061003_add_native_amount_column.php+++ b/database/migrations/2024_12_19_061003_add_native_amount_column.php@@ -7,21 +7,22 @@ use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;return new class () extends Migration {- private array $tables = [- // !!! this array is also in PreferencesEventHandler + RecalculateNativeAmountsCommand- 'accounts' => ['native_virtual_balance'], // works.- 'account_piggy_bank' => ['native_current_amount'], // works- 'auto_budgets' => ['native_amount'], // works- 'available_budgets' => ['native_amount'], // works- 'bills' => ['native_amount_min', 'native_amount_max'], // works- 'budget_limits' => ['native_amount'], // works- 'piggy_bank_events' => ['native_amount'], // works- 'piggy_banks' => ['native_target_amount'], // works- 'transactions' => ['native_amount', 'native_foreign_amount'], // works+ private array $tables+ = [+ // !!! this array is also in PreferencesEventHandler + RecalculateNativeAmountsCommand+ 'accounts' => ['native_virtual_balance'], // works.+ 'account_piggy_bank' => ['native_current_amount'], // works+ 'auto_budgets' => ['native_amount'], // works+ 'available_budgets' => ['native_amount'], // works+ 'bills' => ['native_amount_min', 'native_amount_max'], // works+ 'budget_limits' => ['native_amount'], // works+ 'piggy_bank_events' => ['native_amount'], // works+ 'piggy_banks' => ['native_target_amount'], // works+ 'transactions' => ['native_amount', 'native_foreign_amount'], // works- // TODO button to recalculate all native amounts on selected pages?+ // TODO button to recalculate all native amounts on selected pages?- ];+ ];/*** Run the migrations.diff --git a/routes/api.php b/routes/api.phpindex 27307be17e..b0d31ec8b5 100644--- a/routes/api.php+++ b/routes/api.php@@ -115,8 +115,8 @@ Route::group(static function (): void {Route::get('', ['uses' => 'IndexController@index', 'as' => 'index']);Route::get('rates/{fromCurrencyCode}/{toCurrencyCode}', ['uses' => 'ShowController@show', 'as' => 'show']);-// Route::post('', ['uses' => 'StoreController@store', 'as' => 'store']);-//+ // Route::post('', ['uses' => 'StoreController@store', 'as' => 'store']);+ //// Route::put('{userGroup}', ['uses' => 'UpdateController@update', 'as' => 'update']);// Route::post('{userGroup}/use', ['uses' => 'UpdateController@useUserGroup', 'as' => 'use']);// Route::put('{userGroup}/update-membership', ['uses' => 'UpdateController@updateMembership', 'as' => 'updateMembership']);