aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSebastien Castiel <sebastien@castiel.me>2024-02-29 10:21:23 -0500
committerGitHub <noreply@github.com>2024-02-29 10:21:23 -0500
commit552953151ad691e708977c8bc02ea7a8621cdef3 (patch)
treeb70645edee9ab51a010f859da0ed56ffe49825be /src
parentb227401dd6359b29bb9b21660bcdebdb11805c59 (diff)
Don’t count reimbursements in stats (fixes #118) (#119)HEADmain
Diffstat (limited to 'src')
-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,