diff --git a/app/Api/V1/Controllers/Insight/Income/TagController.php b/app/Api/V1/Controllers/Insight/Income/TagController.php index 94be2ae461..df99eef909 100644 --- a/app/Api/V1/Controllers/Insight/Income/TagController.php +++ b/app/Api/V1/Controllers/Insight/Income/TagController.php @@ -158,10 +158,7 @@ final class TagController extends Controller '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'] = 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/TagController.php b/app/Api/V1/Controllers/Insight/Transfer/TagController.php index b7b85fd376..f92a7aa9f0 100644 --- a/app/Api/V1/Controllers/Insight/Transfer/TagController.php +++ b/app/Api/V1/Controllers/Insight/Transfer/TagController.php @@ -155,10 +155,7 @@ final class TagController extends Controller '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'] = 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/Requests/Data/Bulk/MoveTransactionsRequest.php b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php index ba0e9b1f44..fdc3e77b44 100644 --- a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php +++ b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php @@ -46,9 +46,6 @@ class MoveTransactionsRequest extends FormRequest return ['original_account' => $this->convertInteger('original_account'), 'destination_account' => $this->convertInteger('destination_account')]; } - /** - * @return array - */ public function rules(): array { return [ diff --git a/app/Api/V1/Requests/Models/Budget/StoreRequest.php b/app/Api/V1/Requests/Models/Budget/StoreRequest.php index dbae7bbf02..2a5174507c 100644 --- a/app/Api/V1/Requests/Models/Budget/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Budget/StoreRequest.php @@ -88,7 +88,12 @@ class StoreRequest extends FormRequest 'required_if:auto_budget_type,adjusted', new IsValidPositiveAmount(), ], - 'auto_budget_period' => ['in:daily,weekly,monthly,quarterly,half_year,yearly', 'required_if:auto_budget_type,reset', 'required_if:auto_budget_type,rollover', 'required_if:auto_budget_type,adjusted'], + 'auto_budget_period' => [ + 'in:daily,weekly,monthly,quarterly,half_year,yearly', + 'required_if:auto_budget_type,reset', + 'required_if:auto_budget_type,rollover', + 'required_if:auto_budget_type,adjusted', + ], // webhooks 'fire_webhooks' => [new IsBoolean()], diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php index a61582b81a..04f7fe40de 100644 --- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php +++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php @@ -54,12 +54,14 @@ class StoreByDateRequest extends FormRequest /** * The rules that the incoming request must be matched against. - * - * @return array */ public function rules(): array { - return ['from' => ['required', 'exists:transaction_currencies,code'], 'rates' => ['required', 'array'], 'rates.*' => ['required', 'numeric', 'min:0.0000000001']]; + return [ + 'from' => ['required', 'exists:transaction_currencies,code'], + 'rates' => ['required', 'array'], + 'rates.*' => ['required', 'numeric', 'min:0.0000000001'], + ]; } public function withValidator(Validator $validator): void diff --git a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php index 8bbe4f8383..db4edcb1e4 100644 --- a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php +++ b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php @@ -46,7 +46,10 @@ class TriggerRequest extends FormRequest public function rules(): array { - return ['start' => ['date', 'after:1970-01-02', 'before:2038-01-17'], 'end' => ['date', 'after_or_equal:start', 'after:1970-01-02', 'before:2038-01-17']]; + return [ + 'start' => ['date', 'after:1970-01-02', 'before:2038-01-17'], + 'end' => ['date', 'after_or_equal:start', 'after:1970-01-02', 'before:2038-01-17'], + ]; } private function getAccounts(): array diff --git a/app/Console/Commands/Correction/CorrectsAmounts.php b/app/Console/Commands/Correction/CorrectsAmounts.php index 0477b37473..66ccdfd1fa 100644 --- a/app/Console/Commands/Correction/CorrectsAmounts.php +++ b/app/Console/Commands/Correction/CorrectsAmounts.php @@ -188,7 +188,10 @@ class CorrectsAmounts extends Command private function fixAutoBudgets(): void { - $count = AutoBudget::query()->where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); + $count = AutoBudget::query() + ->where('amount', '<', 0) + ->update(['amount' => DB::raw('amount * -1')]) + ; if (0 === $count) { return; } @@ -197,7 +200,10 @@ class CorrectsAmounts extends Command private function fixAvailableBudgets(): void { - $count = AvailableBudget::query()->where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); + $count = AvailableBudget::query() + ->where('amount', '<', 0) + ->update(['amount' => DB::raw('amount * -1')]) + ; if (0 === $count) { return; } @@ -207,8 +213,14 @@ class CorrectsAmounts extends Command private function fixBills(): void { $count = 0; - $count += Bill::query()->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')]); + $count += Bill::query() + ->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')]) + ; if (0 === $count) { return; } @@ -217,7 +229,10 @@ class CorrectsAmounts extends Command private function fixBudgetLimits(): void { - $count = BudgetLimit::query()->where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); + $count = BudgetLimit::query() + ->where('amount', '<', 0) + ->update(['amount' => DB::raw('amount * -1')]) + ; if (0 === $count) { return; } @@ -226,7 +241,10 @@ class CorrectsAmounts extends Command private function fixExchangeRates(): void { - $count = CurrencyExchangeRate::query()->where('rate', '<', 0)->update(['rate' => DB::raw('rate * -1')]); + $count = CurrencyExchangeRate::query() + ->where('rate', '<', 0) + ->update(['rate' => DB::raw('rate * -1')]) + ; if (0 === $count) { return; } @@ -235,7 +253,10 @@ class CorrectsAmounts extends Command private function fixPiggyBanks(): void { - $count = PiggyBank::query()->where('target_amount', '<', 0)->update(['target_amount' => DB::raw('target_amount * -1')]); + $count = PiggyBank::query() + ->where('target_amount', '<', 0) + ->update(['target_amount' => DB::raw('target_amount * -1')]) + ; if (0 === $count) { return; } @@ -245,8 +266,14 @@ class CorrectsAmounts extends Command private function fixRecurrences(): void { $count = 0; - $count += RecurrenceTransaction::query()->where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); - $count += RecurrenceTransaction::query()->where('foreign_amount', '<', 0)->update(['foreign_amount' => DB::raw('foreign_amount * -1')]); + $count += RecurrenceTransaction::query() + ->where('amount', '<', 0) + ->update(['amount' => DB::raw('amount * -1')]) + ; + $count += RecurrenceTransaction::query() + ->where('foreign_amount', '<', 0) + ->update(['foreign_amount' => DB::raw('foreign_amount * -1')]) + ; if (0 === $count) { return; } diff --git a/app/Console/Commands/Correction/CorrectsGroupAccounts.php b/app/Console/Commands/Correction/CorrectsGroupAccounts.php index d987953b42..51968680e6 100644 --- a/app/Console/Commands/Correction/CorrectsGroupAccounts.php +++ b/app/Console/Commands/Correction/CorrectsGroupAccounts.php @@ -49,7 +49,10 @@ class CorrectsGroupAccounts extends Command { 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')]); + $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) { diff --git a/app/Console/Commands/Correction/CorrectsTransferBudgets.php b/app/Console/Commands/Correction/CorrectsTransferBudgets.php index d7d777fd2a..7eabfa372b 100644 --- a/app/Console/Commands/Correction/CorrectsTransferBudgets.php +++ b/app/Console/Commands/Correction/CorrectsTransferBudgets.php @@ -42,7 +42,8 @@ class CorrectsTransferBudgets extends Command */ public function handle(): int { - $set = TransactionJournal::query()->distinct() + $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]) diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.php index 5a640db53f..a85f634441 100644 --- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php +++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php @@ -76,7 +76,8 @@ class CorrectsUnevenAmount extends Command $repository = app(AccountRepositoryInterface::class); Log::debug('convertOldStyleTransactions()'); $count = 0; - $transactions = Transaction::query()->distinct() + $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') @@ -188,7 +189,8 @@ class CorrectsUnevenAmount extends Command { Log::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() + $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) @@ -262,8 +264,14 @@ class CorrectsUnevenAmount extends Command $journal->id ?? 0, $journal->description ?? '' )); - Transaction::query()->where('transaction_journal_id', $journal->id ?? 0)->forceDelete(); - TransactionJournal::query()->where('id', $journal->id ?? 0)->forceDelete(); + Transaction::query() + ->where('transaction_journal_id', $journal->id ?? 0) + ->forceDelete() + ; + TransactionJournal::query() + ->where('id', $journal->id ?? 0) + ->forceDelete() + ; ++$this->count; return; @@ -282,8 +290,14 @@ class CorrectsUnevenAmount extends Command $journal->description ?? '' )); - Transaction::query()->where('transaction_journal_id', $journal->id ?? 0)->forceDelete(); - TransactionJournal::query()->where('id', $journal->id ?? 0)->forceDelete(); + Transaction::query() + ->where('transaction_journal_id', $journal->id ?? 0) + ->forceDelete() + ; + TransactionJournal::query() + ->where('id', $journal->id ?? 0) + ->forceDelete() + ; ++$this->count; return; diff --git a/app/Console/Commands/Correction/CreatesGroupMemberships.php b/app/Console/Commands/Correction/CreatesGroupMemberships.php index b6156b5b78..9b5d9976a5 100644 --- a/app/Console/Commands/Correction/CreatesGroupMemberships.php +++ b/app/Console/Commands/Correction/CreatesGroupMemberships.php @@ -60,7 +60,12 @@ class CreatesGroupMemberships extends Command 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(); + $membership = GroupMembership::query() + ->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/RemovesEmptyJournals.php b/app/Console/Commands/Correction/RemovesEmptyJournals.php index df686e29d0..df4ea15ca8 100644 --- a/app/Console/Commands/Correction/RemovesEmptyJournals.php +++ b/app/Console/Commands/Correction/RemovesEmptyJournals.php @@ -80,10 +80,14 @@ class RemovesEmptyJournals extends Command */ private 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', - ]); + $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', + ]) + ; $total = 0; /** @var Transaction $row */ diff --git a/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php b/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php index 80941cbbd2..a9d197389f 100644 --- a/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php +++ b/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php @@ -57,10 +57,34 @@ class RemovesLinksToDeletedObjects extends Command */ public function handle(): void { - $deletedTags = Tag::query()->withTrashed()->whereNotNull('deleted_at')->get('tags.id')->pluck('id')->toArray(); - $deletedJournals = TransactionJournal::query()->withTrashed()->whereNotNull('deleted_at')->get('transaction_journals.id')->pluck('id')->toArray(); - $deletedBudgets = Budget::query()->withTrashed()->whereNotNull('deleted_at')->get('budgets.id')->pluck('id')->toArray(); - $deletedCategories = Category::query()->withTrashed()->whereNotNull('deleted_at')->get('categories.id')->pluck('id')->toArray(); + $deletedTags = Tag::query() + ->withTrashed() + ->whereNotNull('deleted_at') + ->get('tags.id') + ->pluck('id') + ->toArray() + ; + $deletedJournals = TransactionJournal::query() + ->withTrashed() + ->whereNotNull('deleted_at') + ->get('transaction_journals.id') + ->pluck('id') + ->toArray() + ; + $deletedBudgets = Budget::query() + ->withTrashed() + ->whereNotNull('deleted_at') + ->get('budgets.id') + ->pluck('id') + ->toArray() + ; + $deletedCategories = Category::query() + ->withTrashed() + ->whereNotNull('deleted_at') + ->get('categories.id') + ->pluck('id') + ->toArray() + ; if (count($deletedTags) > 0) { $this->cleanupTags($deletedTags); diff --git a/app/Console/Commands/System/ForcesDecimalSize.php b/app/Console/Commands/System/ForcesDecimalSize.php index 51c23275e0..6e60d35f41 100644 --- a/app/Console/Commands/System/ForcesDecimalSize.php +++ b/app/Console/Commands/System/ForcesDecimalSize.php @@ -490,11 +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()) { @@ -519,11 +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()) { diff --git a/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php b/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php index 7e6b6dc91c..5327de98d5 100644 --- a/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php +++ b/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php @@ -93,7 +93,8 @@ class AddsTransactionIdentifiers extends Command try { /** @var Transaction $opposing */ - $opposing = Transaction::query()->where('transaction_journal_id', $transaction->transaction_journal_id) + $opposing = Transaction::query() + ->where('transaction_journal_id', $transaction->transaction_journal_id) ->where('amount', $amount) ->where('identifier', '=', 0) ->whereNotIn('id', $exclude) diff --git a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php index a05bd454c2..cf1455e389 100644 --- a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php +++ b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php @@ -66,7 +66,8 @@ class UpgradesCurrencyPreferences extends Command private function getPreference(User $user): string { - $preference = Preference::query()->where('user_id', $user->id) + $preference = Preference::query() + ->where('user_id', $user->id) ->where('name', 'currencyPreference') ->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']) ; diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index e21089de5d..af9733b305 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -425,7 +425,8 @@ class TransactionJournalFactory Log::debug('Will verify duplicate!'); /** @var null|TransactionJournalMeta $result */ - $result = TransactionJournalMeta::query()->withTrashed() + $result = TransactionJournalMeta::query() + ->withTrashed() ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') ->whereNotNull('transaction_journals.id') ->where('transaction_journals.user_id', $this->user->id) diff --git a/app/Handlers/Observer/DeletedAccountObserver.php b/app/Handlers/Observer/DeletedAccountObserver.php index bf7b9cab96..ab7c31fee2 100644 --- a/app/Handlers/Observer/DeletedAccountObserver.php +++ b/app/Handlers/Observer/DeletedAccountObserver.php @@ -49,7 +49,12 @@ class DeletedAccountObserver $repository->destroy($attachment); } - $journalIds = Transaction::query()->where('account_id', $account->id)->get(['transactions.transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); + $journalIds = Transaction::query() + ->where('account_id', $account->id) + ->get(['transactions.transaction_journal_id']) + ->pluck('transaction_journal_id') + ->toArray() + ; $groupIds = array_map(function (array $item) { return $item['transaction_group_id']; diff --git a/app/Http/Controllers/Bill/IndexController.php b/app/Http/Controllers/Bill/IndexController.php index 07947c2c85..2009369ae0 100644 --- a/app/Http/Controllers/Bill/IndexController.php +++ b/app/Http/Controllers/Bill/IndexController.php @@ -255,10 +255,7 @@ final class IndexController extends Controller if (count($bill['paid_dates']) < count($bill['pay_dates'])) { $count = count($bill['pay_dates']) - count($bill['paid_dates']); if ($count > 0) { - $avg = bcdiv( - bcadd((string) $bill['amount_min'], (string) $bill['amount_max']), - '2' - ); + $avg = bcdiv(bcadd((string) $bill['amount_min'], (string) $bill['amount_max']), '2'); $avg = bcmul($avg, (string) $count); $sums[$groupOrder][$currencyId]['total_left_to_pay'] = bcadd($sums[$groupOrder][$currencyId]['total_left_to_pay'], $avg); Log::debug( diff --git a/app/Http/Controllers/Budget/BudgetLimitController.php b/app/Http/Controllers/Budget/BudgetLimitController.php index b263d702a2..9632996690 100644 --- a/app/Http/Controllers/Budget/BudgetLimitController.php +++ b/app/Http/Controllers/Budget/BudgetLimitController.php @@ -198,13 +198,7 @@ final class BudgetLimitController extends Controller if ($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.php index 750a88e633..674f77fbee 100644 --- a/app/Http/Controllers/Budget/IndexController.php +++ b/app/Http/Controllers/Budget/IndexController.php @@ -284,10 +284,7 @@ final class IndexController extends Controller if (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.php index f4b32fe5c5..ad724137dc 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -539,13 +539,7 @@ 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/Requests/BudgetIncomeRequest.php b/app/Http/Requests/BudgetIncomeRequest.php index 79ace5ccf6..78ae35e45f 100644 --- a/app/Http/Requests/BudgetIncomeRequest.php +++ b/app/Http/Requests/BudgetIncomeRequest.php @@ -44,7 +44,11 @@ class BudgetIncomeRequest extends FormRequest public function rules(): array { // fixed - return ['amount' => ['required', new IsValidPositiveAmount()], 'start' => ['required', 'date', 'before:end'], 'end' => ['required', 'date', 'after:start']]; + return [ + 'amount' => ['required', new IsValidPositiveAmount()], + 'start' => ['required', 'date', 'before:end'], + 'end' => ['required', 'date', 'after:start'], + ]; } public function withValidator(Validator $validator): void diff --git a/app/Jobs/CreateAutoBudgetLimits.php b/app/Jobs/CreateAutoBudgetLimits.php index d61661dd50..93cf5e9364 100644 --- a/app/Jobs/CreateAutoBudgetLimits.php +++ b/app/Jobs/CreateAutoBudgetLimits.php @@ -122,13 +122,7 @@ 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)); @@ -218,13 +212,7 @@ 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/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php b/app/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php index 4d6fc8a250..2c4ad5d7a2 100644 --- a/app/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php +++ b/app/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php @@ -128,7 +128,8 @@ class ProcessesUpdatedTransactionGroup $effect = 0; if (TransactionTypeEnum::TRANSFER->value === $type || TransactionTypeEnum::WITHDRAWAL->value === $type) { // set all source transactions to source account: - $effect += Transaction::query()->whereIn('transaction_journal_id', $all) + $effect += Transaction::query() + ->whereIn('transaction_journal_id', $all) ->where('account_id', '!=', $sourceAccount->id) ->where('amount', '<', 0) ->update(['account_id' => $sourceAccount->id]) @@ -136,7 +137,8 @@ class ProcessesUpdatedTransactionGroup } if (TransactionTypeEnum::TRANSFER->value === $type || TransactionTypeEnum::DEPOSIT->value === $type) { // set all destination transactions to destination account: - $effect += Transaction::query()->whereIn('transaction_journal_id', $all) + $effect += Transaction::query() + ->whereIn('transaction_journal_id', $all) ->where('account_id', '!=', $destAccount->id) ->where('amount', '>', 0) ->update(['account_id' => $destAccount->id]) diff --git a/app/Listeners/Model/Webhook/SendsWebhookMessages.php b/app/Listeners/Model/Webhook/SendsWebhookMessages.php index e7047a1684..8aab29be9d 100644 --- a/app/Listeners/Model/Webhook/SendsWebhookMessages.php +++ b/app/Listeners/Model/Webhook/SendsWebhookMessages.php @@ -43,7 +43,8 @@ class SendsWebhookMessages implements ShouldQueue } // kick off the job! - $messages = WebhookMessage::query()->where('webhook_messages.sent', false) + $messages = WebhookMessage::query() + ->where('webhook_messages.sent', false) ->get(['webhook_messages.*']) ->filter(static fn (WebhookMessage $message): bool => $message->webhookAttempts()->count() <= 2) ->splice(0, 5) diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php index 3fb1c07741..357f4eb6dc 100644 --- a/app/Models/AccountType.php +++ b/app/Models/AccountType.php @@ -31,8 +31,9 @@ class AccountType extends Model { use ReturnsIntegerIdTrait; - protected function casts(): array { - return ['created_at' => 'datetime', 'updated_at' => 'datetime']; + protected function casts(): array + { + return ['created_at' => 'datetime', 'updated_at' => 'datetime']; } protected $fillable = ['type']; @@ -41,5 +42,4 @@ class AccountType extends Model { return $this->hasMany(Account::class); } - } diff --git a/app/Models/AutoBudget.php b/app/Models/AutoBudget.php index 7a06e8781c..d811f28f6f 100644 --- a/app/Models/AutoBudget.php +++ b/app/Models/AutoBudget.php @@ -60,16 +60,16 @@ class AutoBudget extends Model protected function amount(): Attribute { - return Attribute::make(get: static fn($value): string => (string)$value); + return Attribute::make(get: static fn ($value): string => (string) $value); } protected function budgetId(): Attribute { - return Attribute::make(get: static fn($value): int => (int)$value); + return Attribute::make(get: static fn ($value): int => (int) $value); } protected function transactionCurrencyId(): Attribute { - return Attribute::make(get: static fn($value): int => (int)$value); + return Attribute::make(get: static fn ($value): int => (int) $value); } } diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php index a2ac9e86b9..a1f8407aa6 100644 --- a/app/Models/TransactionType.php +++ b/app/Models/TransactionType.php @@ -47,13 +47,13 @@ class TransactionType extends Model * * @throws NotFoundHttpException */ - public static function routeBinder(self | string $value): self + public static function routeBinder(self|string $value): self { if (!auth()->check()) { throw new NotFoundHttpException(); } if ($value instanceof self) { - $value = (string)$value->type; + $value = (string) $value->type; } $transactionType = self::where('type', ucfirst($value))->first(); if (null !== $transactionType) { @@ -87,5 +87,4 @@ class TransactionType extends Model { return $this->hasMany(TransactionJournal::class); } - } diff --git a/app/Models/Webhook.php b/app/Models/Webhook.php index 01b53e7cb4..e40d1e6d46 100644 --- a/app/Models/Webhook.php +++ b/app/Models/Webhook.php @@ -134,19 +134,19 @@ class Webhook extends Model * * @throws NotFoundHttpException */ - public static function routeBinder(self | string $value): self + public static function routeBinder(self|string $value): self { if (auth()->check()) { if ($value instanceof self) { - $value = (int)$value->id; + $value = (int) $value->id; } - $webhookId = (int)$value; + $webhookId = (int) $value; /** @var User $user */ - $user = auth()->user(); + $user = auth()->user(); /** @var null|Webhook $webhook */ - $webhook = $user->webhooks()->find($webhookId); + $webhook = $user->webhooks()->find($webhookId); if (null !== $webhook) { return $webhook; } @@ -179,5 +179,4 @@ class Webhook extends Model { return $this->belongsToMany(WebhookTrigger::class); } - } diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index 13bd7347fe..8791c31a6c 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -252,11 +252,13 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface foreach ($budgets as $budget) { DB::table('budget_transaction')->where('budget_id', $budget->id)->delete(); DB::table('budget_transaction_journal')->where('budget_id', $budget->id)->delete(); - RecurrenceTransactionMeta::query()->where('name', 'budget_id') + RecurrenceTransactionMeta::query() + ->where('name', 'budget_id') ->where('value', (string) $budget->id) ->delete() ; - RuleAction::query()->where('action_type', 'set_budget') + RuleAction::query() + ->where('action_type', 'set_budget') ->where('action_value', (string) $budget->id) ->delete() ; diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php index 0f23730a26..e410a5398b 100644 --- a/app/Repositories/Currency/CurrencyRepository.php +++ b/app/Repositories/Currency/CurrencyRepository.php @@ -86,7 +86,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf } // is being used in accounts: - $meta = AccountMeta::query()->where('name', 'currency_id') + $meta = AccountMeta::query() + ->where('name', 'currency_id') ->where('data', json_encode((string) $currency->id)) ->count() ; @@ -97,7 +98,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf } // second search using integer check. - $meta = AccountMeta::query()->where('name', 'currency_id') + $meta = AccountMeta::query() + ->where('name', 'currency_id') ->where('data', json_encode((int) $currency->id)) ->count() ; diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 3ff98d3898..b0454933bf 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -79,7 +79,8 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac #[Override] public function countByNotes(string $value, bool $includeDeleted): int { - $search = Note::query()->where('noteable_type', TransactionJournal::class) + $search = Note::query() + ->where('noteable_type', TransactionJournal::class) ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'notes.noteable_id') ->where('transaction_journals.user_id', $this->user->id) ->where('text', 'LIKE', sprintf('%%%s%%', $value)) diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php index 662fb9bb12..553d49e2eb 100644 --- a/app/Repositories/LinkType/LinkTypeRepository.php +++ b/app/Repositories/LinkType/LinkTypeRepository.php @@ -96,7 +96,12 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf */ public function findSpecificLink(LinkType $linkType, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink { - return TransactionJournalLink::query()->where('link_type_id', $linkType->id)->where('source_id', $inward->id)->where('destination_id', $outward->id)->first(); + return TransactionJournalLink::query() + ->where('link_type_id', $linkType->id) + ->where('source_id', $inward->id) + ->where('destination_id', $outward->id) + ->first() + ; } public function get(): Collection @@ -128,7 +133,8 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf */ public function getJournalLinks(?LinkType $linkType = null): Collection { - $query = TransactionJournalLink::query()->with(['source', 'destination']) + $query = TransactionJournalLink::query() + ->with(['source', 'destination']) ->leftJoin('transaction_journals as source_journals', 'journal_links.source_id', '=', 'source_journals.id') ->leftJoin('transaction_journals as dest_journals', 'journal_links.destination_id', '=', 'dest_journals.id') ->where('source_journals.user_id', $this->user->id) diff --git a/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php b/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php index 90bad72ede..09cc530f19 100644 --- a/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php +++ b/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php @@ -125,7 +125,8 @@ class PeriodStatisticRepository implements PeriodStatisticRepositoryInterface, U return; } - $count = PeriodStatistic::query()->where('primary_statable_type', $class) + $count = PeriodStatistic::query() + ->where('primary_statable_type', $class) ->whereIn('primary_statable_id', $objects->pluck('id')->toArray()) ->where(function (Builder $q) use ($dates): void { foreach ($dates as $date) { diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 7246f8de51..35726057b2 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -372,7 +372,8 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte #[Override] public function purgeAll(): void { - PiggyBank::query()->withTrashed() + PiggyBank::query() + ->withTrashed() ->whereNotNull('piggy_banks.deleted_at') ->leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id') ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id') diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.php index 69b264b76a..753f727b65 100644 --- a/app/Repositories/Recurring/RecurringRepository.php +++ b/app/Repositories/Recurring/RecurringRepository.php @@ -78,12 +78,16 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte // there are X journals made for this recurrence. Any of them meant for today? foreach ($set as $journalMeta) { - $count = TransactionJournalMeta::query()->where(static function (Builder $q2) use ($date): void { - $string = (string) $date; - Log::debug(sprintf('Search for date: %s', json_encode($string))); - $q2->where('name', 'recurrence_date'); - $q2->where('data', json_encode($string)); - })->where('transaction_journal_id', $journalMeta->transaction_journal_id)->count(); + $count = TransactionJournalMeta::query() + ->where(static function (Builder $q2) use ($date): void { + $string = (string) $date; + Log::debug(sprintf('Search for date: %s', json_encode($string))); + $q2->where('name', 'recurrence_date'); + $q2->where('data', json_encode($string)); + }) + ->where('transaction_journal_id', $journalMeta->transaction_journal_id) + ->count() + ; if ($count > 0) { Log::debug(sprintf('Looks like journal #%d was already created', $journalMeta->transaction_journal_id)); @@ -131,7 +135,8 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte public function getAll(): Collection { // grab ALL recurring transactions: - return Recurrence::query()->with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions']) + return Recurrence::query() + ->with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions']) ->orderBy('active', 'DESC') ->orderBy('title', 'ASC') ->get() diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.php index 35fab0e5ff..369bb3cbce 100644 --- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php +++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php @@ -111,7 +111,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface, $repository = app(AttachmentRepositoryInterface::class); $repository->setUser($this->user); $journals = $group->transactionJournals->pluck('id')->toArray(); - $set = Attachment::query()->whereIn('attachable_id', $journals) + $set = Attachment::query() + ->whereIn('attachable_id', $journals) ->where('attachable_type', TransactionJournal::class) ->where('uploaded', true) ->whereNull('deleted_at') @@ -163,15 +164,20 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface, { $return = []; $journals = $group->transactionJournals->pluck('id')->toArray(); - $set = TransactionJournalLink::query()->where(static function (Builder $q) use ($journals): void { - $q->whereIn('source_id', $journals); - $q->orWhereIn('destination_id', $journals); - })->with(['source', 'notes', 'destination', 'source.transactions'])->leftJoin('link_types', 'link_types.id', '=', 'journal_links.link_type_id')->get([ - 'journal_links.*', - 'link_types.inward', - 'link_types.outward', - 'link_types.editable', - ]); + $set = TransactionJournalLink::query() + ->where(static function (Builder $q) use ($journals): void { + $q->whereIn('source_id', $journals); + $q->orWhereIn('destination_id', $journals); + }) + ->with(['source', 'notes', 'destination', 'source.transactions']) + ->leftJoin('link_types', 'link_types.id', '=', 'journal_links.link_type_id') + ->get([ + 'journal_links.*', + 'link_types.inward', + 'link_types.outward', + 'link_types.editable', + ]) + ; /** @var TransactionJournalLink $entry */ foreach ($set as $entry) { diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php index 034dde02da..8943ff6862 100644 --- a/app/Repositories/User/UserRepository.php +++ b/app/Repositories/User/UserRepository.php @@ -237,7 +237,8 @@ class UserRepository implements UserRepositoryInterface 'bills' => $user->bills()->count(), 'categories' => $user->categories()->count(), 'budgets' => $user->budgets()->count(), - 'budgets_with_limits' => BudgetLimit::query()->distinct() + 'budgets_with_limits' => BudgetLimit::query() + ->distinct() ->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') ->where('amount', '>', 0) ->whereNull('budgets.deleted_at') diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.php index 74b8779aa7..8fc76b4191 100644 --- a/app/Services/Internal/Destroy/AccountDestroyService.php +++ b/app/Services/Internal/Destroy/AccountDestroyService.php @@ -69,11 +69,15 @@ class AccountDestroyService Log::debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id)); DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]); - $collection = Transaction::query()->groupBy('transaction_journal_id', 'account_id')->where('account_id', $moveTo->id)->get([ - 'transaction_journal_id', - 'account_id', - DB::raw('count(*) as the_count'), - ]); + $collection = Transaction::query() + ->groupBy('transaction_journal_id', 'account_id') + ->where('account_id', $moveTo->id) + ->get([ + 'transaction_journal_id', + 'account_id', + DB::raw('count(*) as the_count'), + ]) + ; if (0 === $collection->count()) { return; } @@ -137,10 +141,15 @@ class AccountDestroyService private function destroyRecurrences(Account $account): void { - $recurrences = RecurrenceTransaction::query()->where(static function (Builder $q) use ($account): void { - $q->where('source_id', $account->id); - $q->orWhere('destination_id', $account->id); - })->get(['recurrence_id'])->pluck('recurrence_id')->toArray(); + $recurrences = RecurrenceTransaction::query() + ->where(static function (Builder $q) use ($account): void { + $q->where('source_id', $account->id); + $q->orWhere('destination_id', $account->id); + }) + ->get(['recurrence_id']) + ->pluck('recurrence_id') + ->toArray() + ; /** @var RecurrenceDestroyService $destroyService */ $destroyService = app(RecurrenceDestroyService::class); diff --git a/app/Support/Balance.php b/app/Support/Balance.php index 9ae518e6a5..f5ec9cbe8b 100644 --- a/app/Support/Balance.php +++ b/app/Support/Balance.php @@ -50,7 +50,8 @@ class Balance return $cache->get(); } - $query = Transaction::query()->whereIn('transactions.account_id', $accounts->pluck('id')->toArray()) + $query = Transaction::query() + ->whereIn('transactions.account_id', $accounts->pluck('id')->toArray()) ->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->orderBy('transaction_journals.date', 'desc') ->orderBy('transaction_journals.order', 'asc') diff --git a/app/Support/Binder/UserGroupAccount.php b/app/Support/Binder/UserGroupAccount.php index f649a9eeb5..4ff86e6dc3 100644 --- a/app/Support/Binder/UserGroupAccount.php +++ b/app/Support/Binder/UserGroupAccount.php @@ -41,7 +41,8 @@ class UserGroupAccount implements BinderInterface if (auth()->check()) { /** @var User $user */ $user = auth()->user(); - $account = Account::query()->where('id', (int) $value) + $account = Account::query() + ->where('id', (int) $value) ->where('user_group_id', $user->user_group_id) ->first() ; diff --git a/app/Support/Binder/UserGroupBill.php b/app/Support/Binder/UserGroupBill.php index e9bbcb26fa..c4b07d404e 100644 --- a/app/Support/Binder/UserGroupBill.php +++ b/app/Support/Binder/UserGroupBill.php @@ -41,7 +41,8 @@ class UserGroupBill implements BinderInterface if (auth()->check()) { /** @var User $user */ $user = auth()->user(); - $currency = Bill::query()->where('id', (int) $value) + $currency = Bill::query() + ->where('id', (int) $value) ->where('user_group_id', $user->user_group_id) ->first() ; diff --git a/app/Support/Binder/UserGroupExchangeRate.php b/app/Support/Binder/UserGroupExchangeRate.php index 0b2eee832d..44ec929e6c 100644 --- a/app/Support/Binder/UserGroupExchangeRate.php +++ b/app/Support/Binder/UserGroupExchangeRate.php @@ -38,7 +38,8 @@ class UserGroupExchangeRate implements BinderInterface if (auth()->check()) { /** @var User $user */ $user = auth()->user(); - $rate = CurrencyExchangeRate::query()->where('id', (int) $value) + $rate = CurrencyExchangeRate::query() + ->where('id', (int) $value) ->where('user_group_id', $user->user_group_id) ->first() ; diff --git a/app/Support/Binder/UserGroupTransaction.php b/app/Support/Binder/UserGroupTransaction.php index 1a7a1c199f..cc7c806925 100644 --- a/app/Support/Binder/UserGroupTransaction.php +++ b/app/Support/Binder/UserGroupTransaction.php @@ -38,7 +38,8 @@ class UserGroupTransaction implements BinderInterface if (auth()->check()) { /** @var User $user */ $user = auth()->user(); - $group = TransactionGroup::query()->where('id', (int) $value) + $group = TransactionGroup::query() + ->where('id', (int) $value) ->where('user_group_id', $user->user_group_id) ->first() ; diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.php index a507156873..a3a940b1ba 100644 --- a/app/Support/Http/Controllers/AugumentData.php +++ b/app/Support/Http/Controllers/AugumentData.php @@ -222,14 +222,7 @@ 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/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.php index d2cf445ef6..56892c30ac 100644 --- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php +++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php @@ -332,18 +332,19 @@ class AccountEnrichment implements EnrichmentInterface private function collectMetaData(): void { - $set = AccountMeta::query()->whereIn('name', [ - 'is_multi_currency', - 'include_net_worth', - 'currency_id', - 'account_role', - 'account_number', - 'BIC', - 'liability_direction', - 'interest', - 'interest_period', - 'current_debt', - ]) + $set = AccountMeta::query() + ->whereIn('name', [ + 'is_multi_currency', + 'include_net_worth', + 'currency_id', + 'account_role', + 'account_number', + 'BIC', + 'liability_direction', + 'interest', + 'interest_period', + 'current_debt', + ]) ->whereIn('account_id', $this->ids) ->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data']) ->toArray() diff --git a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php index 77efb09286..0342fb5d13 100644 --- a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php @@ -148,10 +148,11 @@ class BudgetLimitEnrichment implements EnrichmentInterface private function collectCurrencies(): void { $this->currencies[$this->primaryCurrency->id] = $this->primaryCurrency; - $currencies = TransactionCurrency::query()->whereIn('id', $this->currencyIds)->whereNot( - 'id', - $this->primaryCurrency->id - )->get(); + $currencies = TransactionCurrency::query() + ->whereIn('id', $this->currencyIds) + ->whereNot('id', $this->primaryCurrency->id) + ->get() + ; foreach ($currencies as $currency) { $this->currencies[(int) $currency->id] = $currency; } diff --git a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php index 672bdb2f90..d0c09bf027 100644 --- a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php +++ b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php @@ -354,10 +354,7 @@ 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/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php index 9b9c1aa106..c1717f4a00 100644 --- a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php +++ b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php @@ -212,7 +212,11 @@ class TransactionGroupEnrichment implements EnrichmentInterface private function collectMetaData(): void { - $set = TransactionJournalMeta::query()->whereIn('transaction_journal_id', $this->journalIds)->get(['transaction_journal_id', 'name', 'data'])->toArray(); + $set = TransactionJournalMeta::query() + ->whereIn('transaction_journal_id', $this->journalIds) + ->get(['transaction_journal_id', 'name', 'data']) + ->toArray() + ; foreach ($set as $entry) { $name = $entry['name']; $data = (string) $entry['data']; diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php index 2819fc5255..f0f3cfa7c6 100644 --- a/app/Support/Preferences.php +++ b/app/Support/Preferences.php @@ -47,7 +47,8 @@ class Preferences return new Collection(); } - return Preference::query()->where('user_id', $user->id) + return Preference::query() + ->where('user_id', $user->id) ->where('name', '!=', 'currencyPreference') ->where(static function (Builder $q) use ($user): void { $q->whereNull('user_group_id'); @@ -118,7 +119,8 @@ class Preferences public function getArrayForUser(User $user, array $list): array { $result = []; - $preferences = Preference::query()->where('user_id', $user->id) + $preferences = Preference::query() + ->where('user_id', $user->id) ->where(static function (Builder $q) use ($user): void { $q->whereNull('user_group_id'); $q->orWhere('user_group_id', $user->user_group_id); diff --git a/app/Support/Steam.php b/app/Support/Steam.php index 97c55dd3f8..661ab57a48 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -83,7 +83,8 @@ class Steam $currencies = $this->getCurrencies($accounts); // balance(s) in all currencies for ALL accounts. - $arrayOfSums = Transaction::query()->whereIn('account_id', $accounts->pluck('id')->toArray()) + $arrayOfSums = Transaction::query() + ->whereIn('account_id', $accounts->pluck('id')->toArray()) ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id') ->where('transaction_journals.date', $inclusive ? '<=' : '<', $date->format('Y-m-d H:i:s')) diff --git a/app/TransactionRules/Actions/AppendNotes.php b/app/TransactionRules/Actions/AppendNotes.php index cd4373dec4..55957889a8 100644 --- a/app/TransactionRules/Actions/AppendNotes.php +++ b/app/TransactionRules/Actions/AppendNotes.php @@ -48,7 +48,8 @@ class AppendNotes implements ActionInterface public function actOnArray(array $journal): bool { $this->refreshNotes($journal); - $dbNote = Note::query()->where('noteable_id', (int) $journal['transaction_journal_id']) + $dbNote = Note::query() + ->where('noteable_id', (int) $journal['transaction_journal_id']) ->where('noteable_type', TransactionJournal::class) ->first(['notes.*']) ; diff --git a/app/TransactionRules/Actions/PrependNotes.php b/app/TransactionRules/Actions/PrependNotes.php index 43bb600c74..139ccd8a72 100644 --- a/app/TransactionRules/Actions/PrependNotes.php +++ b/app/TransactionRules/Actions/PrependNotes.php @@ -44,7 +44,8 @@ class PrependNotes implements ActionInterface public function actOnArray(array $journal): bool { - $dbNote = Note::query()->where('noteable_id', (int) $journal['transaction_journal_id']) + $dbNote = Note::query() + ->where('noteable_id', (int) $journal['transaction_journal_id']) ->where('noteable_type', TransactionJournal::class) ->first(['notes.*']) ; diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php index 574ebf60a5..85d6c60770 100644 --- a/app/TransactionRules/Engine/SearchRuleEngine.php +++ b/app/TransactionRules/Engine/SearchRuleEngine.php @@ -189,7 +189,8 @@ class SearchRuleEngine implements RuleEngineInterface private function addNotes(array $transaction): array { $transaction['notes'] = ''; - $dbNote = Note::query()->where('noteable_id', (int) $transaction['transaction_journal_id']) + $dbNote = Note::query() + ->where('noteable_id', (int) $transaction['transaction_journal_id']) ->where('noteable_type', TransactionJournal::class) ->first(['notes.*']) ; diff --git a/app/TransactionRules/Traits/RefreshNotesTrait.php b/app/TransactionRules/Traits/RefreshNotesTrait.php index 5168a24552..eae46db2fc 100644 --- a/app/TransactionRules/Traits/RefreshNotesTrait.php +++ b/app/TransactionRules/Traits/RefreshNotesTrait.php @@ -33,7 +33,8 @@ trait RefreshNotesTrait final protected function refreshNotes(array $transaction): array { $transaction['notes'] = ''; - $dbNote = Note::query()->where('noteable_id', (int) $transaction['transaction_journal_id']) + $dbNote = Note::query() + ->where('noteable_id', (int) $transaction['transaction_journal_id']) ->where('noteable_type', TransactionJournal::class) ->first(['notes.*']) ; diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 2b2b84fea7..0c22c0f5d6 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -472,7 +472,10 @@ class FireflyValidator extends Validator // check transaction type. // TODO create a helper to automatically return these. if ('transaction_type' === $triggerType) { - $count = TransactionType::query()->where('type', ucfirst((string) $value))->count(); + $count = TransactionType::query() + ->where('type', ucfirst((string) $value)) + ->count() + ; return 1 === $count; } diff --git a/config/firefly.php b/config/firefly.php index ded0d74421..296f940a60 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-05-21', -'build_time' => 1779337713, +'build_time' => 1779338975, '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.json index d26d314202..cdd4c5d44d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8286,11 +8286,14 @@ } }, "node_modules/node-releases": { - "version": "2.0.44", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.44.tgz", - "integrity": "sha512-5WUyunoPMsvvEhS8AxHtRzP+oA8UCkJ7YRxatWKjngndhDGLiqEVAQKWjFAiAiuL8zMRGzGSJxFnLetoa43qGQ==", + "version": "2.0.45", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.45.tgz", + "integrity": "sha512-iIbHXV9eBB2nB0wa7oTsrrXq+qQt+9SIlx9AX3T96YgobtEQfis5n6TJ6vV+3QP8DwdriEAcGhARaFCu37peBg==", "dev": true, - "license": "MIT" + "license": "MIT", + "engines": { + "node": ">=18" + } }, "node_modules/normalize-path": { "version": "3.0.0",