Module: Crm::Reports::OrdersReportHelper
- Defined in:
- app/helpers/crm/reports/orders_report_helper.rb
Overview
View helpers for the CRM orders report: variance percentage indicators and
money/number formatting for the order-origin breakdown.
Instance Method Summary collapse
-
#order_origin_values_format_of(value) ⇒ String, ActiveSupport::SafeBuffer
Formats a money value with its currency symbol.
-
#order_origin_values_format_without_symbol_of(value) ⇒ String, ActiveSupport::SafeBuffer
Formats a value as a delimited number without a currency symbol.
-
#order_origin_var_percentage_of(var_value) ⇒ ActiveSupport::SafeBuffer
Renders a variance percentage with an up/down arrow icon, colored green for positive and red for negative values.
Instance Method Details
#order_origin_values_format_of(value) ⇒ String, ActiveSupport::SafeBuffer
Formats a money value with its currency symbol.
37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/crm/reports/orders_report_helper.rb', line 37 def order_origin_values_format_of(value) return content_tag(:span, "-", class: "text-body-secondary") unless value if value.zero? content_tag(:span, "-", class: "text-body-secondary") else humanized_money_with_symbol(value) end end |
#order_origin_values_format_without_symbol_of(value) ⇒ String, ActiveSupport::SafeBuffer
Formats a value as a delimited number without a currency symbol.
52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/crm/reports/orders_report_helper.rb', line 52 def order_origin_values_format_without_symbol_of(value) return content_tag(:span, "-", class: "text-body-secondary") unless value if value.zero? content_tag(:span, "-", class: "text-body-secondary") else number_with_delimiter(value) end end |
#order_origin_var_percentage_of(var_value) ⇒ ActiveSupport::SafeBuffer
Renders a variance percentage with an up/down arrow icon, colored green
for positive and red for negative values.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/crm/reports/orders_report_helper.rb', line 14 def order_origin_var_percentage_of(var_value) return content_tag(:span, "-", class: "text-body-secondary") unless var_value if var_value.positive? content_tag(:span, class: "text-success") do fa_icon("arrow-up", family: :solid, class: "fa-xs me-1") + "#{var_value} %" end elsif var_value.negative? content_tag(:span, class: "text-danger") do fa_icon("arrow-down", family: :solid, class: "fa-xs me-1") + "#{var_value} %" end else content_tag(:span, "-", class: "text-body-secondary") end end |