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_CURRENCY for cross-currency reporting.
-
#revenue ⇒ String
Discounted line total formatted as currency.
-
#revenue_consolidated ⇒ String
Revenue expressed in CONSOLIDATED_CURRENCY for 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.
21 22 23 |
# File 'app/presenters/search/invoice_presenter.rb', line 21 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.
30 31 32 |
# File 'app/presenters/search/invoice_presenter.rb', line 30 def currency_symbol_consolidated Money::Currency.new(r.consolidated_currency).symbol end |
#customer_link ⇒ ActiveSupport::SafeBuffer
Linked customer name → customer show page.
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_date ⇒ String
Invoice due date rendered through the shared render_date helper
(CRM date formatting).
91 92 93 |
# File 'app/presenters/search/invoice_presenter.rb', line 91 def due_date h.render_date r.due_date end |
#invoice_link ⇒ ActiveSupport::SafeBuffer
Linked invoice reference number → invoice show page.
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 |
#msrp ⇒ String
MSRP-priced line total formatted as currency (uses the same
currency as the invoice — discounts hidden at MSRP view).
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 |
#opportunity_link ⇒ ActiveSupport::SafeBuffer?
Linked opportunity name → opportunity show page; nil when the
invoice has no parent opportunity.
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_consolidated ⇒ String
Profit expressed in CONSOLIDATED_CURRENCY for cross-currency
reporting.
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 |
#revenue ⇒ String
Discounted line total formatted as currency.
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_consolidated ⇒ String
Revenue expressed in CONSOLIDATED_CURRENCY for cross-currency
reporting.
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 |
#total ⇒ String
Invoice grand total formatted as currency.
67 68 69 |
# File 'app/presenters/search/invoice_presenter.rb', line 67 def total h.number_to_currency(r.total, unit: currency_symbol) end |