Sha256: 67ab75cb80972a4a3d3c11df2d7d5ace3bde05a377b3732b6ef92454eacd2eaa

Contents?: true

Size: 944 Bytes

Versions: 21

Compression:

Stored size: 944 Bytes

Contents

class Bankserv::OutputDocument < Bankserv::Document

  after_create :set_user_ref!

  def set_user_ref!
    self.user_ref ||= self.set.header.data[:th_for_use_of_ld_user]
    self.save!
  end
  
  def self.document_type
    'output'
  end
  
  def self.store(string)
    options = Absa::H2h::Transmission::Document.hash_from_s(string, 'output')
    
    raise "Expected a document set" unless options[:type] == "document"
    
    document = Bankserv::OutputDocument.new(
      type: 'output',
      client_code: options[:data][0][:data][:client_code]
    )
    
    document.set = Bankserv::Set.from_hash(options)
    document.set.document = document # whaaaaaa?
    document.save!
    document
  end
  
  def process!
    raise "Document already processed" if processed?
    
    self.set.process
    self.processed = true
    self.save
  end

  def self.for_user_ref(user_ref)
    where(type: 'output', user_ref: user_ref).first
  end
  
end

Version data entries

21 entries across 21 versions & 1 rubygems

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