ach 0.5.13 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/ach/ach_file.rb +12 -11
- data/lib/ach/batch.rb +11 -1
- data/lib/ach/field_identifiers.rb +1 -1
- data/lib/ach/records/entry_detail.rb +12 -2
- data/lib/ach/records/file_control.rb +4 -3
- data/lib/ach/records/record.rb +1 -1
- data/lib/ach/version.rb +1 -1
- data/lib/ach.rb +6 -0
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c8950b0833382bb80f3ebf7b9e0e2702aece4ee0de2f385c4c9e5dbd4a7d1157
|
4
|
+
data.tar.gz: ce02f3a9a926be32cc72f8a986c308e4ceee7ceb617c487bc915ca20d6efa901
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84465c6a64caeead398a541d7110ee473ce1cdd11a1c200a3b9f975813a2898e7d904ceaebc68e7d16cc5c880d9b27d5497f7930d5a28e8b7563038a9a3e1ede
|
7
|
+
data.tar.gz: dfc53a158083ef3559583b1f2e613f8fdd0f76ea38434345773d95af8875bc0d195b9ec560e1202cfcc8eeb742e1a923458fa0d052612132bcc57ec881f63c5b
|
data/lib/ach/ach_file.rb
CHANGED
@@ -14,7 +14,7 @@ module ACH
|
|
14
14
|
@control = Records::FileControl.new
|
15
15
|
|
16
16
|
if data
|
17
|
-
if (data.encode(Encoding.find('ASCII'),ENCODING_OPTIONS) =~ /\n|\r\n/).nil?
|
17
|
+
if (data.encode(Encoding.find('ASCII'), **ENCODING_OPTIONS) =~ /\n|\r\n/).nil?
|
18
18
|
parse_fixed(data)
|
19
19
|
else
|
20
20
|
parse(data)
|
@@ -22,8 +22,9 @@ module ACH
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
|
25
26
|
# @param eol [String] Line ending, default to CRLF
|
26
|
-
def to_s eol =
|
27
|
+
def to_s eol = ACH.eol
|
27
28
|
records = []
|
28
29
|
records << @header
|
29
30
|
|
@@ -33,16 +34,14 @@ module ACH
|
|
33
34
|
end
|
34
35
|
records << @control
|
35
36
|
|
36
|
-
records_count = records.
|
37
|
-
sum + record.records_count
|
38
|
-
end
|
39
|
-
|
37
|
+
records_count = records.map(&:records_count).reduce(:+)
|
40
38
|
nines_needed = (10 - records_count) % 10
|
41
39
|
nines_needed = nines_needed % 10
|
42
40
|
nines_needed.times { records << Records::Nines.new() }
|
43
41
|
|
42
|
+
records_count = records.map(&:records_count).reduce(:+)
|
44
43
|
@control.batch_count = @batches.length
|
45
|
-
@control.block_count = (
|
44
|
+
@control.block_count = (records_count / 10).ceil
|
46
45
|
|
47
46
|
@control.entry_count = 0
|
48
47
|
@control.debit_total = 0
|
@@ -56,10 +55,10 @@ module ACH
|
|
56
55
|
@control.entry_hash += batch.control.entry_hash
|
57
56
|
end
|
58
57
|
|
59
|
-
records.collect { |r| r.to_ach }.join(eol) + eol
|
58
|
+
records.collect { |r| r.to_ach(eol: eol) }.join(eol) + eol
|
60
59
|
end
|
61
60
|
|
62
|
-
def report
|
61
|
+
def report eol: ACH.eol
|
63
62
|
to_s # To ensure correct records
|
64
63
|
lines = []
|
65
64
|
|
@@ -75,7 +74,7 @@ module ACH
|
|
75
74
|
lines << left_justify("Credit Total: ", 25) +
|
76
75
|
sprintf("% 7d.%02d", @control.credit_total / 100, @control.credit_total % 100)
|
77
76
|
|
78
|
-
lines.join(
|
77
|
+
lines.join(eol)
|
79
78
|
end
|
80
79
|
|
81
80
|
def parse_fixed data
|
@@ -106,6 +105,7 @@ module ACH
|
|
106
105
|
batch = ACH::Batch.new
|
107
106
|
bh = batch.header
|
108
107
|
bh.company_name = line[4..19].strip
|
108
|
+
bh.company_discretionary_data = line[20..39].strip
|
109
109
|
bh.company_identification = line[40..49].gsub(/\A1/, '')
|
110
110
|
|
111
111
|
# Does not try to guess if company identification is an EIN
|
@@ -146,7 +146,8 @@ module ACH
|
|
146
146
|
when '8'
|
147
147
|
# skip
|
148
148
|
when '9'
|
149
|
-
|
149
|
+
@control = Records::FileControl.new
|
150
|
+
@control.filler = line[55..93]
|
150
151
|
else
|
151
152
|
raise UnrecognizedTypeCode, "Didn't recognize type code #{type} for this line:\n#{line}"
|
152
153
|
end
|
data/lib/ach/batch.rb
CHANGED
@@ -14,7 +14,7 @@ module ACH
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def to_ach
|
17
|
-
@control.entry_count = @entries.
|
17
|
+
@control.entry_count = @entries.map(&:records_count).reduce(:+).to_i
|
18
18
|
@control.debit_total = 0
|
19
19
|
@control.credit_total = 0
|
20
20
|
@control.entry_hash = 0
|
@@ -51,8 +51,18 @@ module ACH
|
|
51
51
|
@control.company_identification = @header.company_identification
|
52
52
|
@control.originating_dfi_identification = @header.originating_dfi_identification
|
53
53
|
@control.batch_number = @header.batch_number
|
54
|
+
if last_entry.is_a? ACH::BalancingEntryDetail
|
55
|
+
@control.credit_total = last_entry.amount
|
56
|
+
@control.debit_total = last_entry.amount
|
57
|
+
end
|
54
58
|
|
55
59
|
[@header] + @entries + @addendas + [@control]
|
56
60
|
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def last_entry
|
65
|
+
@last_entry ||= @entries.last
|
66
|
+
end
|
57
67
|
end
|
58
68
|
end
|
@@ -54,7 +54,7 @@ module ACH::Records
|
|
54
54
|
return !self.addenda.empty?
|
55
55
|
end
|
56
56
|
|
57
|
-
def to_ach
|
57
|
+
def to_ach eol: ACH.eol
|
58
58
|
self.addenda_record_indicator = (self.addenda.empty? ? 0 : 1) if self.respond_to?(:addenda_record_indicator)
|
59
59
|
self.number_of_addenda_records = self.addenda.length if self.respond_to?(:number_of_addenda_records)
|
60
60
|
|
@@ -62,7 +62,7 @@ module ACH::Records
|
|
62
62
|
|
63
63
|
self.addenda.each {|a|
|
64
64
|
a.entry_detail_sequence_number = self.trace_number
|
65
|
-
ach_string <<
|
65
|
+
ach_string << eol + a.to_ach
|
66
66
|
}
|
67
67
|
return ach_string
|
68
68
|
end
|
@@ -85,4 +85,14 @@ module ACH::Records
|
|
85
85
|
nil, nil, /\A\d{8}\z/
|
86
86
|
field :trace_number, Integer, lambda { |f| sprintf('%07d', f)}
|
87
87
|
end
|
88
|
+
|
89
|
+
class BalancingEntryDetail < EntryDetail
|
90
|
+
@fields = EntryDetail.fields.slice(0, 5)
|
91
|
+
const_field :individual_id_number, (' ' * 15)
|
92
|
+
field :account_description, String, lambda { |f| left_justify(f, 22)}
|
93
|
+
field :discretionary_data, String, lambda { |f| left_justify(f, 2)}, ' '
|
94
|
+
field :addenda_record_indicator, Integer, lambda { |f| sprintf('%01d', f)}, 0
|
95
|
+
field :origin_routing_number, String, lambda { |f| sprintf('%08d', f.to_i) }
|
96
|
+
field :trace_number, Integer, lambda { |f| sprintf('%07d', f)}
|
97
|
+
end
|
88
98
|
end
|
@@ -1,17 +1,18 @@
|
|
1
1
|
module ACH::Records
|
2
2
|
class FileControl < Record
|
3
3
|
@fields = []
|
4
|
-
|
4
|
+
|
5
5
|
const_field :record_type, '9'
|
6
6
|
# Many of the fields are calculated in ACHFile.to_ach
|
7
7
|
field :batch_count, Integer, lambda { |f| sprintf('%06d', f)}
|
8
8
|
field :block_count, Integer, lambda { |f| sprintf('%06d', f)}
|
9
9
|
field :entry_count, Integer, lambda { |f| sprintf('%08d', f)}
|
10
10
|
field :entry_hash, Integer, lambda { |f| sprintf('%010d', f % (10 ** 10))}
|
11
|
-
|
11
|
+
|
12
12
|
field :debit_total, Integer, lambda { |f| sprintf('%012d', f)}
|
13
13
|
field :credit_total, Integer, lambda { |f| sprintf('%012d', f)}
|
14
|
-
|
14
|
+
|
15
|
+
field :filler, String, lambda { |f| left_justify(f, 39)}, ' '
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
data/lib/ach/records/record.rb
CHANGED
data/lib/ach/version.rb
CHANGED
data/lib/ach.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ach
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Morgan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: appraisal
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 12.3.3
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 12.3.3
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
|
-
|
129
|
-
rubygems_version: 2.5.2.3
|
128
|
+
rubygems_version: 3.0.3
|
130
129
|
signing_key:
|
131
130
|
specification_version: 4
|
132
131
|
summary: Helper for building ACH files
|