Fix to make sure that the index respects the fiscal year.

This commit is contained in:
James Cole
2018-12-31 13:44:24 +01:00
parent f80de95bb0
commit aeab5f0333
2 changed files with 28 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ namespace FireflyIII\Support;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\FiscalHelperInterface;
use Log;
/**
@@ -583,7 +584,6 @@ class Navigation
'1W' => 'endOfWeek',
'1M' => 'endOfMonth',
'3M' => 'lastOfQuarter',
'1Y' => 'endOfYear',
'custom' => 'startOfMonth', // this only happens in test situations.
];
$end = clone $start;
@@ -604,6 +604,15 @@ class Navigation
return $end;
}
// make sure 1Y takes the fiscal year into account.
if ('1Y' === $range) {
/** @var FiscalHelperInterface $fiscalHelper */
$fiscalHelper = app(FiscalHelperInterface::class);
return $fiscalHelper->endOfFiscalYear($end);
}
throw new FireflyException(sprintf('updateEndDate cannot handle range "%s"', $range));
}
@@ -622,7 +631,6 @@ class Navigation
'1W' => 'startOfWeek',
'1M' => 'startOfMonth',
'3M' => 'firstOfQuarter',
'1Y' => 'startOfYear',
'custom' => 'startOfMonth', // this only happens in test situations.
];
if (isset($functionMap[$range])) {
@@ -641,6 +649,14 @@ class Navigation
return $start;
}
// make sure 1Y takes the fiscal year into account.
if ('1Y' === $range) {
/** @var FiscalHelperInterface $fiscalHelper */
$fiscalHelper = app(FiscalHelperInterface::class);
return $fiscalHelper->startOfFiscalYear($start);
}
throw new FireflyException(sprintf('updateStartDate cannot handle range "%s"', $range));
}
}