Class: Search::OrderTextPresenter

Inherits:
OrderPresenter
  • Object
show all
Defined in:
app/presenters/search/order_text_presenter.rb

Overview

Plain-text presenter for order search results backed by ViewOrder.

Delegated Instance Attributes collapse

Instance Method Summary collapse

Instance Method Details

Returns the contact name as plain text, if available.

Returns:

  • (String, nil)


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

Returns the customer name and number as plain text, if available.

Returns:

  • (String, nil)


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_costObject

Alias for R#estimated_cost

Returns:

  • (Object)

    R#estimated_cost

See Also:



63
# File 'app/presenters/search/order_text_presenter.rb', line 63

delegate :estimated_cost, to: :r

#gross_revenueBigDecimal

Returns the gross line total, falling back to zero.

Returns:

  • (BigDecimal)


48
# File 'app/presenters/search/order_text_presenter.rb', line 48

def gross_revenue = r.line_total || 0.00

#msrpBigDecimal

Returns the MSRP line total, falling back to zero.

Returns:

  • (BigDecimal)


58
# File 'app/presenters/search/order_text_presenter.rb', line 58

def msrp = r.line_total_msrp || 0.00

#notes_indicatorString

Returns the order notes as plain text.

Returns:

  • (String)


43
# File 'app/presenters/search/order_text_presenter.rb', line 43

def notes_indicator = h.text_only(r.notes)

Returns the order reference number or cart id as plain text.

Returns:

  • (String)


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_checkoutBigDecimal

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

Returns:

  • (BigDecimal)


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

Returns the SPIFF rep name as plain text, if available.

Returns:

  • (String, nil)


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_revenueBigDecimal

Returns the order total, falling back to zero.

Returns:

  • (BigDecimal)


53
# File 'app/presenters/search/order_text_presenter.rb', line 53

def total_revenue = r.total || 0.00