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)


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

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)


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

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

Linked customer name → customer show page.

Returns:

  • (ActiveSupport::SafeBuffer)


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

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)


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

def due_date
  h.render_date r.due_date
end

Linked invoice reference number → invoice show page.

Returns:

  • (ActiveSupport::SafeBuffer)


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

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)


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

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)


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

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)


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

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

#revenueString

Discounted line total formatted as currency.

Returns:

  • (String)


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

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)


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

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

#totalString

Invoice grand total formatted as currency.

Returns:

  • (String)


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

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