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

Commit

Permalink
Merge pull request #4111 from gratipay/takes-masspay
Browse files Browse the repository at this point in the history
Include team members in MassPay
  • Loading branch information
chadwhitacre authored Sep 1, 2016
2 parents 3717449 + 773efff commit 4b5b0b3
Show file tree
Hide file tree
Showing 5 changed files with 900 additions and 672 deletions.
16 changes: 2 additions & 14 deletions bin/masspay.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
#!/usr/bin/env python
"""This is a script for managing MassPay each week.
Most of our payouts are handled by Balanced, but they're limited to people in
the U.S. We need to payout to people outside the U.S. (#126), and while we work
on a long-term solution, we are using PayPal. However, we've grown past the
point that PayPal's Instant Transfer feature is workable. This script is for
interfacing with PayPal's MassPay feature.
See documentation here:
This script provides for:
1. Computing an input CSV by hitting the Gratipay database directly.
2. Computing two output CSVs (one to upload to PayPal, the second to use for POSTing
the exchanges back to Gratipay)
3. POSTing the exchanges back to Gratipay via the HTTP API.
The idea is that you run steps 1 and 2, then run through the MassPay UI on the
PayPal website using the appropriate CSV from step 2, then run step 3.
http://inside.gratipay.com/howto/run-masspay
"""
from __future__ import absolute_import, division, print_function, unicode_literals
Expand Down
17 changes: 14 additions & 3 deletions gratipay/billing/exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ def get_ready_payout_routes_by_network(db, network):
FROM participants p
JOIN current_exchange_routes r ON p.id = r.participant
WHERE p.balance > 0
AND p.claimed_time is not null
AND p.is_suspicious is not true
AND r.network = %s
AND (
Expand All @@ -198,12 +200,21 @@ def get_ready_payout_routes_by_network(db, network):
) > 0
OR -- Include green-lit Gratipay 1.0 balances
OR -- Include team members
(SELECT count(*)
FROM takes
JOIN teams t ON takes.team_id = t.id
WHERE takes.participant_id = p.id
AND p.has_verified_identity -- XXX apply this to *everyone* we pay out to
AND t.is_approved IS TRUE
AND t.is_closed IS NOT TRUE
) > 0
p.status_of_1_0_payout='pending-payout'
OR -- Include green-lit Gratipay 1.0 balances
----- TODO: Include team members once process_takes is implemented
p.status_of_1_0_payout='pending-payout'
)
""", (network,))
Expand Down
4 changes: 2 additions & 2 deletions gratipay/testing/billing.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def setUp(self):
braintree_customer_id=self.obama_bt_id)
self.obama_route = ExchangeRoute.insert(self.obama, 'braintree-cc', self.obama_cc_token)
# A customer with Paypal attached.
self.homer = self.make_participant('homer', is_suspicious=False,
claimed_time='now')
self.homer = self.make_participant('homer', is_suspicious=False, verified_in='US',
claimed_time='now', email_address='[email protected]')
self.homer_route = ExchangeRoute.insert(self.homer, 'paypal', '[email protected]')


Expand Down
Loading

0 comments on commit 4b5b0b3

Please sign in to comment.