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,151 @@
1
+ # coding: utf-8
2
+
3
+ class CollectionsReport < ReportBuilder::Base
4
+ requires_dates!
5
+
6
+ def tables
7
+ @tables ||= {
8
+ :collection => Arel::Table.new(:collections),
9
+ :terminal => Arel::Table.new(:terminals),
10
+ :agent => Arel::Table.new(:agents)
11
+ }.with_indifferent_access
12
+ end
13
+
14
+ def context(start, finish)
15
+ context = tables[:collection]
16
+
17
+ context = context.join(tables[:terminal], Arel::Nodes::OuterJoin).on(tables[:collection][:terminal_id].eq tables[:terminal][:id])
18
+ context = context.join(tables[:agent], Arel::Nodes::OuterJoin).on(tables[:terminal][:agent_id].eq tables[:agent][:id])
19
+
20
+ context = context.where(tables[:collection][:created_at].in(start..finish))
21
+
22
+ context
23
+ end
24
+
25
+ def groupping
26
+ %w(
27
+ collection.agent_id
28
+ collection.terminal_id
29
+ collection.hour
30
+ collection.day
31
+ collection.month
32
+ )
33
+ end
34
+
35
+ def fields
36
+ {
37
+ '' => %w(
38
+ collection.terminal_id
39
+ terminal.keyword
40
+ terminal.address
41
+ terminal.version
42
+ terminal.issues_started_at
43
+ terminal.collected_at
44
+ terminal.printer_error
45
+ terminal.cash_acceptor_error
46
+ terminal.juristic_name
47
+ terminal.sector
48
+ terminal.contact_name
49
+ terminal.contact_phone
50
+ terminal.contact_email
51
+ terminal.schedule
52
+ terminal.juristic_name
53
+ terminal.contract_number
54
+ terminal.manager
55
+ terminal.rent
56
+ terminal.rent_finish_date
57
+ terminal.collection_zone
58
+ terminal.check_phone_number
59
+ collection.agent_id
60
+ agent.title
61
+ agent.juristic_name
62
+ agent.juristic_address_city
63
+ agent.juristic_address_street
64
+ agent.juristic_address_home
65
+ agent.physical_address_city
66
+ agent.physical_address_district
67
+ agent.physical_address_subway
68
+ agent.physical_address_street
69
+ agent.physical_address_home
70
+ agent.contact_name
71
+ agent.contact_info
72
+ agent.director_name
73
+ agent.director_contact_info
74
+ agent.bookkeeper_name
75
+ agent.bookkeeper_contact_info
76
+ agent.inn
77
+ agent.support_phone
78
+ collection.created_at
79
+ collection.approved_payments_sum
80
+ collection.cash_sum
81
+ collection.payments_sum
82
+ ),
83
+ 'collection.terminal_id' => %w(
84
+ collection.terminal_id
85
+ terminal.keyword
86
+ terminal.address
87
+ terminal.version
88
+ terminal.issues_started_at
89
+ terminal.collected_at
90
+ terminal.printer_error
91
+ terminal.cash_acceptor_error
92
+ terminal.juristic_name
93
+ terminal.sector
94
+ terminal.contact_name
95
+ terminal.contact_phone
96
+ terminal.contact_email
97
+ terminal.schedule
98
+ terminal.juristic_name
99
+ terminal.contract_number
100
+ terminal.manager
101
+ terminal.rent
102
+ terminal.rent_finish_date
103
+ terminal.collection_zone
104
+ terminal.check_phone_number
105
+ ),
106
+ 'collection.agent_id' => %w(
107
+ collection.agent_id
108
+ agent.title
109
+ agent.juristic_name
110
+ agent.juristic_address_city
111
+ agent.juristic_address_street
112
+ agent.juristic_address_home
113
+ agent.physical_address_city
114
+ agent.physical_address_district
115
+ agent.physical_address_subway
116
+ agent.physical_address_street
117
+ agent.physical_address_home
118
+ agent.contact_name
119
+ agent.contact_info
120
+ agent.director_name
121
+ agent.director_contact_info
122
+ agent.bookkeeper_name
123
+ agent.bookkeeper_contact_info
124
+ agent.inn
125
+ agent.support_phone
126
+ ),
127
+ 'collection.hour' => %w(
128
+ collection.hour
129
+ ),
130
+ 'collection.day' => %w(
131
+ collection.day
132
+ ),
133
+ 'collection.month' => %w(
134
+ collection.month
135
+ )
136
+ }
137
+ end
138
+
139
+ def calculations
140
+ {
141
+ :cash_sum => lambda{|q, t| t.groupping.blank? ? q : q.project('SUM(collections.cash_sum) AS "calculations.cash_sum"') },
142
+ :approved_payments_sum => lambda{|q, t| t.groupping.blank? ? q : q.project('SUM(collections.approved_payments_sum) AS "calculations.approved_payments_sum"') },
143
+ :payments_sum => lambda{|q, t| t.groupping.blank? ? q : q.project('SUM(collections.payments_sum) AS "calculations.payments_sum"') }
144
+ }.with_indifferent_access
145
+ end
146
+
147
+ def conditions
148
+ {
149
+ }
150
+ end
151
+ end
@@ -0,0 +1,189 @@
1
+ # coding: utf-8
2
+
3
+ class PaymentsReport < ReportBuilder::Base
4
+ requires_dates!
5
+
6
+ def tables
7
+ @tables ||= {
8
+ :terminal => Arel::Table.new(:terminals),
9
+ :payment => Arel::Table.new(:payments),
10
+ :agent => Arel::Table.new(:agents),
11
+ :gateway => Arel::Table.new(:gateways),
12
+ :provider => Arel::Table.new(:providers)
13
+ }.with_indifferent_access
14
+ end
15
+
16
+ def context(start, finish)
17
+ context = tables[:payment]
18
+
19
+ [:terminal, :agent, :gateway, :provider].each do |x|
20
+ context = context.join(tables[x]).on(tables[:payment][x.to_s + '_id'].eq tables[x][:id])
21
+ end
22
+
23
+ context.where(tables[:payment][:created_at].in(start..finish))
24
+
25
+ context
26
+ end
27
+
28
+ def groupping
29
+ %w(
30
+ payment.state
31
+ payment.terminal_id
32
+ payment.provider_id
33
+ payment.agent_id
34
+ payment.gateway_id
35
+ payment.hour
36
+ payment.day
37
+ payment.month
38
+ )
39
+ end
40
+
41
+ def fields
42
+ {
43
+ '' => %w(
44
+ payment.terminal_id
45
+ terminal.keyword
46
+ terminal.address
47
+ terminal.version
48
+ terminal.issues_started_at
49
+ terminal.collected_at
50
+ terminal.printer_error
51
+ terminal.cash_acceptor_error
52
+ terminal.juristic_name
53
+ terminal.sector
54
+ terminal.contact_name
55
+ terminal.contact_phone
56
+ terminal.contact_email
57
+ terminal.schedule
58
+ terminal.juristic_name
59
+ terminal.contract_number
60
+ terminal.manager
61
+ terminal.rent
62
+ terminal.rent_finish_date
63
+ terminal.collection_zone
64
+ terminal.check_phone_number
65
+ payment.agent_id
66
+ agent.title
67
+ agent.juristic_name
68
+ agent.juristic_address_city
69
+ agent.juristic_address_street
70
+ agent.juristic_address_home
71
+ agent.physical_address_city
72
+ agent.physical_address_district
73
+ agent.physical_address_subway
74
+ agent.physical_address_street
75
+ agent.physical_address_home
76
+ agent.contact_name
77
+ agent.contact_info
78
+ agent.director_name
79
+ agent.director_contact_info
80
+ agent.bookkeeper_name
81
+ agent.bookkeeper_contact_info
82
+ agent.inn
83
+ agent.support_phone
84
+ payment.gateway_id
85
+ gateway.title
86
+ payment.provider_id
87
+ provider.title
88
+ provider.keyword
89
+ provider.juristic_name
90
+ provider.inn
91
+ payment.session_id
92
+ payment.foreign_id
93
+ payment.corrected_payment_id
94
+ payment.user_id
95
+ payment.collection_id
96
+ payment.revision_id
97
+ payment.payment_type
98
+ payment.account
99
+ payment.fields
100
+ payment.raw_fields
101
+ payment.meta
102
+ payment.currency
103
+ payment.paid_amount
104
+ payment.commission_amount
105
+ payment.enrolled_amount
106
+ payment.rebate_amount
107
+ payment.state
108
+ payment.gateway_error
109
+ payment.gateway_provider_id
110
+ payment.gateway_payment_id
111
+ payment.source
112
+ payment.receipt_number
113
+ payment.paid_at
114
+ payment.card_number
115
+ payment.card_number_hash
116
+ ),
117
+ 'payment.state' => %w(
118
+ payment.state
119
+ ),
120
+ 'payment.terminal_id' => %w(
121
+ payment.terminal_id
122
+ terminal.keyword
123
+ terminal.address
124
+ terminal.juristic_name
125
+ terminal.manager
126
+ terminal.rent
127
+ terminal.address
128
+ ),
129
+ 'payment.provider_id' => %w(
130
+ payment.provider_id
131
+ provider.title
132
+ provider.keyword
133
+ provider.juristic_name
134
+ provider.inn
135
+ ),
136
+ 'payment.agent_id' => %w(
137
+ payment.agent_id
138
+ agent.title
139
+ agent.juristic_name
140
+ agent.juristic_address_city
141
+ agent.juristic_address_street
142
+ agent.juristic_address_home
143
+ agent.physical_address_city
144
+ agent.physical_address_district
145
+ agent.physical_address_subway
146
+ agent.physical_address_street
147
+ agent.physical_address_home
148
+ agent.contact_name
149
+ agent.contact_info
150
+ agent.director_name
151
+ agent.director_contact_info
152
+ agent.bookkeeper_name
153
+ agent.bookkeeper_contact_info
154
+ agent.inn
155
+ agent.support_phone
156
+ ),
157
+ 'payment.gateway_id' => %w(
158
+ payment.gateway_id
159
+ gateway.title
160
+ ),
161
+ 'payment.hour' => %w(
162
+ payment.hour
163
+ ),
164
+ 'payment.month' => %w(
165
+ payment.month
166
+ ),
167
+ 'payment.day' => %w(
168
+ payment.day
169
+ )
170
+ }
171
+ end
172
+
173
+ def calculations
174
+ {
175
+ :quantity => lambda{|q, t| t.groupping.blank? ? q : q.project('COUNT(*) AS "calculations.quantity"') },
176
+ :enrolled => lambda{|q, t| t.groupping.blank? ? q : q.project('SUM(enrolled_amount) AS "calculations.enrolled"') },
177
+ :paid => lambda{|q, t| t.groupping.blank? ? q : q.project('SUM(paid_amount) AS "calculations.paid"') },
178
+ :commission => lambda{|q, t| t.groupping.blank? ? q : q.project('SUM(commission_amount) AS "calculations.commission"') }
179
+ }.with_indifferent_access
180
+ end
181
+
182
+ def conditions
183
+ {
184
+ 'payment.state' => proc { I18n.t('smartkiosk.payment_states') },
185
+ 'payment.payment_type' => proc { I18n.t('smartkiosk.payment_types') },
186
+ 'payment.provider_id' => proc { Provider.rmap.invert }
187
+ }
188
+ end
189
+ end
@@ -0,0 +1,123 @@
1
+ # coding: utf-8
2
+
3
+ class TerminalsReport < ReportBuilder::Base
4
+ def tables
5
+ @tables ||= {
6
+ :terminal => Arel::Table.new(:terminals),
7
+ :agent => Arel::Table.new(:agents),
8
+ :terminal_profile => Arel::Table.new(:terminal_profiles)
9
+ }.with_indifferent_access
10
+ end
11
+
12
+ def context(start, finish)
13
+ context = tables[:terminal]
14
+
15
+ [:agent, :terminal_profile].each do |x|
16
+ context = context.join(tables[x], Arel::Nodes::OuterJoin).on(tables[:terminal][x.to_s + '_id'].eq tables[x][:id])
17
+ end
18
+
19
+ context
20
+ end
21
+
22
+ def groupping
23
+ %w(
24
+ terminal.agent_id
25
+ terminal.terminal_profile_id
26
+ terminal.printer_error
27
+ terminal.cash_acceptor_error
28
+ terminal.version
29
+ )
30
+ end
31
+
32
+ def fields
33
+ {
34
+ '' => %w(
35
+ terminal.agent_id
36
+ agent.title
37
+ agent.juristic_name
38
+ agent.juristic_address_city
39
+ agent.juristic_address_street
40
+ agent.juristic_address_home
41
+ agent.physical_address_city
42
+ agent.physical_address_district
43
+ agent.physical_address_subway
44
+ agent.physical_address_street
45
+ agent.physical_address_home
46
+ agent.contact_name
47
+ agent.contact_info
48
+ agent.director_name
49
+ agent.director_contact_info
50
+ agent.bookkeeper_name
51
+ agent.bookkeeper_contact_info
52
+ agent.inn
53
+ agent.support_phone
54
+ terminal.keyword
55
+ terminal.address
56
+ terminal.version
57
+ terminal.issues_started_at
58
+ terminal.collected_at
59
+ terminal.printer_error
60
+ terminal.cash_acceptor_error
61
+ terminal.juristic_name
62
+ terminal.sector
63
+ terminal.contact_name
64
+ terminal.contact_phone
65
+ terminal.contact_email
66
+ terminal.schedule
67
+ terminal.juristic_name
68
+ terminal.contract_number
69
+ terminal.manager
70
+ terminal.rent
71
+ terminal.rent_finish_date
72
+ terminal.collection_zone
73
+ terminal.check_phone_number
74
+ ),
75
+ 'terminal.agent_id' => %w(
76
+ terminal.agent_id
77
+ agent.title
78
+ agent.juristic_name
79
+ agent.juristic_address_city
80
+ agent.juristic_address_street
81
+ agent.juristic_address_home
82
+ agent.physical_address_city
83
+ agent.physical_address_district
84
+ agent.physical_address_subway
85
+ agent.physical_address_street
86
+ agent.physical_address_home
87
+ agent.contact_name
88
+ agent.contact_info
89
+ agent.director_name
90
+ agent.director_contact_info
91
+ agent.bookkeeper_name
92
+ agent.bookkeeper_contact_info
93
+ agent.inn
94
+ agent.support_phone
95
+ ),
96
+ 'terminal.terminal_profile_id' => %w(
97
+ terminal.terminal_profile_id
98
+ terminal_profile.title
99
+ ),
100
+ 'terminal.printer_error' => %w(
101
+ terminal.printer_error
102
+ ),
103
+ 'terminal.cash_acceptor_error' => %w(
104
+ terminal.cash_acceptor_error
105
+ ),
106
+ 'terminal.version' => %w(
107
+ terminal.version
108
+ )
109
+ }
110
+ end
111
+
112
+ def calculations
113
+ {
114
+ :quantity => lambda{|q, t| t.groupping.blank? ? q : q.project('COUNT(*) AS "calculations.quantity"') }
115
+ }.with_indifferent_access
116
+ end
117
+
118
+ def conditions
119
+ {
120
+ 'terminal.condition' => proc { I18n.t('smartkiosk.terminal_conditions') }
121
+ }
122
+ end
123
+ end
@@ -0,0 +1,53 @@
1
+ class FileUploader < CarrierWave::Uploader::Base
2
+
3
+ # Include RMagick or MiniMagick support:
4
+ # include CarrierWave::RMagick
5
+ # include CarrierWave::MiniMagick
6
+
7
+ # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
8
+ # include Sprockets::Helpers::RailsHelper
9
+ # include Sprockets::Helpers::IsolatedHelper
10
+
11
+ # Choose what kind of storage to use for this uploader:
12
+ storage :file
13
+ # storage :fog
14
+
15
+ # Override the directory where uploaded files will be stored.
16
+ # This is a sensible default for uploaders that are meant to be mounted:
17
+ def store_dir
18
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
19
+ end
20
+
21
+ # Provide a default URL as a default if there hasn't been a file uploaded:
22
+ # def default_url
23
+ # # For Rails 3.1+ asset pipeline compatibility:
24
+ # # asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
25
+ #
26
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
27
+ # end
28
+
29
+ # Process files as they are uploaded:
30
+ # process :scale => [200, 300]
31
+ #
32
+ # def scale(width, height)
33
+ # # do something
34
+ # end
35
+
36
+ # Create different versions of your uploaded files:
37
+ # version :thumb do
38
+ # process :scale => [50, 50]
39
+ # end
40
+
41
+ # Add a white list of extensions which are allowed to be uploaded.
42
+ # For images you might use something like this:
43
+ # def extension_white_list
44
+ # %w(jpg jpeg gif png)
45
+ # end
46
+
47
+ # Override the filename of the uploaded files:
48
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
49
+ # def filename
50
+ # "something.jpg" if original_filename
51
+ # end
52
+
53
+ end
@@ -0,0 +1,15 @@
1
+ class IconUploader < CarrierWave::Uploader::Base
2
+ include CarrierWave::RMagick
3
+
4
+ storage :file
5
+
6
+ def store_dir
7
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
8
+ end
9
+
10
+ process :resize_to_limit => [200, 200]
11
+
12
+ version :thumb do
13
+ process :resize_to_limit => [30, 30]
14
+ end
15
+ end
@@ -0,0 +1,53 @@
1
+ class ZipUploader < CarrierWave::Uploader::Base
2
+
3
+ # Include RMagick or MiniMagick support:
4
+ # include CarrierWave::RMagick
5
+ # include CarrierWave::MiniMagick
6
+
7
+ # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
8
+ # include Sprockets::Helpers::RailsHelper
9
+ # include Sprockets::Helpers::IsolatedHelper
10
+
11
+ # Choose what kind of storage to use for this uploader:
12
+ storage :file
13
+ # storage :fog
14
+
15
+ # Override the directory where uploaded files will be stored.
16
+ # This is a sensible default for uploaders that are meant to be mounted:
17
+ def store_dir
18
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
19
+ end
20
+
21
+ # Provide a default URL as a default if there hasn't been a file uploaded:
22
+ # def default_url
23
+ # # For Rails 3.1+ asset pipeline compatibility:
24
+ # # asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
25
+ #
26
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
27
+ # end
28
+
29
+ # Process files as they are uploaded:
30
+ # process :scale => [200, 300]
31
+ #
32
+ # def scale(width, height)
33
+ # # do something
34
+ # end
35
+
36
+ # Create different versions of your uploaded files:
37
+ # version :thumb do
38
+ # process :scale => [50, 50]
39
+ # end
40
+
41
+ # Add a white list of extensions which are allowed to be uploaded.
42
+ # For images you might use something like this:
43
+ def extension_white_list
44
+ %w(zip)
45
+ end
46
+
47
+ # Override the filename of the uploaded files:
48
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
49
+ # def filename
50
+ # "something.jpg" if original_filename
51
+ # end
52
+
53
+ end
@@ -0,0 +1,10 @@
1
+ div do
2
+ if assigns[:providers][:success] == false
3
+ para do
4
+ span "Произошла ошибка:"
5
+ strong I18n.t('smartkiosk.gateways.'+assigns[:gateway].keyword+'.errors')[assigns[:providers][:error]]
6
+ end
7
+ else
8
+ p assigns[:providers][:data]
9
+ end
10
+ end
@@ -0,0 +1,28 @@
1
+ paginated_collection assigns[:payments] do
2
+ table_for(assigns[:payments], :i18n => Payment, :class => 'index_table index') do |t|
3
+ t.column :id
4
+ t.column :terminal do |p|
5
+ unless p.terminal.blank?
6
+ link_to p.terminal.keyword, admin_terminal_path(p.terminal)
7
+ end
8
+ end
9
+ t.column :id, :sortable => :id do |p|
10
+ link_to p.id, [:admin, p]
11
+ end
12
+ t.column :foreign_id
13
+ t.column :account
14
+ t.column :terminal
15
+ t.column :state, :sortable => :state do |p|
16
+ condition = :ok
17
+ condition = :warning if ['queue', 'checked'].include?(p.state)
18
+ condition = :error if p.state == 'error'
19
+ status_tag I18n.t("smartkiosk.payment_states.#{p.state}"), condition
20
+ end
21
+ t.column :paid_amount
22
+ t.column :enrolled_amount
23
+ t.column :commission_amount
24
+ t.column :provider
25
+ t.column :paid_at
26
+ t.column :created_at
27
+ end
28
+ end
@@ -0,0 +1,35 @@
1
+ - if entry.is_a?(TerminalProfileProviderGroup)
2
+ %li.input{:style => 'padding-right: 0px; padding-left: 0px; cursor: move', :'data-id' => entry.provider_group.id, :'data-parent' => entry.provider_group.provider_group_id}
3
+ %div{:style => 'padding-left: 10px; padding-bottom: 5px; border-bottom: 1px dashed gray'}
4
+ &#8645;
5
+ = image_tag(entry.icon.url(:thumb), :style => 'vertical-align: middle') unless entry.icon.blank?
6
+ &nbsp;
7
+ %b{:style => 'font-size:1.2em'}= entry.provider_group.title
8
+ %span{:style => "float: right; display: block"}
9
+ %em= entry.class.human_attribute_name(:icon).mb_chars.downcase + ':'
10
+ &nbsp;
11
+ %input{:type => 'file', :name => "terminal_profile_provider_groups[][icon]"}
12
+ %input{:type => 'hidden', :name => "terminal_profile_provider_groups[][terminal_profile_id]", :value => entry.terminal_profile_id}
13
+ %input{:type => 'hidden', :name => "terminal_profile_provider_groups[][provider_group_id]", :value => entry.provider_group_id}
14
+ %input{:type => 'hidden', :name => "terminal_profile_provider_groups[][priority]", :value => entry.priority}
15
+ %ol{:style => 'padding-left:30px'}
16
+ - subs = @terminal_profile.terminal_profile_provider_groups
17
+ - subs = subs.select{|x| x.provider_group.provider_group == entry.provider_group}
18
+ - subs += entry.terminal_profile_providers
19
+
20
+ - subs.sort_by{|x| x.priority}.each_with_index do |x|
21
+ = render 'tree', :entry => x, :level => level+1
22
+ - else
23
+ %li.input{:style => 'padding-right: 0px; padding-left: 0px; cursor: move', :'data-id' => entry.provider.id, :'data-parent' => entry.provider.provider_group_id}
24
+ %div{:style => 'padding-left: 10px; padding-bottom: 5px; border-bottom: 1px dashed gray'}
25
+ &#8645;
26
+ = image_tag(entry.icon.url(:thumb), :style => 'vertical-align: middle') unless entry.icon.blank?
27
+ &nbsp;
28
+ = entry.provider.title
29
+ %span{:style => "float: right; display: block"}
30
+ %em= entry.class.human_attribute_name(:icon).mb_chars.downcase + ':'
31
+ &nbsp;
32
+ %input{:type => 'file', :name => "terminal_profile_providers[][icon]"}
33
+ %input{:type => 'hidden', :name => "terminal_profile_providers[][terminal_profile_id]", :value => entry.terminal_profile_id}
34
+ %input{:type => 'hidden', :name => "terminal_profile_providers[][provider_id]", :value => entry.provider_id}
35
+ %input{:type => 'hidden', :name => "terminal_profile_providers[][priority]", :value => entry.priority}
@@ -0,0 +1,21 @@
1
+ :coffeescript
2
+ $ ->
3
+ $('fieldset.sortable > ol').nestedSortable
4
+ handle: 'div'
5
+ items: 'li'
6
+ toleranceElement: '> div'
7
+ update: ->
8
+ sortInputs = $("fieldset.sortable > ol input[name$='[priority]']")
9
+ sortInputs.each (index) -> $(this).val index
10
+ isAllowed: (item, parent) ->
11
+ item = $(item).attr('data-parent')
12
+ parent = $(parent).attr('data-id')
13
+
14
+ item == parent
15
+
16
+ = semantic_form_for [:admin, @terminal_profile], :html => { :multipart => true } do |f|
17
+ = f.inputs :class => 'sortable', :style => 'padding: 0px; margin: 0px' do
18
+ - @terminal_profile.terminal_profile_provider_groups.select{|x| x.provider_group.provider_group.blank?}.each_with_index do |g, i|
19
+ = render 'tree', :entry => g, :level => 0
20
+
21
+ = f.actions