class WageSlave::ABA::DetailRecord

Attributes

account_number[R]
amount[R]
bsb[R]
indicator[R]
lodgement_reference[R]
name[R]
remitter[R]
trace_account[R]
trace_bsb[R]
transaction_code[R]
withholding_amount[R]

Public Class Methods

new(attrs={}) click to toggle source
# File lib/wage_slave/aba/detail_record.rb, line 38
def initialize(attrs={})
  @type                 = "1"
  @bsb                  = attrs[:bsb]
  @account_number       = attrs[:account_number]
  self.indicator        = attrs[:indicator] || "N"
  self.transaction_code = attrs[:transaction_code] || "53"
  @amount               = attrs[:amount].to_i || 0
  @name                 = attrs[:name]
  @lodgement_reference  = attrs[:lodgement_reference] || WageSlave.configuration.user_name
  @trace_bsb            = attrs[:trace_bsb] || WageSlave.configuration.bank_code
  @trace_account        = attrs[:trace_account] || WageSlave.configuration.account_number
  @remitter             = attrs[:remitter] || WageSlave.configuration.user_name
  @withholding_amount   = attrs[:withholding_amount].to_i || 0
end

Public Instance Methods

indicator=(key) click to toggle source
# File lib/wage_slave/aba/detail_record.rb, line 57
def indicator=(key)
  @indicator = key if @@indicators.include? key
end
to_s() click to toggle source

This method was adapted from github.com/andrba/aba which is released under MIT. See /LICENSE.txt for details.

# File lib/wage_slave/aba/detail_record.rb, line 65
def to_s
  raise RuntimeError.new "Detail record is invalid. Check the contents of 'errors'" unless self.valid?

  # Record type
  # Size: 1
  # Char position: 1
  # Must be 1
  output = @type

  # BSB of account
  # Size: 7
  # Char position: 2-8
  # Format: XXX-XXX
  output += @bsb.to_s

  # Account number
  # Size: 9
  # Char position: 9-17
  # Blank filled, right justified.
  output += @account_number.to_s.rjust(9, " ")

  # Indicator
  # Size: 1
  # Char position: 18
  # Valid entries: N, W, X or Y.
  output += @indicator.to_s.ljust(1, " ")

  # Transaction Code
  # Size: 2
  # Char position: 19-20
  output += @transaction_code.to_s

  # Amount to be credited or debited
  # Size: 10
  # Char position: 21-30
  # Numeric only, shown in cents. Right justified, zero filled.
  output += @amount.to_i.abs.to_s.rjust(10, "0")

  # Title of Account
  # Full BECS character set valid
  # Size: 32
  # Char position: 31-62
  # Blank filled, left justified.
  output += @name.to_s.ljust(32, " ")

  # Lodgement Reference Produced on the recipient’s Account Statement.
  # Size: 18
  # Char position: 63-80
  # Full BECS character set valid
  # Blank filled, left justified.
  output += @lodgement_reference.to_s.ljust(18, " ")

  # Trace BSB Number
  # Size: 7
  # Char position: 81-87
  # Format: XXX-XXX
  output += @trace_bsb.to_s

  # Trace Account Number
  # Size: 9
  # Char position: 88-96
  # Blank filled, right justified.
  output += @trace_account.to_s.rjust(9, " ")

  # Name of Remitter Produced on the recipient’s Account Statement
  # Size: 16
  # Char position: 97-112
  # Full BECS character set valid
  # Blank filled, left justified.
  output += @remitter.to_s.ljust(16, " ")

  # Withholding amount in cents
  # Size: 8
  # Char position: 113-120
  # Numeric only, shown in cents. Right justified, zero filled.
  output += @withholding_amount.abs.to_s.rjust(8, "0")
end
transaction_code=(code) click to toggle source
# File lib/wage_slave/aba/detail_record.rb, line 53
def transaction_code=(code)
  @transaction_code = code if @@transaction_codes.include? code
end