An open source, stand-alone, customisable public spending data web app.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 14 gadiem
pirms 14 gadiem
pirms 14 gadiem
pirms 14 gadiem
pirms 14 gadiem
pirms 14 gadiem
pirms 14 gadiem
pirms 14 gadiem
pirms 14 gadiem
pirms 14 gadiem
pirms 14 gadiem
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. require 'rubygems'
  2. require 'dm-core'
  3. require 'dm-validations'
  4. require 'dm-timestamps'
  5. require 'dm-aggregates'
  6. SITE_URL = 'http://armchairauditor.co.uk/'
  7. class Payment
  8. include DataMapper::Resource
  9. property :id, Serial
  10. property :created_at, DateTime
  11. property :updated_at, DateTime
  12. property :service_id, Integer, :required => true
  13. property :supplier_id, Integer, :required => true
  14. property :amount, BigDecimal, :precision => 10, :scale => 2, :required => true # ex VAT
  15. property :d, Date, :required => true # "Updated" in RBWM CSV files
  16. belongs_to :service
  17. belongs_to :supplier
  18. has 1, :directorate, { :through => :service }
  19. def url
  20. SITE_URL + "payments/" + @id.to_s
  21. end
  22. end
  23. class Directorate
  24. include DataMapper::Resource
  25. property :id, Serial
  26. property :created_at, DateTime
  27. property :updated_at, DateTime
  28. property :name, String, :length => 255, :required => true
  29. property :slug, String, :length => 255
  30. has n, :services, :order => ['name']
  31. has n, :suppliers, { :through => :services, :order => ['name'] }
  32. has n, :payments, { :through => :services }
  33. before :save, :slugify
  34. def slugify
  35. @slug = @name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  36. end
  37. end
  38. class Service
  39. include DataMapper::Resource
  40. property :id, Serial
  41. property :created_at, DateTime
  42. property :updated_at, DateTime
  43. property :directorate_id, Integer, :required => true
  44. property :name, String, :length => 255, :required => true
  45. property :slug, String, :length => 255
  46. has n, :payments, :order => ['d']
  47. has n, :suppliers, { :through => :payments, :order => ['name'] }
  48. belongs_to :directorate
  49. before :save, :slugify
  50. def slugify
  51. @slug = @name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  52. end
  53. end
  54. class Supplier
  55. include DataMapper::Resource
  56. property :id, Serial
  57. property :created_at, DateTime
  58. property :updated_at, DateTime
  59. property :name, String, :length => 255, :required => true
  60. property :slug, String, :length => 255
  61. has n, :payments, :order => ['d']
  62. has n, :services, { :through => :payments, :order => ['name'] }
  63. has n, :directorates, { :through => :payments }
  64. before :save, :slugify
  65. def slugify
  66. @slug = @name.gsub(/[^\w\s-]/, '').gsub(/\s+/, '-').downcase
  67. end
  68. end
  69. DataMapper.setup(:default, ENV['DATABASE_URL'] || "sqlite3://#{Dir.pwd}/db.sqlite3")
  70. DataMapper.auto_upgrade!