2009-01-16 02:17:49 +01:00
|
|
|
class StockChange < ActiveRecord::Base
|
|
|
|
belongs_to :delivery
|
|
|
|
belongs_to :order
|
2013-07-09 21:46:04 +02:00
|
|
|
belongs_to :stock_taking
|
2013-03-16 17:53:24 +01:00
|
|
|
belongs_to :stock_article
|
2009-01-16 02:17:49 +01:00
|
|
|
|
2009-02-06 16:26:35 +01:00
|
|
|
validates_presence_of :stock_article_id, :quantity
|
2009-01-16 02:17:49 +01:00
|
|
|
validates_numericality_of :quantity
|
|
|
|
|
|
|
|
after_save :update_article_quantity
|
2009-02-05 16:40:02 +01:00
|
|
|
after_destroy :update_article_quantity
|
2009-01-16 02:17:49 +01:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def update_article_quantity
|
2009-02-06 16:26:35 +01:00
|
|
|
stock_article.update_quantity!
|
2009-01-16 02:17:49 +01:00
|
|
|
end
|
|
|
|
end
|
2011-05-07 21:55:24 +02:00
|
|
|
|