From df8976eabe195a0dc70a0de047f1b465b6b382ce Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 11 Apr 2015 12:40:47 +0200 Subject: [PATCH] Journals that no longer match a bill will be removed. --- app/Repositories/Bill/BillRepository.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index 611e438dbe..df997ba2c0 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -315,6 +315,12 @@ class BillRepository implements BillRepositoryInterface Log::debug('TOTAL match is true!'); $journal->bill()->associate($bill); $journal->save(); + } else { + if ((!$wordMatch || !$amountMatch) && $bill->id == $journal->bill_id) { + // if no match, but bill used to match, remove it: + $journal->bill_id = null; + $journal->save(); + } } }