2 require 'dm-validations'
8 include DataMapper::Resource
10 ## TODO: add support for subtypes:
16 property :id, Integer, :serial => true
17 property :code, String, :length => 15, :nullable => false
18 property :discount_type, Integer, :default => 0, :nullable => false
19 property :discount_amount, BigDecimal, :default => 0.0, :nullable => false
20 property :start, DateTime, :nullable => false
21 property :end, DateTime, :nullable => false
22 property :minimum_cart_value, BigDecimal
23 property :description, String, :nullable => false
24 property :store_item_id, Integer # foreign-key
27 belongs_to :item, :class_name => "Mart::Store::AbstractItem"
29 validates_present :code, :discount_amount, :discount_type, :description
30 validates_is_number :discount_amount