Class: Search::OutgoingPaymentPresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- Search::OutgoingPaymentPresenter
- Includes:
- Presenters::Timeable
- Defined in:
- app/presenters/search/outgoing_payment_presenter.rb
Overview
Presenter: outgoing payment presenter.
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#amount ⇒ String
Currency-formatted payment amount in USD.
-
#currency_symbol ⇒ String
Always-USD currency symbol — the search index materializes amounts in USD regardless of the payment's native currency.
-
#job_link ⇒ ActiveSupport::SafeBuffer?
Hourglass icon linking to the linked Job, when present.
-
#last_printed_at ⇒ String
Localized cheque-print timestamp.
-
#payee_link ⇒ ActiveSupport::SafeBuffer
Link to the payee Party — same polymorphic dispatch as #supplier_link but rendered red when the payee differs from the supplier (a third-party payment).
-
#payment_date ⇒ String
Localized payment date.
-
#payment_details ⇒ ActiveSupport::SafeBuffer
Button + Bootstrap modal trigger for the payment-items breakdown (#payment_details_modal).
-
#payment_details_modal ⇒ ActiveSupport::SafeBuffer
The modal body that #payment_details pops — renders the
outgoing_payments/payment_items_previewpartial with totals. -
#payment_link ⇒ ActiveSupport::SafeBuffer
Link to the OutgoingPayment detail page.
-
#supplier_link ⇒ ActiveSupport::SafeBuffer
Link to the supplier Party, polymorphic across Supplier / Employee / Contact / Customer.
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
Currency-formatted payment amount in USD.
58 59 60 |
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 58 def amount h.number_to_currency(r.amount, unit: currency_symbol) end |
#currency_symbol ⇒ String
Always-USD currency symbol — the search index materializes
amounts in USD regardless of the payment's native currency.
52 53 54 |
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 52 def currency_symbol Money::Currency.new('USD').symbol end |
#job_link ⇒ ActiveSupport::SafeBuffer?
Hourglass icon linking to the linked Job, when present.
64 65 66 |
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 64 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 ⇒ String
Localized cheque-print timestamp.
76 77 78 |
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 76 def last_printed_at h.render_datetime(r.last_printed_at) end |
#payee_link ⇒ ActiveSupport::SafeBuffer
Link to the payee Party — same polymorphic dispatch as
#supplier_link but rendered red when the payee differs from
the supplier (a third-party payment).
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 35 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 ⇒ String
Localized payment date.
70 71 72 |
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 70 def payment_date h.render_date(r.payment_date) end |
#payment_details ⇒ ActiveSupport::SafeBuffer
Button + Bootstrap modal trigger for the payment-items
breakdown (#payment_details_modal).
83 84 85 86 87 88 |
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 83 def payment_details h.content_tag :span do h.concat h. "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 ⇒ ActiveSupport::SafeBuffer
The modal body that #payment_details pops — renders the
outgoing_payments/payment_items_preview partial with totals.
93 94 95 96 97 98 99 100 101 102 |
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 93 def payment_details_modal h.modal_dialog("payment_details_#{r.id}", nil, true) do h.concat h.modal_dialog_header "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 ⇒ ActiveSupport::SafeBuffer
Link to the OutgoingPayment detail page.
10 11 12 |
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 10 def payment_link h.link_to(r.reference_number, h.outgoing_payment_path(r.id)) end |
#supplier_link ⇒ ActiveSupport::SafeBuffer
Link to the supplier Party, polymorphic across
Supplier / Employee / Contact / Customer.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 17 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 |