From 62a1837d61520a78e3bcb6e2902496692714e9d3 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 19 May 2023 05:38:50 +0200 Subject: [PATCH 1/3] fix: debug would always report midnight. --- app/Http/Controllers/DebugController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php index 1cb72fa4ed..8f7bf846f5 100644 --- a/app/Http/Controllers/DebugController.php +++ b/app/Http/Controllers/DebugController.php @@ -118,7 +118,7 @@ class DebugController extends Controller public function index(Request $request) { // basic scope information: - $now = today(config('app.timezone'))->format('Y-m-d H:i:s e'); + $now = now(config('app.timezone'))->format('Y-m-d H:i:s e'); $buildNr = '(unknown)'; $buildDate = '(unknown)'; $baseBuildNr = '(unknown)'; From c19b89ac932fb0c7bfe2ec34e3ddc4b84d9a1422 Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 19 May 2023 05:39:21 +0200 Subject: [PATCH 2/3] Fix: budget amounts --- app/Jobs/CreateAutoBudgetLimits.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Jobs/CreateAutoBudgetLimits.php b/app/Jobs/CreateAutoBudgetLimits.php index 9ac67dfa13..aed894218b 100644 --- a/app/Jobs/CreateAutoBudgetLimits.php +++ b/app/Jobs/CreateAutoBudgetLimits.php @@ -111,7 +111,7 @@ class CreateAutoBudgetLimits implements ShouldQueue if (null === $budgetLimit) { Log::debug('No budget limit exists in previous period, so create one.'); - // if not, create standard amount and we're done. + // if not, create standard amount, and we're done. $this->createBudgetLimit($autoBudget, $start, $end); return; } @@ -132,10 +132,11 @@ class CreateAutoBudgetLimits implements ShouldQueue $totalAmount = $autoBudget->amount; Log::debug(sprintf('Total amount available for current budget period is %s', $budgetAvailable)); + if (-1 !== bccomp($budgetAvailable, $totalAmount)) { - Log::info(sprintf('There is no overspending, no need to adjust. Budget limit amount will be %s.', $totalAmount)); + Log::info(sprintf('There is no overspending, no need to adjust. Budget limit amount will be %s.', $budgetAvailable)); // create budget limit: - $this->createBudgetLimit($autoBudget, $start, $end, $totalAmount); + $this->createBudgetLimit($autoBudget, $start, $end, $budgetAvailable); } if (1 !== bccomp($budgetAvailable, $totalAmount) && 1 === bccomp($budgetAvailable, '0')) { Log::info(sprintf('There was overspending, so the new amount will be %s.', $budgetAvailable)); From 79c206547141b8482a2309f5f00ff466cd05f95d Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 19 May 2023 05:43:50 +0200 Subject: [PATCH 3/3] fix: Add relevant periods to addPeriod --- app/Support/Navigation.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 5292a430d9..cb55fb25f1 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -65,6 +65,14 @@ class Navigation 'yearly' => 'addYears', '1Y' => 'addYears', 'custom' => 'addMonths', // custom? just add one month. + // last X periods? Jump the relevant month / quarter / year + 'last7' => 'addDays', + 'last30' => 'addMonths', + 'last90' => 'addMonths', + 'last365' => 'addYears', + 'MTD' => 'addMonths', + 'QTD' => 'addMonths', + 'YTD' => 'addYears', ]; $modifierMap = [ 'quarter' => 3, @@ -72,6 +80,9 @@ class Navigation 'quarterly' => 3, '6M' => 6, 'half-year' => 6, + 'last7' => 7, + 'last90' => 3, + 'QTD' => 3, ]; if (!array_key_exists($repeatFreq, $functionMap)) {