Class: Aba::Transaction
- Inherits:
-
Object
- Object
- Aba::Transaction
- Includes:
- Validations
- Defined in:
- lib/aba/transaction.rb
Constant Summary
Constants included from Validations
Validations::BECS_PATTERN, Validations::INDICATORS
Instance Attribute Summary collapse
-
#account_name ⇒ Object
Fall back to empty string.
-
#account_number ⇒ Object
Allow dashes to be input, but remove them from output.
-
#amount ⇒ Object
Fall back to 0.
-
#bsb ⇒ Object
Returns the value of attribute bsb.
-
#indicator ⇒ Object
Fall back to blank string.
-
#lodgement_reference ⇒ Object
Fall back to empty string.
-
#name_of_remitter ⇒ Object
Returns the value of attribute name_of_remitter.
-
#trace_account_number ⇒ Object
Fall back to Account Number.
-
#trace_bsb ⇒ Object
Fall back to BSB.
-
#transaction_code ⇒ Object
Fall back to 50.
-
#witholding_amount ⇒ Object
Returns the value of attribute witholding_amount.
Attributes included from Validations
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ Transaction
constructor
A new instance of Transaction.
- #to_s ⇒ Object
Methods included from Validations
Constructor Details
#initialize(attrs = {}) ⇒ Transaction
Returns a new instance of Transaction.
41 42 43 44 45 |
# File 'lib/aba/transaction.rb', line 41 def initialize(attrs = {}) attrs.each do |key, value| send("#{key}=", value) end end |
Instance Attribute Details
#account_name ⇒ Object
Fall back to empty string
68 69 70 |
# File 'lib/aba/transaction.rb', line 68 def account_name @account_name end |
#account_number ⇒ Object
Allow dashes to be input, but remove them from output
48 49 50 |
# File 'lib/aba/transaction.rb', line 48 def account_number @account_number end |
#amount ⇒ Object
Fall back to 0
63 64 65 |
# File 'lib/aba/transaction.rb', line 63 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
Fall back to blank string
53 54 55 |
# File 'lib/aba/transaction.rb', line 53 def indicator @indicator end |
#lodgement_reference ⇒ Object
Fall back to empty string
73 74 75 |
# File 'lib/aba/transaction.rb', line 73 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 |
#trace_account_number ⇒ Object
Fall back to Account Number
83 84 85 |
# File 'lib/aba/transaction.rb', line 83 def trace_account_number @trace_account_number end |
#trace_bsb ⇒ Object
Fall back to BSB
78 79 80 |
# File 'lib/aba/transaction.rb', line 78 def trace_bsb @trace_bsb end |
#transaction_code ⇒ Object
Fall back to 50
58 59 60 |
# File 'lib/aba/transaction.rb', line 58 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
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/aba/transaction.rb', line 91 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 |