mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-18 20:38:57 +00:00
Use facades.
This commit is contained in:
@@ -83,6 +83,7 @@ class RecurringTransaction extends Ardent
|
||||
return $this->hasMany('TransactionJournal');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO remove this method in favour of something in the FireflyIII libraries.
|
||||
*
|
||||
@@ -92,9 +93,6 @@ class RecurringTransaction extends Ardent
|
||||
public function nextExpectedMatch()
|
||||
{
|
||||
|
||||
/** @var \FireflyIII\Shared\Toolkit\Date $dateKit */
|
||||
$dateKit = App::make('FireflyIII\Shared\Toolkit\Date');
|
||||
|
||||
/*
|
||||
* The date Firefly tries to find. If this stays null, it's "unknown".
|
||||
*/
|
||||
@@ -104,14 +102,14 @@ class RecurringTransaction extends Ardent
|
||||
* $today is the start of the next period, to make sure FF3 won't miss anything
|
||||
* when the current period has a transaction journal.
|
||||
*/
|
||||
$today = $dateKit->addPeriod(new Carbon, $this->repeat_freq, 0);
|
||||
$today = DateKit::addPeriod(new Carbon, $this->repeat_freq, 0);
|
||||
|
||||
/*
|
||||
* FF3 loops from the $start of the recurring transaction, and to make sure
|
||||
* $skip works, it adds one (for modulo).
|
||||
*/
|
||||
$skip = $this->skip + 1;
|
||||
$start = $dateKit->startOfPeriod(new Carbon, $this->repeat_freq);
|
||||
$start = DateKit::startOfPeriod(new Carbon, $this->repeat_freq);
|
||||
/*
|
||||
* go back exactly one month/week/etc because FF3 does not care about 'next'
|
||||
* recurring transactions if they're too far into the past.
|
||||
@@ -124,7 +122,7 @@ class RecurringTransaction extends Ardent
|
||||
while ($start <= $today) {
|
||||
if (($counter % $skip) == 0) {
|
||||
// do something.
|
||||
$end = $dateKit->endOfPeriod(clone $start, $this->repeat_freq);
|
||||
$end = DateKit::endOfPeriod(clone $start, $this->repeat_freq);
|
||||
$journalCount = $this->transactionjournals()->before($end)->after($start)->count();
|
||||
if ($journalCount == 0) {
|
||||
$finalDate = clone $start;
|
||||
@@ -133,7 +131,7 @@ class RecurringTransaction extends Ardent
|
||||
}
|
||||
|
||||
// add period for next round!
|
||||
$start = $dateKit->addPeriod($start, $this->repeat_freq, 0);
|
||||
$start = DateKit::addPeriod($start, $this->repeat_freq, 0);
|
||||
$counter++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user