Replace classes

This commit is contained in:
James Cole
2025-11-25 20:12:23 +01:00
parent 7b7b9118cd
commit fa018e80c0
29 changed files with 124 additions and 102 deletions

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Helpers\Report; namespace FireflyIII\Helpers\Report;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface; use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
@@ -81,7 +82,7 @@ class ReportHelper implements ReportHelperInterface
/** @var Carbon $expectedStart */ /** @var Carbon $expectedStart */
foreach ($expectedDates as $expectedStart) { foreach ($expectedDates as $expectedStart) {
$expectedEnd = app('navigation')->endOfX($expectedStart, $bill->repeat_freq, null); $expectedEnd = Navigation::endOfX($expectedStart, $bill->repeat_freq, null);
// is paid in this period maybe? // is paid in this period maybe?
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Account; namespace FireflyIII\Http\Controllers\Account;
use FireflyIII\Support\Facades\Navigation;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Enums\AccountTypeEnum;
@@ -91,20 +92,20 @@ class ReconcileController extends Controller
$currency = $this->accountRepos->getAccountCurrency($account) ?? $this->primaryCurrency; $currency = $this->accountRepos->getAccountCurrency($account) ?? $this->primaryCurrency;
// no start or end: // no start or end:
$range = app('navigation')->getViewRange(false); $range = Navigation::getViewRange(false);
// get start and end // get start and end
if (!$start instanceof Carbon && !$end instanceof Carbon) { if (!$start instanceof Carbon && !$end instanceof Carbon) {
/** @var Carbon $start */ /** @var Carbon $start */
$start = clone session('start', app('navigation')->startOfPeriod(new Carbon(), $range)); $start = clone session('start', Navigation::startOfPeriod(new Carbon(), $range));
/** @var Carbon $end */ /** @var Carbon $end */
$end = clone session('end', app('navigation')->endOfPeriod(new Carbon(), $range)); $end = clone session('end', Navigation::endOfPeriod(new Carbon(), $range));
} }
if (null === $end) { if (null === $end) {
/** @var Carbon $end */ /** @var Carbon $end */
$end = app('navigation')->endOfPeriod($start, $range); $end = Navigation::endOfPeriod($start, $range);
} }
if ($end->lt($start)) { if ($end->lt($start)) {

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Bill; namespace FireflyIII\Http\Controllers\Bill;
use FireflyIII\Support\Facades\Navigation;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Bill; use FireflyIII\Models\Bill;
@@ -151,7 +152,7 @@ class IndexController extends Controller
private function getSums(array $bills): array private function getSums(array $bills): array
{ {
$sums = []; $sums = [];
$range = app('navigation')->getViewRange(true); $range = Navigation::getViewRange(true);
/** @var array $group */ /** @var array $group */
foreach ($bills as $groupOrder => $group) { foreach ($bills as $groupOrder => $group) {

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Bill; namespace FireflyIII\Http\Controllers\Bill;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -139,8 +140,8 @@ class ShowController extends Controller
$manager->parseIncludes(['attachments', 'notes']); $manager->parseIncludes(['attachments', 'notes']);
// add another period to end, could fix 8163 // add another period to end, could fix 8163
$range = app('navigation')->getViewRange(true); $range = Navigation::getViewRange(true);
$end = app('navigation')->addPeriod($end, $range); $end = Navigation::addPeriod($end, $range);
// Make a resource out of the data and // Make a resource out of the data and
$parameters = new ParameterBag(); $parameters = new ParameterBag();

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Budget; namespace FireflyIII\Http\Controllers\Budget;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -94,11 +95,11 @@ class IndexController extends Controller
Log::debug(sprintf('Start of IndexController::index("%s", "%s")', $start?->format('Y-m-d'), $end?->format('Y-m-d'))); Log::debug(sprintf('Start of IndexController::index("%s", "%s")', $start?->format('Y-m-d'), $end?->format('Y-m-d')));
// collect some basic vars: // collect some basic vars:
$range = app('navigation')->getViewRange(true); $range = Navigation::getViewRange(true);
$isCustomRange = session('is_custom_range', false); $isCustomRange = session('is_custom_range', false);
if (false === $isCustomRange) { if (false === $isCustomRange) {
$start ??= session('start', today(config('app.timezone'))->startOfMonth()); $start ??= session('start', today(config('app.timezone'))->startOfMonth());
$end ??= app('navigation')->endOfPeriod($start, $range); $end ??= Navigation::endOfPeriod($start, $range);
} }
// overrule start and end if necessary: // overrule start and end if necessary:
@@ -112,7 +113,7 @@ class IndexController extends Controller
$spent = '0'; $spent = '0';
// new period stuff: // new period stuff:
$periodTitle = app('navigation')->periodShow($start, $range); $periodTitle = Navigation::periodShow($start, $range);
$prevLoop = $this->getPreviousPeriods($start, $range); $prevLoop = $this->getPreviousPeriods($start, $range);
$nextLoop = $this->getNextPeriods($start, $range); $nextLoop = $this->getNextPeriods($start, $range);

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart; namespace FireflyIII\Http\Controllers\Chart;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
@@ -514,7 +515,7 @@ class AccountController extends Controller
// have to make sure this chart is always based on the balance at the END of the period. // have to make sure this chart is always based on the balance at the END of the period.
// This period depends on the size of the chart // This period depends on the size of the chart
$current = clone $start; $current = clone $start;
$current = app('navigation')->endOfX($current, $step, null); $current = Navigation::endOfX($current, $step, null);
$format = (string)trans('config.month_and_day_js', [], $locale); $format = (string)trans('config.month_and_day_js', [], $locale);
$accountCurrency = $this->accountRepository->getAccountCurrency($account); $accountCurrency = $this->accountRepository->getAccountCurrency($account);
Log::debug('Get and filter balance for entire range start'); Log::debug('Get and filter balance for entire range start');
@@ -574,9 +575,9 @@ class AccountController extends Controller
$label = $current->isoFormat($format); $label = $current->isoFormat($format);
$return[$key]['entries'][$label] = $amount; $return[$key]['entries'][$label] = $amount;
} }
$current = app('navigation')->addPeriod($current, $step); $current = Navigation::addPeriod($current, $step);
// here too, to fix #8041, the data is corrected to the end of the period. // here too, to fix #8041, the data is corrected to the end of the period.
$current = app('navigation')->endOfX($current, $step, null); $current = Navigation::endOfX($current, $step, null);
} }
Log::debug('End of chart loop.'); Log::debug('End of chart loop.');
// second loop (yes) to create nice array with info! Yay! // second loop (yes) to create nice array with info! Yay!

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart; namespace FireflyIII\Http\Controllers\Chart;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -81,8 +82,8 @@ class CategoryController extends Controller
/** @var CategoryRepositoryInterface $repository */ /** @var CategoryRepositoryInterface $repository */
$repository = app(CategoryRepositoryInterface::class); $repository = app(CategoryRepositoryInterface::class);
$start = $repository->firstUseDate($category) ?? $this->getDate(); $start = $repository->firstUseDate($category) ?? $this->getDate();
$range = app('navigation')->getViewRange(false); $range = Navigation::getViewRange(false);
$start = app('navigation')->startOfPeriod($start, $range); $start = Navigation::startOfPeriod($start, $range);
$end = $this->getDate(); $end = $this->getDate();
/** @var WholePeriodChartGenerator $chartGenerator */ /** @var WholePeriodChartGenerator $chartGenerator */
@@ -178,8 +179,8 @@ class CategoryController extends Controller
$income = $opsRepository->listIncome($start, $end, $accounts, $collection); $income = $opsRepository->listIncome($start, $end, $accounts, $collection);
} }
$currencies = array_unique(array_merge(array_keys($income), array_keys($expenses))); $currencies = array_unique(array_merge(array_keys($income), array_keys($expenses)));
$periods = app('navigation')->listOfPeriods($start, $end); $periods = Navigation::listOfPeriods($start, $end);
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end); $format = Navigation::preferredCarbonLocalizedFormat($start, $end);
$chartData = []; $chartData = [];
// make empty data array: // make empty data array:
// double foreach (bad) to make empty array: // double foreach (bad) to make empty array:
@@ -260,8 +261,8 @@ class CategoryController extends Controller
*/ */
public function specificPeriod(Category $category, Carbon $date): JsonResponse public function specificPeriod(Category $category, Carbon $date): JsonResponse
{ {
$range = app('navigation')->getViewRange(false); $range = Navigation::getViewRange(false);
$start = app('navigation')->startOfPeriod($date, $range); $start = Navigation::startOfPeriod($date, $range);
$end = session()->get('end'); $end = session()->get('end');
if ($end < $start) { if ($end < $start) {
[$end, $start] = [$start, $end]; [$end, $start] = [$start, $end];

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart; namespace FireflyIII\Http\Controllers\Chart;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -210,7 +211,7 @@ class CategoryReportController extends Controller
$chartData = []; $chartData = [];
$spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection()->push($category)); $spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection()->push($category));
$earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection()->push($category)); $earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection()->push($category));
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end); $format = Navigation::preferredCarbonLocalizedFormat($start, $end);
// loop expenses. // loop expenses.
foreach ($spent as $currency) { foreach ($spent as $currency) {
// add things to chart Data for each currency: // add things to chart Data for each currency:
@@ -276,11 +277,11 @@ class CategoryReportController extends Controller
private function makeEntries(Carbon $start, Carbon $end): array private function makeEntries(Carbon $start, Carbon $end): array
{ {
$return = []; $return = [];
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end); $format = Navigation::preferredCarbonLocalizedFormat($start, $end);
$preferredRange = app('navigation')->preferredRangeFormat($start, $end); $preferredRange = Navigation::preferredRangeFormat($start, $end);
$currentStart = clone $start; $currentStart = clone $start;
while ($currentStart <= $end) { while ($currentStart <= $end) {
$currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange); $currentEnd = Navigation::endOfPeriod($currentStart, $preferredRange);
$key = $currentStart->isoFormat($format); $key = $currentStart->isoFormat($format);
$return[$key] = '0'; $return[$key] = '0';
$currentStart = clone $currentEnd; $currentStart = clone $currentEnd;

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart; namespace FireflyIII\Http\Controllers\Chart;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -154,7 +155,7 @@ class DoubleReportController extends Controller
$accounts = $accounts->merge($opposing); $accounts = $accounts->merge($opposing);
$spent = $this->opsRepository->listExpenses($start, $end, $accounts); $spent = $this->opsRepository->listExpenses($start, $end, $accounts);
$earned = $this->opsRepository->listIncome($start, $end, $accounts); $earned = $this->opsRepository->listIncome($start, $end, $accounts);
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end); $format = Navigation::preferredCarbonLocalizedFormat($start, $end);
// loop expenses. // loop expenses.
foreach ($spent as $currency) { foreach ($spent as $currency) {
@@ -238,11 +239,11 @@ class DoubleReportController extends Controller
private function makeEntries(Carbon $start, Carbon $end): array private function makeEntries(Carbon $start, Carbon $end): array
{ {
$return = []; $return = [];
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end); $format = Navigation::preferredCarbonLocalizedFormat($start, $end);
$preferredRange = app('navigation')->preferredRangeFormat($start, $end); $preferredRange = Navigation::preferredRangeFormat($start, $end);
$currentStart = clone $start; $currentStart = clone $start;
while ($currentStart <= $end) { while ($currentStart <= $end) {
$currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange); $currentEnd = Navigation::endOfPeriod($currentStart, $preferredRange);
$key = $currentStart->isoFormat($format); $key = $currentStart->isoFormat($format);
$return[$key] = '0'; $return[$key] = '0';
$currentStart = clone $currentEnd; $currentStart = clone $currentEnd;

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart; namespace FireflyIII\Http\Controllers\Chart;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -83,8 +84,8 @@ class ExpenseReportController extends Controller
return response()->json($cache->get()); return response()->json($cache->get());
} }
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end); $format = Navigation::preferredCarbonLocalizedFormat($start, $end);
$function = app('navigation')->preferredEndOfPeriod($start, $end); $function = Navigation::preferredEndOfPeriod($start, $end);
$chartData = []; $chartData = [];
$currentStart = clone $start; $currentStart = clone $start;
$combined = $this->combineAccounts($expense); $combined = $this->combineAccounts($expense);

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart; namespace FireflyIII\Http\Controllers\Chart;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -92,7 +93,7 @@ class PiggyBankController extends Controller
$currentSum = $filtered->sum('amount'); $currentSum = $filtered->sum('amount');
$label = $oldest->isoFormat((string) trans('config.month_and_day_js', [], $locale)); $label = $oldest->isoFormat((string) trans('config.month_and_day_js', [], $locale));
$chartData[$label] = $currentSum; $chartData[$label] = $currentSum;
$oldest = app('navigation')->addPeriod($oldest, $step); $oldest = Navigation::addPeriod($oldest, $step);
} }
$finalFiltered = $set->filter( $finalFiltered = $set->filter(
static fn (PiggyBankEvent $event) => $event->date->lte($today) static fn (PiggyBankEvent $event) => $event->date->lte($today)

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart; namespace FireflyIII\Http\Controllers\Chart;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
@@ -154,9 +155,9 @@ class ReportController extends Controller
Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray()); Log::debug('Going to do operations for accounts ', $accounts->pluck('id')->toArray());
Log::debug(sprintf('Period: %s to %s', $start->toW3cString(), $end->toW3cString())); Log::debug(sprintf('Period: %s to %s', $start->toW3cString(), $end->toW3cString()));
$format = app('navigation')->preferredCarbonFormat($start, $end); $format = Navigation::preferredCarbonFormat($start, $end);
$titleFormat = app('navigation')->preferredCarbonLocalizedFormat($start, $end); $titleFormat = Navigation::preferredCarbonLocalizedFormat($start, $end);
$preferredRange = app('navigation')->preferredRangeFormat($start, $end); $preferredRange = Navigation::preferredRangeFormat($start, $end);
$ids = $accounts->pluck('id')->toArray(); $ids = $accounts->pluck('id')->toArray();
$data = []; $data = [];
$chartData = []; $chartData = [];
@@ -242,7 +243,7 @@ class ReportController extends Controller
// #8374. Sloppy fix for yearly charts. Not really interested in a better fix with v2 layout and all. // #8374. Sloppy fix for yearly charts. Not really interested in a better fix with v2 layout and all.
if ('1Y' === $preferredRange) { if ('1Y' === $preferredRange) {
$currentEnd = app('navigation')->endOfPeriod($currentEnd, $preferredRange); $currentEnd = Navigation::endOfPeriod($currentEnd, $preferredRange);
} }
Log::debug('Start of sub-loop'); Log::debug('Start of sub-loop');
while ($currentStart <= $currentEnd) { while ($currentStart <= $currentEnd) {
@@ -260,7 +261,7 @@ class ReportController extends Controller
$expense['entries'][$title] = '0'; $expense['entries'][$title] = '0';
} }
$currentStart = app('navigation')->addPeriod($currentStart, $preferredRange); $currentStart = Navigation::addPeriod($currentStart, $preferredRange);
} }
Log::debug('End of sub-loop'); Log::debug('End of sub-loop');

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Chart; namespace FireflyIII\Http\Controllers\Chart;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface; use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Http\Controllers\Controller; use FireflyIII\Http\Controllers\Controller;
@@ -214,7 +215,7 @@ class TagReportController extends Controller
$chartData = []; $chartData = [];
$spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection()->push($tag)); $spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection()->push($tag));
$earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection()->push($tag)); $earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection()->push($tag));
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end); $format = Navigation::preferredCarbonLocalizedFormat($start, $end);
// loop expenses. // loop expenses.
foreach ($spent as $currency) { foreach ($spent as $currency) {
@@ -281,11 +282,11 @@ class TagReportController extends Controller
private function makeEntries(Carbon $start, Carbon $end): array private function makeEntries(Carbon $start, Carbon $end): array
{ {
$return = []; $return = [];
$format = app('navigation')->preferredCarbonLocalizedFormat($start, $end); $format = Navigation::preferredCarbonLocalizedFormat($start, $end);
$preferredRange = app('navigation')->preferredRangeFormat($start, $end); $preferredRange = Navigation::preferredRangeFormat($start, $end);
$currentStart = clone $start; $currentStart = clone $start;
while ($currentStart <= $end) { while ($currentStart <= $end) {
$currentEnd = app('navigation')->endOfPeriod($currentStart, $preferredRange); $currentEnd = Navigation::endOfPeriod($currentStart, $preferredRange);
$key = $currentStart->isoFormat($format); $key = $currentStart->isoFormat($format);
$return[$key] = '0'; $return[$key] = '0';
$currentStart = clone $currentEnd; $currentStart = clone $currentEnd;

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers; namespace FireflyIII\Http\Controllers;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency; use FireflyIII\Events\Preferences\UserGroupChangedPrimaryCurrency;
@@ -101,7 +102,7 @@ class PreferencesController extends Controller
/** @var array<int, int> $accountIds */ /** @var array<int, int> $accountIds */
$accountIds = $accounts->pluck('id')->toArray(); $accountIds = $accounts->pluck('id')->toArray();
$viewRange = app('navigation')->getViewRange(false); $viewRange = Navigation::getViewRange(false);
$frontpageAccountsPref = Preferences::get('frontpageAccounts', $accountIds); $frontpageAccountsPref = Preferences::get('frontpageAccounts', $accountIds);
$frontpageAccounts = $frontpageAccountsPref->data; $frontpageAccounts = $frontpageAccountsPref->data;
if (!is_array($frontpageAccounts)) { if (!is_array($frontpageAccounts)) {

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers\Report; namespace FireflyIII\Http\Controllers\Report;
use FireflyIII\Support\Facades\Navigation;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
@@ -485,7 +486,7 @@ class CategoryController extends Controller
// depending on the carbon format (a reliable way to determine the general date difference) // depending on the carbon format (a reliable way to determine the general date difference)
// change the "listOfPeriods" call so the entire period gets included correctly. // change the "listOfPeriods" call so the entire period gets included correctly.
$format = app('navigation')->preferredCarbonFormat($start, $end); $format = Navigation::preferredCarbonFormat($start, $end);
if ('Y' === $format) { if ('Y' === $format) {
$start->startOfYear(); $start->startOfYear();
@@ -494,7 +495,7 @@ class CategoryController extends Controller
$start->startOfMonth(); $start->startOfMonth();
} }
$periods = app('navigation')->listOfPeriods($start, $end); $periods = Navigation::listOfPeriods($start, $end);
$data = []; $data = [];
$with = $this->opsRepository->listExpenses($start, $end, $accounts); $with = $this->opsRepository->listExpenses($start, $end, $accounts);
$without = $this->noCatRepository->listExpenses($start, $end, $accounts); $without = $this->noCatRepository->listExpenses($start, $end, $accounts);
@@ -559,7 +560,7 @@ class CategoryController extends Controller
// depending on the carbon format (a reliable way to determine the general date difference) // depending on the carbon format (a reliable way to determine the general date difference)
// change the "listOfPeriods" call so the entire period gets included correctly. // change the "listOfPeriods" call so the entire period gets included correctly.
$format = app('navigation')->preferredCarbonFormat($start, $end); $format = Navigation::preferredCarbonFormat($start, $end);
if ('Y' === $format) { if ('Y' === $format) {
$start->startOfYear(); $start->startOfYear();
@@ -568,7 +569,7 @@ class CategoryController extends Controller
$start->startOfMonth(); $start->startOfMonth();
} }
$periods = app('navigation')->listOfPeriods($start, $end); $periods = Navigation::listOfPeriods($start, $end);
$data = []; $data = [];
$with = $this->opsRepository->listIncome($start, $end, $accounts); $with = $this->opsRepository->listIncome($start, $end, $accounts);
$without = $this->noCatRepository->listIncome($start, $end, $accounts); $without = $this->noCatRepository->listIncome($start, $end, $accounts);

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Http\Middleware; namespace FireflyIII\Http\Middleware;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use Closure; use Closure;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface; use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
@@ -75,8 +76,8 @@ class Range
} }
$today = today(config('app.timezone')); $today = today(config('app.timezone'));
$start = app('navigation')->updateStartDate((string) $viewRange, $today); $start = Navigation::updateStartDate((string) $viewRange, $today);
$end = app('navigation')->updateEndDate((string) $viewRange, $start); $end = Navigation::updateEndDate((string) $viewRange, $start);
app('session')->put('start', $start); app('session')->put('start', $start);
app('session')->put('end', $end); app('session')->put('end', $end);

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Jobs; namespace FireflyIII\Jobs;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\AutoBudgetType; use FireflyIII\Enums\AutoBudgetType;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
@@ -122,8 +123,8 @@ class CreateAutoBudgetLimits implements ShouldQueue
); );
// get date range for budget limit, based on range in auto-budget // get date range for budget limit, based on range in auto-budget
$start = app('navigation')->startOfPeriod($this->date, $autoBudget->period); $start = Navigation::startOfPeriod($this->date, $autoBudget->period);
$end = app('navigation')->endOfPeriod($start, $autoBudget->period); $end = Navigation::endOfPeriod($start, $autoBudget->period);
// find budget limit: // find budget limit:
$budgetLimit = $this->findBudgetLimit($autoBudget->budget, $start, $end); $budgetLimit = $this->findBudgetLimit($autoBudget->budget, $start, $end);
@@ -237,12 +238,12 @@ class CreateAutoBudgetLimits implements ShouldQueue
{ {
Log::debug(sprintf('Will now manage rollover for auto budget #%d', $autoBudget->id)); Log::debug(sprintf('Will now manage rollover for auto budget #%d', $autoBudget->id));
// current period: // current period:
$start = app('navigation')->startOfPeriod($this->date, $autoBudget->period); $start = Navigation::startOfPeriod($this->date, $autoBudget->period);
$end = app('navigation')->endOfPeriod($start, $autoBudget->period); $end = Navigation::endOfPeriod($start, $autoBudget->period);
// which means previous period: // which means previous period:
$previousStart = app('navigation')->subtractPeriod($start, $autoBudget->period); $previousStart = Navigation::subtractPeriod($start, $autoBudget->period);
$previousEnd = app('navigation')->endOfPeriod($previousStart, $autoBudget->period); $previousEnd = Navigation::endOfPeriod($previousStart, $autoBudget->period);
Log::debug( Log::debug(
sprintf( sprintf(
@@ -297,12 +298,12 @@ class CreateAutoBudgetLimits implements ShouldQueue
{ {
Log::debug(sprintf('Will now manage rollover for auto budget #%d', $autoBudget->id)); Log::debug(sprintf('Will now manage rollover for auto budget #%d', $autoBudget->id));
// current period: // current period:
$start = app('navigation')->startOfPeriod($this->date, $autoBudget->period); $start = Navigation::startOfPeriod($this->date, $autoBudget->period);
$end = app('navigation')->endOfPeriod($start, $autoBudget->period); $end = Navigation::endOfPeriod($start, $autoBudget->period);
// which means previous period: // which means previous period:
$previousStart = app('navigation')->subtractPeriod($start, $autoBudget->period); $previousStart = Navigation::subtractPeriod($start, $autoBudget->period);
$previousEnd = app('navigation')->endOfPeriod($previousStart, $autoBudget->period); $previousEnd = Navigation::endOfPeriod($previousStart, $autoBudget->period);
Log::debug( Log::debug(
sprintf( sprintf(

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Bill; namespace FireflyIII\Repositories\Bill;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Factory\BillFactory; use FireflyIII\Factory\BillFactory;
@@ -463,11 +464,11 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
while ($start < $date) { while ($start < $date) {
Log::debug(sprintf('$start (%s) < $date (%s)', $start->format('Y-m-d H:i:s'), $date->format('Y-m-d H:i:s'))); Log::debug(sprintf('$start (%s) < $date (%s)', $start->format('Y-m-d H:i:s'), $date->format('Y-m-d H:i:s')));
$start = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip); $start = Navigation::addPeriod($start, $bill->repeat_freq, $bill->skip);
Log::debug('Start is now '.$start->format('Y-m-d H:i:s')); Log::debug('Start is now '.$start->format('Y-m-d H:i:s'));
} }
$end = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip); $end = Navigation::addPeriod($start, $bill->repeat_freq, $bill->skip);
$end->endOfDay(); $end->endOfDay();
// see if the bill was paid in this period. // see if the bill was paid in this period.
@@ -477,7 +478,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
// this period had in fact a bill. The new start is the current end, and we create a new end. // this period had in fact a bill. The new start is the current end, and we create a new end.
Log::debug(sprintf('Journal count is %d, so start becomes %s', $journalCount, $end->format('Y-m-d'))); Log::debug(sprintf('Journal count is %d, so start becomes %s', $journalCount, $end->format('Y-m-d')));
$start = clone $end; $start = clone $end;
$end = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip); $end = Navigation::addPeriod($start, $bill->repeat_freq, $bill->skip);
} }
Log::debug('nextExpectedMatch: Final start is '.$start->format('Y-m-d')); Log::debug('nextExpectedMatch: Final start is '.$start->format('Y-m-d'));
Log::debug('nextExpectedMatch: Matching end is '.$end->format('Y-m-d')); Log::debug('nextExpectedMatch: Matching end is '.$end->format('Y-m-d'));
@@ -681,7 +682,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
$start = clone $bill->date; $start = clone $bill->date;
while ($start < $date) { while ($start < $date) {
$start = app('navigation')->addPeriod($start, $bill->repeat_freq, $bill->skip); $start = Navigation::addPeriod($start, $bill->repeat_freq, $bill->skip);
} }
$cache->store($start); $cache->store($start);

View File

@@ -23,6 +23,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Budget; namespace FireflyIII\Repositories\Budget;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\AutoBudgetType; use FireflyIII\Enums\AutoBudgetType;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
@@ -790,8 +791,8 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
// create initial budget limit. // create initial budget limit.
$today = today(config('app.timezone')); $today = today(config('app.timezone'));
$start = app('navigation')->startOfPeriod($today, $autoBudget->period); $start = Navigation::startOfPeriod($today, $autoBudget->period);
$end = app('navigation')->endOfPeriod($start, $autoBudget->period); $end = Navigation::endOfPeriod($start, $autoBudget->period);
$limitRepos = app(BudgetLimitRepositoryInterface::class); $limitRepos = app(BudgetLimitRepositoryInterface::class);
$limitRepos->setUser($this->user); $limitRepos->setUser($this->user);

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Budget; namespace FireflyIII\Repositories\Budget;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Helpers\Collector\GroupCollectorInterface;
@@ -45,7 +46,7 @@ class NoBudgetRepository implements NoBudgetRepositoryInterface, UserGroupInterf
#[Deprecated] #[Deprecated]
public function getNoBudgetPeriodReport(Collection $accounts, Carbon $start, Carbon $end): array public function getNoBudgetPeriodReport(Collection $accounts, Carbon $start, Carbon $end): array
{ {
$carbonFormat = app('navigation')->preferredCarbonFormat($start, $end); $carbonFormat = Navigation::preferredCarbonFormat($start, $end);
/** @var GroupCollectorInterface $collector */ /** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class); $collector = app(GroupCollectorInterface::class);

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Repositories\Budget; namespace FireflyIII\Repositories\Budget;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use Deprecated; use Deprecated;
use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\TransactionTypeEnum;
@@ -82,7 +83,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
#[Deprecated] #[Deprecated]
public function getBudgetPeriodReport(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array public function getBudgetPeriodReport(Collection $budgets, Collection $accounts, Carbon $start, Carbon $end): array
{ {
$carbonFormat = app('navigation')->preferredCarbonFormat($start, $end); $carbonFormat = Navigation::preferredCarbonFormat($start, $end);
$data = []; $data = [];
// get all transactions: // get all transactions:

View File

@@ -76,7 +76,6 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac
*/ */
public function firstNull(): ?TransactionJournal public function firstNull(): ?TransactionJournal
{ {
/** @var null|TransactionJournal $entry */
return $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']); return $this->user->transactionJournals()->orderBy('date', 'ASC')->first(['transaction_journals.*']);
} }
@@ -113,7 +112,6 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac
public function getLast(): ?TransactionJournal public function getLast(): ?TransactionJournal
{ {
/** @var null|TransactionJournal $entry */
return $this->user->transactionJournals()->orderBy('date', 'DESC')->first(['transaction_journals.*']); return $this->user->transactionJournals()->orderBy('date', 'DESC')->first(['transaction_journals.*']);
} }

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Chart\Category; namespace FireflyIII\Support\Chart\Category;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Enums\AccountTypeEnum; use FireflyIII\Enums\AccountTypeEnum;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
@@ -59,10 +60,10 @@ class WholePeriodChartGenerator
while ($current <= $end) { while ($current <= $end) {
$key = $current->format('Y-m-d'); $key = $current->format('Y-m-d');
$currentEnd = app('navigation')->endOfPeriod($current, $step); $currentEnd = Navigation::endOfPeriod($current, $step);
$spent[$key] = $opsRepository->sumExpenses($current, $currentEnd, $accounts, $collection); $spent[$key] = $opsRepository->sumExpenses($current, $currentEnd, $accounts, $collection);
$earned[$key] = $opsRepository->sumIncome($current, $currentEnd, $accounts, $collection); $earned[$key] = $opsRepository->sumIncome($current, $currentEnd, $accounts, $collection);
$current = app('navigation')->addPeriod($current, $step); $current = Navigation::addPeriod($current, $step);
} }
$currencies = $this->extractCurrencies($spent) + $this->extractCurrencies($earned); $currencies = $this->extractCurrencies($spent) + $this->extractCurrencies($earned);
@@ -91,7 +92,7 @@ class WholePeriodChartGenerator
while ($current <= $end) { while ($current <= $end) {
$key = $current->format('Y-m-d'); $key = $current->format('Y-m-d');
$label = app('navigation')->periodShow($current, $step); $label = Navigation::periodShow($current, $step);
/** @var array $currency */ /** @var array $currency */
foreach ($currencies as $currency) { foreach ($currencies as $currency) {
@@ -104,7 +105,7 @@ class WholePeriodChartGenerator
$chartData[$spentInfoKey]['entries'][$label] = app('steam')->bcround($spentAmount, $currency['currency_decimal_places']); $chartData[$spentInfoKey]['entries'][$label] = app('steam')->bcround($spentAmount, $currency['currency_decimal_places']);
$chartData[$earnedInfoKey]['entries'][$label] = app('steam')->bcround($earnedAmount, $currency['currency_decimal_places']); $chartData[$earnedInfoKey]['entries'][$label] = app('steam')->bcround($earnedAmount, $currency['currency_decimal_places']);
} }
$current = app('navigation')->addPeriod($current, $step); $current = Navigation::addPeriod($current, $step);
} }
return $chartData; return $chartData;

View File

@@ -107,7 +107,7 @@ trait AccountFilter
} }
if (0 === count($return)) { if (0 === count($return)) {
$return = $this->types['normal']; return $this->types['normal'];
} }
return $return; return $return;

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Http\Controllers; namespace FireflyIII\Support\Http\Controllers;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
/** /**
@@ -93,18 +94,18 @@ trait DateCalculation
$loop = []; $loop = [];
/** @var Carbon $current */ /** @var Carbon $current */
$current = app('navigation')->startOfPeriod($date, $range); $current = Navigation::startOfPeriod($date, $range);
$current = app('navigation')->endOfPeriod($current, $range); $current = Navigation::endOfPeriod($current, $range);
$current->addDay(); $current->addDay();
$count = 0; $count = 0;
while ($count < 12) { while ($count < 12) {
$current = app('navigation')->endOfPeriod($current, $range); $current = Navigation::endOfPeriod($current, $range);
$currentStart = app('navigation')->startOfPeriod($current, $range); $currentStart = Navigation::startOfPeriod($current, $range);
$loop[] = [ $loop[] = [
'label' => $current->format('Y-m-d'), 'label' => $current->format('Y-m-d'),
'title' => app('navigation')->periodShow($current, $range), 'title' => Navigation::periodShow($current, $range),
'start' => clone $currentStart, 'start' => clone $currentStart,
'end' => clone $current, 'end' => clone $current,
]; ];
@@ -125,15 +126,15 @@ trait DateCalculation
$loop = []; $loop = [];
/** @var Carbon $current */ /** @var Carbon $current */
$current = app('navigation')->startOfPeriod($date, $range); $current = Navigation::startOfPeriod($date, $range);
$count = 0; $count = 0;
while ($count < 12) { while ($count < 12) {
$current->subDay(); $current->subDay();
$current = app('navigation')->startOfPeriod($current, $range); $current = Navigation::startOfPeriod($current, $range);
$currentEnd = app('navigation')->endOfPeriod($current, $range); $currentEnd = Navigation::endOfPeriod($current, $range);
$loop[] = [ $loop[] = [
'label' => $current->format('Y-m-d'), 'label' => $current->format('Y-m-d'),
'title' => app('navigation')->periodShow($current, $range), 'title' => Navigation::periodShow($current, $range),
'start' => clone $current, 'start' => clone $current,
'end' => clone $currentEnd, 'end' => clone $currentEnd,
]; ];

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Http\Controllers; namespace FireflyIII\Support\Http\Controllers;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Facades\FireflyConfig; use FireflyIII\Support\Facades\FireflyConfig;
@@ -82,7 +83,7 @@ trait GetConfigurationData
*/ */
protected function getDateRangeConfig(): array // get configuration + get preferences. protected function getDateRangeConfig(): array // get configuration + get preferences.
{ {
$viewRange = app('navigation')->getViewRange(false); $viewRange = Navigation::getViewRange(false);
Log::debug(sprintf('dateRange: the view range is "%s"', $viewRange)); Log::debug(sprintf('dateRange: the view range is "%s"', $viewRange));
@@ -105,32 +106,32 @@ trait GetConfigurationData
// when current range is a custom range, add the current period as the next range. // when current range is a custom range, add the current period as the next range.
if ($isCustom) { if ($isCustom) {
$index = app('navigation')->periodShow($start, $viewRange); $index = Navigation::periodShow($start, $viewRange);
$customPeriodStart = app('navigation')->startOfPeriod($start, $viewRange); $customPeriodStart = Navigation::startOfPeriod($start, $viewRange);
$customPeriodEnd = app('navigation')->endOfPeriod($customPeriodStart, $viewRange); $customPeriodEnd = Navigation::endOfPeriod($customPeriodStart, $viewRange);
$ranges[$index] = [$customPeriodStart, $customPeriodEnd]; $ranges[$index] = [$customPeriodStart, $customPeriodEnd];
} }
// then add previous range and next range, but skip this for the lastX and YTD stuff. // then add previous range and next range, but skip this for the lastX and YTD stuff.
if (!in_array($viewRange, config('firefly.dynamic_date_ranges', []), true)) { if (!in_array($viewRange, config('firefly.dynamic_date_ranges', []), true)) {
$previousDate = app('navigation')->subtractPeriod($start, $viewRange); $previousDate = Navigation::subtractPeriod($start, $viewRange);
$index = app('navigation')->periodShow($previousDate, $viewRange); $index = Navigation::periodShow($previousDate, $viewRange);
$previousStart = app('navigation')->startOfPeriod($previousDate, $viewRange); $previousStart = Navigation::startOfPeriod($previousDate, $viewRange);
$previousEnd = app('navigation')->endOfPeriod($previousStart, $viewRange); $previousEnd = Navigation::endOfPeriod($previousStart, $viewRange);
$ranges[$index] = [$previousStart, $previousEnd]; $ranges[$index] = [$previousStart, $previousEnd];
$nextDate = app('navigation')->addPeriod($start, $viewRange); $nextDate = Navigation::addPeriod($start, $viewRange);
$index = app('navigation')->periodShow($nextDate, $viewRange); $index = Navigation::periodShow($nextDate, $viewRange);
$nextStart = app('navigation')->startOfPeriod($nextDate, $viewRange); $nextStart = Navigation::startOfPeriod($nextDate, $viewRange);
$nextEnd = app('navigation')->endOfPeriod($nextStart, $viewRange); $nextEnd = Navigation::endOfPeriod($nextStart, $viewRange);
$ranges[$index] = [$nextStart, $nextEnd]; $ranges[$index] = [$nextStart, $nextEnd];
} }
// today: // today:
/** @var Carbon $todayStart */ /** @var Carbon $todayStart */
$todayStart = app('navigation')->startOfPeriod($today, $viewRange); $todayStart = Navigation::startOfPeriod($today, $viewRange);
/** @var Carbon $todayEnd */ /** @var Carbon $todayEnd */
$todayEnd = app('navigation')->endOfPeriod($todayStart, $viewRange); $todayEnd = Navigation::endOfPeriod($todayStart, $viewRange);
if ($todayStart->ne($start) || $todayEnd->ne($end)) { if ($todayStart->ne($start) || $todayEnd->ne($end)) {
$ranges[ucfirst((string)trans('firefly.today'))] = [$todayStart, $todayEnd]; $ranges[ucfirst((string)trans('firefly.today'))] = [$todayStart, $todayEnd];

View File

@@ -69,7 +69,6 @@ class RecurringEnrichment implements EnrichmentInterface
private string $language = 'en_US'; private string $language = 'en_US';
private array $notes = []; private array $notes = [];
private readonly TransactionCurrency $primaryCurrency; private readonly TransactionCurrency $primaryCurrency;
private array $recurrenceIds = [];
private array $recurrenceByTransaction = []; private array $recurrenceByTransaction = [];
private array $repetitions = []; private array $repetitions = [];
private array $sourceAccountIds = []; private array $sourceAccountIds = [];

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support\Models; namespace FireflyIII\Support\Models;
use FireflyIII\Support\Facades\Navigation;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
@@ -49,7 +50,7 @@ class BillDateCalculator
Log::debug(sprintf('Dates must be between %s and %s.', $earliest->format('Y-m-d'), $latest->format('Y-m-d'))); Log::debug(sprintf('Dates must be between %s and %s.', $earliest->format('Y-m-d'), $latest->format('Y-m-d')));
Log::debug(sprintf('Bill started on %s, period is "%s", skip is %d, last paid = "%s".', $billStart->format('Y-m-d'), $period, $skip, $lastPaid?->format('Y-m-d'))); Log::debug(sprintf('Bill started on %s, period is "%s", skip is %d, last paid = "%s".', $billStart->format('Y-m-d'), $period, $skip, $lastPaid?->format('Y-m-d')));
$daysUntilEOM = app('navigation')->daysUntilEndOfMonth($billStart); $daysUntilEOM = Navigation::daysUntilEndOfMonth($billStart);
Log::debug(sprintf('For bill start, days until end of month is %d', $daysUntilEOM)); Log::debug(sprintf('For bill start, days until end of month is %d', $daysUntilEOM));
$set = new Collection(); $set = new Collection();
@@ -94,7 +95,7 @@ class BillDateCalculator
// the next expected month because that month has only 28 days (i.e. february). // the next expected month because that month has only 28 days (i.e. february).
// this applies to leap years as well. // this applies to leap years as well.
if ($daysUntilEOM < 4) { if ($daysUntilEOM < 4) {
$nextUntilEOM = app('navigation')->daysUntilEndOfMonth($nextExpectedMatch); $nextUntilEOM = Navigation::daysUntilEndOfMonth($nextExpectedMatch);
$diffEOM = $daysUntilEOM - $nextUntilEOM; $diffEOM = $daysUntilEOM - $nextUntilEOM;
if ($diffEOM > 0) { if ($diffEOM > 0) {
Log::debug(sprintf('Bill start is %d days from the end of the month. nextExceptedMatch is %d days from the end of the month.', $daysUntilEOM, $nextUntilEOM)); Log::debug(sprintf('Bill start is %d days from the end of the month. nextExceptedMatch is %d days from the end of the month.', $daysUntilEOM, $nextUntilEOM));
@@ -140,7 +141,7 @@ class BillDateCalculator
return $billStartDate; return $billStartDate;
} }
$steps = app('navigation')->diffInPeriods($period, $skip, $earliest, $billStartDate); $steps = Navigation::diffInPeriods($period, $skip, $earliest, $billStartDate);
if ($steps === $this->diffInMonths) { if ($steps === $this->diffInMonths) {
Log::debug(sprintf('Steps is %d, which is the same as diffInMonths (%d), so we add another 1.', $steps, $this->diffInMonths)); Log::debug(sprintf('Steps is %d, which is the same as diffInMonths (%d), so we add another 1.', $steps, $this->diffInMonths));
++$steps; ++$steps;
@@ -150,7 +151,7 @@ class BillDateCalculator
if ($steps > 0) { if ($steps > 0) {
--$steps; --$steps;
Log::debug(sprintf('Steps is %d, because addPeriod already adds 1.', $steps)); Log::debug(sprintf('Steps is %d, because addPeriod already adds 1.', $steps));
$result = app('navigation')->addPeriod($billStartDate, $period, $steps); $result = Navigation::addPeriod($billStartDate, $period, $steps);
} }
Log::debug(sprintf('Number of steps is %d, added to %s, result is %s', $steps, $billStartDate->format('Y-m-d'), $result->format('Y-m-d'))); Log::debug(sprintf('Number of steps is %d, added to %s, result is %s', $steps, $billStartDate->format('Y-m-d'), $result->format('Y-m-d')));

View File

@@ -121,8 +121,8 @@ class Navigation
if ($workEnd->gt($start)) { if ($workEnd->gt($start)) {
while ($workEnd->gt($start) && $loopCount < 20) { while ($workEnd->gt($start) && $loopCount < 20) {
// make range: // make range:
$workStart = app('navigation')->startOfPeriod($workStart, '1Y'); $workStart = \FireflyIII\Support\Facades\Navigation::startOfPeriod($workStart, '1Y');
$workEnd = app('navigation')->endOfPeriod($workStart, '1Y'); $workEnd = \FireflyIII\Support\Facades\Navigation::endOfPeriod($workStart, '1Y');
// make sure we don't go overboard // make sure we don't go overboard
if ($workEnd->gt($start)) { if ($workEnd->gt($start)) {