Skip to content

Commit

Permalink
handle case of no reward.
Browse files Browse the repository at this point in the history
version 5.2
  • Loading branch information
habanoz committed May 29, 2019
1 parent 9d0767f commit 6048f4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/calc/phased_payment_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from model.reward_log import TYPE_FOUNDERS_PARENT, TYPE_OWNERS_PARENT, cmp_by_type_balance
from pay.payment_consumer import logger

MINOR_DIFF = 6
MINOR_DIFF = 8
MINOR_RATIO_DIFF = 1e-6


Expand Down Expand Up @@ -72,11 +72,16 @@ def calculate(self, reward_provider_model):

founder_parent = next(filter(lambda x: x.type == TYPE_FOUNDERS_PARENT, rwrd_logs), None)

calculated_founder_rewards = sum([rl.ratio2 for rl in rwrd_logs if rl.skippedatphase == 3]) + sum(
[rl.service_fee_ratio for rl in rwrd_logs if not rl.skipped])
assert self.almost_equal(founder_parent.ratio3, calculated_founder_rewards)
calculated_founder_rewards = sum([rl.ratio2 for rl in rwrd_logs if rl.skippedatphase == 3]) + sum([rl.service_fee_ratio for rl in rwrd_logs if not rl.skipped])

if founder_parent:
assert self.almost_equal(founder_parent.ratio3, calculated_founder_rewards)
else:
assert self.almost_equal(0, calculated_founder_rewards)

owners_parent = next(filter(lambda x: x.type == TYPE_OWNERS_PARENT, rwrd_logs), None)
assert owners_parent.service_fee_rate == 0
if owners_parent:
assert owners_parent.service_fee_rate == 0

phase4 = CalculatePhase4(self.founders_map, self.owners_map)
rwrd_logs, total_rwrd_amnt = phase4.calculate(rwrd_logs, total_rwrd_amnt)
Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=5.1
version=5.2

0 comments on commit 6048f4c

Please sign in to comment.