Class: Search::InvoicePresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::InvoicePresenter
- 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
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#currency_symbol ⇒ String
Currency symbol for the invoice's transaction currency.
-
#currency_symbol_consolidated ⇒ String
Currency symbol for the consolidated-reporting currency (
CONSOLIDATED_CURRENCY). -
#customer_link ⇒ ActiveSupport::SafeBuffer
Linked customer name → customer show page.
-
#due_date ⇒ String
Invoice due date rendered through the shared
render_datehelper (CRM date formatting). -
#invoice_link ⇒ ActiveSupport::SafeBuffer
Linked invoice reference number → invoice show page.
-
#msrp ⇒ String
MSRP-priced line total formatted as currency (uses the same currency as the invoice — discounts hidden at MSRP view).
-
#opportunity_link ⇒ ActiveSupport::SafeBuffer?
Linked opportunity name → opportunity show page; nil when the invoice has no parent opportunity.
-
#profit_consolidated ⇒ String
Profit expressed in
CONSOLIDATED_CURRENCYfor cross-currency reporting. -
#revenue ⇒ String
Discounted line total formatted as currency.
-
#revenue_consolidated ⇒ String
Revenue expressed in
CONSOLIDATED_CURRENCYfor cross-currency reporting. -
#total ⇒ String
Invoice grand total formatted as currency.
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_symbol ⇒ String
Currency symbol for the invoice's transaction currency.
22 23 24 |
# File 'app/presenters/search/invoice_presenter.rb', line 22 def currency_symbol Money::Currency.new(r.currency).symbol end |
#currency_symbol_consolidated ⇒ String
Currency symbol for the consolidated-reporting currency
(CONSOLIDATED_CURRENCY). Used by the consolidated revenue/profit
cells.
31 32 33 |
# File 'app/presenters/search/invoice_presenter.rb', line 31 def currency_symbol_consolidated Money::Currency.new(r.consolidated_currency).symbol end |
#customer_link ⇒ ActiveSupport::SafeBuffer
Linked customer name → customer show page.
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_date ⇒ String
Invoice due date rendered through the shared render_date helper
(CRM date formatting).
92 93 94 |
# File 'app/presenters/search/invoice_presenter.rb', line 92 def due_date h.render_date r.due_date end |
#invoice_link ⇒ ActiveSupport::SafeBuffer
Linked invoice reference number → invoice show page.
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 |
#msrp ⇒ String
MSRP-priced line total formatted as currency (uses the same
currency as the invoice — discounts hidden at MSRP view).
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 |
#opportunity_link ⇒ ActiveSupport::SafeBuffer?
Linked opportunity name → opportunity show page; nil when the
invoice has no parent opportunity.
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_consolidated ⇒ String
Profit expressed in CONSOLIDATED_CURRENCY for cross-currency
reporting.
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 |
#revenue ⇒ String
Discounted line total formatted as currency.
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_consolidated ⇒ String
Revenue expressed in CONSOLIDATED_CURRENCY for cross-currency
reporting.
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 |
#total ⇒ String
Invoice grand total formatted as currency.
68 69 70 |
# File 'app/presenters/search/invoice_presenter.rb', line 68 def total h.number_to_currency(r.total, unit: currency_symbol) end |