1 require 'dm-validations'
6 include DataMapper::Resource
7 include DataMapper::Validate
9 property :id, Fixnum, :serial => true
10 property :order_number, Fixnum, :default => 0, :nullable => false, :index => :unique
11 property :created_on, DateTime
12 property :shipped_on, DateTime
13 property :notes, DataMapper::Types::Text
14 property :referer, String
15 property :product_cost, Float, :default => 0.0
16 property :shipping_cost, Float, :default => 0.0
17 property :tax, Float, :default => 0.0, :nullable => false
18 property :billing_address_id, Fixnum # foreign-key
19 property :shipping_address_id, Fixnum # foreign-key
20 property :account_id, Fixnum # foreign-key
21 property :customer_id, Fixnum # foreign-key
22 property :order_shipping_type_id, Fixnum # foreign-key
23 property :status_code_id,Fixnum # foreign-key
24 property :promotion_id, Fixnum # foreign-key
26 has 1..n, :line_items, :class_name => 'Orders::LineItem' #, :dependent => :destroy
27 has 1, :billing_address, :class_name => 'Address' #, :foreign_key => 'billing_address_id'
28 has 1, :shipping_address, :class_name => 'Address' #, :foreign_key => 'shipping_address_id'
32 belongs_to :order_shipping_type
33 belongs_to :status_code, :class_name => 'Orders::StatusCode'
36 attr_accessor :promotion_code
38 validates_presence_of :order_number