From a3226ed998483846df8d9b2cef3a89e5332d5189 Mon Sep 17 00:00:00 2001 From: Sugan Krishnan Date: Tue, 4 Jun 2024 06:32:48 +0530 Subject: [PATCH] Fix monthly expense timeline issue (#242) * Fix month issue * Move the startOfMonth outside the loop --- src/lib/utils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index bf488a42..39243f30 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -965,7 +965,7 @@ export function forEachMonth( end: dayjs.Dayjs, cb: (current: dayjs.Dayjs) => any ) { - let current = start; + let current = start.startOf("month"); while (current.isSameOrBefore(end, "month")) { cb(current); current = current.add(1, "month"); @@ -989,7 +989,7 @@ export function forEachFinancialYear( end: dayjs.Dayjs, cb?: (current: dayjs.Dayjs) => any ) { - let current = begingingOfFinancialYear(start); + let current = beginningOfFinancialYear(start); const years: dayjs.Dayjs[] = []; while (current.isSameOrBefore(end, "month")) { if (cb) { @@ -1001,7 +1001,7 @@ export function forEachFinancialYear( return years; } -function begingingOfFinancialYear(date: dayjs.Dayjs) { +function beginningOfFinancialYear(date: dayjs.Dayjs) { date = date.startOf("month"); if (date.month() + 1 < USER_CONFIG.financial_year_starting_month) { return date