2009-01-08 16:33:27 +01:00
|
|
|
# == Schema Information
|
|
|
|
# Schema version: 20090102171850
|
|
|
|
#
|
|
|
|
# Table name: deliveries
|
|
|
|
#
|
|
|
|
# id :integer(4) not null, primary key
|
|
|
|
# supplier_id :integer(4)
|
|
|
|
# delivered_on :date
|
|
|
|
# created_at :datetime
|
|
|
|
#
|
|
|
|
|
|
|
|
class Delivery < ActiveRecord::Base
|
|
|
|
|
|
|
|
belongs_to :supplier
|
2009-01-18 17:42:51 +01:00
|
|
|
has_one :invoice
|
2009-01-16 02:17:49 +01:00
|
|
|
has_many :stock_changes
|
2009-01-08 16:33:27 +01:00
|
|
|
|
2009-01-18 17:42:51 +01:00
|
|
|
named_scope :recent, :order => 'created_at DESC', :limit => 10
|
|
|
|
|
2009-01-08 16:33:27 +01:00
|
|
|
validates_presence_of :supplier_id
|
2009-01-16 02:17:49 +01:00
|
|
|
|
|
|
|
def stock_change_attributes=(stock_change_attributes)
|
|
|
|
for attributes in stock_change_attributes
|
|
|
|
stock_changes.build(attributes) unless attributes[:quantity] == 0.0 or attributes[:quantity].blank?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-01-08 16:33:27 +01:00
|
|
|
end
|