Null pointer in verify routine.

This commit is contained in:
James Cole 2017-12-11 10:59:28 +01:00
parent 5d9e547d05
commit d1c8e54798
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -164,13 +164,16 @@ class VerifyDatabase extends Command
}
foreach ($errored as $journalId) {
// select and update:
$res = Transaction::where('transaction_journal_id', $journalId)->groupBy('amount')->get([DB::raw('MIN(id) as first_id')]);
$res = Transaction::whereNull('deleted_at')->where('transaction_journal_id', $journalId)->groupBy('amount')->get([DB::raw('MIN(id) as first_id')]);
$ids = $res->pluck('first_id')->toArray();
DB::table('transactions')->whereIn('id', $ids)->update(['amount' => DB::raw('amount * -1')]);
$count++;
// report about it
/** @var TransactionJournal $journal */
$journal = TransactionJournal::find($journalId);
if (is_null($journal)) {
continue;
}
if ($journal->transactionType->type === TransactionType::OPENING_BALANCE) {
$this->error(
sprintf(