Module: Crm::Reports::ChannelRevenueHelper
- Defined in:
- app/helpers/crm/reports/channel_revenue_helper.rb
Overview
View helper: channel revenue.
Instance Method Summary collapse
Instance Method Details
#cr_change_indicator(prev_value, cur_value) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/helpers/crm/reports/channel_revenue_helper.rb', line 4 def cr_change_indicator(prev_value, cur_value) return content_tag(:span, "-", class: "text-muted") if prev_value.blank? && cur_value.blank? prev = prev_value.to_f cur = cur_value.to_f percentage_text = if prev.zero? cur.zero? ? "0%" : "#{cur.abs.round(0)}%" else "#{(((cur - prev) / prev) * 100).abs.round(1)}%" end if cur > prev content_tag(:span, class: "text-success") do fa_icon("arrow-up", family: :solid, class: "fa-xs me-1") + percentage_text end elsif cur < prev content_tag(:span, class: "text-danger") do fa_icon("arrow-down", family: :solid, class: "fa-xs me-1") + percentage_text end else content_tag(:span, class: "text-muted") do fa_icon("minus", family: :solid, class: "fa-xs me-1") + percentage_text end end end |