Sha256: f9d9c76b3b7e3fe70bacbc45a2f5fbdce6e1cd15ab2e811839d200b1dea3fea8
Contents?: true
Size: 1013 Bytes
Versions: 41
Compression:
Stored size: 1013 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
41 entries across 41 versions & 1 rubygems