Class: Search::InvoicePresenter

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

Overview

Row presenter for InvoiceSearch — renders the cells in the
CRM invoice search/results table. Wraps an SQL projection of
Invoice columns rather than a fully-loaded model so the search
grid stays light.

Direct Known Subclasses

InvoiceTextPresenter

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

#currency_symbolString

Currency symbol for the invoice's transaction currency.

Returns:

  • (String)


21
22
23
# File 'app/presenters/search/invoice_presenter.rb', line 21

def currency_symbol
  Money::Currency.new(r.currency).symbol
end

#currency_symbol_consolidatedString

Currency symbol for the consolidated-reporting currency
(CONSOLIDATED_CURRENCY). Used by the consolidated revenue/profit
cells.

Returns:

  • (String)


30
31
32
# File 'app/presenters/search/invoice_presenter.rb', line 30

def currency_symbol_consolidated
  Money::Currency.new(r.consolidated_currency).symbol
end

Linked customer name → customer show page.

Returns:

  • (ActiveSupport::SafeBuffer)


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

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

#due_dateString

Invoice due date rendered through the shared render_date helper
(CRM date formatting).

Returns:

  • (String)


91
92
93
# File 'app/presenters/search/invoice_presenter.rb', line 91

def due_date
  h.render_date r.due_date
end

Linked invoice reference number → invoice show page.

Returns:

  • (ActiveSupport::SafeBuffer)


14
15
16
# File 'app/presenters/search/invoice_presenter.rb', line 14

def invoice_link
  h.link_to(r.reference_number, h.invoice_path(r.id))
end

#msrpString

MSRP-priced line total formatted as currency (uses the same
currency as the invoice — discounts hidden at MSRP view).

Returns:

  • (String)


53
54
55
# File 'app/presenters/search/invoice_presenter.rb', line 53

def msrp
  h.number_to_currency(r.line_total_msrp, unit: currency_symbol)
end

Linked opportunity name → opportunity show page; nil when the
invoice has no parent opportunity.

Returns:

  • (ActiveSupport::SafeBuffer, nil)


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

def opportunity_link
  h.link_to(r.opportunity_name, h.opportunity_path(r.opportunity_id)) if r.opportunity_id
end

#profit_consolidatedString

Profit expressed in CONSOLIDATED_CURRENCY for cross-currency
reporting.

Returns:

  • (String)


83
84
85
# File 'app/presenters/search/invoice_presenter.rb', line 83

def profit_consolidated
  h.number_to_currency(r.profit_consolidated, unit: currency_symbol_consolidated)
end

#revenueString

Discounted line total formatted as currency.

Returns:

  • (String)


60
61
62
# File 'app/presenters/search/invoice_presenter.rb', line 60

def revenue
  h.number_to_currency(r.line_total, unit: currency_symbol)
end

#revenue_consolidatedString

Revenue expressed in CONSOLIDATED_CURRENCY for cross-currency
reporting.

Returns:

  • (String)


75
76
77
# File 'app/presenters/search/invoice_presenter.rb', line 75

def revenue_consolidated
  h.number_to_currency(r.revenue_consolidated, unit: currency_symbol_consolidated)
end

#totalString

Invoice grand total formatted as currency.

Returns:

  • (String)


67
68
69
# File 'app/presenters/search/invoice_presenter.rb', line 67

def total
  h.number_to_currency(r.total, unit: currency_symbol)
end