ach 0.3.0.1 → 0.3.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.
data/Rakefile CHANGED
@@ -42,3 +42,6 @@ Rake::RDocTask.new do |rdoc|
42
42
  rdoc.rdoc_files.include('README*')
43
43
  rdoc.rdoc_files.include('lib/**/*.rb')
44
44
  end
45
+
46
+
47
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0.1
1
+ 0.3.1
@@ -1,72 +1,59 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{ach}
8
- s.version = "0.3.0.1"
7
+ s.name = "ach"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jared Morgan", "Josh Puetz"]
12
- s.date = %q{2009-11-29}
13
- s.description = %q{ach is a Ruby helper for builder ACH files. In particular, it helps with field
14
- order and alignment, and adds padding lines to end of file.
15
- }
16
- s.email = %q{jmorgan@morgancreative.net}
12
+ s.date = "2012-10-23"
13
+ s.description = "ach is a Ruby helper for builder ACH files. In particular, it helps with field\norder and alignment, and adds padding lines to end of file.\n"
14
+ s.email = "jmorgan@morgancreative.net"
17
15
  s.extra_rdoc_files = [
18
16
  "README.md"
19
17
  ]
20
18
  s.files = [
21
19
  ".autotest",
22
- ".gitignore",
23
- "MIT-LICENSE",
24
- "README.md",
25
- "Rakefile",
26
- "VERSION",
27
- "ach.gemspec",
28
- "examples/ach/ach_file_example.rb",
29
- "examples/ach/batch_example.rb",
30
- "examples/ach/field_identifiers_example.rb",
31
- "examples/ach/records/batch_control_example.rb",
32
- "examples/ach/records/batch_header_example.rb",
33
- "examples/ach/records/nines_example.rb",
34
- "examples/ach/records/shared/batch_summaries.rb",
35
- "examples/example_helper.rb",
36
- "lib/ach.rb",
37
- "lib/ach/ach_file.rb",
38
- "lib/ach/batch.rb",
39
- "lib/ach/field_identifiers.rb",
40
- "lib/ach/records/addendum.rb",
41
- "lib/ach/records/batch_control.rb",
42
- "lib/ach/records/batch_header.rb",
43
- "lib/ach/records/entry_detail.rb",
44
- "lib/ach/records/file_control.rb",
45
- "lib/ach/records/file_header.rb",
46
- "lib/ach/records/nines.rb",
47
- "lib/ach/records/record.rb"
48
- ]
49
- s.homepage = %q{http://github.com/jm81/ach}
50
- s.rdoc_options = ["--charset=UTF-8"]
51
- s.require_paths = ["lib"]
52
- s.rubygems_version = %q{1.3.5}
53
- s.summary = %q{Helper for building ACH files in Ruby}
54
- s.test_files = [
20
+ "MIT-LICENSE",
21
+ "README.md",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "ach.gemspec",
25
+ "examples/ach/ach_file_example.rb",
26
+ "examples/ach/batch_example.rb",
55
27
  "examples/ach/field_identifiers_example.rb",
56
- "examples/ach/ach_file_example.rb",
57
- "examples/ach/records/nines_example.rb",
58
- "examples/ach/records/shared/batch_summaries.rb",
59
- "examples/ach/records/batch_control_example.rb",
60
- "examples/ach/records/batch_header_example.rb",
61
- "examples/ach/batch_example.rb",
62
- "examples/example_helper.rb"
28
+ "examples/ach/records/batch_control_example.rb",
29
+ "examples/ach/records/batch_header_example.rb",
30
+ "examples/ach/records/ctx_entry_detail_example.rb",
31
+ "examples/ach/records/ctx_entry_detail_test.rb",
32
+ "examples/ach/records/nines_example.rb",
33
+ "examples/ach/records/shared/batch_summaries.rb",
34
+ "examples/example_helper.rb",
35
+ "lib/ach.rb",
36
+ "lib/ach/ach_file.rb",
37
+ "lib/ach/batch.rb",
38
+ "lib/ach/field_identifiers.rb",
39
+ "lib/ach/records/addendum.rb",
40
+ "lib/ach/records/batch_control.rb",
41
+ "lib/ach/records/batch_header.rb",
42
+ "lib/ach/records/entry_detail.rb",
43
+ "lib/ach/records/file_control.rb",
44
+ "lib/ach/records/file_header.rb",
45
+ "lib/ach/records/nines.rb",
46
+ "lib/ach/records/record.rb"
63
47
  ]
48
+ s.homepage = "http://github.com/jm81/ach"
49
+ s.require_paths = ["lib"]
50
+ s.rubygems_version = "1.8.10"
51
+ s.summary = "Helper for building ACH files in Ruby"
64
52
 
65
53
  if s.respond_to? :specification_version then
66
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
67
54
  s.specification_version = 3
68
55
 
69
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
56
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
70
57
  else
71
58
  end
72
59
  else
@@ -0,0 +1,70 @@
1
+ require 'example_helper'
2
+
3
+ describe ACH::Records::CtxEntryDetail do
4
+ before(:each) do
5
+ @entry = ACH::CtxEntryDetail.new
6
+ @entry.transaction_code = ACH::CHECKING_DEBIT
7
+ @entry.routing_number = '023456789'
8
+ @entry.account_number = '123456789'
9
+ @entry.amount = 10000
10
+ @entry.individual_name = "Bob Roberts"
11
+ @entry.originating_dfi_identification = '02345678'
12
+ @entry.individual_id_number = '1'
13
+ @entry.trace_number = 1
14
+ end
15
+
16
+ describe '#addenda_records?' do
17
+ it 'should do report if it contains addena records' do
18
+ @entry.addenda_records?.should == false
19
+
20
+ @entry.addenda << ACH::Addendum.new
21
+ @entry.addenda_records?.should == true
22
+ end
23
+
24
+ it 'should print addenda records as part of to_ach' do
25
+ addendum_1 = ACH::Addendum.new
26
+ addendum_1.payment_data = ""
27
+ addendum_1.sequence_number = "1"
28
+ @entry.addenda << addendum_1
29
+ @entry.addenda.size.should == 1
30
+
31
+ addendum_2 = ACH::Addendum.new
32
+ addendum_2.payment_data = ""
33
+ addendum_2.sequence_number = "2"
34
+ @entry.addenda << addendum_2
35
+ @entry.addenda.size.should == 2
36
+
37
+ # 705 is the beginning of an addendum record
38
+ ach_string = @entry.to_ach
39
+ ach_string.scan("705").count.should == 2
40
+ end
41
+
42
+ it 'should print fields different from a CCD/PPD record' do
43
+ ach_string = @entry.to_ach
44
+ ach_string.slice(39, 15).should == "1 "
45
+ ach_string.slice(58, 16).should == "#{@entry.individual_name.upcase} "
46
+ end
47
+
48
+ it 'should set addenda record indicators, count, and trace numbers' do
49
+ #Set a trace number we expect to find in the addendum record
50
+ expected_trace_number = "474"
51
+ @entry.trace_number = expected_trace_number
52
+
53
+ addendum_1 = ACH::Addendum.new
54
+ addendum_1.payment_data = ""
55
+ addendum_1.sequence_number = "1"
56
+ @entry.addenda << addendum_1
57
+
58
+
59
+ ach_string = @entry.to_ach
60
+ # Test addenda record indicator
61
+ ach_string.slice(78, 1).should == "1"
62
+ # Test number of addenda records
63
+ ach_string.slice(54, 4).should == "0001"
64
+ # Test for trace number in each addendum record
65
+ ach_string.scan(expected_trace_number).count.should == 2
66
+ end
67
+ end
68
+
69
+
70
+ end
@@ -0,0 +1,78 @@
1
+ require 'rubygems'
2
+ require 'ach'
3
+ require 'test/unit'
4
+
5
+ class CtxEntryDetailTest < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @entry = ACH::CtxEntryDetail.new
9
+ @entry.transaction_code = ACH::CHECKING_DEBIT
10
+ @entry.routing_number = '023456789'
11
+ @entry.account_number = '123456789'
12
+ @entry.amount = 10000
13
+ @entry.individual_name = "Bob Roberts"
14
+ @entry.originating_dfi_identification = '02345678'
15
+ @entry.individual_id_number = '1'
16
+ @entry.trace_number = 1
17
+ end
18
+
19
+ def test_addenda_records?
20
+ @entry = ACH::CtxEntryDetail.new
21
+ assert @entry.addenda_records? == false
22
+
23
+ @entry.addenda << ACH::Addendum.new
24
+ assert @entry.addenda_records? == true
25
+
26
+ end
27
+
28
+ def test_ctx_entry_prints_addenda
29
+ addendum_1 = ACH::Addendum.new
30
+ addendum_1.payment_data = ""
31
+ addendum_1.sequence_number = "1"
32
+ @entry.addenda << addendum_1
33
+ assert @entry.addenda.size == 1
34
+
35
+ addendum_2 = ACH::Addendum.new
36
+ addendum_2.payment_data = ""
37
+ addendum_2.sequence_number = "2"
38
+ @entry.addenda << addendum_2
39
+ assert @entry.addenda.size == 2
40
+
41
+ # 705 is the beginning of an addendum record
42
+ ach_string = @entry.to_ach
43
+ assert ach_string.scan("705").count == 2
44
+
45
+ end
46
+
47
+ def test_ctx_correct_fields
48
+ ach_string = @entry.to_ach
49
+ assert ach_string.slice(39, 15) == "1 "
50
+ assert ach_string.slice(58, 16) == "#{@entry.individual_name.upcase} "
51
+ end
52
+
53
+ def test_to_ach_set_addendum_count_and_entry_detail_sequence_number
54
+ #Set a trace number we expect to find in the addendum record
55
+ expected_trace_number = "474"
56
+ @entry.trace_number = expected_trace_number
57
+
58
+
59
+ addendum_1 = ACH::Addendum.new
60
+ addendum_1.payment_data = ""
61
+ addendum_1.sequence_number = "1"
62
+ @entry.addenda << addendum_1
63
+
64
+
65
+ ach_string = @entry.to_ach
66
+ # Test addenda record indicator
67
+ assert ach_string.slice(78, 1) == "1"
68
+ # Test number of addenda records
69
+ assert ach_string.slice(54, 4) == "0001"
70
+ # Test for trace number in each addendum record
71
+ assert ach_string.scan(expected_trace_number).count == 2
72
+
73
+ end
74
+
75
+
76
+
77
+
78
+ end
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'micronaut'
3
3
  require 'ach'
4
+ require 'date'
4
5
 
5
6
  def not_in_editor?
6
7
  !(ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM'))
data/lib/ach.rb CHANGED
@@ -9,6 +9,9 @@ module ACH
9
9
  SAVING_DEBIT = '37'
10
10
  SAVING_CREDIT_PRENOTE = '33'
11
11
  SAVING_DEBIT_PRENOTE = '38'
12
+
13
+ LOAN_CREDIT = '52'
14
+ LOAN_CREDIT_PRENOTE = '53'
12
15
 
13
16
  # Valid service class codes
14
17
  SERVICE_CLASS_CODES = [
@@ -0,0 +1,13 @@
1
+ module ACH::Records
2
+ class Addendum < Record
3
+
4
+ @fields = []
5
+
6
+ const_field :record_type, '7'
7
+ const_field :type_code, '05'
8
+ field :payment_data, String, lambda { |f| left_justify(f, 80)}
9
+ field :sequence_number, Integer, lambda { |f| sprintf('%04d', f)}
10
+ field :entry_detail_sequence_number, Integer, lambda { |f| sprintf('%07d', f)}
11
+
12
+ end
13
+ end
@@ -35,4 +35,43 @@ module ACH::Records
35
35
  end
36
36
 
37
37
  end
38
+
39
+ class CtxEntryDetail < EntryDetail
40
+
41
+ @fields = EntryDetail.fields.slice(0, 6)
42
+ field :number_of_addenda_records, Integer, lambda { |f| sprintf('%04d', f)}, 0
43
+ field :individual_name, String, lambda { |f| left_justify(f, 16)}
44
+ const_field :reserved, ' '
45
+ field :discretionary_data, String, lambda { |f| left_justify(f, 2)}, ' '
46
+ field :addenda_record_indicator, Integer,
47
+ lambda { |f| sprintf('%01d', f)}
48
+ field :originating_dfi_identification, String,
49
+ lambda {|f| f}, nil, /\A\d{8}\Z/
50
+ field :trace_number, Integer, lambda { |f| sprintf('%07d', f)}
51
+
52
+
53
+ attr_reader :addenda
54
+
55
+ def initialize
56
+ @addenda = []
57
+ end
58
+
59
+ def addenda_records?
60
+ return !self.addenda.empty?
61
+ end
62
+
63
+ def to_ach
64
+ self.addenda_record_indicator = (self.addenda.empty? ? 0 : 1)
65
+ self.number_of_addenda_records = self.addenda.length
66
+
67
+ ach_string = super
68
+
69
+ self.addenda.each {|a|
70
+ a.entry_detail_sequence_number = self.trace_number
71
+ ach_string << a.to_ach
72
+ }
73
+ return ach_string
74
+ end
75
+
76
+ end
38
77
  end
metadata CHANGED
@@ -1,40 +1,30 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ach
3
- version: !ruby/object:Gem::Version
4
- hash: 85
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 0
10
- - 1
11
- version: 0.3.0.1
12
6
  platform: ruby
13
- authors:
7
+ authors:
14
8
  - Jared Morgan
15
9
  - Josh Puetz
16
10
  autorequire:
17
11
  bindir: bin
18
12
  cert_chain: []
19
-
20
- date: 2009-11-29 00:00:00 -06:00
21
- default_executable:
13
+ date: 2012-10-23 00:00:00.000000000 Z
22
14
  dependencies: []
15
+ description: ! 'ach is a Ruby helper for builder ACH files. In particular, it helps
16
+ with field
23
17
 
24
- description: |
25
- ach is a Ruby helper for builder ACH files. In particular, it helps with field
26
18
  order and alignment, and adds padding lines to end of file.
27
19
 
20
+ '
28
21
  email: jmorgan@morgancreative.net
29
22
  executables: []
30
-
31
23
  extensions: []
32
-
33
- extra_rdoc_files:
24
+ extra_rdoc_files:
34
25
  - README.md
35
- files:
26
+ files:
36
27
  - .autotest
37
- - .gitignore
38
28
  - MIT-LICENSE
39
29
  - README.md
40
30
  - Rakefile
@@ -45,6 +35,8 @@ files:
45
35
  - examples/ach/field_identifiers_example.rb
46
36
  - examples/ach/records/batch_control_example.rb
47
37
  - examples/ach/records/batch_header_example.rb
38
+ - examples/ach/records/ctx_entry_detail_example.rb
39
+ - examples/ach/records/ctx_entry_detail_test.rb
48
40
  - examples/ach/records/nines_example.rb
49
41
  - examples/ach/records/shared/batch_summaries.rb
50
42
  - examples/example_helper.rb
@@ -60,46 +52,28 @@ files:
60
52
  - lib/ach/records/file_header.rb
61
53
  - lib/ach/records/nines.rb
62
54
  - lib/ach/records/record.rb
63
- has_rdoc: true
64
55
  homepage: http://github.com/jm81/ach
65
56
  licenses: []
66
-
67
57
  post_install_message:
68
- rdoc_options:
69
- - --charset=UTF-8
70
- require_paths:
58
+ rdoc_options: []
59
+ require_paths:
71
60
  - lib
72
- required_ruby_version: !ruby/object:Gem::Requirement
61
+ required_ruby_version: !ruby/object:Gem::Requirement
73
62
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
81
- required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
68
  none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
90
73
  requirements: []
91
-
92
74
  rubyforge_project:
93
- rubygems_version: 1.6.2
75
+ rubygems_version: 1.8.10
94
76
  signing_key:
95
77
  specification_version: 3
96
78
  summary: Helper for building ACH files in Ruby
97
- test_files:
98
- - examples/ach/field_identifiers_example.rb
99
- - examples/ach/ach_file_example.rb
100
- - examples/ach/records/nines_example.rb
101
- - examples/ach/records/shared/batch_summaries.rb
102
- - examples/ach/records/batch_control_example.rb
103
- - examples/ach/records/batch_header_example.rb
104
- - examples/ach/batch_example.rb
105
- - examples/example_helper.rb
79
+ test_files: []
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- *.sw?
2
- .DS_Store
3
- coverage
4
- rdoc
5
- pkg
6
- .project
7
- .loadpath
8
- *qt_temp*
9
- *~
10
- *.gem