Sha256: 9dfe23c52a623b190cb99c1c74f5ea5ad33ffcd61cebd055961521ccb9faab63
Contents?: true
Size: 1014 Bytes
Versions: 1
Compression:
Stored size: 1014 Bytes
Contents
module RockRMS module Response class Batch < Base MAP = { id: 'Id', name: 'Name', control_amount: 'ControlAmount', transactions: 'Transactions', start_date: 'BatchStartDateTime', end_date: 'BatchEndDateTime', campus_id: 'CampusId', is_campus: 'Campus', status: 'Status', }.freeze def format_single(data) response = to_h(MAP, data) response[:transactions] = Transaction.format(response[:transactions]) response[:amount] = calculate_total(response[:transactions]) response[:start_date] = date_parse(response[:start_date]) response[:end_date] = date_parse(response[:end_date]) response end def calculate_total(transactions) transactions.reduce(0) { |sum, txn| sum + txn[:amount] } end def date_parse(string) if string DateTime.parse(string) else nil end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rock_rms-3.4.1 | lib/rock_rms/response/batch.rb |