smartkiosk-server 0.11.7 → 0.11.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,7 +17,7 @@ ActiveAdmin.register ReportResult do
17
17
 
18
18
  result.each do |r|
19
19
  row = []
20
- fields.each{|f| row << r[f]}
20
+ fields.each{|f| row << report_result.human_field_value(f, r[f])}
21
21
  ws.add_row row
22
22
  end
23
23
  end
@@ -56,7 +56,7 @@ ActiveAdmin.register ReportResult do
56
56
  result.each do |row|
57
57
  tr do
58
58
  fields.each do |field|
59
- td row[field]
59
+ td report_result.human_field_value(field, row[field])
60
60
  end
61
61
  end
62
62
  end
data/app/admin/reports.rb CHANGED
@@ -120,7 +120,7 @@ ActiveAdmin.register Report do
120
120
  result.data.each do |row|
121
121
  tr do
122
122
  fields.each do |field|
123
- td row[field]
123
+ td result.human_field_value(field, row[field])
124
124
  end
125
125
  end
126
126
  end
@@ -1,6 +1,8 @@
1
1
  class Gateway < ActiveRecord::Base
2
+ include Redis::Objects::RMap
2
3
 
3
4
  has_paper_trail
5
+ has_rmap({:id => lambda{|x| x.to_s}}, :title)
4
6
 
5
7
  #
6
8
  # RELATIONS
@@ -17,4 +17,12 @@ class ReportResult < ActiveRecord::Base
17
17
  report_template.human_calculation_name field
18
18
  end
19
19
  end
20
+
21
+ def human_field_value(field, value)
22
+ if field.starts_with?('_')
23
+ report_template.report_builder.human_field_value(report.decode_field(field), value)
24
+ else
25
+ value
26
+ end
27
+ end
20
28
  end
@@ -170,6 +170,12 @@ class PaymentsReport < ReportBuilder::Base
170
170
  }
171
171
  end
172
172
 
173
+ def field_localizations
174
+ {
175
+ 'payment.state' => proc{|x| I18n.t("smartkiosk.payment_states.#{x}")}
176
+ }
177
+ end
178
+
173
179
  def calculations
174
180
  {
175
181
  :quantity => lambda{|q, t| t.groupping.blank? ? q : q.project('COUNT(*) AS "quantity"') },
@@ -183,7 +189,10 @@ class PaymentsReport < ReportBuilder::Base
183
189
  {
184
190
  'payment.state' => proc { I18n.t('smartkiosk.payment_states') },
185
191
  'payment.payment_type' => proc { I18n.t('smartkiosk.payment_types') },
186
- 'payment.provider_id' => proc { Provider.rmap.invert }
192
+ 'payment.provider_id' => proc { Provider.rmap.invert },
193
+ 'payment.agent_id' => proc { Agent.rmap.invert },
194
+ 'payment.terminal_id' => proc { Terminal.rmap.invert },
195
+ 'payment.gateway_id' => proc { Gateway.rmap.invert }
187
196
  }
188
197
  end
189
198
  end
@@ -24,6 +24,9 @@ ru:
24
24
  state: Состояние
25
25
  payment_type: Тип
26
26
  provider_id: Получатели
27
+ agent_id: Агенты
28
+ terminal_id: Терминалы
29
+ gateway_id: Шлюзы
27
30
  terminals:
28
31
  calculations:
29
32
  quantity: Количество
@@ -95,6 +95,15 @@ module ReportBuilder
95
95
  title.join(': ')
96
96
  end
97
97
 
98
+ def human_field_value(field, value)
99
+ return value unless respond_to?(:field_localizations)
100
+
101
+ @localizations ||= field_localizations
102
+ return value unless @localizations[field]
103
+
104
+ @localizations[field].call(value)
105
+ end
106
+
98
107
  def human_calculation_name(field)
99
108
  I18n.t "smartkiosk.reports.data.#{keyword}.calculations.#{field}"
100
109
  end
@@ -1,5 +1,5 @@
1
1
  module Smartkiosk
2
2
  module Server
3
- VERSION = '0.11.7'
3
+ VERSION = '0.11.8'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartkiosk-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.7
4
+ version: 0.11.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -333,7 +333,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
333
333
  version: '0'
334
334
  segments:
335
335
  - 0
336
- hash: -3103762174964566922
336
+ hash: 2701655485329085281
337
337
  required_rubygems_version: !ruby/object:Gem::Requirement
338
338
  none: false
339
339
  requirements: