-
Notifications
You must be signed in to change notification settings - Fork 309
run Gittip 89 #2029
Comments
Thanks for reminding me it's Thursday Chad. +1 |
:-) |
I've marked these two users as suspicious: |
And I've notified them on Twitter: |
Reviewed 56 accounts. |
Droplet spun up and updated. Taking a backup ... |
Backup verified. |
Script started, parent shell kill 6ed. |
Script ran for {age} (2:35:51.452689). |
Log downloaded. |
Droplet destroyed. |
Dang it! MassPay is off by a penny again. :-/ |
I've used binary search to find the bad amount amongst the 30 in the MassPay CSV for today. The process is:
The bad amount is 26.26. We compute a net of 25.74 and a fee of 0.52, but PayPal computes a fee of 0.51 on 25.74. |
#!/usr/bin/python
from __future__ import division
from decimal import Decimal as D
def round_(d):
return d.quantize(D('0.01'))
for i in range(2624, 2630):
amount = D(str(i / 100))
fee = amount - round_(amount / D('1.02'))
base = amount - fee
check = round_(base * D('1.02'))
print amount, fee, base, check |
The third column is the number we upload to PayPal.
In this case we're trying to hit 26.27, and we're uploading 25.74. |
We're trying to hit 26.27, which we compute as 25.75, which does hit the special-case we added in #1673. |
Okay! So the number we want to upload is 25.75. Why don't we? |
Why is the special-casing wrong in this case? Why is this case not, in fact, special? And why did we think it was? |
We have two special cases: .25 and .75. The math is opposite in the .75 case, but we treat it just like the .25 case. |
Every 50th one, there is no rounding error. |
I'm doing something wrong. |
Okay, bottom line is if it's 0.75 we don't need to adjust. Giving up on the math. :-( |
Here's where my test.py ended up: #!/usr/bin/python
from __future__ import division
from decimal import Decimal as D
def round_(d):
return d.quantize(D('0.01'))
#for i in range(2624, 2630):
for i in range(0, 3000):
amount = D(str(i / 100))
fee = amount - round_(amount / D('1.02'))
precise_fee = amount - amount / D('1.02')
base = amount - fee
check = round_(base * D('1.02'))
cents = str(base)[-2:]
try:
if cents == '25':
assert check - amount == D('0.01')
if cents == '75':
assert check - amount == D('-0.01')
except AssertionError:
print "NOPE"
print "trying to hit ", str(amount).rjust(5)
print "guessing fee is", str(precise_fee)[:7].rjust(8)
print "so uploading ", str(base).rjust(5)
print "right? ", str(check).rjust(5)
print |
Masspay done for 30 participants. Escrow rebalanced. |
88
The text was updated successfully, but these errors were encountered: