Class: Search::OutgoingPaymentPresenter

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

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

#amountObject



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_symbolObject



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

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


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_atObject



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


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_dateObject



50
51
52
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 50

def payment_date
  h.render_date(r.payment_date)
end

#payment_detailsObject



58
59
60
61
62
63
# File 'app/presenters/search/outgoing_payment_presenter.rb', line 58

def payment_details
  h. :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_modalObject



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.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


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


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