Second part of stock-integration.
Introduced StockArticle and a special page for ordering from stock. StockChanges will be created and the StockArticle.quantity updated in 'order.close!'.
This commit is contained in:
parent
1912a3fd80
commit
c17b63b192
37 changed files with 616 additions and 340 deletions
|
|
@ -1,22 +1,22 @@
|
|||
# == Schema Information
|
||||
# Schema version: 20090119155930
|
||||
# Schema version: 20090120184410
|
||||
#
|
||||
# Table name: stock_changes
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# delivery_id :integer
|
||||
# order_id :integer
|
||||
# article_id :integer
|
||||
# quantity :decimal(6, 2) default(0.0)
|
||||
# created_at :datetime
|
||||
# id :integer not null, primary key
|
||||
# delivery_id :integer
|
||||
# order_id :integer
|
||||
# stock_article_id :integer
|
||||
# quantity :decimal(, ) default(0.0)
|
||||
# created_at :datetime
|
||||
#
|
||||
|
||||
class StockChange < ActiveRecord::Base
|
||||
belongs_to :delivery
|
||||
belongs_to :order
|
||||
belongs_to :article
|
||||
belongs_to :stock_article
|
||||
|
||||
validates_presence_of :article_id, :quantity
|
||||
validates_presence_of :stock_article_id, :quantity
|
||||
validates_numericality_of :quantity
|
||||
|
||||
after_save :update_article_quantity
|
||||
|
|
@ -25,6 +25,6 @@ class StockChange < ActiveRecord::Base
|
|||
protected
|
||||
|
||||
def update_article_quantity
|
||||
article.update_quantity!
|
||||
stock_article.update_quantity!
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue