mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Merge branch 'master' into develop
This commit is contained in:
commit
4794156e80
@ -175,6 +175,9 @@ class Toolkit implements ToolkitInterface
|
|||||||
{
|
{
|
||||||
$end = clone $start;
|
$end = clone $start;
|
||||||
switch ($range) {
|
switch ($range) {
|
||||||
|
default:
|
||||||
|
throw new FireflyException('_updateEndDate cannot handle $range ' . $range);
|
||||||
|
break;
|
||||||
case '1D':
|
case '1D':
|
||||||
$end->endOfDay();
|
$end->endOfDay();
|
||||||
break;
|
break;
|
||||||
@ -197,9 +200,7 @@ class Toolkit implements ToolkitInterface
|
|||||||
case '1Y':
|
case '1Y':
|
||||||
$end->endOfYear();
|
$end->endOfYear();
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
throw new FireflyException('_updateEndDate cannot handle $range ' . $range);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $end;
|
return $end;
|
||||||
@ -241,6 +242,9 @@ class Toolkit implements ToolkitInterface
|
|||||||
protected function _previous($range, Carbon $date)
|
protected function _previous($range, Carbon $date)
|
||||||
{
|
{
|
||||||
switch ($range) {
|
switch ($range) {
|
||||||
|
default:
|
||||||
|
throw new FireflyException('Cannot do _previous() on ' . $range);
|
||||||
|
break;
|
||||||
case '1D':
|
case '1D':
|
||||||
$date->startOfDay()->subDay();
|
$date->startOfDay()->subDay();
|
||||||
break;
|
break;
|
||||||
@ -264,9 +268,7 @@ class Toolkit implements ToolkitInterface
|
|||||||
case '1Y':
|
case '1Y':
|
||||||
$date->startOfYear()->subYear();
|
$date->startOfYear()->subYear();
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
throw new FireflyException('Cannot do _previous() on ' . $range);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return $date;
|
return $date;
|
||||||
}
|
}
|
||||||
|
@ -23,12 +23,13 @@ class EloquentJournalTrigger
|
|||||||
/*
|
/*
|
||||||
* Grab all recurring events.
|
* Grab all recurring events.
|
||||||
*/
|
*/
|
||||||
$set = $journal->user()->first()->recurringtransactions()->get();
|
$set = $journal->user()->first()->recurringtransactions()->get();
|
||||||
$result = [];
|
$result = [];
|
||||||
/*
|
/*
|
||||||
* Prep vars
|
* Prep vars
|
||||||
*/
|
*/
|
||||||
$description = strtolower($journal->description);
|
$description = strtolower($journal->description);
|
||||||
|
$result = [0 => 0];
|
||||||
|
|
||||||
/** @var \RecurringTransaction $recurring */
|
/** @var \RecurringTransaction $recurring */
|
||||||
foreach ($set as $recurring) {
|
foreach ($set as $recurring) {
|
||||||
@ -44,7 +45,16 @@ class EloquentJournalTrigger
|
|||||||
\Log::debug('Recurring transaction #' . $recurring->id . ': word "' . $word . '" found in "' . $description . '".');
|
\Log::debug('Recurring transaction #' . $recurring->id . ': word "' . $word . '" found in "' . $description . '".');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result[$recurring->id] = $count;
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* The one with the highest value is the winrar!
|
* The one with the highest value is the winrar!
|
||||||
@ -54,7 +64,9 @@ class EloquentJournalTrigger
|
|||||||
/*
|
/*
|
||||||
* Find the recurring transaction:
|
* Find the recurring transaction:
|
||||||
*/
|
*/
|
||||||
if (count($result[$index]) > 0) {
|
|
||||||
|
if ($result[$index] > 0 && $index > 0) {
|
||||||
|
|
||||||
$winner = $journal->user()->first()->recurringtransactions()->find($index);
|
$winner = $journal->user()->first()->recurringtransactions()->find($index);
|
||||||
if ($winner) {
|
if ($winner) {
|
||||||
$journal->recurringTransaction()->associate($winner);
|
$journal->recurringTransaction()->associate($winner);
|
||||||
|
Loading…
Reference in New Issue
Block a user