First fixes for level 7.

This commit is contained in:
James Cole 2025-01-04 19:05:24 +01:00
parent 5602715c96
commit d2b6829574
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
4 changed files with 8 additions and 2 deletions

View File

@ -111,6 +111,7 @@ class CorrectsAccountTypes extends Command
$this->friendlyLine(sprintf('Found %d journals that need to be fixed.', $resultSet->count()));
foreach ($resultSet as $entry) {
app('log')->debug(sprintf('Now fixing journal #%d', $entry->id));
/** @var null|TransactionJournal $journal */
$journal = TransactionJournal::find($entry->id);
if (null !== $journal) {
$this->inspectJournal($journal);

View File

@ -236,8 +236,9 @@ class CorrectsNativeAmounts extends Command
TransactionObserver::$recalculate = false;
foreach ($set as $item) {
// here we are.
/** @var Transaction|null $transaction */
$transaction = Transaction::find($item->id);
$transaction->touch();
$transaction?->touch();
}
TransactionObserver::$recalculate = true;
Log::debug(sprintf('Recalculated %d transactions.', $set->count()));

View File

@ -66,7 +66,9 @@ class RemovesEmptyJournals extends Command
if (1 === $count % 2) {
// uneven number, delete journal and transactions:
try {
TransactionJournal::find($row->transaction_journal_id)->delete();
/** @var TransactionJournal|null $journal */
$journal = TransactionJournal::find($row->transaction_journal_id);
$journal?->delete();
} catch (QueryException $e) {
app('log')->info(sprintf('Could not delete journal: %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());

View File

@ -69,6 +69,7 @@ class RemovesOrphanedTransactions extends Command
}
$this->friendlyInfo(sprintf('Found %d orphaned journal(s).', $count));
foreach ($set as $entry) {
/** @var TransactionJournal|null $journal */
$journal = TransactionJournal::withTrashed()->find($entry->id);
if (null !== $journal) {
$journal->delete();
@ -130,6 +131,7 @@ class RemovesOrphanedTransactions extends Command
/** @var Transaction $transaction */
foreach ($set as $transaction) {
// delete journals
/** @var TransactionJournal|null $journal */
$journal = TransactionJournal::find($transaction->transaction_journal_id);
if (null !== $journal) {
$journal->delete();