Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
🤖 Auto commit for release 'develop' on 2026-08-27
JC5a9b1b2b6643b
diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.phpindex 77dac54cac..b8fd44c9cc 100644--- a/app/Api/V1/Controllers/Autocomplete/AccountController.php+++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php@@ -51,8 +51,9 @@ final class AccountController extends Controllerprotected array $acceptedRoles = [UserRoleEnum::READ_ONLY];#[Override]protected array $accepts = ['application/json', 'application/vnd.api+json'];+/** @var array<int, string> */- private array $balanceTypes;+ private array $balanceTypes;private AccountRepositoryInterface $repository;/**@@ -89,9 +90,9 @@ final class AccountController extends Controller// set date to end-of-day for account balance. so it is at $date 23:59:59$date->endOfDay();- $return = [];- $result = $this->repository->searchAccount((string)$query, $types, $limit);- $allBalances = Steam::accountsBalancesOptimized($result, $date, $this->primaryCurrency, $this->convertToPrimary);+ $return = [];+ $result = $this->repository->searchAccount((string) $query, $types, $limit);+ $allBalances = Steam::accountsBalancesOptimized($result, $date, $this->primaryCurrency, $this->convertToPrimary);/** @var Account $account */foreach ($result as $account) {@@ -108,18 +109,18 @@ final class AccountController extends Controller$nameWithBalance = sprintf('%s (%s)', $account->name, Amount::formatAnything($useCurrency, $amount, false));}- $return[] = [- 'id' => (string)$account->id,+ $return[] = [+ 'id' => (string) $account->id,'name' => $account->name,'name_with_balance' => $nameWithBalance,'active' => $account->active,'type' => $account->accountType->type,- 'currency_id' => (string)$useCurrency->id,+ 'currency_id' => (string) $useCurrency->id,'currency_name' => $useCurrency->name,'currency_code' => $useCurrency->code,'currency_symbol' => $useCurrency->symbol,'currency_decimal_places' => $useCurrency->decimal_places,- 'account_currency_id' => (string)$currency->id,+ 'account_currency_id' => (string) $currency->id,'account_currency_name' => $currency->name,'account_currency_code' => $currency->code,'account_currency_symbol' => $currency->symbol,@@ -130,8 +131,8 @@ final class AccountController extends Controller// custom order.usort($return, static function (array $left, array $right): int {$order = [AccountTypeEnum::ASSET->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::EXPENSE->value];- $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 83bde73e0e..aeed709b53 100644--- a/app/Api/V1/Controllers/Autocomplete/BillController.php+++ b/app/Api/V1/Controllers/Autocomplete/BillController.php@@ -39,7 +39,7 @@ use Override;final class BillController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_SUBSCRIPTIONS];+ protected array $acceptedRoles = [UserRoleEnum::READ_SUBSCRIPTIONS];private BillRepositoryInterface $repository;/**@@ -65,7 +65,7 @@ final class BillController extends Controllerpublic function bills(AutocompleteApiRequest $request): JsonResponse{$result = $this->repository->searchBill($request->attributes->get('query'), $request->attributes->get('limit'));- $filtered = $result->map(static fn(Bill $item): array => ['id' => (string)$item->id, 'name' => $item->name, 'active' => $item->active]);+ $filtered = $result->map(static fn (Bill $item): array => ['id' => (string) $item->id, 'name' => $item->name, 'active' => $item->active]);return response()->api($filtered->toArray());}diff --git a/app/Api/V1/Controllers/Autocomplete/BudgetController.php b/app/Api/V1/Controllers/Autocomplete/BudgetController.phpindex 51315938ff..c3948d850c 100644--- a/app/Api/V1/Controllers/Autocomplete/BudgetController.php+++ b/app/Api/V1/Controllers/Autocomplete/BudgetController.php@@ -39,7 +39,7 @@ use Override;final class BudgetController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_BUDGETS];+ protected array $acceptedRoles = [UserRoleEnum::READ_BUDGETS];private BudgetRepositoryInterface $repository;/**@@ -65,7 +65,7 @@ final class BudgetController extends Controllerpublic function budgets(AutocompleteApiRequest $request): JsonResponse{$result = $this->repository->searchBudget($request->attributes->get('query'), $request->attributes->get('limit'));- $filtered = $result->map(static fn(Budget $item): array => ['id' => (string)$item->id, 'name' => $item->name, 'active' => $item->active]);+ $filtered = $result->map(static fn (Budget $item): array => ['id' => (string) $item->id, 'name' => $item->name, 'active' => $item->active]);return response()->api($filtered->toArray());}diff --git a/app/Api/V1/Controllers/Autocomplete/CategoryController.php b/app/Api/V1/Controllers/Autocomplete/CategoryController.phpindex 2b7dd82e84..6932106a37 100644--- a/app/Api/V1/Controllers/Autocomplete/CategoryController.php+++ b/app/Api/V1/Controllers/Autocomplete/CategoryController.php@@ -39,7 +39,7 @@ use Override;final class CategoryController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];private CategoryRepositoryInterface $repository;/**@@ -65,7 +65,7 @@ final class CategoryController extends Controllerpublic function categories(AutocompleteApiRequest $request): JsonResponse{$result = $this->repository->searchCategory($request->attributes->get('query'), $request->attributes->get('limit'));- $filtered = $result->map(static fn(Category $item): array => ['id' => (string)$item->id, 'name' => $item->name]);+ $filtered = $result->map(static fn (Category $item): array => ['id' => (string) $item->id, 'name' => $item->name]);return response()->api($filtered->toArray());}diff --git a/app/Api/V1/Controllers/Autocomplete/CurrencyController.php b/app/Api/V1/Controllers/Autocomplete/CurrencyController.phpindex 92a93db162..6be9bfd454 100644--- a/app/Api/V1/Controllers/Autocomplete/CurrencyController.php+++ b/app/Api/V1/Controllers/Autocomplete/CurrencyController.php@@ -41,7 +41,7 @@ use Override;final class CurrencyController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];private CurrencyRepositoryInterface $repository;/**@@ -72,7 +72,7 @@ final 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,@@ -97,7 +97,7 @@ final 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 8a793e97be..f5512cb690 100644--- a/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php+++ b/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php@@ -39,7 +39,7 @@ use Override;final class ObjectGroupController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];private ObjectGroupRepositoryInterface $repository;/**@@ -69,7 +69,7 @@ final class ObjectGroupController extends Controller/** @var ObjectGroup $objectGroup */foreach ($result as $objectGroup) {- $return[] = ['id' => (string)$objectGroup->id, 'name' => $objectGroup->title, 'title' => $objectGroup->title];+ $return[] = ['id' => (string) $objectGroup->id, 'name' => $objectGroup->title, 'title' => $objectGroup->title];}return response()->api($return);diff --git a/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php b/app/Api/V1/Controllers/Autocomplete/PiggyBankController.phpindex d6ed095071..eebbf95660 100644--- a/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php+++ b/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php@@ -42,8 +42,8 @@ use Override;final class PiggyBankController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_PIGGY_BANKS];- private AccountRepositoryInterface $accountRepository;+ protected array $acceptedRoles = [UserRoleEnum::READ_PIGGY_BANKS];+ private AccountRepositoryInterface $accountRepository;private PiggyBankRepositoryInterface $piggyRepository;/**@@ -75,14 +75,14 @@ final 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,'object_group_order' => $objectGroup?->order,];@@ -103,7 +103,7 @@ final 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)',@@ -111,12 +111,12 @@ final class PiggyBankController extends ControllerAmount::formatAnything($currency, $currentAmount, false),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,'object_group_order' => $objectGroup?->order,];diff --git a/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php b/app/Api/V1/Controllers/Autocomplete/RecurrenceController.phpindex 8de4f02291..6e0aa34077 100644--- a/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php+++ b/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php@@ -39,7 +39,7 @@ use Override;final class RecurrenceController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_RECURRING];+ protected array $acceptedRoles = [UserRoleEnum::READ_RECURRING];private RecurringRepositoryInterface $repository;/**@@ -66,7 +66,7 @@ final 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,'active' => $recurrence->active,diff --git a/app/Api/V1/Controllers/Autocomplete/RuleController.php b/app/Api/V1/Controllers/Autocomplete/RuleController.phpindex cf2a1e8d31..6f7a568328 100644--- a/app/Api/V1/Controllers/Autocomplete/RuleController.php+++ b/app/Api/V1/Controllers/Autocomplete/RuleController.php@@ -39,7 +39,7 @@ use Override;final class RuleController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_RULES];+ protected array $acceptedRoles = [UserRoleEnum::READ_RULES];private RuleRepositoryInterface $repository;/**@@ -66,7 +66,7 @@ final 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,'active' => $rule->active,diff --git a/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php b/app/Api/V1/Controllers/Autocomplete/RuleGroupController.phpindex a8b18c9d09..4302b69af1 100644--- a/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php+++ b/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php@@ -39,7 +39,7 @@ use Override;final class RuleGroupController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_RULES];+ protected array $acceptedRoles = [UserRoleEnum::READ_RULES];private RuleGroupRepositoryInterface $repository;/**@@ -66,7 +66,7 @@ final 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,'active' => $group->active,diff --git a/app/Api/V1/Controllers/Autocomplete/TagController.php b/app/Api/V1/Controllers/Autocomplete/TagController.phpindex af57b63832..2ef820eea3 100644--- a/app/Api/V1/Controllers/Autocomplete/TagController.php+++ b/app/Api/V1/Controllers/Autocomplete/TagController.php@@ -39,7 +39,7 @@ use Override;final class TagController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];private TagRepositoryInterface $repository;/**@@ -65,7 +65,7 @@ final class TagController extends Controller/** @var Tag $tag */foreach ($result as $tag) {- $array[] = ['id' => (string)$tag->id, 'name' => $tag->tag, 'tag' => $tag->tag];+ $array[] = ['id' => (string) $tag->id, 'name' => $tag->tag, 'tag' => $tag->tag];}return response()->api($array);diff --git a/app/Api/V1/Controllers/Autocomplete/TransactionController.php b/app/Api/V1/Controllers/Autocomplete/TransactionController.phpindex d8d4eb1f06..746c0732fb 100644--- a/app/Api/V1/Controllers/Autocomplete/TransactionController.php+++ b/app/Api/V1/Controllers/Autocomplete/TransactionController.php@@ -45,9 +45,9 @@ use Override;final class TransactionController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];private TransactionGroupRepositoryInterface $groupRepository;- private JournalRepositoryInterface $repository;+ private JournalRepositoryInterface $repository;/*** TransactionController constructor.@@ -70,7 +70,7 @@ final class TransactionController extends Controllerpublic function transactions(AutocompleteTransactionApiRequest $request): JsonResponse{- $result = $this->repository->searchJournalDescriptions($request->attributes->get('query'), $request->attributes->get('limit'));+ $result = $this->repository->searchJournalDescriptions($request->attributes->get('query'), $request->attributes->get('limit'));// limit and unique$filtered = $result->unique('description');@@ -79,8 +79,8 @@ final 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,];@@ -94,7 +94,7 @@ final class TransactionController extends Controller$result = new Collection();if (is_numeric($request->attributes->get('query'))) {// search for group, not journal.- $firstResult = $this->groupRepository->find((int)$request->attributes->get('query'));+ $firstResult = $this->groupRepository->find((int) $request->attributes->get('query'));if ($firstResult instanceof TransactionGroup) {// group may contain multiple journals, each a result:foreach ($firstResult->transactionJournals as $journal) {@@ -107,13 +107,13 @@ final class TransactionController extends Controller}// limit and unique- $array = [];+ $array = [];/** @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),];@@ -127,7 +127,7 @@ final class TransactionController extends Controller$result = new Collection();if (is_numeric($request->attributes->get('query'))) {// search for group, not journal.- $firstResult = $this->groupRepository->find((int)$request->attributes->get('query'));+ $firstResult = $this->groupRepository->find((int) $request->attributes->get('query'));if ($firstResult instanceof TransactionGroup) {// group may contain multiple journals, each a result:foreach ($firstResult->transactionJournals as $journal) {@@ -140,14 +140,14 @@ final class TransactionController extends Controller}// limit and unique- $array = [];+ $array = [];/** @var TransactionJournal $journal */foreach ($result as $journal) {$currency = Amount::getCurrencyFromJournal($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,'date' => $journal->date,diff --git a/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php b/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.phpindex a950c1121d..920fc1b42f 100644--- a/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php+++ b/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php@@ -39,7 +39,7 @@ use Override;final class TransactionTypeController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];private TransactionTypeRepositoryInterface $repository;/**@@ -64,7 +64,7 @@ final class TransactionTypeController extends Controller/** @var TransactionType $type */foreach ($types as $type) {// different key for consistency.- $array[] = ['id' => (string)$type->id, 'name' => $type->type, 'type' => $type->type];+ $array[] = ['id' => (string) $type->id, 'name' => $type->type, 'type' => $type->type];}return response()->api($array);diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.phpindex 4de0c90275..06380836b0 100644--- a/app/Api/V1/Controllers/Chart/AccountController.php+++ b/app/Api/V1/Controllers/Chart/AccountController.php@@ -52,7 +52,7 @@ final class AccountController extends Controllerprotected array $acceptedRoles = [UserRoleEnum::READ_ONLY];- private array $chartData = [];+ private array $chartData = [];private AccountRepositoryInterface $repository;/**@@ -100,28 +100,28 @@ final class AccountController extends Controllerprivate function renderAccountData(array $params, Account $account): void{Log::debug(sprintf('Now in %s(array, #%d)', __METHOD__, $account->id));- $currency = $this->repository->getAccountCurrency($account);- $currentStart = clone $params['start'];- $range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToPrimary);- $period = $params['period'] ?? '1D';+ $currency = $this->repository->getAccountCurrency($account);+ $currentStart = clone $params['start'];+ $range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToPrimary);+ $period = $params['period'] ?? '1D';- $previous = array_values($range)[0]['balance'];- $pcPrevious = null;+ $previous = array_values($range)[0]['balance'];+ $pcPrevious = null;if (!$currency instanceof TransactionCurrency) {$currency = $this->primaryCurrency;}- $currentSet = [+ $currentSet = ['label' => $account->name,// the currency that belongs to the account.- '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,// the primary currency- 'primary_currency_id' => (string)$this->primaryCurrency->id,+ 'primary_currency_id' => (string) $this->primaryCurrency->id,// the default currency of the user (could be the same!)'date' => $params['start']->toAtomString(),@@ -135,7 +135,7 @@ final class AccountController extends Controller];if ($this->convertToPrimary) {$currentSet['pc_entries'] = [];- $currentSet['primary_currency_id'] = (string)$this->primaryCurrency->id;+ $currentSet['primary_currency_id'] = (string) $this->primaryCurrency->id;$currentSet['primary_currency_code'] = $this->primaryCurrency->code;$currentSet['primary_currency_symbol'] = $this->primaryCurrency->symbol;$currentSet['primary_currency_decimal_places'] = $this->primaryCurrency->decimal_places;@@ -143,13 +143,13 @@ final class AccountController extends Controller}// create array of values to collect.- $rangeDates = array_map(static fn(string $d): Carbon => Carbon::createFromFormat('Y-m-d', $d)->startOfDay(), array_keys($range));- $rangeVals = array_values($range);- $rangeIdx = 0;- $rangeCount = count($rangeDates);+ $rangeDates = array_map(static fn (string $d): Carbon => Carbon::createFromFormat('Y-m-d', $d)->startOfDay(), array_keys($range));+ $rangeVals = array_values($range);+ $rangeIdx = 0;+ $rangeCount = count($rangeDates);while ($currentStart <= $params['end']) {- $label = $currentStart->toAtomString();+ $label = $currentStart->toAtomString();// Advance through all range entries up to current chart datewhile ($rangeIdx < $rangeCount && $rangeDates[$rangeIdx] <= $currentStart) {@@ -165,7 +165,7 @@ final class AccountController extends Controller$currentSet['pc_entries'][$label] = $pcPrevious;}- $currentStart = Navigation::addPeriod($currentStart, $period);+ $currentStart = Navigation::addPeriod($currentStart, $period);}$this->chartData[] = $currentSet;}diff --git a/app/Api/V1/Controllers/Chart/BalanceController.php b/app/Api/V1/Controllers/Chart/BalanceController.phpindex 7da7585bbe..7885bab44a 100644--- a/app/Api/V1/Controllers/Chart/BalanceController.php+++ b/app/Api/V1/Controllers/Chart/BalanceController.php@@ -49,8 +49,8 @@ final class BalanceController extends Controller#[Override]protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];- private array $chartData = [];- private GroupCollectorInterface $collector;+ private array $chartData = [];+ private GroupCollectorInterface $collector;private AccountRepositoryInterface $repository;// private TransactionCurrency $default;@@ -90,17 +90,18 @@ final class BalanceController extends Controller// get journals for entire period:$this->collector->setRange($queryParameters['start'], $queryParameters['end'])- ->withAccountInformation()- ->setXorAccounts($accounts)- ->setTypes([- TransactionTypeEnum::WITHDRAWAL->value,- TransactionTypeEnum::DEPOSIT->value,- TransactionTypeEnum::RECONCILIATION->value,- TransactionTypeEnum::TRANSFER->value,- ]);- $journals = $this->collector->getExtractedJournals();+ ->withAccountInformation()+ ->setXorAccounts($accounts)+ ->setTypes([+ TransactionTypeEnum::WITHDRAWAL->value,+ TransactionTypeEnum::DEPOSIT->value,+ TransactionTypeEnum::RECONCILIATION->value,+ TransactionTypeEnum::TRANSFER->value,+ ])+ ;+ $journals = $this->collector->getExtractedJournals();- $object = new AccountBalanceGrouped();+ $object = new AccountBalanceGrouped();$object->setPreferredRange($queryParameters['period']);$object->setPrimary($this->primaryCurrency);$object->setAccounts($accounts);@@ -108,7 +109,7 @@ final class BalanceController extends Controller$object->setStart($queryParameters['start']);$object->setEnd($queryParameters['end']);$object->groupByCurrencyAndPeriod();- $data = $object->convertToChartData();+ $data = $object->convertToChartData();foreach ($data as $entry) {$this->chartData[] = $entry;}diff --git a/app/Api/V1/Controllers/Chart/BudgetController.php b/app/Api/V1/Controllers/Chart/BudgetController.phpindex c163e62e94..bad1304a1d 100644--- a/app/Api/V1/Controllers/Chart/BudgetController.php+++ b/app/Api/V1/Controllers/Chart/BudgetController.php@@ -57,9 +57,9 @@ final class BudgetController extends Controllerprotected array $acceptedRoles = [UserRoleEnum::READ_ONLY];protected OperationsRepositoryInterface $opsRepository;- private BudgetLimitRepositoryInterface $blRepository;- private array $currencies = [];- private BudgetRepositoryInterface $repository;+ private BudgetLimitRepositoryInterface $blRepository;+ private array $currencies = [];+ private BudgetRepositoryInterface $repository;public function __construct(){@@ -88,10 +88,10 @@ final class BudgetController extends Controllerpublic function overview(DateRangeRequest $request): JsonResponse{/** @var Carbon $start */- $start = $request->attributes->get('start');+ $start = $request->attributes->get('start');/** @var Carbon $end */- $end = $request->attributes->get('end');+ $end = $request->attributes->get('end');// code from FrontpageChartGenerator, but not in separate class$budgets = $this->repository->getActiveBudgets();@@ -117,7 +117,7 @@ final class BudgetController extends Controllerif ($this->convertToPrimary) {if ($current->transaction_currency_id === $this->primaryCurrency->id) {// simply add it.- $amount = bcadd($amount, (string)$current->amount);+ $amount = bcadd($amount, (string) $current->amount);Log::debug(sprintf('Set amount in limit to %s', $amount));}if ($current->transaction_currency_id !== $this->primaryCurrency->id) {@@ -125,13 +125,13 @@ final class BudgetController extends Controller$converted = $converter->convert($current->transactionCurrency, $this->primaryCurrency, $current->start_date, $current->amount);$amount = bcadd($amount, $converted);Log::debug(sprintf(- 'Budgeted in limit #%d: %s %s, converted to %s %s',- $current->id,- $current->transactionCurrency->code,- $current->amount,- $this->primaryCurrency->code,- $converted- ));+ 'Budgeted in limit #%d: %s %s, converted to %s %s',+ $current->id,+ $current->transactionCurrency->code,+ $current->amount,+ $this->primaryCurrency->code,+ $converted+ ));Log::debug(sprintf('Set amount in limit to %s', $amount));}}@@ -167,7 +167,7 @@ final class BudgetController extends Controller*/foreach ($expenses as $currencyId => $row) {// budgeted, left and overspent are now 0.- $limit = $this->filterLimit($currencyId, $limits);+ $limit = $this->filterLimit($currencyId, $limits);// primary currency entries$row['pc_budgeted'] = '0';@@ -177,7 +177,7 @@ final class BudgetController extends Controllerif ($limit instanceof BudgetLimit) {$row['budgeted'] = $limit->amount;- $row['left'] = bcsub((string)$row['budgeted'], bcmul((string)$row['spent'], '-1'));+ $row['left'] = bcsub((string) $row['budgeted'], bcmul((string) $row['spent'], '-1'));$row['overspent'] = bcmul($row['left'], '-1');$row['left'] = 1 === bccomp($row['left'], '0') ? $row['left'] : '0';$row['overspent'] = 1 === bccomp($row['overspent'], '0') ? $row['overspent'] : '0';@@ -186,10 +186,10 @@ final class BudgetController extends Controller// convert data if necessary.if ($this->convertToPrimary && $currencyId !== $this->primaryCurrency->id) {$currencies[$currencyId] ??= Amount::getTransactionCurrencyById($currencyId);- $row['pc_budgeted'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['budgeted']);- $row['pc_spent'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['spent']);- $row['pc_left'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['left']);- $row['pc_overspent'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['overspent']);+ $row['pc_budgeted'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['budgeted']);+ $row['pc_spent'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['spent']);+ $row['pc_left'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['left']);+ $row['pc_overspent'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['overspent']);}if ($this->convertToPrimary && $currencyId === $this->primaryCurrency->id) {$row['pc_budgeted'] = $row['budgeted'];@@ -197,33 +197,33 @@ final class BudgetController extends Controller$row['pc_left'] = $row['left'];$row['pc_overspent'] = $row['overspent'];}- $rows[] = $row;+ $rows[] = $row;}// is always an array- $return = [];+ $return = [];foreach ($rows as $row) {$current = [- 'label' => $budget->name,- 'currency_id' => (string)$row['currency_id'],- 'currency_name' => $row['currency_name'],- 'currency_code' => $row['currency_code'],- 'currency_decimal_places' => $row['currency_decimal_places'],+ 'label' => $budget->name,+ 'currency_id' => (string) $row['currency_id'],+ 'currency_name' => $row['currency_name'],+ 'currency_code' => $row['currency_code'],+ 'currency_decimal_places' => $row['currency_decimal_places'],- 'primary_currency_id' => (string)$this->primaryCurrency->id,+ 'primary_currency_id' => (string) $this->primaryCurrency->id,'primary_currency_name' => $this->primaryCurrency->name,'primary_currency_code' => $this->primaryCurrency->code,'primary_currency_symbol' => $this->primaryCurrency->symbol,'primary_currency_decimal_places' => $this->primaryCurrency->decimal_places,- 'period' => null,- 'date' => $row['start'],- 'start_date' => $row['start'],- 'end_date' => $row['end'],- 'yAxisID' => 0,- 'type' => 'bar',- 'entries' => ['budgeted' => $row['budgeted'], 'spent' => $row['spent'], 'left' => $row['left'], 'overspent' => $row['overspent']],- 'pc_entries' => [+ 'period' => null,+ 'date' => $row['start'],+ 'start_date' => $row['start'],+ 'end_date' => $row['end'],+ 'yAxisID' => 0,+ 'type' => 'bar',+ 'entries' => ['budgeted' => $row['budgeted'], 'spent' => $row['spent'], 'left' => $row['left'], 'overspent' => $row['overspent']],+ 'pc_entries' => ['budgeted' => $row['pc_budgeted'],'spent' => $row['pc_spent'],'left' => $row['pc_left'],@@ -269,11 +269,11 @@ final class BudgetController extends Controllerforeach ($spent as $currencyId => $block) {$this->currencies[$currencyId] ??= Amount::getTransactionCurrencyById($currencyId);$return[$currencyId] ??= [- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $block['currency_code'],'currency_name' => $block['currency_name'],'currency_symbol' => $block['currency_symbol'],- 'currency_decimal_places' => (int)$block['currency_decimal_places'],+ 'currency_decimal_places' => (int) $block['currency_decimal_places'],'start' => $start->toAtomString(),'end' => $end->toAtomString(),'budgeted' => '0',@@ -281,13 +281,13 @@ final class BudgetController extends Controller'left' => '0','overspent' => '0',];- $currentBudgetArray = $block['budgets'][$budgetId];+ $currentBudgetArray = $block['budgets'][$budgetId];// var_dump($return);/** @var array $journal */foreach ($currentBudgetArray['transaction_journals'] as $journal) {/** @var numeric-string $amount */- $amount = (string)$journal['amount'];+ $amount = (string) $journal['amount'];$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $amount);}}diff --git a/app/Api/V1/Controllers/Chart/CategoryController.php b/app/Api/V1/Controllers/Chart/CategoryController.phpindex 45650e28ec..f2c96f179d 100644--- a/app/Api/V1/Controllers/Chart/CategoryController.php+++ b/app/Api/V1/Controllers/Chart/CategoryController.php@@ -54,7 +54,7 @@ final class CategoryController extends Controller#[Override]protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];- private AccountRepositoryInterface $accountRepos;+ private AccountRepositoryInterface $accountRepos;private CurrencyRepositoryInterface $currencyRepos;public function __construct()@@ -84,32 +84,32 @@ final class CategoryController extends Controllerpublic function overview(DateRangeRequest $request): JsonResponse{/** @var Carbon $start */- $start = $request->attributes->get('start');+ $start = $request->attributes->get('start');/** @var Carbon $end */$end = $request->attributes->get('end');$accounts = $this->accountRepos->getAccountsByType([- AccountTypeEnum::DEBT->value,- AccountTypeEnum::LOAN->value,- AccountTypeEnum::MORTGAGE->value,- AccountTypeEnum::ASSET->value,- ]);+ AccountTypeEnum::DEBT->value,+ AccountTypeEnum::LOAN->value,+ AccountTypeEnum::MORTGAGE->value,+ AccountTypeEnum::ASSET->value,+ ]);$currencies = [];$return = [];$converter = new ExchangeRateConverter();// get journals for entire period:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setRange($start, $end)->withAccountInformation();$collector->setXorAccounts($accounts)->withCategoryInformation();$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::DEPOSIT->value]);- $journals = $collector->getExtractedJournals();+ $journals = $collector->getExtractedJournals();/** @var array $journal */foreach ($journals as $journal) {// find journal:- $journalCurrencyId = (int)$journal['currency_id'];+ $journalCurrencyId = (int) $journal['currency_id'];$type = $journal['transaction_type_type'];$currency = $currencies[$journalCurrencyId] ?? $this->currencyRepos->find($journalCurrencyId);$currencies[$journalCurrencyId] = $currency;@@ -118,7 +118,7 @@ final class CategoryController extends Controller$currencyCode = $currency->code;$currencySymbol = $currency->symbol;$currencyDecimalPlaces = $currency->decimal_places;- $amount = Steam::positive((string)$journal['amount']);+ $amount = Steam::positive((string) $journal['amount']);$pcAmount = null;// overrule if necessary:@@ -135,17 +135,17 @@ final class CategoryController extends ControllerLog::debug(sprintf('Converted %s %s to %s %s', $journal['currency_code'], $amount, $this->primaryCurrency->code, $pcAmount));}- $categoryName = $journal['category_name'] ?? (string)trans('firefly.no_category');- $key = sprintf('%s-%s', $categoryName, $currencyCode);+ $categoryName = $journal['category_name'] ?? (string) trans('firefly.no_category');+ $key = sprintf('%s-%s', $categoryName, $currencyCode);// create arrays$return[$key] ??= ['label' => $categoryName,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_name' => $currencyName,'currency_code' => $currencyCode,'currency_symbol' => $currencySymbol,'currency_decimal_places' => $currencyDecimalPlaces,- 'primary_currency_id' => (string)$this->primaryCurrency->id,+ 'primary_currency_id' => (string) $this->primaryCurrency->id,'primary_currency_name' => $this->primaryCurrency->name,'primary_currency_code' => $this->primaryCurrency->code,'primary_currency_symbol' => $this->primaryCurrency->symbol,@@ -177,13 +177,13 @@ final class CategoryController extends Controller}}}- $return = array_values($return);+ $return = array_values($return);// order by amount- usort($return, static fn(array $a, array $b): int => ((float)$a['entries']['spent'] + (float)$a['entries']['earned'])- < ((float)$b['entries']['spent'] + (float)$b['entries']['earned'])- ? 1- : -1);+ usort($return, static fn (array $a, array $b): int => ((float) $a['entries']['spent'] + (float) $a['entries']['earned'])+ < ((float) $b['entries']['spent'] + (float) $b['entries']['earned'])+ ? 1+ : -1);return response()->json($this->clean($return));}diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.phpindex 399b03ab1b..65791080e2 100644--- a/app/Api/V1/Controllers/Controller.php+++ b/app/Api/V1/Controllers/Controller.php@@ -65,10 +65,12 @@ abstract class Controller extends BaseControllerprotected const string CONTENT_TYPE = 'application/vnd.api+json';protected const string JSON_CONTENT_TYPE = 'application/json';- protected array $acceptedRoles = [];- protected array $accepts = ['application/json', 'application/vnd.api+json'];- protected bool $convertToPrimary = false;+ protected array $acceptedRoles = [];+ protected array $accepts = ['application/json', 'application/vnd.api+json'];++ protected bool $convertToPrimary = false;+/** @deprecated use Request classes */protected ParameterBag $parameters;protected TransactionCurrency $primaryCurrency;@@ -116,14 +118,14 @@ abstract class Controller extends BaseController$params[$key] = $value;}- return $return . http_build_query($params);+ return $return.http_build_query($params);}final protected function getManager(): Manager{// create some objects:$manager = new Manager();- $baseUrl = request()->getSchemeAndHttpHost() . '/api/v1';+ $baseUrl = request()->getSchemeAndHttpHost().'/api/v1';$manager->setSerializer(new JsonApiSerializer($baseUrl));return $manager;@@ -131,14 +133,14 @@ abstract class Controller extends BaseControllerfinal protected function jsonApiList(string $key, LengthAwarePaginator $paginator, AbstractTransformer $transformer): array{- $manager = new Manager();- $baseUrl = sprintf('%s/api/v1/', request()->getSchemeAndHttpHost());+ $manager = new Manager();+ $baseUrl = sprintf('%s/api/v1/', request()->getSchemeAndHttpHost());// TODO add stuff to path?$manager->setSerializer(new JsonApiSerializer($baseUrl));- $objects = $paginator->getCollection();+ $objects = $paginator->getCollection();// the transformer, at this point, needs to collect information that ALL items in the collection// require, like meta-data and stuff like that, and save it for later.@@ -156,11 +158,11 @@ abstract class Controller extends BaseController** @param array<int, mixed>|Model $object*/- final protected function jsonApiObject(string $key, array | Model $object, AbstractTransformer $transformer): array+ final protected function jsonApiObject(string $key, array|Model $object, AbstractTransformer $transformer): array{// create some objects:- $manager = new Manager();- $baseUrl = sprintf('%s/api/v1', request()->getSchemeAndHttpHost());+ $manager = new Manager();+ $baseUrl = sprintf('%s/api/v1', request()->getSchemeAndHttpHost());$manager->setSerializer(new JsonApiSerializer($baseUrl));$resource = new Item($object, $transformer, $key);@@ -171,17 +173,16 @@ abstract class Controller extends BaseController#[Deprecated(message: <<<'TXT'use Request classesMethod to grab all parameters from the URL- TXT- )]+ TXT)]private function getParameters(): ParameterBag{- $bag = new ParameterBag();- $page = (int)request()->get('page');- $page = clamp(value: $page, min: 1, max: 2 ** 16);+ $bag = new ParameterBag();+ $page = (int) request()->get('page');+ $page = clamp(value: $page, min: 1, max: 2 ** 16);$bag->set('page', $page);// some date fields:- $dates = ['start', 'end', 'date'];+ $dates = ['start', 'end', 'date'];foreach ($dates as $field) {$date = null;@@ -192,13 +193,13 @@ abstract class Controller extends BaseControllerLog::error($e->getMessage());Log::error($e->getTraceAsString());}- $obj = null;+ $obj = null;if (null !== $date) {try {- $obj = Carbon::parse((string)$date, config('app.timezone'));+ $obj = Carbon::parse((string) $date, config('app.timezone'));} catch (InvalidFormatException $e) {// don't care- Log::warning(sprintf('Ignored invalid date "%s" in API controller parameter check: %s', substr((string)$date, 0, 20), $e->getMessage()));+ Log::warning(sprintf('Ignored invalid date "%s" in API controller parameter check: %s', substr((string) $date, 0, 20), $e->getMessage()));}}if ($obj instanceof Carbon) {@@ -218,7 +219,7 @@ abstract class Controller extends BaseController$value = null;}if (null !== $value) {- $value = (int)$value;+ $value = (int) $value;$value = clamp($value, 1, 2 ** 16);$bag->set($integer, $value);}@@ -226,9 +227,9 @@ abstract class Controller extends BaseControllerif (null === $value && auth()->check()) {// set default for user:/** @var User $user */- $user = auth()->user();+ $user = auth()->user();- $pageSize = (int)Preferences::getForUser($user, 'listPageSize', 50)->data;+ $pageSize = (int) Preferences::getForUser($user, 'listPageSize', 50)->data;$bag->set($integer, $pageSize);}}diff --git a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php b/app/Api/V1/Controllers/Data/Bulk/TransactionController.phpindex f8d4f7bdd8..c9bbbdba17 100644--- a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php+++ b/app/Api/V1/Controllers/Data/Bulk/TransactionController.php@@ -71,11 +71,11 @@ final 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);+ $service = app(AccountDestroyService::class);$service->moveTransactions($original, $destination);}diff --git a/app/Api/V1/Controllers/Data/DestroyController.php b/app/Api/V1/Controllers/Data/DestroyController.phpindex 6544adf48f..f4ab1bb082 100644--- a/app/Api/V1/Controllers/Data/DestroyController.php+++ b/app/Api/V1/Controllers/Data/DestroyController.php@@ -73,8 +73,8 @@ final class DestroyController extends Controllerpublic function destroy(DestroyRequest $request): JsonResponse{- $objects = $request->getObjects();- $this->unused = $request->boolean('unused');+ $objects = $request->getObjects();+ $this->unused = $request->boolean('unused');$allExceptAssets = [AccountTypeEnum::BENEFICIARY->value,@@ -176,11 +176,11 @@ final class DestroyController extends Controllerprivate function destroyBudgets(): void{/** @var AvailableBudgetRepositoryInterface $abRepository */- $abRepository = app(AvailableBudgetRepositoryInterface::class);+ $abRepository = app(AvailableBudgetRepositoryInterface::class);$abRepository->destroyAll();/** @var BudgetLimitRepositoryInterface $blRepository */- $blRepository = app(BudgetLimitRepositoryInterface::class);+ $blRepository = app(BudgetLimitRepositoryInterface::class);$blRepository->destroyAll();/** @var BudgetRepositoryInterface $budgetRepository */diff --git a/app/Api/V1/Controllers/Data/Export/ExportController.php b/app/Api/V1/Controllers/Data/Export/ExportController.phpindex a71b867273..6dcd449912 100644--- a/app/Api/V1/Controllers/Data/Export/ExportController.php+++ b/app/Api/V1/Controllers/Data/Export/ExportController.php@@ -33,6 +33,7 @@ use Illuminate\Http\Request;use Illuminate\Http\Response as LaravelResponse;use Override;use Safe\Exceptions\DatetimeException;+use function Safe\date;/**@@ -41,7 +42,7 @@ use function Safe\date;final class ExportController extends Controller{#[Override]- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];private ExportDataGenerator $exporter;/**@@ -194,13 +195,14 @@ final class ExportController extends Controller$response->header('Content-Description', 'File Transfer')->header('Content-Type', 'application/octet-stream')- ->header('Content-Disposition', 'attachment; filename=' . $fileName)+ ->header('Content-Disposition', 'attachment; filename='.$fileName)->header('Content-Transfer-Encoding', 'binary')->header('Connection', 'Keep-Alive')->header('Expires', '0')->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')->header('Pragma', 'public')- ->header('Content-Length', (string)strlen((string)$data[$key]));+ ->header('Content-Length', (string) strlen((string) $data[$key]))+ ;return $response;}diff --git a/app/Api/V1/Controllers/Data/PurgeController.php b/app/Api/V1/Controllers/Data/PurgeController.phpindex 7acb778639..19d39520f8 100644--- a/app/Api/V1/Controllers/Data/PurgeController.php+++ b/app/Api/V1/Controllers/Data/PurgeController.php@@ -67,7 +67,7 @@ final class PurgeController extends Controllerpublic function purge(): JsonResponse{/** @var User $user */- $user = auth()->user();+ $user = auth()->user();// some manual code, too lazy to call all repositories.diff --git a/app/Api/V1/Controllers/Insight/Expense/AccountController.php b/app/Api/V1/Controllers/Insight/Expense/AccountController.phpindex 0313b859cc..eea69b2355 100644--- a/app/Api/V1/Controllers/Insight/Expense/AccountController.php+++ b/app/Api/V1/Controllers/Insight/Expense/AccountController.php@@ -42,7 +42,7 @@ final class AccountController extends Controlleruse ApiSupport;private OperationsRepositoryInterface $opsRepository;- private AccountRepositoryInterface $repository;+ private AccountRepositoryInterface $repository;/*** AccountController constructor.@@ -51,8 +51,8 @@ final class AccountController extends Controller{parent::__construct();$this->middleware(function ($request, $next) {- $user = auth()->user();- $this->repository = app(AccountRepositoryInterface::class);+ $user = auth()->user();+ $this->repository = app(AccountRepositoryInterface::class);$this->repository->setUser($user);$this->opsRepository = app(OperationsRepositoryInterface::class);@@ -73,11 +73,11 @@ final 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'],];}@@ -97,11 +97,11 @@ final 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 d4497cb76c..8680b38dbc 100644--- a/app/Api/V1/Controllers/Insight/Expense/BillController.php+++ b/app/Api/V1/Controllers/Insight/Expense/BillController.php@@ -74,14 +74,14 @@ final class BillController extends Controller}// collect all expenses in this period (regardless of type) by the given bills and accounts.- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);$collector->setBills($bills);- $genericSet = $collector->getExtractedJournals();+ $genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {- $billId = (int)$journal['bill_id'];- $currencyId = (int)$journal['currency_id'];+ $billId = (int) $journal['bill_id'];+ $currencyId = (int) $journal['currency_id'];$currencyCode = $journal['currency_code'];$field = 'amount';@@ -96,27 +96,27 @@ final class BillController extends Controller$field = 'foreign_amount';}Log::debug(sprintf(- 'Journal #%d in bill #%d will use %s (%s %s)',- $journal['transaction_group_id'],- $billId,- $field,- $currencyCode,- $journal[$field] ?? '0'- ));+ 'Journal #%d in bill #%d will use %s (%s %s)',+ $journal['transaction_group_id'],+ $billId,+ $field,+ $currencyCode,+ $journal[$field] ?? '0'+ ));- $key = sprintf('%d-%d', $billId, $currencyId);+ $key = sprintf('%d-%d', $billId, $currencyId);if (0 !== $currencyId) {- $response[$key] ??= [- 'id' => (string)$billId,+ $response[$key] ??= [+ 'id' => (string) $billId,'name' => $journal['bill_name'],'difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $currencyCode,];- $response[$key]['difference'] = bcadd($response[$key]['difference'], (string)($journal[$field] ?? '0'));- $response[$key]['difference_float'] = (float)$response[$key]['difference']; // intentional float+ $response[$key]['difference'] = bcadd($response[$key]['difference'], (string) ($journal[$field] ?? '0'));+ $response[$key]['difference_float'] = (float) $response[$key]['difference']; // intentional float}}@@ -136,14 +136,14 @@ final class BillController extends Controller$response = [];// collect all expenses in this period (regardless of type) by the given bills and accounts.- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);$collector->withoutBill();- $genericSet = $collector->getExtractedJournals();+ $genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {- $currencyId = (int)$journal['currency_id'];+ $currencyId = (int) $journal['currency_id'];$currencyCode = $journal['currency_code'];$field = 'amount';@@ -160,14 +160,14 @@ final class BillController extends ControllerLog::debug(sprintf('Journal #%d will use %s (%s %s)', $journal['transaction_group_id'], $field, $currencyCode, $journal[$field] ?? '0'));if (0 !== $currencyId) {- $response[$currencyId] ??= [+ $response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $currencyCode,];- $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string)($journal[$field] ?? '0'));- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float+ $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) ($journal[$field] ?? '0'));+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float}}diff --git a/app/Api/V1/Controllers/Insight/Expense/BudgetController.php b/app/Api/V1/Controllers/Insight/Expense/BudgetController.phpindex 68326da1e6..0d6c227707 100644--- a/app/Api/V1/Controllers/Insight/Expense/BudgetController.php+++ b/app/Api/V1/Controllers/Insight/Expense/BudgetController.php@@ -38,9 +38,9 @@ use Illuminate\Support\Collection;*/final class BudgetController extends Controller{- private NoBudgetRepositoryInterface $noRepository;+ private NoBudgetRepositoryInterface $noRepository;private OperationsRepositoryInterface $opsRepository;- private BudgetRepositoryInterface $repository;+ private BudgetRepositoryInterface $repository;/*** AccountController constructor.@@ -79,11 +79,11 @@ final 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'],];}@@ -104,8 +104,8 @@ final 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 9adfd7ee4a..a5e546ea0b 100644--- a/app/Api/V1/Controllers/Insight/Expense/CategoryController.php+++ b/app/Api/V1/Controllers/Insight/Expense/CategoryController.php@@ -40,7 +40,7 @@ final class CategoryController extends Controller{private NoCategoryRepositoryInterface $noRepository;private OperationsRepositoryInterface $opsRepository;- private CategoryRepositoryInterface $repository;+ private CategoryRepositoryInterface $repository;/*** AccountController constructor.@@ -79,11 +79,11 @@ final 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'],];}@@ -104,8 +104,8 @@ final 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 0bbd4b2181..5ab2c350fd 100644--- a/app/Api/V1/Controllers/Insight/Expense/PeriodController.php+++ b/app/Api/V1/Controllers/Insight/Expense/PeriodController.php@@ -47,21 +47,21 @@ final class PeriodController extends Controller$primary = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type)- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);- $genericSet = $collector->getExtractedJournals();+ $genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {// same code as many other sumExpense methods. I think this needs some kind of generic method.- $amount = '0';- $currencyId = (int)$journal['currency_id'];- $currencyCode = $journal['currency_code'];+ $amount = '0';+ $currencyId = (int) $journal['currency_id'];+ $currencyCode = $journal['currency_code'];if ($convertToPrimary) {$amount = Amount::getAmountFromJournal($journal);- if ($primary->id !== (int)$journal['currency_id'] && $primary->id !== (int)$journal['foreign_currency_id']) {+ if ($primary->id !== (int) $journal['currency_id'] && $primary->id !== (int) $journal['foreign_currency_id']) {$currencyId = $primary->id;$currencyCode = $primary->code;}- if ($primary->id !== (int)$journal['currency_id'] && $primary->id === (int)$journal['foreign_currency_id']) {+ if ($primary->id !== (int) $journal['currency_id'] && $primary->id === (int) $journal['foreign_currency_id']) {$currencyId = $journal['foreign_currency_id'];$currencyCode = $journal['foreign_currency_code'];}@@ -73,14 +73,14 @@ final class PeriodController extends Controller$amount = $journal['amount'];}- $response[$currencyId] ??= [+ $response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $currencyCode,];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $amount);- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float}return response()->json(array_values($response));diff --git a/app/Api/V1/Controllers/Insight/Expense/TagController.php b/app/Api/V1/Controllers/Insight/Expense/TagController.phpindex 9a3c11e7e6..ad399ccb65 100644--- a/app/Api/V1/Controllers/Insight/Expense/TagController.php+++ b/app/Api/V1/Controllers/Insight/Expense/TagController.php@@ -67,24 +67,24 @@ final class TagController extends Controller$primary = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type) by the given bills and accounts.- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);$collector->withoutTags();- $genericSet = $collector->getExtractedJournals();+ $genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {// same code as many other sumExpense methods. I think this needs some kind of generic method.- $amount = '0';- $currencyId = (int)$journal['currency_id'];- $currencyCode = $journal['currency_code'];+ $amount = '0';+ $currencyId = (int) $journal['currency_id'];+ $currencyCode = $journal['currency_code'];if ($convertToPrimary) {$amount = Amount::getAmountFromJournal($journal);- if ($primary->id !== (int)$journal['currency_id'] && $primary->id !== (int)$journal['foreign_currency_id']) {+ if ($primary->id !== (int) $journal['currency_id'] && $primary->id !== (int) $journal['foreign_currency_id']) {$currencyId = $primary->id;$currencyCode = $primary->code;}- if ($primary->id !== (int)$journal['currency_id'] && $primary->id === (int)$journal['foreign_currency_id']) {+ if ($primary->id !== (int) $journal['currency_id'] && $primary->id === (int) $journal['foreign_currency_id']) {$currencyId = $journal['foreign_currency_id'];$currencyCode = $journal['foreign_currency_code'];}@@ -96,14 +96,14 @@ final class TagController extends Controller$amount = $journal['amount'];}- $response[$currencyId] ??= [+ $response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $currencyCode,];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $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.}return response()->json(array_values($response));@@ -114,11 +114,11 @@ final class TagController extends Controller*/public function tag(GenericRequest $request): JsonResponse{- $accounts = $request->getAssetAccounts();- $tags = $request->getTags();- $start = $request->getStart();- $end = $request->getEnd();- $response = [];+ $accounts = $request->getAssetAccounts();+ $tags = $request->getTags();+ $start = $request->getStart();+ $end = $request->getEnd();+ $response = [];// get all tags:if (0 === $tags->count()) {@@ -126,15 +126,15 @@ final class TagController extends Controller}// collect all expenses in this period (regardless of type) by the given bills and accounts.- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);$collector->setTags($tags);$genericSet = $collector->getExtractedJournals();/** @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,16 +144,16 @@ final class TagController extends Controller// on currency IDif (0 !== $currencyId) {- $response[$key] ??= [- 'id' => (string)$tagId,+ $response[$key] ??= [+ '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((string)$response[$key]['difference'], (string)$journal['amount']);- $response[$key]['difference_float'] = (float)$response[$key]['difference']; // float but on purpose.+ $response[$key]['difference'] = bcadd((string) $response[$key]['difference'], (string) $journal['amount']);+ $response[$key]['difference_float'] = (float) $response[$key]['difference']; // float but on purpose.}// on foreign ID@@ -161,11 +161,11 @@ final 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((string)$response[$foreignKey]['difference'], (string)$journal['foreign_amount']);- $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference']; // float but on purpose.+ $response[$foreignKey]['difference'] = bcadd((string) $response[$foreignKey]['difference'], (string) $journal['foreign_amount']);+ $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 61c737e937..66fe0807b8 100644--- a/app/Api/V1/Controllers/Insight/Income/AccountController.php+++ b/app/Api/V1/Controllers/Insight/Income/AccountController.php@@ -42,7 +42,7 @@ final class AccountController extends Controlleruse ApiSupport;private OperationsRepositoryInterface $opsRepository;- private AccountRepositoryInterface $repository;+ private AccountRepositoryInterface $repository;/*** AccountController constructor.@@ -51,8 +51,8 @@ final class AccountController extends Controller{parent::__construct();$this->middleware(function ($request, $next) {- $user = auth()->user();- $this->repository = app(AccountRepositoryInterface::class);+ $user = auth()->user();+ $this->repository = app(AccountRepositoryInterface::class);$this->repository->setUser($user);$this->opsRepository = app(OperationsRepositoryInterface::class);@@ -68,17 +68,17 @@ final class AccountController extends Controller$end = $request->getEnd();$assetAccounts = $request->getAssetAccounts();- $income = $this->opsRepository->sumIncomeByDestination($start, $end, $assetAccounts);- $result = [];+ $income = $this->opsRepository->sumIncomeByDestination($start, $end, $assetAccounts);+ $result = [];/** @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'],];}@@ -98,11 +98,11 @@ final 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 345cb1d39d..a81bf91be9 100644--- a/app/Api/V1/Controllers/Insight/Income/CategoryController.php+++ b/app/Api/V1/Controllers/Insight/Income/CategoryController.php@@ -40,7 +40,7 @@ final class CategoryController extends Controller{private NoCategoryRepositoryInterface $noRepository;private OperationsRepositoryInterface $opsRepository;- private CategoryRepositoryInterface $repository;+ private CategoryRepositoryInterface $repository;/*** AccountController constructor.@@ -79,11 +79,11 @@ final 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'],];}@@ -104,8 +104,8 @@ final 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 c4ba659ea0..b972335a4c 100644--- a/app/Api/V1/Controllers/Insight/Income/PeriodController.php+++ b/app/Api/V1/Controllers/Insight/Income/PeriodController.php@@ -47,14 +47,14 @@ final class PeriodController extends Controller$primary = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type)- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts);- $genericSet = $collector->getExtractedJournals();+ $genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {// currency- $currencyId = $journal['currency_id'];- $currencyCode = $journal['currency_code'];- $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';+ $currencyId = $journal['currency_id'];+ $currencyCode = $journal['currency_code'];+ $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';// perhaps use default currency instead?if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {@@ -66,14 +66,14 @@ final class PeriodController extends Controller$field = 'foreign_amount';}- $response[$currencyId] ??= [+ $response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $currencyCode,];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose.+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.}return response()->json(array_values($response));diff --git a/app/Api/V1/Controllers/Insight/Income/TagController.php b/app/Api/V1/Controllers/Insight/Income/TagController.phpindex ca1576cd14..94be2ae461 100644--- a/app/Api/V1/Controllers/Insight/Income/TagController.php+++ b/app/Api/V1/Controllers/Insight/Income/TagController.php@@ -68,17 +68,17 @@ final class TagController extends Controller$primary = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type) by the given bills and accounts.- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts);$collector->withoutTags();- $genericSet = $collector->getExtractedJournals();+ $genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {// currency- $currencyId = $journal['currency_id'];- $currencyCode = $journal['currency_code'];- $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';+ $currencyId = $journal['currency_id'];+ $currencyCode = $journal['currency_code'];+ $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';// perhaps use default currency instead?if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {@@ -90,14 +90,14 @@ final class TagController extends Controller$field = 'foreign_amount';}- $response[$currencyId] ??= [+ $response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $currencyCode,];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];}return response()->json(array_values($response));@@ -108,11 +108,11 @@ final class TagController extends Controller*/public function tag(GenericRequest $request): JsonResponse{- $accounts = $request->getAssetAccounts();- $tags = $request->getTags();- $start = $request->getStart();- $end = $request->getEnd();- $response = [];+ $accounts = $request->getAssetAccounts();+ $tags = $request->getTags();+ $start = $request->getStart();+ $end = $request->getEnd();+ $response = [];// get all tags:if (0 === $tags->count()) {@@ -120,15 +120,15 @@ final class TagController extends Controller}// collect all expenses in this period (regardless of type) by the given bills and accounts.- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts);$collector->setTags($tags);$genericSet = $collector->getExtractedJournals();/** @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) {@@ -138,16 +138,16 @@ final class TagController extends Controller// on currency IDif (0 !== $currencyId) {- $response[$key] ??= [- 'id' => (string)$tagId,+ $response[$key] ??= [+ '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((string)$response[$key]['difference'], Steam::positive($journal['amount']));- $response[$key]['difference_float'] = (float)$response[$key]['difference'];+ $response[$key]['difference'] = bcadd((string) $response[$key]['difference'], Steam::positive($journal['amount']));+ $response[$key]['difference_float'] = (float) $response[$key]['difference'];}// on foreign ID@@ -155,11 +155,14 @@ final 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((string)$response[$foreignKey]['difference'], Steam::positive($journal['foreign_amount']));- $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference'];+ $response[$foreignKey]['difference'] = bcadd(+ (string) $response[$foreignKey]['difference'],+ Steam::positive($journal['foreign_amount'])+ );+ $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 1f87e9ba0c..2fc72229d3 100644--- a/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php+++ b/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php@@ -40,7 +40,7 @@ final class CategoryController extends Controller{private NoCategoryRepositoryInterface $noRepository;private OperationsRepositoryInterface $opsRepository;- private CategoryRepositoryInterface $repository;+ private CategoryRepositoryInterface $repository;/*** AccountController constructor.@@ -79,11 +79,11 @@ final 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'],];}@@ -104,8 +104,8 @@ final 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 5b034fbe85..cdae02e939 100644--- a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php+++ b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php@@ -47,14 +47,14 @@ final class PeriodController extends Controller$primary = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type)- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setTypes([TransactionTypeEnum::TRANSFER->value])->setRange($start, $end)->setDestinationAccounts($accounts);- $genericSet = $collector->getExtractedJournals();+ $genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {// currency- $currencyId = $journal['currency_id'];- $currencyCode = $journal['currency_code'];- $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';+ $currencyId = $journal['currency_id'];+ $currencyCode = $journal['currency_code'];+ $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';// perhaps use default currency instead?if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {@@ -66,14 +66,14 @@ final class PeriodController extends Controller$field = 'foreign_amount';}- $response[$currencyId] ??= [+ $response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $currencyCode,];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];}return response()->json(array_values($response));diff --git a/app/Api/V1/Controllers/Insight/Transfer/TagController.php b/app/Api/V1/Controllers/Insight/Transfer/TagController.phpindex 53d45457ba..b7b85fd376 100644--- a/app/Api/V1/Controllers/Insight/Transfer/TagController.php+++ b/app/Api/V1/Controllers/Insight/Transfer/TagController.php@@ -65,17 +65,17 @@ final class TagController extends Controller$primary = Amount::getPrimaryCurrency();// collect all expenses in this period (regardless of type) by the given bills and accounts.- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setTypes([TransactionTypeEnum::TRANSFER->value])->setRange($start, $end)->setDestinationAccounts($accounts);$collector->withoutTags();- $genericSet = $collector->getExtractedJournals();+ $genericSet = $collector->getExtractedJournals();foreach ($genericSet as $journal) {// currency- $currencyId = $journal['currency_id'];- $currencyCode = $journal['currency_code'];- $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';+ $currencyId = $journal['currency_id'];+ $currencyCode = $journal['currency_code'];+ $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';// perhaps use default currency instead?if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {@@ -87,14 +87,14 @@ final class TagController extends Controller$field = 'foreign_amount';}- $response[$currencyId] ??= [+ $response[$currencyId] ??= ['difference' => '0','difference_float' => 0,- 'currency_id' => (string)$currencyId,+ 'currency_id' => (string) $currencyId,'currency_code' => $currencyCode,];$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));- $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];+ $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];}return response()->json(array_values($response));@@ -105,11 +105,11 @@ final class TagController extends Controller*/public function tag(GenericRequest $request): JsonResponse{- $accounts = $request->getAssetAccounts();- $tags = $request->getTags();- $start = $request->getStart();- $end = $request->getEnd();- $response = [];+ $accounts = $request->getAssetAccounts();+ $tags = $request->getTags();+ $start = $request->getStart();+ $end = $request->getEnd();+ $response = [];// get all tags:if (0 === $tags->count()) {@@ -117,15 +117,15 @@ final class TagController extends Controller}// collect all expenses in this period (regardless of type) by the given bills and accounts.- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setTypes([TransactionTypeEnum::TRANSFER->value])->setRange($start, $end)->setDestinationAccounts($accounts);$collector->setTags($tags);$genericSet = $collector->getExtractedJournals();/** @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) {@@ -135,16 +135,16 @@ final class TagController extends Controller// on currency IDif (0 !== $currencyId) {- $response[$key] ??= [- 'id' => (string)$tagId,+ $response[$key] ??= [+ '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((string)$response[$key]['difference'], Steam::positive($journal['amount']));- $response[$key]['difference_float'] = (float)$response[$key]['difference'];+ $response[$key]['difference'] = bcadd((string) $response[$key]['difference'], Steam::positive($journal['amount']));+ $response[$key]['difference_float'] = (float) $response[$key]['difference'];}// on foreign ID@@ -152,11 +152,14 @@ final 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((string)$response[$foreignKey]['difference'], Steam::positive($journal['foreign_amount']));- $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference']; // intentional float+ $response[$foreignKey]['difference'] = bcadd(+ (string) $response[$foreignKey]['difference'],+ Steam::positive($journal['foreign_amount'])+ );+ $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float}}}diff --git a/app/Api/V1/Controllers/Models/Account/ListController.php b/app/Api/V1/Controllers/Models/Account/ListController.phpindex 42fa092486..a6ec7bf804 100644--- a/app/Api/V1/Controllers/Models/Account/ListController.php+++ b/app/Api/V1/Controllers/Models/Account/ListController.php@@ -70,21 +70,21 @@ final class ListController extends Controllerpublic function attachments(PaginationRequest $request, Account $account): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();- $collection = $this->repository->getAttachments($account);+ $collection = $this->repository->getAttachments($account);- $count = $collection->count();- $attachments = $collection->slice($offset, $limit);+ $count = $collection->count();+ $attachments = $collection->slice($offset, $limit);// make paginator:- $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);- $paginator->setPath(route('api.v1.accounts.attachments', [$account->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);+ $paginator->setPath(route('api.v1.accounts.attachments', [$account->id]).$this->buildParams());/** @var AttachmentTransformer $transformer */- $transformer = app(AttachmentTransformer::class);+ $transformer = app(AttachmentTransformer::class);- $resource = new FractalCollection($attachments, $transformer, 'attachments');+ $resource = new FractalCollection($attachments, $transformer, 'attachments');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -93,31 +93,31 @@ final class ListController extends Controllerpublic function piggyBanks(PaginationRequest $request, Account $account): JsonResponse{// create some objects:- $manager = $this->getManager();+ $manager = $this->getManager();['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();// get list of piggy banks. Count it and split it.- $collection = $this->repository->getPiggyBanks($account);- $count = $collection->count();- $piggyBanks = $collection->slice($offset, $limit);+ $collection = $this->repository->getPiggyBanks($account);+ $count = $collection->count();+ $piggyBanks = $collection->slice($offset, $limit);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new PiggyBankEnrichment();+ $admin = auth()->user();+ $enrichment = new PiggyBankEnrichment();$enrichment->setUser($admin);- $piggyBanks = $enrichment->enrich($piggyBanks);+ $piggyBanks = $enrichment->enrich($piggyBanks);// make paginator:- $paginator = new LengthAwarePaginator($piggyBanks, $count, $limit, $page);- $paginator->setPath(route('api.v1.accounts.piggy-banks', [$account->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($piggyBanks, $count, $limit, $page);+ $paginator->setPath(route('api.v1.accounts.piggy-banks', [$account->id]).$this->buildParams());/** @var PiggyBankTransformer $transformer */- $transformer = app(PiggyBankTransformer::class);+ $transformer = app(PiggyBankTransformer::class);// $transformer->setParameters($this->parameters);- $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');+ $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -129,15 +129,15 @@ final class ListController extends Controllerpublic function transactions(PaginationDateRangeRequest $request, Account $account): JsonResponse{['limit' => $limit, 'page' => $page, 'start' => $start, 'end' => $end, 'type' => $type] = $request->attributes->all();- $types = $this->mapTransactionTypes($type ?? 'default');- $manager = $this->getManager();+ $types = $this->mapTransactionTypes($type ?? 'default');+ $manager = $this->getManager();/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)->setAccounts(new Collection()->push($account))->withAPIInformation()->setLimit($limit)->setPage($page)->setTypes($types);if (null !== $start) {$collector->setStart($start);@@ -146,18 +146,18 @@ final class ListController extends Controller$collector->setEnd($end);}- $paginator = $collector->getPaginatedGroups();- $paginator->setPath(route('api.v1.accounts.transactions', [$account->id]) . $this->buildParams());+ $paginator = $collector->getPaginatedGroups();+ $paginator->setPath(route('api.v1.accounts.transactions', [$account->id]).$this->buildParams());// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);- $transactions = $enrichment->enrich($paginator->getCollection());+ $transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$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/Account/ShowController.php b/app/Api/V1/Controllers/Models/Account/ShowController.phpindex c7ff8a4b5f..ef115a720f 100644--- a/app/Api/V1/Controllers/Models/Account/ShowController.php+++ b/app/Api/V1/Controllers/Models/Account/ShowController.php@@ -68,7 +68,7 @@ final class ShowController extends Controller*/public function index(ShowRequest $request): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();['types' => $types,'page' => $page,@@ -78,37 +78,36 @@ final class ShowController extends Controller'start' => $start,'end' => $end,'date' => $date,- ]- = $request->attributes->all();+ ] = $request->attributes->all();// get list of accounts. Count it and split it.$this->repository->resetAccountOrder();- $collection = $this->repository->getAccountsByType($types, $sort);- $count = $collection->count();+ $collection = $this->repository->getAccountsByType($types, $sort);+ $count = $collection->count();// continue sort:// TODO if the user sorts on DB dependent field there must be no slice before enrichment, only after.// TODO still need to figure out how to do this easily.- $accounts = $collection->slice($offset, $limit);+ $accounts = $collection->slice($offset, $limit);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new AccountEnrichment();+ $admin = auth()->user();+ $enrichment = new AccountEnrichment();$enrichment->setSort($sort);$enrichment->setDate($date);$enrichment->setStart($start);$enrichment->setEnd($end);$enrichment->setUser($admin);- $accounts = $enrichment->enrich($accounts);+ $accounts = $enrichment->enrich($accounts);// make paginator:- $paginator = new LengthAwarePaginator($accounts, $count, $limit, $page);- $paginator->setPath(route('api.v1.accounts.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($accounts, $count, $limit, $page);+ $paginator->setPath(route('api.v1.accounts.index').$this->buildParams());/** @var AccountTransformer $transformer */$transformer = app(AccountTransformer::class);- $resource = new FractalCollection($accounts, $transformer, self::RESOURCE_KEY);+ $resource = new FractalCollection($accounts, $transformer, self::RESOURCE_KEY);$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -125,22 +124,22 @@ final class ShowController extends Controller// get list of accounts. Count it and split it.$this->repository->resetAccountOrder();$account->refresh();- $manager = $this->getManager();+ $manager = $this->getManager();['start' => $start, 'end' => $end, 'date' => $date] = $request->attributes->all();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new AccountEnrichment();+ $admin = auth()->user();+ $enrichment = new AccountEnrichment();$enrichment->setDate($date);$enrichment->setStart($start);$enrichment->setEnd($end);$enrichment->setUser($admin);- $account = $enrichment->enrichSingle($account);+ $account = $enrichment->enrichSingle($account);/** @var AccountTransformer $transformer */- $transformer = app(AccountTransformer::class);- $resource = new Item($account, $transformer, self::RESOURCE_KEY);+ $transformer = app(AccountTransformer::class);+ $resource = new Item($account, $transformer, self::RESOURCE_KEY);return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Account/StoreController.php b/app/Api/V1/Controllers/Models/Account/StoreController.phpindex e5a245b85a..2e97ee1f24 100644--- a/app/Api/V1/Controllers/Models/Account/StoreController.php+++ b/app/Api/V1/Controllers/Models/Account/StoreController.php@@ -64,23 +64,23 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $data = $request->getAllAccountData();+ $data = $request->getAllAccountData();$this->repository->resetAccountOrder();- $account = $this->repository->store($data);- $manager = $this->getManager();+ $account = $this->repository->store($data);+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new AccountEnrichment();+ $admin = auth()->user();+ $enrichment = new AccountEnrichment();$enrichment->setDate(null);$enrichment->setUser($admin);- $account = $enrichment->enrichSingle($account);+ $account = $enrichment->enrichSingle($account);/** @var AccountTransformer $transformer */$transformer = app(AccountTransformer::class);- $resource = new Item($account, $transformer, self::RESOURCE_KEY);+ $resource = new Item($account, $transformer, self::RESOURCE_KEY);return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Account/UpdateController.php b/app/Api/V1/Controllers/Models/Account/UpdateController.phpindex 95cdcb6535..0c683b7fe9 100644--- a/app/Api/V1/Controllers/Models/Account/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Account/UpdateController.php@@ -69,7 +69,7 @@ final class UpdateController extends Controller{Log::debug(sprintf('Now in %s', __METHOD__));$data = $request->getUpdateData();- $data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);+ $data['type'] = config('firefly.shortNamesByFullName.'.$account->accountType->type);$account = $this->repository->update($account, $data);$manager = $this->getManager();$account->refresh();@@ -77,15 +77,15 @@ final class UpdateController extends Controller// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new AccountEnrichment();+ $admin = auth()->user();+ $enrichment = new AccountEnrichment();$enrichment->setDate(null);$enrichment->setUser($admin);- $account = $enrichment->enrichSingle($account);+ $account = $enrichment->enrichSingle($account);/** @var AccountTransformer $transformer */- $transformer = app(AccountTransformer::class);- $resource = new Item($account, $transformer, self::RESOURCE_KEY);+ $transformer = app(AccountTransformer::class);+ $resource = new Item($account, $transformer, self::RESOURCE_KEY);return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Attachment/ShowController.php b/app/Api/V1/Controllers/Models/Attachment/ShowController.phpindex 3bc95b289a..10e971d6eb 100644--- a/app/Api/V1/Controllers/Models/Attachment/ShowController.php+++ b/app/Api/V1/Controllers/Models/Attachment/ShowController.php@@ -87,24 +87,25 @@ final class ShowController extends Controllerthrow new FireflyException('200000: File has not been uploaded (yet).');}if ($this->repository->exists($attachment)) {- $content = $this->repository->getContent($attachment);+ $content = $this->repository->getContent($attachment);if ('' === $content) {throw new FireflyException('200002: File is empty (zero bytes).');}- $quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));+ $quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));/** @var LaravelResponse $response */$response = response($content);$response->header('Content-Description', 'File Transfer')->header('Content-Type', 'application/octet-stream')- ->header('Content-Disposition', 'attachment; filename=' . $quoted)+ ->header('Content-Disposition', 'attachment; filename='.$quoted)->header('Content-Transfer-Encoding', 'binary')->header('Connection', 'Keep-Alive')->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;}@@ -128,21 +129,21 @@ final class ShowController extends Controllerthrow new NotFoundHttpException();}- $manager = $this->getManager();+ $manager = $this->getManager();// get list of attachments. Count it and split it.- $collection = $this->repository->get();- $count = $collection->count();- $attachments = $collection->slice($offset, $limit);+ $collection = $this->repository->get();+ $count = $collection->count();+ $attachments = $collection->slice($offset, $limit);// make paginator:- $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);- $paginator->setPath(route('api.v1.attachments.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);+ $paginator->setPath(route('api.v1.attachments.index').$this->buildParams());/** @var AttachmentTransformer $transformer */- $transformer = app(AttachmentTransformer::class);+ $transformer = app(AttachmentTransformer::class);- $resource = new FractalCollection($attachments, $transformer, 'attachments');+ $resource = new FractalCollection($attachments, $transformer, 'attachments');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -161,12 +162,12 @@ final class ShowController extends Controllerthrow new NotFoundHttpException();}- $manager = $this->getManager();+ $manager = $this->getManager();/** @var AttachmentTransformer $transformer */$transformer = app(AttachmentTransformer::class);- $resource = new Item($attachment, $transformer, 'attachments');+ $resource = new Item($attachment, $transformer, 'attachments');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Attachment/StoreController.php b/app/Api/V1/Controllers/Models/Attachment/StoreController.phpindex 1a8e0b0911..cf2af07158 100644--- a/app/Api/V1/Controllers/Models/Attachment/StoreController.php+++ b/app/Api/V1/Controllers/Models/Attachment/StoreController.php@@ -79,14 +79,14 @@ final class StoreController extends Controllerthrow new NotFoundHttpException();}Log::debug(sprintf('Now in %s', __METHOD__));- $data = $request->getAll();- $attachment = $this->repository->store($data);- $manager = $this->getManager();+ $data = $request->getAll();+ $attachment = $this->repository->store($data);+ $manager = $this->getManager();/** @var AttachmentTransformer $transformer */$transformer = app(AttachmentTransformer::class);- $resource = new Item($attachment, $transformer, 'attachments');+ $resource = new Item($attachment, $transformer, 'attachments');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Attachment/UpdateController.php b/app/Api/V1/Controllers/Models/Attachment/UpdateController.phpindex 1c903c50cb..bff86bd0ec 100644--- a/app/Api/V1/Controllers/Models/Attachment/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Attachment/UpdateController.php@@ -73,14 +73,14 @@ final class UpdateController extends Controllerthrow new NotFoundHttpException();}- $data = $request->getAll();+ $data = $request->getAll();$this->repository->update($attachment, $data);- $manager = $this->getManager();+ $manager = $this->getManager();/** @var AttachmentTransformer $transformer */$transformer = app(AttachmentTransformer::class);- $resource = new Item($attachment, $transformer, 'attachments');+ $resource = new Item($attachment, $transformer, 'attachments');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.php b/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.phpindex 2c8dc42d96..d97405258b 100644--- a/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.php+++ b/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.php@@ -68,29 +68,29 @@ final class ShowController extends Controller*/public function index(PaginationDateRangeRequest $request): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();['limit' => $limit, 'offset' => $offset, 'page' => $page, 'start' => $start, 'end' => $end] = $request->attributes->all();// get list of available budgets. Count it and split it.- $collection = $this->abRepository->getAvailableBudgetsByDate($start, $end);- $count = $collection->count();- $availableBudgets = $collection->slice($offset, $limit);+ $collection = $this->abRepository->getAvailableBudgetsByDate($start, $end);+ $count = $collection->count();+ $availableBudgets = $collection->slice($offset, $limit);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new AvailableBudgetEnrichment();+ $admin = auth()->user();+ $enrichment = new AvailableBudgetEnrichment();$enrichment->setUser($admin);- $availableBudgets = $enrichment->enrich($availableBudgets);+ $availableBudgets = $enrichment->enrich($availableBudgets);// make paginator:- $paginator = new LengthAwarePaginator($availableBudgets, $count, $limit, $page);- $paginator->setPath(route('api.v1.available-budgets.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($availableBudgets, $count, $limit, $page);+ $paginator->setPath(route('api.v1.available-budgets.index').$this->buildParams());/** @var AvailableBudgetTransformer $transformer */- $transformer = app(AvailableBudgetTransformer::class);+ $transformer = app(AvailableBudgetTransformer::class);- $resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');+ $resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -104,21 +104,21 @@ final class ShowController extends Controller*/public function show(AvailableBudget $availableBudget): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// $start = $this->parameters->get('start');// $end = $this->parameters->get('end');/** @var AvailableBudgetTransformer $transformer */- $transformer = app(AvailableBudgetTransformer::class);+ $transformer = app(AvailableBudgetTransformer::class);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new AvailableBudgetEnrichment();+ $admin = auth()->user();+ $enrichment = new AvailableBudgetEnrichment();$enrichment->setUser($admin);$availableBudget = $enrichment->enrichSingle($availableBudget);- $resource = new Item($availableBudget, $transformer, 'available_budgets');+ $resource = new Item($availableBudget, $transformer, 'available_budgets');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Bill/ListController.php b/app/Api/V1/Controllers/Models/Bill/ListController.phpindex 74bc7bdf8e..5256be1cd7 100644--- a/app/Api/V1/Controllers/Models/Bill/ListController.php+++ b/app/Api/V1/Controllers/Models/Bill/ListController.php@@ -73,20 +73,20 @@ final class ListController extends Controllerpublic function attachments(PaginationRequest $request, Bill $bill): JsonResponse{['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();- $manager = $this->getManager();- $collection = $this->repository->getAttachments($bill);+ $manager = $this->getManager();+ $collection = $this->repository->getAttachments($bill);- $count = $collection->count();- $attachments = $collection->slice($offset, $limit);+ $count = $collection->count();+ $attachments = $collection->slice($offset, $limit);// make paginator:- $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);- $paginator->setPath(route('api.v1.bills.attachments', [$bill->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);+ $paginator->setPath(route('api.v1.bills.attachments', [$bill->id]).$this->buildParams());/** @var AttachmentTransformer $transformer */- $transformer = app(AttachmentTransformer::class);+ $transformer = app(AttachmentTransformer::class);- $resource = new FractalCollection($attachments, $transformer, 'attachments');+ $resource = new FractalCollection($attachments, $transformer, 'attachments');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -102,18 +102,18 @@ final class ListController extends Controller{['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();- $manager = $this->getManager();- $collection = $this->repository->getRulesForBill($bill);- $count = $collection->count();- $rules = $collection->slice($offset, $limit);+ $manager = $this->getManager();+ $collection = $this->repository->getRulesForBill($bill);+ $count = $collection->count();+ $rules = $collection->slice($offset, $limit);// make paginator:- $paginator = new LengthAwarePaginator($rules, $count, $limit, $page);- $paginator->setPath(route('api.v1.bills.rules', [$bill->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($rules, $count, $limit, $page);+ $paginator->setPath(route('api.v1.bills.rules', [$bill->id]).$this->buildParams());/** @var RuleTransformer $transformer */- $transformer = app(RuleTransformer::class);- $resource = new FractalCollection($rules, $transformer, 'rules');+ $transformer = app(RuleTransformer::class);+ $resource = new FractalCollection($rules, $transformer, 'rules');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -129,14 +129,14 @@ final class ListController extends Controller{['limit' => $limit, 'page' => $page, 'types' => $types, 'start' => $start, 'end' => $end] = $request->attributes->all();- $manager = $this->getManager();+ $manager = $this->getManager();/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)// include source + destination account name and type.@@ -148,7 +148,8 @@ final class ListController extends Controller// set page to retrieve->setPage($page)// set types of transactions to return.- ->setTypes($types);+ ->setTypes($types)+ ;if (null !== $start) {$collector->setStart($start);@@ -158,18 +159,18 @@ final class ListController extends Controller}// get paginator.- $paginator = $collector->getPaginatedGroups();- $paginator->setPath(route('api.v1.bills.transactions', [$bill->id]) . $this->buildParams());+ $paginator = $collector->getPaginatedGroups();+ $paginator->setPath(route('api.v1.bills.transactions', [$bill->id]).$this->buildParams());// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);- $transactions = $enrichment->enrich($paginator->getCollection());+ $transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$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/Bill/ShowController.php b/app/Api/V1/Controllers/Models/Bill/ShowController.phpindex c604a576e2..c67d880e1b 100644--- a/app/Api/V1/Controllers/Models/Bill/ShowController.php+++ b/app/Api/V1/Controllers/Models/Bill/ShowController.php@@ -70,25 +70,25 @@ final class ShowController extends Controller['limit' => $limit, 'offset' => $offset, 'start' => $start, 'end' => $end, 'page' => $page] = $request->attributes->all();$this->repository->correctOrder();- $bills = $this->repository->getBills();- $manager = $this->getManager();- $count = $bills->count();- $bills = $bills->slice($offset, $limit);- $paginator = new LengthAwarePaginator($bills, $count, $limit, $page);+ $bills = $this->repository->getBills();+ $manager = $this->getManager();+ $count = $bills->count();+ $bills = $bills->slice($offset, $limit);+ $paginator = new LengthAwarePaginator($bills, $count, $limit, $page);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new SubscriptionEnrichment();+ $admin = auth()->user();+ $enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);$enrichment->setStart($start);$enrichment->setEnd($end);- $bills = $enrichment->enrich($bills);+ $bills = $enrichment->enrich($bills);/** @var BillTransformer $transformer */- $transformer = app(BillTransformer::class);+ $transformer = app(BillTransformer::class);- $resource = new FractalCollection($bills, $transformer, 'bills');+ $resource = new FractalCollection($bills, $transformer, 'bills');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -104,21 +104,21 @@ final class ShowController extends Controller{['start' => $start, 'end' => $end] = $request->attributes->all();- $manager = $this->getManager();+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new SubscriptionEnrichment();+ $admin = auth()->user();+ $enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);$enrichment->setStart($start);$enrichment->setEnd($end);- $bill = $enrichment->enrichSingle($bill);+ $bill = $enrichment->enrichSingle($bill);/** @var BillTransformer $transformer */- $transformer = app(BillTransformer::class);+ $transformer = app(BillTransformer::class);- $resource = new Item($bill, $transformer, 'bills');+ $resource = new Item($bill, $transformer, 'bills');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Bill/StoreController.php b/app/Api/V1/Controllers/Models/Bill/StoreController.phpindex 34b026f7f0..c39a1456cb 100644--- a/app/Api/V1/Controllers/Models/Bill/StoreController.php+++ b/app/Api/V1/Controllers/Models/Bill/StoreController.php@@ -68,23 +68,23 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $data = $request->getAll();- $bill = $this->repository->store($data);- $manager = $this->getManager();+ $data = $request->getAll();+ $bill = $this->repository->store($data);+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new SubscriptionEnrichment();+ $admin = auth()->user();+ $enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));- $bill = $enrichment->enrichSingle($bill);+ $bill = $enrichment->enrichSingle($bill);/** @var BillTransformer $transformer */$transformer = app(BillTransformer::class);- $resource = new Item($bill, $transformer, 'bills');+ $resource = new Item($bill, $transformer, 'bills');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Bill/UpdateController.php b/app/Api/V1/Controllers/Models/Bill/UpdateController.phpindex 4fd7e0e309..fd18909383 100644--- a/app/Api/V1/Controllers/Models/Bill/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Bill/UpdateController.php@@ -63,24 +63,24 @@ final class UpdateController extends Controller*/public function update(UpdateRequest $request, Bill $bill): JsonResponse{- $data = $request->getAll();- $bill = $this->repository->update($bill, $data);- $manager = $this->getManager();+ $data = $request->getAll();+ $bill = $this->repository->update($bill, $data);+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new SubscriptionEnrichment();+ $admin = auth()->user();+ $enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));- $bill = $enrichment->enrichSingle($bill);+ $bill = $enrichment->enrichSingle($bill);/** @var BillTransformer $transformer */$transformer = app(BillTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($bill, $transformer, 'bills');+ $resource = new Item($bill, $transformer, 'bills');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Budget/ListController.php b/app/Api/V1/Controllers/Models/Budget/ListController.phpindex da2357c9a8..8182e94924 100644--- a/app/Api/V1/Controllers/Models/Budget/ListController.php+++ b/app/Api/V1/Controllers/Models/Budget/ListController.php@@ -49,7 +49,7 @@ final class ListController extends Controlleruse TransactionFilter;private BudgetLimitRepositoryInterface $blRepository;- private BudgetRepositoryInterface $repository;+ private BudgetRepositoryInterface $repository;/*** ListController constructor.@@ -73,22 +73,22 @@ final class ListController extends Controller*/public function attachments(Budget $budget): JsonResponse{- $manager = $this->getManager();- $pageSize = $this->parameters->get('limit');- $collection = $this->repository->getAttachments($budget);+ $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');+ $collection = $this->repository->getAttachments($budget);$count = $collection->count();$attachments = $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.budgets.attachments', [$budget->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.budgets.attachments', [$budget->id]).$this->buildParams());/** @var AttachmentTransformer $transformer */$transformer = app(AttachmentTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($attachments, $transformer, 'attachments');+ $resource = new FractalCollection($attachments, $transformer, 'attachments');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -102,26 +102,26 @@ final class ListController extends Controller*/public function budgetLimits(Budget $budget): JsonResponse{- $manager = $this->getManager();- $pageSize = $this->parameters->get('limit');+ $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');$this->parameters->set('budget_id', $budget->id);$collection = $this->blRepository->getBudgetLimits($budget, $this->parameters->get('start'), $this->parameters->get('end'));$count = $collection->count();$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.budgets.budget-limits', [$budget->id]) . $this->buildParams());+ $paginator->setPath(route('api.v1.budgets.budget-limits', [$budget->id]).$this->buildParams());// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new BudgetLimitEnrichment();+ $admin = auth()->user();+ $enrichment = new BudgetLimitEnrichment();$enrichment->setUser($admin);$budgetLimits = $enrichment->enrich($budgetLimits);/** @var BudgetLimitTransformer $transformer */- $transformer = app(BudgetLimitTransformer::class);+ $transformer = app(BudgetLimitTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');+ $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -135,20 +135,20 @@ final class ListController extends Controller*/public function transactions(Request $request, Budget $budget): JsonResponse{- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');- $type = $request->input('type') ?? 'default';+ $type = $request->input('type') ?? 'default';$this->parameters->set('type', $type);- $types = $this->mapTransactionTypes($this->parameters->get('type'));- $manager = $this->getManager();+ $types = $this->mapTransactionTypes($this->parameters->get('type'));+ $manager = $this->getManager();/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)// filter on budget.@@ -160,7 +160,8 @@ final class ListController extends Controller// set page to retrieve->setPage($this->parameters->get('page'))// set types of transactions to return.- ->setTypes($types);+ ->setTypes($types)+ ;if (null !== $this->parameters->get('start')) {$collector->setStart($this->parameters->get('start'));@@ -169,18 +170,18 @@ final class ListController extends Controller$collector->setEnd($this->parameters->get('end'));}- $paginator = $collector->getPaginatedGroups();- $paginator->setPath(route('api.v1.budgets.transactions', [$budget->id]) . $this->buildParams());+ $paginator = $collector->getPaginatedGroups();+ $paginator->setPath(route('api.v1.budgets.transactions', [$budget->id]).$this->buildParams());// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);$transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -194,20 +195,20 @@ final class ListController extends Controller*/public function withoutBudget(Request $request): JsonResponse{- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');- $type = $request->input('type') ?? 'default';+ $type = $request->input('type') ?? 'default';$this->parameters->set('type', $type);- $types = $this->mapTransactionTypes($this->parameters->get('type'));- $manager = $this->getManager();+ $types = $this->mapTransactionTypes($this->parameters->get('type'));+ $manager = $this->getManager();/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)// withdrawals only@@ -221,7 +222,8 @@ final class ListController extends Controller// set page to retrieve->setPage($this->parameters->get('page'))// set types of transactions to return.- ->setTypes($types);+ ->setTypes($types)+ ;if (null !== $this->parameters->get('start')) {$collector->setStart($this->parameters->get('start'));@@ -230,18 +232,18 @@ final class ListController extends Controller$collector->setEnd($this->parameters->get('end'));}- $paginator = $collector->getPaginatedGroups();- $paginator->setPath(route('api.v1.budgets.without-budget') . $this->buildParams());+ $paginator = $collector->getPaginatedGroups();+ $paginator->setPath(route('api.v1.budgets.without-budget').$this->buildParams());// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);$transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$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/Budget/ShowController.php b/app/Api/V1/Controllers/Models/Budget/ShowController.phpindex 25c4e84c9d..17d4bc5c3e 100644--- a/app/Api/V1/Controllers/Models/Budget/ShowController.php+++ b/app/Api/V1/Controllers/Models/Budget/ShowController.php@@ -43,7 +43,7 @@ use League\Fractal\Resource\Item;final class ShowController extends Controller{private BudgetLimitRepositoryInterface $blRepository;- private BudgetRepositoryInterface $repository;+ private BudgetRepositoryInterface $repository;/*** ListController constructor.@@ -69,34 +69,34 @@ final class ShowController extends Controller*/public function index(): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of budgets. Count it and split it.- $collection = $this->repository->getBudgets();- $count = $collection->count();- $budgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->repository->getBudgets();+ $count = $collection->count();+ $budgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new BudgetEnrichment();+ $admin = auth()->user();+ $enrichment = new BudgetEnrichment();$enrichment->setUser($admin);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));- $budgets = $enrichment->enrich($budgets);+ $budgets = $enrichment->enrich($budgets);// make paginator:- $paginator = new LengthAwarePaginator($budgets, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.budgets.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($budgets, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.budgets.index').$this->buildParams());/** @var BudgetTransformer $transformer */$transformer = app(BudgetTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($budgets, $transformer, 'budgets');+ $resource = new FractalCollection($budgets, $transformer, 'budgets');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -107,22 +107,22 @@ final class ShowController extends Controller*/public function show(Budget $budget): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new BudgetEnrichment();+ $admin = auth()->user();+ $enrichment = new BudgetEnrichment();$enrichment->setUser($admin);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));- $budget = $enrichment->enrichSingle($budget);+ $budget = $enrichment->enrichSingle($budget);/** @var BudgetTransformer $transformer */$transformer = app(BudgetTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($budget, $transformer, 'budgets');+ $resource = new Item($budget, $transformer, 'budgets');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Budget/StoreController.php b/app/Api/V1/Controllers/Models/Budget/StoreController.phpindex 6cf376be39..e6a5a8960b 100644--- a/app/Api/V1/Controllers/Models/Budget/StoreController.php+++ b/app/Api/V1/Controllers/Models/Budget/StoreController.php@@ -65,24 +65,24 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $data = $request->getAll();+ $data = $request->getAll();$data['fire_webhooks'] ??= true;- $budget = $this->repository->store($data);+ $budget = $this->repository->store($data);$budget->refresh();- $manager = $this->getManager();+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new BudgetEnrichment();+ $admin = auth()->user();+ $enrichment = new BudgetEnrichment();$enrichment->setUser($admin);- $budget = $enrichment->enrichSingle($budget);+ $budget = $enrichment->enrichSingle($budget);/** @var BudgetTransformer $transformer */$transformer = app(BudgetTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($budget, $transformer, 'budgets');+ $resource = new Item($budget, $transformer, 'budgets');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Budget/UpdateController.php b/app/Api/V1/Controllers/Models/Budget/UpdateController.phpindex 1b67e18aef..004ba2a9d9 100644--- a/app/Api/V1/Controllers/Models/Budget/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Budget/UpdateController.php@@ -57,23 +57,23 @@ final class UpdateController extends Controllerpublic function update(UpdateRequest $request, Budget $budget): JsonResponse{- $data = $request->getAll();+ $data = $request->getAll();$data['fire_webhooks'] ??= true;- $budget = $this->repository->update($budget, $data);- $manager = $this->getManager();+ $budget = $this->repository->update($budget, $data);+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new BudgetEnrichment();+ $admin = auth()->user();+ $enrichment = new BudgetEnrichment();$enrichment->setUser($admin);- $budget = $enrichment->enrichSingle($budget);+ $budget = $enrichment->enrichSingle($budget);/** @var BudgetTransformer $transformer */$transformer = app(BudgetTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($budget, $transformer, 'budgets');+ $resource = new Item($budget, $transformer, 'budgets');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/ListController.php b/app/Api/V1/Controllers/Models/BudgetLimit/ListController.phpindex ddb3a0294a..b5aa78ba74 100644--- a/app/Api/V1/Controllers/Models/BudgetLimit/ListController.php+++ b/app/Api/V1/Controllers/Models/BudgetLimit/ListController.php@@ -51,19 +51,19 @@ final class ListController extends Controller*/public function transactions(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse{- $pageSize = $this->parameters->get('limit');- $type = $request->input('type') ?? 'default';+ $pageSize = $this->parameters->get('limit');+ $type = $request->input('type') ?? 'default';$this->parameters->set('type', $type);- $types = $this->mapTransactionTypes($this->parameters->get('type'));- $manager = $this->getManager();+ $types = $this->mapTransactionTypes($this->parameters->get('type'));+ $manager = $this->getManager();/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)// filter on budget.@@ -75,23 +75,24 @@ final class ListController extends Controller// set page to retrieve->setPage($this->parameters->get('page'))// set types of transactions to return.- ->setTypes($types);+ ->setTypes($types)+ ;$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);$collector->setTypes($types);- $paginator = $collector->getPaginatedGroups();- $paginator->setPath(route('api.v1.budgets.limits.transactions', [$budget->id, $budgetLimit->id]) . $this->buildParams());+ $paginator = $collector->getPaginatedGroups();+ $paginator->setPath(route('api.v1.budgets.limits.transactions', [$budget->id, $budgetLimit->id]).$this->buildParams());// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);$transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$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/BudgetLimit/ShowController.php b/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.phpindex 811ca7d0ef..125f64c25b 100644--- a/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php+++ b/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php@@ -47,7 +47,7 @@ use League\Fractal\Resource\Item;final class ShowController extends Controller{private BudgetLimitRepositoryInterface $blRepository;- private BudgetRepositoryInterface $repository;+ private BudgetRepositoryInterface $repository;/*** BudgetLimitController constructor.@@ -76,35 +76,35 @@ final class ShowController extends Controllerpublic function index(Budget $budget): JsonResponse{/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// enrich budget:- $enrichment = new BudgetEnrichment();+ $enrichment = new BudgetEnrichment();$enrichment->setUser($admin);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));/** @var Budget $budget */- $budget = $enrichment->enrichSingle($budget);+ $budget = $enrichment->enrichSingle($budget);- $manager = $this->getManager();+ $manager = $this->getManager();$manager->parseIncludes('budget');$pageSize = $this->parameters->get('limit');$collection = $this->blRepository->getBudgetLimits($budget, $this->parameters->get('start'), $this->parameters->get('end'));$count = $collection->count();$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.budgets.limits.index', [$budget->id]) . $this->buildParams());+ $paginator->setPath(route('api.v1.budgets.limits.index', [$budget->id]).$this->buildParams());// enrich- $enrichment = new BudgetLimitEnrichment();+ $enrichment = new BudgetLimitEnrichment();$enrichment->setUser($admin);$budgetLimits = $enrichment->enrich($budgetLimits);/** @var BudgetLimitTransformer $transformer */- $transformer = app(BudgetLimitTransformer::class);+ $transformer = app(BudgetLimitTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');+ $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -120,27 +120,27 @@ final class ShowController extends Controller*/public function indexAll(DateRangeRequest $request): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();$manager->parseIncludes('budget');$pageSize = $this->parameters->get('limit');$collection = $this->blRepository->getAllBudgetLimits($request->attributes->get('start'), $request->attributes->get('end'));$count = $collection->count();$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.budget-limits.index') . $this->buildParams());+ $paginator->setPath(route('api.v1.budget-limits.index').$this->buildParams());// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new BudgetLimitEnrichment();+ $admin = auth()->user();+ $enrichment = new BudgetLimitEnrichment();$enrichment->setUser($admin);$budgetLimits = $enrichment->enrich($budgetLimits);/** @var BudgetLimitTransformer $transformer */- $transformer = app(BudgetLimitTransformer::class);+ $transformer = app(BudgetLimitTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');+ $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -158,19 +158,19 @@ final class ShowController extends Controllerthrow new FireflyException('20028: The budget limit does not belong to the budget.');}// continue!- $manager = $this->getManager();+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new BudgetLimitEnrichment();+ $admin = auth()->user();+ $enrichment = new BudgetLimitEnrichment();$enrichment->setUser($admin);$budgetLimit = $enrichment->enrichSingle($budgetLimit);/** @var BudgetLimitTransformer $transformer */$transformer = app(BudgetLimitTransformer::class);- $resource = new Item($budgetLimit, $transformer, 'budget_limits');+ $resource = new Item($budgetLimit, $transformer, 'budget_limits');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php b/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.phpindex a6e2b5b974..17022a1285 100644--- a/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php+++ b/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php@@ -65,27 +65,27 @@ final class StoreController extends Controller*/public function store(StoreRequest $request, Budget $budget): JsonResponse{- $data = $request->getAll();- $data['start_date'] = $data['start'];- $data['end_date'] = $data['end'];+ $data = $request->getAll();+ $data['start_date'] = $data['start'];+ $data['end_date'] = $data['end'];$data['fire_webhooks'] ??= true;- $data['budget_id'] = $budget->id;+ $data['budget_id'] = $budget->id;- $budgetLimit = $this->blRepository->store($data);- $manager = $this->getManager();+ $budgetLimit = $this->blRepository->store($data);+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new BudgetLimitEnrichment();+ $admin = auth()->user();+ $enrichment = new BudgetLimitEnrichment();$enrichment->setUser($admin);- $budgetLimit = $enrichment->enrichSingle($budgetLimit);+ $budgetLimit = $enrichment->enrichSingle($budgetLimit);/** @var BudgetLimitTransformer $transformer */- $transformer = app(BudgetLimitTransformer::class);+ $transformer = app(BudgetLimitTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($budgetLimit, $transformer, 'budget_limits');+ $resource = new Item($budgetLimit, $transformer, 'budget_limits');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php b/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.phpindex 54c8287efd..2106b0ca09 100644--- a/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php+++ b/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php@@ -74,24 +74,24 @@ final class UpdateController extends Controllerif ($budget->id !== $budgetLimit->budget_id) {throw new FireflyException('20028: The budget limit does not belong to the budget.');}- $data = $request->getAll();+ $data = $request->getAll();$data['fire_webhooks'] ??= true;- $data['budget_id'] = $budget->id;- $budgetLimit = $this->blRepository->update($budgetLimit, $data);- $manager = $this->getManager();+ $data['budget_id'] = $budget->id;+ $budgetLimit = $this->blRepository->update($budgetLimit, $data);+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new BudgetLimitEnrichment();+ $admin = auth()->user();+ $enrichment = new BudgetLimitEnrichment();$enrichment->setUser($admin);- $budgetLimit = $enrichment->enrichSingle($budgetLimit);+ $budgetLimit = $enrichment->enrichSingle($budgetLimit);/** @var BudgetLimitTransformer $transformer */- $transformer = app(BudgetLimitTransformer::class);+ $transformer = app(BudgetLimitTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($budgetLimit, $transformer, 'budget_limits');+ $resource = new Item($budgetLimit, $transformer, 'budget_limits');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Category/ListController.php b/app/Api/V1/Controllers/Models/Category/ListController.phpindex d3cd175818..13752ccaf0 100644--- a/app/Api/V1/Controllers/Models/Category/ListController.php+++ b/app/Api/V1/Controllers/Models/Category/ListController.php@@ -68,22 +68,22 @@ final class ListController extends Controller*/public function attachments(Category $category): JsonResponse{- $manager = $this->getManager();- $pageSize = $this->parameters->get('limit');- $collection = $this->repository->getAttachments($category);+ $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');+ $collection = $this->repository->getAttachments($category);$count = $collection->count();$attachments = $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.categories.attachments', [$category->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.categories.attachments', [$category->id]).$this->buildParams());/** @var AttachmentTransformer $transformer */$transformer = app(AttachmentTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($attachments, $transformer, 'attachments');+ $resource = new FractalCollection($attachments, $transformer, 'attachments');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -97,19 +97,19 @@ final class ListController extends Controller*/public function transactions(Request $request, Category $category): JsonResponse{- $pageSize = $this->parameters->get('limit');- $type = $request->input('type') ?? 'default';+ $pageSize = $this->parameters->get('limit');+ $type = $request->input('type') ?? 'default';$this->parameters->set('type', $type);- $types = $this->mapTransactionTypes($this->parameters->get('type'));- $manager = $this->getManager();+ $types = $this->mapTransactionTypes($this->parameters->get('type'));+ $manager = $this->getManager();/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)// filter on category.@@ -121,7 +121,8 @@ final class ListController extends Controller// set page to retrieve->setPage($this->parameters->get('page'))// set types of transactions to return.- ->setTypes($types);+ ->setTypes($types)+ ;if (null !== $this->parameters->get('start')) {$collector->setStart($this->parameters->get('start'));@@ -130,19 +131,19 @@ final class ListController extends Controller$collector->setEnd($this->parameters->get('end'));}- $paginator = $collector->getPaginatedGroups();- $paginator->setPath(route('api.v1.categories.transactions', [$category->id]) . $this->buildParams());+ $paginator = $collector->getPaginatedGroups();+ $paginator->setPath(route('api.v1.categories.transactions', [$category->id]).$this->buildParams());// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);$transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$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/Category/ShowController.php b/app/Api/V1/Controllers/Models/Category/ShowController.phpindex 1756eb4962..87f24f23a7 100644--- a/app/Api/V1/Controllers/Models/Category/ShowController.php+++ b/app/Api/V1/Controllers/Models/Category/ShowController.php@@ -65,33 +65,33 @@ final class ShowController extends Controller*/public function index(): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of budgets. Count it and split it.- $collection = $this->repository->getCategories();- $count = $collection->count();- $categories = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->repository->getCategories();+ $count = $collection->count();+ $categories = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new CategoryEnrichment();+ $admin = auth()->user();+ $enrichment = new CategoryEnrichment();$enrichment->setUser($admin);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));- $categories = $enrichment->enrich($categories);+ $categories = $enrichment->enrich($categories);// make paginator:- $paginator = new LengthAwarePaginator($categories, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.categories.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($categories, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.categories.index').$this->buildParams());/** @var CategoryTransformer $transformer */$transformer = app(CategoryTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($categories, $transformer, 'categories');+ $resource = new FractalCollection($categories, $transformer, 'categories');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -105,7 +105,7 @@ final class ShowController extends Controller*/public function show(Category $category): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();/** @var CategoryTransformer $transformer */$transformer = app(CategoryTransformer::class);@@ -113,14 +113,14 @@ final class ShowController extends Controller// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new CategoryEnrichment();+ $admin = auth()->user();+ $enrichment = new CategoryEnrichment();$enrichment->setUser($admin);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));- $category = $enrichment->enrichSingle($category);+ $category = $enrichment->enrichSingle($category);- $resource = new Item($category, $transformer, 'categories');+ $resource = new Item($category, $transformer, 'categories');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Category/StoreController.php b/app/Api/V1/Controllers/Models/Category/StoreController.phpindex 16c801941c..b9639902a3 100644--- a/app/Api/V1/Controllers/Models/Category/StoreController.php+++ b/app/Api/V1/Controllers/Models/Category/StoreController.php@@ -65,8 +65,8 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $category = $this->repository->store($request->getAll());- $manager = $this->getManager();+ $category = $this->repository->store($request->getAll());+ $manager = $this->getManager();/** @var CategoryTransformer $transformer */$transformer = app(CategoryTransformer::class);@@ -74,14 +74,14 @@ final class StoreController extends Controller// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new CategoryEnrichment();+ $admin = auth()->user();+ $enrichment = new CategoryEnrichment();$enrichment->setUser($admin);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));- $category = $enrichment->enrichSingle($category);+ $category = $enrichment->enrichSingle($category);- $resource = new Item($category, $transformer, 'categories');+ $resource = new Item($category, $transformer, 'categories');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Category/UpdateController.php b/app/Api/V1/Controllers/Models/Category/UpdateController.phpindex 2059e9ad7b..3f482b35ad 100644--- a/app/Api/V1/Controllers/Models/Category/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Category/UpdateController.php@@ -63,9 +63,9 @@ final class UpdateController extends Controller*/public function update(UpdateRequest $request, Category $category): JsonResponse{- $data = $request->getAll();- $category = $this->repository->update($category, $data);- $manager = $this->getManager();+ $data = $request->getAll();+ $category = $this->repository->update($category, $data);+ $manager = $this->getManager();/** @var CategoryTransformer $transformer */$transformer = app(CategoryTransformer::class);@@ -73,14 +73,14 @@ final class UpdateController extends Controller// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new CategoryEnrichment();+ $admin = auth()->user();+ $enrichment = new CategoryEnrichment();$enrichment->setUser($admin);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));- $category = $enrichment->enrichSingle($category);+ $category = $enrichment->enrichSingle($category);- $resource = new Item($category, $transformer, 'categories');+ $resource = new Item($category, $transformer, 'categories');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.phpindex 7280864bb0..94aed4d919 100644--- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.php+++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.php@@ -45,7 +45,7 @@ final class DestroyController extends Controllerpublic const string RESOURCE_KEY = 'exchange-rates';#[Override]- protected array $acceptedRoles = [UserRoleEnum::OWNER];+ protected array $acceptedRoles = [UserRoleEnum::OWNER];private ExchangeRateRepositoryInterface $repository;public function __construct()diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.phpindex 319a3910d2..f426a86476 100644--- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php+++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php@@ -44,7 +44,7 @@ final class IndexController extends Controllerpublic const string RESOURCE_KEY = 'exchange-rates';#[Override]- protected array $acceptedRoles = [UserRoleEnum::OWNER];+ protected array $acceptedRoles = [UserRoleEnum::OWNER];private ExchangeRateRepositoryInterface $repository;public function __construct()diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.phpindex 33d06d1202..4b44b64d02 100644--- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.php+++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.php@@ -48,7 +48,7 @@ final class ShowController extends Controllerpublic const string RESOURCE_KEY = 'exchange-rates';#[Override]- protected array $acceptedRoles = [UserRoleEnum::OWNER];+ protected array $acceptedRoles = [UserRoleEnum::OWNER];private ExchangeRateRepositoryInterface $repository;public function __construct()@@ -64,12 +64,12 @@ final 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 transformer@@ -79,7 +79,7 @@ final class ShowController extends Controllerpublic function showSingleByDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): JsonResponse{- $transformer = new ExchangeRateTransformer();+ $transformer = new ExchangeRateTransformer();$transformer->setParameters($this->parameters);$exchangeRate = $this->repository->getSpecificRateOnDate($from, $to, $date);diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.phpindex 8fbad4b338..c400d41f36 100644--- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php+++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php@@ -51,7 +51,7 @@ final class StoreController extends Controllerpublic const string RESOURCE_KEY = 'exchange-rates';#[Override]- protected array $acceptedRoles = [UserRoleEnum::OWNER];+ protected array $acceptedRoles = [UserRoleEnum::OWNER];private ExchangeRateRepositoryInterface $repository;public function __construct()@@ -67,13 +67,13 @@ final class StoreController extends Controllerpublic function store(StoreRequest $request): JsonResponse{- $date = $request->getDate();- $rate = $request->getRate();- $from = $request->getFromCurrency();- $to = $request->getToCurrency();+ $date = $request->getDate();+ $rate = $request->getRate();+ $from = $request->getFromCurrency();+ $to = $request->getToCurrency();// already has rate?- $object = $this->repository->getSpecificRateOnDate($from, $to, $date);+ $object = $this->repository->getSpecificRateOnDate($from, $to, $date);if ($object instanceof CurrencyExchangeRate) {// just update it, no matter.$rate = $this->repository->updateExchangeRate($object, $rate, $date);@@ -93,8 +93,8 @@ final class StoreController extends Controllerpublic function storeByCurrencies(StoreByCurrenciesRequest $request, TransactionCurrency $from, TransactionCurrency $to): JsonResponse{- $data = $request->getAll();- $collection = new Collection();+ $data = $request->getAll();+ $collection = new Collection();foreach ($data as $date => $rate) {$date = Carbon::createFromFormat('Y-m-d', $date);@@ -107,7 +107,7 @@ final class StoreController extends Controllercontinue;}- $new = $this->repository->storeExchangeRate($from, $to, $rate, $date);+ $new = $this->repository->storeExchangeRate($from, $to, $rate, $date);event(new CreatedCurrencyExchangeRate($new));$collection->push($new);}@@ -122,9 +122,9 @@ final class StoreController extends Controllerpublic function storeByDate(StoreByDateRequest $request, Carbon $date): JsonResponse{- $data = $request->getAll();- $from = $request->getFromCurrency();- $collection = new Collection();+ $data = $request->getAll();+ $from = $request->getFromCurrency();+ $collection = new Collection();foreach ($data['rates'] as $key => $rate) {$to = Amount::getTransactionCurrencyByCode($key);$existing = $this->repository->getSpecificRateOnDate($from, $to, $date);@@ -136,7 +136,7 @@ final class StoreController extends Controllercontinue;}- $new = $this->repository->storeExchangeRate($from, $to, $rate, $date);+ $new = $this->repository->storeExchangeRate($from, $to, $rate, $date);$collection->push($new);event(new CreatedCurrencyExchangeRate($new));}diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.phpindex 93811fec05..701a56fe11 100644--- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.php+++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.php@@ -46,7 +46,7 @@ final class UpdateController extends Controllerpublic const string RESOURCE_KEY = 'exchange-rates';#[Override]- protected array $acceptedRoles = [UserRoleEnum::OWNER];+ protected array $acceptedRoles = [UserRoleEnum::OWNER];private ExchangeRateRepositoryInterface $repository;public function __construct()@@ -70,7 +70,7 @@ final class UpdateController extends Controller$rate = $request->getRate();$exchangeRate = $this->repository->updateExchangeRate($exchangeRate, $rate, $date);event(new UpdatedCurrencyExchangeRate($exchangeRate));- $transformer = new ExchangeRateTransformer();+ $transformer = new ExchangeRateTransformer();return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);}@@ -81,7 +81,7 @@ final class UpdateController extends Controller$rate = $request->getRate();$exchangeRate = $this->repository->updateExchangeRate($exchangeRate, $rate, $date);event(new UpdatedCurrencyExchangeRate($exchangeRate));- $transformer = new ExchangeRateTransformer();+ $transformer = new ExchangeRateTransformer();$transformer->setParameters($this->parameters);return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php b/app/Api/V1/Controllers/Models/ObjectGroup/ListController.phpindex b41babd180..6a4e7ebc33 100644--- a/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php+++ b/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php@@ -68,32 +68,32 @@ final class ListController extends Controller*/public function bills(ObjectGroup $objectGroup): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of piggy banks. Count it and split it.- $collection = $this->repository->getBills($objectGroup);- $count = $collection->count();- $bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->repository->getBills($objectGroup);+ $count = $collection->count();+ $bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new SubscriptionEnrichment();+ $admin = auth()->user();+ $enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));- $bills = $enrichment->enrich($bills);+ $bills = $enrichment->enrich($bills);// make paginator:- $paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.currencies.bills', [$objectGroup->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.currencies.bills', [$objectGroup->id]).$this->buildParams());/** @var BillTransformer $transformer */$transformer = app(BillTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($bills, $transformer, 'bills');+ $resource = new FractalCollection($bills, $transformer, 'bills');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -108,32 +108,32 @@ final class ListController extends Controllerpublic function piggyBanks(ObjectGroup $objectGroup): JsonResponse{// create some objects:- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of piggy banks. Count it and split it.- $collection = $this->repository->getPiggyBanks($objectGroup);- $count = $collection->count();- $piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->repository->getPiggyBanks($objectGroup);+ $count = $collection->count();+ $piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new PiggyBankEnrichment();+ $admin = auth()->user();+ $enrichment = new PiggyBankEnrichment();$enrichment->setUser($admin);- $piggyBanks = $enrichment->enrich($piggyBanks);+ $piggyBanks = $enrichment->enrich($piggyBanks);// make paginator:- $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.object-groups.piggy-banks', [$objectGroup->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.object-groups.piggy-banks', [$objectGroup->id]).$this->buildParams());/** @var PiggyBankTransformer $transformer */$transformer = app(PiggyBankTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');+ $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');$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/ObjectGroup/ShowController.php b/app/Api/V1/Controllers/Models/ObjectGroup/ShowController.phpindex 169616a0e6..589a60f4b6 100644--- a/app/Api/V1/Controllers/Models/ObjectGroup/ShowController.php+++ b/app/Api/V1/Controllers/Models/ObjectGroup/ShowController.php@@ -66,10 +66,10 @@ final class ShowController extends Controller*/public function index(): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');$this->repository->resetOrder();$collection = $this->repository->get();@@ -77,14 +77,14 @@ final class ShowController extends Controller$objectGroups = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($objectGroups, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.object-groups.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($objectGroups, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.object-groups.index').$this->buildParams());/** @var ObjectGroupTransformer $transformer */- $transformer = app(ObjectGroupTransformer::class);+ $transformer = app(ObjectGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($objectGroups, $transformer, 'object_groups');+ $resource = new FractalCollection($objectGroups, $transformer, 'object_groups');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -98,14 +98,14 @@ final class ShowController extends Controller*/public function show(ObjectGroup $objectGroup): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();$this->repository->resetOrder();$objectGroup->refresh();/** @var ObjectGroupTransformer $transformer */$transformer = app(ObjectGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($objectGroup, $transformer, 'object_groups');+ $resource = new Item($objectGroup, $transformer, 'object_groups');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php b/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.phpindex dd4f03cb27..c39763e600 100644--- a/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php+++ b/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php@@ -62,15 +62,15 @@ final class UpdateController extends Controller*/public function update(UpdateRequest $request, ObjectGroup $objectGroup): JsonResponse{- $data = $request->getUpdateData();+ $data = $request->getUpdateData();$this->repository->update($objectGroup, $data);$this->repository->resetOrder();- $manager = $this->getManager();+ $manager = $this->getManager();/** @var ObjectGroupTransformer $transformer */$transformer = app(ObjectGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($objectGroup, $transformer, 'object_groups');+ $resource = new Item($objectGroup, $transformer, 'object_groups');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/PiggyBank/ListController.php b/app/Api/V1/Controllers/Models/PiggyBank/ListController.phpindex 0db8c04f2d..60117da1a0 100644--- a/app/Api/V1/Controllers/Models/PiggyBank/ListController.php+++ b/app/Api/V1/Controllers/Models/PiggyBank/ListController.php@@ -68,30 +68,30 @@ final class ListController extends Controllerpublic function accounts(PiggyBank $piggyBank): JsonResponse{// types to get, page size:- $pageSize = $this->parameters->get('limit');- $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');+ $manager = $this->getManager();- $collection = $piggyBank->accounts;- $count = $collection->count();- $accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $piggyBank->accounts;+ $count = $collection->count();+ $accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new AccountEnrichment();+ $admin = auth()->user();+ $enrichment = new AccountEnrichment();$enrichment->setDate($this->parameters->get('date'));$enrichment->setUser($admin);- $accounts = $enrichment->enrich($accounts);+ $accounts = $enrichment->enrich($accounts);// make paginator:- $paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.piggy-banks.accounts', [$piggyBank->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.piggy-banks.accounts', [$piggyBank->id]).$this->buildParams());/** @var AccountTransformer $transformer */$transformer = app(AccountTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($accounts, $transformer, 'accounts');+ $resource = new FractalCollection($accounts, $transformer, 'accounts');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -103,22 +103,22 @@ final class ListController extends Controller*/public function attachments(PiggyBank $piggyBank): JsonResponse{- $manager = $this->getManager();- $pageSize = $this->parameters->get('limit');- $collection = $this->repository->getAttachments($piggyBank);+ $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');+ $collection = $this->repository->getAttachments($piggyBank);$count = $collection->count();$attachments = $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($attachments, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.piggy-banks.attachments', [$piggyBank->id]).$this->buildParams());/** @var AttachmentTransformer $transformer */$transformer = app(AttachmentTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($attachments, $transformer, 'attachments');+ $resource = new FractalCollection($attachments, $transformer, 'attachments');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -133,29 +133,29 @@ final class ListController extends Controllerpublic function piggyBankEvents(PiggyBank $piggyBank): JsonResponse{// types to get, page size:- $pageSize = $this->parameters->get('limit');- $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');+ $manager = $this->getManager();- $collection = $this->repository->getEvents($piggyBank);- $count = $collection->count();- $events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->repository->getEvents($piggyBank);+ $count = $collection->count();+ $events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new PiggyBankEventEnrichment();+ $admin = auth()->user();+ $enrichment = new PiggyBankEventEnrichment();$enrichment->setUser($admin);- $events = $enrichment->enrich($events);+ $events = $enrichment->enrich($events);// 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($events, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.piggy-banks.events', [$piggyBank->id]).$this->buildParams());/** @var PiggyBankEventTransformer $transformer */$transformer = app(PiggyBankEventTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($events, $transformer, sprintf('piggy-banks/%d/events', $piggyBank->id));+ $resource = new FractalCollection($events, $transformer, sprintf('piggy-banks/%d/events', $piggyBank->id));$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/PiggyBank/ShowController.php b/app/Api/V1/Controllers/Models/PiggyBank/ShowController.phpindex 182cc84115..f305d7cd25 100644--- a/app/Api/V1/Controllers/Models/PiggyBank/ShowController.php+++ b/app/Api/V1/Controllers/Models/PiggyBank/ShowController.php@@ -65,31 +65,31 @@ final class ShowController extends Controller*/public function index(): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of piggy banks. Count it and split it.- $collection = $this->repository->getPiggyBanks();- $count = $collection->count();- $piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->repository->getPiggyBanks();+ $count = $collection->count();+ $piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new PiggyBankEnrichment();+ $admin = auth()->user();+ $enrichment = new PiggyBankEnrichment();$enrichment->setUser($admin);- $piggyBanks = $enrichment->enrich($piggyBanks);+ $piggyBanks = $enrichment->enrich($piggyBanks);// make paginator:- $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.piggy-banks.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.piggy-banks.index').$this->buildParams());/** @var PiggyBankTransformer $transformer */$transformer = app(PiggyBankTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');+ $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -103,20 +103,20 @@ final class ShowController extends Controller*/public function show(PiggyBank $piggyBank): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new PiggyBankEnrichment();+ $admin = auth()->user();+ $enrichment = new PiggyBankEnrichment();$enrichment->setUser($admin);- $piggyBank = $enrichment->enrichSingle($piggyBank);+ $piggyBank = $enrichment->enrichSingle($piggyBank);/** @var PiggyBankTransformer $transformer */$transformer = app(PiggyBankTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($piggyBank, $transformer, 'piggy-banks');+ $resource = new Item($piggyBank, $transformer, 'piggy-banks');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/PiggyBank/StoreController.php b/app/Api/V1/Controllers/Models/PiggyBank/StoreController.phpindex 8e7baddb18..d502921765 100644--- a/app/Api/V1/Controllers/Models/PiggyBank/StoreController.php+++ b/app/Api/V1/Controllers/Models/PiggyBank/StoreController.php@@ -65,21 +65,21 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $piggyBank = $this->repository->store($request->getAll());- $manager = $this->getManager();+ $piggyBank = $this->repository->store($request->getAll());+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new PiggyBankEnrichment();+ $admin = auth()->user();+ $enrichment = new PiggyBankEnrichment();$enrichment->setUser($admin);- $piggyBank = $enrichment->enrichSingle($piggyBank);+ $piggyBank = $enrichment->enrichSingle($piggyBank);/** @var PiggyBankTransformer $transformer */$transformer = app(PiggyBankTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($piggyBank, $transformer, 'piggy_banks');+ $resource = new Item($piggyBank, $transformer, 'piggy_banks');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php b/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.phpindex dcbfed4f6e..65f742b31a 100644--- a/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php+++ b/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php@@ -63,23 +63,23 @@ final class UpdateController extends Controller*/public function update(UpdateRequest $request, PiggyBank $piggyBank): JsonResponse{- $data = $request->getAll();- $piggyBank = $this->repository->update($piggyBank, $data);+ $data = $request->getAll();+ $piggyBank = $this->repository->update($piggyBank, $data);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new PiggyBankEnrichment();+ $admin = auth()->user();+ $enrichment = new PiggyBankEnrichment();$enrichment->setUser($admin);- $piggyBank = $enrichment->enrichSingle($piggyBank);+ $piggyBank = $enrichment->enrichSingle($piggyBank);- $manager = $this->getManager();+ $manager = $this->getManager();/** @var PiggyBankTransformer $transformer */$transformer = app(PiggyBankTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($piggyBank, $transformer, 'piggy-banks');+ $resource = new Item($piggyBank, $transformer, 'piggy-banks');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Recurrence/ListController.php b/app/Api/V1/Controllers/Models/Recurrence/ListController.phpindex 6857fe8159..151019fae6 100644--- a/app/Api/V1/Controllers/Models/Recurrence/ListController.php+++ b/app/Api/V1/Controllers/Models/Recurrence/ListController.php@@ -68,21 +68,21 @@ final class ListController extends Controller*/public function transactions(Request $request, Recurrence $recurrence): JsonResponse{- $pageSize = $this->parameters->get('limit');- $type = $request->input('type') ?? 'default';+ $pageSize = $this->parameters->get('limit');+ $type = $request->input('type') ?? 'default';$this->parameters->set('type', $type);- $types = $this->mapTransactionTypes($this->parameters->get('type'));- $manager = $this->getManager();+ $types = $this->mapTransactionTypes($this->parameters->get('type'));+ $manager = $this->getManager();// whatever is returned by the query, it must be part of these journals:- $journalIds = $this->repository->getJournalIds($recurrence);+ $journalIds = $this->repository->getJournalIds($recurrence);/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);if (0 === count($journalIds)) {$collector->findNothing();}@@ -97,7 +97,8 @@ final class ListController extends Controller// set page to retrieve->setPage($this->parameters->get('page'))// set types of transactions to return.- ->setTypes($types);+ ->setTypes($types)+ ;if (null !== $this->parameters->get('start')) {$collector->setStart($this->parameters->get('start'));@@ -106,19 +107,19 @@ final class ListController extends Controller$collector->setEnd($this->parameters->get('end'));}- $paginator = $collector->getPaginatedGroups();- $paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());+ $paginator = $collector->getPaginatedGroups();+ $paginator->setPath(route('api.v1.transactions.index').$this->buildParams());// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);$transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$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/Recurrence/ShowController.php b/app/Api/V1/Controllers/Models/Recurrence/ShowController.phpindex f4223e647b..8c9cdef82a 100644--- a/app/Api/V1/Controllers/Models/Recurrence/ShowController.php+++ b/app/Api/V1/Controllers/Models/Recurrence/ShowController.php@@ -65,10 +65,10 @@ final class ShowController extends Controller*/public function index(): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of budgets. Count it and split it.$collection = $this->repository->get();@@ -77,20 +77,20 @@ final class ShowController extends Controller// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new RecurringEnrichment();+ $admin = auth()->user();+ $enrichment = new RecurringEnrichment();$enrichment->setUser($admin);$recurrences = $enrichment->enrich($recurrences);// make paginator:- $paginator = new LengthAwarePaginator($recurrences, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.recurrences.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($recurrences, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.recurrences.index').$this->buildParams());/** @var RecurrenceTransformer $transformer */$transformer = app(RecurrenceTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($recurrences, $transformer, 'recurrences');+ $resource = new FractalCollection($recurrences, $transformer, 'recurrences');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -104,20 +104,20 @@ final class ShowController extends Controller*/public function show(Recurrence $recurrence): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new RecurringEnrichment();+ $admin = auth()->user();+ $enrichment = new RecurringEnrichment();$enrichment->setUser($admin);- $recurrence = $enrichment->enrichSingle($recurrence);+ $recurrence = $enrichment->enrichSingle($recurrence);/** @var RecurrenceTransformer $transformer */$transformer = app(RecurrenceTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($recurrence, $transformer, 'recurrences');+ $resource = new Item($recurrence, $transformer, 'recurrences');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Recurrence/StoreController.php b/app/Api/V1/Controllers/Models/Recurrence/StoreController.phpindex 202b0c5377..2c3a574f4f 100644--- a/app/Api/V1/Controllers/Models/Recurrence/StoreController.php+++ b/app/Api/V1/Controllers/Models/Recurrence/StoreController.php@@ -65,22 +65,22 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $data = $request->getAll();- $recurrence = $this->repository->store($data);- $manager = $this->getManager();+ $data = $request->getAll();+ $recurrence = $this->repository->store($data);+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new RecurringEnrichment();+ $admin = auth()->user();+ $enrichment = new RecurringEnrichment();$enrichment->setUser($admin);- $recurrence = $enrichment->enrichSingle($recurrence);+ $recurrence = $enrichment->enrichSingle($recurrence);/** @var RecurrenceTransformer $transformer */$transformer = app(RecurrenceTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($recurrence, $transformer, 'recurrences');+ $resource = new Item($recurrence, $transformer, 'recurrences');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Recurrence/TriggerController.php b/app/Api/V1/Controllers/Models/Recurrence/TriggerController.phpindex a04c0afc0b..f3f1f31dc0 100644--- a/app/Api/V1/Controllers/Models/Recurrence/TriggerController.php+++ b/app/Api/V1/Controllers/Models/Recurrence/TriggerController.php@@ -63,31 +63,31 @@ final class TriggerController extends Controller{// find recurrence occurrence for this date and trigger it.// grab the date from the last time the recurrence fired:- $backupDate = $recurrence->latest_date;- $date = $request->attributes->get('date');+ $backupDate = $recurrence->latest_date;+ $date = $request->attributes->get('date');// fire the recurring cron job on the given date, then post-date the created transaction.Log::info(sprintf('Trigger: will now fire recurring cron job task for date "%s".', $date->format('Y-m-d H:i:s')));/** @var CreateRecurringTransactions $job */- $job = app(CreateRecurringTransactions::class);+ $job = app(CreateRecurringTransactions::class);$job->setRecurrences(new Collection()->push($recurrence));$job->setDate($date);$job->setForce(false);$job->handle();Log::debug('Done with recurrence.');- $groups = $job->getGroups();+ $groups = $job->getGroups();$this->repository->markGroupsAsNow($groups);- $recurrence = $this->repository->setLatestDate($recurrence, $backupDate);+ $recurrence = $this->repository->setLatestDate($recurrence, $backupDate);Preferences::mark();// enrich groups and return them:- $paginator = new LengthAwarePaginator(new Collection(), 0, 1);+ $paginator = new LengthAwarePaginator(new Collection(), 0, 1);if ($groups->count() > 0) {/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */@@ -96,20 +96,20 @@ final class TriggerController extends Controller$paginator = $collector->getPaginatedGroups();}- $manager = $this->getManager();- $paginator->setPath(route('api.v1.recurrences.trigger', [$recurrence->id]) . $this->buildParams());+ $manager = $this->getManager();+ $paginator->setPath(route('api.v1.recurrences.trigger', [$recurrence->id]).$this->buildParams());// enrich- $admin = auth()->user();- $enrichment = new TransactionGroupEnrichment();+ $admin = auth()->user();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);$transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$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/Recurrence/UpdateController.php b/app/Api/V1/Controllers/Models/Recurrence/UpdateController.phpindex 5274de011d..203230b19a 100644--- a/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php@@ -63,22 +63,22 @@ final class UpdateController extends Controller*/public function update(UpdateRequest $request, Recurrence $recurrence): JsonResponse{- $data = $request->getAll();- $recurrence = $this->repository->update($recurrence, $data);- $manager = $this->getManager();+ $data = $request->getAll();+ $recurrence = $this->repository->update($recurrence, $data);+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new RecurringEnrichment();+ $admin = auth()->user();+ $enrichment = new RecurringEnrichment();$enrichment->setUser($admin);- $recurrence = $enrichment->enrichSingle($recurrence);+ $recurrence = $enrichment->enrichSingle($recurrence);/** @var RecurrenceTransformer $transformer */$transformer = app(RecurrenceTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($recurrence, $transformer, 'recurrences');+ $resource = new Item($recurrence, $transformer, 'recurrences');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Rule/DestroyController.php b/app/Api/V1/Controllers/Models/Rule/DestroyController.phpindex 87db86aad3..a9fff279f9 100644--- a/app/Api/V1/Controllers/Models/Rule/DestroyController.php+++ b/app/Api/V1/Controllers/Models/Rule/DestroyController.php@@ -46,7 +46,7 @@ final class DestroyController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->ruleRepository = app(RuleRepositoryInterface::class);$this->ruleRepository->setUser($user);diff --git a/app/Api/V1/Controllers/Models/Rule/ShowController.php b/app/Api/V1/Controllers/Models/Rule/ShowController.phpindex de61506c26..fc8d40737a 100644--- a/app/Api/V1/Controllers/Models/Rule/ShowController.php+++ b/app/Api/V1/Controllers/Models/Rule/ShowController.php@@ -50,7 +50,7 @@ final class ShowController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->ruleRepository = app(RuleRepositoryInterface::class);$this->ruleRepository->setUser($user);@@ -67,25 +67,25 @@ final class ShowController extends Controller*/public function index(): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of budgets. Count it and split it.- $collection = $this->ruleRepository->getAll();- $count = $collection->count();- $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->ruleRepository->getAll();+ $count = $collection->count();+ $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.rules.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.rules.index').$this->buildParams());/** @var RuleTransformer $transformer */$transformer = app(RuleTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($rules, $transformer, 'rules');+ $resource = new FractalCollection($rules, $transformer, 'rules');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -99,13 +99,13 @@ final class ShowController extends Controller*/public function show(Rule $rule): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();/** @var RuleTransformer $transformer */$transformer = app(RuleTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($rule, $transformer, 'rules');+ $resource = new Item($rule, $transformer, 'rules');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Rule/StoreController.php b/app/Api/V1/Controllers/Models/Rule/StoreController.phpindex e43d6159ca..10ea227aa4 100644--- a/app/Api/V1/Controllers/Models/Rule/StoreController.php+++ b/app/Api/V1/Controllers/Models/Rule/StoreController.php@@ -47,7 +47,7 @@ final class StoreController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->ruleRepository = app(RuleRepositoryInterface::class);$this->ruleRepository->setUser($user);@@ -64,14 +64,14 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $rule = $this->ruleRepository->store($request->getAll());- $manager = $this->getManager();+ $rule = $this->ruleRepository->store($request->getAll());+ $manager = $this->getManager();/** @var RuleTransformer $transformer */$transformer = app(RuleTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($rule, $transformer, 'rules');+ $resource = new Item($rule, $transformer, 'rules');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Rule/TriggerController.php b/app/Api/V1/Controllers/Models/Rule/TriggerController.phpindex 89d5912db0..cc969326dc 100644--- a/app/Api/V1/Controllers/Models/Rule/TriggerController.php+++ b/app/Api/V1/Controllers/Models/Rule/TriggerController.php@@ -54,7 +54,7 @@ final class TriggerController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->ruleRepository = app(RuleRepositoryInterface::class);$this->ruleRepository->setUser($user);@@ -69,10 +69,10 @@ final class TriggerController extends Controller*/public function testRule(TestRequest $request, Rule $rule): JsonResponse{- $parameters = $request->getTestParameters();+ $parameters = $request->getTestParameters();/** @var RuleEngineInterface $ruleEngine */- $ruleEngine = app(RuleEngineInterface::class);+ $ruleEngine = app(RuleEngineInterface::class);$ruleEngine->setRules(new Collection()->push($rule));// overrule the rule(s) if necessary.@@ -94,21 +94,21 @@ final class TriggerController extends Controller$count = $transactions->count();// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($rule->user);$transactions = $enrichment->enrich($transactions);- $paginator = new LengthAwarePaginator($transactions, $count, 31_337, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.rules.test', [$rule->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($transactions, $count, 31_337, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.rules.test', [$rule->id]).$this->buildParams());// resulting list is presented as JSON thing.- $manager = $this->getManager();+ $manager = $this->getManager();/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$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/Rule/UpdateController.php b/app/Api/V1/Controllers/Models/Rule/UpdateController.phpindex def7fb59e8..1867208f41 100644--- a/app/Api/V1/Controllers/Models/Rule/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Rule/UpdateController.php@@ -48,7 +48,7 @@ final class UpdateController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->ruleRepository = app(RuleRepositoryInterface::class);$this->ruleRepository->setUser($user);@@ -65,15 +65,15 @@ final class UpdateController extends Controller*/public function update(UpdateRequest $request, Rule $rule): JsonResponse{- $data = $request->getAll();- $rule = $this->ruleRepository->update($rule, $data);- $manager = $this->getManager();+ $data = $request->getAll();+ $rule = $this->ruleRepository->update($rule, $data);+ $manager = $this->getManager();/** @var RuleTransformer $transformer */$transformer = app(RuleTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($rule, $transformer, 'rules');+ $resource = new Item($rule, $transformer, 'rules');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.php b/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.phpindex c7db0cdabe..15a4585317 100644--- a/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.php+++ b/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.php@@ -46,7 +46,7 @@ final class DestroyController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);$this->ruleGroupRepository->setUser($user);diff --git a/app/Api/V1/Controllers/Models/RuleGroup/ListController.php b/app/Api/V1/Controllers/Models/RuleGroup/ListController.phpindex 0318bce43b..96ae8521cb 100644--- a/app/Api/V1/Controllers/Models/RuleGroup/ListController.php+++ b/app/Api/V1/Controllers/Models/RuleGroup/ListController.php@@ -49,7 +49,7 @@ final class ListController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);$this->ruleGroupRepository->setUser($user);@@ -64,24 +64,24 @@ final class ListController extends Controller*/public function rules(RuleGroup $group): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of budgets. Count it and split it.- $collection = $this->ruleGroupRepository->getRules($group);- $count = $collection->count();- $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->ruleGroupRepository->getRules($group);+ $count = $collection->count();+ $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.rule-groups.rules', [$group->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.rule-groups.rules', [$group->id]).$this->buildParams());/** @var RuleTransformer $transformer */$transformer = app(RuleTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($rules, $transformer, 'rules');+ $resource = new FractalCollection($rules, $transformer, 'rules');$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/RuleGroup/ShowController.php b/app/Api/V1/Controllers/Models/RuleGroup/ShowController.phpindex ea6d1277c6..cd842f7636 100644--- a/app/Api/V1/Controllers/Models/RuleGroup/ShowController.php+++ b/app/Api/V1/Controllers/Models/RuleGroup/ShowController.php@@ -50,7 +50,7 @@ final class ShowController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);$this->ruleGroupRepository->setUser($user);@@ -66,24 +66,24 @@ final class ShowController extends Controller*/public function index(): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of rule groups. Count it and split it.- $collection = $this->ruleGroupRepository->get();- $count = $collection->count();- $ruleGroups = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->ruleGroupRepository->get();+ $count = $collection->count();+ $ruleGroups = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($ruleGroups, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.rule-groups.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($ruleGroups, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.rule-groups.index').$this->buildParams());/** @var RuleGroupTransformer $transformer */$transformer = app(RuleGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($ruleGroups, $transformer, 'rule_groups');+ $resource = new FractalCollection($ruleGroups, $transformer, 'rule_groups');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -97,13 +97,13 @@ final class ShowController extends Controller*/public function show(RuleGroup $ruleGroup): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();/** @var RuleGroupTransformer $transformer */$transformer = app(RuleGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($ruleGroup, $transformer, 'rule_groups');+ $resource = new Item($ruleGroup, $transformer, 'rule_groups');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php b/app/Api/V1/Controllers/Models/RuleGroup/StoreController.phpindex 9fc51a1b88..2fdd88323e 100644--- a/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php+++ b/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php@@ -38,7 +38,7 @@ use League\Fractal\Resource\Item;*/final class StoreController extends Controller{- private AccountRepositoryInterface $accountRepository;+ private AccountRepositoryInterface $accountRepository;private RuleGroupRepositoryInterface $ruleGroupRepository;/**@@ -49,12 +49,12 @@ final class StoreController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);$this->ruleGroupRepository->setUser($user);- $this->accountRepository = app(AccountRepositoryInterface::class);+ $this->accountRepository = app(AccountRepositoryInterface::class);$this->accountRepository->setUser($user);return $next($request);@@ -69,14 +69,14 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $ruleGroup = $this->ruleGroupRepository->store($request->getAll());- $manager = $this->getManager();+ $ruleGroup = $this->ruleGroupRepository->store($request->getAll());+ $manager = $this->getManager();/** @var RuleGroupTransformer $transformer */$transformer = app(RuleGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($ruleGroup, $transformer, 'rule_groups');+ $resource = new Item($ruleGroup, $transformer, 'rule_groups');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php b/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.phpindex 23fd987f73..3e1888723f 100644--- a/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php+++ b/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php@@ -55,7 +55,7 @@ final class TriggerController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);$this->ruleGroupRepository->setUser($user);@@ -72,14 +72,14 @@ final class TriggerController extends Controller*/public function testGroup(TestRequest $request, RuleGroup $group): JsonResponse{- $rules = $this->ruleGroupRepository->getActiveRules($group);+ $rules = $this->ruleGroupRepository->getActiveRules($group);if (0 === $rules->count()) {throw new FireflyException('200023: No rules in this rule group.');}- $parameters = $request->getTestParameters();+ $parameters = $request->getTestParameters();/** @var RuleEngineInterface $ruleEngine */- $ruleEngine = app(RuleEngineInterface::class);+ $ruleEngine = app(RuleEngineInterface::class);$ruleEngine->setRules($rules);// overrule the rule(s) if necessary.@@ -101,21 +101,21 @@ final class TriggerController extends Controller$count = $transactions->count();// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($group->user);$transactions = $enrichment->enrich($transactions);- $paginator = new LengthAwarePaginator($transactions, $count, 31_337, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.rule-groups.test', [$group->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($transactions, $count, 31_337, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.rule-groups.test', [$group->id]).$this->buildParams());// resulting list is presented as JSON thing.- $manager = $this->getManager();+ $manager = $this->getManager();/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -131,7 +131,7 @@ final class TriggerController extends Controller*/public function triggerGroup(TriggerRequest $request, RuleGroup $group): JsonResponse{- $rules = $this->ruleGroupRepository->getActiveRules($group);+ $rules = $this->ruleGroupRepository->getActiveRules($group);if (0 === $rules->count()) {throw new FireflyException('200023: No rules in this rule group.');}diff --git a/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.php b/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.phpindex aa45ac3e35..14291cf4d3 100644--- a/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.php+++ b/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.php@@ -48,7 +48,7 @@ final class UpdateController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);$this->ruleGroupRepository->setUser($user);@@ -65,14 +65,14 @@ final class UpdateController extends Controller*/public function update(UpdateRequest $request, RuleGroup $ruleGroup): JsonResponse{- $ruleGroup = $this->ruleGroupRepository->update($ruleGroup, $request->getAll());- $manager = $this->getManager();+ $ruleGroup = $this->ruleGroupRepository->update($ruleGroup, $request->getAll());+ $manager = $this->getManager();/** @var RuleGroupTransformer $transformer */$transformer = app(RuleGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($ruleGroup, $transformer, 'rule_groups');+ $resource = new Item($ruleGroup, $transformer, 'rule_groups');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Tag/DestroyController.php b/app/Api/V1/Controllers/Models/Tag/DestroyController.phpindex 5ca1e2475a..b1b09a77d0 100644--- a/app/Api/V1/Controllers/Models/Tag/DestroyController.php+++ b/app/Api/V1/Controllers/Models/Tag/DestroyController.php@@ -46,7 +46,7 @@ final class DestroyController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(TagRepositoryInterface::class);$this->repository->setUser($user);diff --git a/app/Api/V1/Controllers/Models/Tag/ListController.php b/app/Api/V1/Controllers/Models/Tag/ListController.phpindex 06b403e863..fb3b8c98df 100644--- a/app/Api/V1/Controllers/Models/Tag/ListController.php+++ b/app/Api/V1/Controllers/Models/Tag/ListController.php@@ -56,7 +56,7 @@ final class ListController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(TagRepositoryInterface::class);$this->repository->setUser($user);@@ -71,22 +71,22 @@ final class ListController extends Controller*/public function attachments(Tag $tag): JsonResponse{- $manager = $this->getManager();- $pageSize = $this->parameters->get('limit');- $collection = $this->repository->getAttachments($tag);+ $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');+ $collection = $this->repository->getAttachments($tag);$count = $collection->count();$attachments = $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.tags.attachments', [$tag->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.tags.attachments', [$tag->id]).$this->buildParams());/** @var AttachmentTransformer $transformer */$transformer = app(AttachmentTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($attachments, $transformer, 'attachments');+ $resource = new FractalCollection($attachments, $transformer, 'attachments');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -100,19 +100,19 @@ final class ListController extends Controller*/public function transactions(Request $request, Tag $tag): JsonResponse{- $pageSize = $this->parameters->get('limit');- $type = $request->input('type') ?? 'default';+ $pageSize = $this->parameters->get('limit');+ $type = $request->input('type') ?? 'default';$this->parameters->set('type', $type);- $types = $this->mapTransactionTypes($this->parameters->get('type'));- $manager = $this->getManager();+ $types = $this->mapTransactionTypes($this->parameters->get('type'));+ $manager = $this->getManager();/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)// filter on tag.@@ -124,7 +124,8 @@ final class ListController extends Controller// set page to retrieve->setPage($this->parameters->get('page'))// set types of transactions to return.- ->setTypes($types);+ ->setTypes($types)+ ;if (null !== $this->parameters->get('start')) {$collector->setStart($this->parameters->get('start'));@@ -132,19 +133,19 @@ final class ListController extends Controllerif (null !== $this->parameters->get('end')) {$collector->setEnd($this->parameters->get('end'));}- $paginator = $collector->getPaginatedGroups();- $paginator->setPath(route('api.v1.tags.transactions', [$tag->id]) . $this->buildParams());+ $paginator = $collector->getPaginatedGroups();+ $paginator->setPath(route('api.v1.tags.transactions', [$tag->id]).$this->buildParams());// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);$transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$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/Tag/ShowController.php b/app/Api/V1/Controllers/Models/Tag/ShowController.phpindex b8c323b075..be923830f6 100644--- a/app/Api/V1/Controllers/Models/Tag/ShowController.php+++ b/app/Api/V1/Controllers/Models/Tag/ShowController.php@@ -50,7 +50,7 @@ final class ShowController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(TagRepositoryInterface::class);$this->repository->setUser($user);@@ -67,24 +67,24 @@ final class ShowController extends Controller*/public function index(): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of budgets. Count it and split it.- $collection = $this->repository->get();- $count = $collection->count();- $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->repository->get();+ $count = $collection->count();+ $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.tags.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.tags.index').$this->buildParams());/** @var TagTransformer $transformer */$transformer = app(TagTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($rules, $transformer, 'tags');+ $resource = new FractalCollection($rules, $transformer, 'tags');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -98,13 +98,13 @@ final class ShowController extends Controller*/public function show(Tag $tag): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();/** @var TagTransformer $transformer */$transformer = app(TagTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($tag, $transformer, 'tags');+ $resource = new Item($tag, $transformer, 'tags');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Tag/StoreController.php b/app/Api/V1/Controllers/Models/Tag/StoreController.phpindex b3e87683aa..2be32d3362 100644--- a/app/Api/V1/Controllers/Models/Tag/StoreController.php+++ b/app/Api/V1/Controllers/Models/Tag/StoreController.php@@ -47,7 +47,7 @@ final class StoreController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(TagRepositoryInterface::class);$this->repository->setUser($user);@@ -64,14 +64,14 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $rule = $this->repository->store($request->getAll());- $manager = $this->getManager();+ $rule = $this->repository->store($request->getAll());+ $manager = $this->getManager();/** @var TagTransformer $transformer */$transformer = app(TagTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($rule, $transformer, 'tags');+ $resource = new Item($rule, $transformer, 'tags');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Tag/UpdateController.php b/app/Api/V1/Controllers/Models/Tag/UpdateController.phpindex f9d381c4bb..2bb2a16338 100644--- a/app/Api/V1/Controllers/Models/Tag/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Tag/UpdateController.php@@ -48,7 +48,7 @@ final class UpdateController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(TagRepositoryInterface::class);$this->repository->setUser($user);@@ -65,14 +65,14 @@ final class UpdateController extends Controller*/public function update(UpdateRequest $request, Tag $tag): JsonResponse{- $rule = $this->repository->update($tag, $request->getAll());- $manager = $this->getManager();+ $rule = $this->repository->update($tag, $request->getAll());+ $manager = $this->getManager();/** @var TagTransformer $transformer */$transformer = app(TagTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($rule, $transformer, 'tags');+ $resource = new Item($rule, $transformer, 'tags');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Transaction/DestroyController.php b/app/Api/V1/Controllers/Models/Transaction/DestroyController.phpindex a014070e55..76eac21f5d 100644--- a/app/Api/V1/Controllers/Models/Transaction/DestroyController.php+++ b/app/Api/V1/Controllers/Models/Transaction/DestroyController.php@@ -50,9 +50,9 @@ final class DestroyController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();- $this->repository = app(JournalRepositoryInterface::class);+ $this->repository = app(JournalRepositoryInterface::class);$this->repository->setUser($admin);$this->groupRepository = app(TransactionGroupRepository::class);diff --git a/app/Api/V1/Controllers/Models/Transaction/ListController.php b/app/Api/V1/Controllers/Models/Transaction/ListController.phpindex 40574da140..284ffc4c23 100644--- a/app/Api/V1/Controllers/Models/Transaction/ListController.php+++ b/app/Api/V1/Controllers/Models/Transaction/ListController.php@@ -54,7 +54,7 @@ final class ListController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();$this->journalAPIRepository = app(JournalAPIRepositoryInterface::class);$this->journalAPIRepository->setUser($admin);@@ -69,9 +69,9 @@ final class ListController extends Controller*/public function attachments(TransactionGroup $transactionGroup): JsonResponse{- $manager = $this->getManager();- $pageSize = $this->parameters->get('limit');- $collection = new Collection();+ $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');+ $collection = new Collection();foreach ($transactionGroup->transactionJournals as $transactionJournal) {$collection = $this->journalAPIRepository->getAttachments($transactionJournal)->merge($collection);}@@ -80,14 +80,14 @@ final class ListController extends Controller$attachments = $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.transactions.attachments', [$transactionGroup->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.transactions.attachments', [$transactionGroup->id]).$this->buildParams());/** @var AttachmentTransformer $transformer */$transformer = app(AttachmentTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($attachments, $transformer, 'attachments');+ $resource = new FractalCollection($attachments, $transformer, 'attachments');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -99,31 +99,31 @@ final class ListController extends Controller*/public function piggyBankEvents(TransactionGroup $transactionGroup): JsonResponse{- $manager = $this->getManager();- $collection = new Collection();- $pageSize = $this->parameters->get('limit');+ $manager = $this->getManager();+ $collection = new Collection();+ $pageSize = $this->parameters->get('limit');foreach ($transactionGroup->transactionJournals as $transactionJournal) {$collection = $this->journalAPIRepository->getPiggyBankEvents($transactionJournal)->merge($collection);}- $count = $collection->count();- $events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $count = $collection->count();+ $events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new PiggyBankEventEnrichment();+ $admin = auth()->user();+ $enrichment = new PiggyBankEventEnrichment();$enrichment->setUser($admin);- $events = $enrichment->enrich($events);+ $events = $enrichment->enrich($events);// make paginator:- $paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.transactions.piggy-bank-events', [$transactionGroup->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.transactions.piggy-bank-events', [$transactionGroup->id]).$this->buildParams());/** @var PiggyBankEventTransformer $transformer */$transformer = app(PiggyBankEventTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($events, $transformer, 'piggy_bank_events');+ $resource = new FractalCollection($events, $transformer, 'piggy_bank_events');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));// /** @var PiggyBankEventTransformer $transformer */// $transformer = app(PiggyBankEventTransformer::class);@@ -147,14 +147,14 @@ final class ListController extends Controller$journalLinks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($journalLinks, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.transaction-journals.transaction-links', [$transactionJournal->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($journalLinks, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.transaction-journals.transaction-links', [$transactionJournal->id]).$this->buildParams());/** @var TransactionLinkTransformer $transformer */- $transformer = app(TransactionLinkTransformer::class);+ $transformer = app(TransactionLinkTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($journalLinks, $transformer, 'transaction_links');+ $resource = new FractalCollection($journalLinks, $transformer, 'transaction_links');$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/Transaction/ShowController.php b/app/Api/V1/Controllers/Models/Transaction/ShowController.phpindex ca522a69f7..cd96be0605 100644--- a/app/Api/V1/Controllers/Models/Transaction/ShowController.php+++ b/app/Api/V1/Controllers/Models/Transaction/ShowController.php@@ -54,19 +54,19 @@ final class ShowController extends Controller*/public function index(Request $request): JsonResponse{- $pageSize = $this->parameters->get('limit');- $type = $request->input('type') ?? 'default';+ $pageSize = $this->parameters->get('limit');+ $type = $request->input('type') ?? 'default';$this->parameters->set('type', $type);- $types = $this->mapTransactionTypes($this->parameters->get('type'));- $manager = $this->getManager();+ $types = $this->mapTransactionTypes($this->parameters->get('type'));+ $manager = $this->getManager();/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)// all info needed for the API:@@ -76,23 +76,24 @@ final class ShowController extends Controller// set page to retrieve->setPage($this->parameters->get('page'))// set types of transactions to return.- ->setTypes($types);+ ->setTypes($types)+ ;if (null !== $this->parameters->get('start') || null !== $this->parameters->get('end')) {$collector->setRange($this->parameters->get('start'), $this->parameters->get('end'));}- $paginator = $collector->getPaginatedGroups();- $paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());+ $paginator = $collector->getPaginatedGroups();+ $paginator->setPath(route('api.v1.transactions.index').$this->buildParams());// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);$transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -106,20 +107,21 @@ final class ShowController extends Controller*/public function show(TransactionGroup $transactionGroup): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)// filter on transaction group.->setTransactionGroup($transactionGroup)// all info needed for the API:- ->withAPIInformation();+ ->withAPIInformation()+ ;$selectedGroup = $collector->getGroups()->first();if (null === $selectedGroup) {@@ -127,14 +129,14 @@ final class ShowController extends Controller}// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);$selectedGroup = $enrichment->enrichSingle($selectedGroup);/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($selectedGroup, $transformer, 'transactions');+ $resource = new Item($selectedGroup, $transformer, 'transactions');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Transaction/StoreController.php b/app/Api/V1/Controllers/Models/Transaction/StoreController.phpindex a845525999..e21ae4cf32 100644--- a/app/Api/V1/Controllers/Models/Transaction/StoreController.php+++ b/app/Api/V1/Controllers/Models/Transaction/StoreController.php@@ -54,7 +54,7 @@ final class StoreController extends Controlleruse TransactionFilter;#[Override]- protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS];+ protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS];private TransactionGroupRepositoryInterface $groupRepository;/**@@ -65,8 +65,8 @@ final class StoreController extends Controllerparent::__construct();$this->middleware(function (Request $request, $next) {/** @var User $admin */- $admin = auth()->user();- $userGroup = $this->validateUserGroup($request);+ $admin = auth()->user();+ $userGroup = $this->validateUserGroup($request);$this->groupRepository = app(TransactionGroupRepositoryInterface::class);$this->groupRepository->setUser($admin);@@ -111,36 +111,37 @@ final class StoreController extends Controllerthrow new ValidationException($validator);}- $manager = $this->getManager();+ $manager = $this->getManager();/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)->setUserGroup($this->userGroup)// filter on transaction group.->setTransactionGroup($transactionGroup)// all info needed for the API:- ->withAPIInformation();+ ->withAPIInformation()+ ;- $selectedGroup = $collector->getGroups()->first();+ $selectedGroup = $collector->getGroups()->first();if (null === $selectedGroup) {throw HttpException::fromStatusCode(410, '200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');}// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);- $selectedGroup = $enrichment->enrichSingle($selectedGroup);+ $selectedGroup = $enrichment->enrichSingle($selectedGroup);/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($selectedGroup, $transformer, 'transactions');+ $resource = new Item($selectedGroup, $transformer, 'transactions');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php b/app/Api/V1/Controllers/Models/Transaction/UpdateController.phpindex b2f2cd16ab..e9579cd9cc 100644--- a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php+++ b/app/Api/V1/Controllers/Models/Transaction/UpdateController.php@@ -49,7 +49,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;final class UpdateController extends Controller{#[Override]- protected array $acceptedRoles = [];+ protected array $acceptedRoles = [];private TransactionGroupRepositoryInterface $groupRepository;/**@@ -60,7 +60,7 @@ final class UpdateController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();$this->groupRepository = app(TransactionGroupRepositoryInterface::class);$this->groupRepository->setUser($admin);@@ -77,19 +77,19 @@ final class UpdateController extends Controller*/public function update(UpdateRequest $request, TransactionGroup $transactionGroup): JsonResponse{- $data = $request->getAll();+ $data = $request->getAll();Log::debug('Now in update routine for transaction group', $data);- $oldHash = $this->groupRepository->getCompareHash($transactionGroup);- $objects = TransactionGroupEventObjects::collectFromTransactionGroup($transactionGroup);- $transactionGroup = $this->groupRepository->update($transactionGroup, $data);+ $oldHash = $this->groupRepository->getCompareHash($transactionGroup);+ $objects = TransactionGroupEventObjects::collectFromTransactionGroup($transactionGroup);+ $transactionGroup = $this->groupRepository->update($transactionGroup, $data);$objects->appendFromTransactionGroup($transactionGroup);- $newHash = $this->groupRepository->getCompareHash($transactionGroup);- $manager = $this->getManager();+ $newHash = $this->groupRepository->getCompareHash($transactionGroup);+ $manager = $this->getManager();Preferences::mark();- $applyRules = $data['apply_rules'] ?? true;- $fireWebhooks = $data['fire_webhooks'] ?? true;- $runRecalculations = $oldHash !== $newHash;+ $applyRules = $data['apply_rules'] ?? true;+ $fireWebhooks = $data['fire_webhooks'] ?? true;+ $runRecalculations = $oldHash !== $newHash;$flags = new TransactionGroupEventFlags();$flags->applyRules = $applyRules;@@ -100,31 +100,32 @@ final class UpdateController extends Controllerevent(new WebhookMessagesRequestSending());/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)// filter on transaction group.->setTransactionGroup($transactionGroup)// all info needed for the API:- ->withAPIInformation();+ ->withAPIInformation()+ ;- $selectedGroup = $collector->getGroups()->first();+ $selectedGroup = $collector->getGroups()->first();if (null === $selectedGroup) {throw new NotFoundHttpException();}// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);- $selectedGroup = $enrichment->enrichSingle($selectedGroup);+ $selectedGroup = $enrichment->enrichSingle($selectedGroup);/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);- $resource = new Item($selectedGroup, $transformer, 'transactions');+ $transformer = app(TransactionGroupTransformer::class);+ $resource = new Item($selectedGroup, $transformer, 'transactions');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 019ed473ab..9c8de461d2 100644--- a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php@@ -73,15 +73,15 @@ final class ListController extends Controller*/public function accounts(Request $request, TransactionCurrency $currency): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// read type from URL- $type = $request->input('type') ?? 'all';+ $type = $request->input('type') ?? 'all';$this->parameters->set('type', $type);// types to get, page size:- $types = $this->mapAccountTypes($this->parameters->get('type'));- $pageSize = $this->parameters->get('limit');+ $types = $this->mapAccountTypes($this->parameters->get('type'));+ $pageSize = $this->parameters->get('limit');// get list of accounts. Count it and split it./** @var AccountRepositoryInterface $accountRepository */@@ -89,14 +89,14 @@ final class ListController extends Controller$unfiltered = $accountRepository->getAccountsByType($types);// filter list on currency preference:- $collection = $unfiltered->filter(static function (Account $account) use ($currency, $accountRepository): bool {- $currencyId = (int)$accountRepository->getMetaValue($account, 'currency_id');+ $collection = $unfiltered->filter(static function (Account $account) use ($currency, $accountRepository): bool {+ $currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id');return $currencyId === $currency->id;});- $count = $collection->count();- $accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $count = $collection->count();+ $accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// #11007 go to the end of the previous day.$this->parameters->set('start', $this->parameters->get('start')?->subSecond());@@ -105,22 +105,22 @@ final class ListController extends Controller// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new AccountEnrichment();+ $admin = auth()->user();+ $enrichment = new AccountEnrichment();$enrichment->setDate($this->parameters->get('date'));$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));$enrichment->setUser($admin);- $accounts = $enrichment->enrich($accounts);+ $accounts = $enrichment->enrich($accounts);// make paginator:- $paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.currencies.accounts', [$currency->code]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.currencies.accounts', [$currency->code]).$this->buildParams());/** @var AccountTransformer $transformer */- $transformer = app(AccountTransformer::class);+ $transformer = app(AccountTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($accounts, $transformer, 'accounts');+ $resource = new FractalCollection($accounts, $transformer, 'accounts');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -134,26 +134,26 @@ final class ListController extends Controller*/public function availableBudgets(TransactionCurrency $currency): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of available budgets. Count it and split it./** @var AvailableBudgetRepositoryInterface $abRepository */- $abRepository = app(AvailableBudgetRepositoryInterface::class);+ $abRepository = app(AvailableBudgetRepositoryInterface::class);$collection = $abRepository->getAvailableBudgetsByCurrency($currency);$count = $collection->count();$availableBudgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($availableBudgets, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.currencies.available-budgets', [$currency->code]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($availableBudgets, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.currencies.available-budgets', [$currency->code]).$this->buildParams());/** @var AvailableBudgetTransformer $transformer */- $transformer = app(AvailableBudgetTransformer::class);+ $transformer = app(AvailableBudgetTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');+ $resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -167,36 +167,36 @@ final class ListController extends Controller*/public function bills(TransactionCurrency $currency): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();/** @var BillRepositoryInterface $billRepos */- $billRepos = app(BillRepositoryInterface::class);- $pageSize = $this->parameters->get('limit');- $unfiltered = $billRepos->getBills();+ $billRepos = app(BillRepositoryInterface::class);+ $pageSize = $this->parameters->get('limit');+ $unfiltered = $billRepos->getBills();// filter and paginate list:- $collection = $unfiltered->filter(static fn(Bill $bill): bool => $bill->transaction_currency_id === $currency->id);- $count = $collection->count();- $bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $unfiltered->filter(static fn (Bill $bill): bool => $bill->transaction_currency_id === $currency->id);+ $count = $collection->count();+ $bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new SubscriptionEnrichment();+ $admin = auth()->user();+ $enrichment = new SubscriptionEnrichment();$enrichment->setUser($admin);$enrichment->setStart($this->parameters->get('start'));$enrichment->setEnd($this->parameters->get('end'));- $bills = $enrichment->enrich($bills);+ $bills = $enrichment->enrich($bills);// make paginator:- $paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.currencies.bills', [$currency->code]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.currencies.bills', [$currency->code]).$this->buildParams());/** @var BillTransformer $transformer */$transformer = app(BillTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($bills, $transformer, 'bills');+ $resource = new FractalCollection($bills, $transformer, 'bills');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -219,20 +219,20 @@ final class ListController extends Controller$count = $collection->count();$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.currencies.budget-limits', [$currency->code]) . $this->buildParams());+ $paginator->setPath(route('api.v1.currencies.budget-limits', [$currency->code]).$this->buildParams());// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new BudgetLimitEnrichment();+ $admin = auth()->user();+ $enrichment = new BudgetLimitEnrichment();$enrichment->setUser($admin);$budgetLimits = $enrichment->enrich($budgetLimits);/** @var BudgetLimitTransformer $transformer */- $transformer = app(BudgetLimitTransformer::class);+ $transformer = app(BudgetLimitTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');+ $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -246,9 +246,9 @@ final class ListController extends Controller*/public function recurrences(TransactionCurrency $currency): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();// types to get, page size:- $pageSize = $this->parameters->get('limit');+ $pageSize = $this->parameters->get('limit');// get list of budgets. Count it and split it./** @var RecurringRepositoryInterface $recurringRepos */@@ -256,35 +256,35 @@ final class ListController extends Controller$unfiltered = $recurringRepos->get();// filter selection- $collection = $unfiltered->filter(static function (Recurrence $recurrence) use ($currency): ?Recurrence {+ $collection = $unfiltered->filter(static function (Recurrence $recurrence) use ($currency): ?Recurrence {if (array_any($recurrence->recurrenceTransactions,- static fn($transaction): bool => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id+ static fn ($transaction): bool => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id)) {return $recurrence;}return null;});- $count = $collection->count();- $recurrences = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $count = $collection->count();+ $recurrences = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new RecurringEnrichment();+ $admin = auth()->user();+ $enrichment = new RecurringEnrichment();$enrichment->setUser($admin);- $recurrences = $enrichment->enrich($recurrences);+ $recurrences = $enrichment->enrich($recurrences);// make paginator:- $paginator = new LengthAwarePaginator($recurrences, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.currencies.recurrences', [$currency->code]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($recurrences, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.currencies.recurrences', [$currency->code]).$this->buildParams());/** @var RecurrenceTransformer $transformer */- $transformer = app(RecurrenceTransformer::class);+ $transformer = app(RecurrenceTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($recurrences, $transformer, 'recurrences');+ $resource = new FractalCollection($recurrences, $transformer, 'recurrences');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -298,18 +298,18 @@ final class ListController extends Controller*/public function rules(TransactionCurrency $currency): JsonResponse{- $manager = $this->getManager();- $pageSize = $this->parameters->get('limit');+ $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');// get list of budgets. Count it and split it./** @var RuleRepositoryInterface $ruleRepos */- $ruleRepos = app(RuleRepositoryInterface::class);- $unfiltered = $ruleRepos->getAll();+ $ruleRepos = app(RuleRepositoryInterface::class);+ $unfiltered = $ruleRepos->getAll();- $collection = $unfiltered->filter(static function (Rule $rule) use ($currency): ?Rule {+ $collection = $unfiltered->filter(static function (Rule $rule) use ($currency): ?Rule {if (array_any($rule->ruleTriggers,- static fn($trigger): bool => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value+ static fn ($trigger): bool => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value)) {return $rule;}@@ -317,18 +317,18 @@ final class ListController extends Controllerreturn null;});- $count = $collection->count();- $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $count = $collection->count();+ $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.rules.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.rules.index').$this->buildParams());/** @var RuleTransformer $transformer */$transformer = app(RuleTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($rules, $transformer, 'rules');+ $resource = new FractalCollection($rules, $transformer, 'rules');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -342,19 +342,19 @@ final class ListController extends Controller*/public function transactions(Request $request, TransactionCurrency $currency): JsonResponse{- $pageSize = $this->parameters->get('limit');- $type = $request->input('type') ?? 'default';+ $pageSize = $this->parameters->get('limit');+ $type = $request->input('type') ?? 'default';$this->parameters->set('type', $type);- $types = $this->mapTransactionTypes($this->parameters->get('type'));- $manager = $this->getManager();+ $types = $this->mapTransactionTypes($this->parameters->get('type'));+ $manager = $this->getManager();/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);$collector->setUser($admin)// filter on currency.@@ -366,26 +366,27 @@ final class ListController extends Controller// set page to retrieve->setPage($this->parameters->get('page'))// set types of transactions to return.- ->setTypes($types);+ ->setTypes($types)+ ;if (null !== $this->parameters->get('start')) {$collector->setStart($this->parameters->get('start'));}if (null !== $this->parameters->get('end')) {$collector->setEnd($this->parameters->get('end'));}- $paginator = $collector->getPaginatedGroups();- $paginator->setPath(route('api.v1.currencies.transactions', [$currency->code]) . $this->buildParams());+ $paginator = $collector->getPaginatedGroups();+ $paginator->setPath(route('api.v1.currencies.transactions', [$currency->code]).$this->buildParams());// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);$transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$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/ShowController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/ShowController.phpindex c10302b8a9..a643398767 100644--- a/app/Api/V1/Controllers/Models/TransactionCurrency/ShowController.php+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/ShowController.php@@ -69,21 +69,21 @@ final class ShowController extends Controller*/public function index(): JsonResponse{- $pageSize = $this->parameters->get('limit');- $collection = $this->repository->getAll();- $count = $collection->count();+ $pageSize = $this->parameters->get('limit');+ $collection = $this->repository->getAll();+ $count = $collection->count();// slice them:- $currencies = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);- $paginator = new LengthAwarePaginator($currencies, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.currencies.index') . $this->buildParams());- $manager = $this->getManager();+ $currencies = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $paginator = new LengthAwarePaginator($currencies, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.currencies.index').$this->buildParams());+ $manager = $this->getManager();/** @var CurrencyTransformer $transformer */$transformer = app(CurrencyTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($currencies, $transformer, 'currencies');+ $resource = new FractalCollection($currencies, $transformer, 'currencies');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -98,8 +98,8 @@ final class ShowController extends Controllerpublic function show(TransactionCurrency $currency): JsonResponse{/** @var User $user */- $user = auth()->user();- $manager = $this->getManager();+ $user = auth()->user();+ $manager = $this->getManager();$this->parameters->set('primaryCurrency', $this->primaryCurrency);// update fields with user info.@@ -109,7 +109,7 @@ final class ShowController extends Controller$transformer = app(CurrencyTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($currency, $transformer, 'currencies');+ $resource = new Item($currency, $transformer, 'currencies');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}@@ -120,9 +120,9 @@ final class ShowController extends Controllerpublic function showPrimary(): JsonResponse{/** @var User $user */- $user = auth()->user();- $manager = $this->getManager();- $currency = $this->primaryCurrency;+ $user = auth()->user();+ $manager = $this->getManager();+ $currency = $this->primaryCurrency;// update fields with user info.$currency->refreshForUser($user);@@ -131,7 +131,7 @@ final class ShowController extends Controller$transformer = app(CurrencyTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($currency, $transformer, 'currencies');+ $resource = new Item($currency, $transformer, 'currencies');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.phpindex 61c5fdb693..a970467c6f 100644--- a/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.php+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.php@@ -67,22 +67,22 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $currency = $this->repository->store($request->getAll());+ $currency = $this->repository->store($request->getAll());if (true === $request->boolean('default')) {$this->repository->makePrimary($currency);Preferences::mark();}- $manager = $this->getManager();+ $manager = $this->getManager();/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$currency->refreshForUser($user);/** @var CurrencyTransformer $transformer */$transformer = app(CurrencyTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($currency, $transformer, 'currencies');+ $resource = new Item($currency, $transformer, 'currencies');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.phpindex ae4ebdefdb..2ef137b8d3 100644--- a/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php@@ -81,9 +81,9 @@ final class UpdateController extends Controller}/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository->disable($currency);- $manager = $this->getManager();+ $manager = $this->getManager();$currency->refreshForUser($user);@@ -91,7 +91,7 @@ final class UpdateController extends Controller$transformer = app(CurrencyTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($currency, $transformer, 'currencies');+ $resource = new Item($currency, $transformer, 'currencies');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}@@ -105,10 +105,10 @@ final class UpdateController extends Controllerpublic function enable(TransactionCurrency $currency): JsonResponse{$this->repository->enable($currency);- $manager = $this->getManager();+ $manager = $this->getManager();/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$currency->refreshForUser($user);@@ -116,7 +116,7 @@ final class UpdateController extends Controller$transformer = app(CurrencyTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($currency, $transformer, 'currencies');+ $resource = new Item($currency, $transformer, 'currencies');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}@@ -124,20 +124,20 @@ final class UpdateController extends Controllerpublic function makePrimary(TransactionCurrency $currency): JsonResponse{/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository->enable($currency);$this->repository->makePrimary($currency);Preferences::mark();- $manager = $this->getManager();+ $manager = $this->getManager();$currency->refreshForUser($user);/** @var CurrencyTransformer $transformer */$transformer = app(CurrencyTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($currency, $transformer, 'currencies');+ $resource = new Item($currency, $transformer, 'currencies');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}@@ -152,13 +152,13 @@ final class UpdateController extends Controller*/public function update(UpdateRequest $request, TransactionCurrency $currency): JsonResponse{- $data = $request->getAll();+ $data = $request->getAll();/** @var User $user */- $user = auth()->user();+ $user = auth()->user();// safety catch on currency disablement.- $set = $this->repository->get();+ $set = $this->repository->get();if (array_key_exists('enabled', $data) && false === $data['enabled'] && 1 === count($set) && $set->first()->id === $currency->id) {return response()->json([], 409);}@@ -167,17 +167,17 @@ final class UpdateController extends Controllerreturn response()->json([], 409);}- $currency = $this->repository->update($currency, $data);+ $currency = $this->repository->update($currency, $data);Preferences::mark();- $manager = $this->getManager();+ $manager = $this->getManager();$currency->refreshForUser($user);/** @var CurrencyTransformer $transformer */$transformer = app(CurrencyTransformer::class);- $resource = new Item($currency, $transformer, 'currencies');+ $resource = new Item($currency, $transformer, 'currencies');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.php b/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.phpindex e7f4c8315e..8b4417b983 100644--- a/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.php+++ b/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.php@@ -46,7 +46,7 @@ final class DestroyController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(LinkTypeRepositoryInterface::class);diff --git a/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php b/app/Api/V1/Controllers/Models/TransactionLink/ShowController.phpindex 941e97c676..1d2fdafb25 100644--- a/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php+++ b/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php@@ -51,7 +51,7 @@ final class ShowController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(LinkTypeRepositoryInterface::class);@@ -70,13 +70,13 @@ final class ShowController extends Controllerpublic function index(Request $request): JsonResponse{// create some objects:- $manager = $this->getManager();+ $manager = $this->getManager();// read type from URL- $name = $request->input('name');+ $name = $request->input('name');// types to get, page size:- $pageSize = $this->parameters->get('limit');- $linkType = $this->repository->findByName($name);+ $pageSize = $this->parameters->get('limit');+ $linkType = $this->repository->findByName($name);// get list of transaction links. Count it and split it.$collection = $this->repository->getJournalLinks($linkType);@@ -84,14 +84,14 @@ final class ShowController extends Controller$journalLinks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($journalLinks, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.transaction-links.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($journalLinks, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.transaction-links.index').$this->buildParams());/** @var TransactionLinkTransformer $transformer */- $transformer = app(TransactionLinkTransformer::class);+ $transformer = app(TransactionLinkTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($journalLinks, $transformer, 'transaction_links');+ $resource = new FractalCollection($journalLinks, $transformer, 'transaction_links');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -105,13 +105,13 @@ final class ShowController extends Controller*/public function show(TransactionJournalLink $journalLink): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();/** @var TransactionLinkTransformer $transformer */$transformer = app(TransactionLinkTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($journalLink, $transformer, 'transaction_links');+ $resource = new Item($journalLink, $transformer, 'transaction_links');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php b/app/Api/V1/Controllers/Models/TransactionLink/StoreController.phpindex 8244a53a7d..5da90bbd04 100644--- a/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php+++ b/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php@@ -43,7 +43,7 @@ final class StoreController extends Controller{use TransactionFilter;- private JournalRepositoryInterface $journalRepository;+ private JournalRepositoryInterface $journalRepository;private LinkTypeRepositoryInterface $repository;/**@@ -54,7 +54,7 @@ final class StoreController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(LinkTypeRepositoryInterface::class);$this->journalRepository = app(JournalRepositoryInterface::class);@@ -76,22 +76,22 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $manager = $this->getManager();- $data = $request->getAll();- $inward = $this->journalRepository->find($data['inward_id'] ?? 0);- $outward = $this->journalRepository->find($data['outward_id'] ?? 0);+ $manager = $this->getManager();+ $data = $request->getAll();+ $inward = $this->journalRepository->find($data['inward_id'] ?? 0);+ $outward = $this->journalRepository->find($data['outward_id'] ?? 0);if (!$inward instanceof TransactionJournal || !$outward instanceof TransactionJournal) {throw new FireflyException('200024: Source or destination does not exist.');}$data['direction'] = 'inward';- $journalLink = $this->repository->storeLink($data, $inward, $outward);+ $journalLink = $this->repository->storeLink($data, $inward, $outward);/** @var TransactionLinkTransformer $transformer */- $transformer = app(TransactionLinkTransformer::class);+ $transformer = app(TransactionLinkTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($journalLink, $transformer, 'transaction_links');+ $resource = new Item($journalLink, $transformer, 'transaction_links');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.phpindex 51f42251a4..351c79c8c8 100644--- a/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php+++ b/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php@@ -39,7 +39,7 @@ use League\Fractal\Resource\Item;*/final class UpdateController extends Controller{- private JournalRepositoryInterface $journalRepository;+ private JournalRepositoryInterface $journalRepository;private LinkTypeRepositoryInterface $repository;/**@@ -50,7 +50,7 @@ final class UpdateController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $user */- $user = auth()->user();+ $user = auth()->user();$this->repository = app(LinkTypeRepositoryInterface::class);$this->journalRepository = app(JournalRepositoryInterface::class);@@ -78,7 +78,7 @@ final class UpdateController extends Controller$transformer = app(TransactionLinkTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($journalLink, $transformer, 'transaction_links');+ $resource = new Item($journalLink, $transformer, 'transaction_links');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.phpindex 9a08834c5e..93809f73bb 100644--- a/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.php+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.php@@ -68,22 +68,22 @@ final class ListController extends Controller*/public function transactions(Request $request, LinkType $linkType): JsonResponse{- $pageSize = $this->parameters->get('limit');- $type = $request->input('type') ?? 'default';+ $pageSize = $this->parameters->get('limit');+ $type = $request->input('type') ?? 'default';$this->parameters->set('type', $type);- $types = $this->mapTransactionTypes($this->parameters->get('type'));- $manager = $this->getManager();+ $types = $this->mapTransactionTypes($this->parameters->get('type'));+ $manager = $this->getManager();// whatever is returned by the query, it must be part of these journals:- $journalIds = $this->repository->getJournalIds($linkType);+ $journalIds = $this->repository->getJournalIds($linkType);/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();// use new group collector:/** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);+ $collector = app(GroupCollectorInterface::class);if (0 === count($journalIds)) {$collector->findNothing();}@@ -98,26 +98,27 @@ final class ListController extends Controller// set page to retrieve->setPage($this->parameters->get('page'))// set types of transactions to return.- ->setTypes($types);+ ->setTypes($types)+ ;if (null !== $this->parameters->get('start')) {$collector->setStart($this->parameters->get('start'));}if (null !== $this->parameters->get('end')) {$collector->setEnd($this->parameters->get('end'));}- $paginator = $collector->getPaginatedGroups();- $paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());+ $paginator = $collector->getPaginatedGroups();+ $paginator->setPath(route('api.v1.transactions.index').$this->buildParams());// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser($admin);$transactions = $enrichment->enrich($paginator->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($transactions, $transformer, 'transactions');+ $resource = new FractalCollection($transactions, $transformer, 'transactions');$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/TransactionLinkType/ShowController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/ShowController.phpindex 073362ee0a..e3ac05e86c 100644--- a/app/Api/V1/Controllers/Models/TransactionLinkType/ShowController.php+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/ShowController.php@@ -68,23 +68,23 @@ final class ShowController extends Controllerpublic function index(): JsonResponse{// create some objects:- $manager = $this->getManager();- $pageSize = $this->parameters->get('limit');+ $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');// get list of accounts. Count it and split it.- $collection = $this->repository->get();- $count = $collection->count();- $linkTypes = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->repository->get();+ $count = $collection->count();+ $linkTypes = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($linkTypes, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.link-types.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($linkTypes, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.link-types.index').$this->buildParams());/** @var LinkTypeTransformer $transformer */$transformer = app(LinkTypeTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($linkTypes, $transformer, 'link_types');+ $resource = new FractalCollection($linkTypes, $transformer, 'link_types');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -98,13 +98,13 @@ final class ShowController extends Controller*/public function show(LinkType $linkType): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();/** @var LinkTypeTransformer $transformer */$transformer = app(LinkTypeTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($linkType, $transformer, 'link_types');+ $resource = new Item($linkType, $transformer, 'link_types');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.phpindex c582c58198..ab3c84a44b 100644--- a/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php@@ -69,15 +69,15 @@ final class StoreController extends Controller*/public function store(StoreRequest $request): JsonResponse{- $data = $request->getAll();+ $data = $request->getAll();// if currency ID is 0, find the currency by the code:- $linkType = $this->repository->store($data);- $manager = $this->getManager();+ $linkType = $this->repository->store($data);+ $manager = $this->getManager();/** @var LinkTypeTransformer $transformer */$transformer = app(LinkTypeTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($linkType, $transformer, 'link_types');+ $resource = new Item($linkType, $transformer, 'link_types');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.phpindex 54f47c6bad..13efa8f99d 100644--- a/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php@@ -76,15 +76,15 @@ final class UpdateController extends Controllerthrow new FireflyException('200020: Link type cannot be changed.');}- $data = $request->getAll();+ $data = $request->getAll();$this->repository->update($linkType, $data);- $manager = $this->getManager();+ $manager = $this->getManager();/** @var LinkTypeTransformer $transformer */$transformer = app(LinkTypeTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($linkType, $transformer, 'link_types');+ $resource = new Item($linkType, $transformer, 'link_types');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/UserGroup/IndexController.php b/app/Api/V1/Controllers/Models/UserGroup/IndexController.phpindex a4b44a3af6..54a9fd266e 100644--- a/app/Api/V1/Controllers/Models/UserGroup/IndexController.php+++ b/app/Api/V1/Controllers/Models/UserGroup/IndexController.php@@ -52,12 +52,12 @@ final class IndexController extends Controllerpublic function index(PaginationRequest $request): JsonResponse{- $administrations = $this->repository->get();+ $administrations = $this->repository->get();['page' => $page, 'limit' => $limit, 'offset' => $offset] = $request->attributes->all();- $count = $administrations->count();- $administrations = $administrations->slice($offset, $limit);- $paginator = new LengthAwarePaginator($administrations, $count, $limit, $page);- $transformer = new UserGroupTransformer();+ $count = $administrations->count();+ $administrations = $administrations->slice($offset, $limit);+ $paginator = new LengthAwarePaginator($administrations, $count, $limit, $page);+ $transformer = new UserGroupTransformer();return response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Models/UserGroup/UpdateController.php b/app/Api/V1/Controllers/Models/UserGroup/UpdateController.phpindex 0edd420223..95479cda5a 100644--- a/app/Api/V1/Controllers/Models/UserGroup/UpdateController.php+++ b/app/Api/V1/Controllers/Models/UserGroup/UpdateController.php@@ -55,8 +55,8 @@ final class UpdateController extends Controllerpublic function update(UpdateRequest $request, UserGroup $userGroup): JsonResponse{Log::debug(sprintf('Now in %s', __METHOD__));- $data = $request->getData();- $userGroup = $this->repository->update($userGroup, $data);+ $data = $request->getData();+ $userGroup = $this->repository->update($userGroup, $data);$userGroup->refresh();Preferences::mark();diff --git a/app/Api/V1/Controllers/Search/AccountController.php b/app/Api/V1/Controllers/Search/AccountController.phpindex 58c9f7c5b0..a3b1370b90 100644--- a/app/Api/V1/Controllers/Search/AccountController.php+++ b/app/Api/V1/Controllers/Search/AccountController.php@@ -45,56 +45,55 @@ final class AccountController extends Controller{use AccountFilter;- private array $validFields- = [- AccountSearch::SEARCH_ALL,- AccountSearch::SEARCH_ID,- AccountSearch::SEARCH_NAME,- AccountSearch::SEARCH_IBAN,- AccountSearch::SEARCH_NUMBER,- ];+ private array $validFields = [+ AccountSearch::SEARCH_ALL,+ AccountSearch::SEARCH_ID,+ AccountSearch::SEARCH_NAME,+ AccountSearch::SEARCH_IBAN,+ AccountSearch::SEARCH_NUMBER,+ ];/*** This endpoint is documented at:* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/search/searchAccounts*/- public function search(Request $request): JsonResponse | Response+ public function search(Request $request): JsonResponse|Response{- $manager = $this->getManager();- $query = trim((string)$request->input('query'));- $field = trim((string)$request->input('field'));- $type = $request->input('type') ?? 'all';+ $manager = $this->getManager();+ $query = trim((string) $request->input('query'));+ $field = trim((string) $request->input('field'));+ $type = $request->input('type') ?? 'all';if ('' === $query || !in_array($field, $this->validFields, strict: true)) {return response(null, 422);}Log::debug(sprintf('Now in account search("%s", "%s")', $field, $query));- $types = $this->mapAccountTypes($type);+ $types = $this->mapAccountTypes($type);/** @var AccountSearch $search */- $search = app(AccountSearch::class);+ $search = app(AccountSearch::class);$search->setUser(auth()->user());$search->setTypes($types);$search->setField($field);$search->setQuery($query);- $accounts = $search->search();+ $accounts = $search->search();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new AccountEnrichment();+ $admin = auth()->user();+ $enrichment = new AccountEnrichment();$enrichment->setDate($this->parameters->get('date'));$enrichment->setUser($admin);- $accounts = $enrichment->enrich($accounts);+ $accounts = $enrichment->enrich($accounts);/** @var AccountTransformer $transformer */$transformer = app(AccountTransformer::class);$transformer->setParameters($this->parameters);- $count = $accounts->count();- $perPage = 0 === $count ? 1 : $count;- $paginator = new LengthAwarePaginator($accounts, $count, $perPage, 1);+ $count = $accounts->count();+ $perPage = 0 === $count ? 1 : $count;+ $paginator = new LengthAwarePaginator($accounts, $count, $perPage, 1);- $resource = new FractalCollection($accounts, $transformer, 'accounts');+ $resource = new FractalCollection($accounts, $transformer, 'accounts');$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/Search/TransactionController.php b/app/Api/V1/Controllers/Search/TransactionController.phpindex 197fd2f2bd..5ac75b84cd 100644--- a/app/Api/V1/Controllers/Search/TransactionController.php+++ b/app/Api/V1/Controllers/Search/TransactionController.php@@ -49,7 +49,7 @@ final class TransactionController extends Controllerparent::__construct();$this->middleware(function ($request, $next) {/** @var User $admin */- $admin = auth()->user();+ $admin = auth()->user();$this->repository = app(JournalRepositoryInterface::class);$this->repository->setUser($admin);@@ -62,10 +62,10 @@ final class TransactionController extends Controller{$count = 0;$includeDeleted = $request->attributes->get('include_deleted', false);- $externalId = (string)$request->attributes->get('external_identifier');- $internalRef = (string)$request->attributes->get('internal_reference');- $notes = (string)$request->attributes->get('notes');- $description = (string)$request->attributes->get('description');+ $externalId = (string) $request->attributes->get('external_identifier');+ $internalRef = (string) $request->attributes->get('internal_reference');+ $notes = (string) $request->attributes->get('notes');+ $description = (string) $request->attributes->get('description');Log::debug(sprintf('Include deleted? %s', var_export(value: $includeDeleted, return: true)));if ('' !== $externalId) {$count += $this->repository->countByMeta('external_id', $externalId, $includeDeleted);@@ -93,31 +93,31 @@ final class TransactionController extends Controller*/public function search(TransactionSearchRequest $request, SearchInterface $searcher): JsonResponse{- $manager = $this->getManager();- $fullQuery = (string)$request->attributes->get('query');- $page = $request->attributes->get('page');- $pageSize = $request->attributes->get('limit');+ $manager = $this->getManager();+ $fullQuery = (string) $request->attributes->get('query');+ $page = $request->attributes->get('page');+ $pageSize = $request->attributes->get('limit');$searcher->parseQuery($fullQuery);$searcher->setPage($page);$searcher->setLimit($pageSize);- $groups = $searcher->searchTransactions();- $parameters = ['search' => $fullQuery];- $url = route('api.v1.search.transactions') . '?' . http_build_query($parameters);+ $groups = $searcher->searchTransactions();+ $parameters = ['search' => $fullQuery];+ $url = route('api.v1.search.transactions').'?'.http_build_query($parameters);$groups->setPath($url);// enrich- $enrichment = new TransactionGroupEnrichment();+ $enrichment = new TransactionGroupEnrichment();$enrichment->setUser(auth()->user());$transactions = $enrichment->enrich($groups->getCollection());/** @var TransactionGroupTransformer $transformer */- $transformer = app(TransactionGroupTransformer::class);+ $transformer = app(TransactionGroupTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Collection($transactions, $transformer, 'transactions');+ $resource = new Collection($transactions, $transformer, 'transactions');$resource->setPaginator(new IlluminatePaginatorAdapter($groups));- $array = $manager->createData($resource)->toArray();+ $array = $manager->createData($resource)->toArray();return response()->json($array)->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.phpindex ba0a1cf2e9..a557f35188 100644--- a/app/Api/V1/Controllers/Summary/BasicController.php+++ b/app/Api/V1/Controllers/Summary/BasicController.php@@ -53,11 +53,11 @@ use Illuminate\Support\Facades\Log;final class BasicController extends Controller{private AvailableBudgetRepositoryInterface $abRepository;- private AccountRepositoryInterface $accountRepository;- private BillRepositoryInterface $billRepository;- private BudgetRepositoryInterface $budgetRepository;- private CurrencyRepositoryInterface $currencyRepos;- private OperationsRepositoryInterface $opsRepository;+ private AccountRepositoryInterface $accountRepository;+ private BillRepositoryInterface $billRepository;+ private BudgetRepositoryInterface $budgetRepository;+ private CurrencyRepositoryInterface $currencyRepos;+ private OperationsRepositoryInterface $opsRepository;/*** BasicController constructor.@@ -92,18 +92,18 @@ final class BasicController extends Controller// parameters for boxes:['start' => $start, 'end' => $end, 'code' => $code] = $request->attributes->all();// balance information:- $balanceData = $this->getBalanceInformation($start, $end);- $billData = $this->getSubscriptionInformation($start, $end);- $spentData = $this->getLeftToSpendInfo($start, $end);- $netWorthData = $this->getNetWorthInfo($end);+ $balanceData = $this->getBalanceInformation($start, $end);+ $billData = $this->getSubscriptionInformation($start, $end);+ $spentData = $this->getLeftToSpendInfo($start, $end);+ $netWorthData = $this->getNetWorthInfo($end);// $balanceData = [];// $billData = [];// $spentData = [];// $netWorthData = [];- $total = array_merge($balanceData, $billData, $spentData, $netWorthData);+ $total = array_merge($balanceData, $billData, $spentData, $netWorthData);// give new keys- $return = [];+ $return = [];foreach ($total as $entry) {if ('' === $code || $code === $entry['currency_code']) {$return[$entry['key']] = $entry;@@ -120,27 +120,28 @@ final class BasicController extends Controller$convertToPrimary = Amount::convertToPrimary();$primary = Amount::getPrimaryCurrency();// prep some arrays:- $sums = [];- $return = [];- $currencies = [$primary->id => $primary];+ $sums = [];+ $return = [];+ $currencies = [$primary->id => $primary];// collect income of user using the new group collector./** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);- $summarizer = new TransactionSummarizer();- $set = $collector->setRange($start, $end)->setTypes([TransactionTypeEnum::DEPOSIT->value])->getExtractedJournals();- $incomes = $summarizer->groupByCurrencyId($set, 'positive', false);+ $collector = app(GroupCollectorInterface::class);+ $summarizer = new TransactionSummarizer();+ $set = $collector->setRange($start, $end)->setTypes([TransactionTypeEnum::DEPOSIT->value])->getExtractedJournals();+ $incomes = $summarizer->groupByCurrencyId($set, 'positive', false);// collect expenses of user.// collect expenses of user using the new group collector./** @var GroupCollectorInterface $collector */- $collector = app(GroupCollectorInterface::class);- $set = $collector+ $collector = app(GroupCollectorInterface::class);+ $set = $collector->setRange($start, $end)->setPage($this->parameters->get('page'))->setTypes([TransactionTypeEnum::WITHDRAWAL->value])- ->getExtractedJournals();- $expenses = $summarizer->groupByCurrencyId($set, 'negative', false);+ ->getExtractedJournals()+ ;+ $expenses = $summarizer->groupByCurrencyId($set, 'negative', false);// if convert to primary, do so right now.if ($convertToPrimary) {@@ -172,29 +173,29 @@ final class BasicController extends Controller],];- $converter = new ExchangeRateConverter();+ $converter = new ExchangeRateConverter();// loop over income and expensesforeach ([$expenses, $incomes] as $index => $array) {// loop over either one.foreach ($array as $entry) {// if it is the primary currency already.if ($entry['currency_id'] === $primary->id) {- $sums[$primary->id]['sum'] = bcadd((string)$entry['sum'], $sums[$primary->id]['sum']);+ $sums[$primary->id]['sum'] = bcadd((string) $entry['sum'], $sums[$primary->id]['sum']);// don't forget to add it to newExpenses and newIncomeif (0 === $index) {- $newExpenses[$primary->id]['sum'] = bcadd($newExpenses[$primary->id]['sum'], (string)$entry['sum']);+ $newExpenses[$primary->id]['sum'] = bcadd($newExpenses[$primary->id]['sum'], (string) $entry['sum']);}if (1 === $index) {- $newIncomes[$primary->id]['sum'] = bcadd($newIncomes[$primary->id]['sum'], (string)$entry['sum']);+ $newIncomes[$primary->id]['sum'] = bcadd($newIncomes[$primary->id]['sum'], (string) $entry['sum']);}continue;}$currencies[$entry['currency_id']] ??= $this->currencyRepos->find($entry['currency_id']);- $convertedSum = $converter->convert($currencies[$entry['currency_id']], $primary, $start, $entry['sum']);- $sums[$primary->id]['sum'] = bcadd($sums[$primary->id]['sum'], $convertedSum);+ $convertedSum = $converter->convert($currencies[$entry['currency_id']], $primary, $start, $entry['sum']);+ $sums[$primary->id]['sum'] = bcadd($sums[$primary->id]['sum'], $convertedSum);if (0 === $index) {$newExpenses[$primary->id]['sum'] = bcadd($newExpenses[$primary->id]['sum'], $convertedSum);}@@ -203,26 +204,26 @@ final class BasicController extends Controller}}}- $incomes = $newIncomes;- $expenses = $newExpenses;+ $incomes = $newIncomes;+ $expenses = $newExpenses;}if (!$convertToPrimary) {foreach ([$expenses, $incomes] as $array) {foreach ($array as $entry) {$currencyId = $entry['currency_id'];- $sums[$currencyId] ??= [+ $sums[$currencyId] ??= ['currency_id' => $entry['currency_id'],'currency_code' => $entry['currency_code'],'currency_symbol' => $entry['currency_symbol'],'currency_decimal_places' => $entry['currency_decimal_places'],'sum' => '0',];- $sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], (string)$entry['sum']);+ $sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], (string) $entry['sum']);}}}// format amounts:- $keys = array_keys($sums);+ $keys = array_keys($sums);foreach ($keys as $currencyId) {$currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId);if (null === $currency) {@@ -233,21 +234,21 @@ final 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]['sum'] ?? '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,'value_parsed' => Amount::formatAnything($currency, $sums[$currencyId]['sum'] ?? '0', false),'local_icon' => 'balance-scale','sub_title' => Amount::formatAnything($currency, $expenses[$currencyId]['sum'] ?? '0', false)- . ' + '- . Amount::formatAnything($currency, $incomes[$currencyId]['sum'] ?? '0', false),+ .' + '+ .Amount::formatAnything($currency, $incomes[$currencyId]['sum'] ?? '0', false),];$return[] = ['key' => sprintf('spent-in-%s', $currency->code),'title' => trans('firefly.box_spent_in_currency', ['currency' => $currency->symbol]),'monetary_value' => $expenses[$currencyId]['sum'] ?? '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,@@ -259,7 +260,7 @@ final 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]['sum'] ?? '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,@@ -275,19 +276,19 @@ final class BasicController extends Controller'key' => sprintf('balance-in-%s', $currency->code),'title' => trans('firefly.box_balance_in_currency', ['currency' => $currency->symbol]),'monetary_value' => '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,'value_parsed' => Amount::formatAnything($currency, '0', false),'local_icon' => 'balance-scale',- 'sub_title' => Amount::formatAnything($currency, '0', false) . ' + ' . Amount::formatAnything($currency, '0', false),+ 'sub_title' => Amount::formatAnything($currency, '0', false).' + '.Amount::formatAnything($currency, '0', false),];$return[] = ['key' => sprintf('spent-in-%s', $currency->code),'title' => trans('firefly.box_spent_in_currency', ['currency' => $currency->symbol]),'monetary_value' => '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,@@ -299,7 +300,7 @@ final class BasicController extends Controller'key' => sprintf('earned-in-%s', $currency->code),'title' => trans('firefly.box_earned_in_currency', ['currency' => $currency->symbol]),'monetary_value' => '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,@@ -323,19 +324,19 @@ final class BasicController extends Controller$available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end);$budgets = $this->budgetRepository->getActiveBudgets();$spent = $this->opsRepository->sumExpenses($start, $end, null, $budgets, null, true);- $days = (int)$today->diffInDays($end, true) + 1;+ $days = (int) $today->diffInDays($end, true) + 1;$currencies = [];// first, create an entry for each entry in the "available" array./** @var string $availableBudget */foreach ($available as $currencyId => $availableBudget) {$currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);- $return[$currencyId] = [+ $return[$currencyId] = ['key' => sprintf('left-to-spend-in-%s', $currencies[$currencyId]->code),'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $currencies[$currencyId]->symbol]),'no_available_budgets' => false,'monetary_value' => $availableBudget,- 'currency_id' => (string)$currencies[$currencyId]->id,+ 'currency_id' => (string) $currencies[$currencyId]->id,'currency_code' => $currencies[$currencyId]->code,'currency_symbol' => $currencies[$currencyId]->symbol,'currency_decimal_places' => $currencies[$currencyId]->decimal_places,@@ -349,24 +350,24 @@ final class BasicController extends Controller'sub_title' => Amount::formatFlat($currencies[$currencyId]->symbol,$currencies[$currencyId]->decimal_places,- bcdiv($availableBudget, (string)$days),+ bcdiv($availableBudget, (string) $days),false),];}foreach ($spent as $row) {// either an amount was budgeted or 0 is available.- $currencyId = (int)$row['currency_id'];- $amount = (string)($available[$currencyId] ?? '0');+ $currencyId = (int) $row['currency_id'];+ $amount = (string) ($available[$currencyId] ?? '0');if (0 === bccomp($amount, '0')) {// #9858 skip over currencies with no available budget.continue;}- $spentInCurrency = $row['sum'];- $leftToSpend = bcadd($amount, (string)$spentInCurrency);- $perDay = '0';+ $spentInCurrency = $row['sum'];+ $leftToSpend = bcadd($amount, (string) $spentInCurrency);+ $perDay = '0';if (0 !== $days && bccomp($leftToSpend, '0') > -1) {- $perDay = bcdiv($leftToSpend, (string)$days);+ $perDay = bcdiv($leftToSpend, (string) $days);}Log::debug(sprintf('Spent %s %s', $row['currency_code'], $row['sum']));@@ -376,7 +377,7 @@ final class BasicController extends Controller'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $row['currency_symbol']]),'no_available_budgets' => false,'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'],@@ -387,16 +388,16 @@ final class BasicController extends Controller}unset($leftToSpend);if (0 === count($return)) {- $days = (int)$start->diffInDays($end, true) + 1;+ $days = (int) $start->diffInDays($end, true) + 1;// a small trick to get every expense in this period, regardless of budget.$spent = $this->opsRepository->sumExpenses($start, $end, null, new Collection());foreach ($spent as $row) {// either an amount was budgeted or 0 is available.- $currencyId = (int)$row['currency_id'];- $spentInCurrency = $row['sum'];- $perDay = '0';- if (0 !== $days && -1 === bccomp((string)$spentInCurrency, '0')) {- $perDay = bcdiv((string)$spentInCurrency, (string)$days);+ $currencyId = (int) $row['currency_id'];+ $spentInCurrency = $row['sum'];+ $perDay = '0';+ if (0 !== $days && -1 === bccomp((string) $spentInCurrency, '0')) {+ $perDay = bcdiv((string) $spentInCurrency, (string) $days);}Log::debug(sprintf('Spent %s %s', $row['currency_code'], $row['sum']));@@ -406,7 +407,7 @@ final class BasicController extends Controller'title' => trans('firefly.spent'),'no_available_budgets' => true,'monetary_value' => $spentInCurrency,- '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'],@@ -446,35 +447,35 @@ final class BasicController extends Controllerprivate function getNetWorthInfo(Carbon $end): array{/** @var User $user */- $user = auth()->user();+ $user = auth()->user();Log::debug(sprintf('getNetWorthInfo up until "%s".', $end->format('Y-m-d H:i:s')));/** @var NetWorthInterface $netWorthHelper */$netWorthHelper = app(NetWorthInterface::class);$netWorthHelper->setUser($user);- $allAccounts = $this->accountRepository->getActiveAccountsByType([- AccountTypeEnum::ASSET->value,- AccountTypeEnum::DEFAULT->value,- AccountTypeEnum::LOAN->value,- AccountTypeEnum::MORTGAGE->value,- AccountTypeEnum::DEBT->value,- ]);+ $allAccounts = $this->accountRepository->getActiveAccountsByType([+ AccountTypeEnum::ASSET->value,+ AccountTypeEnum::DEFAULT->value,+ AccountTypeEnum::LOAN->value,+ AccountTypeEnum::MORTGAGE->value,+ AccountTypeEnum::DEBT->value,+ ]);// filter list on preference of being included.- $filtered = $allAccounts->filter(function (Account $account): bool {+ $filtered = $allAccounts->filter(function (Account $account): bool {$includeNetWorth = $this->accountRepository->getMetaValue($account, 'include_net_worth');return null === $includeNetWorth || '1' === $includeNetWorth;});- $netWorthSet = $netWorthHelper->byAccounts($filtered, $end);- $return = [];+ $netWorthSet = $netWorthHelper->byAccounts($filtered, $end);+ $return = [];foreach ($netWorthSet as $key => $data) {if ('pc' === $key) {continue;}- $amount = $data['balance'];- if (0 === bccomp((string)$amount, '0')) {+ $amount = $data['balance'];+ if (0 === bccomp((string) $amount, '0')) {continue;}// return stuff@@ -482,7 +483,7 @@ final 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'],@@ -496,7 +497,7 @@ final class BasicController extends Controller'key' => sprintf('net-worth-in-%s', $this->primaryCurrency->code),'title' => trans('firefly.box_net_worth_in_currency', ['currency' => $this->primaryCurrency->symbol]),'monetary_value' => '0',- 'currency_id' => (string)$this->primaryCurrency->id,+ 'currency_id' => (string) $this->primaryCurrency->id,'currency_code' => $this->primaryCurrency->code,'currency_symbol' => $this->primaryCurrency->symbol,'currency_decimal_places' => $this->primaryCurrency->decimal_places,@@ -523,31 +524,31 @@ final class BasicController extends Controller$currencies = [$this->primaryCurrency->id => $this->primaryCurrency];if ($this->convertToPrimary) {- $converter = new ExchangeRateConverter();- $newPaidAmount = [[- 'id' => $this->primaryCurrency->id,- 'name' => $this->primaryCurrency->name,- 'symbol' => $this->primaryCurrency->symbol,- 'code' => $this->primaryCurrency->code,- 'decimal_places' => $this->primaryCurrency->decimal_places,- 'sum' => '0',- ]];+ $converter = new ExchangeRateConverter();+ $newPaidAmount = [[+ 'id' => $this->primaryCurrency->id,+ 'name' => $this->primaryCurrency->name,+ 'symbol' => $this->primaryCurrency->symbol,+ 'code' => $this->primaryCurrency->code,+ 'decimal_places' => $this->primaryCurrency->decimal_places,+ 'sum' => '0',+ ]];$newUnpaidAmount = [[- 'id' => $this->primaryCurrency->id,- 'name' => $this->primaryCurrency->name,- 'symbol' => $this->primaryCurrency->symbol,- 'code' => $this->primaryCurrency->code,- 'decimal_places' => $this->primaryCurrency->decimal_places,- 'sum' => '0',- ]];+ 'id' => $this->primaryCurrency->id,+ 'name' => $this->primaryCurrency->name,+ 'symbol' => $this->primaryCurrency->symbol,+ 'code' => $this->primaryCurrency->code,+ 'decimal_places' => $this->primaryCurrency->decimal_places,+ 'sum' => '0',+ ]];foreach ([$paidAmount, $unpaidAmount] as $index => $array) {foreach ($array as $item) {- $currencyId = (int)$item['id'];+ $currencyId = (int) $item['id'];if (0 === $index) {// paid amountif ($currencyId === $this->primaryCurrency->id) {- $newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], (string)$item['sum']);+ $newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], (string) $item['sum']);continue;}@@ -559,35 +560,35 @@ final class BasicController extends Controller}// unpaid amountif ($currencyId === $this->primaryCurrency->id) {- $newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], (string)$item['sum']);+ $newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], (string) $item['sum']);continue;}- $currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);+ $currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);$convertedAmount = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $item['sum']);$newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], $convertedAmount);}}- $paidAmount = $newPaidAmount;- $unpaidAmount = $newUnpaidAmount;+ $paidAmount = $newPaidAmount;+ $unpaidAmount = $newUnpaidAmount;}// var_dump($paidAmount);// var_dump($unpaidAmount);// exit;- $return = [];+ $return = [];/*** @var array $info*/foreach ($paidAmount as $info) {- $amount = bcmul((string)$info['sum'], '-1');+ $amount = bcmul((string) $info['sum'], '-1');$return[] = ['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'],@@ -601,12 +602,12 @@ final class BasicController extends Controller* @var array $info*/foreach ($unpaidAmount as $info) {- $amount = bcmul((string)$info['sum'], '-1');+ $amount = bcmul((string) $info['sum'], '-1');$return[] = ['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'],@@ -625,7 +626,7 @@ final class BasicController extends Controller'key' => sprintf('bills-paid-in-%s', $currency->code),'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $currency->symbol]),'monetary_value' => '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,@@ -637,7 +638,7 @@ final class BasicController extends Controller'key' => sprintf('bills-unpaid-in-%s', $currency->code),'title' => trans('firefly.box_bill_unpaid_in_currency', ['currency' => $currency->symbol]),'monetary_value' => '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,diff --git a/app/Api/V1/Controllers/System/AboutController.php b/app/Api/V1/Controllers/System/AboutController.phpindex 25e06ca644..7157d9266d 100644--- a/app/Api/V1/Controllers/System/AboutController.php+++ b/app/Api/V1/Controllers/System/AboutController.php@@ -69,13 +69,13 @@ final class AboutController extends Controller*/public function user(): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();/** @var UserTransformer $transformer */$transformer = app(UserTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item(auth()->user(), $transformer, 'users');+ $resource = new Item(auth()->user(), $transformer, 'users');return response()->api($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/System/BatchController.php b/app/Api/V1/Controllers/System/BatchController.phpindex 96dd1ce1e2..a4172a7e1f 100644--- a/app/Api/V1/Controllers/System/BatchController.php+++ b/app/Api/V1/Controllers/System/BatchController.php@@ -54,7 +54,7 @@ final class BatchController extends Controllerpublic function finishBatch(Request $request): JsonResponse{Log::debug('Now in finishBatch.');- $journals = $this->repository->getUncompletedJournals();+ $journals = $this->repository->getUncompletedJournals();if (0 === count($journals)) {Log::debug('Counted zero journals, return.');@@ -63,8 +63,8 @@ final class BatchController extends ControllerLog::debug(sprintf('Counted %d journals.', count($journals)));/** @var null|TransactionJournal $first */- $first = $journals->first();- $group = $first?->transactionGroup;+ $first = $journals->first();+ $group = $first?->transactionGroup;if (null === $group) {Log::debug('First group is NULL.');diff --git a/app/Api/V1/Controllers/System/ConfigurationController.php b/app/Api/V1/Controllers/System/ConfigurationController.phpindex f5a981a3ce..ee8457fecd 100644--- a/app/Api/V1/Controllers/System/ConfigurationController.php+++ b/app/Api/V1/Controllers/System/ConfigurationController.php@@ -102,7 +102,7 @@ final class ConfigurationController extends Controller}// fallback- $data = [+ $data = ['title' => $configKey,'value' => config($shortKey),'editable' => false,@@ -159,9 +159,9 @@ final class ConfigurationController extends Controllerreturn ['is_demo_site' => $isDemoSite?->data,- 'permission_update_check' => null === $updateCheck ? null : (int)$updateCheck->data,+ 'permission_update_check' => null === $updateCheck ? null : (int) $updateCheck->data,'single_user_mode' => $singleUser?->data,- 'last_update_check' => null === $lastCheck ? null : (int)$lastCheck->data,+ 'last_update_check' => null === $lastCheck ? null : (int) $lastCheck->data,'enable_exchange_rates' => $enableExchangeRates?->data,'use_running_balance' => $useRunningBalance?->data,'enable_external_map' => $enableExternalMap?->data,diff --git a/app/Api/V1/Controllers/System/CronController.php b/app/Api/V1/Controllers/System/CronController.phpindex a095b222d1..fc54231269 100644--- a/app/Api/V1/Controllers/System/CronController.php+++ b/app/Api/V1/Controllers/System/CronController.php@@ -43,8 +43,8 @@ final class CronController extends Controllerpublic function cron(CronRequest $request, #[SensitiveParameter] string $cliToken): JsonResponse{CLIToken::routeBinder($cliToken, $request->route());- $config = $request->getAll();- $user = CLIToken::findUserByToken($cliToken);+ $config = $request->getAll();+ $user = CLIToken::findUserByToken($cliToken);Log::debug(sprintf('Now in %s', __METHOD__));Log::debug(sprintf('Date is %s', $config['date']->toIsoString()));@@ -54,8 +54,8 @@ final class CronController extends Controllerif (true === AppConfiguration::get('enable_external_rates', config('cer.download_enabled'))->data) {$return['exchange_rates'] = $this->exchangeRatesCronJob($user, $config['force'], $config['date']);}- $return['bill_notifications'] = $this->billWarningCronJob($user, $config['force'], $config['date']);- $return['webhooks'] = $this->webhookCronJob($user, $config['force'], $config['date']);+ $return['bill_notifications'] = $this->billWarningCronJob($user, $config['force'], $config['date']);+ $return['webhooks'] = $this->webhookCronJob($user, $config['force'], $config['date']);return response()->api($return);}diff --git a/app/Api/V1/Controllers/System/UserController.php b/app/Api/V1/Controllers/System/UserController.phpindex 3d6aeebb52..4d42348d48 100644--- a/app/Api/V1/Controllers/System/UserController.php+++ b/app/Api/V1/Controllers/System/UserController.php@@ -90,24 +90,24 @@ final class UserController extends Controllerpublic function index(): JsonResponse{// user preferences- $pageSize = $this->parameters->get('limit');- $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');+ $manager = $this->getManager();// build collection- $collection = $this->repository->all();- $count = $collection->count();- $users = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $collection = $this->repository->all();+ $count = $collection->count();+ $users = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($users, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.users.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($users, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.users.index').$this->buildParams());// make resource/** @var UserTransformer $transformer */$transformer = app(UserTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($users, $transformer, 'users');+ $resource = new FractalCollection($users, $transformer, 'users');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -122,14 +122,14 @@ final class UserController extends Controllerpublic function show(User $user): JsonResponse{// make manager- $manager = $this->getManager();+ $manager = $this->getManager();// make resource/** @var UserTransformer $transformer */$transformer = app(UserTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($user, $transformer, 'users');+ $resource = new Item($user, $transformer, 'users');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}@@ -142,21 +142,21 @@ final class UserController extends Controller*/public function store(UserStoreRequest $request): JsonResponse{- $data = $request->getAll();- $user = $this->repository->store($data);+ $data = $request->getAll();+ $user = $this->repository->store($data);Log::info(sprintf('Registered new user %s', $user->email));- $owner = new OwnerNotifiable();+ $owner = new OwnerNotifiable();event(new NewUserRegistered($owner, $user));- $manager = $this->getManager();+ $manager = $this->getManager();// make resource/** @var UserTransformer $transformer */$transformer = app(UserTransformer::class);- $resource = new Item($user, $transformer, 'users');+ $resource = new Item($user, $transformer, 'users');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}@@ -169,7 +169,7 @@ final class UserController extends Controller*/public function update(UserUpdateRequest $request, User $user): JsonResponse{- $data = $request->getAll();+ $data = $request->getAll();// can only update 'blocked' when user is admin.if (!$this->repository->hasRole(auth()->user(), 'owner')) {@@ -177,15 +177,15 @@ final class UserController extends Controllerunset($data['blocked'], $data['blocked_code']);}- $user = $this->repository->update($user, $data);- $manager = $this->getManager();+ $user = $this->repository->update($user, $data);+ $manager = $this->getManager();// make resource/** @var UserTransformer $transformer */$transformer = app(UserTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($user, $transformer, 'users');+ $resource = new Item($user, $transformer, 'users');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/User/PreferencesController.php b/app/Api/V1/Controllers/User/PreferencesController.phpindex cc37ff7b56..f42ce7686e 100644--- a/app/Api/V1/Controllers/User/PreferencesController.php+++ b/app/Api/V1/Controllers/User/PreferencesController.php@@ -37,6 +37,7 @@ use Illuminate\Support\Collection;use League\Fractal\Pagination\IlluminatePaginatorAdapter;use League\Fractal\Resource\Collection as FractalCollection;use League\Fractal\Resource\Item;+use function Safe\preg_match;/**@@ -62,14 +63,14 @@ final class PreferencesController extends Controller$preferences = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($preferences, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.preferences.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($preferences, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.preferences.index').$this->buildParams());/** @var PreferenceTransformer $transformer */$transformer = app(PreferenceTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($preferences, $transformer, self::RESOURCE_KEY);+ $resource = new FractalCollection($preferences, $transformer, self::RESOURCE_KEY);$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -83,7 +84,7 @@ final class PreferencesController extends Controller*/public function show(Preference $preference): JsonResponse{- $manager = $this->getManager();+ $manager = $this->getManager();if ('currencyPreference' === $preference->name) {throw new FireflyException('Please use api/v1/currencies/primary instead.');@@ -93,25 +94,25 @@ final class PreferencesController extends Controller$transformer = app(PreferenceTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($preference, $transformer, 'preferences');+ $resource = new Item($preference, $transformer, 'preferences');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}public function showList(Collection $preferenceList): JsonResponse{- $manager = $this->getManager();- $count = $preferenceList->count();- $names = implode(',', $preferenceList->pluck('name')->toArray());+ $manager = $this->getManager();+ $count = $preferenceList->count();+ $names = implode(',', $preferenceList->pluck('name')->toArray());// make paginator:- $paginator = new LengthAwarePaginator($preferenceList, $count, 31_337, 1);- $paginator->setPath(route('api.v1.preferences-list.show', [$names]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($preferenceList, $count, 31_337, 1);+ $paginator->setPath(route('api.v1.preferences-list.show', [$names]).$this->buildParams());/** @var PreferenceTransformer $transformer */$transformer = app(PreferenceTransformer::class);- $resource = new FractalCollection($preferenceList, $transformer, self::RESOURCE_KEY);+ $resource = new FractalCollection($preferenceList, $transformer, self::RESOURCE_KEY);$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -125,8 +126,8 @@ final class PreferencesController extends Controller*/public function store(PreferenceStoreRequest $request): JsonResponse{- $manager = $this->getManager();- $data = $request->getAll();+ $manager = $this->getManager();+ $data = $request->getAll();if ('currencyPreference' === $data['name']) {throw new FireflyException('Please use api/v1/currencies/default instead.');@@ -138,12 +139,12 @@ final class PreferencesController extends Controllerthrow new FireflyException('Invalid locale specified.');}- $pref = Preferences::set($data['name'], $data['data']);+ $pref = Preferences::set($data['name'], $data['data']);/** @var PreferenceTransformer $transformer */$transformer = app(PreferenceTransformer::class);- $resource = new Item($pref, $transformer, 'preferences');+ $resource = new Item($pref, $transformer, 'preferences');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}@@ -160,15 +161,15 @@ final class PreferencesController extends Controllerthrow new FireflyException('Please use api/v1/currencies/primary instead.');}- $manager = $this->getManager();- $data = $request->getAll();- $pref = Preferences::set($preference->name, $data['data']);+ $manager = $this->getManager();+ $data = $request->getAll();+ $pref = Preferences::set($preference->name, $data['data']);/** @var PreferenceTransformer $transformer */$transformer = app(PreferenceTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($pref, $transformer, 'preferences');+ $resource = new Item($pref, $transformer, 'preferences');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Webhook/AttemptController.php b/app/Api/V1/Controllers/Webhook/AttemptController.phpindex 49745d4f17..3e4c6a2d20 100644--- a/app/Api/V1/Controllers/Webhook/AttemptController.php+++ b/app/Api/V1/Controllers/Webhook/AttemptController.php@@ -73,30 +73,30 @@ final class AttemptController extends Controller}if (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {Log::channel('audit')->warning(sprintf(- 'User lists webhook attempts of webhook #%d and message #%d, but webhooks are DISABLED.',- $webhook->id,- $message->id- ));+ 'User lists webhook attempts of webhook #%d and message #%d, but webhooks are DISABLED.',+ $webhook->id,+ $message->id+ ));throw new NotFoundHttpException('Webhooks are not enabled.');}Log::channel('audit')->info(sprintf('User lists webhook attempts of webhook #%d and message #%d.', $webhook->id, $message->id));- $manager = $this->getManager();- $pageSize = $this->parameters->get('limit');- $collection = $this->repository->getAttempts($message);- $count = $collection->count();- $attempts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');+ $collection = $this->repository->getAttempts($message);+ $count = $collection->count();+ $attempts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($attempts, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.webhooks.attempts.index', [$webhook->id, $message->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($attempts, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.webhooks.attempts.index', [$webhook->id, $message->id]).$this->buildParams());/** @var WebhookAttemptTransformer $transformer */$transformer = app(WebhookAttemptTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($attempts, $transformer, 'webhook_attempts');+ $resource = new FractalCollection($attempts, $transformer, 'webhook_attempts');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -121,23 +121,23 @@ final class AttemptController extends Controllerif (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {Log::channel('audit')->warning(sprintf(- 'User views single webhook attempt #%d of webhook #%d and message #%d, but webhooks are DISABLED',- $attempt->id,- $webhook->id,- $message->id- ));+ 'User views single webhook attempt #%d of webhook #%d and message #%d, but webhooks are DISABLED',+ $attempt->id,+ $webhook->id,+ $message->id+ ));throw new NotFoundHttpException('Webhooks are not enabled.');}Log::channel('audit')->info(sprintf('User views single webhook attempt #%d of webhook #%d and message #%d.', $attempt->id, $webhook->id, $message->id));- $manager = $this->getManager();+ $manager = $this->getManager();/** @var WebhookAttemptTransformer $transformer */$transformer = app(WebhookAttemptTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($attempt, $transformer, self::RESOURCE_KEY);+ $resource = new Item($attempt, $transformer, self::RESOURCE_KEY);return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Webhook/DestroyController.php b/app/Api/V1/Controllers/Webhook/DestroyController.phpindex 424b52f0b1..25855845b5 100644--- a/app/Api/V1/Controllers/Webhook/DestroyController.php+++ b/app/Api/V1/Controllers/Webhook/DestroyController.php@@ -94,11 +94,11 @@ final class DestroyController extends Controllerif (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {Log::channel('audit')->warning(sprintf(- 'User tries to destroy webhook #%d, message #%d, attempt #%d, but webhooks are DISABLED.',- $webhook->id,- $message->id,- $attempt->id- ));+ 'User tries to destroy webhook #%d, message #%d, attempt #%d, but webhooks are DISABLED.',+ $webhook->id,+ $message->id,+ $attempt->id+ ));throw new NotFoundHttpException('Webhooks are not enabled.');}diff --git a/app/Api/V1/Controllers/Webhook/MessageController.php b/app/Api/V1/Controllers/Webhook/MessageController.phpindex 9d3f5486f3..5208666a70 100644--- a/app/Api/V1/Controllers/Webhook/MessageController.php+++ b/app/Api/V1/Controllers/Webhook/MessageController.php@@ -71,22 +71,22 @@ final class MessageController extends Controllerthrow new NotFoundHttpException('Webhooks are not enabled.');}Log::channel('audit')->info(sprintf('User views messages of webhook #%d.', $webhook->id));- $manager = $this->getManager();- $pageSize = $this->parameters->get('limit');- $collection = $this->repository->getMessages($webhook);+ $manager = $this->getManager();+ $pageSize = $this->parameters->get('limit');+ $collection = $this->repository->getMessages($webhook);- $count = $collection->count();- $messages = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $count = $collection->count();+ $messages = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($messages, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.webhooks.messages.index', [$webhook->id]) . $this->buildParams());+ $paginator = new LengthAwarePaginator($messages, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.webhooks.messages.index', [$webhook->id]).$this->buildParams());/** @var WebhookMessageTransformer $transformer */$transformer = app(WebhookMessageTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($messages, $transformer, 'webhook_messages');+ $resource = new FractalCollection($messages, $transformer, 'webhook_messages');$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -113,12 +113,12 @@ final class MessageController extends ControllerLog::channel('audit')->info(sprintf('User views message #%d of webhook #%d.', $message->id, $webhook->id));- $manager = $this->getManager();+ $manager = $this->getManager();/** @var WebhookMessageTransformer $transformer */$transformer = app(WebhookMessageTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($message, $transformer, self::RESOURCE_KEY);+ $resource = new Item($message, $transformer, self::RESOURCE_KEY);return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Webhook/ShowController.php b/app/Api/V1/Controllers/Webhook/ShowController.phpindex cd66248717..4c44f7e753 100644--- a/app/Api/V1/Controllers/Webhook/ShowController.php+++ b/app/Api/V1/Controllers/Webhook/ShowController.php@@ -79,28 +79,28 @@ final class ShowController extends Controller}Log::channel('audit')->info('User views all webhooks.');- $manager = $this->getManager();- $collection = $this->repository->all();- $pageSize = $this->parameters->get('limit');- $count = $collection->count();- $webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);+ $manager = $this->getManager();+ $collection = $this->repository->all();+ $pageSize = $this->parameters->get('limit');+ $count = $collection->count();+ $webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);// make paginator:- $paginator = new LengthAwarePaginator($webhooks, $count, $pageSize, $this->parameters->get('page'));- $paginator->setPath(route('api.v1.webhooks.index') . $this->buildParams());+ $paginator = new LengthAwarePaginator($webhooks, $count, $pageSize, $this->parameters->get('page'));+ $paginator->setPath(route('api.v1.webhooks.index').$this->buildParams());// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new WebhookEnrichment();+ $admin = auth()->user();+ $enrichment = new WebhookEnrichment();$enrichment->setUser($admin);- $webhooks = $enrichment->enrich($webhooks);+ $webhooks = $enrichment->enrich($webhooks);/** @var WebhookTransformer $transformer */$transformer = app(WebhookTransformer::class);$transformer->setParameters($this->parameters);- $resource = new FractalCollection($webhooks, $transformer, self::RESOURCE_KEY);+ $resource = new FractalCollection($webhooks, $transformer, self::RESOURCE_KEY);$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);@@ -121,19 +121,19 @@ final class ShowController extends Controller}Log::channel('audit')->info(sprintf('User views webhook #%d.', $webhook->id));- $manager = $this->getManager();+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new WebhookEnrichment();+ $admin = auth()->user();+ $enrichment = new WebhookEnrichment();$enrichment->setUser($admin);- $webhook = $enrichment->enrichSingle($webhook);+ $webhook = $enrichment->enrichSingle($webhook);/** @var WebhookTransformer $transformer */$transformer = app(WebhookTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($webhook, $transformer, self::RESOURCE_KEY);+ $resource = new Item($webhook, $transformer, self::RESOURCE_KEY);return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}@@ -148,10 +148,10 @@ final class ShowController extends Controller{if (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {Log::channel('audit')->info(sprintf(- 'User tries to trigger webhook #%d on transaction group #%d, but webhooks are DISABLED.',- $webhook->id,- $group->id- ));+ 'User tries to trigger webhook #%d on transaction group #%d, but webhooks are DISABLED.',+ $webhook->id,+ $group->id+ ));throw new NotFoundHttpException('Webhooks are not enabled.');}@@ -166,7 +166,7 @@ final class ShowController extends Controller$engine->setUser(auth()->user());// tell the generator which trigger it should look for- $engine->setTrigger(WebhookTrigger::tryFrom((int)$trigger->key));+ $engine->setTrigger(WebhookTrigger::tryFrom((int) $trigger->key));// tell the generator which objects to process$engine->setObjects(new Collection()->push($group));// set the webhook to triggerdiff --git a/app/Api/V1/Controllers/Webhook/StoreController.php b/app/Api/V1/Controllers/Webhook/StoreController.phpindex e9712b1108..25a334f807 100644--- a/app/Api/V1/Controllers/Webhook/StoreController.php+++ b/app/Api/V1/Controllers/Webhook/StoreController.php@@ -62,23 +62,23 @@ final class StoreController extends Controller*/public function store(CreateRequest $request): JsonResponse{- $data = $request->getData();+ $data = $request->getData();if (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {Log::channel('audit')->info('User tries to store new webhook, but webhooks are DISABLED.', $data);throw new NotFoundHttpException('Webhooks are not enabled.');}- $webhook = $this->repository->store($data);+ $webhook = $this->repository->store($data);// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new WebhookEnrichment();+ $admin = auth()->user();+ $enrichment = new WebhookEnrichment();$enrichment->setUser($admin);- $webhook = $enrichment->enrichSingle($webhook);+ $webhook = $enrichment->enrichSingle($webhook);- $manager = $this->getManager();+ $manager = $this->getManager();Log::channel('audit')->info('User stores new webhook', $data);@@ -86,7 +86,7 @@ final class StoreController extends Controller$transformer = app(WebhookTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($webhook, $transformer, 'webhooks');+ $resource = new Item($webhook, $transformer, 'webhooks');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Controllers/Webhook/UpdateController.php b/app/Api/V1/Controllers/Webhook/UpdateController.phpindex d1a12daa25..b2c8efbfeb 100644--- a/app/Api/V1/Controllers/Webhook/UpdateController.php+++ b/app/Api/V1/Controllers/Webhook/UpdateController.php@@ -61,24 +61,24 @@ final class UpdateController extends Controller*/public function update(Webhook $webhook, UpdateRequest $request): JsonResponse{- $data = $request->getData();+ $data = $request->getData();if (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {Log::channel('audit')->info(sprintf('User tries to update webhook #%d, but webhooks are DISABLED.', $webhook->id), $data);throw new NotFoundHttpException('Webhooks are not enabled.');}- $webhook = $this->repository->update($webhook, $data);- $manager = $this->getManager();+ $webhook = $this->repository->update($webhook, $data);+ $manager = $this->getManager();// enrich/** @var User $admin */- $admin = auth()->user();- $enrichment = new WebhookEnrichment();+ $admin = auth()->user();+ $enrichment = new WebhookEnrichment();$enrichment->setUser($admin);/** @var Webhook $webhook */- $webhook = $enrichment->enrichSingle($webhook);+ $webhook = $enrichment->enrichSingle($webhook);Log::channel('audit')->info(sprintf('User updates webhook #%d', $webhook->id), $data);@@ -86,7 +86,7 @@ final class UpdateController extends Controller$transformer = app(WebhookTransformer::class);$transformer->setParameters($this->parameters);- $resource = new Item($webhook, $transformer, 'webhooks');+ $resource = new Item($webhook, $transformer, 'webhooks');return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);}diff --git a/app/Api/V1/Requests/AggregateFormRequest.php b/app/Api/V1/Requests/AggregateFormRequest.phpindex 8298d88a92..95aaf8788e 100644--- a/app/Api/V1/Requests/AggregateFormRequest.php+++ b/app/Api/V1/Requests/AggregateFormRequest.php@@ -33,10 +33,11 @@ abstract class AggregateFormRequest extends ApiRequest{#[Override]protected array $acceptedRoles = [];+/*** @var Request[]*/- protected array $requests = [];+ protected array $requests = [];#[Override]public function initialize(@@ -46,9 +47,8 @@ abstract class AggregateFormRequest extends ApiRequestarray $cookies = [],array $files = [],array $server = [],- $content = null- ): void- {+ $content = null+ ): void {parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content);// instantiate all subrequests and share current requests' bags with them@@ -56,7 +56,7 @@ abstract class AggregateFormRequest extends ApiRequest/** @var array|string $config */foreach ($this->getRequests() as $config) {- $requestClass = is_array($config) ? array_shift($config) : $config;+ $requestClass = is_array($config) ? array_shift($config) : $config;if (!is_a($requestClass, Request::class, true)) {throw new RuntimeException('getRequests() must return class-strings of subclasses of Request');@@ -86,7 +86,7 @@ abstract class AggregateFormRequest extends ApiRequest// check all subrequests for rules and combine themreturn array_reduce($this->requests,- static fn(array $rules, FormRequest $request): array => $rules + (method_exists($request, 'rules') ? $request->rules() : []),+ static fn (array $rules, FormRequest $request): array => $rules + (method_exists($request, 'rules') ? $request->rules() : []),[]);}diff --git a/app/Api/V1/Requests/ApiRequest.php b/app/Api/V1/Requests/ApiRequest.phpindex ea08010725..cec26a5a73 100644--- a/app/Api/V1/Requests/ApiRequest.php+++ b/app/Api/V1/Requests/ApiRequest.php@@ -34,7 +34,7 @@ class ApiRequest extends FormRequestprotected array $acceptedRoles = [];- protected string $required = '';+ protected string $required = '';public function handleConfig(array $config): void{diff --git a/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php b/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.phpindex c923c7768a..4ab1ed1291 100644--- a/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php+++ b/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php@@ -52,7 +52,7 @@ class AutocompleteRequest extends FormRequest// remove 'initial balance' from allowed types. its internal$array = array_diff($array, [AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::RECONCILIATION->value]);- $date = $this->getCarbonDate('date') ?? today(config('app.timezone'));+ $date = $this->getCarbonDate('date') ?? today(config('app.timezone'));return ['types' => $array, 'query' => $this->convertString('query'), 'date' => $date->endOfDay()];}diff --git a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.phpindex 64bcb267ee..fdc3e77b44 100644--- a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php+++ b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php@@ -74,15 +74,15 @@ class MoveTransactionsRequest extends FormRequestprivate function validateMove(FireflyValidator $validator): void{- $data = $validator->getData();- $repository = app(AccountRepositoryInterface::class);+ $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;}@@ -92,7 +92,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;}@@ -101,7 +101,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/Bulk/TransactionRequest.php b/app/Api/V1/Requests/Data/Bulk/TransactionRequest.phpindex 2ecba16283..93c1247a21 100644--- a/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php+++ b/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php@@ -33,6 +33,7 @@ use Illuminate\Contracts\Validation\Validator;use Illuminate\Foundation\Http\FormRequest;use Illuminate\Support\Facades\Log;use JsonException;+use function Safe\json_decode;/**diff --git a/app/Api/V1/Requests/Data/DestroyRequest.php b/app/Api/V1/Requests/Data/DestroyRequest.phpindex c6c13ea99b..dc5b77c04c 100644--- a/app/Api/V1/Requests/Data/DestroyRequest.php+++ b/app/Api/V1/Requests/Data/DestroyRequest.php@@ -53,8 +53,8 @@ class DestroyRequest extends FormRequest{$valid= 'budgets,bills,piggy_banks,rules,recurring,categories,tags,object_groups'- . ',accounts,asset_accounts,expense_accounts,revenue_accounts,liabilities,transactions,withdrawals,deposits,transfers'- . ',not_assets_liabilities';+ .',accounts,asset_accounts,expense_accounts,revenue_accounts,liabilities,transactions,withdrawals,deposits,transfers'+ .',not_assets_liabilities';return ['objects' => sprintf('required|max:255|min:1|string|in:%s', $valid), 'unused' => 'in:true,false'];}diff --git a/app/Api/V1/Requests/Data/Export/ExportRequest.php b/app/Api/V1/Requests/Data/Export/ExportRequest.phpindex 744417312e..aa3d8a0e8b 100644--- a/app/Api/V1/Requests/Data/Export/ExportRequest.php+++ b/app/Api/V1/Requests/Data/Export/ExportRequest.php@@ -43,18 +43,18 @@ class ExportRequest extends FormRequestpublic function getAll(): array{- $result = [+ $result = ['start' => $this->getCarbonDate('start') ?? today(config('app.timezone'))->subYear(),'end' => $this->getCarbonDate('end') ?? today(config('app.timezone')),'type' => $this->convertString('type'),];- $parts = explode(',', $this->convertString('accounts'));- $repository = app(AccountRepositoryInterface::class);+ $parts = explode(',', $this->convertString('accounts'));+ $repository = app(AccountRepositoryInterface::class);$repository->setUser(auth()->user());- $accounts = new Collection();+ $accounts = new Collection();foreach ($parts as $part) {- $accountId = (int)$part;+ $accountId = (int) $part;if (0 !== $accountId) {$account = $repository->find($accountId);if (null !== $account && AccountTypeEnum::ASSET->value === $account->accountType->type) {diff --git a/app/Api/V1/Requests/DateRequest.php b/app/Api/V1/Requests/DateRequest.phpindex 63588dcb32..6b9cd4956f 100644--- a/app/Api/V1/Requests/DateRequest.php+++ b/app/Api/V1/Requests/DateRequest.php@@ -30,7 +30,7 @@ class DateRequest extends ApiRequest{public function rules(): array{- return ['date' => 'date|after:1970-01-02|before:2038-01-17|' . $this->required];+ return ['date' => 'date|after:1970-01-02|before:2038-01-17|'.$this->required];}public function withValidator(Validator $validator): void@@ -39,13 +39,13 @@ class DateRequest extends ApiRequestif (count($validator->failed()) > 0) {return;}- $date = $this->getCarbonDate('date')?->endOfDay();+ $date = $this->getCarbonDate('date')?->endOfDay();// if we also have a range, date must be in that range$start = $this->attributes->get('start');$end = $this->attributes->get('end');if ($date instanceof Carbon && $start instanceof Carbon && $end instanceof Carbon && !$date->between($start, $end)) {- $validator->errors()->add('date', (string)trans('validation.between_date'));+ $validator->errors()->add('date', (string) trans('validation.between_date'));}$this->attributes->set('date', $date);diff --git a/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php b/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.phpindex 00280ddfeb..f3ed08f188 100644--- a/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php+++ b/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php@@ -57,7 +57,7 @@ class ObjectTypeApiRequest extends ApiRequestpublic function rules(): array{- $rule = null;+ $rule = null;if (Account::class === $this->objectType) {$rule = new IsValidAccountTypeList();}@@ -85,7 +85,7 @@ class ObjectTypeApiRequest extends ApiRequestdefault:$this->attributes->set('types', []);- // no break+ // no breakcase Account::class:$types = $this->mapAccountTypes($type);diff --git a/app/Api/V1/Requests/Insight/GenericRequest.php b/app/Api/V1/Requests/Insight/GenericRequest.phpindex c0ca32acc7..a44eb1cf40 100644--- a/app/Api/V1/Requests/Insight/GenericRequest.php+++ b/app/Api/V1/Requests/Insight/GenericRequest.php@@ -70,8 +70,8 @@ class GenericRequest extends FormRequestforeach ($this->accounts as $account) {$type = $account->accountType->type;if (in_array(- $type,- [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],+ $type,+ [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],strict: true)) {$return->push($account);@@ -179,10 +179,10 @@ class GenericRequest extends FormRequest}$repository = app(AccountRepositoryInterface::class);$repository->setUser(auth()->user());- $array = $this->get('accounts');+ $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);@@ -198,10 +198,10 @@ class GenericRequest extends FormRequest}$repository = app(BillRepositoryInterface::class);$repository->setUser(auth()->user());- $array = $this->get('bills');+ $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);@@ -217,10 +217,10 @@ class GenericRequest extends FormRequest}$repository = app(BudgetRepositoryInterface::class);$repository->setUser(auth()->user());- $array = $this->get('budgets');+ $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);@@ -236,10 +236,10 @@ class GenericRequest extends FormRequest}$repository = app(CategoryRepositoryInterface::class);$repository->setUser(auth()->user());- $array = $this->get('categories');+ $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);@@ -255,10 +255,10 @@ class GenericRequest extends FormRequest}$repository = app(TagRepositoryInterface::class);$repository->setUser(auth()->user());- $array = $this->get('tags');+ $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/Account/StoreRequest.php b/app/Api/V1/Requests/Models/Account/StoreRequest.phpindex 75199833fd..1db2bfb5aa 100644--- a/app/Api/V1/Requests/Models/Account/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Account/StoreRequest.php@@ -55,7 +55,7 @@ class StoreRequest extends FormRequestif (null !== $this->get('include_net_worth')) {$includeNetWorth = $this->boolean('include_net_worth');}- $data = [+ $data = ['name' => $this->convertString('name'),'active' => $active,'include_net_worth' => $includeNetWorth,@@ -78,7 +78,7 @@ class StoreRequest extends FormRequest'interest_period' => $this->convertString('interest_period'),];// append location information.- $data = $this->appendLocationData($data, null);+ $data = $this->appendLocationData($data, null);if ('liability' === $data['account_type_name'] || 'liabilities' === $data['account_type_name']) {$data['account_type_name'] = $this->convertString('liability_type');diff --git a/app/Api/V1/Requests/Models/Account/UpdateRequest.php b/app/Api/V1/Requests/Models/Account/UpdateRequest.phpindex 9d76b48741..5d184f2969 100644--- a/app/Api/V1/Requests/Models/Account/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Account/UpdateRequest.php@@ -91,7 +91,7 @@ class UpdateRequest extends FormRequest$types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));$ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));- $rules = [+ $rules = ['name' => sprintf('min:1|max:1024|uniqueAccountForUser:%d', $account->id),'type' => sprintf('in:%s', $types),'iban' => ['iban', 'nullable', new UniqueIban($account, $this->convertString('type'))],@@ -125,10 +125,10 @@ class UpdateRequest extends FormRequest{$validator->after(function (FireflyValidator $validator): void {// validate start before end only if both are there.- $data = $validator->getData();+ $data = $validator->getData();/** @var Account $account */- $account = $this->route()->parameter('account');+ $account = $this->route()->parameter('account');/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);@@ -137,10 +137,10 @@ class UpdateRequest extends FormRequest// how many piggies are attached?$piggyBanks = $account->piggyBanks()->count();if ($piggyBanks > 0 && array_key_exists('currency_code', $data) && $data['currency_code'] !== $currency->code) {- $validator->errors()->add('currency_code', (string)trans('validation.piggy_no_change_currency'));+ $validator->errors()->add('currency_code', (string) trans('validation.piggy_no_change_currency'));}- if ($piggyBanks > 0 && array_key_exists('currency_id', $data) && (int)$data['currency_id'] !== $currency->id) {- $validator->errors()->add('currency_id', (string)trans('validation.piggy_no_change_currency'));+ if ($piggyBanks > 0 && array_key_exists('currency_id', $data) && (int) $data['currency_id'] !== $currency->id) {+ $validator->errors()->add('currency_id', (string) trans('validation.piggy_no_change_currency'));}});if ($validator->fails()) {diff --git a/app/Api/V1/Requests/Models/Attachment/StoreRequest.php b/app/Api/V1/Requests/Models/Attachment/StoreRequest.phpindex 61e545c284..63fe2a69c6 100644--- a/app/Api/V1/Requests/Models/Attachment/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Attachment/StoreRequest.php@@ -59,7 +59,7 @@ class StoreRequest extends FormRequestpublic function rules(): array{$models = config('firefly.valid_attachment_models');- $models = array_map(static fn(string $className): string => str_replace('FireflyIII\Models\\', '', $className), $models);+ $models = array_map(static fn (string $className): string => str_replace('FireflyIII\Models\\', '', $className), $models);$models = implode(',', $models);$model = $this->convertString('attachable_type');diff --git a/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php b/app/Api/V1/Requests/Models/Attachment/UpdateRequest.phpindex 59266f4490..b230c226dc 100644--- a/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php@@ -61,7 +61,7 @@ class UpdateRequest extends FormRequestpublic function rules(): array{$models = config('firefly.valid_attachment_models');- $models = array_map(static fn(string $className): string => str_replace('FireflyIII\Models\\', '', $className), $models);+ $models = array_map(static fn (string $className): string => str_replace('FireflyIII\Models\\', '', $className), $models);$models = implode(',', $models);$model = $this->convertString('attachable_type');diff --git a/app/Api/V1/Requests/Models/AvailableBudget/Request.php b/app/Api/V1/Requests/Models/AvailableBudget/Request.phpindex 0c3a8342ba..14541253a8 100644--- a/app/Api/V1/Requests/Models/AvailableBudget/Request.php+++ b/app/Api/V1/Requests/Models/AvailableBudget/Request.php@@ -85,7 +85,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 a518c437aa..38e042d4e7 100644--- a/app/Api/V1/Requests/Models/Bill/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Bill/StoreRequest.php@@ -98,13 +98,13 @@ class StoreRequest extends FormRequestpublic function withValidator(Validator $validator): void{$validator->after(static function (Validator $validator): void {- $data = $validator->getData();- $min = $data['amount_min'] ?? '0';- $max = $data['amount_max'] ?? '0';+ $data = $validator->getData();+ $min = $data['amount_min'] ?? '0';+ $max = $data['amount_max'] ?? '0';if (is_array($min) || is_array($max)) {- $validator->errors()->add('amount_min', (string)trans('validation.generic_invalid'));- $validator->errors()->add('amount_max', (string)trans('validation.generic_invalid'));+ $validator->errors()->add('amount_min', (string) trans('validation.generic_invalid'));+ $validator->errors()->add('amount_max', (string) trans('validation.generic_invalid'));$min = '0';$max = '0';}@@ -114,12 +114,12 @@ class StoreRequest extends FormRequest$result = bccomp($min, $max);} catch (ValueError $e) {Log::error($e->getMessage());- $validator->errors()->add('amount_min', (string)trans('validation.generic_invalid'));- $validator->errors()->add('amount_max', (string)trans('validation.generic_invalid'));+ $validator->errors()->add('amount_min', (string) trans('validation.generic_invalid'));+ $validator->errors()->add('amount_max', (string) trans('validation.generic_invalid'));}if (1 === $result) {- $validator->errors()->add('amount_min', (string)trans('validation.amount_min_over_max'));+ $validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max'));}});$failed = false;diff --git a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php b/app/Api/V1/Requests/Models/Bill/UpdateRequest.phpindex 1e4de7156c..6f2faab885 100644--- a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php@@ -105,7 +105,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/BudgetLimit/StoreRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.phpindex 4953282f2f..6703df8783 100644--- a/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php+++ b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php@@ -94,12 +94,12 @@ class StoreRequest extends FormRequestif (0 !== count($validator->failed())) {return;}- $data = $validator->getData();+ $data = $validator->getData();// if no currency has been provided, use the user's default currency:/** @var TransactionCurrencyFactory $factory */- $factory = app(TransactionCurrencyFactory::class);- $currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null);+ $factory = app(TransactionCurrencyFactory::class);+ $currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null);if (null === $currency) {$currency = Amount::getPrimaryCurrency();}@@ -107,16 +107,17 @@ class StoreRequest extends FormRequest$repository->enable($currency);// validator already concluded start and end are valid dates:- $start = Carbon::parse($data['start'], config('app.timezone'));- $end = Carbon::parse($data['end'], config('app.timezone'));+ $start = Carbon::parse($data['start'], config('app.timezone'));+ $end = Carbon::parse($data['end'], config('app.timezone'));// find limit with same date range and currency.- $limit = $budget+ $limit = $budget->budgetlimits()->where('budget_limits.start_date', $start->format('Y-m-d'))->where('budget_limits.end_date', $end->format('Y-m-d'))->where('budget_limits.transaction_currency_id', $currency->id)- ->first(['budget_limits.*']);+ ->first(['budget_limits.*'])+ ;if (null !== $limit) {$validator->errors()->add('start', trans('validation.limit_exists'));}diff --git a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.phpindex 9f518c1f15..3ed1e838c2 100644--- a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php@@ -98,7 +98,7 @@ class UpdateRequest 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/CurrencyExchangeRate/StoreByDateRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.phpindex 39d32596a5..04f7fe40de 100644--- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php+++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php@@ -49,7 +49,7 @@ class StoreByDateRequest extends FormRequestpublic function getFromCurrency(): TransactionCurrency{- return Amount::getTransactionCurrencyByCode((string)$this->get('from'));+ return Amount::getTransactionCurrencyByCode((string) $this->get('from'));}/**@@ -84,7 +84,7 @@ class StoreByDateRequest extends FormRequest}try {- Amount::getTransactionCurrencyByCode((string)$key);+ Amount::getTransactionCurrencyByCode((string) $key);} catch (FireflyException) {$validator->errors()->add(sprintf('rates.%s', $key), trans('validation.invalid_currency_code', ['code' => $key]));}diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.phpindex 80069f4fe1..bad8b8b7e6 100644--- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.php+++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.php@@ -45,17 +45,17 @@ class StoreRequest extends FormRequestpublic function getFromCurrency(): TransactionCurrency{- return Amount::getTransactionCurrencyByCode((string)$this->get('from'));+ return Amount::getTransactionCurrencyByCode((string) $this->get('from'));}public function getRate(): string{- return (string)$this->get('rate');+ return (string) $this->get('rate');}public function getToCurrency(): TransactionCurrency{- return Amount::getTransactionCurrencyByCode((string)$this->get('to'));+ return Amount::getTransactionCurrencyByCode((string) $this->get('to'));}/**diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.phpindex 7600786d3e..2a92c35513 100644--- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.php@@ -43,7 +43,7 @@ class UpdateRequest extends FormRequestpublic function getRate(): string{- return (string)$this->get('rate');+ return (string) $this->get('rate');}/**diff --git a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.phpindex 95ee2baa52..e93e708401 100644--- a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php+++ b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php@@ -94,28 +94,28 @@ class StoreRequest extends FormRequest{$validator->after(function (Validator $validator): void {// validate start before end only if both are there.- $data = $validator->getData();- $currency = $this->getCurrencyFromData($validator, $data);+ $data = $validator->getData();+ $currency = $this->getCurrencyFromData($validator, $data);if (!$currency instanceof TransactionCurrency) {return;}- $targetAmount = (string)($data['target_amount'] ?? '0');+ $targetAmount = (string) ($data['target_amount'] ?? '0');$currentAmount = '0';if (array_key_exists('accounts', $data) && is_array($data['accounts'])) {$repository = app(AccountRepositoryInterface::class);$types = config('firefly.piggy_bank_account_types');foreach ($data['accounts'] as $index => $array) {- $accountId = (int)($array['account_id'] ?? 0);+ $accountId = (int) ($array['account_id'] ?? 0);$account = $repository->find($accountId);if (null !== $account) {// 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'));}- $type = $account->accountType->type;+ $type = $account->accountType->type;if (!in_array($type, $types, strict: true)) {$validator->errors()->add(sprintf('accounts.%d', $index), trans('validation.invalid_account_type'));}@@ -133,11 +133,11 @@ class StoreRequest extends FormRequestprivate function getCurrencyFromData(Validator $validator, array $data): ?TransactionCurrency{- if (array_key_exists('transaction_currency_code', $data) && '' !== (string)$data['transaction_currency_code']) {- return Amount::getTransactionCurrencyByCode((string)$data['transaction_currency_code']);+ if (array_key_exists('transaction_currency_code', $data) && '' !== (string) $data['transaction_currency_code']) {+ return Amount::getTransactionCurrencyByCode((string) $data['transaction_currency_code']);}- if (array_key_exists('transaction_currency_id', $data) && '' !== (string)$data['transaction_currency_id']) {- return Amount::getTransactionCurrencyById((int)$data['transaction_currency_id']);+ if (array_key_exists('transaction_currency_id', $data) && '' !== (string) $data['transaction_currency_id']) {+ return Amount::getTransactionCurrencyById((int) $data['transaction_currency_id']);}$validator->errors()->add('transaction_currency_id', trans('validation.require_currency_id_code'));diff --git a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.phpindex da3618a26b..f7fe234148 100644--- a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php@@ -48,7 +48,7 @@ class UpdateRequest extends FormRequest*/public function getAll(): array{- $fields = [+ $fields = ['name' => ['name', 'convertString'],'target_amount' => ['target_amount', 'convertString'],'start_date' => ['start_date', 'convertDateTime'],@@ -76,7 +76,7 @@ class UpdateRequest extends FormRequest$piggyBank = $this->route()->parameter('piggyBank');return [- 'name' => 'min:1|max:255|uniquePiggyBankForUser:' . $piggyBank->id,+ 'name' => 'min:1|max:255|uniquePiggyBankForUser:'.$piggyBank->id,'current_amount' => ['nullable', new LessThanPiggyTarget(), new IsValidPositiveAmount()],'target_amount' => ['nullable', new IsValidZeroOrMoreAmount()],'start_date' => ['date', 'nullable'],diff --git a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.phpindex 1415fa13a2..ebc871979f 100644--- a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php@@ -78,19 +78,19 @@ class StoreRequest extends FormRequestpublic function rules(): array{return [- 'type' => ['required', 'in:withdrawal,transfer,deposit'],- 'title' => ['required', 'min:1', 'max:255', 'uniqueObjectForUser:recurrences,title'],- 'description' => ['min:1', 'max:32768'],- 'first_date' => ['required', 'date'],- 'apply_rules' => [new IsBoolean()],- 'active' => [new IsBoolean()],- 'repeat_until' => ['nullable', 'date'],- 'nr_of_repetitions' => ['nullable', 'numeric', 'min:1', 'max:255'],-- 'repetitions.*.type' => ['required', 'in:daily,weekly,ndom,monthly,yearly'],- 'repetitions.*.moment' => ['string', 'min:0', 'max:10'],- 'repetitions.*.skip' => ['nullable', 'numeric', 'min:0', 'max:31'],- 'repetitions.*.weekend' => ['numeric', 'min:1', 'max:4'],+ 'type' => ['required', 'in:withdrawal,transfer,deposit'],+ 'title' => ['required', 'min:1', 'max:255', 'uniqueObjectForUser:recurrences,title'],+ 'description' => ['min:1', 'max:32768'],+ 'first_date' => ['required', 'date'],+ 'apply_rules' => [new IsBoolean()],+ 'active' => [new IsBoolean()],+ 'repeat_until' => ['nullable', 'date'],+ 'nr_of_repetitions' => ['nullable', 'numeric', 'min:1', 'max:255'],++ 'repetitions.*.type' => ['required', 'in:daily,weekly,ndom,monthly,yearly'],+ 'repetitions.*.moment' => ['string', 'min:0', 'max:10'],+ 'repetitions.*.skip' => ['nullable', 'numeric', 'min:0', 'max:31'],+ 'repetitions.*.weekend' => ['numeric', 'min:1', 'max:4'],'transactions.*.description' => ['required', 'min:1', 'max:255'],'transactions.*.amount' => ['required', new IsValidPositiveAmount()],@@ -139,7 +139,7 @@ class StoreRequest extends FormRequest*/private function getRepetitionData(): array{- $return = [];+ $return = [];// repetition data:/** @var null|array $repetitions */@@ -150,7 +150,7 @@ class StoreRequest extends FormRequest/** @var array $repetition */foreach ($repetitions as $repetition) {- $current = [];+ $current = [];if (array_key_exists('type', $repetition)) {$current['type'] = $repetition['type'];}@@ -158,10 +158,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;@@ -176,7 +176,7 @@ class StoreRequest extends FormRequest*/private function getTransactionData(): array{- $return = [];+ $return = [];// transaction data:/** @var null|array $transactions */diff --git a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.phpindex f5eabe8ac4..1a9a01bb4f 100644--- a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php@@ -58,7 +58,7 @@ class UpdateRequest extends FormRequestpublic function getAll(): array{// this is the way:- $fields = [+ $fields = ['title' => ['title', 'convertString'],'description' => ['description', 'convertString'],'first_date' => ['first_date', 'convertDateTime'],@@ -68,9 +68,9 @@ class UpdateRequest extends FormRequest'active' => ['active', 'boolean'],'notes' => ['notes', 'convertString'],];- $reps = $this->getRepetitionData();- $transactions = $this->getTransactionData();- $return = ['recurrence' => $this->getAllData($fields)];+ $reps = $this->getRepetitionData();+ $transactions = $this->getTransactionData();+ $return = ['recurrence' => $this->getAllData($fields)];if (null !== $reps) {$return['repetitions'] = $reps;}@@ -88,18 +88,18 @@ class UpdateRequest extends FormRequest$recurrence = $this->route()->parameter('recurrence');return [- 'title' => sprintf('min:1|max:255|uniqueObjectForUser:recurrences,title,%d', $recurrence->id),- 'description' => ['min:1', 'max:32768'],- 'first_date' => ['date', 'after:1970-01-02', 'before:2038-01-17'],- 'apply_rules' => [new IsBoolean()],- 'active' => [new IsBoolean()],- 'repeat_until' => ['nullable', 'date'],- 'nr_of_repetitions' => ['nullable', 'numeric', 'min:1', 'max:255'],-- 'repetitions.*.type' => 'in:daily,weekly,ndom,monthly,yearly',- 'repetitions.*.moment' => ['string', 'min:0', 'max:10'],- 'repetitions.*.skip' => ['nullable', 'numeric', 'min:0', 'max:31'],- 'repetitions.*.weekend' => ['nullable', 'numeric', 'min:1', 'max:4'],+ 'title' => sprintf('min:1|max:255|uniqueObjectForUser:recurrences,title,%d', $recurrence->id),+ 'description' => ['min:1', 'max:32768'],+ 'first_date' => ['date', 'after:1970-01-02', 'before:2038-01-17'],+ 'apply_rules' => [new IsBoolean()],+ 'active' => [new IsBoolean()],+ 'repeat_until' => ['nullable', 'date'],+ 'nr_of_repetitions' => ['nullable', 'numeric', 'min:1', 'max:255'],++ 'repetitions.*.type' => 'in:daily,weekly,ndom,monthly,yearly',+ 'repetitions.*.moment' => ['string', 'min:0', 'max:10'],+ 'repetitions.*.skip' => ['nullable', 'numeric', 'min:0', 'max:31'],+ 'repetitions.*.weekend' => ['nullable', 'numeric', 'min:1', 'max:4'],'transactions.*.description' => ['min:1', 'max:255'],'transactions.*.amount' => [new IsValidPositiveAmount()],@@ -151,7 +151,7 @@ class UpdateRequest extends FormRequest*/private function getRepetitionData(): ?array{- $return = [];+ $return = [];// repetition data:/** @var null|array $repetitions */@@ -162,21 +162,21 @@ class UpdateRequest extends FormRequest/** @var array $repetition */foreach ($repetitions as $repetition) {- $current = [];+ $current = [];if (array_key_exists('type', $repetition)) {$current['type'] = $repetition['type'];}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;}@@ -193,7 +193,7 @@ class UpdateRequest extends FormRequest*/private function getTransactionData(): array{- $return = [];+ $return = [];// transaction data:/** @var null|array $transactions */diff --git a/app/Api/V1/Requests/Models/Rule/StoreRequest.php b/app/Api/V1/Requests/Models/Rule/StoreRequest.phpindex e04cf5eb71..d26ef8b8a5 100644--- a/app/Api/V1/Requests/Models/Rule/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Rule/StoreRequest.php@@ -72,8 +72,8 @@ class StoreRequest extends FormRequest*/public function rules(): array{- $validTriggers = $this->getTriggers();- $validActions = array_keys(config('firefly.rule-actions'));+ $validTriggers = $this->getTriggers();+ $validActions = array_keys(config('firefly.rule-actions'));// some triggers and actions require text:$contextTriggers = implode(',', $this->getTriggersWithContext());@@ -85,11 +85,11 @@ class StoreRequest extends FormRequest'rule_group_id' => ['belongsToUser:rule_groups', 'required_without:rule_group_title'],'rule_group_title' => ['nullable', 'min:1', 'max:255', 'required_without:rule_group_id', 'belongsToUser:rule_groups,title'],'trigger' => ['required', 'in:store-journal,update-journal,manual-activation'],- 'triggers.*.type' => 'required|in:' . implode(',', $validTriggers),- 'triggers.*.value' => 'required_if:actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue|max:1024',+ 'triggers.*.type' => 'required|in:'.implode(',', $validTriggers),+ 'triggers.*.value' => 'required_if:actions.*.type,'.$contextTriggers.'|min:1|ruleTriggerValue|max:1024','triggers.*.stop_processing' => [new IsBoolean()],'triggers.*.active' => [new IsBoolean()],- 'actions.*.type' => 'required|in:' . implode(',', $validActions),+ 'actions.*.type' => 'required|in:'.implode(',', $validActions),'actions.*.value' => [sprintf('required_if:actions.*.type,%s', $contextActions), new IsValidActionExpression(), 'ruleActionValue'],'actions.*.stop_processing' => [new IsBoolean()],'actions.*.active' => [new IsBoolean()],@@ -124,7 +124,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'));}}@@ -133,10 +133,10 @@ class StoreRequest extends FormRequest*/protected function atLeastOneActiveAction(Validator $validator): void{- $data = $validator->getData();+ $data = $validator->getData();/** @var null|array|int|string $actions */- $actions = $data['actions'] ?? [];+ $actions = $data['actions'] ?? [];// need at least one triggerif (!is_countable($actions) || 0 === count($actions)) {return;@@ -153,7 +153,7 @@ class StoreRequest extends FormRequest}}if ($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'));}}@@ -162,10 +162,10 @@ class StoreRequest extends FormRequest*/protected function atLeastOneActiveTrigger(Validator $validator): void{- $data = $validator->getData();+ $data = $validator->getData();/** @var null|array|int|string $triggers */- $triggers = $data['triggers'] ?? [];+ $triggers = $data['triggers'] ?? [];// need at least one triggerif (!is_countable($triggers) || 0 === count($triggers)) {return;@@ -182,7 +182,7 @@ class StoreRequest extends FormRequest}}if ($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'));}}@@ -195,7 +195,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'));}}@@ -208,8 +208,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')),];}}@@ -226,9 +226,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')),];}}diff --git a/app/Api/V1/Requests/Models/Rule/TestRequest.php b/app/Api/V1/Requests/Models/Rule/TestRequest.phpindex 9f97c1df5e..5565946dc6 100644--- a/app/Api/V1/Requests/Models/Rule/TestRequest.php+++ b/app/Api/V1/Requests/Models/Rule/TestRequest.php@@ -65,13 +65,13 @@ 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));}private 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');}}diff --git a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php b/app/Api/V1/Requests/Models/Rule/TriggerRequest.phpindex eeee240466..13f623fdc4 100644--- a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php+++ b/app/Api/V1/Requests/Models/Rule/TriggerRequest.php@@ -65,7 +65,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 f7a0ef5d1c..f835e87098 100644--- a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php@@ -50,7 +50,7 @@ class UpdateRequest extends FormRequest*/public function getAll(): array{- $fields = [+ $fields = ['title' => ['title', 'convertString'],'description' => ['description', 'stringWithNewlines'],'rule_group_id' => ['rule_group_id', 'convertInteger'],@@ -79,11 +79,11 @@ class UpdateRequest extends FormRequest*/public function rules(): array{- $validTriggers = $this->getTriggers();- $validActions = array_keys(config('firefly.rule-actions'));+ $validTriggers = $this->getTriggers();+ $validActions = array_keys(config('firefly.rule-actions'));/** @var Rule $rule */- $rule = $this->route()->parameter('rule');+ $rule = $this->route()->parameter('rule');// some triggers and actions require text:$contextTriggers = implode(',', $this->getTriggersWithContext());@@ -95,11 +95,11 @@ class UpdateRequest extends FormRequest'rule_group_id' => 'belongsToUser:rule_groups','rule_group_title' => ['nullable', 'min:1', 'max:255', 'belongsToUser:rule_groups,title'],'trigger' => 'in:store-journal,update-journal,manual-activation',- 'triggers.*.type' => 'required|in:' . implode(',', $validTriggers),- 'triggers.*.value' => 'required_if:actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue|max:1024',+ 'triggers.*.type' => 'required|in:'.implode(',', $validTriggers),+ 'triggers.*.value' => 'required_if:actions.*.type,'.$contextTriggers.'|min:1|ruleTriggerValue|max:1024','triggers.*.stop_processing' => [new IsBoolean()],'triggers.*.active' => [new IsBoolean()],- 'actions.*.type' => 'required|in:' . implode(',', $validActions),+ 'actions.*.type' => 'required|in:'.implode(',', $validActions),'actions.*.value' => [sprintf('required_if:actions.*.type,%s', $contextActions), new IsValidActionExpression(), 'ruleActionValue'],'actions.*.stop_processing' => [new IsBoolean()],'actions.*.active' => [new IsBoolean()],@@ -135,7 +135,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'));}}@@ -148,7 +148,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'));}}@@ -176,7 +176,7 @@ class UpdateRequest extends FormRequest}}if ($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'));}}@@ -203,7 +203,7 @@ class UpdateRequest extends FormRequest}}if ($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'));}}@@ -219,8 +219,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')),];}}diff --git a/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php b/app/Api/V1/Requests/Models/RuleGroup/TestRequest.phpindex b4223e00ff..466b6a6f3b 100644--- a/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php+++ b/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php@@ -65,7 +65,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 bc62a391e4..db4edcb1e4 100644--- a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php+++ b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php@@ -67,7 +67,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/RuleGroup/UpdateRequest.php b/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.phpindex fe9a1d1573..33c737f1b6 100644--- a/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php@@ -65,7 +65,7 @@ class UpdateRequest extends FormRequest$ruleGroup = $this->route()->parameter('ruleGroup');return [- 'title' => 'min:1|max:100|uniqueObjectForUser:rule_groups,title,' . $ruleGroup->id,+ 'title' => 'min:1|max:100|uniqueObjectForUser:rule_groups,title,'.$ruleGroup->id,'description' => ['min:1', 'max:32768', 'nullable'],'active' => [new IsBoolean()],];diff --git a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php b/app/Api/V1/Requests/Models/Tag/UpdateRequest.phpindex ae477e3a3b..c5deb1b95f 100644--- a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Tag/UpdateRequest.php@@ -62,7 +62,7 @@ class UpdateRequest extends FormRequest/** @var Tag $tag */$tag = $this->route()->parameter('tagOrId');$rules = [- 'tag' => 'min:1|max:1024|uniqueObjectForUser:tags,tag,' . $tag->id,+ 'tag' => 'min:1|max:1024|uniqueObjectForUser:tags,tag,'.$tag->id,'description' => ['min:1', 'nullable', 'max:32768'],'date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'],];diff --git a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php b/app/Api/V1/Requests/Models/Transaction/StoreRequest.phpindex 3c9bff30ed..314031af88 100644--- a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php@@ -221,87 +221,87 @@ class StoreRequest extends FormRequestforeach ($this->get('transactions') as $transaction) {$object = new NullArrayObject($transaction);$return[] = [- 'type' => $this->clearString($object['type']),- 'date' => $this->dateFromValue($object['date']),- 'order' => $this->integerFromValue((string)$object['order']),+ 'type' => $this->clearString($object['type']),+ 'date' => $this->dateFromValue($object['date']),+ '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']),// location- 'latitude' => $this->floatFromValue((string)$object['latitude']),- 'longitude' => $this->floatFromValue((string)$object['longitude']),- 'zoom_level' => $this->integerFromValue((string)$object['zoom_level']),+ 'latitude' => $this->floatFromValue((string) $object['latitude']),+ 'longitude' => $this->floatFromValue((string) $object['longitude']),+ 'zoom_level' => $this->integerFromValue((string) $object['zoom_level']),// 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']),- 'process_date' => $this->dateFromValue($object['process_date']),- 'due_date' => $this->dateFromValue($object['due_date']),- 'payment_date' => $this->dateFromValue($object['payment_date']),- 'invoice_date' => $this->dateFromValue($object['invoice_date']),+ 'interest_date' => $this->dateFromValue($object['interest_date']),+ 'book_date' => $this->dateFromValue($object['book_date']),+ 'process_date' => $this->dateFromValue($object['process_date']),+ 'due_date' => $this->dateFromValue($object['due_date']),+ 'payment_date' => $this->dateFromValue($object['payment_date']),+ 'invoice_date' => $this->dateFromValue($object['invoice_date']),];}diff --git a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.phpindex f3aa2c94a9..bc65904add 100644--- a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php@@ -84,8 +84,8 @@ class UpdateRequest extends FormRequest$this->dateFields = ['date', 'interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'];$this->textareaFields = ['notes'];// not really floats, for validation.- $this->floatFields = ['amount', 'foreign_amount', 'longitude', 'latitude'];- $this->stringFields = [+ $this->floatFields = ['amount', 'foreign_amount', 'longitude', 'latitude'];+ $this->stringFields = ['type','currency_code','foreign_currency_code',@@ -114,9 +114,9 @@ class UpdateRequest extends FormRequest'sepa_batch_id','external_url',];- $this->booleanFields = ['reconciled'];- $this->arrayFields = ['tags'];- $data = ['batch_submission' => false];+ $this->booleanFields = ['reconciled'];+ $this->arrayFields = ['tags'];+ $data = ['batch_submission' => false];if ($this->has('transactions')) {$data['transactions'] = $this->getTransactionData();}@@ -281,7 +281,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]);}}@@ -298,7 +298,7 @@ class UpdateRequest extends FormRequestLog::debug(sprintf('Now at date field %s', $fieldName));if (array_key_exists($fieldName, $transaction)) {Log::debug(sprintf('New value: "%s"', $transaction[$fieldName]));- $current[$fieldName] = $this->dateFromValue((string)$transaction[$fieldName]);+ $current[$fieldName] = $this->dateFromValue((string) $transaction[$fieldName]);}}@@ -318,7 +318,7 @@ class UpdateRequest extends FormRequest$current[$fieldName] = sprintf('%.12f', $value);}if (!is_float($value)) {- $current[$fieldName] = (string)$value;+ $current[$fieldName] = (string) $value;}}}@@ -336,7 +336,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]);}}@@ -351,7 +351,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}}@@ -366,7 +366,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]);}}@@ -381,7 +381,7 @@ class UpdateRequest extends FormRequestprivate function getTransactionData(): array{Log::debug(sprintf('Now in %s', __METHOD__));- $return = [];+ $return = [];/** @var null|array $transactions */$transactions = $this->get('transactions');diff --git a/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.phpindex 1646409ebb..5c30faa6d6 100644--- a/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php@@ -50,7 +50,7 @@ class UpdateRequest extends FormRequest$user = auth()->user();$isAdmin = $user->hasRole('owner');- $fields = [+ $fields = ['enabled' => ['enabled', 'boolean'],];if ($isAdmin) {diff --git a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.phpindex 1c1437e587..d6d1db01b0 100644--- a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php+++ b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php@@ -87,21 +87,21 @@ class StoreRequest extends FormRequestprivate function validateExistingLink(Validator $validator): void{/** @var User $user */- $user = auth()->user();+ $user = auth()->user();/** @var LinkTypeRepositoryInterface $repository */- $repository = app(LinkTypeRepositoryInterface::class);+ $repository = app(LinkTypeRepositoryInterface::class);$repository->setUser($user);/** @var JournalRepositoryInterface $journalRepos */$journalRepos = app(JournalRepositoryInterface::class);$journalRepos->setUser($user);- $data = $validator->getData();- $inwardId = (int)($data['inward_id'] ?? 0);- $outwardId = (int)($data['outward_id'] ?? 0);- $inward = $journalRepos->find($inwardId);- $outward = $journalRepos->find($outwardId);+ $data = $validator->getData();+ $inwardId = (int) ($data['inward_id'] ?? 0);+ $outwardId = (int) ($data['outward_id'] ?? 0);+ $inward = $journalRepos->find($inwardId);+ $outward = $journalRepos->find($outwardId);if (null === $inward) {$validator->errors()->add('inward_id', 'Invalid inward ID.');diff --git a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.phpindex 7678c04d38..f4a6743417 100644--- a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php@@ -87,21 +87,21 @@ class UpdateRequest extends FormRequestprivate function validateUpdate(Validator $validator): void{/** @var TransactionJournalLink $existing */- $existing = $this->route()->parameter('journalLink');- $data = $validator->getData();+ $existing = $this->route()->parameter('journalLink');+ $data = $validator->getData();/** @var LinkTypeRepositoryInterface $repository */- $repository = app(LinkTypeRepositoryInterface::class);+ $repository = app(LinkTypeRepositoryInterface::class);$repository->setUser(auth()->user());/** @var JournalRepositoryInterface $journalRepos */$journalRepos = app(JournalRepositoryInterface::class);$journalRepos->setUser(auth()->user());- $inwardId = $data['inward_id'] ?? $existing->source_id;- $outwardId = $data['outward_id'] ?? $existing->destination_id;- $inward = $journalRepos->find((int)$inwardId);- $outward = $journalRepos->find((int)$outwardId);+ $inwardId = $data['inward_id'] ?? $existing->source_id;+ $outwardId = $data['outward_id'] ?? $existing->destination_id;+ $inward = $journalRepos->find((int) $inwardId);+ $outward = $journalRepos->find((int) $outwardId);if (null === $inward) {$inward = $existing->source;}@@ -113,7 +113,7 @@ class UpdateRequest extends FormRequest$validator->errors()->add('outward_id', 'Inward ID must be different from outward ID.');}- $inDB = $repository->findSpecificLink($existing->linkType, $inward, $outward);+ $inDB = $repository->findSpecificLink($existing->linkType, $inward, $outward);if (null === $inDB) {return;}diff --git a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php b/app/Api/V1/Requests/Models/Webhook/CreateRequest.phpindex 610ab2b8db..a4aa6ef879 100644--- a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php+++ b/app/Api/V1/Requests/Models/Webhook/CreateRequest.php@@ -47,10 +47,10 @@ class CreateRequest extends FormRequestpublic function getData(): array{- $fields = ['title' => ['title', 'convertString'], 'active' => ['active', 'boolean'], 'url' => ['url', 'convertString']];- $triggers = $this->get('triggers', []);- $responses = $this->get('responses', []);- $deliveries = $this->get('deliveries', []);+ $fields = ['title' => ['title', 'convertString'], 'active' => ['active', 'boolean'], 'url' => ['url', 'convertString']];+ $triggers = $this->get('triggers', []);+ $responses = $this->get('responses', []);+ $deliveries = $this->get('deliveries', []);if (in_array(0, [count($triggers), count($responses), count($deliveries)], strict: true)) {throw new FireflyException('Unexpectedly got no responses, triggers or deliveries.');diff --git a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.phpindex 90718b9306..0feed24a0d 100644--- a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php@@ -47,11 +47,11 @@ class UpdateRequest extends FormRequestpublic function getData(): array{- $fields = ['title' => ['title', 'convertString'], 'active' => ['active', 'boolean'], 'url' => ['url', 'convertString']];+ $fields = ['title' => ['title', 'convertString'], 'active' => ['active', 'boolean'], 'url' => ['url', 'convertString']];- $triggers = $this->get('triggers', []);- $responses = $this->get('responses', []);- $deliveries = $this->get('deliveries', []);+ $triggers = $this->get('triggers', []);+ $responses = $this->get('responses', []);+ $deliveries = $this->get('deliveries', []);if (in_array(0, [count($triggers), count($responses), count($deliveries)], strict: true)) {throw new FireflyException('Unexpectedly got no responses, triggers or deliveries.');@@ -76,7 +76,7 @@ class UpdateRequest extends FormRequest$validProtocols = AppConfiguration::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data;/** @var Webhook $webhook */- $webhook = $this->route()->parameter('webhook');+ $webhook = $this->route()->parameter('webhook');return ['title' => sprintf('min:1|max:255|uniqueObjectForUser:webhooks,title,%d', $webhook->id),diff --git a/app/Api/V1/Requests/PaginationRequest.php b/app/Api/V1/Requests/PaginationRequest.phpindex 5cf66fad48..cd1f7d7579 100644--- a/app/Api/V1/Requests/PaginationRequest.php+++ b/app/Api/V1/Requests/PaginationRequest.php@@ -49,7 +49,7 @@ class PaginationRequest extends ApiRequestpublic function rules(): array{return [- 'sort' => ['nullable', new IsValidSortInstruction((string)$this->sortClass)],+ 'sort' => ['nullable', new IsValidSortInstruction((string) $this->sortClass)],'limit' => ['numeric', 'min:1', 'max:131337'],'page' => ['numeric', 'min:1', 'max:131337'],];@@ -62,12 +62,12 @@ class PaginationRequest extends ApiRequestreturn;}- $limit = $this->convertInteger('limit');+ $limit = $this->convertInteger('limit');if (0 === $limit) {// get default for user:/** @var User $user */$user = auth()->user();- $limit = (int)Preferences::getForUser($user, 'listPageSize', 50)->data;+ $limit = (int) Preferences::getForUser($user, 'listPageSize', 50)->data;}$page = $this->convertInteger('page');$page = clamp(value: $page, min: 1, max: 2 ** 16);diff --git a/app/Api/V1/Requests/System/UpdateRequest.php b/app/Api/V1/Requests/System/UpdateRequest.phpindex f9d44cff9a..cb01863154 100644--- a/app/Api/V1/Requests/System/UpdateRequest.php+++ b/app/Api/V1/Requests/System/UpdateRequest.php@@ -39,17 +39,16 @@ class UpdateRequest extends FormRequestprotected array $acceptedRoles = [];- private array $booleans- = [- 'configuration.is_demo_site',- 'configuration.single_user_mode',- 'configuration.enable_exchange_rates',- 'configuration.use_running_balance',- 'configuration.enable_external_map',- 'configuration.enable_external_rates',- 'configuration.allow_webhooks',- ];- private array $integers = ['configuration.permission_update_check', 'configuration.last_update_check'];+ private array $booleans = [+ 'configuration.is_demo_site',+ 'configuration.single_user_mode',+ 'configuration.enable_exchange_rates',+ 'configuration.use_running_balance',+ 'configuration.enable_external_map',+ 'configuration.enable_external_rates',+ 'configuration.allow_webhooks',+ ];+ private array $integers = ['configuration.permission_update_check', 'configuration.last_update_check'];/*** Get all data from the request.diff --git a/app/Api/V1/Requests/System/UserUpdateRequest.php b/app/Api/V1/Requests/System/UserUpdateRequest.phpindex ccafd6e5ed..8dd7da01e0 100644--- a/app/Api/V1/Requests/System/UserUpdateRequest.php+++ b/app/Api/V1/Requests/System/UserUpdateRequest.php@@ -95,7 +95,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'));}});if ($validator->fails()) {diff --git a/app/Api/V1/Requests/User/PreferenceStoreRequest.php b/app/Api/V1/Requests/User/PreferenceStoreRequest.phpindex 305193be09..20802fa518 100644--- a/app/Api/V1/Requests/User/PreferenceStoreRequest.php+++ b/app/Api/V1/Requests/User/PreferenceStoreRequest.php@@ -48,7 +48,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 e467d2b86f..8174b2547e 100644--- a/app/Api/V1/Requests/User/PreferenceUpdateRequest.php+++ b/app/Api/V1/Requests/User/PreferenceUpdateRequest.php@@ -48,7 +48,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/Console/Commands/Correction/ClearsEmptyForeignAmounts.php b/app/Console/Commands/Correction/ClearsEmptyForeignAmounts.phpindex 9991315f76..cde8e59c82 100644--- a/app/Console/Commands/Correction/ClearsEmptyForeignAmounts.php+++ b/app/Console/Commands/Correction/ClearsEmptyForeignAmounts.php@@ -38,12 +38,13 @@ class ClearsEmptyForeignAmounts extends Command* @var string*/protected $description = 'Removes references to foreign amounts if there is no amount.';+/*** The name and signature of the console command.** @var string*/- protected $signature = 'correction:clears-empty-foreign-amounts';+ protected $signature = 'correction:clears-empty-foreign-amounts';/*** Execute the console command.diff --git a/app/Console/Commands/Correction/ConvertsDatesToUTC.php b/app/Console/Commands/Correction/ConvertsDatesToUTC.phpindex bf9053c2b5..4fabf8cc3a 100644--- a/app/Console/Commands/Correction/ConvertsDatesToUTC.php+++ b/app/Console/Commands/Correction/ConvertsDatesToUTC.php@@ -63,14 +63,6 @@ class ConvertsDatesToUTC extends Commandreturn Command::SUCCESS;}- private function ConvertModeltoUTC(string $model, array $fields): void- {- /** @var string $field */- foreach ($fields as $field) {- $this->convertFieldtoUTC($model, $field);- }- }-private function convertFieldtoUTC(string $model, string $field): void{$this->info(sprintf('Converting %s.%s to UTC', $model, $field));@@ -92,11 +84,19 @@ class ConvertsDatesToUTC extends Command}$this->friendlyInfo(sprintf('Converting field "%s" of model "%s" to UTC.', $field, $shortModel));$items->each(static function (Model $item) use ($field, $timezoneField): void {- $date = Carbon::parse($item->{$field}, $item->{$timezoneField});+ $date = Carbon::parse($item->{$field}, $item->{$timezoneField});$date->setTimezone('UTC');$item->{$field} = $date->format('Y-m-d H:i:s');$item->{$timezoneField} = 'UTC';$item->save();});}++ private function ConvertModeltoUTC(string $model, array $fields): void+ {+ /** @var string $field */+ foreach ($fields as $field) {+ $this->convertFieldtoUTC($model, $field);+ }+ }}diff --git a/app/Console/Commands/Correction/CorrectsAccountTypes.php b/app/Console/Commands/Correction/CorrectsAccountTypes.phpindex 17a64883aa..8247db585b 100644--- a/app/Console/Commands/Correction/CorrectsAccountTypes.php+++ b/app/Console/Commands/Correction/CorrectsAccountTypes.php@@ -43,11 +43,11 @@ class CorrectsAccountTypes extends Command{use ShowsFriendlyMessages;- protected $description = 'Make sure all journals have the correct from/to account types.';- protected $signature = 'correction:account-types';- private int $count;- private array $expected;- private AccountFactory $factory;+ protected $description = 'Make sure all journals have the correct from/to account types.';+ protected $signature = 'correction:account-types';+ private int $count;+ private array $expected;+ private AccountFactory $factory;private AccountRepositoryInterface $repository;/**@@ -62,17 +62,18 @@ class CorrectsAccountTypes extends Command$this->expected = config('firefly.source_dests');$expected = config('firefly.source_dests');- $query = TransactionJournal::leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')- ->leftJoin('transactions as source', static function (JoinClause $join): void {- $join->on('transaction_journals.id', '=', 'source.transaction_journal_id')->where('source.amount', '<', 0);- })- ->leftJoin('transactions as destination', static function (JoinClause $join): void {- $join->on('transaction_journals.id', '=', 'destination.transaction_journal_id')->where('destination.amount', '>', 0);- })- ->leftJoin('accounts as source_account', 'source.account_id', '=', 'source_account.id')- ->leftJoin('accounts as destination_account', 'destination.account_id', '=', 'destination_account.id')- ->leftJoin('account_types as source_account_type', 'source_account.account_type_id', '=', 'source_account_type.id')- ->leftJoin('account_types as destination_account_type', 'destination_account.account_type_id', '=', 'destination_account_type.id');+ $query = TransactionJournal::leftJoin('transaction_types', 'transaction_journals.transaction_type_id', '=', 'transaction_types.id')+ ->leftJoin('transactions as source', static function (JoinClause $join): void {+ $join->on('transaction_journals.id', '=', 'source.transaction_journal_id')->where('source.amount', '<', 0);+ })+ ->leftJoin('transactions as destination', static function (JoinClause $join): void {+ $join->on('transaction_journals.id', '=', 'destination.transaction_journal_id')->where('destination.amount', '>', 0);+ })+ ->leftJoin('accounts as source_account', 'source.account_id', '=', 'source_account.id')+ ->leftJoin('accounts as destination_account', 'destination.account_id', '=', 'destination_account.id')+ ->leftJoin('account_types as source_account_type', 'source_account.account_type_id', '=', 'source_account_type.id')+ ->leftJoin('account_types as destination_account_type', 'destination_account.account_type_id', '=', 'destination_account_type.id')+ ;// list all valid combinations, those are allowed. So we select those which are broken.$query->where(static function (Builder $q) use ($expected): void {@@ -89,19 +90,19 @@ class CorrectsAccountTypes extends Command}});- $resultSet = $query->get([- 'transaction_journals.id',- // 'transaction_type_id as type_id',- 'transaction_types.type as journal_type',- // 'source.id as source_transaction_id',- // 'source_account.id as source_account_id',- // 'source_account_type.id as source_account_type_id',- 'source_account_type.type as source_account_type',- // 'destination.id as destination_transaction_id',- // 'destination_account.id as destination_account_id',- // 'destination_account_type.id as destination_account_type_id',- 'destination_account_type.type as destination_account_type',- ]);+ $resultSet = $query->get([+ 'transaction_journals.id',+ // 'transaction_type_id as type_id',+ 'transaction_types.type as journal_type',+ // 'source.id as source_transaction_id',+ // 'source_account.id as source_account_id',+ // 'source_account_type.id as source_account_type_id',+ 'source_account_type.type as source_account_type',+ // 'destination.id as destination_transaction_id',+ // 'destination_account.id as destination_account_id',+ // 'destination_account_type.id as destination_account_type_id',+ 'destination_account_type.type as destination_account_type',+ ]);if ($resultSet->count() > 0) {$this->friendlyLine(sprintf('Found %d journals that need to be fixed.', $resultSet->count()));foreach ($resultSet as $entry) {@@ -138,13 +139,13 @@ class CorrectsAccountTypes extends Commandprivate function fixJournal(TransactionJournal $journal, string $transactionType, Transaction $source, Transaction $dest): void{Log::debug(sprintf('Going to fix journal #%d', $journal->id));- $this->repository = app(AccountRepositoryInterface::class);+ $this->repository = app(AccountRepositoryInterface::class);$this->repository->setUser($journal->user);++$this->count;// variables:- $sourceType = $source->account->accountType->type;- $destinationType = $dest->account->accountType->type;- $combination = sprintf('%s%s%s', $transactionType, $source->account->accountType->type, $dest->account->accountType->type);+ $sourceType = $source->account->accountType->type;+ $destinationType = $dest->account->accountType->type;+ $combination = sprintf('%s%s%s', $transactionType, $source->account->accountType->type, $dest->account->accountType->type);Log::debug(sprintf('Combination is "%s"', $combination));if ($this->shouldBeTransfer($transactionType, $sourceType, $destinationType)) {@@ -169,9 +170,9 @@ class CorrectsAccountTypes extends Command}// transaction has no valid source.- $validSources = array_keys($this->expected[$transactionType]);- $canCreateSource = $this->canCreateSource($validSources);- $hasValidSource = $this->hasValidAccountType($validSources, $sourceType);+ $validSources = array_keys($this->expected[$transactionType]);+ $canCreateSource = $this->canCreateSource($validSources);+ $hasValidSource = $this->hasValidAccountType($validSources, $sourceType);if (!$hasValidSource && $canCreateSource) {$this->giveNewRevenue($journal, $source);@@ -254,7 +255,7 @@ class CorrectsAccountTypes extends Command$oldDest = $destTransaction->account;$destTransaction->account_id = $newDestination->id;$destTransaction->save();- $message = sprintf(+ $message = sprintf('Transaction journal #%d, destination account changed from #%d ("%s") to #%d ("%s").',$journal->id,$oldDest->id,@@ -276,12 +277,12 @@ class CorrectsAccountTypes extends Command$destination->account()->associate($newDestination);$destination->save();$this->friendlyPositive(sprintf(- 'Firefly III gave transaction #%d a new destination %s: #%d ("%s").',- $journal->transaction_group_id,- AccountTypeEnum::EXPENSE->value,- $newDestination->id,- $newDestination->name- ));+ 'Firefly III gave transaction #%d a new destination %s: #%d ("%s").',+ $journal->transaction_group_id,+ AccountTypeEnum::EXPENSE->value,+ $newDestination->id,+ $newDestination->name+ ));Log::debug(sprintf('Associated account #%d with transaction #%d', $newDestination->id, $destination->id));$this->inspectJournal($journal);}@@ -295,12 +296,12 @@ class CorrectsAccountTypes extends Command$source->account()->associate($newSource);$source->save();$this->friendlyPositive(sprintf(- 'Firefly III gave transaction #%d a new source %s: #%d ("%s").',- $journal->transaction_group_id,- AccountTypeEnum::REVENUE->value,- $newSource->id,- $newSource->name- ));+ 'Firefly III gave transaction #%d a new source %s: #%d ("%s").',+ $journal->transaction_group_id,+ AccountTypeEnum::REVENUE->value,+ $newSource->id,+ $newSource->name+ ));Log::debug(sprintf('Associated account #%d with transaction #%d', $newSource->id, $source->id));$this->inspectJournal($journal);}@@ -313,7 +314,7 @@ class CorrectsAccountTypes extends Commandprivate function inspectJournal(TransactionJournal $journal): void{Log::debug(sprintf('Now inspecting journal #%d', $journal->id));- $transactions = $journal->transactions()->count();+ $transactions = $journal->transactions()->count();if (2 !== $transactions) {Log::debug(sprintf('Journal has %d transactions, so can\'t fix.', $transactions));$this->friendlyError(sprintf('Cannot inspect transaction journal #%d because it has %d transaction(s) instead of 2.', $journal->id, $transactions));@@ -340,7 +341,7 @@ class CorrectsAccountTypes extends Commandreturn;}- $expectedTypes = $this->expected[$type][$sourceAccountType];+ $expectedTypes = $this->expected[$type][$sourceAccountType];if (!in_array($destAccountType, $expectedTypes, strict: true)) {Log::debug(sprintf('[b] Going to fix journal #%d', $journal->id));$this->fixJournal($journal, $type, $sourceTransaction, $destTransaction);@@ -398,7 +399,7 @@ class CorrectsAccountTypes extends Command$oldSource = $source->account;$source->account()->associate($result);$source->save();- $message = sprintf(+ $message = sprintf('Transaction journal #%d, source account changed from #%d ("%s") to #%d ("%s").',$journal->id,$oldSource->id,@@ -417,7 +418,7 @@ class CorrectsAccountTypes extends Command$withdrawal = TransactionType::whereType(TransactionTypeEnum::WITHDRAWAL->value)->first();$journal->transactionType()->associate($withdrawal);$journal->save();- $message = sprintf('Converted transaction #%d from a transfer to a withdrawal.', $journal->id);+ $message = sprintf('Converted transaction #%d from a transfer to a withdrawal.', $journal->id);$this->friendlyInfo($message);Log::debug($message);// check it again:diff --git a/app/Console/Commands/Correction/CorrectsAmounts.php b/app/Console/Commands/Correction/CorrectsAmounts.phpindex f785157a59..943ce389ec 100644--- a/app/Console/Commands/Correction/CorrectsAmounts.php+++ b/app/Console/Commands/Correction/CorrectsAmounts.php@@ -51,8 +51,8 @@ class CorrectsAmounts extends Command{use ShowsFriendlyMessages;- protected $description = 'This command makes sure positive and negative amounts are recorded correctly.';- protected $signature = 'correction:amounts';+ protected $description = 'This command makes sure positive and negative amounts are recorded correctly.';+ protected $signature = 'correction:amounts';private GenericDestroyService $genericService;private JournalDestroyService $service;@@ -193,17 +193,18 @@ class CorrectsAmounts extends Command$repository = app(AccountRepositoryInterface::class);$type = TransactionType::query()->where('type', TransactionTypeEnum::TRANSFER->value)->first();$journals = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->whereNotNull('transactions.foreign_amount')- ->where('transaction_journals.transaction_type_id', $type->id)- ->distinct()- ->get(['transaction_journals.*']);+ ->whereNotNull('transactions.foreign_amount')+ ->where('transaction_journals.transaction_type_id', $type->id)+ ->distinct()+ ->get(['transaction_journals.*'])+ ;/** @var TransactionJournal $journal */foreach ($journals as $journal) {$repository->setUser($journal->user);- $primary = Amount::getPrimaryCurrencyByUserGroup($journal->userGroup);+ $primary = Amount::getPrimaryCurrencyByUserGroup($journal->userGroup);- $valid = $this->validateJournal($journal);+ $valid = $this->validateJournal($journal);if (false === $valid) {// Log::debug(sprintf('Journal #%d does not need to be fixed or is invalid (see previous messages)', $journal->id));@@ -221,8 +222,8 @@ class CorrectsAmounts extends Commandif ($sourceCurrency->id === $destCurrency->id) {Log::debug('Both accounts have the same currency. Removing foreign currency info.');- $source->foreign_currency_id = null;- $source->foreign_amount = null;+ $source->foreign_currency_id = null;+ $source->foreign_amount = null;$source->save();$destination->foreign_currency_id = null;$destination->foreign_amount = null;@@ -234,23 +235,23 @@ class CorrectsAmounts extends Command// validate source transactionif ($destCurrency->id !== $source->foreign_currency_id) {Log::debug(sprintf(- '[a] Journal #%d: transaction #%d refers to foreign currency "%s" but should refer to "%s".',- $journal->id,- $source->id,- $source->foreignCurrency->code,- $destCurrency->code- ));+ '[a] Journal #%d: transaction #%d refers to foreign currency "%s" but should refer to "%s".',+ $journal->id,+ $source->id,+ $source->foreignCurrency->code,+ $destCurrency->code+ ));$source->foreign_currency_id = $destCurrency->id;$source->save();}if ($sourceCurrency->id !== $source->transaction_currency_id) {Log::debug(sprintf(- '[b] Journal #%d: transaction #%d refers to currency "%s" but should refer to "%s".',- $journal->id,- $source->id,- $source->transactionCurrency->code,- $sourceCurrency->code- ));+ '[b] Journal #%d: transaction #%d refers to currency "%s" but should refer to "%s".',+ $journal->id,+ $source->id,+ $source->transactionCurrency->code,+ $sourceCurrency->code+ ));$source->transaction_currency_id = $sourceCurrency->id;$source->save();}@@ -258,24 +259,24 @@ class CorrectsAmounts extends Command// validate destination:if ($sourceCurrency->id !== $destination->foreign_currency_id) {Log::debug(sprintf(- '[c] Journal #%d: transaction #%d refers to foreign currency "%s" but should refer to "%s".',- $journal->id,- $destination->id,- $destination->foreignCurrency->code,- $sourceCurrency->code- ));+ '[c] Journal #%d: transaction #%d refers to foreign currency "%s" but should refer to "%s".',+ $journal->id,+ $destination->id,+ $destination->foreignCurrency->code,+ $sourceCurrency->code+ ));$destination->foreign_currency_id = $sourceCurrency->id;$destination->save();}if ($destCurrency->id !== $destination->transaction_currency_id) {Log::debug(sprintf(- '[d] Journal #%d: transaction #%d refers to currency "%s" but should refer to "%s".',- $journal->id,- $destination->id,- $destination->transactionCurrency->code,- $destCurrency->code- ));+ '[d] Journal #%d: transaction #%d refers to currency "%s" but should refer to "%s".',+ $journal->id,+ $destination->id,+ $destination->transactionCurrency->code,+ $destCurrency->code+ ));$destination->transaction_currency_id = $destCurrency->id;$destination->save();}@@ -291,8 +292,9 @@ class CorrectsAmounts extends Commandprivate function fixAutoBudgets(): void{$count = AutoBudget::query()- ->where('amount', '<', 0)- ->update(['amount' => DB::raw('amount * -1')]);+ ->where('amount', '<', 0)+ ->update(['amount' => DB::raw('amount * -1')])+ ;if (0 === $count) {return;}@@ -302,8 +304,9 @@ class CorrectsAmounts extends Commandprivate function fixAvailableBudgets(): void{$count = AvailableBudget::query()- ->where('amount', '<', 0)- ->update(['amount' => DB::raw('amount * -1')]);+ ->where('amount', '<', 0)+ ->update(['amount' => DB::raw('amount * -1')])+ ;if (0 === $count) {return;}@@ -314,11 +317,13 @@ class CorrectsAmounts extends Command{$count = 0;$count += Bill::query()- ->where('amount_max', '<', 0)- ->update(['amount_max' => DB::raw('amount_max * -1')]);+ ->where('amount_max', '<', 0)+ ->update(['amount_max' => DB::raw('amount_max * -1')])+ ;$count += Bill::query()- ->where('amount_min', '<', 0)- ->update(['amount_min' => DB::raw('amount_min * -1')]);+ ->where('amount_min', '<', 0)+ ->update(['amount_min' => DB::raw('amount_min * -1')])+ ;if (0 === $count) {return;}@@ -328,8 +333,9 @@ class CorrectsAmounts extends Commandprivate function fixBudgetLimits(): void{$count = BudgetLimit::query()- ->where('amount', '<', 0)- ->update(['amount' => DB::raw('amount * -1')]);+ ->where('amount', '<', 0)+ ->update(['amount' => DB::raw('amount * -1')])+ ;if (0 === $count) {return;}@@ -339,8 +345,9 @@ class CorrectsAmounts extends Commandprivate function fixExchangeRates(): void{$count = CurrencyExchangeRate::query()- ->where('rate', '<', 0)- ->update(['rate' => DB::raw('rate * -1')]);+ ->where('rate', '<', 0)+ ->update(['rate' => DB::raw('rate * -1')])+ ;if (0 === $count) {return;}@@ -350,8 +357,9 @@ class CorrectsAmounts extends Commandprivate function fixPiggyBanks(): void{$count = PiggyBank::query()- ->where('target_amount', '<', 0)- ->update(['target_amount' => DB::raw('target_amount * -1')]);+ ->where('target_amount', '<', 0)+ ->update(['target_amount' => DB::raw('target_amount * -1')])+ ;if (0 === $count) {return;}@@ -362,11 +370,13 @@ class CorrectsAmounts extends Command{$count = 0;$count += RecurrenceTransaction::query()- ->where('amount', '<', 0)- ->update(['amount' => DB::raw('amount * -1')]);+ ->where('amount', '<', 0)+ ->update(['amount' => DB::raw('amount * -1')])+ ;$count += RecurrenceTransaction::query()- ->where('foreign_amount', '<', 0)- ->update(['foreign_amount' => DB::raw('foreign_amount * -1')]);+ ->where('foreign_amount', '<', 0)+ ->update(['foreign_amount' => DB::raw('foreign_amount * -1')])+ ;if (0 === $count) {return;}@@ -376,14 +386,14 @@ class CorrectsAmounts extends Commandprivate function fixRuleTrigger(RuleTrigger $item): bool{try {- $check = bccomp((string)$item->trigger_value, '0');+ $check = bccomp((string) $item->trigger_value, '0');} catch (ValueError) {$this->friendlyError(sprintf(- 'Rule #%d contained invalid %s-trigger "%s". The trigger has been removed, and the rule is disabled.',- $item->rule_id,- $item->trigger_type,- $item->trigger_value- ));+ 'Rule #%d contained invalid %s-trigger "%s". The trigger has been removed, and the rule is disabled.',+ $item->rule_id,+ $item->trigger_type,+ $item->trigger_value+ ));$item->rule->active = false;$item->rule->save();$this->genericService->deleteRuleTrigger($item);@@ -423,8 +433,8 @@ class CorrectsAmounts extends Commandprivate function validateJournal(TransactionJournal $journal): bool{- $countSource = $journal->transactions()->where('amount', '<', 0)->count();- $countDest = $journal->transactions()->where('amount', '>', 0)->count();+ $countSource = $journal->transactions()->where('amount', '<', 0)->count();+ $countDest = $journal->transactions()->where('amount', '>', 0)->count();if (1 !== $countSource || 1 !== $countDest) {$this->friendlyError(sprintf('Transaction journal #%d has bad transaction information. Will delete.', $journal->id));@@ -435,10 +445,10 @@ class CorrectsAmounts extends Command}/** @var null|Transaction $source */- $source = $journal->transactions()->where('amount', '<', 0)->first();+ $source = $journal->transactions()->where('amount', '<', 0)->first();/** @var null|Transaction $destination */- $destination = $journal->transactions()->where('amount', '>', 0)->first();+ $destination = $journal->transactions()->where('amount', '>', 0)->first();if (null === $source || null === $destination) {$this->friendlyError(sprintf('Could not find source OR destination for journal #%d .', $journal->id));@@ -454,7 +464,7 @@ class CorrectsAmounts extends Command}if (null === $source->foreign_amount || null === $destination->foreign_amount) {$this->friendlyError(sprintf('Transactions of journal #%d have no foreign amount, but have foreign currency info. Will reset this.', $journal->id));- $source->foreign_currency_id = null;+ $source->foreign_currency_id = null;$source->save();$destination->foreign_currency_id = null;$source->save();diff --git a/app/Console/Commands/Correction/CorrectsCurrencies.php b/app/Console/Commands/Correction/CorrectsCurrencies.phpindex f1181729db..21a46ba24b 100644--- a/app/Console/Commands/Correction/CorrectsCurrencies.php+++ b/app/Console/Commands/Correction/CorrectsCurrencies.php@@ -61,58 +61,60 @@ class CorrectsCurrencies extends Commandprivate function correctCurrencies(UserGroup $userGroup): void{/** @var CurrencyRepositoryInterface $repos */- $repos = app(CurrencyRepositoryInterface::class);+ $repos = app(CurrencyRepositoryInterface::class);// first check if the user has any default currency (not necessarily the case, so can be forced).$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($userGroup);Log::debug(sprintf('Now correcting currencies for user group #%d', $userGroup->id));- $found = [$primaryCurrency->id];+ $found = [$primaryCurrency->id];// get all meta entries- $meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')- ->where('accounts.user_group_id', $userGroup->id)- ->where('account_meta.name', 'currency_id')- ->groupBy('data')- ->get(['data']);+ $meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')+ ->where('accounts.user_group_id', $userGroup->id)+ ->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:- $journals = TransactionJournal::query()->where('user_group_id', $userGroup->id)->groupBy('transaction_currency_id')->get(['transaction_currency_id']);+ $journals = TransactionJournal::query()->where('user_group_id', $userGroup->id)->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- $transactions = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')- ->where('transaction_journals.user_group_id', $userGroup->id)- ->groupBy('transactions.transaction_currency_id', 'transactions.foreign_currency_id')- ->get(['transactions.transaction_currency_id', 'transactions.foreign_currency_id']);+ $transactions = Transaction::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')+ ->where('transaction_journals.user_group_id', $userGroup->id)+ ->groupBy('transactions.transaction_currency_id', 'transactions.foreign_currency_id')+ ->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 limits- $limits = BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')->groupBy('transaction_currency_id')->get([- 'budget_limits.transaction_currency_id',- ]);+ $limits = BudgetLimit::leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id')->groupBy('transaction_currency_id')->get([+ 'budget_limits.transaction_currency_id',+ ]);foreach ($limits as $entry) {$found[] = $entry->transaction_currency_id;}// also get all currencies already enabled.- $alreadyEnabled = $userGroup->currencies()->get(['transaction_currencies.id'])->pluck('id')->toArray();+ $alreadyEnabled = $userGroup->currencies()->get(['transaction_currencies.id'])->pluck('id')->toArray();foreach ($alreadyEnabled as $currencyId) {$found[] = $currencyId;}- $found = array_values(array_unique($found));- $found = array_values(array_filter($found, static fn(int $currencyId): bool => 0 !== $currencyId));+ $found = array_values(array_unique($found));+ $found = array_values(array_filter($found, static fn (int $currencyId): bool => 0 !== $currencyId));- $valid = new Collection();+ $valid = new Collection();/** @var int $currencyId */foreach ($found as $currencyId) {@@ -121,7 +123,7 @@ class CorrectsCurrencies extends Command$valid->push($currency);}}- $ids = $valid->pluck('id')->toArray();+ $ids = $valid->pluck('id')->toArray();Log::debug(sprintf('Found currencies for user group #%d: %s', $userGroup->id, implode(', ', $ids)));$userGroup->currencies()->sync($ids);diff --git a/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php b/app/Console/Commands/Correction/CorrectsFrontpageAccounts.phpindex 6c8105b29e..56b4a83ec2 100644--- a/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php+++ b/app/Console/Commands/Correction/CorrectsFrontpageAccounts.php@@ -59,7 +59,7 @@ class CorrectsFrontpageAccounts extends Commandprivate function fixPreference(Preference $preference): void{- $fixed = [];+ $fixed = [];/** @var AccountRepositoryInterface $repository */$repository = app(AccountRepositoryInterface::class);@@ -67,11 +67,11 @@ class CorrectsFrontpageAccounts extends Commandreturn;}$repository->setUser($preference->user);- $data = $preference->data;+ $data = $preference->data;if (is_array($data)) {/** @var string $accountId */foreach ($data as $accountId) {- $accountIdInt = (int)$accountId;+ $accountIdInt = (int) $accountId;$account = $repository->find($accountIdInt);if (null !== $accountdiff --git a/app/Console/Commands/Correction/CorrectsGroupAccounts.php b/app/Console/Commands/Correction/CorrectsGroupAccounts.phpindex 66a2a3c023..51968680e6 100644--- a/app/Console/Commands/Correction/CorrectsGroupAccounts.php+++ b/app/Console/Commands/Correction/CorrectsGroupAccounts.php@@ -48,16 +48,16 @@ class CorrectsGroupAccounts extends Commandpublic function handle(): int{Log::debug('Start of correction:group-accounts');- $groups = [];- $res = TransactionJournal::query()->groupBy('transaction_group_id')->get([- 'transaction_group_id',- DB::raw('COUNT(transaction_group_id) as the_count'),- ]);+ $groups = [];+ $res = TransactionJournal::query()->groupBy('transaction_group_id')->get([+ 'transaction_group_id',+ DB::raw('COUNT(transaction_group_id) as the_count'),+ ]);/** @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;}}$flags = new TransactionGroupEventFlags();diff --git a/app/Console/Commands/Correction/CorrectsGroupInformation.php b/app/Console/Commands/Correction/CorrectsGroupInformation.phpindex d2698d8ff6..ddb2a400ef 100644--- a/app/Console/Commands/Correction/CorrectsGroupInformation.php+++ b/app/Console/Commands/Correction/CorrectsGroupInformation.php@@ -79,7 +79,7 @@ class CorrectsGroupInformation extends Commandreturn;}- $set = [+ $set = [Account::class,Attachment::class,AvailableBudget::class,@@ -113,11 +113,11 @@ class CorrectsGroupInformation extends Command}if (0 !== $result) {$this->friendlyPositive(sprintf(- 'User #%d: Moved %d %s objects to the correct group.',- $user->id,- $result,- str_replace('FireflyIII\Models\\', '', $className)- ));+ 'User #%d: Moved %d %s objects to the correct group.',+ $user->id,+ $result,+ str_replace('FireflyIII\Models\\', '', $className)+ ));}}}diff --git a/app/Console/Commands/Correction/CorrectsIbans.php b/app/Console/Commands/Correction/CorrectsIbans.phpindex 58fb8f3399..4c7e6e571e 100644--- a/app/Console/Commands/Correction/CorrectsIbans.php+++ b/app/Console/Commands/Correction/CorrectsIbans.php@@ -35,9 +35,9 @@ class CorrectsIbans extends Command{use ShowsFriendlyMessages;- protected $description = 'Removes spaces from IBANs';- protected $signature = 'correction:ibans';- private int $count = 0;+ protected $description = 'Removes spaces from IBANs';+ protected $signature = 'correction:ibans';+ private int $count = 0;/*** Execute the console command.@@ -57,13 +57,13 @@ class CorrectsIbans extends Command/** @var Account $account */foreach ($accounts as $account) {- $userId = $account->user_id;+ $userId = $account->user_id;$set[$userId] ??= [];- $iban = (string)$account->iban;+ $iban = (string) $account->iban;if ('' === $iban) {continue;}- $type = $account->accountType->type;+ $type = $account->accountType->type;if (in_array($type, [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value], true)) {$type = 'liabilities';}@@ -80,12 +80,12 @@ class CorrectsIbans extends Command}if ($showWarningAndCorrect) {$this->friendlyWarning(sprintf(- 'IBAN "%s" is used more than once and will be removed from %s #%d ("%s")',- $iban,- $account->accountType->type,- $account->id,- $account->name- ));+ 'IBAN "%s" is used more than once and will be removed from %s #%d ("%s")',+ $iban,+ $account->accountType->type,+ $account->id,+ $account->name+ ));$account->iban = null;$account->save();++$this->count;@@ -101,8 +101,8 @@ class CorrectsIbans extends Command{/** @var Account $account */foreach ($accounts as $account) {- $iban = (string)$account->iban;- $newIban = Steam::filterSpaces($iban);+ $iban = (string) $account->iban;+ $newIban = Steam::filterSpaces($iban);if ('' !== $iban && $iban !== $newIban) {$account->iban = $newIban;$account->save();@@ -112,7 +112,7 @@ class CorrectsIbans extends Command// same for account number:$accountNumber = $account->accountMeta->where('name', 'account_number')->first();if (null !== $accountNumber) {- $number = (string)$accountNumber->value;+ $number = (string) $accountNumber->value;$newNumber = Steam::filterSpaces($number);if ('' !== $number && $number !== $newNumber) {$accountNumber->value = $newNumber;diff --git a/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.php b/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.phpindex 25575c3efc..07ec7253b9 100644--- a/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.php+++ b/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.php@@ -40,12 +40,13 @@ class CorrectsInvertedBudgetLimits extends Command* @var string*/protected $description = 'Reverse budget limits where the dates are inverted.';+/*** The name and signature of the console command.** @var string*/- protected $signature = 'correction:corrects-inverted-budget-limits';+ protected $signature = 'correction:corrects-inverted-budget-limits';/*** Execute the console command.diff --git a/app/Console/Commands/Correction/CorrectsLongDescriptions.php b/app/Console/Commands/Correction/CorrectsLongDescriptions.phpindex 26b0e9b7f2..c57c4eb1c6 100644--- a/app/Console/Commands/Correction/CorrectsLongDescriptions.php+++ b/app/Console/Commands/Correction/CorrectsLongDescriptions.php@@ -36,8 +36,8 @@ class CorrectsLongDescriptions extends Commandprivate const int MAX_LENGTH = 1000;- protected $description = 'Fixes long descriptions in journals and groups.';- protected $signature = 'correction:long-descriptions';+ protected $description = 'Fixes long descriptions in journals and groups.';+ protected $signature = 'correction:long-descriptions';/*** Execute the console command.@@ -49,20 +49,20 @@ class CorrectsLongDescriptions extends Command/** @var TransactionJournal $journal */foreach ($journals as $journal) {- if (strlen((string)$journal->description) > self::MAX_LENGTH) {- $journal->description = substr((string)$journal->description, 0, self::MAX_LENGTH);+ if (strlen((string) $journal->description) > self::MAX_LENGTH) {+ $journal->description = substr((string) $journal->description, 0, self::MAX_LENGTH);$journal->save();$this->friendlyWarning(sprintf('Truncated description of transaction journal #%d', $journal->id));++$count;}}- $groups = TransactionGroup::query()->where(DB::raw('LENGTH(title)'), '>', self::MAX_LENGTH)->get(['id', 'title']);+ $groups = TransactionGroup::query()->where(DB::raw('LENGTH(title)'), '>', self::MAX_LENGTH)->get(['id', 'title']);/** @var TransactionGroup $group */foreach ($groups as $group) {- if (strlen((string)$group->title) > self::MAX_LENGTH) {- $group->title = substr((string)$group->title, 0, self::MAX_LENGTH);+ if (strlen((string) $group->title) > self::MAX_LENGTH) {+ $group->title = substr((string) $group->title, 0, self::MAX_LENGTH);$group->save();$this->friendlyWarning(sprintf('Truncated description of transaction group #%d', $group->id));++$count;diff --git a/app/Console/Commands/Correction/CorrectsMetaDataFields.php b/app/Console/Commands/Correction/CorrectsMetaDataFields.phpindex 20293ea17f..82adce9563 100644--- a/app/Console/Commands/Correction/CorrectsMetaDataFields.php+++ b/app/Console/Commands/Correction/CorrectsMetaDataFields.php@@ -35,7 +35,7 @@ class CorrectsMetaDataFields extends Commandprotected $description = 'Rename changed meta fields.';protected $signature = 'correction:meta-fields';- private int $count = 0;+ private int $count = 0;/*** Execute the console command.@@ -68,7 +68,7 @@ class CorrectsMetaDataFields extends Commandprivate function rename(string $original, string $update): void{- $total = DB::table('journal_meta')->where('name', '=', $original)->update(['name' => $update]);+ $total = DB::table('journal_meta')->where('name', '=', $original)->update(['name' => $update]);$this->count += $total;}}diff --git a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.phpindex 619ffc00f4..7160a488ba 100644--- a/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php+++ b/app/Console/Commands/Correction/CorrectsOpeningBalanceCurrencies.php@@ -110,19 +110,20 @@ class CorrectsOpeningBalanceCurrencies extends Command{/** @var Collection */return TransactionJournal::leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')- ->whereNull('transaction_journals.deleted_at')- ->where('transaction_types.type', TransactionTypeEnum::OPENING_BALANCE->value)- ->get(['transaction_journals.*']);+ ->whereNull('transaction_journals.deleted_at')+ ->where('transaction_types.type', TransactionTypeEnum::OPENING_BALANCE->value)+ ->get(['transaction_journals.*'])+ ;}private function setCorrectCurrency(Account $account, TransactionJournal $journal): int{$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;+ $count = 1;}/** @var Transaction $transaction */@@ -130,7 +131,7 @@ class CorrectsOpeningBalanceCurrencies extends Commandif ($transaction->transaction_currency_id !== $currency->id) {$transaction->transaction_currency_id = $currency->id;$transaction->save();- $count = 1;+ $count = 1;}}diff --git a/app/Console/Commands/Correction/CorrectsPreferences.php b/app/Console/Commands/Correction/CorrectsPreferences.phpindex 10615fb8c6..8113234e31 100644--- a/app/Console/Commands/Correction/CorrectsPreferences.php+++ b/app/Console/Commands/Correction/CorrectsPreferences.php@@ -33,7 +33,7 @@ class CorrectsPreferences extends Command{protected $description = 'Give Firefly III preferences a user group ID so they can be made administration specific.';- protected $signature = 'correction:preferences';+ protected $signature = 'correction:preferences';/*** Execute the console command.diff --git a/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php b/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.phpindex 38e67c0cd1..e635dc9961 100644--- a/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php+++ b/app/Console/Commands/Correction/CorrectsPrimaryCurrencyAmounts.php@@ -36,7 +36,7 @@ class CorrectsPrimaryCurrencyAmounts extends Commandprotected $description = 'Recalculate primary currency amounts for all objects.';- protected $signature = 'correction:recalculate-pc-amounts';+ protected $signature = 'correction:recalculate-pc-amounts';/*** Execute the console command.diff --git a/app/Console/Commands/Correction/CorrectsRecurringTransactions.php b/app/Console/Commands/Correction/CorrectsRecurringTransactions.phpindex b91de2eb36..afbd042833 100644--- a/app/Console/Commands/Correction/CorrectsRecurringTransactions.php+++ b/app/Console/Commands/Correction/CorrectsRecurringTransactions.php@@ -37,11 +37,11 @@ class CorrectsRecurringTransactions extends Command{use ShowsFriendlyMessages;- protected $description = 'Fixes recurring transactions with the wrong transaction type.';- protected $signature = 'correction:recurring-transactions';- private int $count = 0;+ protected $description = 'Fixes recurring transactions with the wrong transaction type.';+ protected $signature = 'correction:recurring-transactions';+ private int $count = 0;private RecurringRepositoryInterface $recurringRepos;- private UserRepositoryInterface $userRepos;+ private UserRepositoryInterface $userRepos;/*** Execute the console command.@@ -78,13 +78,13 @@ class CorrectsRecurringTransactions extends Command$destination = $transaction->destinationAccount;$type = $recurrence->transactionType;$link = config(sprintf('firefly.account_to_transaction.%s.%s', $source->accountType->type, $destination->accountType->type));- if (null !== $link && strtolower((string)$type->type) !== strtolower($link)) {+ if (null !== $link && strtolower((string) $type->type) !== strtolower($link)) {$this->friendlyWarning(sprintf(- 'Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.',- $recurrence->id,- $link,- $type->type- ));+ 'Recurring transaction #%d should be a "%s" but is a "%s" and will be corrected.',+ $recurrence->id,+ $link,+ $type->type+ ));$transactionType = TransactionType::whereType($link)->first();if (null !== $transactionType) {$recurrence->transaction_type_id = $transactionType->id;diff --git a/app/Console/Commands/Correction/CorrectsTimezoneInformation.php b/app/Console/Commands/Correction/CorrectsTimezoneInformation.phpindex 3a6faee97f..d35b4b50d4 100644--- a/app/Console/Commands/Correction/CorrectsTimezoneInformation.php+++ b/app/Console/Commands/Correction/CorrectsTimezoneInformation.php@@ -45,23 +45,22 @@ class CorrectsTimezoneInformation extends Command{use ShowsFriendlyMessages;- public static array $models- = [- 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'],- ];+ public static array $models = [+ 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 $description = 'Make sure all dates have a timezone.';- protected $signature = 'correction:timezones';+ protected $description = 'Make sure all dates have a timezone.';+ protected $signature = 'correction:timezones';/*** Execute the console command.diff --git a/app/Console/Commands/Correction/CorrectsTransactionTypes.php b/app/Console/Commands/Correction/CorrectsTransactionTypes.phpindex 5f50ae577d..6c900f6f3a 100644--- a/app/Console/Commands/Correction/CorrectsTransactionTypes.php+++ b/app/Console/Commands/Correction/CorrectsTransactionTypes.php@@ -86,7 +86,7 @@ class CorrectsTransactionTypes extends Commandprivate function fixJournal(TransactionJournal $journal): bool{- $type = $journal->transactionType->type;+ $type = $journal->transactionType->type;try {$source = $this->getSourceAccount($journal);@@ -96,16 +96,16 @@ class CorrectsTransactionTypes 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(- 'Transaction journal #%d was of type "%s" but is corrected to "%s" (%s -> %s)',- $journal->id,- $type,- $expectedType,- $source->accountType->type,- $destination->accountType->type- ));+ 'Transaction journal #%d was of type "%s" but is corrected to "%s" (%s -> %s)',+ $journal->id,+ $type,+ $expectedType,+ $source->accountType->type,+ $destination->accountType->type+ ));$this->changeJournal($journal, $expectedType);return true;@@ -119,7 +119,7 @@ class CorrectsTransactionTypes extends Command*/private function getDestinationAccount(TransactionJournal $journal): Account{- $collection = $journal->transactions->filter(static fn(Transaction $transaction): bool => $transaction->amount > 0);+ $collection = $journal->transactions->filter(static fn (Transaction $transaction): bool => $transaction->amount > 0);if (0 === $collection->count()) {throw new FireflyException(sprintf('300004: Journal #%d has no destination transaction.', $journal->id));}@@ -131,7 +131,7 @@ class CorrectsTransactionTypes extends Command$transaction = $collection->first();/** @var null|Account $account */- $account = $transaction->account;+ $account = $transaction->account;if (null === $account) {throw new FireflyException(sprintf('300006: Journal #%d, transaction #%d has no destination account.', $journal->id, $transaction->id));}@@ -144,7 +144,7 @@ class CorrectsTransactionTypes extends Command*/private function getSourceAccount(TransactionJournal $journal): Account{- $collection = $journal->transactions->filter(static fn(Transaction $transaction): bool => $transaction->amount < 0);+ $collection = $journal->transactions->filter(static fn (Transaction $transaction): bool => $transaction->amount < 0);if (0 === $collection->count()) {throw new FireflyException(sprintf('300001: Journal #%d has no source transaction.', $journal->id));}@@ -156,7 +156,7 @@ class CorrectsTransactionTypes extends Command$transaction = $collection->first();/** @var null|Account $account */- $account = $transaction->account;+ $account = $transaction->account;if (null === $account) {throw new FireflyException(sprintf('300003: Journal #%d, transaction #%d has no source account.', $journal->id, $transaction->id));}diff --git a/app/Console/Commands/Correction/CorrectsTransferBudgets.php b/app/Console/Commands/Correction/CorrectsTransferBudgets.phpindex 4521827a87..7eabfa372b 100644--- a/app/Console/Commands/Correction/CorrectsTransferBudgets.php+++ b/app/Console/Commands/Correction/CorrectsTransferBudgets.php@@ -43,12 +43,13 @@ class CorrectsTransferBudgets extends Commandpublic function handle(): int{$set = TransactionJournal::query()- ->distinct()- ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')- ->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')- ->whereNotIn('transaction_types.type', [TransactionTypeEnum::WITHDRAWAL->value])- ->whereNotNull('budget_transaction_journal.budget_id')- ->get(['transaction_journals.*']);+ ->distinct()+ ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id')+ ->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id')+ ->whereNotIn('transaction_types.type', [TransactionTypeEnum::WITHDRAWAL->value])+ ->whereNotNull('budget_transaction_journal.budget_id')+ ->get(['transaction_journals.*'])+ ;$count = 0;/** @var TransactionJournal $entry */diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.phpindex b658e53ebc..5bbdf0845b 100644--- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php+++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php@@ -43,8 +43,8 @@ class CorrectsUnevenAmount extends Command{use ShowsFriendlyMessages;- protected $description = 'Fix journals with uneven amounts.';- protected $signature = 'correction:uneven-amounts';+ protected $description = 'Fix journals with uneven amounts.';+ protected $signature = 'correction:uneven-amounts';private int $count;/**@@ -73,30 +73,31 @@ class CorrectsUnevenAmount extends Commandprivate function convertOldStyleTransactions(): void{/** @var AccountRepositoryInterface $repository */- $repository = app(AccountRepositoryInterface::class);+ $repository = app(AccountRepositoryInterface::class);Log::debug('convertOldStyleTransactions()');$count = 0;$transactions = Transaction::query()- ->distinct()- ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')- ->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')- ->leftJoin('accounts', 'accounts.id', 'transactions.account_id')- ->leftJoin('account_types', 'account_types.id', 'accounts.account_type_id')- ->whereNot('transaction_types.type', TransactionTypeEnum::TRANSFER->value)- ->whereNotNull('foreign_currency_id')- ->whereNotNull('foreign_amount')- ->whereIn('account_types.type', [- AccountTypeEnum::ASSET->value,- AccountTypeEnum::DEBT->value,- AccountTypeEnum::MORTGAGE->value,- AccountTypeEnum::LOAN->value,- ])- ->get(['transactions.transaction_journal_id']);+ ->distinct()+ ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id')+ ->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id')+ ->leftJoin('accounts', 'accounts.id', 'transactions.account_id')+ ->leftJoin('account_types', 'account_types.id', 'accounts.account_type_id')+ ->whereNot('transaction_types.type', TransactionTypeEnum::TRANSFER->value)+ ->whereNotNull('foreign_currency_id')+ ->whereNotNull('foreign_amount')+ ->whereIn('account_types.type', [+ AccountTypeEnum::ASSET->value,+ AccountTypeEnum::DEBT->value,+ AccountTypeEnum::MORTGAGE->value,+ AccountTypeEnum::LOAN->value,+ ])+ ->get(['transactions.transaction_journal_id'])+ ;/** @var Transaction $transaction */foreach ($transactions as $transaction) {/** @var null|TransactionJournal $journal */- $journal = TransactionJournal::find($transaction->transaction_journal_id);+ $journal = TransactionJournal::find($transaction->transaction_journal_id);$repository->setUser($journal->user);if (null === $journal) {Log::debug('Found no journal, continue.');@@ -120,15 +121,15 @@ class CorrectsUnevenAmount extends Commandcontinue;}if (- 0 === bccomp((string)$source->amount, (string)$source->foreign_amount)- && 0 === bccomp((string)$source->foreign_amount, (string)$source->amount)+ 0 === bccomp((string) $source->amount, (string) $source->foreign_amount)+ && 0 === bccomp((string) $source->foreign_amount, (string) $source->amount)) {Log::debug('Already fixed, continue.');continue;}// source transaction. Switch info when does not match.- if ((int)$source->transaction_currency_id !== (int)$sourceCurrency->id) {+ if ((int) $source->transaction_currency_id !== (int) $sourceCurrency->id) {Log::debug(sprintf('Ready to swap data in transaction #%d.', $source->id));// swap amounts.$amount = $source->amount;@@ -146,7 +147,7 @@ class CorrectsUnevenAmount extends Command++$count;}// same but for destination- if ((int)$destination->transaction_currency_id !== (int)$destCurrency->id) {+ if ((int) $destination->transaction_currency_id !== (int) $destCurrency->id) {++$count;Log::debug(sprintf('Ready to swap data in transaction #%d.', $destination->id));// swap amounts.@@ -189,19 +190,20 @@ class CorrectsUnevenAmount extends CommandLog::debug('convertOldStyleTransfers()');// select transactions with a foreign amount and a foreign currency. and it's a transfer. and they are different.$transactions = Transaction::query()- ->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']);+ ->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;/** @var Transaction $transaction */foreach ($transactions as $transaction) {/** @var null|TransactionJournal $journal */- $journal = TransactionJournal::find($transaction->transaction_journal_id);+ $journal = TransactionJournal::find($transaction->transaction_journal_id);if (null === $journal) {Log::debug('Found no journal, continue.');@@ -218,7 +220,7 @@ class CorrectsUnevenAmount extends Command$destination = $journal->transactions()->where('amount', '>', 0)->first();/** @var null|Transaction $source */- $source = $journal->transactions()->where('amount', '<', 0)->first();+ $source = $journal->transactions()->where('amount', '<', 0)->first();if (null === $destination || null === $source) {Log::debug('Source or destination transaction is NULL, continue.');@@ -248,50 +250,54 @@ class CorrectsUnevenAmount extends Commandprivate function fixJournal(int $param): void{// one of the transactions is bad.- $journal = TransactionJournal::find($param);+ $journal = TransactionJournal::find($param);if (null === $journal) {return;}/** @var null|Transaction $source */- $source = $journal->transactions()->where('amount', '<', 0)->first();+ $source = $journal->transactions()->where('amount', '<', 0)->first();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 ?? ''- ));+ 'Journal #%d ("%s") has no source transaction. It will be deleted to maintain database consistency.',+ $journal->id ?? 0,+ $journal->description ?? ''+ ));Transaction::query()- ->where('transaction_journal_id', $journal->id ?? 0)- ->forceDelete();+ ->where('transaction_journal_id', $journal->id ?? 0)+ ->forceDelete()+ ;TransactionJournal::query()- ->where('id', $journal->id ?? 0)- ->forceDelete();+ ->where('id', $journal->id ?? 0)+ ->forceDelete()+ ;++$this->count;return;}- $amount = bcmul('-1', (string)$source->amount);+ $amount = bcmul('-1', (string) $source->amount);// fix amount of destination:/** @var null|Transaction $destination */- $destination = $journal->transactions()->where('amount', '>', 0)->first();+ $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 ?? ''- ));+ 'Journal #%d ("%s") has no destination transaction. It will be deleted to maintain database consistency.',+ $journal->id ?? 0,+ $journal->description ?? ''+ ));Transaction::query()- ->where('transaction_journal_id', $journal->id ?? 0)- ->forceDelete();+ ->where('transaction_journal_id', $journal->id ?? 0)+ ->forceDelete()+ ;TransactionJournal::query()- ->where('id', $journal->id ?? 0)- ->forceDelete();+ ->where('id', $journal->id ?? 0)+ ->forceDelete()+ ;++$this->count;return;@@ -304,7 +310,7 @@ class CorrectsUnevenAmount extends Commandreturn;}- $message = sprintf('Sum of journal #%d is not zero, journal is broken and now fixed.', $journal->id);+ $message = sprintf('Sum of journal #%d is not zero, journal is broken and now fixed.', $journal->id);$this->friendlyWarning($message);Log::warning($message);@@ -312,7 +318,7 @@ class CorrectsUnevenAmount extends Command$destination->amount = $amount;$destination->save();- $message = sprintf('Corrected amount in transaction journal #%d', $param);+ $message = sprintf('Corrected amount in transaction journal #%d', $param);$this->friendlyInfo($message);++$this->count;}@@ -321,13 +327,14 @@ class CorrectsUnevenAmount extends Command{Log::debug('fixUnevenAmounts()');$journals = DB::table('transactions')- ->groupBy('transaction_journal_id')- ->whereNull('deleted_at')- ->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')]);+ ->groupBy('transaction_journal_id')+ ->whereNull('deleted_at')+ ->get(['transaction_journal_id', DB::raw('SUM(amount) AS the_sum')])+ ;/** @var stdClass $entry */foreach ($journals as $entry) {- $sum = (string)$entry->the_sum;+ $sum = (string) $entry->the_sum;$sum = Steam::floatalize($sum);if (!is_numeric($sum) || str_contains($sum, 'e') || str_contains($sum, ',')) {$message = sprintf('Journal #%d has an invalid sum ("%s"). No sure what to do.', $entry->transaction_journal_id, $entry->the_sum);@@ -347,7 +354,7 @@ class CorrectsUnevenAmount extends CommandLog::error($e->getTraceAsString());}if (0 !== $res) {- $this->fixJournal((int)$entry->transaction_journal_id);+ $this->fixJournal((int) $entry->transaction_journal_id);}}}@@ -355,7 +362,7 @@ class CorrectsUnevenAmount extends Commandprivate function isBetweenAssetAndLiability(TransactionJournal $journal): bool{/** @var null|Transaction $sourceTransaction */- $sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();+ $sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();/** @var null|Transaction $destinationTransaction */$destinationTransaction = $journal->transactions()->where('amount', '>', 0)->first();@@ -370,15 +377,15 @@ class CorrectsUnevenAmount extends Commandreturn false;}- $source = $sourceTransaction->account;- $destination = $destinationTransaction->account;+ $source = $sourceTransaction->account;+ $destination = $destinationTransaction->account;if (null === $source || null === $destination) {Log::warning('Either is false, stop.');return false;}- $sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];+ $sourceTypes = [AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];// source is liability, destination is assetif (in_array($source->accountType->type, $sourceTypes, true) && AccountTypeEnum::ASSET->value === $destination->accountType->type) {@@ -406,7 +413,7 @@ class CorrectsUnevenAmount extends Command$destination = $journal->transactions()->where('amount', '>', 0)->first();/** @var Transaction $source */- $source = $journal->transactions()->where('amount', '<', 0)->first();+ $source = $journal->transactions()->where('amount', '<', 0)->first();// safety catch on NULL should not be necessary, we just had that catch.// source amount = dest foreign amount@@ -421,7 +428,7 @@ class CorrectsUnevenAmount extends Command0 === bccomp(Steam::positive($source->amount), Steam::positive($destination->foreign_amount))&& $source->transaction_currency_id === $destination->foreign_currency_id&& 0 === bccomp(Steam::positive($destination->amount), Steam::positive($source->foreign_amount))- && (int)$destination->transaction_currency_id === (int)$source->foreign_currency_id;+ && (int) $destination->transaction_currency_id === (int) $source->foreign_currency_id;}private function matchCurrencies(): void@@ -432,7 +439,7 @@ class CorrectsUnevenAmount extends CommandDB::raw('transaction_journals.transaction_currency_id'))->get(['transaction_journals.*']);- $count = 0;+ $count = 0;/** @var TransactionJournal $journal */foreach ($journals as $journal) {diff --git a/app/Console/Commands/Correction/CreatesAccessTokens.php b/app/Console/Commands/Correction/CreatesAccessTokens.phpindex d4f4e632a2..47b6d96201 100644--- a/app/Console/Commands/Correction/CreatesAccessTokens.php+++ b/app/Console/Commands/Correction/CreatesAccessTokens.php@@ -37,7 +37,7 @@ class CreatesAccessTokens extends Commandprotected $description = 'Creates user access tokens which are used for command line access to personal data.';- protected $signature = 'correction:access-tokens';+ protected $signature = 'correction:access-tokens';/*** Execute the console command.@@ -50,8 +50,8 @@ class CreatesAccessTokens extends Command/** @var UserRepositoryInterface $repository */$repository = app(UserRepositoryInterface::class);- $count = 0;- $users = $repository->all();+ $count = 0;+ $users = $repository->all();/** @var User $user */foreach ($users as $user) {diff --git a/app/Console/Commands/Correction/CreatesGroupMemberships.php b/app/Console/Commands/Correction/CreatesGroupMemberships.phpindex 557e5996f7..9b5d9976a5 100644--- a/app/Console/Commands/Correction/CreatesGroupMemberships.php+++ b/app/Console/Commands/Correction/CreatesGroupMemberships.php@@ -39,8 +39,8 @@ class CreatesGroupMemberships extends Commandpublic const string CONFIG_NAME = '560_create_group_memberships';- protected $description = 'Update group memberships';- protected $signature = 'correction:create-group-memberships';+ protected $description = 'Update group memberships';+ protected $signature = 'correction:create-group-memberships';/*** TODO move to helper.@@ -50,21 +50,22 @@ class CreatesGroupMemberships extends Commandpublic static function createGroupMembership(User $user): void{// check if membership exists- $userGroup = UserGroup::query()->where('title', $user->email)->first();+ $userGroup = UserGroup::query()->where('title', $user->email)->first();if (null === $userGroup) {$userGroup = UserGroup::create(['title' => $user->email]);}- $userRole = UserRole::query()->where('title', UserRoleEnum::OWNER->value)->first();+ $userRole = UserRole::query()->where('title', UserRoleEnum::OWNER->value)->first();if (null === $userRole) {throw new FireflyException('Firefly III could not find a user role. Please make sure all migrations have run.');}$membership = GroupMembership::query()- ->where('user_id', $user->id)- ->where('user_group_id', $userGroup->id)- ->where('user_role_id', $userRole->id)- ->first();+ ->where('user_id', $user->id)+ ->where('user_group_id', $userGroup->id)+ ->where('user_role_id', $userRole->id)+ ->first()+ ;if (null === $membership) {GroupMembership::create(['user_id' => $user->id, 'user_role_id' => $userRole->id, 'user_group_id' => $userGroup->id]);}diff --git a/app/Console/Commands/Correction/CreatesLinkTypes.php b/app/Console/Commands/Correction/CreatesLinkTypes.phpindex 6aab976053..7aa9098c60 100644--- a/app/Console/Commands/Correction/CreatesLinkTypes.php+++ b/app/Console/Commands/Correction/CreatesLinkTypes.php@@ -34,7 +34,7 @@ class CreatesLinkTypes extends Commandprotected $description = 'Creates all link types.';- protected $signature = 'correction:link-types';+ protected $signature = 'correction:link-types';/*** Execute the console command.@@ -49,7 +49,7 @@ class CreatesLinkTypes extends Command'Reimbursement' => ['(partially) reimburses', 'is (partially) reimbursed by'],];foreach ($set as $name => $values) {- $link = LinkType::query()->where('name', $name)->first();+ $link = LinkType::query()->where('name', $name)->first();if (null === $link) {$link = new LinkType();$link->name = $name;diff --git a/app/Console/Commands/Correction/RemovesBills.php b/app/Console/Commands/Correction/RemovesBills.phpindex 2bd992482b..7fd46bd5d8 100644--- a/app/Console/Commands/Correction/RemovesBills.php+++ b/app/Console/Commands/Correction/RemovesBills.php@@ -47,7 +47,7 @@ class RemovesBills extends Commandif (null === $withdrawal) {return 0;}- $journals = TransactionJournal::query()->whereNotNull('bill_id')->where('transaction_type_id', '!=', $withdrawal->id)->get();+ $journals = TransactionJournal::query()->whereNotNull('bill_id')->where('transaction_type_id', '!=', $withdrawal->id)->get();/** @var TransactionJournal $journal */foreach ($journals as $journal) {diff --git a/app/Console/Commands/Correction/RemovesEmptyGroups.php b/app/Console/Commands/Correction/RemovesEmptyGroups.phpindex 2f428fce21..018c5d80a0 100644--- a/app/Console/Commands/Correction/RemovesEmptyGroups.php+++ b/app/Console/Commands/Correction/RemovesEmptyGroups.php@@ -44,12 +44,13 @@ class RemovesEmptyGroups extends Commandpublic function handle(): int{$groupIds = TransactionGroup::leftJoin('transaction_journals', 'transaction_groups.id', '=', 'transaction_journals.transaction_group_id')- ->whereNull('transaction_journals.id')- ->get(['transaction_groups.id'])- ->pluck('id')- ->toArray();+ ->whereNull('transaction_journals.id')+ ->get(['transaction_groups.id'])+ ->pluck('id')+ ->toArray()+ ;- $total = count($groupIds);+ $total = count($groupIds);if ($total > 0) {$this->friendlyInfo(sprintf('Deleted %d empty transaction group(s).', $total));diff --git a/app/Console/Commands/Correction/RemovesEmptyJournals.php b/app/Console/Commands/Correction/RemovesEmptyJournals.phpindex eb659df7c1..df4ea15ca8 100644--- a/app/Console/Commands/Correction/RemovesEmptyJournals.php+++ b/app/Console/Commands/Correction/RemovesEmptyJournals.php@@ -38,7 +38,7 @@ class RemovesEmptyJournals extends Commandprotected $description = 'Delete empty and uneven transaction journals.';- protected $signature = 'correction:empty-journals';+ protected $signature = 'correction:empty-journals';/*** Execute the console command.@@ -55,9 +55,10 @@ class RemovesEmptyJournals extends Command{$count = 0;$set = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->groupBy('transaction_journals.id')- ->whereNull('transactions.transaction_journal_id')- ->get(['transaction_journals.id']);+ ->groupBy('transaction_journals.id')+ ->whereNull('transactions.transaction_journal_id')+ ->get(['transaction_journals.id'])+ ;foreach ($set as $entry) {try {@@ -80,17 +81,18 @@ class RemovesEmptyJournals extends Commandprivate function deleteUnevenJournals(): void{$set = Transaction::query()- ->whereNull('deleted_at')- ->groupBy('transactions.transaction_journal_id')- ->get([- DB::raw('COUNT(transactions.transaction_journal_id) as the_count'),- 'transaction_journal_id',- ]);+ ->whereNull('deleted_at')+ ->groupBy('transactions.transaction_journal_id')+ ->get([+ DB::raw('COUNT(transactions.transaction_journal_id) as the_count'),+ 'transaction_journal_id',+ ])+ ;$total = 0;/** @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 {@@ -104,9 +106,9 @@ class RemovesEmptyJournals extends CommandTransaction::query()->where('transaction_journal_id', $row->transaction_journal_id)->delete();$this->friendlyWarning(sprintf(- 'Deleted transaction journal #%d because it had an uneven number of transactions.',- $row->transaction_journal_id- ));+ 'Deleted transaction journal #%d because it had an uneven number of transactions.',+ $row->transaction_journal_id+ ));++$total;}}diff --git a/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php b/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.phpindex 92f2b8313e..1dda1ce34d 100644--- a/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php+++ b/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php@@ -44,12 +44,13 @@ class RemovesLinksToDeletedObjects extends Command* @var string*/protected $description = 'Removes deleted entries from intermediate tables.';+/*** The name and signature of the console command.** @var string*/- protected $signature = 'correction:remove-links-to-deleted-objects';+ protected $signature = 'correction:remove-links-to-deleted-objects';/*** Execute the console command.@@ -57,29 +58,33 @@ class RemovesLinksToDeletedObjects extends Commandpublic function handle(): void{$deletedTags = Tag::query()- ->withTrashed()- ->whereNotNull('deleted_at')- ->get('tags.id')- ->pluck('id')- ->toArray();+ ->withTrashed()+ ->whereNotNull('deleted_at')+ ->get('tags.id')+ ->pluck('id')+ ->toArray()+ ;$deletedJournals = TransactionJournal::query()- ->withTrashed()- ->whereNotNull('deleted_at')- ->get('transaction_journals.id')- ->pluck('id')- ->toArray();+ ->withTrashed()+ ->whereNotNull('deleted_at')+ ->get('transaction_journals.id')+ ->pluck('id')+ ->toArray()+ ;$deletedBudgets = Budget::query()- ->withTrashed()- ->whereNotNull('deleted_at')- ->get('budgets.id')- ->pluck('id')- ->toArray();+ ->withTrashed()+ ->whereNotNull('deleted_at')+ ->get('budgets.id')+ ->pluck('id')+ ->toArray()+ ;$deletedCategories = Category::query()- ->withTrashed()- ->whereNotNull('deleted_at')- ->get('categories.id')- ->pluck('id')- ->toArray();+ ->withTrashed()+ ->whereNotNull('deleted_at')+ ->get('categories.id')+ ->pluck('id')+ ->toArray()+ ;if (count($deletedTags) > 0) {$this->cleanupTags($deletedTags);@@ -97,7 +102,7 @@ class RemovesLinksToDeletedObjects extends Command// count and clean up available budgets in currencies with no budget limits.// this is not entirely the place for it but OK./** @var AvailableBudgetRepositoryInterface $repository */- $repository = app(AvailableBudgetRepositoryInterface::class);+ $repository = app(AvailableBudgetRepositoryInterface::class);/** @var User $user */foreach (User::get() as $user) {diff --git a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php b/app/Console/Commands/Correction/RemovesOrphanedTransactions.phpindex 21235d700d..8f088b43d0 100644--- a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php+++ b/app/Console/Commands/Correction/RemovesOrphanedTransactions.php@@ -40,7 +40,7 @@ class RemovesOrphanedTransactions extends Commandprotected $description = 'Deletes orphaned transactions.';- protected $signature = 'correction:orphaned-transactions';+ protected $signature = 'correction:orphaned-transactions';/*** Execute the console command.@@ -69,10 +69,10 @@ class RemovesOrphanedTransactions extends Command$journal?->delete();Transaction::query()->where('transaction_journal_id', $transaction->transaction_journal_id)->delete();$this->friendlyWarning(sprintf(- 'Deleted transaction journal #%d because account #%d was already deleted.',- $transaction->transaction_journal_id,- $transaction->account_id- ));+ 'Deleted transaction journal #%d because account #%d was already deleted.',+ $transaction->transaction_journal_id,+ $transaction->account_id+ ));++$count;}}@@ -80,9 +80,10 @@ class RemovesOrphanedTransactions extends Commandprivate function deleteOrphanedJournals(): void{$set = TransactionJournal::leftJoin('transaction_groups', 'transaction_journals.transaction_group_id', 'transaction_groups.id')- ->whereNotNull('transaction_groups.deleted_at')- ->whereNull('transaction_journals.deleted_at')- ->get(['transaction_journals.id', 'transaction_journals.transaction_group_id']);+ ->whereNotNull('transaction_groups.deleted_at')+ ->whereNull('transaction_journals.deleted_at')+ ->get(['transaction_journals.id', 'transaction_journals.transaction_group_id'])+ ;$count = $set->count();if (0 === $count) {// $this->friendlyPositive('No orphaned journals.');@@ -96,10 +97,10 @@ class RemovesOrphanedTransactions extends Commandif (null !== $journal) {$journal->delete();$this->friendlyWarning(sprintf(- 'Journal #%d (part of deleted transaction group #%d) has been deleted as well.',- $entry->id,- $entry->transaction_group_id- ));+ 'Journal #%d (part of deleted transaction group #%d) has been deleted as well.',+ $entry->id,+ $entry->transaction_group_id+ ));}}}@@ -111,21 +112,22 @@ class RemovesOrphanedTransactions extends Command{$count = 0;$set = Transaction::leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->whereNotNull('transaction_journals.deleted_at')- ->whereNull('transactions.deleted_at')- ->whereNotNull('transactions.id')- ->get(['transaction_journals.id as journal_id', 'transactions.id as transaction_id']);+ ->whereNotNull('transaction_journals.deleted_at')+ ->whereNull('transactions.deleted_at')+ ->whereNotNull('transactions.id')+ ->get(['transaction_journals.id as journal_id', 'transactions.id as transaction_id'])+ ;/** @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(sprintf(- 'Transaction #%d (part of deleted transaction journal #%d) has been deleted as well.',- $entry->transaction_id,- $entry->journal_id- ));+ 'Transaction #%d (part of deleted transaction journal #%d) has been deleted as well.',+ $entry->transaction_id,+ $entry->journal_id+ ));++$count;}}diff --git a/app/Console/Commands/Correction/RemovesZeroAmount.php b/app/Console/Commands/Correction/RemovesZeroAmount.phpindex b339816dd8..c7d19f59c5 100644--- a/app/Console/Commands/Correction/RemovesZeroAmount.php+++ b/app/Console/Commands/Correction/RemovesZeroAmount.php@@ -35,7 +35,7 @@ class RemovesZeroAmount extends Commandprotected $description = 'Delete transactions with zero amount.';- protected $signature = 'correction:zero-amounts';+ protected $signature = 'correction:zero-amounts';/*** Execute the console command.diff --git a/app/Console/Commands/Correction/RestoresOAuthKeys.php b/app/Console/Commands/Correction/RestoresOAuthKeys.phpindex 5f2832a508..c7a9657707 100644--- a/app/Console/Commands/Correction/RestoresOAuthKeys.php+++ b/app/Console/Commands/Correction/RestoresOAuthKeys.php@@ -29,6 +29,7 @@ use FireflyIII\Support\System\OAuthKeys;use Illuminate\Console\Command;use Illuminate\Support\Facades\Log;use Laravel\Passport\Passport;+use function Safe\chmod;class RestoresOAuthKeys extends Commanddiff --git a/app/Console/Commands/Correction/RollbacksSingleMigration.php b/app/Console/Commands/Correction/RollbacksSingleMigration.phpindex ca500e5a29..c7a455b005 100644--- a/app/Console/Commands/Correction/RollbacksSingleMigration.php+++ b/app/Console/Commands/Correction/RollbacksSingleMigration.php@@ -38,12 +38,13 @@ class RollbacksSingleMigration extends Command* @var string*/protected $description = 'Removes the last entry from the migration table. ';+/*** The name and signature of the console command.** @var string*/- protected $signature = 'correction:rollback-single-migration {--force}';+ protected $signature = 'correction:rollback-single-migration {--force}';/*** Execute the console command.@@ -67,7 +68,7 @@ class RollbacksSingleMigration extends Command$this->friendlyLine('');$this->friendlyLine('If this doesn\'t work, run the command a few times to remove more rows and try "php artisan migrate" again.');$this->friendlyLine('');- $res = true;+ $res = true;if (!$this->option('force')) {$this->friendlyWarning('Use this command at your own risk.');$res = $this->confirm('Are you sure you want to continue?');@@ -75,8 +76,9 @@ class RollbacksSingleMigration extends Commandif ($res) {DB::table('migrations')- ->where('id', (int)$entry->id)- ->delete();+ ->where('id', (int) $entry->id)+ ->delete()+ ;$this->friendlyInfo(sprintf('Database migration #%d ("%s") is deleted.', $entry->id, $entry->migration));$this->friendlyLine('');$this->friendlyLine('Try running "php artisan migrate" now.');diff --git a/app/Console/Commands/Explain/ExplainAvailableBudget.php b/app/Console/Commands/Explain/ExplainAvailableBudget.phpindex 2309f12457..9ff754af8d 100644--- a/app/Console/Commands/Explain/ExplainAvailableBudget.php+++ b/app/Console/Commands/Explain/ExplainAvailableBudget.php@@ -41,12 +41,13 @@ class ExplainAvailableBudget extends Command* @var string*/protected $description = 'Explains why the available budget amount is what it is.';+/*** The name and signature of the console command.** @var string*/- protected $signature = 'explain:available-budget+ protected $signature = 'explain:available-budget{--date=now : A date formatted YYYY-MM-DD or the word "now"}{--user=1 : The user ID.}{--token= : The user\'s access token.}@@ -57,16 +58,16 @@ class ExplainAvailableBudget extends Command*/public function handle(): int{- $date = $this->getDate((string)$this->option('date'));+ $date = $this->getDate((string) $this->option('date'));$range = Preferences::getForUser($this->getUser(), 'viewRange', '1M')->data ?? '1M';$title = Navigation::periodShow($date, $range);$this->line('This command explains why the "available" budget bar at the top of your /budget bar means.');$this->line(sprintf(- 'You submitted date %s and your settings show a %s period, so this explanation concerns the period "%s".',- $date->format('Y-m-d'),- $range,- $title- ));+ 'You submitted date %s and your settings show a %s period, so this explanation concerns the period "%s".',+ $date->format('Y-m-d'),+ $range,+ $title+ ));return Command::SUCCESS;}diff --git a/app/Console/Commands/Export/ExportsData.php b/app/Console/Commands/Export/ExportsData.phpindex 1bc87fb53e..736ae1f882 100644--- a/app/Console/Commands/Export/ExportsData.php+++ b/app/Console/Commands/Export/ExportsData.php@@ -40,6 +40,7 @@ use Illuminate\Support\Collection;use Illuminate\Support\Facades\Log;use InvalidArgumentException;use Safe\Exceptions\FilesystemException;+use function Safe\file_put_contents;class ExportsData extends Command@@ -49,7 +50,7 @@ class ExportsData extends Commandprotected $description = 'Command to export data from Firefly III.';- protected $signature = 'firefly-iii:export-data+ protected $signature = 'firefly-iii:export-data{--user=1 : The user ID that the export should run for.}{--token= : The user\'s access token.}{--start= : First transaction to export. Defaults to your very first transaction. Only applies to transaction export.}@@ -84,7 +85,7 @@ class ExportsData extends Command}// set up repositories.$this->stupidLaravel();- $user = $this->getUser();+ $user = $this->getUser();$this->journalRepository->setUser($user);$this->accountRepository->setUser($user);@@ -99,7 +100,7 @@ class ExportsData extends Command// make export object and configure it./** @var ExportDataGenerator $exporter */- $exporter = app(ExportDataGenerator::class);+ $exporter = app(ExportDataGenerator::class);$exporter->setUser($user);$exporter->setStart($options['start']);@@ -114,7 +115,7 @@ class ExportsData extends Command$exporter->setExportRules($options['export']['rules']);$exporter->setExportBills($options['export']['bills']);$exporter->setExportPiggies($options['export']['piggies']);- $data = $exporter->export();+ $data = $exporter->export();if (0 === count($data)) {$this->friendlyError('You must export *something*. Use --export-transactions or another option. See docs.firefly-iii.org');}@@ -160,7 +161,7 @@ class ExportsData extends Command{$final = new Collection();$accounts = new Collection();- $accountList = (string)$this->option('accounts');+ $accountList = (string) $this->option('accounts');$types = [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value];if ('' !== $accountList) {$accountIds = explode(',', $accountList);@@ -242,7 +243,7 @@ class ExportsData 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/ReportsEmptyObjects.php b/app/Console/Commands/Integrity/ReportsEmptyObjects.phpindex 1dbae20f63..2dda07a5e2 100644--- a/app/Console/Commands/Integrity/ReportsEmptyObjects.php+++ b/app/Console/Commands/Integrity/ReportsEmptyObjects.php@@ -38,7 +38,7 @@ class ReportsEmptyObjects extends Commandprotected $description = 'Reports on empty database objects.';- protected $signature = 'integrity:empty-objects';+ protected $signature = 'integrity:empty-objects';/*** Execute the console command.@@ -60,10 +60,11 @@ class ReportsEmptyObjects extends Commandprivate function reportAccounts(): void{$set = Account::leftJoin('transactions', 'transactions.account_id', '=', 'accounts.id')- ->leftJoin('users', 'accounts.user_id', '=', 'users.id')- ->groupBy(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email'])- ->whereNull('transactions.account_id')- ->get(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email']);+ ->leftJoin('users', 'accounts.user_id', '=', 'users.id')+ ->groupBy(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email'])+ ->whereNull('transactions.account_id')+ ->get(['accounts.id', 'accounts.encrypted', 'accounts.name', 'accounts.user_id', 'users.email'])+ ;/** @var stdClass $entry */foreach ($set as $entry) {@@ -79,10 +80,11 @@ class ReportsEmptyObjects extends Commandprivate function reportBudgetLimits(): void{$set = Budget::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id')- ->leftJoin('users', 'budgets.user_id', '=', 'users.id')- ->groupBy(['budgets.id', 'budgets.name', 'budgets.encrypted', 'budgets.user_id', 'users.email'])- ->whereNull('budget_limits.id')- ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'budgets.encrypted', 'users.email']);+ ->leftJoin('users', 'budgets.user_id', '=', 'users.id')+ ->groupBy(['budgets.id', 'budgets.name', 'budgets.encrypted', 'budgets.user_id', 'users.email'])+ ->whereNull('budget_limits.id')+ ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'budgets.encrypted', 'users.email'])+ ;/** @var Budget $entry */foreach ($set as $entry) {@@ -97,11 +99,12 @@ class ReportsEmptyObjects extends Commandprivate function reportEmptyBudgets(): void{$set = Budget::leftJoin('budget_transaction_journal', 'budgets.id', '=', 'budget_transaction_journal.budget_id')- ->leftJoin('users', 'budgets.user_id', '=', 'users.id')- ->distinct()- ->whereNull('budget_transaction_journal.budget_id')- ->whereNull('budgets.deleted_at')- ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email']);+ ->leftJoin('users', 'budgets.user_id', '=', 'users.id')+ ->distinct()+ ->whereNull('budget_transaction_journal.budget_id')+ ->whereNull('budgets.deleted_at')+ ->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email'])+ ;/** @var stdClass $entry */foreach ($set as $entry) {@@ -116,11 +119,12 @@ class ReportsEmptyObjects extends Commandprivate function reportEmptyCategories(): void{$set = Category::leftJoin('category_transaction_journal', 'categories.id', '=', 'category_transaction_journal.category_id')- ->leftJoin('users', 'categories.user_id', '=', 'users.id')- ->distinct()- ->whereNull('category_transaction_journal.category_id')- ->whereNull('categories.deleted_at')- ->get(['categories.id', 'categories.name', 'categories.user_id', 'users.email']);+ ->leftJoin('users', 'categories.user_id', '=', 'users.id')+ ->distinct()+ ->whereNull('category_transaction_journal.category_id')+ ->whereNull('categories.deleted_at')+ ->get(['categories.id', 'categories.name', 'categories.user_id', 'users.email'])+ ;/** @var stdClass $entry */foreach ($set as $entry) {@@ -132,11 +136,12 @@ class ReportsEmptyObjects extends Commandprivate function reportEmptyTags(): void{$set = Tag::leftJoin('tag_transaction_journal', 'tags.id', '=', 'tag_transaction_journal.tag_id')- ->leftJoin('users', 'tags.user_id', '=', 'users.id')- ->distinct()- ->whereNull('tag_transaction_journal.tag_id')- ->whereNull('tags.deleted_at')- ->get(['tags.id', 'tags.tag', 'tags.user_id', 'users.email']);+ ->leftJoin('users', 'tags.user_id', '=', 'users.id')+ ->distinct()+ ->whereNull('tag_transaction_journal.tag_id')+ ->whereNull('tags.deleted_at')+ ->get(['tags.id', 'tags.tag', 'tags.user_id', 'users.email'])+ ;/** @var stdClass $entry */foreach ($set as $entry) {diff --git a/app/Console/Commands/Integrity/ReportsIntegrity.php b/app/Console/Commands/Integrity/ReportsIntegrity.phpindex dabee7ebb3..6f66b89df1 100644--- a/app/Console/Commands/Integrity/ReportsIntegrity.php+++ b/app/Console/Commands/Integrity/ReportsIntegrity.php@@ -34,7 +34,7 @@ class ReportsIntegrity extends Commandprotected $description = 'Will report on the integrity of your database.';- protected $signature = 'firefly-iii:report-integrity';+ protected $signature = 'firefly-iii:report-integrity';/*** Execute the console command.diff --git a/app/Console/Commands/Integrity/ReportsSums.php b/app/Console/Commands/Integrity/ReportsSums.phpindex 1e137d778e..3ebf1d7fc6 100644--- a/app/Console/Commands/Integrity/ReportsSums.php+++ b/app/Console/Commands/Integrity/ReportsSums.php@@ -57,8 +57,8 @@ class ReportsSums extends Command/** @var User $user */foreach ($userRepository->all() as $user) {- $sum = (string)$user->transactions()->selectRaw('SUM(amount) as total')->value('total');- $foreign = (string)$user->transactions()->selectRaw('SUM(foreign_amount) as total')->value('total');+ $sum = (string) $user->transactions()->selectRaw('SUM(amount) as total')->value('total');+ $foreign = (string) $user->transactions()->selectRaw('SUM(foreign_amount) as total')->value('total');$sum = '' === $sum ? '0' : $sum;$foreign = '' === $foreign ? '0' : $foreign;$sum = Steam::floatalize($sum);diff --git a/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.php b/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.phpindex b469072955..d77b8ff2a6 100644--- a/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.php+++ b/app/Console/Commands/Integrity/ValidatesEnvironmentVariables.php@@ -71,9 +71,9 @@ class ValidatesEnvironmentVariables extends Commandprivate function validateLanguage(): bool{- $language = config('firefly.default_language');- $locale = config('firefly.default_locale');- $options = array_keys(config('firefly.languages'));+ $language = config('firefly.default_language');+ $locale = config('firefly.default_locale');+ $options = array_keys(config('firefly.languages'));if (!in_array($language, $options, true)) {$this->friendlyError(sprintf('DEFAULT_LANGUAGE "%s" is not a valid language for Firefly III.', $language));@@ -96,7 +96,7 @@ class ValidatesEnvironmentVariables extends Commandprivate function validateStaticToken(): bool{- $token = (string)config('firefly.static_cron_token');+ $token = (string) config('firefly.static_cron_token');if ('' !== $token && 32 !== strlen($token)) {$this->friendlyError('STATIC_CRON_TOKEN must be empty or a 32-character string.');$this->friendlyError('Please check your .env file and make sure you use a valid setting.');diff --git a/app/Console/Commands/Integrity/ValidatesFilePermissions.php b/app/Console/Commands/Integrity/ValidatesFilePermissions.phpindex 36420f16e4..4ea2711541 100644--- a/app/Console/Commands/Integrity/ValidatesFilePermissions.php+++ b/app/Console/Commands/Integrity/ValidatesFilePermissions.php@@ -38,12 +38,13 @@ class ValidatesFilePermissions extends Command* @var string*/protected $description = 'Command description';+/*** The name and signature of the console command.** @var string*/- protected $signature = 'integrity:file-permissions';+ protected $signature = 'integrity:file-permissions';/*** Execute the console command.@@ -61,7 +62,7 @@ class ValidatesFilePermissions extends Command$message = sprintf('Directory "%s" cannot found. It is necessary to allow files to be uploaded.', $directory);Log::error($message);$this->friendlyError($message);- $errors = true;+ $errors = true;continue;}@@ -70,7 +71,7 @@ class ValidatesFilePermissions extends Command$message = sprintf('Directory "%s" is not writeable. Uploading attachments may fail silently.', $directory);$this->friendlyError($message);Log::error($message);- $errors = true;+ $errors = true;}Log::debug('It is writeable!');Log::debug(sprintf('Done processing %s', $directory));diff --git a/app/Console/Commands/SendTestEmail.php b/app/Console/Commands/SendTestEmail.phpindex a5f072435b..ba86efb483 100644--- a/app/Console/Commands/SendTestEmail.php+++ b/app/Console/Commands/SendTestEmail.php@@ -40,12 +40,13 @@ class SendTestEmail extends Command* @var string*/protected $description = 'Send test email';+/*** The name and signature of the console command.** @var string*/- protected $signature = 'firefly-iii:send-test-email+ protected $signature = 'firefly-iii:send-test-email{--user=1 : The user ID.}{--token= : The user\'s access token.}';@@ -54,9 +55,9 @@ class SendTestEmail extends Command*/public function handle(): int{- $user = $this->getUser();+ $user = $this->getUser();if (!$user->hasRole('owner')) {- $this->friendlyError((string)trans('firefly.must_be_owner'));+ $this->friendlyError((string) trans('firefly.must_be_owner'));return Command::FAILURE;}@@ -64,12 +65,12 @@ class SendTestEmail extends Command/** @var int $lastNotification */$lastNotification = AppConfiguration::get('last_test_notification', 123)->data;if ((time() - $lastNotification) < 120) {- $this->friendlyError((string)trans('firefly.test_rate_limited'));+ $this->friendlyError((string) trans('firefly.test_rate_limited'));return Command::FAILURE;}- $owner = new OwnerNotifiable();+ $owner = new OwnerNotifiable();event(new OwnerTestsNotificationChannel('email', $owner));AppConfiguration::set('last_test_notification', time());diff --git a/app/Console/Commands/System/CreatesDatabase.php b/app/Console/Commands/System/CreatesDatabase.phpindex f186cf80d0..d6a8e28752 100644--- a/app/Console/Commands/System/CreatesDatabase.php+++ b/app/Console/Commands/System/CreatesDatabase.php@@ -37,7 +37,7 @@ class CreatesDatabase extends Commandprotected $description = 'Tries to create the database if it doesn\'t exist yet.';- protected $signature = 'firefly-iii:create-database';+ protected $signature = 'firefly-iii:create-database';public function handle(): int{@@ -53,15 +53,15 @@ class CreatesDatabase extends Commandreturn 0;}// try to set up a raw connection:- $exists = false;- $dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', config('database.connections.mysql.host'), config('database.connections.mysql.port'));+ $exists = false;+ $dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', config('database.connections.mysql.host'), config('database.connections.mysql.port'));- if ('' !== (string)config('database.connections.mysql.unix_socket')) {+ if ('' !== (string) config('database.connections.mysql.unix_socket')) {$dsn = sprintf('mysql:unix_socket=%s;charset=utf8mb4', config('database.connections.mysql.unix_socket'));}$this->friendlyLine(sprintf('DSN is %s', $dsn));- $options = [+ $options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,PDO::ATTR_EMULATE_PREPARES => false,@@ -69,7 +69,7 @@ class CreatesDatabase extends Command// when it fails, display errortry {- $pdo = new PDO($dsn, (string)config('database.connections.mysql.username'), (string)config('database.connections.mysql.password'), $options);+ $pdo = new PDO($dsn, (string) config('database.connections.mysql.username'), (string) config('database.connections.mysql.password'), $options);} catch (PDOException $e) {$this->friendlyError(sprintf('Error when connecting to DB: %s', $e->getMessage()));@@ -79,7 +79,7 @@ class CreatesDatabase extends Command// only continue when no error.// with PDO, try to list DB's (/** @var array $stmt */- $stmt = $pdo->query('SHOW DATABASES;');+ $stmt = $pdo->query('SHOW DATABASES;');// slightly more complex but less error-prone.foreach ($stmt as $row) {$name = $row['Database'] ?? false;diff --git a/app/Console/Commands/System/CreatesFirstUser.php b/app/Console/Commands/System/CreatesFirstUser.phpindex 92192fc91b..f5ac718924 100644--- a/app/Console/Commands/System/CreatesFirstUser.php+++ b/app/Console/Commands/System/CreatesFirstUser.php@@ -39,7 +39,7 @@ class CreatesFirstUser extends Commandprotected $description = 'Creates a new user and gives admin rights. Outputs the password on the command line. Strictly for testing.';- protected $signature = 'system:create-first-user {email}';+ protected $signature = 'system:create-first-user {email}';private UserRepositoryInterface $repository;/**@@ -53,7 +53,7 @@ class CreatesFirstUser extends Commandreturn 1;}$this->stupidLaravel();- $count = $this->repository->count();+ $count = $this->repository->count();if ($count > 0) {$this->friendlyError('Already have more than zero users in DB.');@@ -67,7 +67,7 @@ class CreatesFirstUser extends Command$user->setRememberToken(Str::random(60));Log::info(sprintf('Registered new user %s', $user->email));- $owner = new OwnerNotifiable();+ $owner = new OwnerNotifiable();event(new NewUserRegistered($owner, $user));$this->friendlyInfo(sprintf('Created new admin user (ID #%d) with email address "%s" and password "%s".', $user->id, $user->email, $password));diff --git a/app/Console/Commands/System/ForcesDecimalSize.php b/app/Console/Commands/System/ForcesDecimalSize.phpindex 265209ae87..6e60d35f41 100644--- a/app/Console/Commands/System/ForcesDecimalSize.php+++ b/app/Console/Commands/System/ForcesDecimalSize.php@@ -42,6 +42,7 @@ use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\Model;use Illuminate\Support\Facades\DB;use Illuminate\Support\Facades\Log;+use function Safe\json_encode;use function Safe\mb_regex_encoding;@@ -54,40 +55,38 @@ class ForcesDecimalSize extends Command{use ShowsFriendlyMessages;- protected $description = 'This command resizes DECIMAL columns in MySQL or PostgreSQL and correct amounts (only MySQL).';- protected $signature = 'firefly-iii:force-decimal-size {--force}';+ protected $description = 'This command resizes DECIMAL columns in MySQL or PostgreSQL and correct amounts (only MySQL).';+ protected $signature = 'firefly-iii:force-decimal-size {--force}';private string $cast;- private array $classes- = [- 'accounts' => Account::class,- 'auto_budgets' => AutoBudget::class,- 'available_budgets' => AvailableBudget::class,- 'bills' => Bill::class,- 'budget_limits' => BudgetLimit::class,- 'piggy_bank_events' => PiggyBankEvent::class,- 'piggy_bank_repetitions' => PiggyBankRepetition::class,- 'piggy_banks' => PiggyBank::class,- 'recurrences_transactions' => RecurrenceTransaction::class,- 'transactions' => Transaction::class,- ];+ private array $classes = [+ 'accounts' => Account::class,+ 'auto_budgets' => AutoBudget::class,+ 'available_budgets' => AvailableBudget::class,+ 'bills' => Bill::class,+ 'budget_limits' => BudgetLimit::class,+ 'piggy_bank_events' => PiggyBankEvent::class,+ 'piggy_bank_repetitions' => PiggyBankRepetition::class,+ 'piggy_banks' => PiggyBank::class,+ 'recurrences_transactions' => RecurrenceTransaction::class,+ 'transactions' => Transaction::class,+ ];private string $operator;private string $regularExpression;- private array $tables- = [- 'accounts' => ['virtual_balance'],- 'auto_budgets' => ['amount'],- 'available_budgets' => ['amount'],- 'bills' => ['amount_min', 'amount_max'],- 'budget_limits' => ['amount'],- 'currency_exchange_rates' => ['rate', 'user_rate'],- 'limit_repetitions' => ['amount'],- 'piggy_bank_events' => ['amount'],- 'piggy_bank_repetitions' => ['current_amount'],- 'piggy_banks' => ['target_amount'],- 'recurrences_transactions' => ['amount', 'foreign_amount'],- 'transactions' => ['amount', 'foreign_amount'],- ];+ private array $tables = [+ 'accounts' => ['virtual_balance'],+ 'auto_budgets' => ['amount'],+ 'available_budgets' => ['amount'],+ 'bills' => ['amount_min', 'amount_max'],+ 'budget_limits' => ['amount'],+ 'currency_exchange_rates' => ['rate', 'user_rate'],+ 'limit_repetitions' => ['amount'],+ 'piggy_bank_events' => ['amount'],+ 'piggy_bank_repetitions' => ['current_amount'],+ 'piggy_banks' => ['target_amount'],+ 'recurrences_transactions' => ['amount', 'foreign_amount'],+ 'transactions' => ['amount', 'foreign_amount'],+ ];/*** Execute the console command.@@ -123,9 +122,10 @@ class ForcesDecimalSize extends Command$regularExpression = $this->regularExpression;/** @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));+ $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))+ ;$query->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {foreach ($fields as $field) {$q->orWhere(@@ -135,7 +135,7 @@ class ForcesDecimalSize extends Command);}});- $result = $query->get(['accounts.*']);+ $result = $query->get(['accounts.*']);if (0 === $result->count()) {$this->friendlyPositive(sprintf('All accounts in %s are OK', $currency->code));@@ -146,13 +146,13 @@ class ForcesDecimalSize extends Commandforeach ($result as $account) {/** @var string $field */foreach ($fields as $field) {- $value = $account->{$field};+ $value = $account->{$field};if (null === $value) {continue;}// fix $field by rounding it down correctly.- $pow = 10 ** $currency->decimal_places;- $correct = bcdiv((string)round($value * $pow), (string)$pow, 12);+ $pow = 10 ** $currency->decimal_places;+ $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));/** @var null|Account $updateAccount */@@ -168,19 +168,20 @@ class ForcesDecimalSize 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): int {- mb_regex_encoding('UTF-8');- $pattern = trim($pattern, '"');-- return mb_ereg($pattern, (string)$value) ? 1 : 0;- });+ ->getPdo()+ ->sqliteCreateFunction('REGEXP', static function ($pattern, $value): int {+ mb_regex_encoding('UTF-8');+ $pattern = trim($pattern, '"');++ return 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;}@@ -275,15 +276,16 @@ class ForcesDecimalSize extends Command$regularExpression = $this->regularExpression;/** @var Builder $query */- $query = $class::where('transaction_currency_id', $currency->id)- ->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {- /** @var string $field */- foreach ($fields as $field) {- $q->orWhere(DB::raw(sprintf('CAST(%s AS %s)', $field, $cast)), $operator, DB::raw(sprintf($regularExpression, $currency->decimal_places)));- }- });+ $query = $class::where('transaction_currency_id', $currency->id)+ ->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {+ /** @var string $field */+ foreach ($fields as $field) {+ $q->orWhere(DB::raw(sprintf('CAST(%s AS %s)', $field, $cast)), $operator, DB::raw(sprintf($regularExpression, $currency->decimal_places)));+ }+ })+ ;- $result = $query->get();+ $result = $query->get();if (0 === $result->count()) {$this->friendlyPositive(sprintf('All %s in %s are OK', $table, $currency->code));@@ -294,17 +296,17 @@ class ForcesDecimalSize extends Commandforeach ($result as $item) {/** @var string $field */foreach ($fields as $field) {- $value = $item->{$field};+ $value = $item->{$field};if (null === $value || '' === $value) {continue;}// 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));/** @var null|Model $model */- $model = $class::find($item->id);+ $model = $class::find($item->id);$model?->update([$field => $correct]);}}@@ -320,21 +322,22 @@ class ForcesDecimalSize extends Command$regularExpression = $this->regularExpression;/** @var Builder $query */- $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(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {- foreach ($fields as $field) {- $q->orWhere(- DB::raw(sprintf('CAST(piggy_banks.%s AS %s)', $field, $cast)),- $operator,- DB::raw(sprintf($regularExpression, $currency->decimal_places))- );- }- });-- $result = $query->get(['piggy_banks.*']);+ $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(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {+ foreach ($fields as $field) {+ $q->orWhere(+ DB::raw(sprintf('CAST(piggy_banks.%s AS %s)', $field, $cast)),+ $operator,+ DB::raw(sprintf($regularExpression, $currency->decimal_places))+ );+ }+ })+ ;++ $result = $query->get(['piggy_banks.*']);if (0 === $result->count()) {$this->friendlyPositive(sprintf('All piggy banks in %s are OK', $currency->code));@@ -345,13 +348,13 @@ class ForcesDecimalSize extends Commandforeach ($result as $item) {/** @var string $field */foreach ($fields as $field) {- $value = $item->{$field};+ $value = $item->{$field};if (null === $value) {continue;}// fix $field by rounding it down correctly.- $pow = 10 ** $currency->decimal_places;- $correct = bcdiv((string)round($value * $pow), (string)$pow, 12);+ $pow = 10 ** $currency->decimal_places;+ $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));/** @var null|PiggyBank $piggyBank */@@ -371,22 +374,23 @@ class ForcesDecimalSize extends Command$regularExpression = $this->regularExpression;/** @var Builder $query */- $query = PiggyBankEvent::leftJoin('piggy_banks', 'piggy_bank_events.piggy_bank_id', '=', 'piggy_banks.id')- ->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(static function (Builder $q) use ($fields, $currency, $cast, $operator, $regularExpression): void {- foreach ($fields as $field) {- $q->orWhere(- DB::raw(sprintf('CAST(piggy_bank_events.%s AS %s)', $field, $cast)),- $operator,- DB::raw(sprintf($regularExpression, $currency->decimal_places))- );- }- });-- $result = $query->get(['piggy_bank_events.*']);+ $query = PiggyBankEvent::leftJoin('piggy_banks', 'piggy_bank_events.piggy_bank_id', '=', 'piggy_banks.id')+ ->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(static function (Builder $q) use ($fields, $currency, $cast, $operator, $regularExpression): void {+ foreach ($fields as $field) {+ $q->orWhere(+ DB::raw(sprintf('CAST(piggy_bank_events.%s AS %s)', $field, $cast)),+ $operator,+ DB::raw(sprintf($regularExpression, $currency->decimal_places))+ );+ }+ })+ ;++ $result = $query->get(['piggy_bank_events.*']);if (0 === $result->count()) {$this->friendlyPositive(sprintf('All piggy bank events in %s are OK', $currency->code));@@ -397,23 +401,23 @@ class ForcesDecimalSize extends Commandforeach ($result as $item) {/** @var string $field */foreach ($fields as $field) {- $value = $item->{$field};+ $value = $item->{$field};if (null === $value) {continue;}// 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- ));+ 'Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".',+ $item->id,+ $field,+ $value,+ $correct+ ));/** @var null|PiggyBankEvent $event */- $event = PiggyBankEvent::find($item->id);+ $event = PiggyBankEvent::find($item->id);$event?->update([$field => $correct]);}}@@ -430,22 +434,23 @@ class ForcesDecimalSize extends Command// select all piggy bank repetitions with this currency and issue./** @var Builder $query */- $query = PiggyBankRepetition::leftJoin('piggy_banks', 'piggy_bank_repetitions.piggy_bank_id', '=', 'piggy_banks.id')- ->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(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {- foreach ($fields as $field) {- $q->orWhere(- DB::raw(sprintf('CAST(piggy_bank_repetitions.%s AS %s)', $field, $cast)),- $operator,- DB::raw(sprintf($regularExpression, $currency->decimal_places))- );- }- });-- $result = $query->get(['piggy_bank_repetitions.*']);+ $query = PiggyBankRepetition::leftJoin('piggy_banks', 'piggy_bank_repetitions.piggy_bank_id', '=', 'piggy_banks.id')+ ->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(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {+ foreach ($fields as $field) {+ $q->orWhere(+ DB::raw(sprintf('CAST(piggy_bank_repetitions.%s AS %s)', $field, $cast)),+ $operator,+ DB::raw(sprintf($regularExpression, $currency->decimal_places))+ );+ }+ })+ ;++ $result = $query->get(['piggy_bank_repetitions.*']);if (0 === $result->count()) {$this->friendlyPositive(sprintf('All piggy bank repetitions in %s', $currency->code));@@ -456,20 +461,20 @@ class ForcesDecimalSize extends Commandforeach ($result as $item) {/** @var string $field */foreach ($fields as $field) {- $value = $item->{$field};+ $value = $item->{$field};if (null === $value) {continue;}// fix $field by rounding it down correctly.- $pow = 10 ** $currency->decimal_places;- $correct = bcdiv((string)round($value * $pow), (string)$pow, 12);+ $pow = 10 ** $currency->decimal_places;+ $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- ));+ 'Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".',+ $item->id,+ $field,+ $value,+ $correct+ ));/** @var null|PiggyBankRepetition $repetition */$repetition = PiggyBankRepetition::find($item->id);@@ -485,13 +490,14 @@ class ForcesDecimalSize extends Command{// select all transactions with this currency and issue./** @var Builder $query */- $query = Transaction::query()- ->where('transaction_currency_id', $currency->id)- ->where(- DB::raw(sprintf('CAST(amount as %s)', $this->cast)),- $this->operator,- DB::raw(sprintf($this->regularExpression, $currency->decimal_places))- );+ $query = Transaction::query()+ ->where('transaction_currency_id', $currency->id)+ ->where(+ DB::raw(sprintf('CAST(amount as %s)', $this->cast)),+ $this->operator,+ DB::raw(sprintf($this->regularExpression, $currency->decimal_places))+ )+ ;$result = $query->get(['transactions.*']);if (0 === $result->count()) {@@ -500,13 +506,13 @@ class ForcesDecimalSize extends Command/** @var Transaction $item */foreach ($result as $item) {- $value = $item->amount;+ $value = $item->amount;if ('' === $value) {continue;}// fix $field by rounding it down correctly.- $pow = 10.0 ** $currency->decimal_places;- $correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);+ $pow = 10.0 ** $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));/** @var null|Transaction $transaction */@@ -516,13 +522,14 @@ class ForcesDecimalSize extends Command// select all transactions with this FOREIGN currency and issue./** @var Builder $query */- $query = Transaction::query()- ->where('foreign_currency_id', $currency->id)- ->where(- DB::raw(sprintf('CAST(foreign_amount as %s)', $this->cast)),- $this->operator,- DB::raw(sprintf($this->regularExpression, $currency->decimal_places))- );+ $query = Transaction::query()+ ->where('foreign_currency_id', $currency->id)+ ->where(+ DB::raw(sprintf('CAST(foreign_amount as %s)', $this->cast)),+ $this->operator,+ DB::raw(sprintf($this->regularExpression, $currency->decimal_places))+ )+ ;$result = $query->get();if (0 === $result->count()) {@@ -533,19 +540,19 @@ class ForcesDecimalSize extends Command/** @var Transaction $item */foreach ($result as $item) {- $value = $item->foreign_amount;+ $value = $item->foreign_amount;if (null === $value) {continue;}// fix $field by rounding it down correctly.- $pow = 10.0 ** $currency->decimal_places;- $correct = bcdiv((string)round((float)$value * $pow), (string)$pow, 12);+ $pow = 10.0 ** $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- ));+ 'Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".',+ $item->id,+ $value,+ $correct+ ));/** @var null|Transaction $transaction */$transaction = Transaction::find($item->id);@@ -572,7 +579,7 @@ class ForcesDecimalSize 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/ForcesMigrations.php b/app/Console/Commands/System/ForcesMigrations.phpindex e94a67eca7..479031c62e 100644--- a/app/Console/Commands/System/ForcesMigrations.php+++ b/app/Console/Commands/System/ForcesMigrations.php@@ -40,7 +40,7 @@ class ForcesMigrations extends Commandprotected $description = 'This command will force-run all database migrations.';- protected $signature = 'firefly-iii:force-migrations+ protected $signature = 'firefly-iii:force-migrations{--user=1 : The user ID.}{--token= : The user\'s access token.}';diff --git a/app/Console/Commands/System/OutputsInstructions.php b/app/Console/Commands/System/OutputsInstructions.phpindex e1495d0485..e342822bc0 100644--- a/app/Console/Commands/System/OutputsInstructions.php+++ b/app/Console/Commands/System/OutputsInstructions.php@@ -37,7 +37,7 @@ class OutputsInstructions extends Commandprotected $description = 'Instructions in case of upgrade trouble.';- protected $signature = 'firefly-iii:instructions {task=install}';+ protected $signature = 'firefly-iii:instructions {task=install}';/*** Execute the console command.@@ -89,26 +89,26 @@ class OutputsInstructions extends Command*/private function installInstructions(): void{- $version = (string)config('firefly.version');+ $version = (string) config('firefly.version');/** @var array $config */- $config = config('upgrade.text.install');- $text = '';+ $config = config('upgrade.text.install');+ $text = '';/** @var string $compare */foreach (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.';}- $prefix = 'v';+ $prefix = 'v';if (str_starts_with($version, 'develop')) {$prefix = '';}@@ -151,8 +151,8 @@ class OutputsInstructions extends Command*/private function showLogo(): void{- $today = Carbon::now()->format('m-d');- $month = Carbon::now()->format('m');+ $today = Carbon::now()->format('m-d');+ $month = Carbon::now()->format('m');// variation in colors and effects just because I can!// default is Ukraine flag:$colors = ['blue', 'blue', 'blue', 'yellow', 'yellow', 'yellow', 'default', 'default'];@@ -223,26 +223,26 @@ class OutputsInstructions extends Command*/private function updateInstructions(): void{- $version = (string)config('firefly.version');+ $version = (string) config('firefly.version');/** @var array $config */- $config = config('upgrade.text.upgrade');- $text = '';+ $config = config('upgrade.text.upgrade');+ $text = '';/** @var string $compare */foreach (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.';}- $prefix = 'v';+ $prefix = 'v';if (str_starts_with($version, 'develop') || str_starts_with($version, 'branch')) {$prefix = '';}diff --git a/app/Console/Commands/System/OutputsVersion.php b/app/Console/Commands/System/OutputsVersion.phpindex 86a523f364..56050f3cd4 100644--- a/app/Console/Commands/System/OutputsVersion.php+++ b/app/Console/Commands/System/OutputsVersion.php@@ -30,7 +30,7 @@ class OutputsVersion extends Command{protected $description = 'Outputs the Firefly III version';- protected $signature = 'firefly-iii:output-version';+ protected $signature = 'firefly-iii:output-version';/*** Execute the console command.diff --git a/app/Console/Commands/System/RecalculatesRunningBalance.php b/app/Console/Commands/System/RecalculatesRunningBalance.phpindex a330622062..3a35cf91ae 100644--- a/app/Console/Commands/System/RecalculatesRunningBalance.php+++ b/app/Console/Commands/System/RecalculatesRunningBalance.php@@ -45,7 +45,7 @@ class RecalculatesRunningBalance extends Command** @var string*/- protected $signature = 'firefly-iii:refresh-running-balance {--F|force : Force the execution of this command.}';+ protected $signature = 'firefly-iii:refresh-running-balance {--F|force : Force the execution of this command.}';/*** Execute the console command.diff --git a/app/Console/Commands/System/ResetsErrorMailLimit.php b/app/Console/Commands/System/ResetsErrorMailLimit.phpindex 875d059b4a..d08bc4ff72 100644--- a/app/Console/Commands/System/ResetsErrorMailLimit.php+++ b/app/Console/Commands/System/ResetsErrorMailLimit.php@@ -27,6 +27,7 @@ namespace FireflyIII\Console\Commands\System;use FireflyIII\Console\Commands\ShowsFriendlyMessages;use Illuminate\Console\Command;use Symfony\Component\Console\Command\Command as CommandAlias;+use function Safe\file_put_contents;use function Safe\json_encode;@@ -40,12 +41,13 @@ class ResetsErrorMailLimit extends Command* @var string*/protected $description = 'Resets the number of error mails sent.';+/*** The name and signature of the console command.** @var string*/- protected $signature = 'firefly-iii:reset-error-mail-limit';+ protected $signature = 'firefly-iii:reset-error-mail-limit';/*** Execute the console command.diff --git a/app/Console/Commands/System/ScansAttachments.php b/app/Console/Commands/System/ScansAttachments.phpindex f1f2b76ce7..0225cf0008 100644--- a/app/Console/Commands/System/ScansAttachments.php+++ b/app/Console/Commands/System/ScansAttachments.php@@ -34,6 +34,7 @@ use Illuminate\Support\Facades\Storage;use Safe\Exceptions\FileinfoException;use Safe\Exceptions\FilesystemException;use Safe\Exceptions\StringsException;+use function Safe\file_put_contents;use function Safe\md5_file;use function Safe\mime_content_type;@@ -45,7 +46,7 @@ class ScansAttachments extends Commandprotected $description = 'Rescan all attachments and re-set the correct MD5 hash and mime.';- protected $signature = 'firefly-iii:scan-attachments';+ protected $signature = 'firefly-iii:scan-attachments';/*** Execute the console command.@@ -75,7 +76,7 @@ class ScansAttachments extends CommandLog::error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));$decryptedContent = $encryptedContent;}- $tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');+ $tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');file_put_contents($tempFileName, $decryptedContent);$attachment->md5 = md5_file($tempFileName);$attachment->mime = mime_content_type($tempFileName);diff --git a/app/Console/Commands/System/SetsLatestVersion.php b/app/Console/Commands/System/SetsLatestVersion.phpindex a6b43ab4d5..cce25ac7de 100644--- a/app/Console/Commands/System/SetsLatestVersion.php+++ b/app/Console/Commands/System/SetsLatestVersion.php@@ -34,7 +34,7 @@ class SetsLatestVersion extends Commandprotected $description = 'Set latest version in DB.';- protected $signature = 'firefly-iii:set-latest-version {--james-is-cool}';+ protected $signature = 'firefly-iii:set-latest-version {--james-is-cool}';/*** Execute the console command.@@ -46,7 +46,7 @@ class SetsLatestVersion extends Commandreturn 0;}- AppConfiguration::set('ff3_build_time', (int)config('firefly.build_time'));+ AppConfiguration::set('ff3_build_time', (int) config('firefly.build_time'));$this->friendlyInfo('Updated version.');return 0;diff --git a/app/Console/Commands/System/VerifySecurityAlerts.php b/app/Console/Commands/System/VerifySecurityAlerts.phpindex 07fc5fe353..daf99b9b77 100644--- a/app/Console/Commands/System/VerifySecurityAlerts.php+++ b/app/Console/Commands/System/VerifySecurityAlerts.php@@ -32,6 +32,7 @@ use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\Storage;use League\Flysystem\FilesystemException;use Safe\Exceptions\JsonException;+use function Safe\json_decode;class VerifySecurityAlerts extends Command@@ -40,7 +41,7 @@ class VerifySecurityAlerts extends Commandprotected $description = 'Verify security alerts';- protected $signature = 'firefly-iii:verify-security-alerts';+ protected $signature = 'firefly-iii:verify-security-alerts';/*** Execute the console command.@@ -62,7 +63,7 @@ class VerifySecurityAlerts extends Commandreturn 0;}$content = $disk->get('alerts.json');- $json = json_decode((string)$content, true, 10);+ $json = json_decode((string) $content, true, 10);/** @var array $array */foreach ($json as $array) {diff --git a/app/Console/Commands/Tools/ApplyRules.php b/app/Console/Commands/Tools/ApplyRules.phpindex d94715d7b2..c318ad0d0e 100644--- a/app/Console/Commands/Tools/ApplyRules.php+++ b/app/Console/Commands/Tools/ApplyRules.php@@ -47,7 +47,7 @@ class ApplyRules extends Commandprotected $description = 'This command will apply your rules and rule groups on a selection of your transactions.';- protected $signature = 'firefly-iii:apply-rules+ protected $signature = 'firefly-iii:apply-rules{--user=1 : The user ID.}{--token= : The user\'s access token.}{--accounts= : A comma-separated list of asset accounts or liabilities to apply your rules to.}@@ -56,16 +56,16 @@ class ApplyRules extends Command{--all_rules : If set, will overrule both settings and simply apply ALL of your rules.}{--start_date= : The date of the earliest transaction to be included (inclusive). If omitted, will be your very first transaction ever. Format: YYYY-MM-DD}{--end_date= : The date of the latest transaction to be included (inclusive). If omitted, will be your latest transaction ever. Format: YYYY-MM-DD}';- private array $acceptedAccounts;- private Collection $accounts;- private bool $allRules;- private Carbon $endDate;- private Collection $groups;+ private array $acceptedAccounts;+ private Collection $accounts;+ private bool $allRules;+ private Carbon $endDate;+ private Collection $groups;private RuleGroupRepositoryInterface $ruleGroupRepository;- private array $ruleGroupSelection;- private RuleRepositoryInterface $ruleRepository;- private array $ruleSelection;- private Carbon $startDate;+ private array $ruleGroupSelection;+ private RuleRepositoryInterface $ruleRepository;+ private array $ruleSelection;+ private Carbon $startDate;/*** Execute the console command.@@ -74,7 +74,7 @@ class ApplyRules extends Command*/public function handle(): int{- $start = microtime(true);+ $start = microtime(true);$this->stupidLaravel();if (!$this->verifyAccessToken()) {$this->friendlyError('Invalid access token.');@@ -86,19 +86,19 @@ class ApplyRules extends Command$this->ruleRepository->setUser($this->getUser());$this->ruleGroupRepository->setUser($this->getUser());- $result = $this->verifyInput();+ $result = $this->verifyInput();if (false === $result) {return 1;}- $this->allRules = $this->option('all_rules');+ $this->allRules = $this->option('all_rules');// always get all the rules of the user.$this->grabAllRules();// loop all groups and rules and indicate if they're included:- $rulesToApply = $this->getRulesToApply();- $count = $rulesToApply->count();+ $rulesToApply = $this->getRulesToApply();+ $count = $rulesToApply->count();if (0 === $count) {$this->friendlyError('No rules or rule groups have been included.');$this->friendlyWarning('Make a selection using:');@@ -111,7 +111,7 @@ class ApplyRules extends Command// create new rule engine:/** @var RuleEngineInterface $ruleEngine */- $ruleEngine = app(RuleEngineInterface::class);+ $ruleEngine = app(RuleEngineInterface::class);$ruleEngine->setRules($rulesToApply);$ruleEngine->setUser($this->getUser());@@ -120,7 +120,7 @@ class ApplyRules extends Commandforeach ($this->accounts as $account) {$filterAccountList[] = $account->id;}- $list = implode(',', $filterAccountList);+ $list = implode(',', $filterAccountList);$ruleEngine->addOperator(['type' => 'account_id', 'value' => $list]);// add the date as a filter:@@ -134,7 +134,7 @@ class ApplyRules extends Command$ruleEngine->fire();$this->friendlyLine('');- $end = round(microtime(true) - $start, 2);+ $end = round(microtime(true) - $start, 2);$this->friendlyPositive(sprintf('Done in %s seconds!', $end));return 0;@@ -175,7 +175,7 @@ class ApplyRules extends Commandprivate function includeRule(Rule $rule, RuleGroup $group): bool{- return in_array((int)$group->id, $this->ruleGroupSelection, true) || in_array((int)$rule->id, $this->ruleSelection, true) || $this->allRules;+ return in_array((int) $group->id, $this->ruleGroupSelection, true) || in_array((int) $rule->id, $this->ruleSelection, true) || $this->allRules;}/**@@ -228,32 +228,32 @@ class ApplyRules extends Command*/private function verifyInputAccounts(): bool{- $accountString = $this->option('accounts');+ $accountString = $this->option('accounts');if (null === $accountString || '' === $accountString) {$this->friendlyError('Please use the --accounts option to indicate the accounts to apply rules to.');return false;}- $finalList = new Collection();- $accountList = explode(',', $accountString);+ $finalList = new Collection();+ $accountList = explode(',', $accountString);/** @var AccountRepositoryInterface $accountRepository */$accountRepository = app(AccountRepositoryInterface::class);$accountRepository->setUser($this->getUser());foreach ($accountList as $accountId) {- $accountId = (int)$accountId;+ $accountId = (int) $accountId;if (0 === $accountId) {$this->friendlyWarning('You provided an account with ID 0 (zero). It will be ignored.');continue;}- $account = $accountRepository->find($accountId);+ $account = $accountRepository->find($accountId);if (null === $account) {$this->friendlyWarning(sprintf('There is no account with ID #%d, it cannot be added.', $accountId));continue;}- $type = $account->accountType->type;+ $type = $account->accountType->type;if (!in_array($account->accountType->type, $this->acceptedAccounts, true)) {$this->friendlyWarning(sprintf('Account "%s" with ID #%d is of type "%s" and cannot be added.', $account->name, $accountId, $type));@@ -267,7 +267,7 @@ class ApplyRules extends Commandreturn false;}- $this->accounts = $finalList;+ $this->accounts = $finalList;return true;}@@ -278,13 +278,13 @@ class ApplyRules extends Commandprivate function verifyInputDates(): void{// parse start date.- $inputStart = today(config('app.timezone'))->startOfMonth();- $startString = $this->option('start_date');+ $inputStart = today(config('app.timezone'))->startOfMonth();+ $startString = $this->option('start_date');if (null === $startString) {/** @var JournalRepositoryInterface $repository */$repository = app(JournalRepositoryInterface::class);$repository->setUser($this->getUser());- $first = $repository->firstNull();+ $first = $repository->firstNull();if (null !== $first) {$inputStart = $first->date;}@@ -294,8 +294,8 @@ class ApplyRules extends Command}// parse end date- $inputEnd = today(config('app.timezone'));- $endString = $this->option('end_date');+ $inputEnd = today(config('app.timezone'));+ $endString = $this->option('end_date');if (null !== $endString && '' !== $endString) {$inputEnd = Carbon::createFromFormat('Y-m-d', $endString);}@@ -320,10 +320,10 @@ class ApplyRules extends Command// can be empty.return true;}- $ruleGroupList = explode(',', $ruleGroupString);+ $ruleGroupList = explode(',', $ruleGroupString);foreach ($ruleGroupList as $ruleGroupId) {- $ruleGroupId = (int)$ruleGroupId;+ $ruleGroupId = (int) $ruleGroupId;if (0 === $ruleGroupId) {$this->friendlyWarning('You added a rule group with ID 0 (zero). It will be skipped.');@@ -331,7 +331,7 @@ class ApplyRules extends Commandcontinue;}- $ruleGroup = $this->ruleGroupRepository->find($ruleGroupId);+ $ruleGroup = $this->ruleGroupRepository->find($ruleGroupId);if (null === $ruleGroup) {$this->friendlyWarning(sprintf('There is no rule group with ID #%d, this ID will be ignored.', $ruleGroupId));@@ -356,16 +356,16 @@ class ApplyRules extends Command// can be empty.return true;}- $ruleList = explode(',', $ruleString);+ $ruleList = explode(',', $ruleString);foreach ($ruleList as $ruleId) {- $ruleId = (int)$ruleId;+ $ruleId = (int) $ruleId;if (0 === $ruleId) {$this->friendlyWarning('You added a rule with ID 0 (zero). It will be skipped.');continue;}- $rule = $this->ruleRepository->find($ruleId);+ $rule = $this->ruleRepository->find($ruleId);if (null === $rule) {$this->friendlyWarning(sprintf('There is no rule with ID #%d, this ID will be ignored.', $ruleId));diff --git a/app/Console/Commands/Tools/ChecksForUpdates.php b/app/Console/Commands/Tools/ChecksForUpdates.phpindex f717ff107f..49bdeca55b 100644--- a/app/Console/Commands/Tools/ChecksForUpdates.php+++ b/app/Console/Commands/Tools/ChecksForUpdates.php@@ -40,20 +40,21 @@ class ChecksForUpdates extends Command* @var string*/protected $description = 'Checks for Firefly III updates';+/*** The name and signature of the console command.** @var string*/- protected $signature = 'firefly-iii:check-for-updates {--force}';+ protected $signature = 'firefly-iii:check-for-updates {--force}';/*** Execute the console command.*/public function handle(): int{- $build = Carbon::createFromTimestamp(config('firefly.build_time'), config('app.timezone'));- $version = config('firefly.version');+ $build = Carbon::createFromTimestamp(config('firefly.build_time'), config('app.timezone'));+ $version = config('firefly.version');$this->friendlyLine(sprintf('You are running version "%s", built on %s', $version, $build->format('Y-m-d H:i')));$permission = AppConfiguration::get('permission_update_check', -1)->data;@@ -67,9 +68,9 @@ class ChecksForUpdates extends Command}/** @var UpdateRequestInterface $request */- $request = app(UpdateRequestInterface::class);+ $request = app(UpdateRequestInterface::class);// stable, alpha or beta- $info = $request->getUpdateInformation($version, $build, 'stable');+ $info = $request->getUpdateInformation($version, $build, 'stable');if ('' !== $info->getError()) {$this->friendlyError($info->getError());diff --git a/app/Console/Commands/Tools/Cron.php b/app/Console/Commands/Tools/Cron.phpindex 6e29ec99ea..41905428b9 100644--- a/app/Console/Commands/Tools/Cron.php+++ b/app/Console/Commands/Tools/Cron.php@@ -46,7 +46,7 @@ class Cron extends Commandprotected $description = 'Runs all Firefly III cron-job related commands. Configure a cron job according to the official Firefly III documentation.';- protected $signature = 'firefly-iii:cron+ protected $signature = 'firefly-iii:cron{--F|force : Force the cron job(s) to execute.}{--date= : Set the date in YYYY-MM-DD to make Firefly III think that\'s the current date.}{--check-version : Check if there is a new Firefly III version. Other tasks will be skipped unless also requested.}@@ -62,8 +62,8 @@ class Cron extends Commandpublic function handle(): int{/** @var UserRepositoryInterface $repository */- $repository = app(UserRepositoryInterface::class);- $admin = $repository->getUsersByRole('owner')->first();+ $repository = app(UserRepositoryInterface::class);+ $admin = $repository->getUsersByRole('owner')->first();if (null === $admin) {$this->friendlyError('There is no user in the system with the "owner"-role, cannot continue.');@@ -71,11 +71,11 @@ class Cron extends Command}$this->admin = $admin;$doAll = !$this->option('download-cer')- && !$this->option('create-recurring')- && !$this->option('create-auto-budgets')- && !$this->option('send-subscription-warnings')- && !$this->option('check-version')- && !$this->option('send-webhook-messages');+ && !$this->option('create-recurring')+ && !$this->option('create-auto-budgets')+ && !$this->option('send-subscription-warnings')+ && !$this->option('check-version')+ && !$this->option('send-webhook-messages');$date = null;try {@@ -83,7 +83,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');+ $force = (bool) $this->option('force');// Fire exchange rates cron job.if (true === AppConfiguration::get('enable_external_rates', config('cer.download_enabled'))->data && ($doAll || $this->option('download-cer'))) {diff --git a/app/Console/Commands/Tools/VerifiesDatabaseConnection.php b/app/Console/Commands/Tools/VerifiesDatabaseConnection.phpindex e455bf6aa2..cd83b21cef 100644--- a/app/Console/Commands/Tools/VerifiesDatabaseConnection.php+++ b/app/Console/Commands/Tools/VerifiesDatabaseConnection.php@@ -38,12 +38,13 @@ class VerifiesDatabaseConnection extends Command* @var string*/protected $description = 'This command tries to connect to the database.';+/*** The name and signature of the console command.** @var string*/- protected $signature = 'firefly-iii:verify-database-connection';+ protected $signature = 'firefly-iii:verify-database-connection';/*** Execute the console command.diff --git a/app/Console/Commands/Tools/VerifiesDatabaseConnectionTrait.php b/app/Console/Commands/Tools/VerifiesDatabaseConnectionTrait.phpindex 14de0ba925..44f70fd7ab 100644--- a/app/Console/Commands/Tools/VerifiesDatabaseConnectionTrait.php+++ b/app/Console/Commands/Tools/VerifiesDatabaseConnectionTrait.php@@ -33,10 +33,10 @@ trait VerifiesDatabaseConnectionTrait{protected function verifyDatabaseConnection(): bool{- $loops = 30;- $loop = 0;- $queries = ['pgsql' => 'SELECT * FROM pg_catalog.pg_tables;', 'sqlite' => 'SELECT name FROM sqlite_schema;', 'mysql' => 'SHOW TABLES;'];- $default = config('database.default');+ $loops = 30;+ $loop = 0;+ $queries = ['pgsql' => 'SELECT * FROM pg_catalog.pg_tables;', 'sqlite' => 'SELECT name FROM sqlite_schema;', 'mysql' => 'SHOW TABLES;'];+ $default = config('database.default');if (!array_key_exists($default, $queries)) {$this->friendlyWarning(sprintf('Cannot validate database connection for "%s"', $default));diff --git a/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php b/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.phpindex d04ffe7ddc..65e0ee96df 100644--- a/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php+++ b/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php@@ -40,10 +40,10 @@ class AddsTransactionIdentifiers extends Commandpublic const string CONFIG_NAME = '480_transaction_identifier';- protected $description = 'Fixes transaction identifiers.';- protected $signature = 'upgrade:480-transaction-identifiers {--F|force : Force the execution of this command.}';+ protected $description = 'Fixes transaction identifiers.';+ protected $signature = 'upgrade:480-transaction-identifiers {--F|force : Force the execution of this command.}';private JournalCLIRepositoryInterface $cliRepository;- private int $count;+ private int $count;/*** This method gives all transactions which are part of a split journal (so more than 2) a sort of "order" so they@@ -94,11 +94,12 @@ class AddsTransactionIdentifiers extends Commandtry {/** @var Transaction $opposing */$opposing = Transaction::query()- ->where('transaction_journal_id', $transaction->transaction_journal_id)- ->where('amount', $amount)- ->where('identifier', '=', 0)- ->whereNotIn('id', $exclude)- ->first();+ ->where('transaction_journal_id', $transaction->transaction_journal_id)+ ->where('amount', $amount)+ ->where('identifier', '=', 0)+ ->whereNotIn('id', $exclude)+ ->first()+ ;} catch (QueryException $e) {Log::error($e->getMessage());$this->friendlyError('Firefly III could not find the "identifier" field in the "transactions" table.');@@ -116,7 +117,7 @@ class AddsTransactionIdentifiers extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): void@@ -154,8 +155,8 @@ class AddsTransactionIdentifiers extends Command$opposing->identifier = $identifier;$transaction->save();$opposing->save();- $exclude[] = $transaction->id;- $exclude[] = $opposing->id;+ $exclude[] = $transaction->id;+ $exclude[] = $opposing->id;++$this->count;}++$identifier;diff --git a/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php b/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.phpindex ced07d11f1..9ae22a900c 100644--- a/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php+++ b/app/Console/Commands/Upgrade/RemovesDatabaseDecryption.php@@ -35,6 +35,7 @@ use Illuminate\Support\Facades\DB;use Illuminate\Support\Facades\Log;use JsonException;use stdClass;+use function Safe\json_decode;class RemovesDatabaseDecryption extends Command@@ -109,8 +110,8 @@ class RemovesDatabaseDecryption extends Commandif (null === $original) {return;}- $id = (int)$row->id;- $value = '';+ $id = (int) $row->id;+ $value = '';try {$value = $this->tryDecrypt($original);@@ -158,7 +159,7 @@ class RemovesDatabaseDecryption extends CommandLog::error($e->getMessage());}- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}/**diff --git a/app/Console/Commands/Upgrade/RepairsAccountBalances.php b/app/Console/Commands/Upgrade/RepairsAccountBalances.phpindex e7214041b8..2c024cad75 100644--- a/app/Console/Commands/Upgrade/RepairsAccountBalances.php+++ b/app/Console/Commands/Upgrade/RepairsAccountBalances.php@@ -35,8 +35,8 @@ class RepairsAccountBalances extends Commandpublic const string CONFIG_NAME = '610_correct_balances';- protected $description = 'Recalculate all account balance amounts';- protected $signature = 'upgrade:610-account-balances {--F|force : Force the execution of this command.}';+ protected $description = 'Recalculate all account balance amounts';+ protected $signature = 'upgrade:610-account-balances {--F|force : Force the execution of this command.}';public function handle(): int{@@ -67,7 +67,7 @@ class RepairsAccountBalances extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): voiddiff --git a/app/Console/Commands/Upgrade/RepairsPostgresSequences.php b/app/Console/Commands/Upgrade/RepairsPostgresSequences.phpindex da52835d6f..f0a11c8d6c 100644--- a/app/Console/Commands/Upgrade/RepairsPostgresSequences.php+++ b/app/Console/Commands/Upgrade/RepairsPostgresSequences.php@@ -36,7 +36,7 @@ class RepairsPostgresSequences extends Commandprotected $description = 'Fixes issues with PostgreSQL sequences.';- protected $signature = 'upgrade:600-pgsql-sequences';+ protected $signature = 'upgrade:600-pgsql-sequences';/*** Execute the console command.@@ -116,8 +116,9 @@ class RepairsPostgresSequences extends Commandtry {$nextId = DB::table($tableToCheck)- ->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))- ->first();+ ->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))+ ->first()+ ;} catch (QueryException $e) {Log::warning(sprintf('Could not get nextval, but will ignore this: %s', $e->getMessage()));$nextId = null;@@ -132,8 +133,9 @@ class RepairsPostgresSequences extends CommandDB::select(sprintf('SELECT setval(\'%s_id_seq\', %d)', $tableToCheck, $highestId->max));$highestId = DB::table($tableToCheck)->select(DB::raw('MAX(id)'))->first();$nextId = DB::table($tableToCheck)- ->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))- ->first();+ ->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))+ ->first()+ ;if ($nextId->nextval > $highestId->max) {$this->friendlyInfo(sprintf('Table "%s" autoincrement corrected.', $tableToCheck));}diff --git a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.phpindex f6932c769b..3c5b0f4f5e 100644--- a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php+++ b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php@@ -44,11 +44,11 @@ class UpgradesAccountCurrencies extends Commandpublic const string CONFIG_NAME = '480_account_currencies';- protected $description = 'Give all accounts proper currency info.';- protected $signature = 'upgrade:480-account-currencies {--F|force : Force the execution of this command.}';+ protected $description = 'Give all accounts proper currency info.';+ protected $signature = 'upgrade:480-account-currencies {--F|force : Force the execution of this command.}';private AccountRepositoryInterface $accountRepos;- private int $count;- private UserRepositoryInterface $userRepos;+ private int $count;+ private UserRepositoryInterface $userRepos;/*** Each (asset) account must have a reference to a preferred currency. If the account does not have one, it's@@ -77,7 +77,7 @@ class UpgradesAccountCurrencies extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): void@@ -100,9 +100,9 @@ class UpgradesAccountCurrencies 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) {@@ -147,7 +147,7 @@ class UpgradesAccountCurrencies extends Commandprivate function updateCurrenciesForUser(User $user): void{$this->accountRepos->setUser($user);- $accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value]);+ $accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value]);// get user's currency preference:$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($user->userGroup);diff --git a/app/Console/Commands/Upgrade/UpgradesAccountMetaData.php b/app/Console/Commands/Upgrade/UpgradesAccountMetaData.phpindex aab895d062..b35d480e88 100644--- a/app/Console/Commands/Upgrade/UpgradesAccountMetaData.php+++ b/app/Console/Commands/Upgrade/UpgradesAccountMetaData.php@@ -36,9 +36,9 @@ class UpgradesAccountMetaData extends Commandpublic const string CONFIG_NAME = '480_rename_account_meta';- protected $description = 'Rename account meta-data to new format.';+ protected $description = 'Rename account meta-data to new format.';- protected $signature = 'upgrade:480-account-meta {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:480-account-meta {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -85,7 +85,7 @@ class UpgradesAccountMetaData extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): voiddiff --git a/app/Console/Commands/Upgrade/UpgradesAttachments.php b/app/Console/Commands/Upgrade/UpgradesAttachments.phpindex 5875977186..b62d7a38c0 100644--- a/app/Console/Commands/Upgrade/UpgradesAttachments.php+++ b/app/Console/Commands/Upgrade/UpgradesAttachments.php@@ -38,9 +38,9 @@ class UpgradesAttachments extends Commandpublic const string CONFIG_NAME = '480_migrate_attachments';- protected $description = 'Migrates attachment meta-data.';+ protected $description = 'Migrates attachment meta-data.';- protected $signature = 'upgrade:480-attachments {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:480-attachments {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -49,7 +49,7 @@ class UpgradesAttachments extends Command*/public function handle(): int{- $start = microtime(true);+ $start = microtime(true);if ($this->isExecuted() && true !== $this->option('force')) {$this->friendlyInfo('This command has already been executed.');@@ -62,15 +62,15 @@ class UpgradesAttachments 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();+ $note = $att->notes()->first();if (null === $note) {$note = new Note();$note->noteable()->associate($att);}- $note->text = $attDescription;+ $note->text = $attDescription;$note->save();// clear description:@@ -84,7 +84,7 @@ class UpgradesAttachments extends Commandif (0 !== $count) {$this->friendlyInfo(sprintf('Updated %d attachment(s).', $count));}- $end = round(microtime(true) - $start, 2);+ $end = round(microtime(true) - $start, 2);$this->friendlyInfo(sprintf('Migrated attachment notes in %s seconds.', $end));$this->markAsExecuted();@@ -95,7 +95,7 @@ class UpgradesAttachments extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): voiddiff --git a/app/Console/Commands/Upgrade/UpgradesBillsToRules.php b/app/Console/Commands/Upgrade/UpgradesBillsToRules.phpindex 0f16a5933f..bd18021dd2 100644--- a/app/Console/Commands/Upgrade/UpgradesBillsToRules.php+++ b/app/Console/Commands/Upgrade/UpgradesBillsToRules.php@@ -44,14 +44,14 @@ class UpgradesBillsToRules extends Commandpublic const string CONFIG_NAME = '480_bills_to_rules';- protected $description = 'Migrate bills to rules.';+ protected $description = 'Migrate bills to rules.';- protected $signature = 'upgrade:480-bills-to-rules {--F|force : Force the execution of this command.}';- private BillRepositoryInterface $billRepository;- private int $count;+ protected $signature = 'upgrade:480-bills-to-rules {--F|force : Force the execution of this command.}';+ private BillRepositoryInterface $billRepository;+ private int $count;private RuleGroupRepositoryInterface $ruleGroupRepository;- private RuleRepositoryInterface $ruleRepository;- private UserRepositoryInterface $userRepository;+ private RuleRepositoryInterface $ruleRepository;+ private UserRepositoryInterface $userRepository;/*** Execute the console command.@@ -88,7 +88,7 @@ class UpgradesBillsToRules extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): void@@ -101,17 +101,17 @@ class UpgradesBillsToRules 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));- $newRule = [+ $match = implode(' ', explode(',', $bill->match));+ $newRule = ['rule_group_id' => $ruleGroup->id,'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' => [['type' => 'description_contains', 'value' => $match]],'actions' => [['type' => 'link_to_bill', 'value' => $bill->name]],@@ -129,7 +129,7 @@ class UpgradesBillsToRules extends Command$this->ruleRepository->store($newRule);// update bill:- $newBillData = [+ $newBillData = ['currency_id' => $bill->transaction_currency_id,'name' => $bill->name,'match' => 'MIGRATED_TO_RULES',@@ -155,18 +155,18 @@ class UpgradesBillsToRules extends Command/** @var Preference $lang */$lang = 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 (!$ruleGroup instanceof RuleGroup) {$ruleGroup = $this->ruleGroupRepository->store([- 'title' => (string)trans('firefly.rulegroup_for_bills_title', [], $language),- 'description' => (string)trans('firefly.rulegroup_for_bills_description', [], $language),- 'active' => true,- ]);+ 'title' => (string) trans('firefly.rulegroup_for_bills_title', [], $language),+ 'description' => (string) trans('firefly.rulegroup_for_bills_description', [], $language),+ 'active' => true,+ ]);}- $bills = $this->billRepository->getBills();+ $bills = $this->billRepository->getBills();/** @var Bill $bill */foreach ($bills as $bill) {diff --git a/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.php b/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.phpindex d85924a704..1b131553b9 100644--- a/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.php+++ b/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.php@@ -36,9 +36,9 @@ class UpgradesBudgetLimitPeriods extends Commandpublic const string CONFIG_NAME = '550_budget_limit_periods';- protected $description = 'Append budget limits with their (estimated) timeframe.';+ protected $description = 'Append budget limits with their (estimated) timeframe.';- protected $signature = 'upgrade:550-budget-limit-periods {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:550-budget-limit-periods {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -59,7 +59,7 @@ class UpgradesBudgetLimitPeriods extends Commandprivate function fixLimit(BudgetLimit $limit): void{- $period = $this->getLimitPeriod($limit);+ $period = $this->getLimitPeriod($limit);if (null === $period) {$message = sprintf(@@ -76,7 +76,7 @@ class UpgradesBudgetLimitPeriods extends Command$limit->period = $period;$limit->saveQuietly();- $msg = sprintf(+ $msg = sprintf('Budget limit #%d (%s - %s) period is "%s".',$limit->id,$limit->start_date->format('Y-m-d'),@@ -96,7 +96,7 @@ class UpgradesBudgetLimitPeriods extends Commandif ('1' === $limit->start_date->format('N')&& '7' === $limit->end_date->format('N')- && 6 === (int)$limit->end_date->diffInDays($limit->start_date, true)+ && 6 === (int) $limit->end_date->diffInDays($limit->start_date, true)) {return 'weekly';}@@ -116,7 +116,7 @@ class UpgradesBudgetLimitPeriods 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';}@@ -126,7 +126,7 @@ class UpgradesBudgetLimitPeriods 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';}@@ -142,7 +142,7 @@ class UpgradesBudgetLimitPeriods extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar->data;+ return (bool) $configVar->data;}private function markAsExecuted(): voiddiff --git a/app/Console/Commands/Upgrade/UpgradesBudgetLimits.php b/app/Console/Commands/Upgrade/UpgradesBudgetLimits.phpindex fdddea86e5..166bdb2cf4 100644--- a/app/Console/Commands/Upgrade/UpgradesBudgetLimits.php+++ b/app/Console/Commands/Upgrade/UpgradesBudgetLimits.php@@ -39,9 +39,9 @@ class UpgradesBudgetLimits extends Commandpublic const string CONFIG_NAME = '480_bl_currency';- protected $description = 'Give budget limits a currency';+ protected $description = 'Give budget limits a currency';- protected $signature = 'upgrade:480-budget-limit-currencies {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:480-budget-limit-currencies {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -72,11 +72,11 @@ class UpgradesBudgetLimits extends Command$budgetLimit->transaction_currency_id = $currency->id;$budgetLimit->saveQuietly();$this->friendlyInfo(sprintf(- 'Budget limit #%d (part of budget "%s") now has a currency setting (%s).',- $budgetLimit->id,- $budget->name,- $currency->name- ));+ 'Budget limit #%d (part of budget "%s") now has a currency setting (%s).',+ $budgetLimit->id,+ $budget->name,+ $currency->name+ ));++$count;}}@@ -91,7 +91,7 @@ class UpgradesBudgetLimits extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): voiddiff --git a/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php b/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.phpindex f59efa8bc0..ffba93fd6d 100644--- a/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php+++ b/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php@@ -39,8 +39,8 @@ class UpgradesCreditCardLiabilities extends Commandpublic const string CONFIG_NAME = '480_cc_liabilities';- protected $description = 'Convert old credit card liabilities.';- protected $signature = 'upgrade:480-cc-liabilities {--F|force : Force the execution of this command.}';+ protected $description = 'Convert old credit card liabilities.';+ protected $signature = 'upgrade:480-cc-liabilities {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -84,7 +84,7 @@ class UpgradesCreditCardLiabilities extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): voiddiff --git a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.phpindex c21f751ba9..9ebb20ab85 100644--- a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php+++ b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php@@ -41,9 +41,9 @@ class UpgradesCurrencyPreferences extends Commandpublic const string CONFIG_NAME = '610_upgrade_currency_prefs';- protected $description = 'Upgrade user currency preferences';+ protected $description = 'Upgrade user currency preferences';- protected $signature = 'upgrade:610-currency-preferences {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:610-currency-preferences {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -67,16 +67,17 @@ class UpgradesCurrencyPreferences extends Commandprivate function getPreference(User $user): string{$preference = Preference::query()- ->where('user_id', $user->id)- ->where('name', 'currencyPreference')- ->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']);+ ->where('user_id', $user->id)+ ->where('name', 'currencyPreference')+ ->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at'])+ ;if (null === $preference) {return 'EUR';}if (null !== $preference->data && !is_array($preference->data)) {- return (string)$preference->data;+ return (string) $preference->data;}return 'EUR';@@ -86,7 +87,7 @@ class UpgradesCurrencyPreferences extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): void@@ -103,7 +104,7 @@ class UpgradesCurrencyPreferences extends Command$this->upgradeGroupPreferences($group);}- $users = User::get();+ $users = User::get();/** @var User $user */foreach ($users as $user) {diff --git a/app/Console/Commands/Upgrade/UpgradesDatabase.php b/app/Console/Commands/Upgrade/UpgradesDatabase.phpindex 0e59f9fc0a..4ad2e9ec23 100644--- a/app/Console/Commands/Upgrade/UpgradesDatabase.php+++ b/app/Console/Commands/Upgrade/UpgradesDatabase.php@@ -29,6 +29,7 @@ use FireflyIII\Support\Facades\AppConfiguration;use Illuminate\Console\Command;use Illuminate\Support\Facades\Log;use Safe\Exceptions\InfoException;+use function Safe\set_time_limit;try {@@ -86,7 +87,7 @@ class UpgradesDatabase extends Command$this->call($command, $args);}// index will set FF3 version.- AppConfiguration::set('ff3_build_time', (int)config('firefly.build_time'));+ AppConfiguration::set('ff3_build_time', (int) config('firefly.build_time'));return 0;}diff --git a/app/Console/Commands/Upgrade/UpgradesJournalMetaData.php b/app/Console/Commands/Upgrade/UpgradesJournalMetaData.phpindex a7c9799f43..3f830bcf36 100644--- a/app/Console/Commands/Upgrade/UpgradesJournalMetaData.php+++ b/app/Console/Commands/Upgrade/UpgradesJournalMetaData.php@@ -40,9 +40,9 @@ class UpgradesJournalMetaData extends Commandpublic const string CONFIG_NAME = '480_back_to_journals';- protected $description = 'Move meta data back to journals, not individual transactions.';+ protected $description = 'Move meta data back to journals, not individual transactions.';- protected $signature = 'upgrade:480-journal-meta-data {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:480-journal-meta-data {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -100,14 +100,14 @@ class UpgradesJournalMetaData extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar->data;+ return (bool) $configVar->data;}private function isMigrated(): bool{$configVar = AppConfiguration::get(UpgradesToGroups::CONFIG_NAME, false);- return (bool)$configVar->data;+ return (bool) $configVar->data;}private function markAsExecuted(): void@@ -145,7 +145,7 @@ class UpgradesJournalMetaData extends Command{// grab category from first transaction/** @var null|Transaction $transaction */- $transaction = $journal->transactions->first();+ $transaction = $journal->transactions->first();if (null === $transaction) {$this->friendlyInfo(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));@@ -153,7 +153,7 @@ class UpgradesJournalMetaData extends Command}/** @var null|Budget $budget */- $budget = $transaction->budgets->first();+ $budget = $transaction->budgets->first();/** @var null|Budget $journalBudget */$journalBudget = $journal->budgets->first();@@ -178,7 +178,7 @@ class UpgradesJournalMetaData extends Command$journals = new Collection();$allIds = $this->getIdsForCategories();- $chunks = array_chunk($allIds, 500);+ $chunks = array_chunk($allIds, 500);foreach ($chunks as $chunk) {$collected = TransactionJournal::query()->whereIn('id', $chunk)->with(['transactions', 'categories', 'transactions.categories'])->get();$journals = $journals->merge($collected);@@ -194,7 +194,7 @@ class UpgradesJournalMetaData extends Command{// grab category from first transaction/** @var null|Transaction $transaction */- $transaction = $journal->transactions->first();+ $transaction = $journal->transactions->first();if (null === $transaction) {$this->friendlyInfo(sprintf('Transaction journal #%d has no transactions. Will be fixed later.', $journal->id));@@ -202,7 +202,7 @@ class UpgradesJournalMetaData extends Command}/** @var null|Category $category */- $category = $transaction->categories->first();+ $category = $transaction->categories->first();/** @var null|Category $journalCategory */$journalCategory = $journal->categories->first();diff --git a/app/Console/Commands/Upgrade/UpgradesJournalNotes.php b/app/Console/Commands/Upgrade/UpgradesJournalNotes.phpindex 609e4251c6..e3132be9c8 100644--- a/app/Console/Commands/Upgrade/UpgradesJournalNotes.php+++ b/app/Console/Commands/Upgrade/UpgradesJournalNotes.php@@ -37,9 +37,9 @@ class UpgradesJournalNotes extends Commandpublic const string CONFIG_NAME = '480_migrate_notes';- protected $description = 'Migrate notes for transaction journals.';+ protected $description = 'Migrate notes for transaction journals.';- protected $signature = 'upgrade:480-notes {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:480-notes {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -59,8 +59,8 @@ class UpgradesJournalNotes extends Command/** @var TransactionJournalMeta $meta */foreach ($set as $meta) {- $journal = $meta->transactionJournal;- $note = $journal->notes()->first();+ $journal = $meta->transactionJournal;+ $note = $journal->notes()->first();if (null === $note) {$note = new Note();$note->noteable()->associate($journal);@@ -78,7 +78,7 @@ class UpgradesJournalNotes extends Command$this->friendlyInfo(sprintf('Migrated %d note(s).', $count));}- $end = round(microtime(true) - $start, 2);+ $end = round(microtime(true) - $start, 2);$this->friendlyInfo(sprintf('Migrated notes in %s seconds.', $end));$this->markAsExecuted();@@ -89,7 +89,7 @@ class UpgradesJournalNotes extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): voiddiff --git a/app/Console/Commands/Upgrade/UpgradesLiabilities.php b/app/Console/Commands/Upgrade/UpgradesLiabilities.phpindex 7aae7c8dd5..bd4431af8f 100644--- a/app/Console/Commands/Upgrade/UpgradesLiabilities.php+++ b/app/Console/Commands/Upgrade/UpgradesLiabilities.php@@ -41,8 +41,8 @@ class UpgradesLiabilities extends Commandpublic const string CONFIG_NAME = '560_upgrade_liabilities';- protected $description = 'Upgrade liabilities to new 5.6.0 structure.';- protected $signature = 'upgrade:560-liabilities {--F|force : Force the execution of this command.}';+ protected $description = 'Upgrade liabilities to new 5.6.0 structure.';+ protected $signature = 'upgrade:560-liabilities {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -95,7 +95,7 @@ class UpgradesLiabilities extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): void@@ -109,7 +109,8 @@ class UpgradesLiabilities extends Command->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')->whereIn('account_types.type', config('firefly.valid_liabilities'))- ->get(['accounts.*']);+ ->get(['accounts.*'])+ ;/** @var Account $account */foreach ($accounts as $account) {@@ -133,7 +134,7 @@ class UpgradesLiabilities extends Commandprivate function upgradeLiability(Account $account): void{/** @var AccountRepositoryInterface $repository */- $repository = app(AccountRepositoryInterface::class);+ $repository = app(AccountRepositoryInterface::class);$repository->setUser($account->user);// get opening balance, and correct if necessary.@@ -144,7 +145,7 @@ class UpgradesLiabilities extends Command}// add liability direction property (if it does not yet exist!)- $value = $repository->getMetaValue($account, 'liability_direction');+ $value = $repository->getMetaValue($account, 'liability_direction');if (null === $value) {/** @var AccountMetaFactory $factory */$factory = app(AccountMetaFactory::class);diff --git a/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php b/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.phpindex 4baad177df..3aef1d4bee 100644--- a/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php+++ b/app/Console/Commands/Upgrade/UpgradesLiabilitiesEight.php@@ -44,8 +44,8 @@ class UpgradesLiabilitiesEight extends Commandpublic const string CONFIG_NAME = '600_upgrade_liabilities';- protected $description = 'Upgrade liabilities to new 6.0.0 structure.';- protected $signature = 'upgrade:600-liabilities {--F|force : Force the execution of this command.}';+ protected $description = 'Upgrade liabilities to new 6.0.0 structure.';+ protected $signature = 'upgrade:600-liabilities {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -67,9 +67,10 @@ class UpgradesLiabilitiesEight extends Command{$liabilityType = TransactionType::whereType(TransactionTypeEnum::LIABILITY_CREDIT->value)->first();$liabilityJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->where('transactions.account_id', $account->id)- ->where('transaction_journals.transaction_type_id', $liabilityType->id)- ->first(['transaction_journals.*']);+ ->where('transactions.account_id', $account->id)+ ->where('transaction_journals.transaction_type_id', $liabilityType->id)+ ->first(['transaction_journals.*'])+ ;if (null !== $liabilityJournal && null !== $liabilityJournal->transactionGroup) {$group = $liabilityJournal->transactionGroup;$service = new TransactionGroupDestroyService();@@ -85,7 +86,7 @@ class UpgradesLiabilitiesEight extends Command$account->id)->get(['transaction_journals.*']);- $service = app(TransactionGroupDestroyService::class);+ $service = app(TransactionGroupDestroyService::class);/** @var TransactionJournal $journal */foreach ($journals as $journal) {@@ -104,22 +105,24 @@ class UpgradesLiabilitiesEight extends Command$openingBalanceType = TransactionType::whereType(TransactionTypeEnum::OPENING_BALANCE->value)->first();/** @var TransactionType $liabilityType */- $liabilityType = TransactionType::whereType(TransactionTypeEnum::LIABILITY_CREDIT->value)->first();+ $liabilityType = TransactionType::whereType(TransactionTypeEnum::LIABILITY_CREDIT->value)->first();/** @var null|TransactionJournal $openingJournal */- $openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->where('transactions.account_id', $account->id)- ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)- ->first(['transaction_journals.*']);+ $openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')+ ->where('transactions.account_id', $account->id)+ ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)+ ->first(['transaction_journals.*'])+ ;if (null === $openingJournal) {return false;}/** @var null|TransactionJournal $liabilityJournal */- $liabilityJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->where('transactions.account_id', $account->id)- ->where('transaction_journals.transaction_type_id', $liabilityType->id)- ->first(['transaction_journals.*']);+ $liabilityJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')+ ->where('transactions.account_id', $account->id)+ ->where('transaction_journals.transaction_type_id', $liabilityType->id)+ ->first(['transaction_journals.*'])+ ;if (null === $liabilityJournal) {return false;}@@ -131,7 +134,7 @@ class UpgradesLiabilitiesEight extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): void@@ -144,16 +147,17 @@ class UpgradesLiabilitiesEight extends Command$openingBalanceType = TransactionType::whereType(TransactionTypeEnum::OPENING_BALANCE->value)->first();/** @var TransactionJournal $openingJournal */- $openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')- ->where('transactions.account_id', $account->id)- ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)- ->first(['transaction_journals.*']);+ $openingJournal = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')+ ->where('transactions.account_id', $account->id)+ ->where('transaction_journals.transaction_type_id', $openingBalanceType->id)+ ->first(['transaction_journals.*'])+ ;/** @var null|Transaction $source */- $source = $openingJournal->transactions()->where('amount', '<', 0)->first();+ $source = $openingJournal->transactions()->where('amount', '<', 0)->first();/** @var null|Transaction $dest */- $dest = $openingJournal->transactions()->where('amount', '>', 0)->first();+ $dest = $openingJournal->transactions()->where('amount', '>', 0)->first();if (null !== $source && null !== $dest) {$sourceId = $source->account_id;$destId = $dest->account_id;@@ -173,7 +177,8 @@ class UpgradesLiabilitiesEight extends Command->accounts()->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')->whereIn('account_types.type', config('firefly.valid_liabilities'))- ->get(['accounts.*']);+ ->get(['accounts.*'])+ ;/** @var Account $account */foreach ($accounts as $account) {@@ -200,7 +205,7 @@ class UpgradesLiabilitiesEight extends Command$repository = app(AccountRepositoryInterface::class);$repository->setUser($account->user);- $direction = $repository->getMetaValue($account, 'liability_direction');+ $direction = $repository->getMetaValue($account, 'liability_direction');if ('credit' === $direction && $this->hasBadOpening($account)) {$this->deleteCreditTransaction($account);$this->reverseOpeningBalance($account);diff --git a/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php b/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.phpindex 47a6cca8ae..7e2d385682 100644--- a/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php+++ b/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php@@ -39,10 +39,10 @@ class UpgradesMultiPiggyBanks extends Commandpublic const string CONFIG_NAME = '620_make_multi_piggies';- protected $description = 'Upgrade piggy banks so they can use multiple accounts.';+ protected $description = 'Upgrade piggy banks so they can use multiple accounts.';- protected $signature = 'upgrade:620-piggy-banks {--F|force : Force the execution of this command.}';- private AccountRepositoryInterface $accountRepository;+ protected $signature = 'upgrade:620-piggy-banks {--F|force : Force the execution of this command.}';+ private AccountRepositoryInterface $accountRepository;private PiggyBankRepositoryInterface $repository;/**@@ -67,7 +67,7 @@ class UpgradesMultiPiggyBanks extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): void@@ -85,8 +85,8 @@ class UpgradesMultiPiggyBanks extends Command}$this->repository->setUser($piggyBank->account->user);$this->accountRepository->setUser($piggyBank->account->user);- $repetition = $this->repository->getRepetition($piggyBank, true);- $currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? Amount::getPrimaryCurrencyByUserGroup($piggyBank->account->user->userGroup);+ $repetition = $this->repository->getRepetition($piggyBank, true);+ $currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? Amount::getPrimaryCurrencyByUserGroup($piggyBank->account->user->userGroup);// update piggy bank to have a currency.$piggyBank->transaction_currency_id = $currency->id;@@ -94,7 +94,7 @@ class UpgradesMultiPiggyBanks extends Command// store current amount in account association.$piggyBank->accounts()->sync([$piggyBank->account->id => ['current_amount' => $repetition->current_amount]]);- $piggyBank->account_id = null;+ $piggyBank->account_id = null;$piggyBank->saveQuietly();// remove all repetitions (no longer used)diff --git a/app/Console/Commands/Upgrade/UpgradesPrimaryCurrencyAmounts.php b/app/Console/Commands/Upgrade/UpgradesPrimaryCurrencyAmounts.phpindex eeef4a801c..5d927e7a07 100644--- a/app/Console/Commands/Upgrade/UpgradesPrimaryCurrencyAmounts.php+++ b/app/Console/Commands/Upgrade/UpgradesPrimaryCurrencyAmounts.php@@ -35,9 +35,9 @@ class UpgradesPrimaryCurrencyAmounts extends Commandpublic const string CONFIG_NAME = '620_pc_amounts';- protected $description = 'Runs the primary currency amounts calculations.';+ protected $description = 'Runs the primary currency amounts calculations.';- protected $signature = 'upgrade:620-pc-amounts {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:620-pc-amounts {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -61,7 +61,7 @@ class UpgradesPrimaryCurrencyAmounts extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): voiddiff --git a/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php b/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.phpindex b5f21859d8..3c1b67b325 100644--- a/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php+++ b/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php@@ -30,6 +30,7 @@ use FireflyIII\Models\RecurrenceMeta;use FireflyIII\Models\RecurrenceTransactionMeta;use FireflyIII\Support\Facades\AppConfiguration;use Illuminate\Console\Command;+use function Safe\json_encode;class UpgradesRecurrenceMetaData extends Command@@ -38,9 +39,9 @@ class UpgradesRecurrenceMetaData extends Commandpublic const string CONFIG_NAME = '481_migrate_recurrence_meta';- protected $description = 'Migrate recurrence meta data';+ protected $description = 'Migrate recurrence meta data';- protected $signature = 'upgrade:481-recurrence-meta {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:481-recurrence-meta {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -67,7 +68,7 @@ class UpgradesRecurrenceMetaData extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): void@@ -78,7 +79,7 @@ class UpgradesRecurrenceMetaData extends Commandprivate function migrateEntry(RecurrenceMeta $meta): int{/** @var null|Recurrence $recurrence */- $recurrence = $meta->recurrence;+ $recurrence = $meta->recurrence;if (null === $recurrence) {return 0;}@@ -86,7 +87,7 @@ class UpgradesRecurrenceMetaData extends Commandif (null === $firstTransaction) {return 0;}- $value = $meta->value;+ $value = $meta->value;if ('tags' === $meta->name) {$array = explode(',', $meta->value);@@ -101,7 +102,7 @@ class UpgradesRecurrenceMetaData extends Commandprivate function migrateMetaData(): int{- $count = 0;+ $count = 0;// get all recurrence meta data:$collection = RecurrenceMeta::query()->with('recurrence')->get();diff --git a/app/Console/Commands/Upgrade/UpgradesRuleActions.php b/app/Console/Commands/Upgrade/UpgradesRuleActions.phpindex ae5bc0af06..38d55c2156 100644--- a/app/Console/Commands/Upgrade/UpgradesRuleActions.php+++ b/app/Console/Commands/Upgrade/UpgradesRuleActions.php@@ -35,9 +35,9 @@ class UpgradesRuleActions extends Commandpublic const string CONFIG_NAME = '610_migrate_rule_actions';- protected $description = 'Migrate rule actions away from expression engine';+ protected $description = 'Migrate rule actions away from expression engine';- protected $signature = 'upgrade:600-rule-actions {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:600-rule-actions {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -65,7 +65,7 @@ class UpgradesRuleActions extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): void@@ -80,8 +80,8 @@ class UpgradesRuleActions extends Command/** @var RuleAction $action */foreach ($actions as $action) {- if (str_starts_with((string)$action->action_value, '=')) {- $action->action_value = sprintf('%s%s', '\=', substr((string)$action->action_value, 1));+ if (str_starts_with((string) $action->action_value, '=')) {+ $action->action_value = sprintf('%s%s', '\=', substr((string) $action->action_value, 1));$action->save();++$count;}diff --git a/app/Console/Commands/Upgrade/UpgradesTagLocations.php b/app/Console/Commands/Upgrade/UpgradesTagLocations.phpindex f63ef5f5e0..9845827939 100644--- a/app/Console/Commands/Upgrade/UpgradesTagLocations.php+++ b/app/Console/Commands/Upgrade/UpgradesTagLocations.php@@ -36,9 +36,9 @@ class UpgradesTagLocations extends Commandpublic const string CONFIG_NAME = '500_migrate_tag_locations';- protected $description = 'Migrate tag locations.';+ protected $description = 'Migrate tag locations.';- protected $signature = 'upgrade:500-tag-locations {--F|force : Force the execution of this command.}';+ protected $signature = 'upgrade:500-tag-locations {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -65,7 +65,7 @@ class UpgradesTagLocations extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): void@@ -82,9 +82,9 @@ class UpgradesTagLocations extends Command$location->locatable()->associate($tag);$location->save();- $tag->longitude = null;- $tag->latitude = null;- $tag->zoomLevel = null;+ $tag->longitude = null;+ $tag->latitude = null;+ $tag->zoomLevel = null;$tag->save();}diff --git a/app/Console/Commands/Upgrade/UpgradesToGroups.php b/app/Console/Commands/Upgrade/UpgradesToGroups.phpindex 7ded66b1e9..1cb86fa1fd 100644--- a/app/Console/Commands/Upgrade/UpgradesToGroups.php+++ b/app/Console/Commands/Upgrade/UpgradesToGroups.php@@ -47,13 +47,13 @@ class UpgradesToGroups extends Commandpublic const string CONFIG_NAME = '480_migrated_to_groups';- protected $description = 'Migrates a pre-4.7.8 transaction structure to the 4.7.8+ transaction structure.';- protected $signature = 'upgrade:480-migrate-to-groups {--F|force : Force the migration, even if it fired before.}';+ protected $description = 'Migrates a pre-4.7.8 transaction structure to the 4.7.8+ transaction structure.';+ protected $signature = 'upgrade:480-migrate-to-groups {--F|force : Force the migration, even if it fired before.}';private JournalCLIRepositoryInterface $cliRepository;- private int $count;- private TransactionGroupFactory $groupFactory;- private JournalRepositoryInterface $journalRepository;- private JournalDestroyService $service;+ private int $count;+ private TransactionGroupFactory $groupFactory;+ private JournalRepositoryInterface $journalRepository;+ private JournalDestroyService $service;/*** Execute the console command.@@ -86,7 +86,7 @@ class UpgradesToGroups extends Commandprivate function findOpposingTransaction(TransactionJournal $journal, Transaction $transaction): ?Transaction{$set = $journal->transactions->filter(static function (Transaction $subject) use ($transaction): bool {- $amount = -(float)$transaction->amount === (float)$subject->amount; // intentional float+ $amount = -(float) $transaction->amount === (float) $subject->amount; // intentional float$identifier = $transaction->identifier === $subject->identifier;Log::debug(sprintf('Amount the same? %s', var_export($amount, return: true)));Log::debug(sprintf('ID the same? %s', var_export($identifier, return: true)));@@ -104,14 +104,14 @@ class UpgradesToGroups extends Commandprivate function generateTransaction(TransactionJournal $journal, Transaction $transaction): array{Log::debug(sprintf('Now going to add transaction #%d to the array.', $transaction->id));- $opposingTr = $this->findOpposingTransaction($journal, $transaction);+ $opposingTr = $this->findOpposingTransaction($journal, $transaction);if (!$opposingTr instanceof Transaction) {$this->friendlyError(sprintf(- 'Journal #%d has no opposing transaction for transaction #%d. Cannot upgrade this entry.',- $journal->id,- $transaction->id- ));+ 'Journal #%d has no opposing transaction for transaction #%d. Cannot upgrade this entry.',+ $journal->id,+ $transaction->id+ ));return [];}@@ -143,11 +143,11 @@ class UpgradesToGroups extends Command$invoiceDate = $this->cliRepository->getMetaDate($journal, 'invoice_date');// overrule journal category with transaction category.- $budgetId = $this->getTransactionBudget($transaction, $opposingTr) ?? $budgetId;- $categoryId = $this->getTransactionCategory($transaction, $opposingTr) ?? $categoryId;+ $budgetId = $this->getTransactionBudget($transaction, $opposingTr) ?? $budgetId;+ $categoryId = $this->getTransactionCategory($transaction, $opposingTr) ?? $categoryId;return [- 'type' => strtolower((string)$journal->transactionType->type),+ 'type' => strtolower((string) $journal->transactionType->type),'date' => $journal->date,'user' => $journal->user,'user_group' => $journal->user->userGroup,@@ -189,7 +189,7 @@ class UpgradesToGroups extends Commandprivate function getDestinationTransactions(TransactionJournal $journal): Collection{- return $journal->transactions->filter(static fn(Transaction $transaction): bool => $transaction->amount > 0);+ return $journal->transactions->filter(static fn (Transaction $transaction): bool => $transaction->amount > 0);}private function getTransactionBudget(Transaction $left, Transaction $right): ?int@@ -249,11 +249,11 @@ class UpgradesToGroups extends Commandprivate function giveGroup(array $array): void{$groupId = DB::table('transaction_groups')->insertGetId([- 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),- 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),- 'title' => null,- 'user_id' => $array['user_id'],- ]);+ 'created_at' => Carbon::now()->format('Y-m-d H:i:s'),+ 'updated_at' => Carbon::now()->format('Y-m-d H:i:s'),+ 'title' => null,+ 'user_id' => $array['user_id'],+ ]);DB::table('transaction_journals')->where('id', $array['id'])->update(['transaction_group_id' => $groupId]);++$this->count;}@@ -262,7 +262,7 @@ class UpgradesToGroups extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}/**@@ -330,7 +330,7 @@ class UpgradesToGroups extends Command$data['transactions'][] = $this->generateTransaction($journal, $transaction);}Log::debug(sprintf('Now calling transaction journal factory (%d transactions in array)', count($data['transactions'])));- $group = $this->groupFactory->create($data);+ $group = $this->groupFactory->create($data);Log::debug('Done calling transaction journal factory');// delete the old transaction journal.@@ -340,17 +340,17 @@ class UpgradesToGroups extends Command// report on result:Log::debug(sprintf(- 'Migrated journal #%d into group #%d with these journals: #%s',- $journal->id,- $group->id,- implode(', #', $group->transactionJournals->pluck('id')->toArray())- ));+ 'Migrated journal #%d into group #%d with these journals: #%s',+ $journal->id,+ $group->id,+ implode(', #', $group->transactionJournals->pluck('id')->toArray())+ ));$this->friendlyInfo(sprintf(- 'Migrated journal #%d into group #%d with these journals: #%s',- $journal->id,- $group->id,- implode(', #', $group->transactionJournals->pluck('id')->toArray())- ));+ 'Migrated journal #%d into group #%d with these journals: #%s',+ $journal->id,+ $group->id,+ implode(', #', $group->transactionJournals->pluck('id')->toArray())+ ));}private function markAsMigrated(): voiddiff --git a/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php b/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.phpindex 2ef6cd9493..b340f8c5c4 100644--- a/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php+++ b/app/Console/Commands/Upgrade/UpgradesTransferCurrencies.php@@ -40,14 +40,14 @@ class UpgradesTransferCurrencies extends Command{use ShowsFriendlyMessages;- public const string CONFIG_NAME = '480_transfer_currencies';+ public const string CONFIG_NAME = '480_transfer_currencies';- protected $description = 'Updates transfer currency information.';- protected $signature = 'upgrade:480-transfer-currencies {--F|force : Force the execution of this command.}';- private array $accountCurrencies;- private AccountRepositoryInterface $accountRepos;+ protected $description = 'Updates transfer currency information.';+ protected $signature = 'upgrade:480-transfer-currencies {--F|force : Force the execution of this command.}';+ private array $accountCurrencies;+ private AccountRepositoryInterface $accountRepos;private JournalCLIRepositoryInterface $cliRepos;- private int $count;+ private int $count;private ?Account $destinationAccount = null;private ?TransactionCurrency $destinationCurrency = null;@@ -78,6 +78,31 @@ class UpgradesTransferCurrencies extends Commandreturn 0;}+ /**+ * The destination transaction must have the correct currency. If not, it will be set by+ * taking it from the destination account's preference.+ */+ private function fixDestinationUnmatchedCurrency(): void+ {+ if (+ $this->destinationCurrency instanceof TransactionCurrency+ && null === $this->destinationTransaction->foreign_amount+ && (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.',+ $this->destinationTransaction->id,+ $this->destinationTransaction->transaction_currency_id,+ $this->destinationAccount->id,+ $this->destinationTransaction->amount+ );+ $this->friendlyWarning($message);+ ++$this->count;+ $this->destinationTransaction->transaction_currency_id = $this->destinationCurrency->id;+ $this->destinationTransaction->save();+ }+ }+/*** The destination transaction must have a currency. If not, it will be added by* taking it from the destination account's preference.@@ -108,35 +133,10 @@ class UpgradesTransferCurrencies extends Command$this->destinationTransaction->save();++$this->count;$this->friendlyInfo(sprintf(- 'Restored foreign amount of destination transaction #%d to %s',- $this->destinationTransaction->id,- $this->destinationTransaction->foreign_amount- ));- }- }-- /**- * The destination transaction must have the correct currency. If not, it will be set by- * taking it from the destination account's preference.- */- private function fixDestinationUnmatchedCurrency(): void- {- if (- $this->destinationCurrency instanceof TransactionCurrency- && null === $this->destinationTransaction->foreign_amount- && (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.',+ 'Restored foreign amount of destination transaction #%d to %s',$this->destinationTransaction->id,- $this->destinationTransaction->transaction_currency_id,- $this->destinationAccount->id,- $this->destinationTransaction->amount- );- $this->friendlyWarning($message);- ++$this->count;- $this->destinationTransaction->transaction_currency_id = $this->destinationCurrency->id;- $this->destinationTransaction->save();+ $this->destinationTransaction->foreign_amount+ ));}}@@ -149,8 +149,8 @@ class UpgradesTransferCurrencies extends Command{if ($this->destinationCurrency->id === $this->sourceCurrency->id) {// update both transactions to match:- $this->sourceTransaction->foreign_amount = null;- $this->sourceTransaction->foreign_currency_id = null;+ $this->sourceTransaction->foreign_amount = null;+ $this->sourceTransaction->foreign_currency_id = null;$this->destinationTransaction->foreign_amount = null;$this->destinationTransaction->foreign_currency_id = null;@@ -177,10 +177,10 @@ class UpgradesTransferCurrencies extends Command$this->destinationTransaction->save();++$this->count;$this->friendlyInfo(sprintf(- 'Verified foreign currency ID of transaction #%d and #%d',- $this->sourceTransaction->id,- $this->destinationTransaction->id- ));+ 'Verified foreign currency ID of transaction #%d and #%d',+ $this->sourceTransaction->id,+ $this->destinationTransaction->id+ ));}}@@ -214,10 +214,10 @@ class UpgradesTransferCurrencies extends Command$this->sourceTransaction->save();++$this->count;$this->friendlyInfo(sprintf(- 'Restored foreign amount of source transaction #%d to %s',- $this->sourceTransaction->id,- $this->sourceTransaction->foreign_amount- ));+ 'Restored foreign amount of source transaction #%d to %s',+ $this->sourceTransaction->id,+ $this->sourceTransaction->foreign_amount+ ));}}@@ -230,9 +230,9 @@ class UpgradesTransferCurrencies extends Commandif ($this->sourceCurrency instanceof TransactionCurrency&& 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(+ $message = sprintf('Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',$this->sourceTransaction->id,$this->sourceTransaction->transaction_currency_id,@@ -251,7 +251,7 @@ class UpgradesTransferCurrencies 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(@@ -269,14 +269,14 @@ class UpgradesTransferCurrencies extends Commandprivate function getCurrency(Account $account): ?TransactionCurrency{- $accountId = $account->id;+ $accountId = $account->id;if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {return null;}if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {return $this->accountCurrencies[$accountId];}- $currency = $this->accountRepos->getAccountCurrency($account);+ $currency = $this->accountRepos->getAccountCurrency($account);if (!$currency instanceof TransactionCurrency) {$this->accountCurrencies[$accountId] = 0;@@ -335,7 +335,7 @@ class UpgradesTransferCurrencies extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function isNoCurrencyPresent(): bool@@ -448,9 +448,9 @@ class UpgradesTransferCurrencies extends Commandif ($this->isNoCurrencyPresent()) {$this->friendlyError(sprintf(- 'Source or destination accounts for transaction journal #%d have no currency information. Cannot fix this one.',- $transfer->id- ));+ 'Source or destination accounts for transaction journal #%d have no currency information. Cannot fix this one.',+ $transfer->id+ ));return;}diff --git a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.phpindex b0461ecbda..e9729aa84a 100644--- a/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php+++ b/app/Console/Commands/Upgrade/UpgradesVariousCurrencyInformation.php@@ -43,13 +43,13 @@ class UpgradesVariousCurrencyInformation extends Commandpublic const string CONFIG_NAME = '480_other_currencies';- protected $description = 'Update all journal currency information.';- protected $signature = 'upgrade:480-currency-information {--F|force : Force the execution of this command.}';- private array $accountCurrencies;- private AccountRepositoryInterface $accountRepos;+ protected $description = 'Update all journal currency information.';+ protected $signature = 'upgrade:480-currency-information {--F|force : Force the execution of this command.}';+ private array $accountCurrencies;+ private AccountRepositoryInterface $accountRepos;private JournalCLIRepositoryInterface $cliRepos;- private int $count;- private JournalRepositoryInterface $journalRepos;+ private int $count;+ private JournalRepositoryInterface $journalRepos;/*** Execute the console command.@@ -74,14 +74,14 @@ class UpgradesVariousCurrencyInformation extends Commandprivate function getCurrency(Account $account): ?TransactionCurrency{- $accountId = $account->id;+ $accountId = $account->id;if (array_key_exists($accountId, $this->accountCurrencies) && 0 === $this->accountCurrencies[$accountId]) {return null;}if (array_key_exists($accountId, $this->accountCurrencies) && $this->accountCurrencies[$accountId] instanceof TransactionCurrency) {return $this->accountCurrencies[$accountId];}- $currency = $this->accountRepos->getAccountCurrency($account);+ $currency = $this->accountRepos->getAccountCurrency($account);if (!$currency instanceof TransactionCurrency) {$this->accountCurrencies[$accountId] = 0;@@ -125,7 +125,8 @@ class UpgradesVariousCurrencyInformation extends Command->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')->where('account_types.type', '!=', AccountTypeEnum::INITIAL_BALANCE->value)- ->first(['transactions.*']);+ ->first(['transactions.*'])+ ;break;@@ -137,7 +138,8 @@ class UpgradesVariousCurrencyInformation extends Command->leftJoin('accounts', 'transactions.account_id', '=', 'accounts.id')->leftJoin('account_types', 'accounts.account_type_id', '=', 'account_types.id')->where('account_types.type', '!=', AccountTypeEnum::RECONCILIATION->value)- ->first(['transactions.*']);+ ->first(['transactions.*'])+ ;break;}@@ -149,7 +151,7 @@ class UpgradesVariousCurrencyInformation extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function isMultiCurrency(Account $account): bool@@ -200,11 +202,11 @@ class UpgradesVariousCurrencyInformation extends Command$isMultiCurrency = $this->isMultiCurrency($account);if (!$currency instanceof TransactionCurrency) {$this->friendlyError(sprintf(- 'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected',- $account->id,- $account->name,- $journal->id- ));+ 'Account #%d ("%s") has no currency preference, so transaction journal #%d can\'t be corrected',+ $account->id,+ $account->name,+ $journal->id+ ));++$this->count;return;@@ -241,11 +243,11 @@ class UpgradesVariousCurrencyInformation extends Commandprivate function updateOtherJournalsCurrencies(): void{$set = $this->cliRepos->getAllJournals([- TransactionTypeEnum::WITHDRAWAL->value,- TransactionTypeEnum::DEPOSIT->value,- TransactionTypeEnum::OPENING_BALANCE->value,- TransactionTypeEnum::RECONCILIATION->value,- ]);+ TransactionTypeEnum::WITHDRAWAL->value,+ TransactionTypeEnum::DEPOSIT->value,+ TransactionTypeEnum::OPENING_BALANCE->value,+ TransactionTypeEnum::RECONCILIATION->value,+ ]);/** @var TransactionJournal $journal */foreach ($set as $journal) {diff --git a/app/Console/Commands/Upgrade/UpgradesWebhooks.php b/app/Console/Commands/Upgrade/UpgradesWebhooks.phpindex 5806e905a3..865b510524 100644--- a/app/Console/Commands/Upgrade/UpgradesWebhooks.php+++ b/app/Console/Commands/Upgrade/UpgradesWebhooks.php@@ -41,8 +41,8 @@ class UpgradesWebhooks extends Commandpublic const string CONFIG_NAME = '640_upgrade_webhooks';- protected $description = 'Upgrade webhooks so they can handle multiple triggers.';- protected $signature = 'upgrade:640-upgrade-webhooks {--F|force : Force the execution of this command.}';+ protected $description = 'Upgrade webhooks so they can handle multiple triggers.';+ protected $signature = 'upgrade:640-upgrade-webhooks {--F|force : Force the execution of this command.}';/*** Execute the console command.@@ -66,7 +66,7 @@ class UpgradesWebhooks extends Command{$configVar = AppConfiguration::get(self::CONFIG_NAME, false);- return (bool)$configVar?->data;+ return (bool) $configVar?->data;}private function markAsExecuted(): void@@ -76,17 +76,17 @@ class UpgradesWebhooks extends Commandprivate function upgradeWebhook(Webhook $webhook): void{- $delivery = WebhookDelivery::tryFrom((int)$webhook->delivery);- $response = WebhookResponse::tryFrom((int)$webhook->response);- $trigger = WebhookTrigger::tryFrom((int)$webhook->trigger);+ $delivery = WebhookDelivery::tryFrom((int) $webhook->delivery);+ $response = WebhookResponse::tryFrom((int) $webhook->response);+ $trigger = WebhookTrigger::tryFrom((int) $webhook->trigger);if (in_array(null, [$delivery, $response, $trigger], true)) {$this->friendlyError(sprintf('[a] Webhook #%d has an invalid delivery, response or trigger value. Will not upgrade.', $webhook->id));return;}- $deliveryModel = WebhookDeliveryModel::query()->where('key', $delivery->value)->first();- $responseModel = WebhookResponseModel::query()->where('key', $response->value)->first();- $triggerModel = WebhookTriggerModel::query()->where('key', $trigger->value)->first();+ $deliveryModel = WebhookDeliveryModel::query()->where('key', $delivery->value)->first();+ $responseModel = WebhookResponseModel::query()->where('key', $response->value)->first();+ $triggerModel = WebhookTriggerModel::query()->where('key', $trigger->value)->first();if (in_array(null, [$deliveryModel, $responseModel, $triggerModel], true)) {$this->friendlyError(sprintf('[b] Webhook #%d has an invalid delivery, response or trigger model. Will not upgrade.', $webhook->id));diff --git a/app/Console/Commands/VerifiesAccessToken.php b/app/Console/Commands/VerifiesAccessToken.phpindex b7d20d5e70..67aee2cfc1 100644--- a/app/Console/Commands/VerifiesAccessToken.php+++ b/app/Console/Commands/VerifiesAccessToken.php@@ -37,12 +37,21 @@ use Illuminate\Support\Facades\Log;*/trait VerifiesAccessToken{+ /**+ * Abstract method to make sure trait knows about method "option".+ *+ * @param null|string $key+ *+ * @return mixed+ */+ abstract public function option($key = null);+/*** @throws FireflyException*/public function getUser(): User{- $userId = (int)$this->option('user');+ $userId = (int) $this->option('user');/** @var UserRepositoryInterface $repository */$repository = app(UserRepositoryInterface::class);@@ -54,26 +63,17 @@ trait VerifiesAccessTokenreturn $user;}- /**- * Abstract method to make sure trait knows about method "option".- *- * @param null|string $key- *- * @return mixed- */- abstract public function option($key = null);-/*** Returns false when given token does not match given user token.*/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);- $user = $repository->find($userId);+ $repository = app(UserRepositoryInterface::class);+ $user = $repository->find($userId);if (null === $user) {Log::error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId));diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.phpindex ef20fe9a26..3a71f8b254 100644--- a/app/Http/Controllers/Auth/TwoFactorController.php+++ b/app/Http/Controllers/Auth/TwoFactorController.php@@ -132,7 +132,7 @@ final class TwoFactorController extends ControllerLog::channel('audit')->info(sprintf('MFA failure count is set to %d.', $preference));Preferences::set('mfa_failure_count', $preference, true);$preference = clamp($preference, 2, 16);- $count = 2 ** $preference;+ $count = 2 ** $preference;Log::debug(sprintf('Sleeping for %d seconds to slow down brute force attacks.', $count));sleep($count);}diff --git a/app/Http/Controllers/Budget/BudgetLimitController.php b/app/Http/Controllers/Budget/BudgetLimitController.phpindex de7337738f..04d75cd738 100644--- a/app/Http/Controllers/Budget/BudgetLimitController.php+++ b/app/Http/Controllers/Budget/BudgetLimitController.php@@ -198,7 +198,13 @@ final class BudgetLimitController extends Controllerif ($request->expectsJson()) {$array = $limit->toArray();// add some extra metadata:- $spentArr = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection()->push($budget), $currency);+ $spentArr = $this->opsRepository->sumExpenses(+ $limit->start_date,+ $limit->end_date,+ null,+ new Collection()->push($budget),+ $currency+ );$array['spent'] = $spentArr[$currency->id]['sum'] ?? '0';$array['left_formatted'] = Amount::formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));$array['amount_formatted'] = Amount::formatAnything($limit->transactionCurrency, $limit['amount']);diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.phpindex 215ebbd484..d40d4432a3 100644--- a/app/Http/Controllers/Budget/IndexController.php+++ b/app/Http/Controllers/Budget/IndexController.php@@ -284,7 +284,10 @@ final class IndexController extends Controllerif (array_key_exists($currency->id, $spentArr) && array_key_exists('sum', $spentArr[$currency->id])) {$array['spent'][$currency->id]['spent'] = $spentArr[$currency->id]['sum'];- $array['spent'][$currency->id]['spent_outside'] = Steam::negative(bcsub($spentInLimits[$currency->id], $spentArr[$currency->id]['sum']));+ $array['spent'][$currency->id]['spent_outside'] = Steam::negative(bcsub(+ $spentInLimits[$currency->id],+ $spentArr[$currency->id]['sum']+ ));$array['spent'][$currency->id]['currency_id'] = $currency->id;$array['spent'][$currency->id]['currency_symbol'] = $currency->symbol;$array['spent'][$currency->id]['currency_decimal_places'] = $currency->decimal_places;diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.phpindex ad724137dc..f4b32fe5c5 100644--- a/app/Http/Controllers/Chart/BudgetController.php+++ b/app/Http/Controllers/Chart/BudgetController.php@@ -539,7 +539,13 @@ final class BudgetController extends Controller}// get spent amount in this period for this currency.- $sum = $this->opsRepository->sumExpenses($currentStart, $currentEnd, $accounts, new Collection()->push($budget), $currency);+ $sum = $this->opsRepository->sumExpenses(+ $currentStart,+ $currentEnd,+ $accounts,+ new Collection()->push($budget),+ $currency+ );$amount = Steam::positive($sum[$currency->id]['sum'] ?? '0');$chartData[0]['entries'][$title] = Steam::bcround($amount, $currency->decimal_places);diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.phpindex 0f507d8c3f..2f556b3296 100644--- a/app/Http/Controllers/DebugController.php+++ b/app/Http/Controllers/DebugController.php@@ -65,8 +65,8 @@ use const PHP_SAPI;*/final class DebugController extends Controller{- use IsOldVersion;use GetConfigurationData;+ use IsOldVersion;/*** DebugController constructor.@@ -146,9 +146,9 @@ final class DebugController extends Controller$now = now(config('app.timezone'))->format('Y-m-d H:i:s');$logContent = '';- if(auth()->check() && auth()->user()->hasRole('owner')) {+ if (auth()->check() && auth()->user()->hasRole('owner')) {// get latest log file:- $logger = Log::driver();+ $logger = Log::driver();// PHPstan doesn't recognize the method because of its polymorphic nature.$handlers = $logger->getHandlers();@@ -162,7 +162,7 @@ final class DebugController extends Controller}if ('' !== $logContent) {// last few lines- $logContent = 'Truncated from this point <----|' . substr($logContent, -16_384);+ $logContent = 'Truncated from this point <----|'.substr($logContent, -16_384);}}diff --git a/app/Jobs/CreateAutoBudgetLimits.php b/app/Jobs/CreateAutoBudgetLimits.phpindex ceede3cd1c..39c60c3b9a 100644--- a/app/Jobs/CreateAutoBudgetLimits.php+++ b/app/Jobs/CreateAutoBudgetLimits.php@@ -135,7 +135,13 @@ class CreateAutoBudgetLimits implements ShouldQueue// if has one, calculate expenses and use that as a base.$repository = app(OperationsRepositoryInterface::class);$repository->setUser($autoBudget->budget->user);- $spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection()->push($autoBudget->budget), $autoBudget->transactionCurrency);+ $spent = $repository->sumExpenses(+ $previousStart,+ $previousEnd,+ null,+ new Collection()->push($autoBudget->budget),+ $autoBudget->transactionCurrency+ );$currencyId = $autoBudget->transaction_currency_id;$spentAmount = $spent[$currencyId]['sum'] ?? '0';Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));@@ -225,7 +231,13 @@ class CreateAutoBudgetLimits implements ShouldQueue// if has one, calculate expenses and use that as a base.$repository = app(OperationsRepositoryInterface::class);$repository->setUser($autoBudget->budget->user);- $spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection()->push($autoBudget->budget), $autoBudget->transactionCurrency);+ $spent = $repository->sumExpenses(+ $previousStart,+ $previousEnd,+ null,+ new Collection()->push($autoBudget->budget),+ $autoBudget->transactionCurrency+ );$currencyId = $autoBudget->transaction_currency_id;$spentAmount = $spent[$currencyId]['sum'] ?? '0';Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));diff --git a/app/Rules/Webhook/IsValidWebhookUrl.php b/app/Rules/Webhook/IsValidWebhookUrl.phpindex dc0c93333c..931093f2f4 100644--- a/app/Rules/Webhook/IsValidWebhookUrl.php+++ b/app/Rules/Webhook/IsValidWebhookUrl.php@@ -40,8 +40,8 @@ class IsValidWebhookUrl implements ValidationRulepublic function validate(string $attribute, mixed $value, Closure $fail): void{$value = (string) $value;- $parsed = parse_url($value, PHP_URL_HOST);- if(!is_string($parsed)) {+ $parsed = parse_url($value, PHP_URL_HOST);+ if (!is_string($parsed)) {$fail('validation.bad_url')->translate();}$resolved = gethostbyname($parsed);@@ -70,7 +70,7 @@ class IsValidWebhookUrl implements ValidationRule$validProtocols = AppConfiguration::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data;$parts = explode(',', $validProtocols);$valid = false;- $scheme = parse_url($value, PHP_URL_SCHEME);+ $scheme = parse_url($value, PHP_URL_SCHEME);foreach ($parts as $part) {if (is_string($scheme) && str_starts_with($scheme, $part)) {$valid = true;diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.phpindex a3a940b1ba..a507156873 100644--- a/app/Support/Http/Controllers/AugumentData.php+++ b/app/Support/Http/Controllers/AugumentData.php@@ -222,7 +222,14 @@ trait AugumentData$currentEnd->addMonth();}// primary currency amount.- $expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $entry->transactionCurrency, $this->convertToPrimary);+ $expenses = $opsRepository->sumExpenses(+ $currentStart,+ $currentEnd,+ null,+ $budgetCollection,+ $entry->transactionCurrency,+ $this->convertToPrimary+ );$spent = $expenses[$currency->id]['sum'] ?? '0';$entry->pc_spent = $spent;diff --git a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php b/app/Support/JsonApi/Enrichments/RecurringEnrichment.phpindex d0c09bf027..2428353cb0 100644--- a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php+++ b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php@@ -354,7 +354,11 @@ class RecurringEnrichment implements EnrichmentInterface/** @var RecurrenceRepetition $repetition */foreach ($set as $repetition) {- $recurrence = $this->collection->filter(static fn (Recurrence $item): bool => (int) $item->id === (int) $repetition->recurrence_id)->first();+ $recurrence = $this->collection->filter(+ static fn (Recurrence $item): bool => (int) $item->id === (int) $repetition->recurrence_id+ )+ ->first()+ ;$fromDate = clone ($recurrence->latest_date ?? $recurrence->first_date);$recurrenceId = (int) $repetition->recurrence_id;$repId = (int) $repetition->id;diff --git a/composer.lock b/composer.lockindex 1c8d488849..b3e61bb0b3 100644--- a/composer.lock+++ b/composer.lock@@ -10373,24 +10373,46 @@},{"name": "driftingly/rector-laravel",- "version": "2.5.0",+ "version": "2.6.1","source": {"type": "git","url": "https://github.com/driftingly/rector-laravel.git",- "reference": "0dbdd842dfdbc821cfe5f47ca7326e2502b2a107"+ "reference": "8deb9786f50cb263be3e2219136e53d6d143a7d6"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/0dbdd842dfdbc821cfe5f47ca7326e2502b2a107",- "reference": "0dbdd842dfdbc821cfe5f47ca7326e2502b2a107",+ "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/8deb9786f50cb263be3e2219136e53d6d143a7d6",+ "reference": "8deb9786f50cb263be3e2219136e53d6d143a7d6","shasum": ""},"require": {- "php": "^7.4 || ^8.0",- "rector/rector": "^2.2.7",+ "php": ">=8.3",+ "rector/rector": "^2.6.4",+ "symplify/rule-doc-generator-contracts": "^11.2","webmozart/assert": "^1.11 || ^2.0"},+ "require-dev": {+ "boundwize/structarmed": "^0.16",+ "nette/utils": "^4.0",+ "nikic/php-parser": "^5.6",+ "phpstan/extension-installer": "^1.3",+ "phpstan/phpstan": "^2.2",+ "phpstan/phpstan-deprecation-rules": "^2.0",+ "phpstan/phpstan-strict-rules": "^2.0",+ "phpstan/phpstan-webmozart-assert": "^2.0",+ "phpunit/phpunit": "^10.5",+ "symplify/rule-doc-generator": "^12.2",+ "tightenco/duster": "^3.1",+ "tracy/tracy": "^2.10"+ },"type": "rector-extension",+ "extra": {+ "rector": {+ "includes": [+ "config/config.php"+ ]+ }+ },"autoload": {"psr-4": {"RectorLaravel\\": "src"@@ -10403,9 +10425,9 @@"description": "Rector upgrades rules for Laravel Framework","support": {"issues": "https://github.com/driftingly/rector-laravel/issues",- "source": "https://github.com/driftingly/rector-laravel/tree/2.5.0"+ "source": "https://github.com/driftingly/rector-laravel/tree/2.6.1"},- "time": "2026-06-02T16:22:14+00:00"+ "time": "2026-08-27T12:43:48+00:00"},{"name": "ergebnis/phpstan-rules",@@ -12054,16 +12076,16 @@},{"name": "phpunit/phpunit",- "version": "13.3.1",+ "version": "13.3.2","source": {"type": "git","url": "https://github.com/sebastianbergmann/phpunit.git",- "reference": "fc024931d6ad047404e9d86536735923fe63a06b"+ "reference": "22104a5ceb8d642e6b30ab00211d53d88e2db368"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fc024931d6ad047404e9d86536735923fe63a06b",- "reference": "fc024931d6ad047404e9d86536735923fe63a06b",+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/22104a5ceb8d642e6b30ab00211d53d88e2db368",+ "reference": "22104a5ceb8d642e6b30ab00211d53d88e2db368","shasum": ""},"require": {@@ -12077,8 +12099,8 @@"phar-io/manifest": "^2.0.4","phar-io/version": "^3.2.1","php": ">=8.4.1",- "phpunit/php-code-coverage": "^14.3",- "phpunit/php-file-iterator": "^7.0.1",+ "phpunit/php-code-coverage": "^14.3.1",+ "phpunit/php-file-iterator": "^7.0.2","phpunit/php-invoker": "^7.0.0","phpunit/php-text-template": "^6.0.0","phpunit/php-timer": "^9.0.0",@@ -12134,7 +12156,7 @@"support": {"issues": "https://github.com/sebastianbergmann/phpunit/issues","security": "https://github.com/sebastianbergmann/phpunit/security/policy",- "source": "https://github.com/sebastianbergmann/phpunit/tree/13.3.1"+ "source": "https://github.com/sebastianbergmann/phpunit/tree/13.3.2"},"funding": [{@@ -12142,20 +12164,20 @@"type": "other"}],- "time": "2026-08-13T13:14:23+00:00"+ "time": "2026-08-27T08:40:49+00:00"},{"name": "rector/rector",- "version": "2.6.3",+ "version": "2.6.4","source": {"type": "git","url": "https://github.com/rectorphp/rector.git",- "reference": "7e46709996a4b3dc59e1d6ecbb6a38ace335bd58"+ "reference": "6ff008471683591224951526247b7a2b86980ba9"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/rectorphp/rector/zipball/7e46709996a4b3dc59e1d6ecbb6a38ace335bd58",- "reference": "7e46709996a4b3dc59e1d6ecbb6a38ace335bd58",+ "url": "https://api.github.com/repos/rectorphp/rector/zipball/6ff008471683591224951526247b7a2b86980ba9",+ "reference": "6ff008471683591224951526247b7a2b86980ba9","shasum": ""},"require": {@@ -12194,7 +12216,7 @@],"support": {"issues": "https://github.com/rectorphp/rector/issues",- "source": "https://github.com/rectorphp/rector/tree/2.6.3"+ "source": "https://github.com/rectorphp/rector/tree/2.6.4"},"funding": [{@@ -12202,7 +12224,7 @@"type": "github"}],- "time": "2026-08-18T22:01:18+00:00"+ "time": "2026-08-27T09:20:34+00:00"},{"name": "revolt/event-loop",@@ -13434,6 +13456,65 @@],"time": "2024-10-20T05:08:20+00:00"},+ {+ "name": "symplify/rule-doc-generator-contracts",+ "version": "11.2.0",+ "source": {+ "type": "git",+ "url": "https://github.com/symplify/rule-doc-generator-contracts.git",+ "reference": "479cfcfd46047f80624aba931d9789e50475b5c6"+ },+ "dist": {+ "type": "zip",+ "url": "https://api.github.com/repos/symplify/rule-doc-generator-contracts/zipball/479cfcfd46047f80624aba931d9789e50475b5c6",+ "reference": "479cfcfd46047f80624aba931d9789e50475b5c6",+ "shasum": ""+ },+ "require": {+ "php": ">=8.1"+ },+ "require-dev": {+ "php-parallel-lint/php-parallel-lint": "^1.3",+ "phpstan/extension-installer": "^1.2",+ "rector/rector": "^0.15.10",+ "symplify/easy-ci": "^11.1",+ "symplify/easy-coding-standard": "^11.1",+ "symplify/easy-testing": "^11.1",+ "symplify/phpstan-extensions": "^11.1",+ "symplify/phpstan-rules": "11.2.3.72",+ "tomasvotruba/unused-public": "^0.0.34"+ },+ "type": "library",+ "extra": {+ "branch-alias": {+ "dev-main": "11.2-dev"+ }+ },+ "autoload": {+ "psr-4": {+ "Symplify\\RuleDocGenerator\\": "src"+ }+ },+ "notification-url": "https://packagist.org/downloads/",+ "license": [+ "MIT"+ ],+ "description": "Contracts for production code of RuleDocGenerator",+ "support": {+ "source": "https://github.com/symplify/rule-doc-generator-contracts/tree/11.2.0"+ },+ "funding": [+ {+ "url": "https://www.paypal.me/rectorphp",+ "type": "custom"+ },+ {+ "url": "https://github.com/tomasvotruba",+ "type": "github"+ }+ ],+ "time": "2024-03-18T22:02:54+00:00"+ },{"name": "thecodingmachine/phpstan-safe-rule","version": "v1.4.7",diff --git a/config/firefly.php b/config/firefly.phpindex cb53b96d8a..4987a0b6af 100644--- a/config/firefly.php+++ b/config/firefly.php@@ -79,7 +79,7 @@ return [// see cer.php for exchange rates feature flag.],'version' => 'develop/2026-08-27',-'build_time' => 1787813395,+'build_time' => 1787858610,'api_version' => '2.1.0', // field is no longer used.'db_version' => 28, // field is no longer used.diff --git a/package-lock.json b/package-lock.jsonindex 422555921f..b8a5aab451 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,5 +1,5 @@{- "name": "release",+ "name": "firefly-iii","lockfileVersion": 3,"requires": true,"packages": {