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
|
|
@ -22,6 +22,7 @@
|
|||
# updated_at :datetime
|
||||
# quantity :decimal(, ) default(0.0)
|
||||
# deleted_at :datetime
|
||||
# type :string(255)
|
||||
#
|
||||
|
||||
class Article < ActiveRecord::Base
|
||||
|
|
@ -32,9 +33,7 @@ class Article < ActiveRecord::Base
|
|||
belongs_to :supplier
|
||||
belongs_to :article_category
|
||||
has_many :article_prices, :order => "created_at"
|
||||
has_many :stock_changes
|
||||
|
||||
named_scope :in_stock, :conditions => "quantity > 0", :order => 'suppliers.name', :include => :supplier
|
||||
named_scope :available, :conditions => {:availability => true}
|
||||
|
||||
# Validations
|
||||
|
|
@ -173,11 +172,6 @@ class Article < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
# Update the quantity of items in stock
|
||||
def update_quantity!
|
||||
update_attribute :quantity, stock_changes.collect(&:quantity).sum
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Checks if the article is in use before it will deleted
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue