mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
First fixes for level 7.
This commit is contained in:
parent
d2b6829574
commit
23178614d5
@ -36,7 +36,7 @@ class RemovesEmptyJournals extends Command
|
||||
|
||||
protected $description = 'Delete empty and uneven transaction journals.';
|
||||
|
||||
protected $signature = 'correction:empty-journals';
|
||||
protected $signature = 'correction:empty-journals';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
@ -55,8 +55,8 @@ class RemovesEmptyJournals extends Command
|
||||
private function deleteUnevenJournals(): void
|
||||
{
|
||||
$set = Transaction::whereNull('deleted_at')
|
||||
->groupBy('transactions.transaction_journal_id')
|
||||
->get([\DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']) // @phpstan-ignore-line
|
||||
->groupBy('transactions.transaction_journal_id')
|
||||
->get([\DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']) // @phpstan-ignore-line
|
||||
;
|
||||
$total = 0;
|
||||
|
||||
@ -87,14 +87,15 @@ 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 {
|
||||
TransactionJournal::find($entry->id)->delete();
|
||||
/** @var TransactionJournal|null $journal */
|
||||
$journal = TransactionJournal::find($entry->id);
|
||||
$journal?->delete();
|
||||
} catch (QueryException $e) {
|
||||
app('log')->info(sprintf('Could not delete entry: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
|
@ -264,7 +264,9 @@ class ForcesDecimalSize extends Command
|
||||
$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));
|
||||
Account::find($account->id)->update([$field => $correct]);
|
||||
/** @var Account|null $updateAccount */
|
||||
$updateAccount = Account::find($account->id);
|
||||
$updateAccount?->update([$field => $correct]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -313,7 +315,9 @@ class ForcesDecimalSize extends Command
|
||||
$pow = 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round($value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(sprintf('%s #%d has %s with value "%s", this has been corrected to "%s".', $table, $item->id, $field, $value, $correct));
|
||||
$class::find($item->id)->update([$field => $correct]);
|
||||
/** @var Model|null $model */
|
||||
$model = $class::find($item->id);
|
||||
$model?->update([$field => $correct]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -365,7 +369,9 @@ class ForcesDecimalSize extends Command
|
||||
$this->friendlyWarning(
|
||||
sprintf('Piggy bank event #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
|
||||
);
|
||||
PiggyBankEvent::find($item->id)->update([$field => $correct]);
|
||||
/** @var PiggyBankEvent|null $event */
|
||||
$event = PiggyBankEvent::find($item->id);
|
||||
$event?->update([$field => $correct]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -418,7 +424,9 @@ class ForcesDecimalSize extends Command
|
||||
$this->friendlyWarning(
|
||||
sprintf('Piggy bank repetition #%d has %s with value "%s", this has been corrected to "%s".', $item->id, $field, $value, $correct)
|
||||
);
|
||||
PiggyBankRepetition::find($item->id)->update([$field => $correct]);
|
||||
/** @var PiggyBankRepetition|null $repetition */
|
||||
$repetition = PiggyBankRepetition::find($item->id);
|
||||
$repetition->update([$field => $correct]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -467,7 +475,9 @@ class ForcesDecimalSize extends Command
|
||||
$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));
|
||||
PiggyBank::find($item->id)->update([$field => $correct]);
|
||||
/** @var PiggyBank|null $piggyBank */
|
||||
$piggyBank = PiggyBank::find($item->id);
|
||||
$piggyBank?->update([$field => $correct]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -500,7 +510,9 @@ class ForcesDecimalSize extends Command
|
||||
$pow = (float) 10 ** $currency->decimal_places;
|
||||
$correct = bcdiv((string) round((float) $value * $pow), (string) $pow, 12);
|
||||
$this->friendlyWarning(sprintf('Transaction #%d has amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct));
|
||||
Transaction::find($item->id)->update(['amount' => $correct]);
|
||||
/** @var Transaction|null $transaction */
|
||||
$transaction = Transaction::find($item->id);
|
||||
$transaction?->update(['amount' => $correct]);
|
||||
}
|
||||
|
||||
// select all transactions with this FOREIGN currency and issue.
|
||||
@ -530,7 +542,9 @@ class ForcesDecimalSize extends Command
|
||||
$this->friendlyWarning(
|
||||
sprintf('Transaction #%d has foreign amount with value "%s", this has been corrected to "%s".', $item->id, $value, $correct)
|
||||
);
|
||||
Transaction::find($item->id)->update(['foreign_amount' => $correct]);
|
||||
/** @var Transaction|null $transaction */
|
||||
$transaction = Transaction::find($item->id);
|
||||
$transaction?->update(['foreign_amount' => $correct]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,11 @@ class BudgetLimitHandler
|
||||
private function updateAvailableBudget(BudgetLimit $budgetLimit): void
|
||||
{
|
||||
Log::debug(sprintf('Now in updateAvailableBudget(limit #%d)', $budgetLimit->id));
|
||||
/** @var Budget|null $budget */
|
||||
$budget = Budget::find($budgetLimit->budget_id);
|
||||
if (null === $budget) {
|
||||
Log::warning('Budget is null, probably deleted, find deleted version.');
|
||||
/** @var Budget|null $budget */
|
||||
$budget = Budget::withTrashed()->find($budgetLimit->budget_id);
|
||||
}
|
||||
if (null === $budget) {
|
||||
|
@ -37,7 +37,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', '')),
|
||||
'stateful' => explode(',', (string) env('SANCTUM_STATEFUL_DOMAINS', '')),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user