Sha256: 80e10e293861b2c71b53d88c29506aaa835bb7fc59dafb3c54fae17802313c15

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 Bytes

Contents

class ProductType < ActiveRecord::Base
  acts_as_nested_set
  include ErpTechSvcs::Utils::DefaultNestedSetMethods
  
  acts_as_priceable
  has_file_assets
  is_describable
  
	belongs_to :product_type_record, :polymorphic => true  
  has_one    :product_instance
  
  def prod_type_relns_to
    ProdTypeReln.where('prod_type_id_to = ?',id)
  end

  def prod_type_relns_from
    ProdTypeReln.where('prod_type_id_from = ?',id)
  end
 
  def to_label
    "#{description}"
  end
  
  def to_s
    "#{description}"
  end

  def self.count_by_status(product_type, prod_availability_status_type)
    ProductInstance.count("product_type_id = #{product_type.id} and prod_availability_status_type_id = #{prod_availability_status_type.id}")
  end
  
  def images_path
    file_support = ErpTechSvcs::FileSupport::Base.new(:storage => ErpTechSvcs::FileSupport.options[:storage])
    File.join(file_support.root,'products/images',"#{self.description.underscore}_#{self.id}")
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
erp_products-3.0.0 app/models/product_type.rb