Module: SubjModels::NomenclaturePriceModule

Defined in:
lib/subj_models/nomenclature_price.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(including_class) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/subj_models/nomenclature_price.rb', line 7

def self.included(including_class)

  including_class.class_eval do

    include SubjModels::ComprisingExternalId

    belongs_to :nomenclature, touch: true
    belongs_to :nomenclature_variety
    belongs_to :price_type
    belongs_to :quality
    belongs_to :measure_unit
    belongs_to :event

    has_many :order_items

    validates :current_price, presence: true

    scope :nomenclature_id, -> (nomenclature_id) { parent_id_scope("nomenclature", nomenclature_id) }

    scope :belongs_to_nomenclature, -> (nomenclature_id) do
      where(nomenclature_id: nomenclature_id).union(joins(:nomenclature_variety).where("nomenclature_varieties.nomenclature_id" => nomenclature_id))
    end

  end

end

Instance Method Details

#to_sObject



34
35
36
# File 'lib/subj_models/nomenclature_price.rb', line 34

def to_s
  id.to_s # TODO
end