~singpolyma/sgx-jmp

7b1379d203d72bb0edb6a4d8b8dd2bb0bae5f216 — Christopher Vollick 1 year, 9 months ago 5a8273f
Customer Visible Plan Info

We moved some of the currently private things to be public, like currency, and
then included things like how much the monthly price is as well.
2 files changed, 10 insertions(+), 10 deletions(-)

M lib/customer_info.rb
M lib/customer_plan.rb
M lib/customer_info.rb => lib/customer_info.rb +9 -9
@@ 37,12 37,19 @@ class CustomerInfo
		{ var: "Next renewal", value: expires_at.strftime("%Y-%m-%d") } if expires_at
	end

	def monthly_amount
		return unless plan.monthly_price
		{ var: "Renewal", value: "$%.4f / month" % plan.monthly_price }
	end

	def fields
		[
			{ var: "Account Status", value: account_status },
			{ var: "Phone Number", value: tel || "Not Registered" },
			{ var: "Balance", value: "$%.4f" % balance },
			next_renewal
			monthly_amount,
			next_renewal,
			{ var: "Currency", value: (plan.currency || "No Currency").to_s }
		].compact
	end
end


@@ 68,19 75,12 @@ class AdminInfo
		end
	end

	def plan_fields
		[
			{ var: "Plan", value: info.plan.plan_name || "No Plan" },
			{ var: "Currency", value: (info.plan.currency || "No Currency").to_s }
		]
	end

	def fields
		info.fields + [
			{ var: "JID", value: jid.unproxied.to_s },
			{ var: "Cheo JID", value: jid.to_s },
			{ var: "Customer ID", value: customer_id },
			*plan_fields,
			{ var: "Plan", value: info.plan.plan_name || "No Plan" },
			{ var: "API", value: api.to_s }
		]
	end

M lib/customer_plan.rb => lib/customer_plan.rb +1 -1
@@ 9,7 9,7 @@ class CustomerPlan

	attr_reader :expires_at
	def_delegator :@plan, :name, :plan_name
	def_delegators :@plan, :currency, :merchant_account
	def_delegators :@plan, :currency, :merchant_account, :monthly_price

	def initialize(customer_id, plan: nil, expires_at: Time.now)
		@customer_id = customer_id