This commit is contained in:
Mateusz Gruszczyński
2026-04-07 10:06:48 +02:00
parent deaa6dfe43
commit ca9c78d88d
36 changed files with 1801 additions and 503 deletions

View File

@@ -113,7 +113,13 @@ const currentMonthKey = () => {
return `${date.getFullYear()}-${`${date.getMonth() + 1}`.padStart(2, '0')}`;
};
const monthRange = (monthKey: string) => ({ startDate: `${monthKey}-01`, endDate: `${monthKey}-31` });
const monthRange = (monthKey: string) => {
const [yearText, monthText] = monthKey.split('-');
const year = Number(yearText);
const month = Number(monthText);
const lastDay = new Date(year, month, 0).getDate();
return { startDate: `${monthKey}-01`, endDate: `${monthKey}-${String(lastDay).padStart(2, '0')}` };
};
export const getCashflowSummary = async (userId: string) => {
const expenseRepo = AppDataSource.getRepository(Expense);