Skip to content

Commit

Permalink
bypass rounding errors of zero-decimal currencies
Browse files Browse the repository at this point in the history
fixes LIBERAPAYCOM-28J
  • Loading branch information
Changaco committed Jan 8, 2025
1 parent a8f649e commit 5409335
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions liberapay/billing/payday.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,9 @@ def resolve_takes(tips, takes, ref_currency, payday_id):
if tip_amount == 0:
continue
assert tip_amount > 0
assert tip_amount <= tip.full_amount
tip.amount = tip_amount
else:
tip.amount = (tip.funded_amount * tips_ratio).round_up()
tip_amount = (tip.funded_amount * tips_ratio).round_up()
tip.amount = min(tip_amount, tip.funded_amount)
sorted_takes = chain(
takes_by_preferred_currency.get(tip_currency, ()),
takes_by_secondary_currency.get(tip_currency, ()),
Expand Down Expand Up @@ -540,6 +539,7 @@ def resolve_takes(tips, takes, ref_currency, payday_id):
# members who have now left the team or have zeroed takes.
transfers = list(transfers.values())
leftover = total_income - MoneyBasket(t.amount for t in transfers)
assert leftover >= 0
if leftover and leftover_takes:
leftover_takes.sort(key=lambda t: t.member)
leftover_takes_fuzzy_sum = MoneyBasket(
Expand Down

0 comments on commit 5409335

Please sign in to comment.