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

Add tests for payday behavior when balance is negative #4255

Closed
wants to merge 2 commits into from

Conversation

chadwhitacre
Copy link
Contributor

@chadwhitacre chadwhitacre commented Dec 23, 2016

In limited situations, we send a participant's Gratipay escrow balance negative. For example, when they receive stolen money that we refund (https://github.com/gratipay/violations/issues/34), or when I forget to post back MassPay and subsequently overpay people (gratipay/inside.gratipay.com#951). In these situations, we want to recoup the loss from future takes, but our current behavior is to charge their credit card (if they have one) to make up the difference. That penalizes the participant for a mistake on our part, so I think the best thing to do is update payday to not charge a card when a pre-payday balance is negative.

Update: We ended up working around the charges for the 10 people in question by manually overriding the error field on their route to prevent charging. The tests on this PR are still valuable as documentation of existing behavior.

@chadwhitacre
Copy link
Contributor Author

I think that has implications for people who would've received from these people, though.

A → B
B → C

We double-pay B and send their balance negative to correct. Next week they receive from A again, but that just brings them up to 0 and they don't have enough to pay C.

Sorry, C. :-(

@chadwhitacre
Copy link
Contributor Author

Or can we be smart enough to charge if the net for the payday is positive? Seems like we should be able to.

@chadwhitacre
Copy link
Contributor Author

This is complicated because new_balance < 0 is precisely how we decide which card holds to settle.

@chadwhitacre
Copy link
Contributor Author

One possibility would be to floor old_balance and/or new_balance at 0. Would that work cleanly?

@chadwhitacre
Copy link
Contributor Author

Alright, this is non-trivial.

@chadwhitacre chadwhitacre changed the title Don't charge when balance is negative Add tests for payday behavior when balance is negative Dec 29, 2016
@chadwhitacre
Copy link
Contributor Author

Spurious build failures? Restarted ...

@chadwhitacre
Copy link
Contributor Author

Rebased, was 68e36a2.

@chadwhitacre chadwhitacre force-pushed the test-negative-balances branch from 68e36a2 to e9a3b66 Compare December 29, 2016 22:07
@chadwhitacre chadwhitacre force-pushed the test-negative-balances branch from e9a3b66 to 0015f4b Compare January 12, 2017 19:30
@chadwhitacre
Copy link
Contributor Author

Ping @mattbk @nobodxbodon @kaguillera I think this should be an easy one to review, because it only touches tests.

@chadwhitacre
Copy link
Contributor Author

Withdrawing from review. Tests are failing and it's not obvious to me why.

@chadwhitacre
Copy link
Contributor Author

Giving up. 😞

@chadwhitacre chadwhitacre deleted the test-negative-balances branch February 20, 2017 15:28
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.

1 participant