From 552953151ad691e708977c8bc02ea7a8621cdef3 Mon Sep 17 00:00:00 2001 From: Sebastien Castiel Date: Thu, 29 Feb 2024 10:21:23 -0500 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20count=20reimbursements=20in=20s?= =?UTF-8?q?tats=20(fixes=20#118)=20(#119)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/totals.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/totals.ts b/src/lib/totals.ts index 797318c8..6d5e794a 100644 --- a/src/lib/totals.ts +++ b/src/lib/totals.ts @@ -5,7 +5,7 @@ export function getTotalGroupSpending( ): number { return expenses.reduce( (total, expense) => - !expense.isReimbursement ? total + expense.amount : total + 0, + expense.isReimbursement ? total : total + expense.amount, 0, ) } @@ -16,7 +16,9 @@ export function getTotalActiveUserPaidFor( ): number { return expenses.reduce( (total, expense) => - expense.paidBy.id === activeUserId ? total + expense.amount : total + 0, + expense.paidBy.id === activeUserId && !expense.isReimbursement + ? total + expense.amount + : total, 0, ) } @@ -28,6 +30,8 @@ export function getTotalActiveUserShare( let total = 0 expenses.forEach((expense) => { + if (expense.isReimbursement) return + const paidFors = expense.paidFor const userPaidFor = paidFors.find( (paidFor) => paidFor.participantId === activeUserId,