From 4ac5458aa9f003760d8be039db35e81b5eeb7007 Mon Sep 17 00:00:00 2001 From: Changaco Date: Sat, 16 Sep 2023 10:51:13 +0200 Subject: [PATCH] fix inaccuracy in `send_upcoming_debit_notifications` --- liberapay/payin/cron.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/liberapay/payin/cron.py b/liberapay/payin/cron.py index fb8643861..9c898f810 100644 --- a/liberapay/payin/cron.py +++ b/liberapay/payin/cron.py @@ -211,6 +211,7 @@ def send_upcoming_debit_notifications(): max_execution_date = max(sp['execution_date'] for sp in payins) assert last_execution_date == max_execution_date context['ndays'] = (max_execution_date - utcnow().date()).days + currency = payins[0]['amount'].currency while True: route = db.one(""" SELECT r @@ -218,11 +219,12 @@ def send_upcoming_debit_notifications(): WHERE r.participant = %s AND r.status = 'chargeable' AND r.network::text LIKE 'stripe-%%' - ORDER BY r.is_default NULLS LAST + ORDER BY r.is_default_for = %s DESC NULLS LAST + , r.is_default NULLS LAST , r.network = 'stripe-sdd' DESC , r.ctime DESC LIMIT 1 - """, (payer.id,)) + """, (payer.id, currency)) if route is None: break route.sync_status()