class Accounting::DecreaseDecorator < Accounting::TransactionDecorator
  def payment_method
    return unless payment?

    details = JSON.parse(payment_detail.details) unless payment_detail.cash?

    case payment_detail.payment.to_sym
    when :cash
      'Cash'
    when :check
      "Check ##{details['check_number']}"
    when :paya_credit_card
      "Credit Card ##{details['paya_credit_card']['last_four']}"
    when :payjunction_ach
      "ACH ##{details['vault']['lastFour']}"
    when :payjunction_credit_card
      "Credit Card ##{details['vault']['lastFour']}"
    end
  end

  def payment_with_currency
    "#{payment_method} - #{currency}"
  end
end
