Q: Why do mountain climbers rope themselves together?

A:	To prevent the sensible ones from going home.
This commit is contained in:
Sebastien Castiel
2024-10-25 15:02:31 -04:00
parent 9bdc8a715c
commit c1c75fa260
29 changed files with 73 additions and 96 deletions

View File

@@ -1,4 +1,4 @@
import { getGroupExpenses } from '@/lib/api'
import { getGroupExpenses } from './api'
export function getTotalGroupSpending(
expenses: NonNullable<Awaited<ReturnType<typeof getGroupExpenses>>>,
@@ -55,14 +55,15 @@ export function getTotalActiveUserShare(
// Calculate the user's share based on their percentage of the total expense
total += (expense.amount * userPaidFor.shares) / 10000 // Assuming shares are out of 10000 for percentage
break
case 'BY_SHARES':
// Calculate the user's share based on their shares relative to the total shares
case 'BY_SHARES': // Calculate the user's share based on their shares relative to the total shares
{
const totalShares = paidFors.reduce(
(sum, paidFor) => sum + paidFor.shares,
0,
)
total += (expense.amount * userPaidFor.shares) / totalShares
break
}
}
})