Created
May 20, 2022 03:32
-
-
Save benmacleod/46140a29bfe33f46ae253f5caa3c8a0b to your computer and use it in GitHub Desktop.
Capturing where a donation's amount doesn't match a subscription's amount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT s.region_id, s.frequency, s.payment_provider, s.payment_method, s.created_at, s.id, s.email, s.amount_in_local, d.amount_in_local, > | |
FROM subscriptions s | |
JOIN donations d ON s.id = d.subscription_id | |
WHERE d.amount_in_local != s.amount_in_local | |
AND s.created_at > CURRENT_TIMESTAMP - INTERVAL '3 years' | |
GROUP BY 1,2,3,4,5,6,7,8,9 | |
ORDER BY 1,2,3,4,5 | |
; | |
-- Some reasons: | |
-- 1. donor/admin changes amount via Stripe or PayPal | |
-- 2. for PayPal, billing failed one month, then doubles up the following month | |
-- 3. when admins increased a monthly donation in Stripe, there is sometimes an extra "pro-rated" payment which makes up for supposed missing revenue coming from the part of the month that has already happened which "should have been" charged at the new amount | |
-- 4. for a time, we would round pledges down to the nearest dollar/pound/euro (source PR?) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment