feat(dashboard): add pending/upcoming expenses table

- Backend: GET /expenses/pending-upcoming returns PENDING expenses with dueDate <= today+5 days, classified as overdue/upcoming
- DashboardExpensesTable: groups by periodicExpenseId, shows summed totals with status badges, links to /expenses?periodicExpenseId=X
- Expenses route accepts ?periodicExpenseId search param and pre-selects it in the filter
- fix: BeloAnalysisPage DatePicker type mismatch
This commit is contained in:
Jose Selesan
2026-06-04 10:34:34 -03:00
parent 33248401f7
commit 53a797703e
12 changed files with 269 additions and 5 deletions

View File

@@ -216,6 +216,27 @@ export async function getTotalPending() {
return data;
}
export async function listPendingUpcomingExpenses() {
const now = new Date();
const today = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), 0, 0, 0, 0));
const fiveDaysLater = new Date(today);
fiveDaysLater.setUTCDate(fiveDaysLater.getUTCDate() + 5);
const data = await prisma.expense.findMany({
where: {
status: PaymentStatus.PENDING,
dueDate: { lte: fiveDaysLater },
},
include: { periodicExpense: true },
orderBy: { dueDate: "asc" },
});
return data.map((expense) => ({
...expense,
dueType: expense.dueDate < today ? "overdue" as const : "upcoming" as const,
}));
}
export async function generateExpensesForCurrentMonth() {
const { year, month } = getCurrentYearMonthUTC();