From 4390b00a2f0a969b350f23fd1c73a384b43f2f85 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 3 Apr 2023 13:24:54 -0500 Subject: [PATCH] Allow code to extend plan without billing --- lib/customer.rb | 3 ++- lib/customer_plan.rb | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/customer.rb b/lib/customer.rb index 626be27..dd9437c 100644 --- a/lib/customer.rb +++ b/lib/customer.rb @@ -24,7 +24,8 @@ class Customer def_delegators :@plan, :active?, :activate_plan_starting_now, :bill_plan, :currency, :merchant_account, :plan_name, :minute_limit, :message_limit, :monthly_overage_limit, :activation_date, - :expires_at, :monthly_price, :save_plan!, :auto_top_up_amount + :expires_at, :monthly_price, :save_plan!, :auto_top_up_amount, + :extend_plan def_delegators :@sgx, :deregister!, :register!, :registered?, :set_ogm_url, :fwd, :transcription_enabled def_delegators :@usage, :usage_report, :message_usage, :incr_message_usage, diff --git a/lib/customer_plan.rb b/lib/customer_plan.rb index 4891826..9f956a5 100644 --- a/lib/customer_plan.rb +++ b/lib/customer_plan.rb @@ -77,7 +77,7 @@ class CustomerPlan next false unless !block_given? || yield(db) charge_for_plan(note) - add_one_month_to_current_plan unless activate_plan_starting_now + extend_plan true end end @@ -98,6 +98,10 @@ class CustomerPlan SQL end + def extend_plan + add_one_month_to_current_plan unless activate_plan_starting_now + end + def activation_date DB.query_one(<<~SQL, @customer_id).then { |r| r[:start_date] } SELECT -- 2.45.2