class Aba::Transaction

Attributes

account_name[RW]
account_number[RW]
amount[RW]
bsb[RW]
indicator[RW]
lodgement_reference[RW]
name_of_remitter[RW]
trace_account_number[RW]
trace_bsb[RW]
transaction_code[RW]
witholding_amount[RW]

Public Instance Methods

to_s() click to toggle source
# File lib/aba/transaction.rb, line 55
def to_s
  raise RuntimeError, 'Transaction data is invalid - check the contents of `errors`' unless valid?

  # Record type
  output = "1"

  # BSB of account
  output += bsb

  # Account number
  #raise RuntimeError, 'Transaction is missing account_number' unless account_number
  output += account_number.to_s.rjust(9, " ")

  # Withholding Tax Indicator
  # "N" – for new or varied Bank/State/Branch number or name details, otherwise blank filled.
  # "T" - for a drawing under a Transaction Negotiation Authority.
  # "W" – dividend paid to a resident of a country where a double tax agreement is in force.
  # "X" – dividend paid to a resident of any other country.
  # "Y" – interest paid to all non-residents.
  output += indicator.to_s.ljust(1, " ")

  # Transaction Code
  # 50 General Credit.
  # 53 Payroll.
  # 54 Pension.
  # 56 Dividend.
  # 57 Debenture Interest.
  # 13 General Debit.
  output += transaction_code.to_s

  # Amount to be credited or debited
  output += amount.to_i.abs.to_s.rjust(10, "0")

  # Title of Account
  # Full BECS character set valid
  output += account_name.to_s.ljust(32, " ")

  # Lodgement Reference Produced on the recipient’s Account Statement.
  # Full BECS character set valid
  output += lodgement_reference.to_s.ljust(18, " ")

  # Trace BSB Number
  output += trace_bsb

  # Trace Account Number
  output += trace_account_number.to_s.rjust(9, " ")

  # Name of Remitter Produced on the recipient’s Account Statement
  # Full BECS character set valid
  output += name_of_remitter.to_s.ljust(16, " ")

  # Withholding amount in cents
  output += (witholding_amount || 0).abs.to_s.rjust(8, "0")
end