Sha256: c21c2f31206791bac97558516111652852ada3b3b61a74ca55dcaf8da7c797d5
Contents?: true
Size: 796 Bytes
Versions: 2
Compression:
Stored size: 796 Bytes
Contents
module ACH class Batch < Component has_many :entries def has_credit? entries.any?(&:credit?) end def has_debit? entries.any?(&:debit?) end def entry_count entries.length end def entry_hash entries.map{ |e| e.routing_number.to_i / 10 }.compact.inject(&:+) end def total_debit_amount entries.select(&:debit?).map{ |e| e.amount.to_i }.compact.inject(&:+) || 0 end def total_credit_amount entries.select(&:credit?).map{ |e| e.amount.to_i }.compact.inject(&:+) || 0 end def to_ach [header] + entries + [control] end def before_header attributes[:service_class_code] ||= (has_debit? && has_credit? ? 200 : has_debit? ? 225 : 220) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ach_builder-0.0.2 | lib/ach/batch.rb |
ach_builder-0.0.1.1 | lib/ach/batch.rb |