Some last-minute fixes.

This commit is contained in:
James Cole
2018-07-03 17:48:26 +02:00
parent 53addcf99a
commit 18b06ff283
7 changed files with 50 additions and 12 deletions

View File

@@ -90,6 +90,7 @@ class VerifyDatabase extends Command
$this->createAccessTokens();
$this->fixDoubleAmounts();
$this->fixBadMeta();
$this->removeBills();
}
/**
@@ -255,6 +256,23 @@ class VerifyDatabase extends Command
}
}
/**
*
*/
private function removeBills(): void
{
/** @var TransactionType $withdrawal */
$withdrawal = TransactionType::where('type', TransactionType::WITHDRAWAL)->first();
$journals = TransactionJournal::whereNotNull('bill_id')
->where('transaction_type_id', '!=', $withdrawal->id)->get();
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
$this->line(sprintf('Transaction journal #%d should not be linked to bill #%d.', $journal->id, $journal->bill_id));
$journal->bill_id = null;
$journal->save();
}
}
/**
* Eeport (and fix) piggy banks. Make sure there are only transfers linked to piggy bank events.
*/