Class: OFX::BankingStatementResponse

Inherits:
TransactionalResponse show all
Defined in:
lib/ofx/banking_message_set.rb,
lib/ofx/1.0.2/banking_message_set.rb

Instance Attribute Summary collapse

Attributes inherited from TransactionalResponse

#client_cookie, #transaction_identifier

Attributes inherited from Response

#status

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TransactionalResponse

#to_ofx_102_s

Methods inherited from Response

#to_ofx_102_s

Instance Attribute Details

#accountObject

Returns the value of attribute account.



116
117
118
# File 'lib/ofx/banking_message_set.rb', line 116

def 
  @account
end

#available_balanceObject

Returns the value of attribute available_balance.



120
121
122
# File 'lib/ofx/banking_message_set.rb', line 120

def available_balance
  @available_balance
end

#default_currencyObject

Returns the value of attribute default_currency.



115
116
117
# File 'lib/ofx/banking_message_set.rb', line 115

def default_currency
  @default_currency
end

#ledger_balanceObject

Returns the value of attribute ledger_balance.



119
120
121
# File 'lib/ofx/banking_message_set.rb', line 119

def ledger_balance
  @ledger_balance
end

#marketing_informationObject

Returns the value of attribute marketing_information.



117
118
119
# File 'lib/ofx/banking_message_set.rb', line 117

def marketing_information
  @marketing_information
end

#transaction_rangeObject

Returns the value of attribute transaction_range.



122
123
124
# File 'lib/ofx/banking_message_set.rb', line 122

def transaction_range
  @transaction_range
end

#transactionsObject

Returns the value of attribute transactions.



123
124
125
# File 'lib/ofx/banking_message_set.rb', line 123

def transactions
  @transactions
end

Class Method Details

.from_ofx_102_hash(transaction_hash) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/ofx/1.0.2/banking_message_set.rb', line 190

def self.from_ofx_102_hash(transaction_hash)
    response = BankingStatementResponse.new
               
    response.transaction_identifier = transaction_hash['TRNUID']
    response.status = OFX::Status.from_ofx_102_hash(transaction_hash['STATUS'])
    
    response_hash = transaction_hash['STMTRS']
    return unless response_hash
    
    response.default_currency = response_hash['CURDEF']
    response. = BankingAccount.from_ofx_102_hash(response_hash['BANKACCTFROM'])
    
    response.marketing_information = response_hash['MKTGINFO']

    response.ledger_balance = Balance.from_ofx_102_hash(response_hash['LEDGERBAL']) if response_hash['LEDGERBAL']
    response.available_balance = Balance.from_ofx_102_hash(response_hash['AVAILBAL']) if response_hash['AVAILBAL']
    
    transaction_list_hash = response_hash['BANKTRANLIST']
    if (transaction_list_hash)
        if transaction_list_hash['DTSTART'] && transaction_list_hash['DTEND']
            response.transaction_range = transaction_list_hash['DTSTART'].to_datetime..transaction_list_hash['DTEND'].to_datetime
        end
        
        response.transactions = []
        transactions = transaction_list_hash['STMTTRN'] if transaction_list_hash['STMTTRN'].kind_of?(Array)
        transactions = [transaction_list_hash['STMTTRN']] if transaction_list_hash['STMTTRN'].kind_of?(Hash)
        transactions = [] unless transactions
        
        transactions.each do |transaction_hash|
            transaction = Transaction.new
            
            transaction.transaction_type = Transaction.ofx_102_transaction_type_name_to_transaction_type(transaction_hash['TRNTYPE'])
            transaction.date_posted = transaction_hash['DTPOSTED'].to_datetime if transaction_hash['DTPOSTED']
            transaction.date_initiated = transaction_hash['DTUSER'].to_datetime if transaction_hash['DTUSER']
            transaction.date_available = transaction_hash['DTAVAIL'].to_datetime if transaction_hash['DTAVAIL']

            transaction.amount = transaction_hash['TRNAMT'].to_d if transaction_hash['TRNAMT']
            transaction.currency = transaction_hash['CURRENCY'] || transaction_hash['ORIGCURRENCY'] || response.default_currency

            transaction.financial_institution_transaction_identifier = transaction_hash['FITID']
            transaction.corrected_financial_institution_transaction_identifier = transaction_hash['CORRECTFITID']
            transaction.correction_action = case transaction_hash['CORRECT_ACTION']
                                                when 'REPLACE' then :replace
                                                when 'DELETE'  then :delete
                                            end if transaction_hash['CORRECT_ACTION']
            transaction.server_transaction_identifier = transaction_hash['SRVRTID']
            transaction.check_number = transaction_hash['CHECKNUM']
            transaction.reference_number = transaction_hash['REFNUM']
                    
            transaction.standard_industrial_code = transaction_hash['SIC']
            
            transaction.payee_identifier = transaction_hash['PAYEEID']
            if transaction_hash['PAYEE']
                raise NotImplementedError
            else
                transaction.payee = transaction_hash['NAME']
            end
            
            if (transaction_hash['BANKACCTTO'])
                transaction. = BankingAccount.from_ofx_102_hash(transaction_hash['BANKACCTTO'])
            elsif (transaction_hash['CCACCTTO'])
                transaction. = CreditCardAccount.from_ofx_102_hash(transaction_hash['CCACCTTO'])
            end
            
            transaction.memo = transaction_hash['MEMO']
            
            response.transactions << transaction
        end
    end
    
    response
end

Instance Method Details

#ofx_102_nameObject



182
183
184
# File 'lib/ofx/1.0.2/banking_message_set.rb', line 182

def ofx_102_name
    'STMT'
end

#ofx_102_response_bodyObject

Raises:

  • (NotImplementedError)


186
187
188
# File 'lib/ofx/1.0.2/banking_message_set.rb', line 186

def ofx_102_response_body
    raise NotImplementedError
end