~singpolyma/sgx-jmp

fd09daddda8d9dcbcd4c6b13a8f49a625f6be8ab — Stephen Paul Weber 1 year, 20 days ago a492d19
Show pending status for not yet activated users
5 files changed, 16 insertions(+), 6 deletions(-)

M lib/customer.rb
M lib/customer_info.rb
M lib/customer_plan.rb
M lib/customer_repo.rb
M schemas
M lib/customer.rb => lib/customer.rb +1 -1
@@ 25,7 25,7 @@ class Customer
	               :currency, :merchant_account, :plan_name, :minute_limit,
	               :message_limit, :monthly_overage_limit, :activation_date,
	               :expires_at, :monthly_price, :save_plan!, :auto_top_up_amount,
	               :extend_plan
	               :extend_plan, :status
	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_info.rb => lib/customer_info.rb +1 -1
@@ 73,7 73,7 @@ class PlanInfo
	end

	def status
		customer.active? ? "Active" : "Expired"
		customer.status.to_s.capitalize
	end

	def remaining_included_calling_credit

M lib/customer_plan.rb => lib/customer_plan.rb +10 -2
@@ 36,7 36,7 @@ class CustomerPlan
		self.for(
			customer_id,
			**kwargs.slice(
				:plan_name, :expires_at, :parent_customer_id,
				:plan_name, :expires_at, :parent_customer_id, :pending,
				:auto_top_up_amount, :monthly_overage_limit
			)
		)


@@ 48,13 48,14 @@ class CustomerPlan
		expires_at: Time.now,
		auto_top_up_amount: 0,
		monthly_overage_limit: 0,
		parent_customer_id: nil
		pending: false, parent_customer_id: nil
	)
		@customer_id = customer_id
		@plan = plan || OpenStruct.new
		@expires_at = expires_at
		@auto_top_up_amount = auto_top_up_amount || 0
		@monthly_overage_limit = monthly_overage_limit || 0
		@pending = pending
		@parent_customer_id = parent_customer_id
	end



@@ 62,6 63,13 @@ class CustomerPlan
		plan_name && @expires_at > Time.now
	end

	def status
		return :active if active?
		return :pending if @pending

		:expired
	end

	def with_plan_name(plan_name)
		self.class.new(
			@customer_id,

M lib/customer_repo.rb => lib/customer_repo.rb +3 -1
@@ 177,7 177,9 @@ protected
	end

	SQL = <<~SQL
		SELECT COALESCE(balance,0) AS balance, plan_name, expires_at, parent_customer_id
		SELECT
			COALESCE(balance,0) AS balance, plan_name, expires_at,
			parent_customer_id, pending
		FROM customer_plans LEFT JOIN balances USING (customer_id)
		WHERE customer_id=$1 LIMIT 1
	SQL

M schemas => schemas +1 -1
@@ 1,1 1,1 @@
Subproject commit dfb88d581ced2cb82cd1bab454de1afafcb9668d
Subproject commit a40dc7b43c222c2d19db87615424f327638192b0