Sha256: d2717dd827701697c9bd97174075915ccf3d53738c384544fa9c19a826760f9a
Contents?: true
Size: 1.6 KB
Versions: 33
Compression:
Stored size: 1.6 KB
Contents
require 'subj_models/concerns/comprising_external_id' require 'subj_models/services/values_checker' module SubjModels module OrderItemModule include SubjModels::TypesSupport::ItemTypes include SubjModels::ValuesChecker def self.included(including_class) including_class.class_eval do include SubjModels::ComprisingExternalId # before_destroy :decrease_nomenclature_popularity # after_create :increase_nomenclature_popularity enum item_type: ITEM_TYPES belongs_to :order belongs_to :event belongs_to :nomenclature_variety belongs_to :nomenclature belongs_to :quality validates :item_type, presence: true, inclusion: { in: item_types.keys } validates :item_price, :item_count, presence: true scope :order_id, -> (order_id) { parent_id_scope("order", order_id) } scope :without_autoadded, -> { where(autoaddedposition: [nil, false]) } end end def to_s id.to_s # TODO end private # def increase_nomenclature_popularity # if nomenclature # current_popularity = (nomenclature.popularity && nomenclature.popularity > 0) ? nomenclature.popularity : 0 # nomenclature.update(popularity: current_popularity + item_count) # end # end # def decrease_nomenclature_popularity # if nomenclature # current_popularity = (nomenclature.popularity && nomenclature.popularity > item_count) ? nomenclature.popularity : item_count # nomenclature.update(popularity: current_popularity - item_count) # end # end end end
Version data entries
33 entries across 33 versions & 2 rubygems