ach_client 2.1.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e40c40c7ee42a6264c64f512772b254fac48b70cb7bb323ba238594c3d2d50c
4
- data.tar.gz: a6d925e6f0a9682e085de0f1d12240c827cf769d521ee66fabe7001ade43fd64
3
+ metadata.gz: d140b0751adee4c2f924f737d9533bf084656ff330e6ebd2f764cede1cac4bf7
4
+ data.tar.gz: 91340a5b05226ad8e2f1eeeeac110415187a7bb7341c45d155720e143e93b165
5
5
  SHA512:
6
- metadata.gz: 86303a731c6e1c4de5f4a82fa8a12f2f9f955e3ef70601c423d907282b50e2e5992a762f4736223bab87672b28a86b566fa112c55c0e9a0f7fd2c9c819dbc6c3
7
- data.tar.gz: 71299fac7355cd6b0a48e0245e8aa19e01f809f4acdcc00f97afda028c0f18dc0bb8792fabd5b242c6e590317f83385cef7e434fac395d3ad3ac8371897a1cc4
6
+ metadata.gz: 4affcfdf1085e60c06bf45916cea073f02b83e70bcae42e6e0f4ba9b774aa7695c82676344a2de91a4e0b294663aad91af3cbd055a34b9012f009e2775fcaecf
7
+ data.tar.gz: 2d9dc7b4c4f4ec66665e8cb74b646d8f21606adab21058c44a74b5451926f1e98cf4a8bf40f905167bfa8f9e388ce7aec2e18d163ee8cffd26e00c3227e3c259
@@ -0,0 +1 @@
1
+ * @ForwardFinancing/funding-app-smes
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.0
1
+ 2.6.8
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 2.5.0
1
+ ruby 2.6.8
data/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2022, ForwardFinancing
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  ## Overview
12
12
 
13
13
  The AchClient gem provides a common interface for working with a variety of
14
- ACH providers.
14
+ ACH providers. This is an **OPEN SOURCE PROJECT, PUBLICLY ACCESSIBLE**, and licensed under the BSD 3-Clause license
15
15
 
16
16
  Supported features include:
17
17
 
@@ -337,6 +337,7 @@ these new classes using the same interface described above for the API providers
337
337
  | `outgoing_path` | Path on the remote server where bank has asked you to dump your NACHAs |
338
338
  | `incoming_path` | Path on the remote server where the bank leaves confirmation/return files |
339
339
  | `file_naming_strategy` | Function to define filenames for the NACHA files |
340
+ | `transmission_datetime_calculator` | (optional) Function to define File Creation Date header value - defaults to `-> { Time.now }` - note that you may wish to override this to use a non-UTC zone |
340
341
 
341
342
  #### File Naming Strategy
342
343
 
data/ach_client.gemspec CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency 'ach', '~> 0'
33
33
 
34
34
  # Handy ruby behavior from rails
35
- spec.add_dependency 'activesupport'
35
+ spec.add_dependency 'activesupport', '< 6' # Need to rename .parent to .module_parent before upgrade
36
36
 
37
37
  # SFTP client (for Bank providers)
38
38
  spec.add_dependency 'net-sftp'
@@ -62,7 +62,8 @@ module AchClient
62
62
  :immediate_destination,
63
63
  :immediate_destination_name,
64
64
  :immediate_origin,
65
- :immediate_origin_name
65
+ :immediate_origin_name,
66
+ :transmission_datetime
66
67
  ].each do |attribute|
67
68
  file_header.send("#{attribute}=", self.class.parent.send(attribute))
68
69
  end
@@ -25,6 +25,13 @@ module AchClient
25
25
  # @return [String] originating_dfi_identification refers to your bank?
26
26
  # originating_dfi => "Originating Depository Financial Institution"
27
27
  class_attribute :originating_dfi_identification
28
+
29
+ # @return [Proc<Time>] method to calculate the File Creation Date for NACHA header
30
+ class_attribute :transmission_datetime_calculator, default: -> { Time.now }
31
+
32
+ def self.transmission_datetime
33
+ transmission_datetime_calculator.call
34
+ end
28
35
  end
29
36
  end
30
37
  end
@@ -14,6 +14,8 @@ module AchClient
14
14
  "ACCESS DENIED"
15
15
  ]
16
16
 
17
+ EMPTY_RETURNS_RESPONSE = 'NO RETURNS REPORTED'.freeze
18
+
17
19
  ##
18
20
  # ICheckGateway does not support this
19
21
  def self.most_recent
@@ -34,31 +36,74 @@ module AchClient
34
36
  end
35
37
  end
36
38
 
37
- # Wrapper for the range response endpoint
38
- # @return [Hash{String => [AchClient::AchResponse]}] Hash with
39
+ # @return Hash{String => [AchClient::AchResponse]} Hash with
39
40
  # confirmation number as the key, lists of AchResponse objects as values
40
41
  def self.in_range(start_date:, end_date:)
41
42
  Helpers::Utils.hashlist_merge(
43
+ check_for_late_returns(start_date: start_date, end_date: end_date) +
44
+ pull_transaction_report(start_date: start_date, end_date: end_date)
45
+ )
46
+ end
47
+
48
+ # @return [Hash{String => [AchClient::AchResponse]}] List of hashes with
49
+ # confirmation number as the key, lists of AchResponse objects as values
50
+ private_class_method def self.pull_transaction_report(start_date:, end_date:)
51
+ AchClient::ICheckGateway.wrap_request(
52
+ method: :pull_transaction_report,
53
+ message: AchClient::ICheckGateway::CompanyInfo.build.to_hash.merge({
54
+ startDate: start_date,
55
+ endDate: end_date
56
+ })
57
+ ).split("\n").select do |record|
58
+ check_for_errors(record)
59
+ # Only the records that start with ICHECK are ACH transactions.
60
+ # Everything else is other types of transactions such as credit card swipes which are outside
61
+ # the scope of this library
62
+ record.start_with?('ICHECK')
63
+ end.map do |record|
64
+ # The 4th column is the external_ach_id which becomes the hash key
65
+ {
66
+ record.split('|')[3] =>
67
+ [
68
+ AchClient::ICheckGateway::ResponseRecordProcessor
69
+ .process_response_record(record)
70
+ ]
71
+ }
72
+ end
73
+ end
74
+
75
+ # The pull_transaction_report method returns ACHs by effective entry date, which won't necessarily include
76
+ # any late returns that were returned outside the window of pending ACHs.
77
+ # This uses a separate endpoint which gives back returned ACHs by the return date, which will include late
78
+ # returns
79
+ # @return [Hash{String => [AchClient::AchResponse]}] List of hashes with
80
+ # confirmation number as the key, lists of AchResponse objects as values
81
+ private_class_method def self.check_for_late_returns(start_date:, end_date:)
82
+ (start_date..end_date).map do |date|
42
83
  AchClient::ICheckGateway.wrap_request(
43
- method: :pull_transaction_report,
84
+ method: :pull_returned_checks,
44
85
  message: AchClient::ICheckGateway::CompanyInfo.build.to_hash.merge({
45
- startDate: start_date,
46
- endDate: end_date
86
+ ReturnedDate: date
47
87
  })
48
- ).split("\n").select do |record|
49
- check_for_errors(record)
50
- # Ignore credit card swipes if there are any
51
- record.start_with?('ICHECK')
52
- end.map do |record|
53
- {
54
- record.split('|')[3] =>
55
- [
56
- AchClient::ICheckGateway::ResponseRecordProcessor
57
- .process_response_record(record)
58
- ]
59
- }
88
+ ).split("\n").map do |record|
89
+ if record.include?("|")
90
+ # Each record returned by the API is a pipe separated list with 2 columns:
91
+ # Example: external_ach_id|R01\r\n
92
+ external_ach_id, return_code = record.split('|')
93
+ {external_ach_id => [AchClient::ReturnedAchResponse.new(
94
+ amount: nil, # response does not include amount
95
+ date: date,
96
+ return_code: AchClient::ReturnCodes.find_by(code: return_code)
97
+ )]}
98
+ elsif record.include?(EMPTY_RETURNS_RESPONSE)
99
+ # Server returns an error message instead of an empty list, so we catch the error message and return our
100
+ # own empty response
101
+ {}
102
+ else
103
+ raise "Couldnt process ICheckGateway Late Returns Response: #{record}"
104
+ end
60
105
  end
61
- )
106
+ end.reduce(&:+)
62
107
  end
63
108
  end
64
109
  end
@@ -10,11 +10,13 @@ module AchClient
10
10
  AMOUNT_COLUMN = 15
11
11
  # The column index with the record submission date
12
12
  DATE_COLUMN = 17
13
- # THe string index range within the record status with the return code
13
+ # The string index range within the record status with the return code
14
14
  RETURN_CODE_INDEX = 3..5
15
15
 
16
16
  ## Transforms ICheckGateway transaction report response records into
17
- # AchClient::Response objects
17
+ # AchClient::Response object
18
+ # Here is an example record:
19
+ # ICHECK|N||external_ach_id|abc||||||||BC|012345678|********1234|250.00|D|9/12/2016|05:03:04|C1234-1234||AutoCheck|||abcde|CCD|||\r\ns
18
20
  # @param record [String] the | separated record string from ICheckGateway
19
21
  # @return [AchClient::AchResponse] our representation of the response
20
22
  def self.process_response_record(record)
@@ -1,4 +1,4 @@
1
1
  module AchClient
2
2
  # Increment this when changes are published
3
- VERSION = '2.1.0'
3
+ VERSION = '3.1.0'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ach_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zach Cotter
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2022-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ach
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '6'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "<"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: net-sftp
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -248,7 +248,7 @@ dependencies:
248
248
  - - ">="
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
- description:
251
+ description:
252
252
  email:
253
253
  - zach@zachcotter.com
254
254
  executables: []
@@ -256,14 +256,15 @@ extensions: []
256
256
  extra_rdoc_files: []
257
257
  files:
258
258
  - ".codeclimate.yml"
259
+ - ".github/CODEOWNERS"
259
260
  - ".gitignore"
260
261
  - ".rubocop.yml"
261
262
  - ".ruby-version"
262
263
  - ".tool-versions"
263
264
  - ".tool-versions-e"
264
- - ".travis.yml"
265
265
  - CHANGELOG.md
266
266
  - Gemfile
267
+ - LICENSE
267
268
  - README.md
268
269
  - Rakefile
269
270
  - ach_client.gemspec
@@ -332,7 +333,7 @@ homepage: https://github.com/ForwardFinancing/ach_client
332
333
  licenses:
333
334
  - MIT
334
335
  metadata: {}
335
- post_install_message:
336
+ post_install_message:
336
337
  rdoc_options: []
337
338
  require_paths:
338
339
  - lib
@@ -348,9 +349,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
348
349
  - !ruby/object:Gem::Version
349
350
  version: '0'
350
351
  requirements: []
351
- rubyforge_project:
352
- rubygems_version: 2.7.3
353
- signing_key:
352
+ rubygems_version: 3.0.3.1
353
+ signing_key:
354
354
  specification_version: 4
355
355
  summary: Adapter to interact with various ACH service providers
356
356
  test_files: []
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- before_install:
3
- - export TZ=US/Eastern
4
- - export CODECLIMATE_REPO_TOKEN=1fc324a28beed303e632765cca14487904a23023d85b9127a288f04cc007d28d
5
- - export CC_TEST_REPORTER_ID=1fc324a28beed303e632765cca14487904a23023d85b9127a288f04cc007d28d
6
- - date
7
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
8
- - chmod +x ./cc-test-reporter
9
- - ./cc-test-reporter before-build
10
- script:
11
- - bundle exec rake test
12
- after_script:
13
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
14
- notifications:
15
- email: false