Class: Search::ReceiptPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::ReceiptPresenter
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/receipt_presenter.rb
Overview
Row presenter for ReceiptSearch — renders the cells in the CRM receipt
search/results table. Wraps a ViewReceipt projection rather than a
fully-loaded Receipt so the search grid stays light.
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#amount ⇒ String
Receipt amount formatted as currency.
-
#currency_symbol ⇒ String
Currency symbol for the receipt amount (USD).
-
#customer_link ⇒ ActiveSupport::SafeBuffer
Linked customer/supplier/employee/contact name → the appropriate show page based on the receipt's customer type.
-
#gl_date ⇒ String
General ledger date rendered through the shared
render_datehelper. -
#receipt_date ⇒ String
Receipt date rendered through the shared
render_datehelper. -
#receipt_link ⇒ ActiveSupport::SafeBuffer
Linked receipt ID → receipt show page.
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
#amount ⇒ String
Receipt amount formatted as currency.
46 47 48 |
# File 'app/presenters/search/receipt_presenter.rb', line 46 def amount h.number_to_currency(r.amount, unit: currency_symbol) end |
#currency_symbol ⇒ String
Currency symbol for the receipt amount (USD).
39 40 41 |
# File 'app/presenters/search/receipt_presenter.rb', line 39 def currency_symbol Money::Currency.new('USD').symbol end |
#customer_link ⇒ ActiveSupport::SafeBuffer
Linked customer/supplier/employee/contact name → the appropriate show page
based on the receipt's customer type.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/presenters/search/receipt_presenter.rb', line 22 def customer_link path = case r.customer_type when 'Supplier' h.supplier_path(r.customer_id) when 'Employee' h.employee_path(r.customer_id) when 'Contact' h.contact_path(r.customer_id) when 'Customer' h.customer_path(r.customer_id) end h.link_to(r.customer_name, path) end |
#gl_date ⇒ String
General ledger date rendered through the shared render_date helper.
60 61 62 |
# File 'app/presenters/search/receipt_presenter.rb', line 60 def gl_date h.render_date(r.gl_date) end |
#receipt_date ⇒ String
Receipt date rendered through the shared render_date helper.
53 54 55 |
# File 'app/presenters/search/receipt_presenter.rb', line 53 def receipt_date h.render_date(r.receipt_date) end |
#receipt_link ⇒ ActiveSupport::SafeBuffer
Linked receipt ID → receipt show page.
14 15 16 |
# File 'app/presenters/search/receipt_presenter.rb', line 14 def receipt_link h.link_to(r.id, h.receipt_path(r.id)) end |