mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Expand match to include expense account.
This commit is contained in:
parent
849b711b79
commit
b7517b49ed
@ -41,20 +41,36 @@ class EloquentRecurringTrigger
|
||||
$wordMatch = false;
|
||||
$matches = explode(' ', $recurring->match);
|
||||
$description = strtolower($journal->description);
|
||||
|
||||
/*
|
||||
* Attach expense account to description for more narrow matching.
|
||||
*/
|
||||
$transactions = $journal->transactions()->get();
|
||||
/** @var \Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
/** @var \Account $account */
|
||||
$account = $transaction->account()->first();
|
||||
/** @var \AccountType $type */
|
||||
$type = $account->accountType()->first();
|
||||
if ($type->type == 'Expense account' || $type->type == 'Beneficiary account') {
|
||||
$description .= ' ' . strtolower($account->name);
|
||||
}
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
foreach ($matches as $word) {
|
||||
if (!(strpos($description, strtolower($word)) === false)) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
if ($count > 0) {
|
||||
if ($count >= count($matches)) {
|
||||
$wordMatch = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Match amount.
|
||||
*/
|
||||
$transactions = $journal->transactions()->get();
|
||||
|
||||
$amountMatch = false;
|
||||
if (count($transactions) > 1) {
|
||||
|
||||
@ -73,6 +89,7 @@ class EloquentRecurringTrigger
|
||||
$journal->recurringTransaction()->associate($recurring);
|
||||
$journal->save();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user