An open source, stand-alone, customisable public spending data web app.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

59 líneas
1.6 KiB

  1. require 'rubygems'
  2. require 'dm-core'
  3. require 'dm-validations'
  4. require 'dm-timestamps'
  5. require 'dm-aggregates'
  6. class Payment
  7. include DataMapper::Resource
  8. property :id, Serial
  9. property :trans_no, Integer, :required => false # "TransNo" in RBWM CSV files
  10. property :directorate_id, Integer, :required => true
  11. property :service_id, Integer, :required => true
  12. property :supplier_id, Integer, :required => true
  13. property :cost_centre, String, :required => false
  14. property :amount, BigDecimal, :precision => 10, :scale => 2, :required => true # ex VAT
  15. property :d, Date, :required => true # "Updated" in RBWM CSV files
  16. property :tyype, String, :required => true # Capital or Revenue
  17. belongs_to :directorate
  18. belongs_to :service
  19. belongs_to :supplier
  20. end
  21. class Directorate
  22. include DataMapper::Resource
  23. property :id, Serial
  24. property :name, String, :length => 255, :required => true
  25. has n, :payments, :order => ['d']
  26. end
  27. class Service
  28. include DataMapper::Resource
  29. property :id, Serial
  30. property :name, String, :length => 255, :required => true
  31. has n, :payments, :order => ['d']
  32. end
  33. class Supplier
  34. include DataMapper::Resource
  35. property :id, Serial
  36. property :name, String, :length => 255, :required => true
  37. has n, :payments, :order => ['d']
  38. # def self.slugify(name)
  39. # name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  40. # end
  41. end
  42. DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/db.sqlite3")
  43. DataMapper.auto_upgrade!