ach 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8950b0833382bb80f3ebf7b9e0e2702aece4ee0de2f385c4c9e5dbd4a7d1157
4
- data.tar.gz: ce02f3a9a926be32cc72f8a986c308e4ceee7ceb617c487bc915ca20d6efa901
3
+ metadata.gz: 2675fc4115782f0d7fca900b070cebd739e9ceceee0c32d197b0ecd24e56f985
4
+ data.tar.gz: 3cb59f5617acdad57d7272124ca83999313c7675d48239a3cc0e510dcb095130
5
5
  SHA512:
6
- metadata.gz: 84465c6a64caeead398a541d7110ee473ce1cdd11a1c200a3b9f975813a2898e7d904ceaebc68e7d16cc5c880d9b27d5497f7930d5a28e8b7563038a9a3e1ede
7
- data.tar.gz: dfc53a158083ef3559583b1f2e613f8fdd0f76ea38434345773d95af8875bc0d195b9ec560e1202cfcc8eeb742e1a923458fa0d052612132bcc57ec881f63c5b
6
+ metadata.gz: 8426fe5b8944fb11d7ca51bbc631a14f64e9e5dbd7ca668833905ac0f05b14c8f91248b4f43ff0c8245f705ec0b07e8588cb168ba82bb7160a880965414bbdfa
7
+ data.tar.gz: 5b403f8700e4ecc92f41f619f960455df6d88538f989ba3a545f28ff98632506dfeb76753622ff4d7ffbeecba71d91783110cb555cb4021097be9a71d2e9fdfd
data/README.md CHANGED
@@ -1,18 +1,20 @@
1
- #ACH
1
+ # ACH
2
+
3
+ Note: I'm no longer actively maintaining this gem, and would be happy to turn it over to someone else. Let me know if you'd like to take over.
2
4
 
3
5
  [![Build Status](https://travis-ci.org/jm81/ach.svg?branch=master)](https://travis-ci.org/jm81/ach)
4
6
 
5
7
  ach is a Ruby helper for builder ACH files. In particular, it helps with field
6
8
  order and alignment, and adds padding lines to end of file.
7
9
 
8
- **This library has only been used in one production application and for very
10
+ **This library has only been used in two production applications and for very
9
11
  limited purposes. Please test thoroughly before using in a production
10
12
  environment.**
11
13
 
12
14
  See [ACH::Builder](http://search.cpan.org/~tkeefer/ACH-Builder-0.03/lib/ACH/Builder.pm)
13
15
  for a similar Perl library
14
16
 
15
- ##Example
17
+ ## Example
16
18
 
17
19
  You should consult a copy of the [ACH Rules](http://www.nacha.org) for details
18
20
  on individual fields. You can probably obtain a copy from your bank.
@@ -30,6 +32,11 @@ fh.immediate_destination = '000000000'
30
32
  fh.immediate_destination_name = 'BANK NAME'
31
33
  fh.immediate_origin = '000000000'
32
34
  fh.immediate_origin_name = 'BANK NAME'
35
+ # Optional - This value is used in the File Creation Date/Time attributes - if excluded will default to Time.now
36
+ # Note that you may wish to modify the time zone here if your environment has a different time zone than the banks
37
+ # For example if your server is in UTC and the bank's is in US/Eastern, any files sent after 8pm Eastern/Midnight UTC
38
+ # would have a File Creation Date of the next day from the bank's perspective
39
+ fh.transmission_datetime = Time.now
33
40
 
34
41
  # Batch
35
42
  batch = ACH::Batch.new
@@ -38,7 +45,7 @@ bh.company_name = 'Company Name'
38
45
  bh.company_identification = '123456789' # Use 10 characters if you're not using an EIN
39
46
  bh.standard_entry_class_code = 'PPD'
40
47
  bh.company_entry_description = 'DESCRIPTION'
41
- bh.company_descriptive_date = Date.today
48
+ bh.company_descriptive_date = Date.today # Or string with 'SDHHMM' for same day ACH
42
49
  bh.effective_entry_date = ACH::NextFederalReserveEffectiveDate.new(Date.today).result
43
50
  bh.originating_dfi_identification = '00000000'
44
51
  ach.batches << batch
@@ -73,6 +80,6 @@ ach.batches.first.entries.first.addenda.first.payment_data
73
80
 
74
81
  **Note:** When adding an amount to your ach file, it needs to be in cents. So you'll want to multiply any dollar amounts by 100
75
82
 
76
- ##Copyright
83
+ ## Copyright
77
84
 
78
85
  Copyright (c) 2008-2009 Jared E Morgan, released under the MIT license
data/lib/ach/ach_file.rb CHANGED
@@ -114,7 +114,7 @@ module ACH
114
114
  bh.full_company_identification = line[40..49]
115
115
  bh.standard_entry_class_code = line[50..52].strip
116
116
  bh.company_entry_description = line[53..62].strip
117
- bh.company_descriptive_date = Date.parse(line[63..68]) rescue nil # this can be various formats
117
+ bh.company_descriptive_date = parse_descriptive_date(line[63..68].strip)
118
118
  bh.effective_entry_date = Date.parse(line[69..74])
119
119
  bh.originating_dfi_identification = line[79..86].strip
120
120
  when '6'
@@ -156,5 +156,19 @@ module ACH
156
156
  self.batches << batch unless batch.nil?
157
157
  to_s
158
158
  end
159
+
160
+ def parse_descriptive_date(date_string)
161
+ return if date_string.empty?
162
+
163
+ date_time = date_string.match(/^SD(\d{2})(\d{2})$/) do
164
+ same_day_hour, same_day_minute = _1.captures.map(&:to_f)
165
+
166
+ Date.today.to_datetime + (same_day_hour + same_day_minute/60) / 24
167
+ end
168
+
169
+ date_time || Data.parse(date_string)
170
+ rescue
171
+ date_string
172
+ end
159
173
  end
160
174
  end
@@ -3,7 +3,10 @@ module ACH
3
3
  # Passing in SD to the date signifies same-day to banks. This is used for the company_descriptive_date
4
4
  def self.stringify_with_same_day(f)
5
5
  return f.upcase if f.to_s.upcase.match(/^SD\d+$/)
6
- f.strftime('%y%m%d')
6
+
7
+ Date.strptime(f, '%y%m%d')
8
+ rescue
9
+ f
7
10
  end
8
11
  end
9
- end
12
+ end
data/lib/ach/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ACH
2
- VERSION = '0.6.0'.freeze
2
+ VERSION = '0.6.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ach
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Morgan
8
8
  - Josh Puetz
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-09-18 00:00:00.000000000 Z
12
+ date: 2023-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: appraisal
@@ -110,7 +110,7 @@ files:
110
110
  homepage: https://github.com/jm81/ach
111
111
  licenses: []
112
112
  metadata: {}
113
- post_install_message:
113
+ post_install_message:
114
114
  rdoc_options: []
115
115
  require_paths:
116
116
  - lib
@@ -125,8 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
- rubygems_version: 3.0.3
129
- signing_key:
128
+ rubygems_version: 3.0.9
129
+ signing_key:
130
130
  specification_version: 4
131
131
  summary: Helper for building ACH files
132
132
  test_files: []