Skip to content

Commit

Permalink
Fix monthly expense timeline issue (#242)
Browse files Browse the repository at this point in the history
* Fix month issue

* Move the startOfMonth outside the loop
  • Loading branch information
rgksugan authored Jun 4, 2024
1 parent 7bb0a9b commit a3226ed
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit a3226ed

Please sign in to comment.