Added a new API endpiont
...api/v1/expense-groups/{expenseGroupId}/balances
Returns Balances for a certain ExpenseGroup, including some extra data
Postman Collection updated (server/test folder)
Note:
By now, is assuming that all expenses will be equally divided.
Also, is assuming that the user that created the Expense is the one that paid it (needs to be refactored)
To be discussed:
The expense should have a reference to a participant. And these Balances should be grouped by this new "participantId" instead of by "createdBy" (the current behavior, after this PR). A user can create an expense paid by another user.
Added a new API endpiont ...api/v1/expense-groups/{expenseGroupId}/balances
Returns Balances for a certain ExpenseGroup, including some extra data
Postman Collection updated (server/test folder)
Note: By now, is assuming that all expenses will be equally divided. Also, is assuming that the user that created the Expense is the one that paid it (needs to be refactored) To be discussed: The expense should have a reference to a participant. And these Balances should be grouped by this new "participantId" instead of by "createdBy" (the current behavior, after this PR). A user can create an expense paid by another user.
This is a sample of returned data:
{ "expenseGroupId": 40, "totalExpenses": 1250, "numOfParticipants": 4, "individualContribution": 312.5, "totalExpensesByUser": { "1": 100, "2": 150, "3": 200, "5": 800 }, "balances": [ { "userId": 1, "userName": "Attila Ádám Honvédő", "userEmail": "adam.honvedo@gmail.com", "amountPaid": 100, "balance": -212.5 }, { "userId": 2, "userName": "Ádám Honvédő", "userEmail": "honvedoadamkj@gmail.com", "amountPaid": 150, "balance": -162.5 }, { "userId": 3, "userName": "", "userEmail": "newusername@test.com", "amountPaid": 200, "balance": -112.5 }, { "userId": 5, "userName": "User #1", "userEmail": "user0001@gmail.com", "amountPaid": 800, "balance": 487.5 } ] }