Monatsabos automatisch Stichtagen zuordnen
CI / Build and Deploy (push) Successful in 2m39s

This commit is contained in:
jan
2026-05-27 15:58:24 +02:00
parent 1209265b01
commit 78692338f7
+33 -3
View File
@@ -2445,7 +2445,12 @@ export function DashboardShell({
}}
required
fullWidth
disabled={expenseCutoffOptions.length === 0}
disabled={expenseCutoffOptions.length === 0 || expenseForm.recurrence === "MONTHLY"}
helperText={
expenseForm.recurrence === "MONTHLY"
? "Monatliche Abos werden anhand ihrer Fälligkeit automatisch den Stichtagen zugeordnet."
: undefined
}
>
{expenseCutoffOptions.map((option) => (
<MenuItem key={option.value} value={option.value}>
@@ -3713,11 +3718,29 @@ export function DashboardShell({
const expenseById = new Map(allExpenses.map((expense) => [expense.id, expense]));
const rows = expenseCutoffOptions.map((option) => {
const expenses = allExpenses.filter(
(expense) => expense.cutoffId === option.cutoffId && expense.cutoffPhase === option.cutoffPhase
(expense) =>
expense.recurrence !== "MONTHLY" &&
expense.cutoffId === option.cutoffId &&
expense.cutoffPhase === option.cutoffPhase
);
const monthlyOccurrences = allExpenses.flatMap((expense) =>
expense.recurrence === "MONTHLY"
? expense.occurrences
.filter((occurrence) => getGeneralDonationCutoffSelectionValue(currentCutoffs, occurrence.dueAt) === option.value)
.map((occurrence) => ({
amount: occurrence.amount,
approvalStatus: expense.approvalStatus,
paidAt: expense.paidAt
}))
: []
);
const donationsForSection = donations.filter((donation) => {
if (donation.expenseId) {
const expense = expenseById.get(donation.expenseId);
if (expense?.recurrence === "MONTHLY") {
return getGeneralDonationCutoffSelectionValue(currentCutoffs, donation.donatedAt) === option.value;
}
return (
expense?.cutoffId === option.cutoffId &&
expense.cutoffPhase === option.cutoffPhase
@@ -3732,12 +3755,19 @@ export function DashboardShell({
planned: expenses.reduce(
(sum, expense) => sum + (expense.approvalStatus === "PENDING" ? expense.netPeriodAmount : 0),
0
) + monthlyOccurrences.reduce(
(sum, occurrence) => sum + (occurrence.approvalStatus === "PENDING" ? occurrence.amount : 0),
0
),
approved: expenses.reduce(
(sum, expense) => sum + (expense.approvalStatus === "APPROVED" ? expense.netPeriodAmount : 0),
0
) + monthlyOccurrences.reduce(
(sum, occurrence) => sum + (occurrence.approvalStatus === "APPROVED" ? occurrence.amount : 0),
0
),
paid: expenses.reduce((sum, expense) => sum + (expense.paidAt ? expense.netPeriodAmount : 0), 0),
paid: expenses.reduce((sum, expense) => sum + (expense.paidAt ? expense.netPeriodAmount : 0), 0) +
monthlyOccurrences.reduce((sum, occurrence) => sum + (occurrence.paidAt ? occurrence.amount : 0), 0),
donations: donationsForSection.reduce((sum, donation) => sum + donation.amount, 0)
};
});