ach_builder 0.0.2 → 0.2.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.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +2 -1
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +10 -0
  7. data/Gemfile +11 -2
  8. data/MIT-LICENSE +1 -1
  9. data/README.md +19 -11
  10. data/Rakefile +44 -0
  11. data/ach_builder.gemspec +9 -5
  12. data/lib/ach/batch.rb +10 -32
  13. data/lib/ach/batch/builder.rb +60 -0
  14. data/lib/ach/batch/control.rb +18 -3
  15. data/lib/ach/batch/header.rb +21 -4
  16. data/lib/ach/component.rb +125 -43
  17. data/lib/ach/component/has_many_association.rb +155 -0
  18. data/lib/ach/constants.rb +15 -1
  19. data/lib/ach/file.rb +50 -44
  20. data/lib/ach/file/builder.rb +81 -0
  21. data/lib/ach/file/control.rb +15 -3
  22. data/lib/ach/file/header.rb +20 -3
  23. data/lib/ach/file/reader.rb +103 -0
  24. data/lib/ach/file/transmission_header.rb +77 -0
  25. data/lib/ach/formatter.rb +113 -76
  26. data/lib/ach/formatter/rule.rb +27 -0
  27. data/lib/ach/record.rb +13 -64
  28. data/lib/ach/record/addenda.rb +25 -0
  29. data/lib/ach/record/base.rb +109 -0
  30. data/lib/ach/record/dynamic.rb +58 -0
  31. data/lib/ach/record/entry.rb +49 -0
  32. data/lib/ach/record/tail.rb +10 -0
  33. data/lib/ach/validations.rb +5 -3
  34. data/lib/ach/version.rb +1 -1
  35. data/lib/ach_builder.rb +20 -33
  36. data/spec/batch_spec.rb +23 -11
  37. data/spec/componenet/has_many_association_spec.rb +111 -0
  38. data/spec/file_spec.rb +173 -81
  39. data/spec/formatter_spec.rb +9 -9
  40. data/spec/reader_spec.rb +55 -0
  41. data/spec/record/addenda_spec.rb +8 -0
  42. data/spec/record/base_spec.rb +53 -0
  43. data/spec/record/dynamic_spec.rb +74 -0
  44. data/spec/record/entry_spec.rb +7 -0
  45. data/spec/record/tail_spec.rb +7 -0
  46. data/spec/spec_helper.rb +1 -0
  47. data/spec/support/ach_file_factory.rb +70 -0
  48. data/spec/support/examples/well_fargo_empty.ach +2 -0
  49. data/spec/support/examples/well_fargo_with_data.ach +6 -0
  50. data/spec/support/helpers/ach_files_examples.rb +17 -0
  51. metadata +69 -26
  52. data/lib/ach/entry.rb +0 -31
  53. data/lib/ach/tail.rb +0 -6
  54. data/spec/entry_spec.rb +0 -7
  55. data/spec/record_spec.rb +0 -34
  56. data/spec/tail_spec.rb +0 -7
@@ -1,31 +0,0 @@
1
- module ACH
2
- class Entry < Record
3
- CREDIT_TRANSACTION_CODE_ENDING_DIGITS = ('0'..'4').to_a.freeze
4
-
5
- fields :record_type,
6
- :transaction_code,
7
- :routing_number,
8
- :bank_account,
9
- :amount,
10
- :customer_acct,
11
- :customer_name,
12
- :transaction_type,
13
- :addenda,
14
- :bank_15
15
-
16
- defaults :record_type => 6,
17
- :transaction_code => 27,
18
- :transaction_type => 'S',
19
- :customer_acct => '',
20
- :addenda => 0,
21
- :bank_15 => ''
22
-
23
- def debit?
24
- !credit?
25
- end
26
-
27
- def credit?
28
- CREDIT_TRANSACTION_CODE_ENDING_DIGITS.include? transaction_code.to_s[1..1]
29
- end
30
- end
31
- end
@@ -1,6 +0,0 @@
1
- module ACH
2
- class Tail < Record
3
- fields :nines
4
- defaults :nines => '9' * RECORD_SIZE
5
- end
6
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ACH::Entry do
4
- it "should have length of 94" do
5
- ACH.sample_file.batch(0).entry(0).to_s!.length.should == ACH::Constants::RECORD_SIZE
6
- end
7
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ACH::Record do
4
- before(:all) do
5
- class Entry < ACH::Record
6
- fields :customer_name, :amount
7
- defaults :customer_name => 'JOHN SMITH'
8
- end
9
- end
10
-
11
- it "should have 2 ordered fields" do
12
- Entry.fields.should == [:customer_name, :amount]
13
- end
14
-
15
- it "should create a record with default value" do
16
- Entry.new.customer_name.should == 'JOHN SMITH'
17
- end
18
-
19
- it "should overwrite default value" do
20
- entry = Entry.new(:customer_name => 'SMITH JOHN')
21
- entry.customer_name.should == 'SMITH JOHN'
22
- end
23
-
24
- it "should generate formatted string" do
25
- entry = Entry.new :amount => 1599
26
- entry.to_s!.should == "JOHN SMITH".ljust(22) + "1599".rjust(10, '0')
27
- end
28
-
29
- it "should raise exception with unfilled value" do
30
- lambda{
31
- Entry.new.to_s!
32
- }.should raise_error(ACH::Record::EmptyField)
33
- end
34
- end
@@ -1,7 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ACH::Tail do
4
- it "should have length of 94" do
5
- ACH::Tail.new.to_s!.length.should == ACH::Constants::RECORD_SIZE
6
- end
7
- end