Class: Search::VoucherPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::VoucherPresenter
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/voucher_presenter.rb
Overview
Presents voucher search results with HTML links and formatted currency.
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#currency_symbol ⇒ String
Returns the symbol for the voucher currency.
-
#due_date ⇒ String
Returns the due date formatted for display.
-
#gl_date ⇒ String
Returns the GL date formatted for display.
-
#invoice_date ⇒ String
Returns the invoice date formatted for display.
-
#open_amount ⇒ String
Returns the voucher open amount formatted as currency.
-
#payee_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the voucher payee, if available.
-
#supplier_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the voucher's supplier payee.
-
#total ⇒ String
Returns the voucher total formatted as currency.
-
#voucher_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the voucher.
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
Returns the symbol for the voucher currency.
38 39 40 |
# File 'app/presenters/search/voucher_presenter.rb', line 38 def currency_symbol Money::Currency.new('USD').symbol end |
#due_date ⇒ String
Returns the due date formatted for display.
73 74 75 |
# File 'app/presenters/search/voucher_presenter.rb', line 73 def due_date h.render_date(r.due_date) end |
#gl_date ⇒ String
Returns the GL date formatted for display.
66 67 68 |
# File 'app/presenters/search/voucher_presenter.rb', line 66 def gl_date h.render_date(r.gl_date) end |
#invoice_date ⇒ String
Returns the invoice date formatted for display.
59 60 61 |
# File 'app/presenters/search/voucher_presenter.rb', line 59 def invoice_date h.render_date(r.invoice_date) end |
#open_amount ⇒ String
Returns the voucher open amount formatted as currency.
52 53 54 |
# File 'app/presenters/search/voucher_presenter.rb', line 52 def open_amount h.number_to_currency(r.open_amount, unit: currency_symbol) end |
#payee_link ⇒ ActiveSupport::SafeBuffer?
Returns a link to the voucher payee, if available.
80 81 82 83 84 |
# File 'app/presenters/search/voucher_presenter.rb', line 80 def payee_link return unless r.has_columns?(:payee_name, :payee_id) h.link_to(r.payee_name, h.polymorphic_path(r.payee)) end |
#supplier_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the voucher's supplier payee.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/presenters/search/voucher_presenter.rb', line 21 def supplier_link path = case r.supplier_type when 'Supplier' h.supplier_path(r.supplier_id) when 'Employee' h.employee_path(r.supplier_id) when 'Contact' h.contact_path(r.supplier_id) when 'Customer' h.customer_path(r.supplier_id) end h.link_to(r.supplier_name, path) end |
#total ⇒ String
Returns the voucher total formatted as currency.
45 46 47 |
# File 'app/presenters/search/voucher_presenter.rb', line 45 def total h.number_to_currency(r.total, unit: currency_symbol) end |
#voucher_link ⇒ ActiveSupport::SafeBuffer
Returns a link to the voucher.
14 15 16 |
# File 'app/presenters/search/voucher_presenter.rb', line 14 def voucher_link h.link_to(r.reference_number, h.voucher_path(r.id)) end |