Check for valid reference object in recurring finance (#1056)

This commit is contained in:
Nabeel S 2021-03-02 16:19:54 -05:00 committed by GitHub
parent 936cd2efd3
commit 922e754c9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,6 +66,10 @@ class RecurringFinanceService extends Service
$obj = $expense->getReferencedObject();
}
if (empty($obj)) {
return [null, null];
}
if ($klass === 'Airport') {
$memo = "Airport Expense: {$expense->name} ({$expense->ref_model_id})";
$transaction_group = "Airport: {$expense->ref_model_id}";
@ -128,6 +132,9 @@ class RecurringFinanceService extends Service
}
[$memo, $ta_group] = $this->getMemoAndGroup($expense);
if (empty($memo) || empty($ta_group)) {
continue;
}
$this->financeSvc->debitFromJournal(
$journal,