diff options
| author | Sebastien Castiel <sebastien@castiel.me> | 2024-02-29 10:21:23 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-29 10:21:23 -0500 |
| commit | 552953151ad691e708977c8bc02ea7a8621cdef3 (patch) | |
| tree | b70645edee9ab51a010f859da0ed56ffe49825be /src/lib/totals.ts | |
| parent | b227401dd6359b29bb9b21660bcdebdb11805c59 (diff) | |
Diffstat (limited to 'src/lib/totals.ts')
| -rw-r--r-- | src/lib/totals.ts | 8 |
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, |
