Module: Crm::Reports::ConversionReportHelper

Defined in:
app/helpers/crm/reports/conversion_report_helper.rb

Overview

View helper for the CRM conversion report
(Crm::Reports::ConversionReportController), rendering the opportunity and
conversion-rate metric cells for each report row and its totals row.

Instance Method Summary collapse

Instance Method Details

#cr_metric_cells(row) ⇒ ActiveSupport::SafeBuffer

Renders the table cells for a single conversion report data row
(opportunities created/won, conversion rate, and average closing time,
each for previous and current periods plus their variance).

Parameters:

  • row (Hash)

    row metrics keyed by symbol (e.g. :opps_created_prev, :opps_growth)

Returns:

  • (ActiveSupport::SafeBuffer)

    the row cells HTML



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/helpers/crm/reports/conversion_report_helper.rb', line 15

def cr_metric_cells(row)
  safe_join([
              (:td, values_format_without_symbol(row[:opps_created_prev].to_i), class: 'text-end font-monospace border-start'),
              (:td, values_format_without_symbol(row[:opps_created_cur].to_i), class: 'text-end font-monospace'),
              (:td, value_ptg(row[:opps_growth].to_i),
                          class: "text-end font-monospace#{' text-danger' if row[:opps_growth].to_f.negative?}"),
              (:td, values_format_without_symbol(row[:opps_won_prev].to_i), class: 'text-end font-monospace border-start col-shaded'),
              (:td, values_format_without_symbol(row[:opps_won_cur].to_i), class: 'text-end font-monospace col-shaded'),
              (:td, values_format_without_symbol(row[:opp_won_var].to_i),
                          class: "text-end font-monospace col-shaded#{' text-danger' if row[:opp_won_var].to_i.negative?}"),
              (:td, value_ptg(row[:conversion_rate_prev].to_i), class: 'text-end font-monospace border-start'),
              (:td, value_ptg(row[:conversion_rate_cur].to_i), class: 'text-end font-monospace'),
              (:td, value_ptg(row[:conversion_rate_var].to_i),
                          class: "text-end font-monospace#{' text-danger' if row[:conversion_rate_var].to_f.negative?}"),
              (:td, values_format_without_symbol(row[:avg_closing_time_prev].to_i), class: 'text-end font-monospace border-start col-shaded'),
              (:td, values_format_without_symbol(row[:avg_closing_time_cur].to_i), class: 'text-end font-monospace col-shaded'),
              (:td, values_format_without_symbol(row[:avg_closing_time_var].to_i),
                          class: "text-end font-monospace col-shaded#{' text-success' if row[:avg_closing_time_var].to_i.negative?}")
            ])
end

#cr_total_cells(row) ⇒ ActiveSupport::SafeBuffer

Renders the table cells for the conversion report totals row, mirroring
#cr_metric_cells but wrapping each value in a strong tag.

Parameters:

  • row (Hash)

    totals metrics keyed by symbol (e.g. :opps_created_prev, :opps_growth)

Returns:

  • (ActiveSupport::SafeBuffer)

    the totals cells HTML



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/helpers/crm/reports/conversion_report_helper.rb', line 41

def cr_total_cells(row)
  safe_join([
              (:td, (:strong, values_format_without_symbol(row[:opps_created_prev].to_i)), class: 'text-end font-monospace border-start'),
              (:td, (:strong, values_format_without_symbol(row[:opps_created_cur].to_i)), class: 'text-end font-monospace'),
              (:td, (:strong, value_ptg(row[:opps_growth].to_i)),
                          class: "text-end font-monospace#{' text-danger' if row[:opps_growth].to_f.negative?}"),
              (:td, (:strong, values_format_without_symbol(row[:opps_won_prev].to_i)), class: 'text-end font-monospace border-start col-shaded'),
              (:td, (:strong, values_format_without_symbol(row[:opps_won_cur].to_i)), class: 'text-end font-monospace col-shaded'),
              (:td, (:strong, values_format_without_symbol(row[:opp_won_var].to_i)),
                          class: "text-end font-monospace col-shaded#{' text-danger' if row[:opp_won_var].to_i.negative?}"),
              (:td, (:strong, value_ptg(row[:conversion_rate_prev].to_i)), class: 'text-end font-monospace border-start'),
              (:td, (:strong, value_ptg(row[:conversion_rate_cur].to_i)), class: 'text-end font-monospace'),
              (:td, (:strong, value_ptg(row[:conversion_rate_var].to_i)),
                          class: "text-end font-monospace#{' text-danger' if row[:conversion_rate_var].to_f.negative?}"),
              (:td, (:strong, values_format_without_symbol(row[:avg_closing_time_prev].to_i)), class: 'text-end font-monospace border-start col-shaded'),
              (:td, (:strong, values_format_without_symbol(row[:avg_closing_time_cur].to_i)), class: 'text-end font-monospace col-shaded'),
              (:td, (:strong, values_format_without_symbol(row[:avg_closing_time_var].to_i)),
                          class: "text-end font-monospace col-shaded#{' text-success' if row[:avg_closing_time_var].to_i.negative?}")
            ])
end