Sha256: dc7dceeb83479fea910aaef417a9b37de103e613f9134fc46dbb6748a97a2cea
Contents?: true
Size: 1.82 KB
Versions: 1
Compression:
Stored size: 1.82 KB
Contents
require "money" module InvestecOpenApi::Models class Transaction < Base attr_reader :id, :account_id, :posted_order, :type, :transaction_type, :status, :card_number, :amount, :description, :running_balance, :date, :posting_date, :value_date, :action_date ## Unique identifier # Composite key generated by Investec using the following formula: # account_id.slice(0, 5) + posting_date.gsub(/-/, "") + posted_order.to_s.rjust(7, "0") # This will only be populated for posted transaction on Private Bank Accounts. # This is not a backend banking generated ID and will change if any of the properties making it up changes. attr_reader :uuid def initialize(params) super set_id end # Investec exposes a uuid for uniqueness so this is no longer needed (non-pending transactions). # It is kept here for legacy purposes. It is also useful for pending transactions. def set_id @id = [ amount.to_i, description, date.to_s ].map(&:to_s).join('-') end def self.from_api(params, currency = "ZAR") params["currency"] = currency should_make_amount_negative = params['type'] == 'DEBIT' convert_param_value_to_money(params, "amount", "currency", should_make_amount_negative) convert_param_value_to_money(params, "runningBalance") rewrite_param_key(params, "transactionDate", "date") convert_param_value_to_date(params, "date") convert_param_value_to_date(params, "postingDate") convert_param_value_to_date(params, "valueDate") convert_param_value_to_date(params, "actionDate") new params end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
investec_open_api-2.1.0 | lib/investec_open_api/models/transaction.rb |