Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f0aa8f8
Merge pull request #1 from QuietStreamFinancial/IMS-10957
germs12 May 31, 2017
07a14dc
super minor version bump
germs12 May 31, 2017
4731db0
versions be locked down
germs12 May 31, 2017
4bb5086
IMS-19288 adjust nines records count for entry addenda
bthews Feb 25, 2019
3c3b8a7
IMS-19288 bump version
bthews Feb 26, 2019
9fa1358
Merge pull request #2 from QuietStreamFinancial/IMS-19288
Feb 26, 2019
c5cb004
IMS-20624: Include addenda entry count when calculating block count
mtmorra Jun 14, 2019
7ae8ae9
IMS-20624: Update gem version
mtmorra Jun 14, 2019
5c57673
Merge pull request #3 from QuietStreamFinancial/IMS-20624
mtmorra Jun 14, 2019
06e9ebe
Fix ruby keyword argument deprecation
lorman Oct 13, 2023
6575d65
Bump version number
lorman Oct 13, 2023
5fd38aa
Merge pull request #71 from bodyshopbidsdotcom/fix-keyword-argument-2.7
henriquegasques Oct 16, 2023
0c8da9b
Update README to remove the note about it not being actively maintained
henriquegasques Nov 14, 2023
e360008
fix: use federalreservebanks holiday definition for ACH files
kapil2004 Nov 14, 2023
97a9eec
Merge pull request #73 from dailypay/master
henriquegasques Nov 21, 2023
942447b
Bump version to 0.6.4
henriquegasques Nov 21, 2023
d711777
[PAY-797] Fix Forked Ach Gem
jkaufman638 Jan 8, 2024
33111b1
Merge pull request #74 from justworkshr/josh.fixdateparsing
henriquegasques Jan 18, 2024
04b3a08
Update version to 0.6.5
henriquegasques Jan 18, 2024
3d812c4
Update homepage in gemspec (for rubygems.org)
biow0lf Jan 24, 2024
30017d9
Add required_ruby_version with >= 2.0.0 due travis.yml
biow0lf Jan 25, 2024
75d58d2
Update link to homepage and add metadata with bug_tracker_uri, change…
biow0lf Jan 26, 2024
bfe0a79
Fix spec
henriquegasques Jan 26, 2024
c497e47
Update ach.gemspec
henriquegasques Feb 22, 2024
c9c734e
Update ach.gemspec
henriquegasques Feb 22, 2024
1049cac
Update ach.gemspec
henriquegasques Feb 22, 2024
16a1452
Merge pull request #75 from biow0lf/update-links
henriquegasques Feb 22, 2024
528caa7
IMS-26754: fix argument issue to support ruby > 3.0
ilurinikhil Oct 3, 2024
03f302e
Merge remote-tracking branch 'upstream/master' into IMS-26754
ilurinikhil Oct 19, 2024
9114349
IMS-26754: bump version
ilurinikhil Oct 19, 2024
914c4c2
Merge pull request #5 from QuietStreamFinancial/IMS-26754
ilurinikhil Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ pkg
*.gem
install.log
*.gemfile.lock
.idea
26 changes: 13 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
PATH
remote: .
specs:
ach (0.6.0)
holidays (>= 3.1)
ach (0.5.8.2)
holidays (>= 1.2.0, < 5.4.0)

GEM
remote: https://rubygems.org/
specs:
appraisal (2.2.0)
appraisal (2.5.0)
bundler
rake
thor (>= 0.14.0)
autotest (5.0.0)
minitest-autotest (~> 1.0)
diff-lcs (1.3)
holidays (8.4.1)
minitest (5.14.1)
diff-lcs (1.5.0)
holidays (8.7.1)
minitest (5.20.0)
minitest-autotest (1.1.1)
minitest-server (~> 1.0)
path_expander (~> 1.0)
minitest-server (1.0.6)
minitest (~> 5.0)
minitest-server (1.0.7)
minitest (~> 5.16)
path_expander (1.1.0)
rake (13.0.1)
rake (13.1.0)
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.9.0)
rspec-core (3.9.2)
rspec-core (3.9.3)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.2)
rspec-expectations (3.9.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
thor (1.0.1)
thor (1.3.0)

PLATFORMS
ruby
Expand All @@ -51,4 +51,4 @@ DEPENDENCIES
rspec (~> 3.2)

BUNDLED WITH
2.2.2
2.3.26
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
# ACH

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.
ACH is a Ruby helper for building and parsing ACH files.

[![Build Status](https://travis-ci.org/jm81/ach.svg?branch=master)](https://travis-ci.org/jm81/ach)

ach is a Ruby helper for builder ACH files. In particular, it helps with field
In particular, it helps with field
order and alignment, and adds padding lines to end of file.

**This library has only been used in two production applications and for very
limited purposes. Please test thoroughly before using in a production
environment.**

See [ACH::Builder](http://search.cpan.org/~tkeefer/ACH-Builder-0.03/lib/ACH/Builder.pm)
for a similar Perl library

## Example

You should consult a copy of the [ACH Rules](http://www.nacha.org) for details
Expand Down
27 changes: 19 additions & 8 deletions ach.gemspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require 'ach/version'
require "ach/version"

Gem::Specification.new do |s|
s.name = 'ach'
s.name = "ach"
s.version = ACH::VERSION.dup
s.summary = 'Helper for building ACH files'
s.description = 'ach is a Ruby helper for building and parsing ACH files. In particular, it helps with field order and alignment, and adds padding lines to end of file.'
s.email = 'jmorgan@morgancreative.net'
s.homepage = 'https://github.com/jm81/ach'
s.authors = ['Jared Morgan', 'Josh Puetz']
s.summary = "Helper for building ACH files"
s.description = "ach is a Ruby helper for building and parsing ACH files. In particular, it helps with field order and alignment, and adds padding lines to end of file."
s.email = "henriquegasques@gmail.com"
s.homepage = "https://github.com/rubyritas/ach"
s.authors = ["Jared Morgan", "Josh Puetz"]
s.license = "MIT"

s.extra_rdoc_files = ['README.md']
s.metadata = {
"bug_tracker_uri" => "https://github.com/rubyritas/ach/issues",
"changelog_uri" => "https://github.com/rubyritas/ach/blob/main/CHANGELOG.md",
"documentation_uri" => "https://github.com/rubyritas/ach/blob/main/README.md",
"homepage_uri" => "https://github.com/rubyritas/ach",
"source_code_uri" => "https://github.com/rubyritas/ach"
}

s.extra_rdoc_files = ["README.md"]

s.files = Dir.glob('lib/**/*') + %w{MIT-LICENSE README.md}
s.test_files = Dir.glob('examples/**/*')
s.require_path = 'lib'

s.required_ruby_version = ">= 2.0.0"

s.add_development_dependency('appraisal')
s.add_development_dependency('autotest')
s.add_development_dependency('rake', '>= 12.3.3')
Expand Down
12 changes: 7 additions & 5 deletions lib/ach/ach_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,23 @@ def initialize data=nil
def to_s eol = ACH.eol
records = []
records << @header
addenda_entry_count = 0

@batches.each_with_index do |batch, index|
batch.header.batch_number ||= index + 1
addenda_entry_count += batch.entries.flat_map{|e| e.addenda}.length
records += batch.to_ach
end
records << @control
total_length = addenda_entry_count + records.length

records_count = records.map(&:records_count).reduce(:+)
nines_needed = (10 - records_count) % 10
nines_needed = 10 - (total_length % 10)
nines_needed = nines_needed % 10
nines_needed.times { records << Records::Nines.new() }

records_count = records.map(&:records_count).reduce(:+)
@control.batch_count = @batches.length
@control.block_count = (records_count / 10).ceil
@control.block_count = ((records.length + addenda_entry_count) / 10).ceil

@control.entry_count = 0
@control.debit_total = 0
Expand Down Expand Up @@ -79,7 +81,7 @@ def report eol: ACH.eol

def parse_fixed data
# replace with a space to preserve the record-lengths
encoded_data = data.encode(Encoding.find('ASCII'),{:invalid => :replace, :undef => :replace, :replace => ' '})
encoded_data = data.encode(Encoding.find('ASCII'), **{:invalid => :replace, :undef => :replace, :replace => ' '})
parse encoded_data.scan(/.{94}/).join("\n")
end

Expand Down Expand Up @@ -166,7 +168,7 @@ def parse_descriptive_date(date_string)
Date.today.to_datetime + (same_day_hour + same_day_minute/60) / 24
end

date_time || ACH::Data.parse(date_string)
date_time || Date.parse(date_string)
rescue
date_string
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ach/next_federal_reserve_effective_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class NextFederalReserveEffectiveDate
if Gem.loaded_specs['holidays'].version < Gem::Version.new('7.0.0')
:federal_reserve
else
:federalreserve
:federalreservebanks
end
def initialize(submission_date)
@submission_date = submission_date
Expand Down
2 changes: 1 addition & 1 deletion lib/ach/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ACH
VERSION = '0.6.2'.freeze
VERSION = '0.5.8.2'.freeze
end
2 changes: 1 addition & 1 deletion spec/ach/ach_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,4 @@ def add_balancing_entry_detail(batch)
end
end
end
end
end
8 changes: 8 additions & 0 deletions spec/ach/next_federal_reserve_effective_date_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
end
end

context 'when today is Thursday and tomorrow is a observed holiday' do
let(:run_date) { Date.new(2023, 11, 9) }

it 'returns tomorrow' do
expect(subject).to eq(Date.new(2023, 11, 10))
end
end

context 'when today is Monday and a holiday' do
let(:run_date) { Date.new(2012, 5, 28) }

Expand Down
5 changes: 3 additions & 2 deletions spec/ach/parse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

it "should parse return/notification of change file" do
fake_current_datetime = Date.new(2012, 10, 15)
expected_datetime = DateTime.new(2012, 10, 15, 19, 32)
allow(Date).to receive(:today).and_return(fake_current_datetime)

ach = ACH::ACHFile.new(@data)
Expand All @@ -41,7 +42,7 @@
expect(bh.full_company_identification).to eq("1412345678")
expect(bh.standard_entry_class_code).to eq('COR')
expect(bh.company_entry_description).to eq("DESCRIPT")
expect(bh.company_descriptive_date).to eq('SD1932')
expect(bh.company_descriptive_date).to eq(expected_datetime)
expect(bh.effective_entry_date).to eq(Date.parse('121015'))
expect(bh.originating_dfi_identification).to eq("99222222")

Expand All @@ -52,7 +53,7 @@
expect(bh.full_company_identification).to eq("1412345678")
expect(bh.standard_entry_class_code).to eq('PPD')
expect(bh.company_entry_description).to eq("DESCRIPT")
expect(bh.company_descriptive_date).to eq('121015')
expect(bh.company_descriptive_date).to eq(Date.parse('121015'))
expect(bh.effective_entry_date).to eq(Date.parse('121015'))
expect(bh.originating_dfi_identification).to eq("99222222")

Expand Down