From a7ad8369535aeafaf64db05e74dc2b2067ac3e69 Mon Sep 17 00:00:00 2001 From: Chad Whitacre Date: Thu, 11 Jun 2015 00:07:28 -0400 Subject: [PATCH] Pay out for pending-release participants --- bin/masspay.py | 5 +++-- gratipay/billing/payday.py | 6 ++++-- sql/branch.sql | 11 +++++++++++ tests/py/test_billing_payday.py | 4 ++-- 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 sql/branch.sql diff --git a/bin/masspay.py b/bin/masspay.py index d48a060e62..2dcffaec10 100755 --- a/bin/masspay.py +++ b/bin/masspay.py @@ -132,12 +132,13 @@ def compute_input_csv(): ---- Only include team owners ---- TODO: Include members on payroll once process_payroll is implemented - AND ( SELECT count(*) + AND (( SELECT count(*) FROM teams t WHERE t.owner = p.username AND t.is_approved IS TRUE AND t.is_closed IS NOT TRUE - ) > 0 + ) > 0 + OR p.status_of_1_0_balance='pending-release') ORDER BY p.balance DESC diff --git a/gratipay/billing/payday.py b/gratipay/billing/payday.py index ccafb596a3..79a542c3b4 100644 --- a/gratipay/billing/payday.py +++ b/gratipay/billing/payday.py @@ -416,12 +416,14 @@ def payout(self): ---- Only include team owners ---- TODO: Include members on payroll once process_payroll is implemented - AND ( SELECT count(*) + AND (( SELECT count(*) FROM teams t WHERE t.owner = p.username AND t.is_approved IS TRUE AND t.is_closed IS NOT TRUE - ) > 0 + ) > 0 + OR p.status_of_1_0_balance='pending-release') + """) def credit(participant): if participant.is_suspicious is None: diff --git a/sql/branch.sql b/sql/branch.sql new file mode 100644 index 0000000000..5a00530afe --- /dev/null +++ b/sql/branch.sql @@ -0,0 +1,11 @@ +BEGIN; + + CREATE TYPE status_of_1_0_balance AS ENUM + ('unreleased', 'pending-release', 'released', 'refunded'); + + ALTER TABLE participants + ADD COLUMN status_of_1_0_balance status_of_1_0_balance + NOT NULL + DEFAULT 'unreleased'; + +END; diff --git a/tests/py/test_billing_payday.py b/tests/py/test_billing_payday.py index ec8a164838..50733b2e0f 100644 --- a/tests/py/test_billing_payday.py +++ b/tests/py/test_billing_payday.py @@ -567,8 +567,8 @@ def test_payout_ach_error_gets_recorded(self, ach_credit): @mock.patch('gratipay.billing.payday.ach_credit') def test_payout_pays_out_Gratipay_1_0_balance(self, ach): alice = self.make_participant('alice', claimed_time='now', is_suspicious=False, - balanced_customer_href='foo', - last_ach_result='') + balanced_customer_href='foo', last_ach_result='', + balance=20, status_of_1_0_balance='pending-release') Payday.start().payout() assert ach.call_count == 1