Class: RockRMS::Response::Transaction
- Inherits:
-
Base
- Object
- Base
- RockRMS::Response::Transaction
show all
- Defined in:
- lib/rock_rms/response/transaction.rb
Constant Summary
collapse
- MAP =
{
id: 'Id',
date: 'TransactionDateTime',
person: 'AuthorizedPersonAlias',
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
Instance Attribute Summary
Attributes inherited from Base
#data
Instance Method Summary
collapse
Methods inherited from Base
format, #format, #initialize, #to_h
Instance Method Details
#calculate_total(details) ⇒ Object
35
36
37
|
# File 'lib/rock_rms/response/transaction.rb', line 35
def calculate_total(details)
details.reduce(0) { |sum, td| sum + td[:amount] }
end
|
30
31
32
33
|
# File 'lib/rock_rms/response/transaction.rb', line 30
def format_person(res)
return res if res.nil?
Person.format(res['Person'])
end
|
21
22
23
24
25
26
27
28
|
# File 'lib/rock_rms/response/transaction.rb', line 21
def format_single(data)
response = to_h(MAP, data)
response[:details] = TransactionDetail.format(response[:details])
response[:payment_details] = PaymentDetail.format(response[:payment_details])
response[:person] = format_person(response[:person])
response[:amount] = calculate_total(response[:details])
response
end
|