Sha256: 120da5a65fa4022b75b61300db1b1189340106dd64c48a872288f8de6307852f
Contents?: true
Size: 909 Bytes
Versions: 1
Compression:
Stored size: 909 Bytes
Contents
module ACH class File < Component has_many :batches, lambda{ {:batch_number => batches.length + 1} } def batch_count batches.length end def block_count (entry_count / 10.0).ceil end def entry_count batches.map{ |b| b.entries.length }.inject(&:+) || 0 end def entry_hash batches.map(&:entry_hash).compact.inject(&:+) end def total_debit_amount batches.map(&:total_debit_amount).compact.inject(&:+) end def total_credit_amount batches.map(&:total_credit_amount).compact.inject(&:+) end def to_ach [header] + batches.map(&:to_ach).flatten + [control] end def to_s! to_ach.map(&:to_s!).join("\n") end def write filename return false unless valid? ::File.open(filename, 'w') do |fh| fh.write(to_s!) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ach_builder-0.0.1.1 | lib/ach/file.rb |