From 4e7a2d3ea90cbaed29c52913641d8d405af0e715 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Thu, 7 Sep 2023 20:00:34 -0500 Subject: [PATCH] Don't renew if there is a future plan Note this means if there is a big hole between the end of current plan and the future plan that they won't renew properly. --- bin/billing_monthly_cronjob | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/billing_monthly_cronjob b/bin/billing_monthly_cronjob index bdf5493d712a4112758de536d6a7ec1c0a528ab0..b201196ae2ec3d7d86ffb8e607d6a22e3a6dcada 100755 --- a/bin/billing_monthly_cronjob +++ b/bin/billing_monthly_cronjob @@ -88,7 +88,13 @@ EM::Iterator.new(db.exec( FROM customer_plans WHERE expires_at <= LOCALTIMESTAMP + '4 days' AND - expires_at > LOCALTIMESTAMP - INTERVAL '1 month' + expires_at > LOCALTIMESTAMP - INTERVAL '1 month' AND ( + SELECT COUNT(*) + FROM plan_log + WHERE + customer_id=customer_plans.customer_id AND + UPPER(date_range) > LOCALTIMESTAMP + '4 days' + ) < 1; SQL ), 3).each(nil, -> { one << :done }) do |row, iter| customer = ExpiringCustomer.new(row["customer_id"])