Class: WageSlave::ABA

Inherits:
Object
  • Object
show all
Defined in:
lib/wage_slave/aba.rb,
lib/wage_slave/aba/record.rb,
lib/wage_slave/aba/detail_record.rb,
lib/wage_slave/aba/detail_collection.rb,
lib/wage_slave/aba/descriptive_record.rb,
lib/wage_slave/validators/detail_record_validator.rb,
lib/wage_slave/validators/descriptive_record_validator.rb

Defined Under Namespace

Classes: DescriptiveRecord, DescriptiveRecordValidator, DetailCollection, DetailRecord, DetailRecordValidator, Record

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transactions = []) ⇒ ABA

Returns a new instance of ABA.



6
7
8
9
# File 'lib/wage_slave/aba.rb', line 6

def initialize(transactions = [])
  @descriptive_record = WageSlave::ABA::DescriptiveRecord.new
  @details = WageSlave::ABA::DetailCollection.new(transactions)
end

Instance Attribute Details

#descriptive_recordObject (readonly)

Returns the value of attribute descriptive_record.



4
5
6
# File 'lib/wage_slave/aba.rb', line 4

def descriptive_record
  @descriptive_record
end

#detailsObject (readonly)

Returns the value of attribute details.



4
5
6
# File 'lib/wage_slave/aba.rb', line 4

def details
  @details
end

Instance Method Details

#to_sObject

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



15
16
17
18
19
20
21
22
23
24
25
26
27
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
# File 'lib/wage_slave/aba.rb', line 15

def to_s
  output = @descriptive_record.to_s + "\r\n"
  output += @details.to_s + "\r\n"

  # Record Type
  # Size: 1
  # Char position: 1
  # Must be 7
  output += "7"

  # BSB format filler
  # Size: 7
  # Char position: 2-8
  # Must be 999-999
  output += "999-999"

  # Reserved
  # Size: 12
  # Char position: 9-20
  # Blank filled
  output += " " * 12

  # Net total amount
  # Size: 10
  # Char position: 21-30
  # Right justified, zero filled.
  output += @details.net_total.abs.to_s.rjust(10, "0")

  # Credit total amount
  # Size: 10
  # Char position: 31-40
  # Right justified, zero filled.
  output += @details.credit_total.abs.to_s.rjust(10, "0")

  # Debit total amount
  # Size: 10
  # Char position: 41-50
  # Right justified, zero filled.
  output += @details.debit_total.abs.to_s.rjust(10, "0")

  # Reserved
  # Size: 24
  # Char position: 51-74
  # Blank filled
  output += " " * 24

  # Count of Type 1 records
  # Size: 6
  # Char position: 75-80
  # Right justified, zero filled.
  output += @details.size.to_s.rjust(6, "0")

  # Reserved
  # Size: 40
  # Char position: 81-120
  # Blank filled
  output += " " * 40
end