Class: Search::VoucherPresenter

Inherits:
BasePresenter show all
Includes:
Presenters::Timeable
Defined in:
app/presenters/search/voucher_presenter.rb

Overview

Presents voucher search results with HTML links and formatted currency.

See Also:

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

Returns the symbol for the voucher currency.

Returns:

  • (String)

    the currency symbol



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

def currency_symbol
  Money::Currency.new('USD').symbol
end

#due_dateString

Returns the due date formatted for display.

Returns:

  • (String)

    the formatted due date



73
74
75
# File 'app/presenters/search/voucher_presenter.rb', line 73

def due_date
  h.render_date(r.due_date)
end

#gl_dateString

Returns the GL date formatted for display.

Returns:

  • (String)

    the formatted GL date



66
67
68
# File 'app/presenters/search/voucher_presenter.rb', line 66

def gl_date
  h.render_date(r.gl_date)
end

#invoice_dateString

Returns the invoice date formatted for display.

Returns:

  • (String)

    the formatted invoice date



59
60
61
# File 'app/presenters/search/voucher_presenter.rb', line 59

def invoice_date
  h.render_date(r.invoice_date)
end

#open_amountString

Returns the voucher open amount formatted as currency.

Returns:

  • (String)

    the formatted open amount



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

Returns a link to the voucher payee, if available.

Returns:

  • (ActiveSupport::SafeBuffer, nil)

    the payee link, or nil



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

Returns a link to the voucher's supplier payee.

Returns:

  • (ActiveSupport::SafeBuffer)

    the supplier link



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

#totalString

Returns the voucher total formatted as currency.

Returns:

  • (String)

    the formatted total



45
46
47
# File 'app/presenters/search/voucher_presenter.rb', line 45

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

Returns a link to the voucher.

Returns:

  • (ActiveSupport::SafeBuffer)

    the voucher link



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