smartkiosk-server 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +32 -0
- data/.rspec +1 -0
- data/Capfile +4 -0
- data/Gemfile +71 -0
- data/Gemfile.lock +439 -0
- data/Guardfile +25 -0
- data/LICENSE +287 -0
- data/README.md +13 -0
- data/Rakefile +5 -0
- data/app/acquirers/cards_mkb_acquirer.rb +87 -0
- data/app/acquirers/cash_acquirer.rb +22 -0
- data/app/admin/agents.rb +108 -0
- data/app/admin/collections.rb +62 -0
- data/app/admin/commissions.rb +87 -0
- data/app/admin/gateways.rb +183 -0
- data/app/admin/limits.rb +82 -0
- data/app/admin/payments.rb +246 -0
- data/app/admin/provider_groups.rb +60 -0
- data/app/admin/provider_profiles.rb +11 -0
- data/app/admin/provider_receipt_templates.rb +82 -0
- data/app/admin/providers.rb +201 -0
- data/app/admin/rebates.rb +83 -0
- data/app/admin/report_results.rb +66 -0
- data/app/admin/report_templates.rb +209 -0
- data/app/admin/reports.rb +158 -0
- data/app/admin/revisions.rb +120 -0
- data/app/admin/system_receipt_templates.rb +76 -0
- data/app/admin/terminal_builds.rb +39 -0
- data/app/admin/terminal_profiles.rb +123 -0
- data/app/admin/terminals.rb +388 -0
- data/app/admin/users.rb +117 -0
- data/app/admin/versions.rb +131 -0
- data/app/admin/welcome.rb +64 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.eot +0 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.svg +6386 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.ttf +0 -0
- data/app/assets/fonts/PT_Sans-Web-Bold.woff +0 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.eot +0 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.svg +5650 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.ttf +0 -0
- data/app/assets/fonts/PT_Sans-Web-Regular.woff +0 -0
- data/app/assets/images/chosen-sprite.png +0 -0
- data/app/assets/javascripts/active_admin/chosen.js.erb.coffee +12 -0
- data/app/assets/javascripts/active_admin/qtip.js.coffee +22 -0
- data/app/assets/javascripts/active_admin/sortable_forms.js.coffee +14 -0
- data/app/assets/javascripts/active_admin.js.coffee +9 -0
- data/app/assets/javascripts/application.js +15 -0
- data/app/assets/javascripts/report_templates.js.coffee +10 -0
- data/app/assets/javascripts/terminals.js.coffee +12 -0
- data/app/assets/stylesheets/active_admin/PIE.css.scss +18 -0
- data/app/assets/stylesheets/active_admin/filter_numeric_range.css.scss +14 -0
- data/app/assets/stylesheets/active_admin/selectable_check_boxes.css.scss +12 -0
- data/app/assets/stylesheets/active_admin/sortable_forms.css.scss +11 -0
- data/app/assets/stylesheets/active_admin.css.scss +705 -0
- data/app/assets/stylesheets/fonts.css.scss +14 -0
- data/app/assets/stylesheets/provider_groups.css.scss +12 -0
- data/app/assets/stylesheets/provider_receipt_templates.css.scss +12 -0
- data/app/assets/stylesheets/terminals.css.scss +9 -0
- data/app/controllers/application_controller.rb +12 -0
- data/app/controllers/collections_controller.rb +10 -0
- data/app/controllers/payments_controller.rb +73 -0
- data/app/controllers/system_receipt_templates_controller.rb +10 -0
- data/app/controllers/terminal_builds_controller.rb +5 -0
- data/app/controllers/terminal_orders_controller.rb +25 -0
- data/app/controllers/terminal_pings_controller.rb +45 -0
- data/app/controllers/welcome_controller.rb +5 -0
- data/app/helpers/active_admin/report_templates_helper.rb +56 -0
- data/app/helpers/active_admin/views_helper.rb +20 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/ability.rb +30 -0
- data/app/models/agent.rb +24 -0
- data/app/models/collection.rb +65 -0
- data/app/models/commission.rb +77 -0
- data/app/models/commission_section.rb +75 -0
- data/app/models/gateway.rb +99 -0
- data/app/models/gateway_attachment.rb +9 -0
- data/app/models/gateway_setting.rb +7 -0
- data/app/models/gateway_switch.rb +7 -0
- data/app/models/limit.rb +77 -0
- data/app/models/limit_section.rb +58 -0
- data/app/models/payment.rb +322 -0
- data/app/models/provider.rb +59 -0
- data/app/models/provider_field.rb +7 -0
- data/app/models/provider_gateway.rb +47 -0
- data/app/models/provider_group.rb +45 -0
- data/app/models/provider_profile.rb +9 -0
- data/app/models/provider_rebate.rb +69 -0
- data/app/models/provider_receipt_template.rb +85 -0
- data/app/models/rebate.rb +84 -0
- data/app/models/report.rb +71 -0
- data/app/models/report_result.rb +11 -0
- data/app/models/report_template.rb +56 -0
- data/app/models/revision.rb +104 -0
- data/app/models/role.rb +48 -0
- data/app/models/system_receipt_template.rb +13 -0
- data/app/models/terminal.rb +126 -0
- data/app/models/terminal_build.rb +62 -0
- data/app/models/terminal_order.rb +42 -0
- data/app/models/terminal_ping.rb +120 -0
- data/app/models/terminal_profile.rb +51 -0
- data/app/models/terminal_profile_promotion.rb +18 -0
- data/app/models/terminal_profile_provider.rb +11 -0
- data/app/models/terminal_profile_provider_group.rb +19 -0
- data/app/models/user.rb +38 -0
- data/app/models/user_role.rb +45 -0
- data/app/reports/agents_report.rb +81 -0
- data/app/reports/collections_report.rb +151 -0
- data/app/reports/payments_report.rb +189 -0
- data/app/reports/terminals_report.rb +123 -0
- data/app/uploaders/file_uploader.rb +53 -0
- data/app/uploaders/icon_uploader.rb +15 -0
- data/app/uploaders/zip_uploader.rb +53 -0
- data/app/views/admin/gateways/providers.html.arb +10 -0
- data/app/views/admin/revisions/payments.html.arb +28 -0
- data/app/views/admin/terminal_profiles/_tree.html.haml +35 -0
- data/app/views/admin/terminal_profiles/sort.html.haml +21 -0
- data/app/views/admin/terminals/pings.html.arb +55 -0
- data/app/views/admin/terminals/upgrade_build.html.arb +30 -0
- data/app/views/layouts/application.html.erb +1 -0
- data/app/views/welcome/index.html.erb +25 -0
- data/app/workers/pay_worker.rb +11 -0
- data/app/workers/report_worker.rb +7 -0
- data/app/workers/revise_worker.rb +7 -0
- data/config/acquiring.yml +13 -0
- data/config/application.rb +75 -0
- data/config/boot.rb +6 -0
- data/config/database.yml +17 -0
- data/config/deploy/roundlake-passenger.rb +3 -0
- data/config/deploy/roundlake-trinidad.rb +3 -0
- data/config/deploy.rb +37 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +39 -0
- data/config/environments/production.rb +67 -0
- data/config/environments/test.rb +37 -0
- data/config/initializers/active_admin.rb +31 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/devise.rb +232 -0
- data/config/initializers/inflections.rb +15 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/money.rb +6 -0
- data/config/initializers/redis.rb +4 -0
- data/config/initializers/secret_token.rb +7 -0
- data/config/initializers/session_store.rb +8 -0
- data/config/initializers/setup_rack.rb +1 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/active_admin.ru.yml +71 -0
- data/config/locales/activerecord.ru.yml +645 -0
- data/config/locales/devise.ru.yml +57 -0
- data/config/locales/ru.yml +33 -0
- data/config/locales/smartkiosk.gateways.ru.yml +241 -0
- data/config/locales/smartkiosk.hardware.ru.yml +38 -0
- data/config/locales/smartkiosk.reports.ru.yml +56 -0
- data/config/locales/smartkiosk.ru.yml +163 -0
- data/config/nginx.conf +9 -0
- data/config/redis.yml +9 -0
- data/config/routes.rb +48 -0
- data/config/schedule.rb +13 -0
- data/config/sidekiq.yml +5 -0
- data/config/trinidad.yml +6 -0
- data/config.ru +4 -0
- data/db/migrate/20120825083035_create_terminals.rb +47 -0
- data/db/migrate/20120825083305_create_payments.rb +51 -0
- data/db/migrate/20120827062618_devise_create_users.rb +50 -0
- data/db/migrate/20120827132621_create_admin_notes.rb +17 -0
- data/db/migrate/20120827132622_move_admin_notes_to_comments.rb +25 -0
- data/db/migrate/20120903193346_create_providers.rb +24 -0
- data/db/migrate/20120922075345_create_collections.rb +26 -0
- data/db/migrate/20120922080440_create_agents.rb +29 -0
- data/db/migrate/20120922081104_create_commissions.rb +10 -0
- data/db/migrate/20120927035841_create_gateways.rb +13 -0
- data/db/migrate/20120927040626_create_provider_gateways.rb +13 -0
- data/db/migrate/20120927091849_create_limits.rb +10 -0
- data/db/migrate/20120927164647_create_roles.rb +14 -0
- data/db/migrate/20121003131522_create_report_templates.rb +18 -0
- data/db/migrate/20121007135652_create_reports.rb +13 -0
- data/db/migrate/20121008073905_create_report_results.rb +10 -0
- data/db/migrate/20121017114538_create_gateway_settings.rb +12 -0
- data/db/migrate/20121017114556_create_gateway_attachments.rb +10 -0
- data/db/migrate/20121019132606_create_revisions.rb +19 -0
- data/db/migrate/20121023073501_create_gateway_switches.rb +10 -0
- data/db/migrate/20121112142743_create_terminal_orders.rb +13 -0
- data/db/migrate/20121118191553_create_versions.rb +19 -0
- data/db/migrate/20121125093414_create_system_receipt_templates.rb +9 -0
- data/db/migrate/20121127192257_create_terminal_builds.rb +10 -0
- data/db/migrate/20121212053441_create_rebates.rb +15 -0
- data/db/migrate/20121216143855_create_provider_receipt_templates.rb +9 -0
- data/db/migrate/20130101091100_create_terminal_profiles.rb +13 -0
- data/db/migrate/20130101091734_create_provider_rebates.rb +21 -0
- data/db/migrate/20130102164447_create_limit_sections.rb +14 -0
- data/db/migrate/20130102164503_create_commission_sections.rb +17 -0
- data/db/migrate/20130102171743_create_provider_profiles.rb +10 -0
- data/db/migrate/20130103152507_create_provider_fields.rb +17 -0
- data/db/migrate/20130103154526_create_provider_groups.rb +10 -0
- data/db/migrate/20130104063628_create_terminal_profile_providers.rb +11 -0
- data/db/migrate/20130104090957_create_terminal_profile_provider_groups.rb +11 -0
- data/db/migrate/20130108091644_create_terminal_profile_promotions.rb +10 -0
- data/db/schema.rb +489 -0
- data/db/seeds/receipt_templates/payment.txt +19 -0
- data/db/seeds/receipt_templates/system/balance.txt +13 -0
- data/db/seeds/receipt_templates/system/collection.txt +17 -0
- data/db/seeds/receipt_templates/system/touchtest.txt +15 -0
- data/db/seeds.rb +18 -0
- data/doc/README_FOR_APP +2 -0
- data/init.rb +1 -0
- data/lib/active_admin/cancan_integration.rb +81 -0
- data/lib/active_admin/form_builder_fix.rb +76 -0
- data/lib/active_admin/inputs/filter_date_range_input_fix.rb +24 -0
- data/lib/active_admin/inputs/filter_multiple_select_input.rb +18 -0
- data/lib/active_admin/inputs/filter_numeric_range_input.rb +31 -0
- data/lib/active_admin/resource_controller_fix.rb +23 -0
- data/lib/active_admin/views/pages/base_fix.rb +13 -0
- data/lib/assets/.gitkeep +0 -0
- data/lib/blueprints.rb +79 -0
- data/lib/date_expander.rb +38 -0
- data/lib/dav4rack/build_resource.rb +59 -0
- data/lib/formtastic/inputs/selectable_check_boxes.rb +39 -0
- data/lib/paper_trail/version_fix.rb +3 -0
- data/lib/report_builder.rb +88 -0
- data/lib/seeder.rb +103 -0
- data/lib/smartkiosk/server/version.rb +5 -0
- data/lib/smartkiosk/server.rb +35 -0
- data/lib/string_file.rb +12 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/db.rake +27 -0
- data/lib/tasks/dump.rake +53 -0
- data/lib/tasks/matrioshka.rake +16 -0
- data/log/.gitkeep +0 -0
- data/log/gateways/.gitkeep +0 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +25 -0
- data/public/robots.txt +5 -0
- data/script/rails +6 -0
- data/smartkiosk-server.gemspec +23 -0
- data/spec/controllers/collections_controller_spec.rb +32 -0
- data/spec/controllers/payments_controller_spec.rb +123 -0
- data/spec/controllers/system_receipt_templates_controller_spec.rb +5 -0
- data/spec/controllers/terminal_builds_controller_spec.rb +5 -0
- data/spec/controllers/terminal_orders_controller_spec.rb +32 -0
- data/spec/controllers/terminal_pings_controller_spec.rb +31 -0
- data/spec/spec_helper.rb +66 -0
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/javascripts/chosen.jquery.js +1026 -0
- data/vendor/assets/javascripts/datepicker-ru.jquery.js +21 -0
- data/vendor/assets/javascripts/nestedSortable.jquery.js +429 -0
- data/vendor/assets/javascripts/qtip.jquery.js +3403 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/chosen.jquery.css +397 -0
- data/vendor/assets/stylesheets/modules/PIE.htc +96 -0
- data/vendor/assets/stylesheets/qtip.jquery.css.scss +604 -0
- data/vendor/plugins/.gitkeep +0 -0
- metadata +333 -0
@@ -0,0 +1,183 @@
|
|
1
|
+
ActiveAdmin.register Gateway do
|
2
|
+
actions :index, :show, :edit, :update
|
3
|
+
|
4
|
+
menu :parent => I18n.t('activerecord.models.gateway.other'),
|
5
|
+
:label => I18n.t('smartkiosk.admin.menu.manage'),
|
6
|
+
:priority => 1,
|
7
|
+
:if => proc { can? :index, Gateway }
|
8
|
+
|
9
|
+
member_action :providers do
|
10
|
+
@gateway = Gateway.find(params[:id])
|
11
|
+
@providers = @gateway.librarize.providers
|
12
|
+
end
|
13
|
+
|
14
|
+
#
|
15
|
+
# INDEX
|
16
|
+
#
|
17
|
+
batch_action I18n.t('smartkiosk.admin.actions.gateways.enable') do |selection|
|
18
|
+
Gateway.find(selection).each do |p|
|
19
|
+
p.update_attribute(:enabled, true)
|
20
|
+
end
|
21
|
+
|
22
|
+
redirect_to :action => :index
|
23
|
+
end
|
24
|
+
|
25
|
+
batch_action I18n.t('smartkiosk.admin.actions.gateways.disable') do |selection|
|
26
|
+
Gateway.find(selection).each do |p|
|
27
|
+
p.update_attribute(:enabled, false)
|
28
|
+
end
|
29
|
+
|
30
|
+
redirect_to :action => :index
|
31
|
+
end
|
32
|
+
|
33
|
+
filter :title
|
34
|
+
filter :keyword
|
35
|
+
filter :debug_level, :as => 'multiple_select',
|
36
|
+
:collection => proc { I18n.t('smartkiosk.debug_levels').invert },
|
37
|
+
:input_html => { :class => 'chosen' }
|
38
|
+
filter :created_at
|
39
|
+
filter :updated_at
|
40
|
+
|
41
|
+
index do
|
42
|
+
selectable_column
|
43
|
+
column :title, :sortable => :title do |x|
|
44
|
+
link_to x.title, [:admin, x]
|
45
|
+
end
|
46
|
+
column :keyword
|
47
|
+
column :enabled do |x|
|
48
|
+
if x.enabled?
|
49
|
+
status_tag I18n.t('formtastic.yes'), 'ok'
|
50
|
+
else
|
51
|
+
status_tag I18n.t('fomtastic.no'), 'error'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
column :updated_at
|
55
|
+
default_actions
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# SHOW
|
60
|
+
#
|
61
|
+
action_item :only => [:show] do
|
62
|
+
link_to I18n.t('smartkiosk.admin.actions.gateways.pay'),
|
63
|
+
new_admin_payment_path(:payment => {:gateway_id => gateway.id})
|
64
|
+
end
|
65
|
+
|
66
|
+
action_item :only => [:show], :if => proc { gateway.librarize.can_list_providers? } do
|
67
|
+
link_to I18n.t('smartkiosk.admin.actions.gateways.providers'),
|
68
|
+
providers_admin_gateway_path(gateway)
|
69
|
+
end
|
70
|
+
|
71
|
+
show do
|
72
|
+
attributes_table do
|
73
|
+
row :title
|
74
|
+
row :keyword
|
75
|
+
row :created_at
|
76
|
+
end
|
77
|
+
|
78
|
+
panel I18n.t('smartkiosk.admin.panels.gateways.settings') do
|
79
|
+
div(:class => 'attributes_table') do
|
80
|
+
table do
|
81
|
+
gateway.available_switches.each do |s|
|
82
|
+
tr do
|
83
|
+
th do
|
84
|
+
I18n.t("smartkiosk.gateways.#{gateway.keyword}.switches.#{s}")
|
85
|
+
end
|
86
|
+
td do
|
87
|
+
if gateway.send("switch_#{s}")
|
88
|
+
I18n.t('formtastic.yes')
|
89
|
+
else
|
90
|
+
span(I18n.t('formtastic.no'), :class => 'empty')
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
gateway.available_settings.each do |s|
|
96
|
+
tr do
|
97
|
+
th do
|
98
|
+
I18n.t("smartkiosk.gateways.#{gateway.keyword}.settings.#{s}")
|
99
|
+
end
|
100
|
+
td do
|
101
|
+
value = gateway.send("setting_#{s}")
|
102
|
+
unless value.blank?
|
103
|
+
value
|
104
|
+
else
|
105
|
+
span(I18n.t('active_admin.empty'), :class => 'empty')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
gateway.available_attachments.each do |a|
|
111
|
+
tr do
|
112
|
+
th do
|
113
|
+
I18n.t("smartkiosk.gateways.#{gateway.keyword}.attachments.#{a}")
|
114
|
+
end
|
115
|
+
td do
|
116
|
+
value = gateway.send("attachment_#{a}")
|
117
|
+
unless value.blank?
|
118
|
+
link_to value.path.split('/').last, value.url
|
119
|
+
else
|
120
|
+
span(I18n.t('active_admin.empty'), :class => 'empty')
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
panel I18n.t('activerecord.models.payment.other') do
|
130
|
+
table_for(gateway.payments.limit(20), :i18n => Payment) do |t|
|
131
|
+
t.column :terminal do |p|
|
132
|
+
unless p.terminal.blank?
|
133
|
+
link_to p.terminal.keyword, admin_terminal_path(p.terminal)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
t.column :paid_amount
|
137
|
+
t.column :provider
|
138
|
+
t.column :created_at
|
139
|
+
end
|
140
|
+
button(link_to I18n.t('smartkiosk.full_list'), admin_payments_path(:q => {:gateway_id_eq => gateway.id}))
|
141
|
+
end
|
142
|
+
|
143
|
+
active_admin_comments
|
144
|
+
end
|
145
|
+
|
146
|
+
#
|
147
|
+
# FORM
|
148
|
+
#
|
149
|
+
form do |f|
|
150
|
+
f.inputs I18n.t('smartkiosk.admin.panels.gateways.settings') do
|
151
|
+
f.input :debug_level, :as => :select,
|
152
|
+
:collection => I18n.t("smartkiosk.debug_levels").invert, :input_html => {:class => 'chosen'}
|
153
|
+
|
154
|
+
f.input :requires_revisions_moderation, :as => :select, :input_html => {:class => 'chosen'}
|
155
|
+
|
156
|
+
gateway.available_switches.each do |s|
|
157
|
+
f.input "switch_#{s}", :as => :select,
|
158
|
+
:label => I18n.t("smartkiosk.gateways.#{gateway.keyword}.switches.#{s}"),
|
159
|
+
:input_html => {:value => f.object.send("switch_#{s}"), :class => 'chosen'}
|
160
|
+
end
|
161
|
+
|
162
|
+
gateway.available_settings.each do |s|
|
163
|
+
f.input "setting_#{s}", :as => :string,
|
164
|
+
:label => I18n.t("smartkiosk.gateways.#{gateway.keyword}.settings.#{s}"),
|
165
|
+
:input_html => {:value => f.object.send("setting_#{s}")}
|
166
|
+
end
|
167
|
+
|
168
|
+
gateway.available_attachments.each do |a|
|
169
|
+
file = f.object.send(:"attachment_#{a}")
|
170
|
+
|
171
|
+
f.input "attachment_#{a}",
|
172
|
+
:label => I18n.t("smartkiosk.gateways.#{gateway.keyword}.attachments.#{a}"), :as => :file,
|
173
|
+
:hint => (f.template.link_to(file.path.split('/').last).html_safe unless file.blank?)
|
174
|
+
end
|
175
|
+
|
176
|
+
f.input :enabled, :as => :select, :input_html => {:class => 'chosen'}
|
177
|
+
|
178
|
+
f.form_buffers.last
|
179
|
+
end
|
180
|
+
|
181
|
+
f.actions
|
182
|
+
end
|
183
|
+
end
|
data/app/admin/limits.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
ActiveAdmin.register Limit do
|
2
|
+
menu :parent => I18n.t('activerecord.models.provider.other'),
|
3
|
+
:if => proc { can? :index, Limit }
|
4
|
+
|
5
|
+
#
|
6
|
+
# INDEX
|
7
|
+
#
|
8
|
+
filter :id
|
9
|
+
filter :provider_profile, :as => 'multiple_select', :input_html => { :class => 'chosen' },
|
10
|
+
:collection => proc { ProviderProfile.rmap }
|
11
|
+
filter :provider_profile_providers_id, :as => 'multiple_select', :input_html => { :class => 'chosen' },
|
12
|
+
:collection => proc { Provider.rmap }
|
13
|
+
filter :start
|
14
|
+
filter :finish
|
15
|
+
filter :created_at
|
16
|
+
filter :updated_at
|
17
|
+
|
18
|
+
index do
|
19
|
+
selectable_column
|
20
|
+
column :id, :sortable => :id do |x|
|
21
|
+
link_to x.id, [:admin, x]
|
22
|
+
end
|
23
|
+
column :provider_profile
|
24
|
+
column :start
|
25
|
+
column :finish
|
26
|
+
default_actions
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# SHOW
|
31
|
+
#
|
32
|
+
show do
|
33
|
+
attributes_table do
|
34
|
+
row :provider_profile
|
35
|
+
row :start
|
36
|
+
row :finish
|
37
|
+
row :created_at
|
38
|
+
row :updated_at
|
39
|
+
end
|
40
|
+
|
41
|
+
panel I18n.t('activerecord.models.limit_section.other') do
|
42
|
+
table_for(limit.limit_sections, :i18n => LimitSection) do |t|
|
43
|
+
t.column :agent
|
44
|
+
t.column :terminal_profile
|
45
|
+
t.column :payment_type
|
46
|
+
t.column :min
|
47
|
+
t.column :max
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
active_admin_comments
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# FORM
|
56
|
+
#
|
57
|
+
form do |f|
|
58
|
+
f.semantic_errors
|
59
|
+
f.inputs do
|
60
|
+
f.input :provider_profile, :input_html => { :class => 'chosen' },
|
61
|
+
:collection => ProviderProfile.rmap
|
62
|
+
f.input :start, :as => :datepicker
|
63
|
+
f.input :finish, :as => :datepicker
|
64
|
+
end
|
65
|
+
f.inputs do
|
66
|
+
f.has_many :limit_sections do |lsf|
|
67
|
+
lsf.semantic_errors
|
68
|
+
lsf.input :agent, :collection => Agent.rmap, :input_html => { :class => 'chosen' }
|
69
|
+
lsf.input :terminal_profile, :collection => TerminalProfile.rmap, :input_html => { :class => 'chosen' }
|
70
|
+
lsf.input :payment_type, :as => :select, :input_html => { :class => 'chosen' },
|
71
|
+
:collection => I18n.t('smartkiosk.payment_types').invert
|
72
|
+
lsf.input :min
|
73
|
+
lsf.input :max
|
74
|
+
unless lsf.object.new_record?
|
75
|
+
lsf.input :_destroy, :as => :boolean, :label => I18n.t('active_admin.delete')
|
76
|
+
end
|
77
|
+
lsf.form_buffers.last
|
78
|
+
end
|
79
|
+
end
|
80
|
+
f.actions
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
ActiveAdmin.register Payment do
|
2
|
+
actions :index, :show, :new, :create
|
3
|
+
|
4
|
+
controller do
|
5
|
+
def scoped_collection
|
6
|
+
Payment.includes(:terminal, :provider)
|
7
|
+
end
|
8
|
+
|
9
|
+
def create
|
10
|
+
@payment.source = Payment::SOURCE_MANUAL
|
11
|
+
@payment.user = current_user
|
12
|
+
|
13
|
+
Payment.transaction do
|
14
|
+
unless @payment.save
|
15
|
+
render :action => 'new'
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
@payment.check!
|
20
|
+
|
21
|
+
unless @payment.state == 'checked'
|
22
|
+
@payment = Payment.new(@payment.attributes)
|
23
|
+
@payment.errors[:base] << I18n.t('activerecord.errors.models.payment.declined')
|
24
|
+
render :action => 'new'
|
25
|
+
raise ActiveRecord::Rollback
|
26
|
+
end
|
27
|
+
|
28
|
+
@payment.enqueue!
|
29
|
+
@payment.corrected_payment.pay_manually!(@payment.user) rescue false
|
30
|
+
|
31
|
+
redirect_to [:admin, @payment]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
member_action :confirm, :method => :post do
|
37
|
+
payment = Payment.find(params[:id])
|
38
|
+
payment.pay_manually!(current_user)
|
39
|
+
redirect_to :action => :show
|
40
|
+
end
|
41
|
+
|
42
|
+
member_action :requeue, :method => :post do
|
43
|
+
payment = Payment.find(params[:id])
|
44
|
+
payment.requeue!(current_user)
|
45
|
+
redirect_to :action => :show
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# INDEX
|
50
|
+
#
|
51
|
+
batch_action I18n.t('smartkiosk.admin.actions.payments.paid_manually') do |selection|
|
52
|
+
Payment.find(selection).each do |p|
|
53
|
+
p.pay_manually!(current_user) if p.state == 'error'
|
54
|
+
end
|
55
|
+
|
56
|
+
redirect_to :back
|
57
|
+
end
|
58
|
+
|
59
|
+
batch_action I18n.t('smartkiosk.admin.actions.payments.repay') do |selection|
|
60
|
+
Payment.find(selection).each do |p|
|
61
|
+
p.requeue!(current_user) if p.state == 'error'
|
62
|
+
end
|
63
|
+
|
64
|
+
redirect_to :back
|
65
|
+
end
|
66
|
+
|
67
|
+
scope I18n.t('active_admin.all'), :all
|
68
|
+
scope I18n.t('activerecord.scopes.payment.queued'), :queued
|
69
|
+
scope I18n.t('activerecord.scopes.payment.error'), :error
|
70
|
+
|
71
|
+
filter :id
|
72
|
+
filter :state, :as => 'multiple_select',
|
73
|
+
:input_html => { :class => 'chosen' },
|
74
|
+
:collection => proc { I18n.t('smartkiosk.payment_states').invert }
|
75
|
+
filter :source, :as => 'multiple_select',
|
76
|
+
:input_html => { :class => 'chosen' },
|
77
|
+
:collection => proc { I18n.t('smartkiosk.payment_sources').invert }
|
78
|
+
filter :agent, :as => 'multiple_select', :input_html => { :class => 'chosen' },
|
79
|
+
:collection => proc { Agent.rmap }
|
80
|
+
filter :terminal, :as => 'multiple_select', :input_html => { :class => 'chosen' }
|
81
|
+
filter :session_id
|
82
|
+
filter :gateway, :as => 'multiple_select', :input_html => { :class => 'chosen' }
|
83
|
+
filter :provider, :as => 'multiple_select', :input_html => { :class => 'chosen' }
|
84
|
+
filter :account
|
85
|
+
filter :paid_amount, :as => 'numeric_range'
|
86
|
+
filter :commission_amount, :as => 'numeric_range'
|
87
|
+
filter :rebate_amount, :as => 'numeric_range'
|
88
|
+
filter :created_at
|
89
|
+
|
90
|
+
index do
|
91
|
+
selectable_column
|
92
|
+
column :id, :sortable => :id do |x|
|
93
|
+
link_to x.id, [:admin, x]
|
94
|
+
end
|
95
|
+
column :terminal
|
96
|
+
column :session_id
|
97
|
+
column :account
|
98
|
+
column :provider
|
99
|
+
column :state, :sortable => :state do |x|
|
100
|
+
condition = :ok
|
101
|
+
condition = :warning if ['queue', 'checked'].include?(x.state)
|
102
|
+
condition = :error if x.state == 'error'
|
103
|
+
status_tag I18n.t("smartkiosk.payment_states.#{x.state}"), condition
|
104
|
+
end
|
105
|
+
column :paid_amount, :sort => :paid_amount do |x|
|
106
|
+
div :title => "#{x.enrolled_amount} + #{x.commission_amount}" do
|
107
|
+
x.paid_amount
|
108
|
+
end
|
109
|
+
end
|
110
|
+
column :rebate_amount
|
111
|
+
column :date, :sortable => :created_at do |x|
|
112
|
+
div :class => 'nowrap', :title => Payment.human_attribute_name(:created_at) do
|
113
|
+
status_tag I18n.l(x.created_at, :format => :long), :raw
|
114
|
+
end
|
115
|
+
if x.paid?
|
116
|
+
div :class => 'nowrap', :title => Payment.human_attribute_name(:paid_at) do
|
117
|
+
status_tag I18n.l(x.paid_at, :format => :long), :ok
|
118
|
+
end
|
119
|
+
elsif x.error?
|
120
|
+
div :class => 'nowrap', :title => Payment.human_attribute_name(:updated_at) do
|
121
|
+
status_tag I18n.l(x.updated_at, :format => :long), :error
|
122
|
+
end
|
123
|
+
else
|
124
|
+
div :class => 'nowrap', :title => Payment.human_attribute_name(:updated_at) do
|
125
|
+
status_tag I18n.l(x.updated_at, :format => :long), :warning
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
#
|
132
|
+
# SHOW
|
133
|
+
#
|
134
|
+
action_item :only => [:show], :if => proc { ['error'].include? payment.state } do
|
135
|
+
link_to I18n.t('smartkiosk.admin.actions.payments.paid_manually'),
|
136
|
+
confirm_admin_payment_path(payment), :method => :post
|
137
|
+
end
|
138
|
+
|
139
|
+
action_item :only => [:show], :if => proc { ['error'].include? payment.state } do
|
140
|
+
link_to I18n.t('smartkiosk.admin.actions.payments.repay'),
|
141
|
+
requeue_admin_payment_path(payment), :method => :post
|
142
|
+
end
|
143
|
+
|
144
|
+
show do
|
145
|
+
attributes_table do
|
146
|
+
row :id
|
147
|
+
row :session_id
|
148
|
+
row :terminal do |x|
|
149
|
+
unless x.terminal.blank?
|
150
|
+
link_to x.terminal.keyword, admin_terminal_path(x.terminal)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
row :state do |x|
|
154
|
+
condition = :ok
|
155
|
+
condition = :warning if x.state == 'queue'
|
156
|
+
condition = :error if x.state == 'error'
|
157
|
+
status_tag I18n.t("smartkiosk.payment_states.#{x.state}"), condition
|
158
|
+
end
|
159
|
+
row :gateway
|
160
|
+
row :provider
|
161
|
+
row :paid_amount
|
162
|
+
row :enrolled_amount
|
163
|
+
row :commission_amount
|
164
|
+
row :rebate_amount
|
165
|
+
row :created_at
|
166
|
+
row :updated_at
|
167
|
+
row :account
|
168
|
+
row :user
|
169
|
+
row :fields do |x|
|
170
|
+
unless x.fields.blank?
|
171
|
+
x.fields.each do |k,v|
|
172
|
+
li do
|
173
|
+
b("#{k}:")
|
174
|
+
span(v)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
row :raw_fields do |x|
|
180
|
+
unless x.fields.blank?
|
181
|
+
x.fields.each do |k,v|
|
182
|
+
li do
|
183
|
+
b("#{k}:")
|
184
|
+
span(v)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
row :gateway_provider_id
|
190
|
+
row :gateway_payment_id
|
191
|
+
row :gateway_error do |x|
|
192
|
+
unless x.gateway_error.blank?
|
193
|
+
(
|
194
|
+
I18n.t("smartkiosk.gateways.#{x.gateway.keyword}.errors")[x.gateway_error] ||
|
195
|
+
I18n.t('smartkiosk.unlocalized')
|
196
|
+
) + " (#{x.gateway_error})"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
row :payment_type do |x|
|
200
|
+
I18n.t('smartkiosk.payment_types')[x.payment_type]
|
201
|
+
end
|
202
|
+
row :source do |x|
|
203
|
+
I18n.t('smartkiosk.payment_sources')[x.source]
|
204
|
+
end
|
205
|
+
row :corrected_payment
|
206
|
+
row :corrected_by
|
207
|
+
end
|
208
|
+
|
209
|
+
active_admin_comments
|
210
|
+
end
|
211
|
+
|
212
|
+
#
|
213
|
+
# FORM
|
214
|
+
#
|
215
|
+
form do |f|
|
216
|
+
f.semantic_errors
|
217
|
+
f.inputs do
|
218
|
+
f.input :user_id, :as => :hidden, :input_html => {:value => current_user.id}
|
219
|
+
f.input :corrected_payment_id, :as => :string, :input_html => { :id => 'cpi' }
|
220
|
+
f.input :gateway, :collection => Gateway.enabled, :input_html => {
|
221
|
+
:class => 'chosen',
|
222
|
+
:onchange => "location.href = '/admin/payments/new?payment[gateway_id]='+$(this).val()+'&payment[corrected_payment_id]='+$('#cpi').val()"
|
223
|
+
}
|
224
|
+
if payment.gateway.blank?
|
225
|
+
f.form_buffers.last << content_tag(:li, I18n.t('smartkiosk.admin.messages.payments.choose_gateway'))
|
226
|
+
elsif payment.gateway.providers.count < 1
|
227
|
+
f.form_buffers.last << content_tag(:li, I18n.t('smartkiosk.admin.messages.payments.no_providers'))
|
228
|
+
else
|
229
|
+
f.input :provider, :input_html => {:class => 'chosen'}, :collection => payment.gateway.providers
|
230
|
+
f.input :gateway_provider_id
|
231
|
+
f.input :account
|
232
|
+
f.input :human_fields, :as => :text, :hint => "foo=bar<br/>bar=baz".html_safe
|
233
|
+
f.input :enrolled_amount, :required => true
|
234
|
+
f.input :commission_amount, :required => true
|
235
|
+
end
|
236
|
+
|
237
|
+
f.form_buffers.last
|
238
|
+
end
|
239
|
+
|
240
|
+
if !payment.gateway.blank? && payment.gateway.providers.count > 0
|
241
|
+
f.actions
|
242
|
+
end
|
243
|
+
|
244
|
+
f.form_buffers.last
|
245
|
+
end
|
246
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
ActiveAdmin.register ProviderGroup do
|
2
|
+
menu :parent => I18n.t('activerecord.models.provider.other'),
|
3
|
+
:if => proc { can? :index, ProviderGroup },
|
4
|
+
:priority => 2
|
5
|
+
|
6
|
+
#
|
7
|
+
# INDEX
|
8
|
+
#
|
9
|
+
filter :id
|
10
|
+
filter :title
|
11
|
+
filter :provider_group, :input_html => { :class => 'chosen' }
|
12
|
+
|
13
|
+
index do
|
14
|
+
selectable_column
|
15
|
+
column :id do |x|
|
16
|
+
link_to x.id, [:admin, x]
|
17
|
+
end
|
18
|
+
column :icon do |x|
|
19
|
+
image_tag(x.icon.url(:thumb)) unless x.icon.blank?
|
20
|
+
end
|
21
|
+
column :title
|
22
|
+
column :provider_group
|
23
|
+
column :created_at
|
24
|
+
column :updated_at
|
25
|
+
default_actions
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# SHOW
|
30
|
+
#
|
31
|
+
show do |provider_group|
|
32
|
+
attributes_table do
|
33
|
+
row :id
|
34
|
+
row :title
|
35
|
+
row :icon do
|
36
|
+
image_tag(provider_group.icon) unless provider_group.icon.blank?
|
37
|
+
end
|
38
|
+
row :provider_group
|
39
|
+
row :created_at
|
40
|
+
row :updated_at
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# FORM
|
46
|
+
#
|
47
|
+
form do |f|
|
48
|
+
f.inputs do
|
49
|
+
f.input :title
|
50
|
+
f.input :provider_group, :input_html => { :class => 'chosen' },
|
51
|
+
:collection => ProviderGroup.tree(f.object)
|
52
|
+
f.input :icon, :hint => (
|
53
|
+
unless provider_group.icon.blank?
|
54
|
+
f.template.image_tag(provider_group.icon).html_safe
|
55
|
+
end
|
56
|
+
)
|
57
|
+
end
|
58
|
+
f.actions
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
ActiveAdmin.register ProviderProfile do
|
2
|
+
menu :parent => I18n.t('activerecord.models.provider.other'),
|
3
|
+
:if => proc { can? :index, ProviderProfile },
|
4
|
+
:priority => 3
|
5
|
+
|
6
|
+
filter :providers_id, :as => 'multiple_select', :input_html => { :class => 'chosen' },
|
7
|
+
:collection => proc { Provider.rmap }
|
8
|
+
filter :title
|
9
|
+
filter :created_at
|
10
|
+
filter :updated_at
|
11
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
ActiveAdmin.register ProviderReceiptTemplate do
|
2
|
+
|
3
|
+
menu :parent => I18n.t('activerecord.models.provider.other'),
|
4
|
+
:if => proc { can? :index, Gateway }
|
5
|
+
|
6
|
+
|
7
|
+
controller do
|
8
|
+
before_filter(:only => :new) do
|
9
|
+
@provider_receipt_template = ProviderReceiptTemplate.sample
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# INDEX
|
15
|
+
#
|
16
|
+
filter :providers_id, :as => 'multiple_select', :input_html => { :class => 'chosen' }
|
17
|
+
filter :created_at
|
18
|
+
filter :updated_at
|
19
|
+
|
20
|
+
index do
|
21
|
+
selectable_column
|
22
|
+
column :id
|
23
|
+
column :providers do |x|
|
24
|
+
x.title
|
25
|
+
end
|
26
|
+
column :created_at
|
27
|
+
column :updated_at
|
28
|
+
default_actions
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# SHOW
|
33
|
+
#
|
34
|
+
show do |rt|
|
35
|
+
attributes_table do
|
36
|
+
row :providers do |x|
|
37
|
+
x.title
|
38
|
+
end
|
39
|
+
row :template do
|
40
|
+
pre rt.template
|
41
|
+
end
|
42
|
+
row :updated_at
|
43
|
+
end
|
44
|
+
|
45
|
+
active_admin_comments
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# FORM
|
50
|
+
#
|
51
|
+
form do |f|
|
52
|
+
f.inputs do
|
53
|
+
unless f.object.system?
|
54
|
+
f.input :providers, :collection => Provider.rmap, :input_html => {
|
55
|
+
:class => 'chosen',
|
56
|
+
:'data-placeholder' => I18n.t('active_admin.filters.multiple_select.placeholder'),
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
f.input :template, :input_html => {
|
61
|
+
:style => 'font-family: Consolas, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace'
|
62
|
+
}
|
63
|
+
f.form_buffers.last << Arbre::Context.new do
|
64
|
+
table(:class => 'hint') do
|
65
|
+
tr do
|
66
|
+
ProviderReceiptTemplate.entities.each do |entity, fields|
|
67
|
+
td(:style => 'white-space: nowrap') do
|
68
|
+
fields.each do |field|
|
69
|
+
para do
|
70
|
+
strong "#{entity}_#{field}:"
|
71
|
+
span I18n.t("activerecord.attributes.#{entity}.#{field}")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end.to_s
|
79
|
+
end
|
80
|
+
f.actions
|
81
|
+
end
|
82
|
+
end
|