Class: Aba::Transaction

Inherits:
Object
  • Object
show all
Includes:
Validations
Defined in:
lib/aba/transaction.rb

Instance Attribute Summary collapse

Attributes included from Validations

#errors

Instance Method Summary collapse

Methods included from Validations

included, #valid?

Constructor Details

#initialize(attrs = {}) ⇒ Transaction

Returns a new instance of Transaction.



22
23
24
25
26
# File 'lib/aba/transaction.rb', line 22

def initialize(attrs = {})
  attrs.each do |key, value|
    send("#{key}=", value)
  end
end

Instance Attribute Details

#account_name ⇒ Object

Returns the value of attribute account_name.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def 
  @account_name
end

#account_number ⇒ Object

Returns the value of attribute account_number.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def 
  @account_number
end

#amount ⇒ Object

Returns the value of attribute amount.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def amount
  @amount
end

#bsb ⇒ Object

Returns the value of attribute bsb.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def bsb
  @bsb
end

#indicator ⇒ Object

Returns the value of attribute indicator.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def indicator
  @indicator
end

#lodgement_reference ⇒ Object

Returns the value of attribute lodgement_reference.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def lodgement_reference
  @lodgement_reference
end

#name_of_remitter ⇒ Object

Returns the value of attribute name_of_remitter.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def name_of_remitter
  @name_of_remitter
end

#payment_id ⇒ Object

Returns the value of attribute payment_id.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def payment_id
  @payment_id
end

#trace_account_number ⇒ Object

Returns the value of attribute trace_account_number.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def 
  @trace_account_number
end

#trace_bsb ⇒ Object

Returns the value of attribute trace_bsb.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def trace_bsb
  @trace_bsb
end

#transaction_code ⇒ Object

Returns the value of attribute transaction_code.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def transaction_code
  @transaction_code
end

#witholding_amount ⇒ Object

Returns the value of attribute witholding_amount.



5
6
7
# File 'lib/aba/transaction.rb', line 5

def witholding_amount
  @witholding_amount
end

Instance Method Details

#to_s ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/aba/transaction.rb', line 28

def to_s
  # Record type
  output = "1"

  # BSB of account
  output += bsb

  # Account number
  output += .to_s.rjust(9, " ")

  # Withholding Tax Indicator
  # "N" – for new or varied Bank/State/Branch number or name details, otherwise blank filled.
  # "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.abs.to_s.rjust(10, "0")

  # Title of Account
  output += .ljust(32, " ")

  # Lodgement Reference Produced on the recipient’s Account Statement. 
  output += lodgement_reference.ljust(18, " ")     

  # Trace BSB Number
  output += trace_bsb

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

  # Name of Remitter Produced on the recipient’s Account Statement
  output += name_of_remitter.ljust(16, " ")

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