Closed dbarashev-jetbrains closed 1 month ago
@DanLyss @whylot this is the second task for the first phase
Is currency fixed inside the records list, or it may differs from one record to another?
@DanLyss for now you may think that the currency is the same, however, it would be nice to be able to add currency conversion in the future without any significant changes in the code
Suppose that we have a list of ExpenseItem objects from issue #3. Now, we need to process it and build a summary of how much money every event participant owes other participants. For instance, if we have three records:
then
paul
owesjohn
30/3 + 60/2 = 40 USD,mick
owes 30/3 =10 USD tojohn
and 20/2=10 USD tojose
, andjohn
owesjose
5 USD.john
expects to receive 50 USD from his friends, andjose
expects 15 USD.The task is:
DebtSummary
, built from tuples, lists, dicts and atomic types, that would allow for storing the person's debts. It must store the following data:john
john
's balance is 45, because he owes 5 and other participants owe him 50.buildDebtSummaries(records: list[ExpenseItem]): list[DebtSummary]
that builds the debt summaries.Please write unit tests, make sure that they are passing (it is also a good idea to see them failing at least once), create a pull request with the changes, assign @dbarashev-jetbrains as a reviewer and wait until the end of the code review.