Sha256: 42aa3765ecbd4182bfc5a2f3ca1eeb0f96ac8e30aa17fb24e06b7101dd904e18

Contents?: true

Size: 1.05 KB

Versions: 45

Compression:

Stored size: 1.05 KB

Contents

module Bankserv

  class NotifyMeStatement < ActiveRecord::Base
    
    has_many :notify_me_transactions, :foreign_key => 'bankserv_notify_me_statement_id'
  
    def self.store(file)
      options = Absa::NotifyMe::XmlStatement.file_to_hash(file)
      
      raise "Expected a document set" unless options[:type] == "document"
      
      client_code = options[:data][:data][0][:data][:client_code]
    
      statement = new
      statement.client_code = client_code
      statement.data = options
      statement.save!
      statement
    end
  
    def process!
      raise "Document already processed" if processed?
    
      recon_account_detail_records.each do |record|
        Bankserv::NotifyMeTransaction.create! data: record[:data], client_code: client_code, bankserv_notify_me_statement_id: id
      end
    
      self.processed = true
      self.save
    end
  
    def recon_transmission_data
      data[:data][:data]
    end
  
    def recon_account_detail_records
      recon_transmission_data.select{|item| item[:type] == 'detail'}
    end
  
  end
  
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
bankserv-0.8.6 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.8.5 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.8.4 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.8.2 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.8.1 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.8.0 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.7.9 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.7.8 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.7.7 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.7.6 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.7.5 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.7.4 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.7.3 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.7.2 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.7.1 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.7.0 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.6.9 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.6.8 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.6.7 lib/bankserv/transmission/notify_me_statement.rb
bankserv-0.6.6 lib/bankserv/transmission/notify_me_statement.rb