Sha256: 950214c5447ec50b20116489005c9280eb30fd9e4ad1c4d9af6c4d6ca4fb461f

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

class BizTxnType < ActiveRecord::Base
  attr_protected :created_at, :updated_at

	acts_as_nested_set
	include ErpTechSvcs::Utils::DefaultNestedSetMethods
	acts_as_erp_type

  belongs_to_erp_type :parent, :class_name => "BizTxnType"

  # this method handles default behavior for find by type and subtype
  def self.find_by_type_and_subtype(txn_type, txn_subtype)
    return self.find_by_type_and_subtype_eid(txn_type, txn_subtype)
  end

  # find by type Internal Identifier and subtype Internal Identifier
  def self.find_by_type_and_subtype_iid(txn_type, txn_subtype)
    txn_type_recs = find_all_by_internal_identifier(txn_type.strip)
    return nil if txn_type_recs.blank?
    txn_type_recs.each do |txn_type_rec|
      txn_subtype_rec = find_by_parent_id_and_internal_identifier(txn_type_rec.id, txn_subtype.strip)
      return txn_subtype_rec unless txn_subtype_rec.nil?
    end
    return nil
  end

  # find by type External Identifier and subtype External Identifier
  def self.find_by_type_and_subtype_eid(txn_type, txn_subtype)
    txn_type_recs = find_all_by_external_identifier(txn_type.strip)
    return nil if txn_type_recs.blank?
    txn_type_recs.each do |txn_type_rec|
      txn_subtype_rec = find_by_parent_id_and_external_identifier(txn_type_rec.id, txn_subtype.strip)
      return txn_subtype_rec unless txn_subtype_rec.nil?
    end
    return nil
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
erp_txns_and_accts-4.0.0 app/models/biz_txn_type.rb
erp_txns_and_accts-3.1.1 app/models/biz_txn_type.rb
erp_txns_and_accts-3.1.0 app/models/biz_txn_type.rb