An open source, stand-alone, customisable public spending data web app.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

72 lignes
1.9 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. property :slug, String, :length => 255
  26. has n, :payments, :order => ['d']
  27. def self.slugify(name)
  28. name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  29. end
  30. end
  31. class Service
  32. include DataMapper::Resource
  33. property :id, Serial
  34. property :name, String, :length => 255, :required => true
  35. property :slug, String, :length => 255
  36. has n, :payments, :order => ['d']
  37. def self.slugify(name)
  38. name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  39. end
  40. end
  41. class Supplier
  42. include DataMapper::Resource
  43. property :id, Serial
  44. property :name, String, :length => 255, :required => true
  45. property :slug, String, :length => 255
  46. has n, :payments, :order => ['d']
  47. def self.slugify(name)
  48. name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  49. end
  50. end
  51. DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/db.sqlite3")
  52. DataMapper.auto_upgrade!