diff --git a/lib/customer.rb b/lib/customer.rb index 626be279d339d3e4b9fd70481fac18ea1d0c17c8..dd9437c528737224b128bc0c9cae991f12818440 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 489182614aef7c3280b51988c88ca0e2d24708d4..9f956a5098d376410be8ee70c7f9bf170c3c9f12 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