Commit 3735d662 by ivan Lan

Fix spec validation in series & Add code about stock in series

parent 2a046bc4
...@@ -55,6 +55,11 @@ module Shotengai ...@@ -55,6 +55,11 @@ module Shotengai
end end
end end
def cut_stock count
self.stock -= count
self.save!
end
private private
# spec 字段 # spec 字段
def check_spec_value def check_spec_value
...@@ -66,7 +71,7 @@ module Shotengai ...@@ -66,7 +71,7 @@ module Shotengai
end end
def uniq_spec def uniq_spec
errors.add(:spec, 'Non uniq spec for the product.') if self.class.where(self.spec, self.product).any? errors.add(:spec, 'Non uniq spec for the product.') if self.class.query_spec_with_product(self.spec, self.product).any?
end end
def validate_stock def validate_stock
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment