complete implementation of the revenue sharing model #3

Merged
dachary merged 1 commits from dachary/accountant:wip-share into master 4 months ago
Owner

See the leading comment for a detailed explanation.

Signed-off-by: Loïc Dachary loic@dachary.org

See the leading comment for a detailed explanation. Signed-off-by: Loïc Dachary <loic@dachary.org>
dachary added 1 commit 4 months ago
dc796278a6
complete implementation of the revenue sharing model
dachary requested review from Gusted 4 months ago
dachary requested review from realaravinth 4 months ago
Gusted reviewed 4 months ago
members = [["a", 10, 5], ["b", 450, 25], ["c", 0, 0]]
payable, payments = share_income(members)
assert payable == [["a", 10, 5], ["b", 20, 25]]
assert payments == {"a": [("b", 5)]}
Owner

Why does a give their whole income to b, who already has an income of 25?

Why does `a` give their whole income to `b`, who already has an income of 25?
Poster
Owner

It's the other way around :-) "a" receives 5 from "b".

It's the other way around :-) "a" receives 5 from "b".
Owner

Aha okay, might have missed the comments that specified the structure 😅

Aha okay, might have missed the comments that specified the structure :sweat_smile:
dachary marked this conversation as resolved
dachary reviewed 4 months ago
# For instance in the if the 'members' argument is [['isabelle', 200, 10]], the
# shares will be [['isabelle', 10, 10]] where the 200 expense was reduced to a
# share of 10 because there only is 10 income available.
#
Poster
Owner

The comment explaining the structure is here @gusted.

The comment explaining the structure is here @gusted.
Owner

It doesn't mention the result structure which is member: getting paid by and how much

It doesn't mention the result structure which is `member: getting paid by and how much`
Poster
Owner

Right: I meant what is below these lines... but it only shows the above. I'll try again.

Right: I meant what is below these lines... but it only shows the above. I'll try again.
dachary marked this conversation as resolved
dachary reviewed 4 months ago
# 'marie': [('isabelle', 200), ('john', 50)],
# 'lucie': [('john', 10)],
# }
#
Poster
Owner

The comment explaining the structure is here @gusted.

# The 'payments' maps member IDs to the amount other peer members must be invoiced:
#
#  {
#    ID: [(ID, integer), (ID, integer), ...],
#    ...
#  }
#
# For instance in the following marie will invoice isable for 200
# and john for 50 while lucie will invoice john for 10:
#
#  {
#    'marie': [('isabelle', 200), ('john', 50)],
#    'lucie': [('john', 10)],
#  }
#
The comment explaining the structure is here @gusted. ``` # The 'payments' maps member IDs to the amount other peer members must be invoiced: # # { # ID: [(ID, integer), (ID, integer), ...], # ... # } # # For instance in the following marie will invoice isable for 200 # and john for 50 while lucie will invoice john for 10: # # { # 'marie': [('isabelle', 200), ('john', 50)], # 'lucie': [('john', 10)], # } # ```
Gusted marked this conversation as resolved
Gusted approved these changes 4 months ago
Gusted left a comment
Owner

Looks according to spec!

Looks according to spec!
dachary merged commit e817380e42 into master 4 months ago

Reviewers

realaravinth was requested for review 4 months ago
Gusted approved these changes 4 months ago
The pull request has been merged as e817380e42.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: Hostea/accountant#3
Loading…
There is no content yet.