module Skr::Concerns::IsSkuLocLine::InstanceMethods
Public Instance Methods
ea_qty()
click to toggle source
# File lib/skr/concerns/is_sku_loc_line.rb, line 17 def ea_qty self.qty*self.uom_size end
extended_price()
click to toggle source
# File lib/skr/concerns/is_sku_loc_line.rb, line 25 def extended_price self.price && self.qty ? self.price * self.qty : BigDecimal.new(0) end
is_other_charge?()
click to toggle source
# File lib/skr/concerns/is_sku_loc_line.rb, line 21 def is_other_charge? self.sku.is_other_charge? end
uom_record()
click to toggle source
# File lib/skr/concerns/is_sku_loc_line.rb, line 9 def uom_record if self.association(:sku).loaded? && self.sku.association(:uoms).loaded? self.sku.uoms.detect{|uom| uom.code == self.uom_code } else self.sku.uoms.where({ code: self.uom_code }).first end end
Private Instance Methods
ensure_sku_does_not_change()
click to toggle source
# File lib/skr/concerns/is_sku_loc_line.rb, line 31 def ensure_sku_does_not_change errors.add(:sku, "can not be updated") if changes['sku_code'] if change = changes['sku_loc_id'] # allow if the sku_id is the same on both old & new locations unless 1 == SkuLoc.where( id: change ).pluck('sku_id').uniq.length errors.add(:sku, "must be the same in both locations") if sku_code_changed? end end end