Class: Search::OrderTextPresenter
- Inherits:
-
OrderPresenter
- Object
- OrderPresenter
- Search::OrderTextPresenter
- Defined in:
- app/presenters/search/order_text_presenter.rb
Overview
Plain-text presenter for order search results backed by ViewOrder.
Delegated Instance Attributes collapse
-
#estimated_cost ⇒ Object
Alias for R#estimated_cost.
Instance Method Summary collapse
-
#contact_link ⇒ String?
Returns the contact name as plain text, if available.
-
#customer_link ⇒ String?
Returns the customer name and number as plain text, if available.
-
#gross_revenue ⇒ BigDecimal
Returns the gross line total, falling back to zero.
-
#msrp ⇒ BigDecimal
Returns the MSRP line total, falling back to zero.
-
#notes_indicator ⇒ String
Returns the order notes as plain text.
-
#order_link ⇒ String
Returns the order reference number or cart id as plain text.
-
#revenue_consolidated_at_time_of_checkout ⇒ BigDecimal
Returns the revenue consolidated at checkout, falling back to the order total.
-
#spiff_rep_link ⇒ String?
Returns the SPIFF rep name as plain text, if available.
-
#total_revenue ⇒ BigDecimal
Returns the order total, falling back to zero.
Instance Method Details
#contact_link ⇒ String?
Returns the contact name as plain text, if available.
34 35 36 37 38 |
# File 'app/presenters/search/order_text_presenter.rb', line 34 def contact_link return unless r.has_columns?(:contact_full_name, :contact_id) r.contact_full_name.to_s end |
#customer_link ⇒ String?
Returns the customer name and number as plain text, if available.
16 17 18 19 20 |
# File 'app/presenters/search/order_text_presenter.rb', line 16 def customer_link return unless r.has_columns?(:customer_full_name, :customer_id) "#{r.customer_full_name} (CN#{r.customer_id})" end |
#estimated_cost ⇒ Object
Alias for R#estimated_cost
63 |
# File 'app/presenters/search/order_text_presenter.rb', line 63 delegate :estimated_cost, to: :r |
#gross_revenue ⇒ BigDecimal
Returns the gross line total, falling back to zero.
48 |
# File 'app/presenters/search/order_text_presenter.rb', line 48 def gross_revenue = r.line_total || 0.00 |
#msrp ⇒ BigDecimal
Returns the MSRP line total, falling back to zero.
58 |
# File 'app/presenters/search/order_text_presenter.rb', line 58 def msrp = r.line_total_msrp || 0.00 |
#notes_indicator ⇒ String
Returns the order notes as plain text.
43 |
# File 'app/presenters/search/order_text_presenter.rb', line 43 def notes_indicator = h.text_only(r.notes) |
#order_link ⇒ String
Returns the order reference number or cart id as plain text.
11 |
# File 'app/presenters/search/order_text_presenter.rb', line 11 def order_link = r.reference_number || "Cart id #{r.id}" |
#revenue_consolidated_at_time_of_checkout ⇒ BigDecimal
Returns the revenue consolidated at checkout, falling back to the order total.
order.revenue_consolidated_at_time_of_checkout should NEVER be nil, but hey it happens, very rarely, for no explicable reason, the fix is to set it to order.total
69 |
# File 'app/presenters/search/order_text_presenter.rb', line 69 def revenue_consolidated_at_time_of_checkout = r.revenue_consolidated_at_time_of_checkout || r.total |
#spiff_rep_link ⇒ String?
Returns the SPIFF rep name as plain text, if available.
25 26 27 28 29 |
# File 'app/presenters/search/order_text_presenter.rb', line 25 def spiff_rep_link return unless r.has_columns?(:spiff_rep_full_name, :spiff_rep_id) r.spiff_rep_full_name.to_s end |
#total_revenue ⇒ BigDecimal
Returns the order total, falling back to zero.
53 |
# File 'app/presenters/search/order_text_presenter.rb', line 53 def total_revenue = r.total || 0.00 |