First fixes for level 7.

This commit is contained in:
James Cole
2025-01-04 19:05:24 +01:00
parent 5602715c96
commit d2b6829574
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())); $this->friendlyLine(sprintf('Found %d journals that need to be fixed.', $resultSet->count()));
foreach ($resultSet as $entry) { foreach ($resultSet as $entry) {
app('log')->debug(sprintf('Now fixing journal #%d', $entry->id)); app('log')->debug(sprintf('Now fixing journal #%d', $entry->id));
/** @var null|TransactionJournal $journal */
$journal = TransactionJournal::find($entry->id); $journal = TransactionJournal::find($entry->id);
if (null !== $journal) { if (null !== $journal) {
$this->inspectJournal($journal); $this->inspectJournal($journal);

View File

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

View File

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

View File

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