2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/helpers/crm/reports/channel_revenue_helper.rb', line 2
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
content_tag(:i, "", class: "fa-solid fa-arrow-up fa-xs me-1") + percentage_text
end
elsif cur < prev
content_tag(:span, class: "text-danger") do
content_tag(:i, "", class: "fa-solid fa-arrow-down fa-xs me-1") + percentage_text
end
else
content_tag(:span, class: "text-muted") do
content_tag(:i, "", class: "fa-solid fa-minus fa-xs me-1") + percentage_text
end
end
end
|