Introduced StockTaking. TODO: Dry up the stockit/stock_takings/deliveries controllers/views!

This commit is contained in:
Benjamin Meichsner 2009-02-12 18:32:20 +01:00
parent 2bb4cdb9d6
commit 951d19db6a
30 changed files with 436 additions and 55 deletions

View file

@ -30,6 +30,8 @@ class StockArticle < Article
named_scope :available, :conditions => "quantity > 0"
before_destroy :check_quantity
# Update the quantity of items in stock
def update_quantity!
update_attribute :quantity, stock_changes.collect(&:quantity).sum
@ -46,4 +48,10 @@ class StockArticle < Article
end
available
end
protected
def check_quantity
raise "#{name} kann nicht gelöscht werden. Der Lagerbestand ist nicht null." unless quantity == 0
end
end