feat(expenses): add import functionality for expenses and total pending calculation
This commit is contained in:
@@ -39,7 +39,7 @@ export function getCurrentYearMonthUTC(): { year: number; month: number } {
|
||||
export async function listPeriodicExpenses() {
|
||||
return prisma.periodicExpense.findMany({
|
||||
where: { isDeleted: false },
|
||||
orderBy: { createdAt: "desc" },
|
||||
orderBy: { description: "asc" },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -163,6 +163,15 @@ export async function getMonthlyTotals(year: number, month: number) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function getTotalPending() {
|
||||
const expenses = await prisma.expense.findMany({
|
||||
where: { status: PaymentStatus.PENDING },
|
||||
select: { amount: true },
|
||||
});
|
||||
const total = expenses.reduce((sum, e) => sum + Number(e.amount), 0);
|
||||
return { total };
|
||||
}
|
||||
|
||||
export async function generateExpensesForCurrentMonth() {
|
||||
const { year, month } = getCurrentYearMonthUTC();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user