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

Commit

Permalink
Clean up code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Aug 13, 2015
1 parent 2bd3ba0 commit 22867fd
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions gratipay/billing/payday.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,26 +271,36 @@ def process_payment_instructions(cursor):
log("Processing payment instructions.")
cursor.run("UPDATE payday_payment_instructions SET is_funded=true;")


@staticmethod
def park_payment_instructions(cursor):
"""In the case of participants in whose case the amount to be charged to their cc's
in order to meet all outstanding and current subscriptions does not reach the minimum
charge threshold, park this for the next week by adding the current subscription amount
charge threshold, park this for the next week by adding the current subscription amount
to giving_due
"""
cursor.run("""INSERT INTO participants_payments_uncharged
SELECT participant
FROM payday_payment_instructions
GROUP BY participant
HAVING SUM(amount + giving_due) < %(MINIMUM_CHARGE)s
""",dict(MINIMUM_CHARGE=MINIMUM_CHARGE))

cursor.run("""UPDATE payment_instructions
SET giving_due = amount + giving_due
WHERE id IN (SELECT id
FROM payday_payment_instructions ppi, participants_payments_uncharged ppu
WHERE ppi.participant = ppu.participant)
""")
cursor.run("""
INSERT INTO participants_payments_uncharged
SELECT participant
FROM payday_payment_instructions
GROUP BY participant
HAVING SUM(amount + giving_due) < %(MINIMUM_CHARGE)s
""", dict(MINIMUM_CHARGE=MINIMUM_CHARGE))

cursor.run("""
UPDATE payment_instructions
SET giving_due = amount + giving_due
WHERE id IN ( SELECT id
FROM payday_payment_instructions ppi
, participants_payments_uncharged ppu
WHERE ppi.participant = ppu.participant
)
""")


@staticmethod
def transfer_takes(cursor, ts_start):
Expand Down

0 comments on commit 22867fd

Please sign in to comment.