Class: Search::OrderPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::OrderPresenter
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/order_presenter.rb
Overview
HTML presenter for order search results backed by ViewOrder.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#contact_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated contact, if available.
-
#coupons ⇒ String?
Returns a sentence listing the coupon codes applied to the order.
-
#currency_symbol ⇒ String
Returns the symbol for the USD currency.
-
#customer_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated customer, if available.
-
#estimated_cost ⇒ String?
Returns the estimated cost formatted as currency, for managers only.
-
#estimated_profit_margin ⇒ String?
Returns the estimated profit margin formatted as a percentage, for managers only.
-
#gross_revenue ⇒ String
Returns the gross revenue formatted as currency.
-
#has_pending_drop_ship_deliveries ⇒ ActiveSupport::SafeBuffer
Returns a yes/no indicator for pending drop-ship deliveries.
-
#msrp ⇒ String
Returns the MSRP formatted as currency.
-
#notes_indicator ⇒ ActiveSupport::SafeBuffer
Returns a notes popover for the order notes.
-
#opportunity_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated opportunity, if available.
-
#order_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the order using its reference number or cart id.
-
#original_order_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the original order, if one exists.
-
#rma_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated RMA, if one exists.
-
#spiff_rep_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the SPIFF rep, if available.
-
#state ⇒ String
Returns the human-readable order state name.
-
#support_case_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated support case, if one exists.
-
#total_revenue ⇒ String
Returns the total revenue formatted as currency.
Methods inherited from BasePresenter
#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u
Constructor Details
This class inherits a constructor from BasePresenter
Instance Method Details
#contact_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated contact, if available.
155 156 157 158 159 |
# File 'app/presenters/search/order_presenter.rb', line 155 def contact_link return unless r.has_columns?(:contact_full_name, :contact_id) h.link_to r.contact_full_name, h.contact_path(r.contact_id) end |
#coupons ⇒ String?
Returns a sentence listing the coupon codes applied to the order.
137 138 139 140 141 |
# File 'app/presenters/search/order_presenter.rb', line 137 def coupons return unless r.has_columns?(:coupons) r.coupons.to_sentence end |
#currency_symbol ⇒ String
Returns the symbol for the USD currency.
72 73 74 |
# File 'app/presenters/search/order_presenter.rb', line 72 def currency_symbol Money::Currency.new('USD').symbol end |
#customer_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated customer, if available.
128 129 130 131 132 |
# File 'app/presenters/search/order_presenter.rb', line 128 def customer_link return unless r.has_columns?(:customer_full_name, :customer_id) h.link_to r.customer_full_name, h.customer_path(r.customer_id) end |
#estimated_cost ⇒ String?
Returns the estimated cost formatted as currency, for managers only.
100 101 102 103 104 105 106 |
# File 'app/presenters/search/order_presenter.rb', line 100 def estimated_cost return unless current_account.is_manager? return unless r.has_columns?(:estimated_cost, :currency) return unless r.estimated_cost h.number_to_currency r.estimated_cost, unit: currency_symbol end |
#estimated_profit_margin ⇒ String?
Returns the estimated profit margin formatted as a percentage, for managers only.
111 112 113 114 115 116 |
# File 'app/presenters/search/order_presenter.rb', line 111 def estimated_profit_margin return unless current_account.is_manager? return unless r.has_columns?(:estimated_profit_margin) h.number_to_percentage r.estimated_profit_margin, precision: 2 end |
#gross_revenue ⇒ String
Returns the gross revenue formatted as currency.
79 80 81 |
# File 'app/presenters/search/order_presenter.rb', line 79 def gross_revenue h.number_to_currency (r.line_total || 0.00), unit: currency_symbol end |
#has_pending_drop_ship_deliveries ⇒ ActiveSupport::SafeBuffer
Returns a yes/no indicator for pending drop-ship deliveries.
121 122 123 |
# File 'app/presenters/search/order_presenter.rb', line 121 def has_pending_drop_ship_deliveries h.y r.has_pending_drop_ship_deliveries end |
#msrp ⇒ String
Returns the MSRP formatted as currency.
93 94 95 |
# File 'app/presenters/search/order_presenter.rb', line 93 def msrp h.number_to_currency (r.line_total_msrp || 0.00), unit: currency_symbol end |
#notes_indicator ⇒ ActiveSupport::SafeBuffer
Returns a notes popover for the order notes.
65 66 67 |
# File 'app/presenters/search/order_presenter.rb', line 65 def notes_indicator h.notes_popover r.notes end |
#opportunity_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated opportunity, if available.
49 50 51 52 53 |
# File 'app/presenters/search/order_presenter.rb', line 49 def opportunity_link return unless r.has_columns?(:opportunity_name, :opportunity_id) h.link_to r.opportunity_name, h.opportunity_path(r.opportunity_id) end |
#order_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the order using its reference number or cart id.
15 16 17 |
# File 'app/presenters/search/order_presenter.rb', line 15 def order_link h.link_to r.reference_number || "Cart id #{r.id}", h.order_path(r.id) end |
#original_order_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the original order, if one exists.
22 23 24 25 26 |
# File 'app/presenters/search/order_presenter.rb', line 22 def original_order_link return nil if r.original_order_id.nil? h.link_to r.original_order_reference_number, h.order_path(r.original_order_id) end |
#rma_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated RMA, if one exists.
31 32 33 34 35 |
# File 'app/presenters/search/order_presenter.rb', line 31 def rma_link return nil if r.rma_id.nil? h.link_to r.credit_rma_number, h.rma_path(r.rma_id) end |
#spiff_rep_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the SPIFF rep, if available.
146 147 148 149 150 |
# File 'app/presenters/search/order_presenter.rb', line 146 def spiff_rep_link return unless r.has_columns?(:spiff_rep_full_name, :spiff_rep_id) h.link_to r.spiff_rep_full_name, h.contact_path(r.spiff_rep_id) end |
#state ⇒ String
Returns the human-readable order state name.
58 59 60 |
# File 'app/presenters/search/order_presenter.rb', line 58 def state Order.human_state_name(r.state) end |
#support_case_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the associated support case, if one exists.
40 41 42 43 44 |
# File 'app/presenters/search/order_presenter.rb', line 40 def support_case_link return nil if r.support_case_id.nil? h.link_to r.support_case_number, h.support_case_path(r.support_case_id) end |
#total_revenue ⇒ String
Returns the total revenue formatted as currency.
86 87 88 |
# File 'app/presenters/search/order_presenter.rb', line 86 def total_revenue h.number_to_currency (r.total || 0.00), unit: currency_symbol end |