~singpolyma/sgx-jmp

4390b00a2f0a969b350f23fd1c73a384b43f2f85 — Stephen Paul Weber 8 months ago 85e561c
Allow code to extend plan without billing
2 files changed, 7 insertions(+), 2 deletions(-)

M lib/customer.rb
M lib/customer_plan.rb
M lib/customer.rb => lib/customer.rb +2 -1
@@ 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,

M lib/customer_plan.rb => lib/customer_plan.rb +5 -1
@@ 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