Module: Crm::Reports::OpportunityConversionHelper
- Defined in:
- app/helpers/crm/reports/opportunity_conversion_helper.rb
Overview
View helpers for the CRM opportunity conversion report: sales rep naming
and period-over-period variance calculations against last year's results.
Instance Method Summary collapse
-
#last_year_pct_value(data, column) ⇒ Float
Computes the variance of a row's value against the matching rows from last year's results (same
time_measurement). -
#rep_name ⇒ String
Returns the full name of the sales rep assigned to the report, falling back to "WarmlyYours" when no rep is available.
-
#totals_last_year(data, column) ⇒ Float
Computes the variance of a row's value against last year's total row.
Instance Method Details
#last_year_pct_value(data, column) ⇒ Float
Computes the variance of a row's value against the matching rows from
last year's results (same time_measurement).
24 25 26 |
# File 'app/helpers/crm/reports/opportunity_conversion_helper.rb', line 24 def last_year_pct_value(data, column) (data[column].to_f - @last_year_results.select { |b| b["time_measurement"] == data["time_measurement"] }.sum { |b| b[column].to_f }).round(2).to_f end |
#rep_name ⇒ String
Returns the full name of the sales rep assigned to the report, falling
back to "WarmlyYours" when no rep is available.
12 13 14 15 16 |
# File 'app/helpers/crm/reports/opportunity_conversion_helper.rb', line 12 def rep_name @sales_rep.first.full_name rescue StandardError "WarmlyYours" end |
#totals_last_year(data, column) ⇒ Float
Computes the variance of a row's value against last year's total row.
33 34 35 |
# File 'app/helpers/crm/reports/opportunity_conversion_helper.rb', line 33 def totals_last_year(data, column) (data[column].to_f - @last_year_total_results[column].to_f).round(2).to_f end |