This commit is contained in:
@@ -2445,7 +2445,12 @@ export function DashboardShell({
|
|||||||
}}
|
}}
|
||||||
required
|
required
|
||||||
fullWidth
|
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) => (
|
{expenseCutoffOptions.map((option) => (
|
||||||
<MenuItem key={option.value} value={option.value}>
|
<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 expenseById = new Map(allExpenses.map((expense) => [expense.id, expense]));
|
||||||
const rows = expenseCutoffOptions.map((option) => {
|
const rows = expenseCutoffOptions.map((option) => {
|
||||||
const expenses = allExpenses.filter(
|
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) => {
|
const donationsForSection = donations.filter((donation) => {
|
||||||
if (donation.expenseId) {
|
if (donation.expenseId) {
|
||||||
const expense = expenseById.get(donation.expenseId);
|
const expense = expenseById.get(donation.expenseId);
|
||||||
|
if (expense?.recurrence === "MONTHLY") {
|
||||||
|
return getGeneralDonationCutoffSelectionValue(currentCutoffs, donation.donatedAt) === option.value;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
expense?.cutoffId === option.cutoffId &&
|
expense?.cutoffId === option.cutoffId &&
|
||||||
expense.cutoffPhase === option.cutoffPhase
|
expense.cutoffPhase === option.cutoffPhase
|
||||||
@@ -3732,12 +3755,19 @@ export function DashboardShell({
|
|||||||
planned: expenses.reduce(
|
planned: expenses.reduce(
|
||||||
(sum, expense) => sum + (expense.approvalStatus === "PENDING" ? expense.netPeriodAmount : 0),
|
(sum, expense) => sum + (expense.approvalStatus === "PENDING" ? expense.netPeriodAmount : 0),
|
||||||
0
|
0
|
||||||
|
) + monthlyOccurrences.reduce(
|
||||||
|
(sum, occurrence) => sum + (occurrence.approvalStatus === "PENDING" ? occurrence.amount : 0),
|
||||||
|
0
|
||||||
),
|
),
|
||||||
approved: expenses.reduce(
|
approved: expenses.reduce(
|
||||||
(sum, expense) => sum + (expense.approvalStatus === "APPROVED" ? expense.netPeriodAmount : 0),
|
(sum, expense) => sum + (expense.approvalStatus === "APPROVED" ? expense.netPeriodAmount : 0),
|
||||||
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)
|
donations: donationsForSection.reduce((sum, donation) => sum + donation.amount, 0)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user