aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/totals.ts8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/totals.ts b/src/lib/totals.ts
index 797318c..6d5e794 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,