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;
|
$wordMatch = false;
|
||||||
$matches = explode(' ', $recurring->match);
|
$matches = explode(' ', $recurring->match);
|
||||||
$description = strtolower($journal->description);
|
$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;
|
$count = 0;
|
||||||
foreach ($matches as $word) {
|
foreach ($matches as $word) {
|
||||||
if (!(strpos($description, strtolower($word)) === false)) {
|
if (!(strpos($description, strtolower($word)) === false)) {
|
||||||
$count++;
|
$count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($count > 0) {
|
if ($count >= count($matches)) {
|
||||||
$wordMatch = true;
|
$wordMatch = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Match amount.
|
* Match amount.
|
||||||
*/
|
*/
|
||||||
$transactions = $journal->transactions()->get();
|
|
||||||
$amountMatch = false;
|
$amountMatch = false;
|
||||||
if (count($transactions) > 1) {
|
if (count($transactions) > 1) {
|
||||||
|
|
||||||
@ -73,6 +89,7 @@ class EloquentRecurringTrigger
|
|||||||
$journal->recurringTransaction()->associate($recurring);
|
$journal->recurringTransaction()->associate($recurring);
|
||||||
$journal->save();
|
$journal->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user