nacha 0.1.6 → 0.1.8

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: 782ae8de3e488c9404aab641bf27e71da0b9bc6d391d235dbec10fc8d750c27a
4
- data.tar.gz: 76e485087bcdd967c437912b1318bd79f21e50c1e9ed6eb3dbd73ea3233b86ec
3
+ metadata.gz: 8e70f9ad804c23687e8b3c9b6aa0fed4327554a98bdad5419a84dfe9f5d7f459
4
+ data.tar.gz: 475cc33a0528eda1b5c55f670f87537ea8f7a6610b7943304738e09f4740bae1
5
5
  SHA512:
6
- metadata.gz: 799751bb17453a1f28e7e0b362e7a06eb017445d5928c06e7130c15c6d7b6a6a427e2b96ecb05567fafc60107400c82e39e0c81799158f2d942af6839ba470b7
7
- data.tar.gz: adf86d5aa5302590c53c0333e3ea7a32c5e0e3ed255da5bf8812d0d2e853173e31b8cf12a7ba1602b9c0420f1aa52eedd9c54f7698f90ba11f0a399bd787bb42
6
+ metadata.gz: 7b5d4c12e34b8eda4e97fd6a1ee4fa082217f967ac75893195566091673196346b544bc262d1ad789f136f55c28d1b4002495ae859474776200841d06fc10a21
7
+ data.tar.gz: 98f8cb7134340a7088946dfe1904b1e11c485676f9ad7369bf299e20aa23af45323bb12dd7d0ba2d2064ff7fcffa8a9a9639ca4e885e09fa89c5f9b191d73dea
data/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.8] - 2025-06-24
11
+
12
+ - Now parses filler records correctly (fixed definition)
13
+
14
+ - Add support for `ack_entry_detail` record type
15
+
16
+ - Tweaked the child record types for file_control and file_header
17
+
18
+ ## [0.1.7] - 2025-06-23
19
+
20
+ - Better parsing. Nacha::Record::FileControl had issues parsing if the reserved
21
+ part of the record was stripped off. Since the reserved part of the record is
22
+ all spaces, it can safely be missing.
23
+
24
+
10
25
  ## [0.1.6] - 2025-06-20
11
26
 
12
27
  - Better code coverage
data/lib/nacha/field.rb CHANGED
@@ -108,7 +108,9 @@ class Nacha::Field
108
108
  add_error("'position' must be present for a field definition.") unless @position
109
109
  add_error("'contents' must be present for a field definition.") unless @contents
110
110
 
111
- if @data_assigned && (mandatory? || required?) && (@input_data.nil? || @input_data.to_s.strip.empty?)
111
+ if @data_assigned &&
112
+ (mandatory? || required?) &&
113
+ ((@input_data.nil? || @input_data.to_s.empty?) && @contents !~ /\AC( *)\z/)
112
114
  add_error("'#{human_name}' is a required field and cannot be blank.")
113
115
  end
114
116
 
data/lib/nacha/parser.rb CHANGED
@@ -4,7 +4,8 @@ require 'nacha'
4
4
  require 'nacha/parser_context'
5
5
 
6
6
  class Nacha::Parser
7
- DEFAULT_RECORD_TYPES = ['Nacha::Record::FileHeader'].freeze
7
+ DEFAULT_RECORD_TYPES = ['Nacha::Record::FileHeader',
8
+ 'Nacha::Record::Filler'].freeze
8
9
 
9
10
  attr_reader :context
10
11
 
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ require 'nacha/record/base.rb'
5
+ require 'nacha/record/detail_record_type.rb'
6
+
7
+ module Nacha
8
+ module Record
9
+ class AckEntryDetail < Nacha::Record::Base
10
+ include DetailRecordType
11
+ nacha_field :record_type_code, inclusion: 'M', contents: 'C6', position: 1..1
12
+ nacha_field :transaction_code, inclusion: 'M', contents: 'Numeric', position: 2..3
13
+ nacha_field :receiving_dfi_identification, inclusion: 'M', contents: 'TTTTAAAAC', position: 4..12
14
+ nacha_field :dfi_account_number, inclusion: 'R', contents: 'Alphameric', position: 13..29
15
+ nacha_field :amount, inclusion: 'M', contents: '$$$$$$$$¢¢', position: 30..39
16
+ nacha_field :originl_entry_trace_number, inclusion: 'M', contents: 'Numeric', position: 40..54
17
+ nacha_field :receiving_company_name, inclusion: 'R', contents: 'Alphameric', position: 55..76
18
+ nacha_field :discretionary_data, inclusion: 'O', contents: 'Alphameric', position: 77..78
19
+ nacha_field :addenda_record_indicator, inclusion: 'M', contents: 'Numeric', position: 79..79
20
+ nacha_field :trace_number, inclusion: 'M', contents: 'Numeric', position: 80..94
21
+ end
22
+ end
23
+ end
@@ -29,8 +29,6 @@ module Nacha
29
29
  end
30
30
 
31
31
  class << self
32
- attr_reader :nacha_record_name
33
-
34
32
  def nacha_field(name, inclusion:, contents:, position:)
35
33
  definition[name] = { inclusion: inclusion,
36
34
  contents: contents,
@@ -41,7 +39,9 @@ module Nacha
41
39
 
42
40
  validations[name] ||= []
43
41
  validations[name] << validation_method
42
+ Nacha.add_ach_record_type(self)
44
43
  end
44
+
45
45
  def definition
46
46
  @definition ||= {}
47
47
  end
@@ -81,15 +81,17 @@ module Nacha
81
81
  @matcher ||=
82
82
  Regexp.new('\A' + definition.values.reverse.collect do |d|
83
83
  if d[:contents] =~ /\AC(.+)\z/
84
- output_started = true
85
- Regexp.last_match(1)
86
- elsif d[:contents] =~ /\ANumeric\z/
87
- if output_started
88
- '[0-9 ]' + "{#{(d[:position] || d['position']).size}}"
89
- else
84
+ last_match = Regexp.last_match(1)
85
+ if last_match =~ /\A *\z/
90
86
  skipped_output = true
91
87
  ''
88
+ else
89
+ output_started = true
90
+ last_match
92
91
  end
92
+ elsif d[:contents] =~ /\ANumeric\z/
93
+ output_started = true
94
+ '[0-9 ]' + "{#{(d[:position] || d['position']).size}}"
93
95
  elsif d[:contents] =~ /\AYYMMDD\z/
94
96
  if output_started
95
97
  '[0-9 ]' + "{#{(d[:position] || d['position']).size}}"
@@ -9,7 +9,9 @@ module Nacha
9
9
 
10
10
  module ClassMethods
11
11
  def child_record_types
12
- []
12
+ [
13
+ "Nacha::Record::Filler",
14
+ ]
13
15
  end
14
16
  end
15
17
 
@@ -12,7 +12,6 @@ module Nacha
12
12
  [
13
13
  'Nacha::Record::BatchHeader',
14
14
  'Nacha::Record::FileControl',
15
- 'Nacha::Record::Filler'
16
15
  ]
17
16
  end
18
17
  end
@@ -9,8 +9,8 @@ module Nacha
9
9
  class Filler < Nacha::Record::Base
10
10
  include FillerRecordType
11
11
 
12
- nacha_field :record_type_code, inclusion: 'M', contents: ('C' + ('9' * 93)), position: 1..1
13
- nacha_field :filler, inclusion: 'M', contents: 'Numeric', position: 2..94
12
+ nacha_field :record_type_code, inclusion: 'M', contents: 'C9', position: 1..1
13
+ nacha_field :filler, inclusion: 'M', contents: ('C' + ('9' * 93)), position: 2..94
14
14
  end
15
15
  end
16
16
  end
data/lib/nacha/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nacha
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.8'
5
5
  end
data/lib/nacha.rb CHANGED
@@ -7,16 +7,6 @@ require 'nacha/ach_date'
7
7
  require 'nacha/field'
8
8
  require 'nacha/numeric'
9
9
 
10
- Gem.find_files('nacha/record/*.rb').reject{|f| f =~ /\/spec\//}.each do |file|
11
- require File.expand_path(file)
12
- end
13
-
14
- Gem.find_files('nacha/record/**/*.rb').reject{|f| f =~ /\/spec\//}.each do |file|
15
- require File.expand_path(file)
16
- end
17
-
18
- require 'nacha/parser'
19
-
20
10
  module Nacha
21
11
  STANDARD_ENTRY_CLASS_CODES = %w[ACK ADV ARC ATX BOC CCD PPD CIE
22
12
  COR CTX DNE ENR IAT POP POS SHR
@@ -30,6 +20,16 @@ module Nacha
30
20
  48 49 55 56 82 84 86 88].freeze
31
21
 
32
22
  TRANSACTION_CODES = (CREDIT_TRANSACTION_CODES + DEBIT_TRANSACTION_CODES).freeze
23
+ @@ach_record_types = []
24
+
25
+ def self.add_ach_record_type(klass)
26
+ @@ach_record_types << klass unless @@ach_record_types.include?(klass)
27
+ end
28
+
29
+ def self.ach_record_types
30
+ @@ach_record_types
31
+ end
32
+
33
33
  class << self
34
34
  def parse(object)
35
35
  parser = Nacha::Parser.new
@@ -53,3 +53,14 @@ module Nacha
53
53
  end
54
54
  end
55
55
  end
56
+
57
+ Gem.find_files('nacha/record/*.rb').reject{|f| f =~ /\/spec\//}.each do |file|
58
+ require File.expand_path(file)
59
+ end
60
+
61
+ Gem.find_files('nacha/record/**/*.rb').reject{|f| f =~ /\/spec\//}.each do |file|
62
+ require File.expand_path(file)
63
+ end
64
+
65
+ require 'nacha/parser'
66
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nacha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - David H. Wilkins
@@ -238,6 +238,7 @@ files:
238
238
  - lib/nacha/numeric.rb
239
239
  - lib/nacha/parser.rb
240
240
  - lib/nacha/parser_context.rb
241
+ - lib/nacha/record/ack_entry_detail.rb
241
242
  - lib/nacha/record/addenda_record_type.rb
242
243
  - lib/nacha/record/adv_batch_control.rb
243
244
  - lib/nacha/record/adv_entry_detail.rb