2009-03-17 19:43:41 +01:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: stock_takings
|
|
|
|
#
|
2009-08-01 13:41:22 +02:00
|
|
|
# id :integer(4) not null, primary key
|
2009-03-17 19:43:41 +01:00
|
|
|
# date :date
|
|
|
|
# note :text
|
|
|
|
# created_at :datetime
|
|
|
|
#
|
|
|
|
|
2009-02-12 18:32:20 +01:00
|
|
|
class StockTaking < ActiveRecord::Base
|
|
|
|
|
|
|
|
has_many :stock_changes, :dependent => :destroy
|
|
|
|
has_many :stock_articles, :through => :stock_changes
|
|
|
|
|
|
|
|
validates_presence_of :date
|
|
|
|
|
|
|
|
def stock_change_attributes=(stock_change_attributes)
|
|
|
|
for attributes in stock_change_attributes
|
|
|
|
stock_changes.build(attributes) unless attributes[:quantity].to_i == 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|