Sha256: 4a6e2e18186e6a6cc076b8a49d1d766a28fddbf21e21c970f12b3b2d48dbfa25
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
module RockRMS module Response class Transaction < Base MAP = { id: 'Id', date: 'TransactionDateTime', person_id: 'AuthorizedPersonAliasId', batch_id: 'BatchId', gateway_id: 'FinancialGatewayId', recurring_donation_id: 'ScheduledTransactionId', summary: 'Summary', transaction_code: 'TransactionCode', details: 'TransactionDetails', payment_details: 'FinancialPaymentDetail', payment_detail_id: 'FinancialPaymentDetailId', transaction_type_id: 'TransactionTypeValueId' }.freeze def format_single(data) response = to_h(MAP, data) response[:details] = TransactionDetail.format(response[:details]) response[:payment_details] = PaymentMethod.format(response[:payment_details]) response[:amount] = calculate_total(response[:details]) response end def calculate_total(details) details.reduce(0) { |sum, td| sum + td[:amount] } end end end end
Version data entries
5 entries across 5 versions & 1 rubygems