Sha256: 1eda5b6236f4c998e30fdc8832fb9f6ea1dd74a138ef44bdb4e54f0de294f26c
Contents?: true
Size: 1.09 KB
Versions: 33
Compression:
Stored size: 1.09 KB
Contents
module Bankserv class Statement < ActiveRecord::Base has_many :transactions, :foreign_key => 'bankserv_statement_id' def self.store(string) options = Absa::Esd::Transmission::Document.hash_from_s(string) raise "Expected a document set" unless options[:type] == "document" client_code = options[:data][0][: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::Transaction.create! data: record[:data], client_code: client_code, bankserv_statement_id: id end self.processed = true self.save end def recon_transmission_data data[:data][0][:data] end def recon_account_data recon_transmission_data[1][:data] end def recon_account_detail_records recon_account_data.select{|item| item[:type] == 'detail'} end end end
Version data entries
33 entries across 33 versions & 1 rubygems