ach 0.4.8 → 0.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NzUzNDkyMzc0ZDk4ODk2MzhjZTY0MGE5Y2ZlMmFkNmE0NjZiNjVjNw==
5
- data.tar.gz: !binary |-
6
- YzQ4ZGQ1MTAwNGYwOTAxZTFlZDk1OGFkMjJhNDgzNGNiNzBjNWJiYQ==
2
+ SHA1:
3
+ metadata.gz: c4049660c0f3f3ed764549f2ca4841153182b687
4
+ data.tar.gz: 4e0965b436351a9fa3b6362483e98a02b3a5791c
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MjUwMTUwM2U4NmFkZDI3ZGVjMTgzMDRhZWZkNWMzY2IwYTJiNjU4MjA3YjU2
10
- MzYwYjVhYzdkMDVmZDVlMzEyZDEwNWM0YmY4YTU3ODhiMjhmZTgxMWYwOGQ5
11
- NmE0NjQxN2RjNTNhODIyYTg4ZWJjYTE5N2NlZTJiNmRhYjYyOGI=
12
- data.tar.gz: !binary |-
13
- ODFmY2MzYmM3NTlkMWMwNWU2OTAzYmU1ZTRlZDgyMGMzNzVlZmE5YjE0YzBj
14
- NmZjNjhlN2VlNTI0MjNiYzU5NDZhZDU3YWNmYWU1MDFlODBmMGQzMmE4MGQ0
15
- ZWQxZjI0ZWQxNjkwNTJlOWUyMjEwZDg5MmQ2OTViYzJiNDEzODY=
6
+ metadata.gz: 40dcf0cbeb86791665f58c43dd5caa6c53397dc1f3c31193e412aab997069f3ddc170d116645912528e7ffabeb8c1f4a46f00daa8af2d87946f96088cc913825
7
+ data.tar.gz: 1bcd9d3197f705d6ff97aa4556956494efd58b1ac48e7a2ffa7c9170a0403646e136a22748eeb047e0db318220cb5db6c19c7750f3f3883529899ac1b1b7ddd4
data/README.md CHANGED
@@ -16,6 +16,8 @@ You should consult a copy of the [ACH Rules](http://www.nacha.org) for details
16
16
  on individual fields. You can probably obtain a copy from your bank.
17
17
 
18
18
  ```ruby
19
+ require 'ach'
20
+
19
21
  # Create ACH file
20
22
  ach = ACH::ACHFile.new
21
23
  trace_number = 0
@@ -76,7 +76,6 @@ module ACH
76
76
  end
77
77
 
78
78
  def parse data
79
- trace_number = 0
80
79
  fh = self.header
81
80
  batch = nil
82
81
  bh = nil
@@ -140,7 +139,6 @@ module ACH
140
139
  end
141
140
 
142
141
  self.batches << batch unless batch.nil?
143
- batch.entries.each{ |entry| entry.trace_number = (trace_number += 1) }
144
142
  to_s
145
143
  end
146
144
  end
@@ -25,7 +25,8 @@ module ACH::Records
25
25
  lambda { Time.now }
26
26
  field :effective_entry_date, Time,
27
27
  lambda { |f| f.strftime('%y%m%d')}
28
- const_field :settlement_date, ' '
28
+ field :settlement_date, String,
29
+ lambda { |f| f.to_s }, ' ', /\A([0-9]{3}| {3})\z/
29
30
  const_field :originator_status_code, '1'
30
31
  field :originating_dfi_identification, String,
31
32
  nil, nil, /\A\d{8}\z/
@@ -1,4 +1,6 @@
1
1
  module ACH::Records
2
+ # PPD Entry Detail. Some other entry details, such as CCD, are close enough
3
+ # to use this class. Version 1.x will have support for other types.
2
4
  class EntryDetail < Record
3
5
  CREDIT_RECORD_TRANSACTION_CODE_ENDING_DIGITS = ["0", "1", "2", "3", "4"]
4
6
 
@@ -18,6 +20,13 @@ module ACH::Records
18
20
  field :discretionary_data, String, lambda { |f| left_justify(f, 2)}, ' '
19
21
  field :addenda_record_indicator, Integer,
20
22
  lambda { |f| sprintf('%01d', f)}, 0
23
+ # There's not actually an originating DFI identification field for PPD
24
+ # entries. Instead, it is suggested by the ACH spec that the ODFI be used
25
+ # as the first 8 digits of the 15-digit trace number. I (Jared Morgan)
26
+ # initially decided to treat the two elements of the trace number as
27
+ # diffent fields, but that has caused confusion. I now intend to make this
28
+ # an optional field which can used in generating the trace number, although
29
+ # I haven't actually worked out how that will function.
21
30
  field :originating_dfi_identification, String,
22
31
  nil, nil, /\A\d{8}\z/
23
32
  field :trace_number, Integer, lambda { |f| sprintf('%07d', f)}, nil,
@@ -1,3 +1,3 @@
1
1
  module ACH
2
- VERSION = '0.4.8'.freeze
2
+ VERSION = '0.4.9'.freeze
3
3
  end
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.8
4
+ version: 0.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Morgan
@@ -9,34 +9,34 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-14 00:00:00.000000000 Z
12
+ date: 2015-01-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ! '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ! '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rspec
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '2.0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '2.0'
42
42
  description: ach is a Ruby helper for building and parsing ACH files. In particular,
@@ -51,7 +51,6 @@ files:
51
51
  - README.md
52
52
  - lib/ach.rb
53
53
  - lib/ach/ach_file.rb
54
- - lib/ach/ach_file.rb.orig
55
54
  - lib/ach/batch.rb
56
55
  - lib/ach/field_identifiers.rb
57
56
  - lib/ach/records/addendum.rb
@@ -72,17 +71,17 @@ require_paths:
72
71
  - lib
73
72
  required_ruby_version: !ruby/object:Gem::Requirement
74
73
  requirements:
75
- - - ! '>='
74
+ - - ">="
76
75
  - !ruby/object:Gem::Version
77
76
  version: '0'
78
77
  required_rubygems_version: !ruby/object:Gem::Requirement
79
78
  requirements:
80
- - - ! '>='
79
+ - - ">="
81
80
  - !ruby/object:Gem::Version
82
81
  version: '0'
83
82
  requirements: []
84
83
  rubyforge_project:
85
- rubygems_version: 2.2.0
84
+ rubygems_version: 2.2.2
86
85
  signing_key:
87
86
  specification_version: 4
88
87
  summary: Helper for building ACH files
@@ -1,150 +0,0 @@
1
- require 'date'
2
-
3
- module ACH
4
- class ACHFile
5
- include FieldIdentifiers
6
-
7
- attr_reader :batches
8
- attr_reader :header
9
- attr_reader :control
10
-
11
- def initialize data=nil
12
- @batches = []
13
- @header = Records::FileHeader.new
14
- @control = Records::FileControl.new
15
-
16
- if data
17
- if (data =~ /\n|\r\n/).nil?
18
- parse_fixed(data)
19
- else
20
- parse(data)
21
- end
22
- end
23
- end
24
-
25
- def to_s
26
- records = []
27
- records << @header
28
- @batches.each { |b| records += b.to_ach }
29
- records << @control
30
-
31
- nines_needed = 10 - (records.length % 10)
32
- nines_needed = nines_needed % 10
33
- nines_needed.times { records << Records::Nines.new() }
34
-
35
- @control.batch_count = @batches.length
36
- @control.block_count = (records.length / 10).ceil
37
-
38
- @control.entry_count = 0
39
- @control.debit_total = 0
40
- @control.credit_total = 0
41
- @control.entry_hash = 0
42
-
43
- @batches.each do | batch |
44
- @control.entry_count += batch.entries.length
45
- @control.debit_total += batch.control.debit_total
46
- @control.credit_total += batch.control.credit_total
47
- @control.entry_hash += batch.control.entry_hash
48
- end
49
-
50
-
51
- records.collect { |r| r.to_ach }.join("\r\n") + "\r\n"
52
- end
53
-
54
- def report
55
- to_s # To ensure correct records
56
- lines = []
57
-
58
- @batches.each do | batch |
59
- batch.entries.each do | entry |
60
- lines << left_justify(entry.individual_name + ": ", 25) +
61
- sprintf("% 7d.%02d", entry.amount / 100, entry.amount % 100)
62
- end
63
- end
64
- lines << ""
65
- lines << left_justify("Debit Total: ", 25) +
66
- sprintf("% 7d.%02d", @control.debit_total / 100, @control.debit_total % 100)
67
- lines << left_justify("Credit Total: ", 25) +
68
- sprintf("% 7d.%02d", @control.credit_total / 100, @control.credit_total % 100)
69
-
70
- lines.join("\r\n")
71
- end
72
-
73
- def parse_fixed data
74
- parse data.scan(/.{94}/).join("\n")
75
- end
76
-
77
- def parse data
78
- trace_number = 0
79
- fh = self.header
80
- batch = nil
81
- bh = nil
82
- ed = nil
83
-
84
- data.strip.split(/\n|\r\n/).each do |line|
85
- type = line[0].chr
86
- case type
87
- when '1'
88
- fh.immediate_destination = line[03..12].strip
89
- fh.immediate_origin = line[13..22].strip
90
- fh.transmission_datetime = Time.utc('20'+line[23..24], line[25..26], line[27..28], line[29..30], line[31..32])
91
- fh.file_id_modifier = line[33..33]
92
- fh.immediate_destination_name = line[40..62].strip
93
- fh.immediate_origin_name = line[63..85].strip
94
- fh.reference_code = line[86..93].strip
95
- when '5'
96
- self.batches << batch unless batch.nil?
97
- batch = ACH::Batch.new
98
- bh = batch.header
99
- bh.company_name = line[4..19].strip
100
- <<<<<<< HEAD
101
- bh.company_identification = line[40..49].strip.gsub(/\A1/, '')
102
- =======
103
- bh.company_identification = line[41..49]# .strip - do not strip need to preserve trailing spaces
104
- >>>>>>> 2dd27ff1c45679b6544a088c4a21f2689123ddf8
105
- bh.standard_entry_class_code = line[50..52].strip
106
- bh.company_entry_description = line[53..62].strip
107
- bh.company_descriptive_date = Date.parse(line[63..68]) rescue nil # this can be various formats
108
- bh.effective_entry_date = Date.parse(line[69..74])
109
- bh.originating_dfi_identification = line[79..86].strip
110
- when '6'
111
- ed = ACH::CtxEntryDetail.new
112
- ed.transaction_code = line[1..2]
113
- ed.routing_number = line[3..11]
114
- ed.account_number = line[12..28].strip
115
- ed.amount = line[29..38].to_i # cents
116
- ed.individual_id_number = line[39..53].strip
117
- ed.individual_name = line[54..75].strip
118
- ed.originating_dfi_identification = line[79..86]
119
- ed.trace_number = line[87..93].to_i
120
- batch.entries << ed
121
- when '7'
122
- type_code = line[1..2]
123
- ad = case type_code
124
- when '98'
125
- ACH::Addendum::NotificationOfChange.new
126
- when '99'
127
- ACH::Addendum::Return.new
128
- else
129
- ACH::Addendum.new
130
- end
131
- ad.type_code = type_code
132
- ad.payment_data = line[3..82].strip
133
- ad.sequence_number = line[83..86].strip.to_i
134
- ad.entry_detail_sequence_number = line[87..93].to_i
135
- ed.addenda << ad
136
- when '8'
137
- # skip
138
- when '9'
139
- # skip
140
- else
141
- raise "Didn't recognize type code #{type} for this line:\n#{line}"
142
- end
143
- end
144
-
145
- self.batches << batch unless batch.nil?
146
- batch.entries.each{ |entry| entry.trace_number = (trace_number += 1) }
147
- to_s
148
- end
149
- end
150
- end