Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Teach masspay.py to use new paypal_fee_cap field
Browse files Browse the repository at this point in the history
Rel. #1675
  • Loading branch information
chadwhitacre committed Apr 17, 2014
1 parent f17182a commit e1ef306
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions bin/masspay.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,17 @@ class Payee(object):
additional_note = ""

def __init__(self, rec):
self.username, self.email, amount = rec
self.username, self.email, fee_cap, amount = rec
self.gross = D(amount)
self.fee = D(0)
self.fee_cap = D(fee_cap)
self.net = self.gross

def assess_fee(self):
fee = self.gross - round_(self.gross / D('1.02')) # 2% fee
fee = min(fee, D('20.00')) # capped at $20
self.fee += fee # XXX or $1 for U.S. :/
self.net -= fee # XXX See #1675.
fee = min(fee, self.fee_cap) # capped at $20, or $1 for U.S.
self.fee += fee
self.net -= fee
if self.net % 1 == D('0.25'):

# Prevent an escrow leak. It's complicated, but it goes something
Expand Down Expand Up @@ -114,7 +115,8 @@ def compute_input_csv():
""")
writer = csv.writer(open(INPUT_CSV, 'w+'))
print_rule()
print("{:<24}{:<32} {:^7} {:^7} {:^7}".format("username", "email", "balance", "tips", "amount"))
headers = "username", "email", "fee cap", "balance", "tips", "amount"
print("{:<24}{:<32} {:^7} {:^7} {:^7} {:^7}".format(*headers))
print_rule()
total_gross = 0
for participant in participants:
Expand All @@ -125,13 +127,14 @@ def compute_input_csv():
# See https://github.com/gittip/www.gittip.com/issues/1958.
continue
total_gross += amount
print("{:<24}{:<32} {:>7} {:>7} {:>7}".format( participant.username
, participant.paypal_email
, participant.balance
, total
, amount
))
row = (participant.username, participant.paypal_email, amount)
print("{:<24}{:<32} {:>7} {:>7} {:>7} {:>7}".format( participant.username
, participant.paypal_email
, participant.paypal_fee_cap
, participant.balance
, total
, amount
))
row = (participant.username, participant.paypal_email, participant.paypal_fee_cap, amount)
writer.writerow(row)
print(" "*72, "-"*7)
print("{:>80}".format(total_gross))
Expand Down

0 comments on commit e1ef306

Please sign in to comment.