Lots of mago fixes applied.

This commit is contained in:
James Cole
2026-05-21 06:31:24 +02:00
parent 9ee1b4587c
commit b81943fad6
231 changed files with 718 additions and 718 deletions
@@ -93,7 +93,7 @@ class AddsTransactionIdentifiers extends Command
try {
/** @var Transaction $opposing */
$opposing = Transaction::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)
@@ -106,7 +106,7 @@ class UpgradesAccountCurrencies extends Command
// both 0? set to default currency:
if (0 === $accountCurrency && 0 === $obCurrency) {
AccountMeta::where('account_id', $account->id)->where('name', 'currency_id')->forceDelete();
AccountMeta::query()->where('account_id', $account->id)->where('name', 'currency_id')->forceDelete();
AccountMeta::create(['account_id' => $account->id, 'name' => 'currency_id', 'data' => $currency->id]);
$this->friendlyInfo(sprintf('Account #%d ("%s") now has a currency setting (%s).', $account->id, $account->name, $currency->code));
++$this->count;
@@ -66,10 +66,10 @@ class UpgradesAccountMetaData extends Command
* @var string $new
*/
foreach ($array as $old => $new) {
$count += AccountMeta::where('name', $old)->update(['name' => $new]);
$count += AccountMeta::query()->where('name', $old)->update(['name' => $new]);
// delete empty entries while we're at it.
AccountMeta::where('name', $new)->where('data', '""')->delete();
AccountMeta::query()->where('name', $new)->where('data', '""')->delete();
}
$this->markAsExecuted();
@@ -152,7 +152,7 @@ class UpgradesBudgetLimitPeriods extends Command
private function theresNoLimit(): void
{
$limits = BudgetLimit::whereNull('period')->get();
$limits = BudgetLimit::query()->whereNull('period')->get();
/** @var BudgetLimit $limit */
foreach ($limits as $limit) {
@@ -55,8 +55,8 @@ class UpgradesCreditCardLiabilities extends Command
return 0;
}
$ccType = AccountType::where('type', AccountTypeEnum::CREDITCARD->value)->first();
$debtType = AccountType::where('type', AccountTypeEnum::DEBT->value)->first();
$ccType = AccountType::query()->where('type', AccountTypeEnum::CREDITCARD->value)->first();
$debtType = AccountType::query()->where('type', AccountTypeEnum::DEBT->value)->first();
if (null === $ccType || null === $debtType) {
$this->markAsExecuted();
@@ -64,7 +64,7 @@ class UpgradesCreditCardLiabilities extends Command
}
/** @var Collection $accounts */
$accounts = Account::where('account_type_id', $ccType->id)->get();
$accounts = Account::query()->where('account_type_id', $ccType->id)->get();
foreach ($accounts as $account) {
$account->account_type_id = $debtType->id;
$account->save();
@@ -66,7 +66,7 @@ class UpgradesCurrencyPreferences extends Command
private function getPreference(User $user): string
{
$preference = Preference::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'])
;
@@ -144,7 +144,7 @@ class UpgradesCurrencyPreferences extends Command
try {
$primaryCurrency = Amount::getTransactionCurrencyByCode($preference);
} catch (FireflyException) {
$primaryCurrency = TransactionCurrency::where('code', 'EUR')->first();
$primaryCurrency = TransactionCurrency::query()->where('code', 'EUR')->first();
}
$user->currencies()->updateExistingPivot($primaryCurrency->id, ['user_default' => true]);
$user->userGroup->currencies()->updateExistingPivot($primaryCurrency->id, ['group_default' => true]);
@@ -131,7 +131,7 @@ class UpgradesJournalMetaData extends Command
$allIds = $this->getIdsForBudgets();
$chunks = array_chunk($allIds, 500);
foreach ($chunks as $journalIds) {
$collected = TransactionJournal::whereIn('id', $journalIds)->with(['transactions', 'budgets', 'transactions.budgets'])->get();
$collected = TransactionJournal::query()->whereIn('id', $journalIds)->with(['transactions', 'budgets', 'transactions.budgets'])->get();
$journals = $journals->merge($collected);
}
@@ -180,7 +180,7 @@ class UpgradesJournalMetaData extends Command
$chunks = array_chunk($allIds, 500);
foreach ($chunks as $chunk) {
$collected = TransactionJournal::whereIn('id', $chunk)->with(['transactions', 'categories', 'transactions.categories'])->get();
$collected = TransactionJournal::query()->whereIn('id', $chunk)->with(['transactions', 'categories', 'transactions.categories'])->get();
$journals = $journals->merge($collected);
}
@@ -105,7 +105,7 @@ class UpgradesMultiPiggyBanks extends Command
{
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->accountRepository = app(AccountRepositoryInterface::class);
$set = PiggyBank::whereNotNull('account_id')->get();
$set = PiggyBank::query()->whereNotNull('account_id')->get();
Log::debug(sprintf('Will update %d piggy banks(s).', $set->count()));
/** @var PiggyBank $piggyBank */
@@ -104,7 +104,7 @@ class UpgradesRecurrenceMetaData extends Command
{
$count = 0;
// get all recurrence meta data:
$collection = RecurrenceMeta::with('recurrence')->get();
$collection = RecurrenceMeta::query()->with('recurrence')->get();
/** @var RecurrenceMeta $meta */
foreach ($collection as $meta) {
@@ -106,7 +106,7 @@ class UpgradesRuleActions extends Command
'move_descr_to_notes',
'move_notes_to_descr',
];
$actions = RuleAction::whereIn('action_type', $obsolete)->get();
$actions = RuleAction::query()->whereIn('action_type', $obsolete)->get();
/** @var RuleAction $action */
foreach ($actions as $action) {
@@ -84,9 +84,9 @@ class UpgradesWebhooks extends Command
return;
}
$deliveryModel = WebhookDeliveryModel::where('key', $delivery->value)->first();
$responseModel = WebhookResponseModel::where('key', $response->value)->first();
$triggerModel = WebhookTriggerModel::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));
@@ -104,7 +104,7 @@ class UpgradesWebhooks extends Command
private function upgradeWebhooks(): void
{
$set = Webhook::where('delivery', '>', 1)->orWhere('trigger', '>', 1)->orWhere('response', '>', 1)->get();
$set = Webhook::query()->where('delivery', '>', 1)->orWhere('trigger', '>', 1)->orWhere('response', '>', 1)->get();
/** @var Webhook $webhook */
foreach ($set as $webhook) {