From fa16a60d24fb84715da0ebf5488993a8082c8039 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Thu, 24 Sep 2026 20:59:44 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20show=20total=20expense=20amount=20a?= =?UTF-8?q?nd=20your=20part?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/ExpenseList.vue | 43 +++++++++++++++++++++++++++++++++ app/pages/p/[slug]/expenses.vue | 1 + i18n/locales/de.json | 2 ++ i18n/locales/en.json | 2 ++ 4 files changed, 48 insertions(+) diff --git a/app/components/ExpenseList.vue b/app/components/ExpenseList.vue index 9772e9e..0466d74 100644 --- a/app/components/ExpenseList.vue +++ b/app/components/ExpenseList.vue @@ -5,6 +5,7 @@ const props = defineProps<{ expenses: ExpenseView[]; participants: ParticipantView[]; currency: string; + currentParticipantId?: number; }>(); const emit = defineEmits<{ @@ -37,10 +38,52 @@ function toggle(id: number) { const sorted = computed(() => [...props.expenses].sort((a, b) => b.createdAt - a.createdAt), ); + +const totalExpensesCents = computed(() => + props.expenses + .filter((expense) => expense.type === 'expense') + .reduce((sum, expense) => sum + expense.amountCents, 0), +); + +const myExpensesCents = computed(() => { + const myId = props.currentParticipantId; + if (myId === undefined) return 0; + return props.expenses + .filter( + (expense) => + expense.type === 'expense' && expense.participantIds.includes(myId), + ) + .reduce((sum, expense) => { + const shares = computeSplit(expense.amountCents, expense.participantIds); + return sum + (shares[myId] ?? 0); + }, 0); +});