-
Notifications
You must be signed in to change notification settings - Fork 308
calculate fee properly in MassPay script #1673
Comments
I tried levying the fee on the individual payments and am not seeing that it worked. :-/ I'm going to try uploading 12 spreadsheets, one for each payment, to compare the fee for each so I can pinpoint the problem. |
Found it! One of the twelve is off by one. |
And only that one is off. |
The target amount is 15.55, and we're calculating a 0.30 fee, but PayPal calculates a 0.31 fee on 15.25. |
|
|
Sure feels like there's some math going on here ... |
So if we drop back to 15.24 we come out a penny under, and if we go with 15.25 we are a penny over. |
Is this the only number this happens for, or are there others? |
Interesting. Could be a rounding error:
#!/usr/bin/python
from __future__ import division
from decimal import Decimal as D
for i in range(1554, 1557):
amount = D(str(i / 100))
fee = amount - (amount / D('1.02'))
print amount, fee, amount - fee, (amount - fee) * D('1.02') |
That is, we do get from the target back to the target there. |
It's related to the quantize call in our rounding. |
But even then, can we give PayPal a dollar amount with more than two digits after the decimal point? |
That was for |
Nope. Same error. Okay! |
Back to square one: is |
Many numbers:
That's with: #!/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(0, 2000):
amount = D(str(i / 100))
fee = amount - round_(amount / D('1.02'))
base = amount - fee
check = round_(base * D('1.02'))
if amount == check:
continue
print amount, fee, base, check |
Look at that! If |
We can't hit the target. That's the bottom line. I repeat: we can't hit the target. |
So what do we do? |
Ev has $15.55 to withdraw. We compute $15.25 to pass to PayPal. This results in a 31¢ fee where we intended a 30¢ fee. Options?
|
I don't see another way to do it. If we accept the extra penny charge from PayPal then we are leaking escrow, and that's Bad™. |
What if we upload the spreadsheet and then take whatever the fee actually is and then as an additional step feed that back into computing the spreadsheet from which we POST exchanges back to Gittip? The problem is that PayPal calculates fees per-receiver. That still doesn't help us hit the target. |
Thanks! :-) |
It's calculated as a percentage on the individual payments, not on the total.
Reticketed from #1671 (comment) :
The text was updated successfully, but these errors were encountered: