Allow code to extend plan without billing

Stephen Paul Weber created

Change summary

lib/customer.rb      | 3 ++-
lib/customer_plan.rb | 6 +++++-
2 files changed, 7 insertions(+), 2 deletions(-)

Detailed changes

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,

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