|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- require 'rubygems'
- require 'dm-core'
- require 'dm-validations'
- require 'dm-timestamps'
- require 'dm-aggregates'
-
- class Payment
- include DataMapper::Resource
-
- property :id, Serial
- property :trans_no, Integer, :required => false # "TransNo" in RBWM CSV files
- property :directorate_id, Integer, :required => true
- property :service_id, Integer, :required => true
- property :supplier_id, Integer, :required => true
- property :cost_centre, String, :required => false
- property :amount, BigDecimal, :precision => 10, :scale => 2, :required => true # ex VAT
- property :d, Date, :required => true # "Updated" in RBWM CSV files
- property :tyype, String, :required => true # Capital or Revenue
-
- belongs_to :directorate
- belongs_to :service
- belongs_to :supplier
- end
-
-
- class Directorate
- include DataMapper::Resource
-
- property :id, Serial
- property :name, String, :length => 255, :required => true
- property :slug, String, :length => 255
-
- has n, :payments, :order => ['d']
-
- def self.slugify(name)
- name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
- end
-
- end
-
- class Service
- include DataMapper::Resource
-
- property :id, Serial
- property :name, String, :length => 255, :required => true
- property :slug, String, :length => 255
-
- has n, :payments, :order => ['d']
-
- def self.slugify(name)
- name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
- end
-
- end
-
- class Supplier
- include DataMapper::Resource
-
- property :id, Serial
- property :name, String, :length => 255, :required => true
- property :slug, String, :length => 255
-
- has n, :payments, :order => ['d']
-
- def self.slugify(name)
- name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
- end
- end
-
- DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/db.sqlite3")
- DataMapper.auto_upgrade!
|