Browse files

make BatchHeader#standard_entry_class_code a regular field

I had set it as a const_field--apparently out of laziness.
Still defaults to PPD (may change that later?)
  • Loading branch information...
jm81 committed Nov 6, 2009
1 parent 263e8bd commit 797da342860fcbd7e0aba301f18fd04a4e3c9cfb
Showing with 32 additions and 2 deletions.
  1. +1 −0
  2. +26 −0 examples/ach/records/batch_header_example.rb
  3. +5 −2 lib/ach/records/batch_header.rb
@@ -31,6 +31,7 @@ on individual fields. You can probably obtain a copy from your bank.
bh = batch.header
bh.company_name = "Company Name"
bh.company_identification = "123456789"
bh.standard_entry_class_code = 'PPD'
bh.company_entry_description = "DESCRIPTION"
bh.company_descriptive_date =
bh.effective_entry_date = ( + 1)
@@ -0,0 +1,26 @@
require 'example_helper'
describe ACH::Records::BatchHeader do
before(:each) do
@record =
describe '#standard_entry_class_code' do
it 'should default to PPD' do
@record.standard_entry_class_code_to_ach.should == 'PPD'
it 'should be capitalized' do
@record.standard_entry_class_code = 'ccd'
@record.standard_entry_class_code_to_ach.should == 'CCD'
it 'should be exactly three characters' do
lambda { @record.standard_entry_class_code = 'CCDA' }.should raise_error(RuntimeError)
lambda { @record.standard_entry_class_code = 'CC' }.should raise_error(RuntimeError)
lambda { @record.standard_entry_class_code = 'CCD' }.should_not raise_error(RuntimeError)
it 'should be limited to real codes'
@@ -12,8 +12,11 @@ class BatchHeader < Record
field :company_identification, String,
lambda {|f| '1' + f}, nil, /\A\d{9}\Z/,
'Company Tax ID'
#TODO Allow being set as a default/preference?
const_field :standard_entry_class_code, 'CCD'
# TODO This should be used to determine whether other records are valid for
# for this code. Should there be a Class for each code?
# The default of PPD is purely for my benefit (Jared Morgan)
field :standard_entry_class_code, String,
lambda { |f| f.upcase }, 'PPD', /\A\w{3}\Z/
field :company_entry_description, String,
lambda { |f| left_justify(f, 10)}
field :company_descriptive_date, Time,

1 comment on commit 797da34


This comment has been minimized.


jm81 commented on 797da34 Nov 6, 2009

I'm not sure why I made this a const_field (laziness, probably). I've just committed a change to make this a regular field

Please sign in to comment.