Monatsauswahl und Spendenbearbeitung ergaenzen
All checks were successful
CI / Build and Deploy (push) Successful in 3m26s
All checks were successful
CI / Build and Deploy (push) Successful in 3m26s
This commit is contained in:
@@ -178,12 +178,17 @@ export default async function DashboardPage() {
|
||||
const periodCutoffById = new Map(periodCutoffs.map((period) => [period.id, period]));
|
||||
const expenseCutoffById = new Map(expenseCutoffs.map((expense) => [expense.id, expense.cutoff_phase]));
|
||||
const donationsByExpenseId = new Map<string, number>();
|
||||
const donationRowsByExpenseId = new Map<string, typeof donationRows>();
|
||||
for (const donation of donationRows) {
|
||||
if (donation.expense_id) {
|
||||
donationsByExpenseId.set(
|
||||
donation.expense_id,
|
||||
(donationsByExpenseId.get(donation.expense_id) ?? 0) + Number(donation.amount)
|
||||
);
|
||||
donationRowsByExpenseId.set(donation.expense_id, [
|
||||
...(donationRowsByExpenseId.get(donation.expense_id) ?? []),
|
||||
donation
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,6 +250,13 @@ export default async function DashboardPage() {
|
||||
recurrenceStartAt,
|
||||
cutoffPhase: expenseCutoffById.get(expense.id) ?? "PRE",
|
||||
donationAmount: donationsByExpenseId.get(expense.id) ?? 0,
|
||||
donations: (donationRowsByExpenseId.get(expense.id) ?? []).map((donation) => ({
|
||||
id: donation.id,
|
||||
title: donation.title,
|
||||
description: donation.description,
|
||||
amount: Number(donation.amount),
|
||||
donatedAt: donation.donated_at.toISOString()
|
||||
})),
|
||||
netPeriodAmount: Math.max(
|
||||
0,
|
||||
getExpensePeriodAmount(amount, expense.recurrence, occurrences.length) -
|
||||
|
||||
Reference in New Issue
Block a user