From 849b711b79f417e7bfb86561d28975fbed010219 Mon Sep 17 00:00:00 2001 From: Sander Dorigo Date: Tue, 14 Oct 2014 07:24:41 +0200 Subject: [PATCH] Recycle code instead of copy pasting. --- .../Journals/EloquentJournalTrigger.php | 39 +------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/app/lib/Firefly/Trigger/Journals/EloquentJournalTrigger.php b/app/lib/Firefly/Trigger/Journals/EloquentJournalTrigger.php index a78c22737d..b2cdbf9bde 100644 --- a/app/lib/Firefly/Trigger/Journals/EloquentJournalTrigger.php +++ b/app/lib/Firefly/Trigger/Journals/EloquentJournalTrigger.php @@ -33,46 +33,9 @@ class EloquentJournalTrigger /** @var \RecurringTransaction $recurring */ foreach ($set as $recurring) { - $matches = explode(' ', $recurring->match); - - /* - * Count the number of matches. - */ - $count = 0; - foreach ($matches as $word) { - if (!(strpos($description, strtolower($word)) === false)) { - $count++; - \Log::debug('Recurring transaction #' . $recurring->id . ': word "' . $word . '" found in "' . $description . '".'); - } - } - /* - * Check the amount if match on words: - */ - $amount = max(floatval($journal->transactions[0]->amount), floatval($journal->transactions[1]->amount)); - $min = floatval($recurring->amount_min); - $max = floatval($recurring->amount_max); - if ($amount >= $min && $amount <= $max) { - $result[$recurring->id] = $count; - } - + \Event::fire('recurring.rescan', [$recurring, $journal]); } - /* - * The one with the highest value is the winrar! - */ - $index = array_search(max($result), $result); - /* - * Find the recurring transaction: - */ - - if ($result[$index] > 0 && $index > 0) { - - $winner = $journal->user()->first()->recurringtransactions()->find($index); - if ($winner) { - $journal->recurringTransaction()->associate($winner); - $journal->save(); - } - } return true; }