implementation of the revenue sharing model #2
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "dachary/accountant:wip-share"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
Signed-off-by: Loïc Dachary loic@dachary.org
Can confirm this is implemented according to specification.
@ -0,0 +9,4 @@
# See https://forum.hostea.org/t/decision-revenue-sharing-model/92
#
def share_income(income, members):
if income <= 0:
Add a comment:
Your suggestions inspired me to extensively comment on the function and the implementation.
@ -0,0 +11,4 @@
def share_income(income, members):
if income <= 0:
return members
if income < len(members):
Just to simplify the case for
income == len(members)
, you could doincome <= len(members)
done
@ -0,0 +15,4 @@
share = 1
count = income
else:
share = min(int(income / len(members)), min(members, key=lambda m: m[EXPENSE])[EXPENSE])
@ -0,0 +18,4 @@
share = min(int(income / len(members)), min(members, key=lambda m: m[EXPENSE])[EXPENSE])
count = len(members)
remaining = []
for i in range(count):
0c24ce9ac6
toba9f610c61
@Gusted I'm glad you enjoyed the implementation :-) Since it is a terminal recursion it could be a loop but it would make it a little bit less elegant.
instead of
You will end up with a big loop as you would need to handle the edge-cases already being checked for in the first few lines. The recusion seems better for now
ba9f610c61
to332efe15d0
LGTM. Ran tests locally, must configure CI if we are going to co-dev this tool :)