Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-fidd committed Feb 21, 2025
1 parent 30b4f11 commit 4c9cf92
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,9 @@ function calculatePerMonth(
amount: monthlyData[d.format(m, 'yyyy-MM')] || 0,
}));

const dayOfMonth = months.at(-1)!.getDate();
const daysInMonth = monthUtils.getDay(
monthUtils.lastDayOfMonth(months.at(-1)!),
);
const lastMonth = months.at(-1)!;
const dayOfMonth = lastMonth.getDate();
const daysInMonth = monthUtils.getDay(monthUtils.lastDayOfMonth(lastMonth));
const numMonths = months.length - 1 + dayOfMonth / daysInMonth;

const totalAmount = monthsSum.reduce((sum, month) => sum + month.amount, 0);
Expand Down

0 comments on commit 4c9cf92

Please sign in to comment.