An open source, stand-alone, customisable public spending data web app.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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