5 include DataMapper::Resource
6 include DataMapper::Validate
8 one_to_many :order_line_items, :dependent => :destroy
10 one_to_one :billing_address, :class => 'OrderAddress', :foreign_key => 'billing_address_id'
11 one_to_one :shipping_address, :class => 'OrderAddress', :foreign_key => 'shipping_address_id'
15 many_to_one :order_shipping_type
16 many_to_one :order_status_code
17 many_to_one :promotion
19 attr_accessor :promotion_code
21 property :id, Fixnum, :serial => true
22 property :order_number, Fixnum, :default => 0, :nullable => false, :index => :unique
23 property :created_on, DateTime
24 property :shipped_on, DateTime
25 property :notes, DataMapper::Types::Text
26 property :referer, String
27 property :product_cost, Float, :default => 0.0
28 property :shipping_cost, Float, :default => 0.0
29 property :tax, Float, :default => 0.0, :nullable => false
31 validates_presence_of :order_number