Class: Search::OutgoingPaymentPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::OutgoingPaymentPresenter
show all
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/outgoing_payment_presenter.rb
Instance Attribute Summary
#current_account, #options, #url_helper
Instance Method Summary
collapse
#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 ⇒ Object
42
43
44
|
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 42
def amount
h.number_to_currency(r.amount, unit: currency_symbol)
end
|
#currency_symbol ⇒ Object
38
39
40
|
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 38
def currency_symbol
Money::Currency.new('USD').symbol
end
|
#job_link ⇒ Object
46
47
48
|
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 46
def job_link
r.job_id.nil? ? nil : h.link_to(h.fa_icon("hourglass-half"), h.job_path(r.job_id))
end
|
#last_printed_at ⇒ Object
54
55
56
|
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 54
def last_printed_at
h.render_datetime(r.last_printed_at)
end
|
#payee_link ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 24
def payee_link
path = case r.payee_type
when 'Supplier'
h.supplier_path(r.payee_id)
when 'Employee'
h.employee_path(r.payee_id)
when 'Contact'
h.contact_path(r.payee_id)
when 'Customer'
h.customer_path(r.payee_id)
end
h.link_to(r.payee_name, path, style: r.payee_id == r.supplier_id ? '' : 'color:red')
end
|
#payment_date ⇒ Object
50
51
52
|
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 50
def payment_date
h.render_date(r.payment_date)
end
|
#payment_details ⇒ Object
58
59
60
61
62
63
|
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 58
def payment_details
h.content_tag :span do
h.concat h.button_tag "Details", class: 'btn btn-outline-primary', 'data-bs-toggle': 'modal', 'data-bs-target': "#payment_details_#{r.id}"
h.concat payment_details_modal
end
end
|
#payment_details_modal ⇒ Object
65
66
67
68
69
70
71
72
73
|
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 65
def payment_details_modal
h.modal_dialog("payment_details_#{r.id}", nil, true) do
h.concat h. "Payment Details"
body = h.modal_dialog_body do
h.render partial: "outgoing_payments/payment_items_preview", locals: {outgoing_payment: r.outgoing_payment, outgoing_payment_items: r.outgoing_payment_items, total_gross: r.outgoing_payment_items.to_a.sum(&:gross_amount), total_payment: r.outgoing_payment_items.to_a.sum(&:amount)}
end
h.concat body
end
end
|
#payment_link ⇒ Object
6
7
8
|
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 6
def payment_link
h.link_to(r.reference_number, h.outgoing_payment_path(r.id))
end
|
#supplier_link ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 10
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
|