From 7b1379d203d72bb0edb6a4d8b8dd2bb0bae5f216 Mon Sep 17 00:00:00 2001 From: Christopher Vollick <0@psycoti.ca> Date: Wed, 25 Aug 2021 17:02:34 -0400 Subject: [PATCH] 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. --- lib/customer_info.rb | 18 +++++++++--------- lib/customer_plan.rb | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/customer_info.rb b/lib/customer_info.rb index 09efc9fc7c83526b354d332964af1ba7ad11078f..013871e732187368dcc8d064688fd2eaa18c5ba7 100644 --- a/lib/customer_info.rb +++ b/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 diff --git a/lib/customer_plan.rb b/lib/customer_plan.rb index 1854dffaecb519418017ed9bd1e94f8916ffcc5a..e9cd62ef3f33c71487437748ae36e75099c58733 100644 --- a/lib/customer_plan.rb +++ b/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