Customer Visible Plan Info

Christopher Vollick created

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.

Change summary

lib/customer_info.rb | 18 +++++++++---------
lib/customer_plan.rb |  2 +-
2 files changed, 10 insertions(+), 10 deletions(-)

Detailed changes

lib/customer_info.rb 🔗

@@ -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

lib/customer_plan.rb 🔗

@@ -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