Class: Search::CreditMemoPresenter

Inherits:
BasePresenter
  • Object
show all
Includes:
Presenters::Timeable
Defined in:
app/presenters/search/credit_memo_presenter.rb

Overview

Row presenter for CreditMemoSearch — renders the cells in the CRM
credit-memo search/results table. Wraps a lightweight SQL projection
of CreditMemo columns rather than a fully-loaded model.

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_account, #options, #url_helper

Instance Method Summary collapse

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

#billing_customerActiveSupport::SafeBuffer?

Linked billing-customer name → show page; nil when no separate
billing customer is set.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


28
29
30
31
# File 'app/presenters/search/credit_memo_presenter.rb', line 28

def billing_customer
  return nil if r.billing_customer_id.nil?
  h.link_to(r.billing_customer_name, h.customer_path(r.billing_customer_id))
end

#coActiveSupport::SafeBuffer?

Linked credit-Order reference → order show page; nil for memos
not tied to a credit order.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


45
46
47
48
# File 'app/presenters/search/credit_memo_presenter.rb', line 45

def co
  return nil if r.credit_order_id.nil?
  h.link_to(r.credit_order_reference_number, h.order_path(r.credit_order_id))
end

#created_atString

Created-at timestamp rendered through the shared render_date helper.

Returns:

  • (String)


84
85
86
# File 'app/presenters/search/credit_memo_presenter.rb', line 84

def created_at
  h.render_date(r.created_at)
end

#credit_memoActiveSupport::SafeBuffer

Linked credit-memo reference number → show page.

Returns:

  • (ActiveSupport::SafeBuffer)


13
14
15
# File 'app/presenters/search/credit_memo_presenter.rb', line 13

def credit_memo
  h.link_to(r.reference_number, h.credit_memo_path(r.id))
end

#customerActiveSupport::SafeBuffer

Linked customer name → customer show page.

Returns:

  • (ActiveSupport::SafeBuffer)


20
21
22
# File 'app/presenters/search/credit_memo_presenter.rb', line 20

def customer
  h.link_to(r.customer_name, h.customer_path(r.customer_id))
end

#document_dateString

Document date rendered through the shared render_date helper.

Returns:

  • (String)


69
70
71
# File 'app/presenters/search/credit_memo_presenter.rb', line 69

def document_date
  h.render_date(r.document_date)
end

#original_orderActiveSupport::SafeBuffer?

Linked original-Order reference → order show page; nil when no
source order is recorded.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


54
55
56
57
# File 'app/presenters/search/credit_memo_presenter.rb', line 54

def original_order
  return nil if r.original_order_id.nil?
  h.link_to(r.original_order_reference_number, h.order_path(r.original_order_id))
end

#request_dateString

Date the credit-memo request was filed (often the RMA-creation
date) rendered as CRM date.

Returns:

  • (String)


77
78
79
# File 'app/presenters/search/credit_memo_presenter.rb', line 77

def request_date
  h.render_date(r.request_date)
end

#rmaActiveSupport::SafeBuffer?

Linked Rma number → RMA show page; nil for stand-alone credit memos.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


36
37
38
39
# File 'app/presenters/search/credit_memo_presenter.rb', line 36

def rma
  return nil if r.rma_id.nil?
  h.link_to(r.rma_number, h.rma_path(r.rma_id))
end

#totalString

Credit-memo total formatted in its own currency (negative).

Returns:

  • (String)


62
63
64
# File 'app/presenters/search/credit_memo_presenter.rb', line 62

def total
  h.number_to_currency(r.total, unit: Money::Currency.new(r.currency).symbol)
end