Module: OutgoingPaymentsHelper
- Defined in:
- app/helpers/outgoing_payments_helper.rb
Overview
== Schema Information
Table name: payments
id :integer not null, primary key
category :string(255)
company_id :integer
supplier_id :integer
reference_number :string(255)
amount :decimal(10, 2)
payment_date :date
currency :string(255)
bank_account_id :integer
exchange_rate :float
state :string(255)
remark :text
creator_id :integer
updater_id :integer
created_at :datetime
updated_at :datetime
check_state :string(255)
job_id :string(255)
reversal_date :date
Constant Summary collapse
- PAYMENT_STATE_BADGES =
Payment state badges.
{ 'draft' => 'text-bg-secondary', 'applied' => 'text-bg-success', 'voided' => 'text-bg-danger' }.freeze
- PAYMENT_CATEGORY_BADGES =
Payment category badges.
{ 'ach' => %w[text-bg-primary arrows-left-right], 'cash' => %w[text-bg-secondary money-bill], 'check' => %w[text-bg-info money-check], 'debit_card' => %w[text-bg-dark credit-card], 'e_billpay' => %w[text-bg-secondary file-invoice], 'non_cash' => %w[text-bg-secondary ban], 'paypal' => %w[text-bg-warning paypal], 'wire_transfer' => %w[text-bg-primary building-columns] }.freeze
- CHECK_STATE_BADGES =
Check state badges.
{ 'pending_review' => 'text-bg-warning', 'queued' => 'text-bg-primary', 'generated' => 'text-bg-info', 'printed' => 'text-bg-success', 'reprinted' => 'text-bg-secondary' }.freeze
Instance Method Summary collapse
- #check_audit_history(check) ⇒ Object
- #check_command_options(payment, check) ⇒ Object
- #check_state_badge(state) ⇒ Object
- #outgoing_payment_command_options(payment) ⇒ Object
- #payment_category_badge(category) ⇒ Object
- #payment_state_badge(state) ⇒ Object
Instance Method Details
#check_audit_history(check) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'app/helpers/outgoing_payments_helper.rb', line 103 def check_audit_history(check) links = [] links << check.last_printed_by.try(:full_name) if check.last_printed_by check.print_audit.each do |audit| date_parsed = begin Time.zone.parse(audit[:printed_on]) rescue StandardError nil end links << { tag: :span, content: "Printed by #{audit[:printed_by]} on #{date_parsed&.to_fs(:crm_default)}", class: 'mb-0 px-2', style: 'white-space:nowrap' } end links end |
#check_command_options(payment, check) ⇒ Object
96 97 98 99 100 101 |
# File 'app/helpers/outgoing_payments_helper.rb', line 96 def (payment, check) links = [] links << link_to("Print", print_check_outgoing_payment_path(payment, check_id: check.id)) unless check.uploads.empty? links << link_to("Preview Pdf", check_path(check, format: :pdf)) if user_has_role?("accounting_rep") links end |
#check_state_badge(state) ⇒ Object
68 69 70 71 72 73 |
# File 'app/helpers/outgoing_payments_helper.rb', line 68 def check_state_badge(state) return nil if state.blank? css = CHECK_STATE_BADGES.fetch(state.to_s, 'text-bg-secondary') content_tag(:span, state.to_s.humanize, class: "badge #{css}") end |
#outgoing_payment_command_options(payment) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/helpers/outgoing_payments_helper.rb', line 75 def (payment) links = [] links << if payment.category == 'check' && !payment.voided? fa_icon('shuffle', text: "#{payment.human_state_name.titleize} and #{payment.human_check_state_name.titleize}") else fa_icon('shuffle', text: payment.human_state_name.titleize) end links << link_to("Edit", edit_outgoing_payment_path(payment)) unless @outgoing_payment.editing_locked? links << link_to("Pay Items", pay_items_outgoing_payment_path(@outgoing_payment)) if @outgoing_payment.draft? links << link_to("Approve Check", approve_check_outgoing_payment_path(@outgoing_payment)) if @outgoing_payment.pending_review? && !@outgoing_payment.voided? if payment.can_print_check? unless payment.checks.any? && payment.checks.all? { |c| c.uploads.empty? } links << link_to(payment.checks.any? ? "Reprint Check" : "Print Check", print_check_outgoing_payment_path(payment)) end end links << link_to("Void", void_outgoing_payment_path(@outgoing_payment), data: { turbo_confirm: "Are you sure you want to void this payment? Any linked vouchers or credit memos will be marked as unpaid." }) unless @outgoing_payment.voided? links << link_to("Reverse", reverse_outgoing_payment_path(@outgoing_payment)) unless @outgoing_payment.voided? links << link_to("Delete", payment, data: { turbo_confirm: "Are you sure you want to delete this payment?", turbo_method: :delete }) if payment.draft? links end |
#payment_category_badge(category) ⇒ Object
61 62 63 64 65 66 |
# File 'app/helpers/outgoing_payments_helper.rb', line 61 def payment_category_badge(category) css, icon = PAYMENT_CATEGORY_BADGES.fetch(category.to_s, %w[text-bg-secondary circle-dollar]) tag.span(class: "badge #{css} d-inline-flex align-items-center gap-1") do fa_icon(icon, family: :regular, text: category.to_s.humanize) end end |
#payment_state_badge(state) ⇒ Object
56 57 58 59 |
# File 'app/helpers/outgoing_payments_helper.rb', line 56 def payment_state_badge(state) css = PAYMENT_STATE_BADGES.fetch(state.to_s, 'text-bg-secondary') content_tag(:span, state.to_s.humanize, class: "badge #{css}") end |