smartkiosk-server 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. data/.gitignore +32 -0
  2. data/.rspec +1 -0
  3. data/Capfile +4 -0
  4. data/Gemfile +71 -0
  5. data/Gemfile.lock +439 -0
  6. data/Guardfile +25 -0
  7. data/LICENSE +287 -0
  8. data/README.md +13 -0
  9. data/Rakefile +5 -0
  10. data/app/acquirers/cards_mkb_acquirer.rb +87 -0
  11. data/app/acquirers/cash_acquirer.rb +22 -0
  12. data/app/admin/agents.rb +108 -0
  13. data/app/admin/collections.rb +62 -0
  14. data/app/admin/commissions.rb +87 -0
  15. data/app/admin/gateways.rb +183 -0
  16. data/app/admin/limits.rb +82 -0
  17. data/app/admin/payments.rb +246 -0
  18. data/app/admin/provider_groups.rb +60 -0
  19. data/app/admin/provider_profiles.rb +11 -0
  20. data/app/admin/provider_receipt_templates.rb +82 -0
  21. data/app/admin/providers.rb +201 -0
  22. data/app/admin/rebates.rb +83 -0
  23. data/app/admin/report_results.rb +66 -0
  24. data/app/admin/report_templates.rb +209 -0
  25. data/app/admin/reports.rb +158 -0
  26. data/app/admin/revisions.rb +120 -0
  27. data/app/admin/system_receipt_templates.rb +76 -0
  28. data/app/admin/terminal_builds.rb +39 -0
  29. data/app/admin/terminal_profiles.rb +123 -0
  30. data/app/admin/terminals.rb +388 -0
  31. data/app/admin/users.rb +117 -0
  32. data/app/admin/versions.rb +131 -0
  33. data/app/admin/welcome.rb +64 -0
  34. data/app/assets/fonts/PT_Sans-Web-Bold.eot +0 -0
  35. data/app/assets/fonts/PT_Sans-Web-Bold.svg +6386 -0
  36. data/app/assets/fonts/PT_Sans-Web-Bold.ttf +0 -0
  37. data/app/assets/fonts/PT_Sans-Web-Bold.woff +0 -0
  38. data/app/assets/fonts/PT_Sans-Web-Regular.eot +0 -0
  39. data/app/assets/fonts/PT_Sans-Web-Regular.svg +5650 -0
  40. data/app/assets/fonts/PT_Sans-Web-Regular.ttf +0 -0
  41. data/app/assets/fonts/PT_Sans-Web-Regular.woff +0 -0
  42. data/app/assets/images/chosen-sprite.png +0 -0
  43. data/app/assets/javascripts/active_admin/chosen.js.erb.coffee +12 -0
  44. data/app/assets/javascripts/active_admin/qtip.js.coffee +22 -0
  45. data/app/assets/javascripts/active_admin/sortable_forms.js.coffee +14 -0
  46. data/app/assets/javascripts/active_admin.js.coffee +9 -0
  47. data/app/assets/javascripts/application.js +15 -0
  48. data/app/assets/javascripts/report_templates.js.coffee +10 -0
  49. data/app/assets/javascripts/terminals.js.coffee +12 -0
  50. data/app/assets/stylesheets/active_admin/PIE.css.scss +18 -0
  51. data/app/assets/stylesheets/active_admin/filter_numeric_range.css.scss +14 -0
  52. data/app/assets/stylesheets/active_admin/selectable_check_boxes.css.scss +12 -0
  53. data/app/assets/stylesheets/active_admin/sortable_forms.css.scss +11 -0
  54. data/app/assets/stylesheets/active_admin.css.scss +705 -0
  55. data/app/assets/stylesheets/fonts.css.scss +14 -0
  56. data/app/assets/stylesheets/provider_groups.css.scss +12 -0
  57. data/app/assets/stylesheets/provider_receipt_templates.css.scss +12 -0
  58. data/app/assets/stylesheets/terminals.css.scss +9 -0
  59. data/app/controllers/application_controller.rb +12 -0
  60. data/app/controllers/collections_controller.rb +10 -0
  61. data/app/controllers/payments_controller.rb +73 -0
  62. data/app/controllers/system_receipt_templates_controller.rb +10 -0
  63. data/app/controllers/terminal_builds_controller.rb +5 -0
  64. data/app/controllers/terminal_orders_controller.rb +25 -0
  65. data/app/controllers/terminal_pings_controller.rb +45 -0
  66. data/app/controllers/welcome_controller.rb +5 -0
  67. data/app/helpers/active_admin/report_templates_helper.rb +56 -0
  68. data/app/helpers/active_admin/views_helper.rb +20 -0
  69. data/app/helpers/application_helper.rb +2 -0
  70. data/app/mailers/.gitkeep +0 -0
  71. data/app/models/.gitkeep +0 -0
  72. data/app/models/ability.rb +30 -0
  73. data/app/models/agent.rb +24 -0
  74. data/app/models/collection.rb +65 -0
  75. data/app/models/commission.rb +77 -0
  76. data/app/models/commission_section.rb +75 -0
  77. data/app/models/gateway.rb +99 -0
  78. data/app/models/gateway_attachment.rb +9 -0
  79. data/app/models/gateway_setting.rb +7 -0
  80. data/app/models/gateway_switch.rb +7 -0
  81. data/app/models/limit.rb +77 -0
  82. data/app/models/limit_section.rb +58 -0
  83. data/app/models/payment.rb +322 -0
  84. data/app/models/provider.rb +59 -0
  85. data/app/models/provider_field.rb +7 -0
  86. data/app/models/provider_gateway.rb +47 -0
  87. data/app/models/provider_group.rb +45 -0
  88. data/app/models/provider_profile.rb +9 -0
  89. data/app/models/provider_rebate.rb +69 -0
  90. data/app/models/provider_receipt_template.rb +85 -0
  91. data/app/models/rebate.rb +84 -0
  92. data/app/models/report.rb +71 -0
  93. data/app/models/report_result.rb +11 -0
  94. data/app/models/report_template.rb +56 -0
  95. data/app/models/revision.rb +104 -0
  96. data/app/models/role.rb +48 -0
  97. data/app/models/system_receipt_template.rb +13 -0
  98. data/app/models/terminal.rb +126 -0
  99. data/app/models/terminal_build.rb +62 -0
  100. data/app/models/terminal_order.rb +42 -0
  101. data/app/models/terminal_ping.rb +120 -0
  102. data/app/models/terminal_profile.rb +51 -0
  103. data/app/models/terminal_profile_promotion.rb +18 -0
  104. data/app/models/terminal_profile_provider.rb +11 -0
  105. data/app/models/terminal_profile_provider_group.rb +19 -0
  106. data/app/models/user.rb +38 -0
  107. data/app/models/user_role.rb +45 -0
  108. data/app/reports/agents_report.rb +81 -0
  109. data/app/reports/collections_report.rb +151 -0
  110. data/app/reports/payments_report.rb +189 -0
  111. data/app/reports/terminals_report.rb +123 -0
  112. data/app/uploaders/file_uploader.rb +53 -0
  113. data/app/uploaders/icon_uploader.rb +15 -0
  114. data/app/uploaders/zip_uploader.rb +53 -0
  115. data/app/views/admin/gateways/providers.html.arb +10 -0
  116. data/app/views/admin/revisions/payments.html.arb +28 -0
  117. data/app/views/admin/terminal_profiles/_tree.html.haml +35 -0
  118. data/app/views/admin/terminal_profiles/sort.html.haml +21 -0
  119. data/app/views/admin/terminals/pings.html.arb +55 -0
  120. data/app/views/admin/terminals/upgrade_build.html.arb +30 -0
  121. data/app/views/layouts/application.html.erb +1 -0
  122. data/app/views/welcome/index.html.erb +25 -0
  123. data/app/workers/pay_worker.rb +11 -0
  124. data/app/workers/report_worker.rb +7 -0
  125. data/app/workers/revise_worker.rb +7 -0
  126. data/config/acquiring.yml +13 -0
  127. data/config/application.rb +75 -0
  128. data/config/boot.rb +6 -0
  129. data/config/database.yml +17 -0
  130. data/config/deploy/roundlake-passenger.rb +3 -0
  131. data/config/deploy/roundlake-trinidad.rb +3 -0
  132. data/config/deploy.rb +37 -0
  133. data/config/environment.rb +5 -0
  134. data/config/environments/development.rb +39 -0
  135. data/config/environments/production.rb +67 -0
  136. data/config/environments/test.rb +37 -0
  137. data/config/initializers/active_admin.rb +31 -0
  138. data/config/initializers/backtrace_silencers.rb +7 -0
  139. data/config/initializers/devise.rb +232 -0
  140. data/config/initializers/inflections.rb +15 -0
  141. data/config/initializers/mime_types.rb +5 -0
  142. data/config/initializers/money.rb +6 -0
  143. data/config/initializers/redis.rb +4 -0
  144. data/config/initializers/secret_token.rb +7 -0
  145. data/config/initializers/session_store.rb +8 -0
  146. data/config/initializers/setup_rack.rb +1 -0
  147. data/config/initializers/wrap_parameters.rb +14 -0
  148. data/config/locales/active_admin.ru.yml +71 -0
  149. data/config/locales/activerecord.ru.yml +645 -0
  150. data/config/locales/devise.ru.yml +57 -0
  151. data/config/locales/ru.yml +33 -0
  152. data/config/locales/smartkiosk.gateways.ru.yml +241 -0
  153. data/config/locales/smartkiosk.hardware.ru.yml +38 -0
  154. data/config/locales/smartkiosk.reports.ru.yml +56 -0
  155. data/config/locales/smartkiosk.ru.yml +163 -0
  156. data/config/nginx.conf +9 -0
  157. data/config/redis.yml +9 -0
  158. data/config/routes.rb +48 -0
  159. data/config/schedule.rb +13 -0
  160. data/config/sidekiq.yml +5 -0
  161. data/config/trinidad.yml +6 -0
  162. data/config.ru +4 -0
  163. data/db/migrate/20120825083035_create_terminals.rb +47 -0
  164. data/db/migrate/20120825083305_create_payments.rb +51 -0
  165. data/db/migrate/20120827062618_devise_create_users.rb +50 -0
  166. data/db/migrate/20120827132621_create_admin_notes.rb +17 -0
  167. data/db/migrate/20120827132622_move_admin_notes_to_comments.rb +25 -0
  168. data/db/migrate/20120903193346_create_providers.rb +24 -0
  169. data/db/migrate/20120922075345_create_collections.rb +26 -0
  170. data/db/migrate/20120922080440_create_agents.rb +29 -0
  171. data/db/migrate/20120922081104_create_commissions.rb +10 -0
  172. data/db/migrate/20120927035841_create_gateways.rb +13 -0
  173. data/db/migrate/20120927040626_create_provider_gateways.rb +13 -0
  174. data/db/migrate/20120927091849_create_limits.rb +10 -0
  175. data/db/migrate/20120927164647_create_roles.rb +14 -0
  176. data/db/migrate/20121003131522_create_report_templates.rb +18 -0
  177. data/db/migrate/20121007135652_create_reports.rb +13 -0
  178. data/db/migrate/20121008073905_create_report_results.rb +10 -0
  179. data/db/migrate/20121017114538_create_gateway_settings.rb +12 -0
  180. data/db/migrate/20121017114556_create_gateway_attachments.rb +10 -0
  181. data/db/migrate/20121019132606_create_revisions.rb +19 -0
  182. data/db/migrate/20121023073501_create_gateway_switches.rb +10 -0
  183. data/db/migrate/20121112142743_create_terminal_orders.rb +13 -0
  184. data/db/migrate/20121118191553_create_versions.rb +19 -0
  185. data/db/migrate/20121125093414_create_system_receipt_templates.rb +9 -0
  186. data/db/migrate/20121127192257_create_terminal_builds.rb +10 -0
  187. data/db/migrate/20121212053441_create_rebates.rb +15 -0
  188. data/db/migrate/20121216143855_create_provider_receipt_templates.rb +9 -0
  189. data/db/migrate/20130101091100_create_terminal_profiles.rb +13 -0
  190. data/db/migrate/20130101091734_create_provider_rebates.rb +21 -0
  191. data/db/migrate/20130102164447_create_limit_sections.rb +14 -0
  192. data/db/migrate/20130102164503_create_commission_sections.rb +17 -0
  193. data/db/migrate/20130102171743_create_provider_profiles.rb +10 -0
  194. data/db/migrate/20130103152507_create_provider_fields.rb +17 -0
  195. data/db/migrate/20130103154526_create_provider_groups.rb +10 -0
  196. data/db/migrate/20130104063628_create_terminal_profile_providers.rb +11 -0
  197. data/db/migrate/20130104090957_create_terminal_profile_provider_groups.rb +11 -0
  198. data/db/migrate/20130108091644_create_terminal_profile_promotions.rb +10 -0
  199. data/db/schema.rb +489 -0
  200. data/db/seeds/receipt_templates/payment.txt +19 -0
  201. data/db/seeds/receipt_templates/system/balance.txt +13 -0
  202. data/db/seeds/receipt_templates/system/collection.txt +17 -0
  203. data/db/seeds/receipt_templates/system/touchtest.txt +15 -0
  204. data/db/seeds.rb +18 -0
  205. data/doc/README_FOR_APP +2 -0
  206. data/init.rb +1 -0
  207. data/lib/active_admin/cancan_integration.rb +81 -0
  208. data/lib/active_admin/form_builder_fix.rb +76 -0
  209. data/lib/active_admin/inputs/filter_date_range_input_fix.rb +24 -0
  210. data/lib/active_admin/inputs/filter_multiple_select_input.rb +18 -0
  211. data/lib/active_admin/inputs/filter_numeric_range_input.rb +31 -0
  212. data/lib/active_admin/resource_controller_fix.rb +23 -0
  213. data/lib/active_admin/views/pages/base_fix.rb +13 -0
  214. data/lib/assets/.gitkeep +0 -0
  215. data/lib/blueprints.rb +79 -0
  216. data/lib/date_expander.rb +38 -0
  217. data/lib/dav4rack/build_resource.rb +59 -0
  218. data/lib/formtastic/inputs/selectable_check_boxes.rb +39 -0
  219. data/lib/paper_trail/version_fix.rb +3 -0
  220. data/lib/report_builder.rb +88 -0
  221. data/lib/seeder.rb +103 -0
  222. data/lib/smartkiosk/server/version.rb +5 -0
  223. data/lib/smartkiosk/server.rb +35 -0
  224. data/lib/string_file.rb +12 -0
  225. data/lib/tasks/.gitkeep +0 -0
  226. data/lib/tasks/db.rake +27 -0
  227. data/lib/tasks/dump.rake +53 -0
  228. data/lib/tasks/matrioshka.rake +16 -0
  229. data/log/.gitkeep +0 -0
  230. data/log/gateways/.gitkeep +0 -0
  231. data/public/404.html +26 -0
  232. data/public/422.html +26 -0
  233. data/public/500.html +25 -0
  234. data/public/robots.txt +5 -0
  235. data/script/rails +6 -0
  236. data/smartkiosk-server.gemspec +23 -0
  237. data/spec/controllers/collections_controller_spec.rb +32 -0
  238. data/spec/controllers/payments_controller_spec.rb +123 -0
  239. data/spec/controllers/system_receipt_templates_controller_spec.rb +5 -0
  240. data/spec/controllers/terminal_builds_controller_spec.rb +5 -0
  241. data/spec/controllers/terminal_orders_controller_spec.rb +32 -0
  242. data/spec/controllers/terminal_pings_controller_spec.rb +31 -0
  243. data/spec/spec_helper.rb +66 -0
  244. data/vendor/assets/javascripts/.gitkeep +0 -0
  245. data/vendor/assets/javascripts/chosen.jquery.js +1026 -0
  246. data/vendor/assets/javascripts/datepicker-ru.jquery.js +21 -0
  247. data/vendor/assets/javascripts/nestedSortable.jquery.js +429 -0
  248. data/vendor/assets/javascripts/qtip.jquery.js +3403 -0
  249. data/vendor/assets/stylesheets/.gitkeep +0 -0
  250. data/vendor/assets/stylesheets/chosen.jquery.css +397 -0
  251. data/vendor/assets/stylesheets/modules/PIE.htc +96 -0
  252. data/vendor/assets/stylesheets/qtip.jquery.css.scss +604 -0
  253. data/vendor/plugins/.gitkeep +0 -0
  254. metadata +333 -0
@@ -0,0 +1,5 @@
1
+ ---
2
+ :verbose: false
3
+ :pidfile: tmp/pids/sidekiq.pid
4
+ :namespace: sidekiq_namespace
5
+ :concurrency: 25
@@ -0,0 +1,6 @@
1
+ ---
2
+ address: 127.0.0.1
3
+ port: 3000
4
+ environment: production
5
+ jruby_min_runtimes: 1
6
+ jruby_max_runtimes: 1
data/config.ru ADDED
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application.class
@@ -0,0 +1,47 @@
1
+ class CreateTerminals < ActiveRecord::Migration
2
+ def change
3
+ create_table :terminals do |t|
4
+ t.belongs_to :agent
5
+ t.belongs_to :terminal_profile
6
+ t.string :address
7
+ t.string :keyword
8
+ t.string :description
9
+ t.string :state, :default => 'unknown'
10
+ t.string :condition
11
+ t.datetime :notified_at
12
+ t.datetime :collected_at
13
+ t.datetime :issues_started_at
14
+
15
+ t.integer :foreign_id
16
+
17
+ t.string :sector
18
+ t.string :contact_name
19
+ t.string :contact_phone
20
+ t.string :contact_email
21
+ t.string :schedule
22
+ t.string :juristic_name
23
+ t.string :contract_number
24
+ t.string :manager
25
+ t.string :rent
26
+ t.string :rent_finish_date
27
+ t.string :collection_zone
28
+ t.string :check_phone_number
29
+
30
+ t.integer :printer_error
31
+ t.integer :cash_acceptor_error
32
+ t.integer :modem_error
33
+ t.string :version
34
+
35
+ t.boolean :has_adv_monitor, :null => false, :default => true
36
+
37
+ t.integer :incomplete_orders_count, :null => false, :default => 0
38
+
39
+ t.timestamps
40
+ end
41
+
42
+ add_index :terminals, :keyword
43
+ add_index :terminals, :state
44
+ add_index :terminals, :condition
45
+ add_index :terminals, :agent_id
46
+ end
47
+ end
@@ -0,0 +1,51 @@
1
+ class CreatePayments < ActiveRecord::Migration
2
+ def change
3
+ create_table :payments do |t|
4
+ t.string :session_id
5
+ t.integer :foreign_id
6
+ t.belongs_to :agent
7
+ t.belongs_to :terminal
8
+ t.belongs_to :gateway
9
+ t.belongs_to :provider
10
+ t.belongs_to :corrected_payment
11
+ t.belongs_to :user
12
+ t.belongs_to :collection
13
+ t.belongs_to :revision
14
+ t.integer :payment_type
15
+ t.boolean :offline, :null => false, :default => false
16
+ t.string :account
17
+ t.text :fields
18
+ t.text :raw_fields
19
+ t.text :meta
20
+ t.string :currency, :null => false, :default => 'rur'
21
+ t.decimal :paid_amount, :precision => 38, :scale => 2
22
+ t.decimal :commission_amount, :precision => 38, :scale => 2
23
+ t.decimal :enrolled_amount, :precision => 38, :scale => 2
24
+ t.decimal :rebate_amount, :precision => 38, :scale => 2
25
+ t.string :state, :null => false, :default => 'new'
26
+ t.integer :gateway_error
27
+ t.string :gateway_provider_id
28
+ t.string :gateway_payment_id
29
+ t.datetime :hour
30
+ t.date :day
31
+ t.date :month
32
+ t.integer :source, :null => false, :default => 0
33
+ t.string :receipt_number
34
+ t.datetime :paid_at
35
+
36
+ t.string :card_number
37
+ t.string :card_number_hash
38
+ t.string :card_track1
39
+ t.string :card_track2
40
+
41
+ t.timestamps
42
+ end
43
+
44
+ add_index :payments, :state
45
+ add_index :payments, :agent_id
46
+ add_index :payments, :terminal_id
47
+ add_index :payments, :gateway_id
48
+ add_index :payments, :provider_id
49
+ add_index :payments, :created_at
50
+ end
51
+ end
@@ -0,0 +1,50 @@
1
+ class DeviseCreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table(:users) do |t|
4
+ ## Database authenticatable
5
+ t.string :email, :null => false, :default => ""
6
+ t.string :encrypted_password, :null => false, :default => ""
7
+
8
+ ## Recoverable
9
+ t.string :reset_password_token
10
+ t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Trackable
16
+ t.integer :sign_in_count, :default => 0
17
+ t.datetime :current_sign_in_at
18
+ t.datetime :last_sign_in_at
19
+ t.string :current_sign_in_ip
20
+ t.string :last_sign_in_ip
21
+
22
+ t.string :full_name
23
+
24
+ t.boolean :root, :null => false, :default => false
25
+
26
+ ## Confirmable
27
+ # t.string :confirmation_token
28
+ # t.datetime :confirmed_at
29
+ # t.datetime :confirmation_sent_at
30
+ # t.string :unconfirmed_email # Only if using reconfirmable
31
+
32
+ ## Lockable
33
+ # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
34
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
35
+ # t.datetime :locked_at
36
+
37
+ ## Token authenticatable
38
+ # t.string :authentication_token
39
+
40
+
41
+ t.timestamps
42
+ end
43
+
44
+ add_index :users, :email, :unique => true
45
+ add_index :users, :reset_password_token, :unique => true
46
+ # add_index :users, :confirmation_token, :unique => true
47
+ # add_index :users, :unlock_token, :unique => true
48
+ # add_index :users, :authentication_token, :unique => true
49
+ end
50
+ end
@@ -0,0 +1,17 @@
1
+ class CreateAdminNotes < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :admin_notes do |t|
4
+ t.string :resource_id, :null => false
5
+ t.string :resource_type, :null => false
6
+ t.references :admin_user, :polymorphic => true
7
+ t.text :body
8
+ t.timestamps
9
+ end
10
+ add_index :admin_notes, [:resource_type, :resource_id]
11
+ add_index :admin_notes, [:admin_user_type, :admin_user_id]
12
+ end
13
+
14
+ def self.down
15
+ drop_table :admin_notes
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ class MoveAdminNotesToComments < ActiveRecord::Migration
2
+ def self.up
3
+ remove_index :admin_notes, [:admin_user_type, :admin_user_id]
4
+ rename_table :admin_notes, :active_admin_comments
5
+ rename_column :active_admin_comments, :admin_user_type, :author_type
6
+ rename_column :active_admin_comments, :admin_user_id, :author_id
7
+ add_column :active_admin_comments, :namespace, :string
8
+ add_index :active_admin_comments, [:namespace]
9
+ add_index :active_admin_comments, [:author_type, :author_id]
10
+
11
+ # Update all the existing comments to the default namespace
12
+ say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace."
13
+ execute "UPDATE active_admin_comments SET namespace='#{ActiveAdmin.application.default_namespace}'"
14
+ end
15
+
16
+ def self.down
17
+ remove_index :active_admin_comments, :column => [:author_type, :author_id]
18
+ remove_index :active_admin_comments, :column => [:namespace]
19
+ remove_column :active_admin_comments, :namespace
20
+ rename_column :active_admin_comments, :author_id, :admin_user_id
21
+ rename_column :active_admin_comments, :author_type, :admin_user_type
22
+ rename_table :active_admin_comments, :admin_notes
23
+ add_index :admin_notes, [:admin_user_type, :admin_user_id]
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ class CreateProviders < ActiveRecord::Migration
2
+ def change
3
+ create_table :providers do |t|
4
+ t.belongs_to :provider_profile
5
+ t.belongs_to :provider_group
6
+ t.string :title
7
+ t.string :keyword
8
+ t.string :juristic_name
9
+ t.string :inn
10
+ t.boolean :requires_print, :null => false, :default => true
11
+ t.integer :foreign_id
12
+ t.integer :provider_gateways_count, :default => 0
13
+ t.string :icon
14
+ t.string :support_phone
15
+
16
+ t.belongs_to :provider_receipt_template
17
+
18
+ t.timestamps
19
+ end
20
+
21
+ add_index :providers, :keyword, :unique => true
22
+ add_index :providers, :updated_at
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ class CreateCollections < ActiveRecord::Migration
2
+ def change
3
+ create_table :collections do |t|
4
+ t.belongs_to :agent
5
+ t.belongs_to :terminal
6
+ t.integer :source, :null => false, :default => 0
7
+ t.boolean :reset_counters, :null => false, :default => true
8
+ t.integer :foreign_id
9
+ t.decimal :payments_sum, :precision => 38, :scale => 2
10
+ t.integer :payments_count
11
+ t.decimal :receipts_sum, :precision => 38, :scale => 2
12
+ t.decimal :approved_payments_sum, :precision => 38, :scale => 2
13
+ t.integer :approved_payments_count
14
+ t.decimal :cash_sum, :precision => 38, :scale => 2
15
+ t.integer :cash_payments_count
16
+ t.integer :cashless_payments_count
17
+ t.text :banknotes
18
+ t.text :session_ids
19
+ t.datetime :collected_at
20
+ t.datetime :hour
21
+ t.date :day
22
+ t.date :month
23
+ t.timestamps
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,29 @@
1
+ class CreateAgents < ActiveRecord::Migration
2
+ def change
3
+ create_table :agents do |t|
4
+ t.belongs_to :agent
5
+ t.string :title
6
+
7
+ t.integer :foreign_id
8
+
9
+ t.string :juristic_name
10
+ t.string :juristic_address_city
11
+ t.string :juristic_address_street
12
+ t.string :juristic_address_home
13
+ t.string :physical_address_city
14
+ t.string :physical_address_district
15
+ t.string :physical_address_subway
16
+ t.string :physical_address_street
17
+ t.string :physical_address_home
18
+ t.string :contact_name
19
+ t.string :contact_info
20
+ t.string :director_name
21
+ t.string :director_contact_info
22
+ t.string :bookkeeper_name
23
+ t.string :bookkeeper_contact_info
24
+ t.string :inn
25
+ t.string :support_phone
26
+ t.timestamps
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ class CreateCommissions < ActiveRecord::Migration
2
+ def change
3
+ create_table :commissions do |t|
4
+ t.belongs_to :provider_profile
5
+ t.date :start
6
+ t.date :finish
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ class CreateGateways < ActiveRecord::Migration
2
+ def change
3
+ create_table :gateways do |t|
4
+ t.string :title
5
+ t.string :keyword
6
+ t.string :payzilla
7
+ t.boolean :requires_revisions_moderation, :null => false, :default => false
8
+ t.integer :debug_level, :null => false, :default => 0
9
+ t.boolean :enabled, :null => false, :default => true
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class CreateProviderGateways < ActiveRecord::Migration
2
+ def change
3
+ create_table :provider_gateways do |t|
4
+ t.belongs_to :provider
5
+ t.belongs_to :gateway
6
+ t.integer :priority
7
+ t.string :gateway_provider_id
8
+ t.string :account_mapping
9
+ t.text :fields_mapping
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ class CreateLimits < ActiveRecord::Migration
2
+ def change
3
+ create_table :limits do |t|
4
+ t.belongs_to :provider_profile
5
+ t.date :start
6
+ t.date :finish
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ class CreateRoles < ActiveRecord::Migration
2
+ def change
3
+ create_table :roles do |t|
4
+ t.string :keyword
5
+ t.timestamps
6
+ end
7
+
8
+ create_table :user_roles do |t|
9
+ t.belongs_to :user
10
+ t.belongs_to :role
11
+ t.text :priveleges
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ class CreateReportTemplates < ActiveRecord::Migration
2
+ def change
3
+ create_table :report_templates do |t|
4
+ t.string :kind
5
+ t.string :title
6
+ t.boolean :open, :null => false, :default => false
7
+ t.text :groupping, :null => false, :default => ''
8
+ t.text :fields
9
+ t.text :calculations
10
+ t.string :sorting
11
+ t.boolean :sort_desc, :null => false, :default => false
12
+ t.text :conditions
13
+ t.string :email
14
+ t.belongs_to :user
15
+ t.timestamps
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,13 @@
1
+ class CreateReports < ActiveRecord::Migration
2
+ def change
3
+ create_table :reports do |t|
4
+ t.belongs_to :report_template
5
+ t.belongs_to :user
6
+ t.date :start
7
+ t.date :finish
8
+ t.string :state, :null => false, :default => 'new'
9
+ t.text :error
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ class CreateReportResults < ActiveRecord::Migration
2
+ def change
3
+ create_table :report_results do |t|
4
+ t.integer :rows
5
+ t.belongs_to :report
6
+ t.text :data
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ class CreateGatewaySettings < ActiveRecord::Migration
2
+ def change
3
+ create_table :gateway_settings do |t|
4
+ t.belongs_to :gateway
5
+ t.string :keyword
6
+ t.text :value
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :gateway_settings, [:gateway_id, :keyword]
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ class CreateGatewayAttachments < ActiveRecord::Migration
2
+ def change
3
+ create_table :gateway_attachments do |t|
4
+ t.belongs_to :gateway
5
+ t.string :keyword
6
+ t.string :value
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ class CreateRevisions < ActiveRecord::Migration
2
+ def change
3
+ create_table :revisions do |t|
4
+ t.belongs_to :gateway
5
+ t.date :date
6
+ t.string :state, :null => false, :default => 'new'
7
+ t.integer :error
8
+ t.decimal :paid_sum, :precision => 38, :scale => 2
9
+ t.decimal :enrolled_sum, :precision => 38, :scale => 2
10
+ t.decimal :commission_sum, :precision => 38, :scale => 2
11
+ t.integer :payments_count
12
+ t.boolean :moderated, :null => false, :default => false
13
+ t.string :data
14
+ t.timestamps
15
+ end
16
+
17
+ add_index :revisions, :state
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ class CreateGatewaySwitches < ActiveRecord::Migration
2
+ def change
3
+ create_table :gateway_switches do |t|
4
+ t.belongs_to :gateway
5
+ t.string :keyword
6
+ t.boolean :value, :null => false, :default => false
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ class CreateTerminalOrders < ActiveRecord::Migration
2
+ def change
3
+ create_table :terminal_orders do |t|
4
+ t.belongs_to :terminal
5
+ t.string :keyword
6
+ t.text :args
7
+ t.string :state, :null => false, :default => 'new'
8
+ t.string :error
9
+ t.integer :percent
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ class CreateVersions < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :versions do |t|
4
+ t.string :item_type, :null => false
5
+ t.integer :item_id, :null => false
6
+ t.string :event, :null => false
7
+ t.string :whodunnit
8
+ t.text :object_changes
9
+ t.text :object
10
+ t.datetime :created_at
11
+ end
12
+ add_index :versions, [:item_type, :item_id]
13
+ end
14
+
15
+ def self.down
16
+ remove_index :versions, [:item_type, :item_id]
17
+ drop_table :versions
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ class CreateSystemReceiptTemplates < ActiveRecord::Migration
2
+ def change
3
+ create_table :system_receipt_templates do |t|
4
+ t.string :keyword
5
+ t.text :template
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ class CreateTerminalBuilds < ActiveRecord::Migration
2
+ def change
3
+ create_table :terminal_builds do |t|
4
+ t.string :version
5
+ t.string :source
6
+ t.text :hashes
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ class CreateRebates < ActiveRecord::Migration
2
+ def change
3
+ create_table :rebates do |t|
4
+ t.belongs_to :gateway
5
+
6
+ t.decimal :period_fee
7
+ t.integer :period_kind
8
+
9
+ t.date :start
10
+ t.date :finish
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ class CreateProviderReceiptTemplates < ActiveRecord::Migration
2
+ def change
3
+ create_table :provider_receipt_templates do |t|
4
+ t.boolean :system, :null => false, :default => false
5
+ t.text :template
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class CreateTerminalProfiles < ActiveRecord::Migration
2
+ def change
3
+ create_table :terminal_profiles do |t|
4
+
5
+ t.string :title
6
+ t.string :support_phone
7
+ t.string :keyword
8
+ t.string :logo
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ class CreateProviderRebates < ActiveRecord::Migration
2
+ def change
3
+ create_table :provider_rebates do |t|
4
+
5
+ t.belongs_to :rebate
6
+
7
+ t.belongs_to :provider
8
+ t.boolean :requires_commission
9
+ t.integer :payment_type
10
+
11
+ t.decimal :min, :precision => 38, :scale => 2
12
+ t.decimal :max, :precision => 38, :scale => 2
13
+
14
+ t.decimal :min_percent_amount, :precision => 38, :scale => 2, :null => false, :default => 0.0
15
+ t.decimal :percent_fee, :precision => 38, :scale => 2
16
+ t.decimal :static_fee, :precision => 38, :scale => 2
17
+
18
+ t.timestamps
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ class CreateLimitSections < ActiveRecord::Migration
2
+ def change
3
+ create_table :limit_sections do |t|
4
+ t.belongs_to :limit
5
+ t.belongs_to :agent
6
+ t.belongs_to :terminal_profile
7
+ t.integer :payment_type
8
+
9
+ t.decimal :min, :precision => 38, :scale => 2
10
+ t.decimal :max, :precision => 38, :scale => 2
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ class CreateCommissionSections < ActiveRecord::Migration
2
+ def change
3
+ create_table :commission_sections do |t|
4
+ t.belongs_to :commission
5
+ t.belongs_to :agent
6
+ t.belongs_to :terminal_profile
7
+ t.integer :payment_type
8
+
9
+ t.decimal :min, :precision => 38, :scale => 2
10
+ t.decimal :max, :precision => 38, :scale => 2
11
+
12
+ t.decimal :percent_fee, :precision => 38, :scale => 2, :null => false, :default => 0
13
+ t.decimal :static_fee, :precision => 38, :scale => 2, :null => false, :default => 0
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ class CreateProviderProfiles < ActiveRecord::Migration
2
+ def change
3
+ create_table :provider_profiles do |t|
4
+
5
+ t.string :title
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ class CreateProviderFields < ActiveRecord::Migration
2
+ def change
3
+ create_table :provider_fields do |t|
4
+ t.belongs_to :provider
5
+
6
+ t.string :keyword
7
+ t.string :title
8
+ t.string :kind
9
+ t.string :mask
10
+ t.string :regexp
11
+ t.text :values
12
+ t.integer :priority
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ class CreateProviderGroups < ActiveRecord::Migration
2
+ def change
3
+ create_table :provider_groups do |t|
4
+ t.string :title
5
+ t.string :icon
6
+ t.belongs_to :provider_group
7
+ t.timestamps
8
+ end
9
+ end
10
+ end