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

Better PayPal penny testing #2209

Merged
merged 5 commits into from
Apr 21, 2014
Merged

Better PayPal penny testing #2209

merged 5 commits into from
Apr 21, 2014

Conversation

rummik
Copy link
Contributor

@rummik rummik commented Mar 30, 2014

Should solve #2198

Edit: Please note, I don't know how to test this. I'll leave that up to @whit537

@rummik
Copy link
Contributor Author

rummik commented Mar 30, 2014

Ping @whit537. I don't know who else deals with PayPal right now.

@chadwhitacre
Copy link
Contributor

IRC

Here's why I took out the test for 0.75.

I always try masspay.py -p, and the user is always right! :-)
I never use it. Instead let's just point to the command line switches.
Over on #1988 I've done some more thinking about how to manage our
escrow across our multiple accounts. This adds a report to the masspay
script to help make decisions about that.
@chadwhitacre
Copy link
Contributor

The bad amount is 26.26. We compute a net of 25.74 and a fee of 0.52

I am unable to reproduce this result. Right now I am seeing masspay.py compute 25.75 given 26.26. I think we indeed need to back out ba2b611 (or the functional equivalent).

@chadwhitacre
Copy link
Contributor

No wait ...

@chadwhitacre
Copy link
Contributor

No, actually, yes ... ?

@chadwhitacre
Copy link
Contributor

Yeesh. Now I am seeing masspay.py compute take 26.26 and compute 25.74, with PayPal assessing a fee of 0.51 as expected:

screen shot 2014-04-17 at 9 44 47 pm

@chadwhitacre
Copy link
Contributor

Here's the Python script I was using:

#!/usr/bin/env python

from decimal import Decimal as D


def round_(d):
    return d.quantize(D('0.01'))


for dollars in range(25,27):
    for cents in range(100):
        target = D('{}.{:0>2}'.format(dollars, cents))
        exact = target / D('1.02')
        inexact = round_(exact)
        check_exact = inexact * D('1.02')
        check_rounded = round_(check_exact)
        if check_rounded != target:
            print target, check_rounded, check_exact, inexact, exact

Here's a similar JavaScript script that @rummik came up with:

http://jsbin.com/rujoc/2

@chadwhitacre
Copy link
Contributor

I rebased this on masspay-report (#2099) and modified it to go back to the previous test we had, prior to #2029.

@clone1018 clone1018 merged commit de92176 into master Apr 21, 2014
@seanlinsley seanlinsley deleted the eat-more-pennies branch April 21, 2014 19:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants