gera 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +674 -0
  3. data/README.md +67 -0
  4. data/Rakefile +43 -0
  5. data/app/assets/config/gera_manifest.js +2 -0
  6. data/app/assets/javascripts/gera/application.js +14 -0
  7. data/app/assets/stylesheets/gera/application.css +15 -0
  8. data/app/authorizers/gera/application_authorizer.rb +6 -0
  9. data/app/authorizers/gera/currency_rate_authorizer.rb +9 -0
  10. data/app/authorizers/gera/currency_rate_mode_authorizer.rb +7 -0
  11. data/app/authorizers/gera/direction_rate_authorizer.rb +8 -0
  12. data/app/authorizers/gera/exchange_rate_authorizer.rb +8 -0
  13. data/app/authorizers/gera/payment_system_authorizer.rb +13 -0
  14. data/app/authorizers/gera/rate_source_authorizer.rb +7 -0
  15. data/app/controllers/gera/application_controller.rb +30 -0
  16. data/app/controllers/gera/currencies_controller.rb +8 -0
  17. data/app/controllers/gera/currency_rate_history_intervals_controller.rb +53 -0
  18. data/app/controllers/gera/currency_rate_mode_snapshots_controller.rb +83 -0
  19. data/app/controllers/gera/currency_rate_modes_controller.rb +60 -0
  20. data/app/controllers/gera/currency_rates_controller.rb +70 -0
  21. data/app/controllers/gera/direction_rate_history_intervals_controller.rb +62 -0
  22. data/app/controllers/gera/direction_rates_controller.rb +28 -0
  23. data/app/controllers/gera/exchange_rates_controller.rb +25 -0
  24. data/app/controllers/gera/external_rate_snapshots_controller.rb +35 -0
  25. data/app/controllers/gera/external_rates_controller.rb +28 -0
  26. data/app/controllers/gera/payment_systems_controller.rb +78 -0
  27. data/app/controllers/gera/rate_sources_controller.rb +8 -0
  28. data/app/decorators/gera/currency_rate_decorator.rb +148 -0
  29. data/app/decorators/gera/direction_rate_decorator.rb +47 -0
  30. data/app/decorators/gera/payment_system_decorator.rb +19 -0
  31. data/app/helpers/gera/application_helper.rb +110 -0
  32. data/app/helpers/gera/currency_rate_helper.rb +19 -0
  33. data/app/helpers/gera/currency_rate_modes_helper.rb +73 -0
  34. data/app/helpers/gera/direction_rate_helper.rb +36 -0
  35. data/app/helpers/gera/exchange_rates_helper.rb +21 -0
  36. data/app/jobs/gera/application_job.rb +6 -0
  37. data/app/models/concerns/gera/currency_pair_generator.rb +14 -0
  38. data/app/models/concerns/gera/currency_pair_support.rb +42 -0
  39. data/app/models/concerns/gera/currency_rate_mode_builder_support.rb +35 -0
  40. data/app/models/concerns/gera/direction_support.rb +14 -0
  41. data/app/models/concerns/gera/history_interval_concern.rb +46 -0
  42. data/app/models/gera/application_record.rb +8 -0
  43. data/app/models/gera/cbr_external_rate.rb +13 -0
  44. data/app/models/gera/cross_rate_mode.rb +13 -0
  45. data/app/models/gera/currency_rate.rb +78 -0
  46. data/app/models/gera/currency_rate_history_interval.rb +25 -0
  47. data/app/models/gera/currency_rate_history_interval_filter.rb +30 -0
  48. data/app/models/gera/currency_rate_mode.rb +20 -0
  49. data/app/models/gera/currency_rate_mode_snapshot.rb +26 -0
  50. data/app/models/gera/currency_rate_snapshot.rb +12 -0
  51. data/app/models/gera/direction.rb +44 -0
  52. data/app/models/gera/direction_rate.rb +136 -0
  53. data/app/models/gera/direction_rate_history_interval.rb +33 -0
  54. data/app/models/gera/direction_rate_history_interval_filter.rb +30 -0
  55. data/app/models/gera/direction_rate_snapshot.rb +7 -0
  56. data/app/models/gera/exchange_rate.rb +130 -0
  57. data/app/models/gera/external_rate.rb +38 -0
  58. data/app/models/gera/external_rate_snapshot.rb +20 -0
  59. data/app/models/gera/payment_system.rb +98 -0
  60. data/app/models/gera/rate_source.rb +77 -0
  61. data/app/models/gera/rate_source_auto.rb +25 -0
  62. data/app/models/gera/rate_source_bitfinex.rb +9 -0
  63. data/app/models/gera/rate_source_cbr.rb +13 -0
  64. data/app/models/gera/rate_source_cbr_avg.rb +6 -0
  65. data/app/models/gera/rate_source_exmo.rb +9 -0
  66. data/app/models/gera/rate_source_manual.rb +13 -0
  67. data/app/views/application/_exchange_rate_monitor.slim +1 -0
  68. data/app/views/gera/application/_attributes_table.slim +5 -0
  69. data/app/views/gera/application/_currencies_table.slim +18 -0
  70. data/app/views/gera/application/_currency_rate_mode_snapshots.slim +6 -0
  71. data/app/views/gera/application/_direction_rate.slim +6 -0
  72. data/app/views/gera/application/_directions_submenu.slim +11 -0
  73. data/app/views/gera/application/_directions_table.slim +15 -0
  74. data/app/views/gera/application/_exchange_rate.slim +6 -0
  75. data/app/views/gera/application/_external_rate.slim +6 -0
  76. data/app/views/gera/application/_header.slim +12 -0
  77. data/app/views/gera/application/_table.slim +28 -0
  78. data/app/views/gera/application/_topnav.slim +21 -0
  79. data/app/views/gera/application/direction_details.slim +75 -0
  80. data/app/views/gera/application/page.html.slim +1 -0
  81. data/app/views/gera/currencies/index.html.slim +20 -0
  82. data/app/views/gera/currency_rate_history_intervals/_filter.slim +11 -0
  83. data/app/views/gera/currency_rate_history_intervals/index.slim +39 -0
  84. data/app/views/gera/currency_rate_mode_snapshots/_snapshot.slim +20 -0
  85. data/app/views/gera/currency_rate_mode_snapshots/edit.html.slim +30 -0
  86. data/app/views/gera/currency_rate_modes/_cross_rate_mode_fields.slim +21 -0
  87. data/app/views/gera/currency_rate_modes/_currency_rate_mode.slim +7 -0
  88. data/app/views/gera/currency_rate_modes/_form.slim +29 -0
  89. data/app/views/gera/currency_rate_modes/edit.slim +11 -0
  90. data/app/views/gera/currency_rate_modes/index.html.slim +12 -0
  91. data/app/views/gera/currency_rates/_currency_rate.slim +22 -0
  92. data/app/views/gera/currency_rates/_currency_rate_humanized.slim +35 -0
  93. data/app/views/gera/currency_rates/diff.slim +12 -0
  94. data/app/views/gera/currency_rates/index.slim +27 -0
  95. data/app/views/gera/currency_rates/modes.slim +14 -0
  96. data/app/views/gera/currency_rates/show.slim +4 -0
  97. data/app/views/gera/direction_rate_history_intervals/_filter.slim +11 -0
  98. data/app/views/gera/direction_rate_history_intervals/index.slim +41 -0
  99. data/app/views/gera/direction_rates/_direction_rate_example_calculator.slim +28 -0
  100. data/app/views/gera/direction_rates/diff.slim +19 -0
  101. data/app/views/gera/direction_rates/index.slim +26 -0
  102. data/app/views/gera/direction_rates/legacy.html.slim +5 -0
  103. data/app/views/gera/direction_rates/minimals.slim +5 -0
  104. data/app/views/gera/direction_rates/show.slim +14 -0
  105. data/app/views/gera/external_rate_snapshots/index.slim +25 -0
  106. data/app/views/gera/external_rate_snapshots/show.slim +22 -0
  107. data/app/views/gera/external_rates/_flat_list.slim +22 -0
  108. data/app/views/gera/external_rates/index.html.slim +28 -0
  109. data/app/views/gera/external_rates/show.slim +1 -0
  110. data/app/views/gera/payment_systems/_fields.slim +4 -0
  111. data/app/views/gera/payment_systems/_fields_table.slim +18 -0
  112. data/app/views/gera/payment_systems/_form.slim +9 -0
  113. data/app/views/gera/payment_systems/edit.slim +7 -0
  114. data/app/views/gera/payment_systems/index.slim +3 -0
  115. data/app/views/gera/payment_systems/new.slim +9 -0
  116. data/app/views/gera/payment_systems/show.slim +1 -0
  117. data/app/views/gera/rate_sources/_list.slim +13 -0
  118. data/app/views/gera/rate_sources/_rate_source.slim +23 -0
  119. data/app/views/gera/rate_sources/index.html.slim +6 -0
  120. data/app/views/layouts/application.html.slim +15 -0
  121. data/app/views/layouts/gera/blank.html.slim +10 -0
  122. data/app/workers/concerns/gera/rates_worker.rb +87 -0
  123. data/app/workers/gera/bitfinex_rates_worker.rb +65 -0
  124. data/app/workers/gera/cbr_avg_rates_worker.rb +42 -0
  125. data/app/workers/gera/cbr_rates_worker.rb +192 -0
  126. data/app/workers/gera/create_history_intervals_worker.rb +38 -0
  127. data/app/workers/gera/currency_rates_worker.rb +64 -0
  128. data/app/workers/gera/directions_rates_worker.rb +51 -0
  129. data/app/workers/gera/exmo_rates_worker.rb +62 -0
  130. data/app/workers/gera/purge_currency_rates_worker.rb +21 -0
  131. data/app/workers/gera/purge_direction_rates_worker.rb +30 -0
  132. data/config/currencies.yml +559 -0
  133. data/config/routes.rb +30 -0
  134. data/db/migrate/20180912130000_setup.rb +228 -0
  135. data/db/migrate/20190314114844_add_is_available_to_payment_systems.rb +7 -0
  136. data/db/migrate/20190315113046_add_icon_url_to_payment_systems.rb +7 -0
  137. data/db/migrate/20190315132137_add_commission_to_payment_systems.rb +7 -0
  138. data/lib/banks/currency_exchange.rb +12 -0
  139. data/lib/builders/currency_rate_auto_builder.rb +38 -0
  140. data/lib/builders/currency_rate_builder.rb +60 -0
  141. data/lib/builders/currency_rate_cross_builder.rb +70 -0
  142. data/lib/builders/currency_rate_direct_builder.rb +26 -0
  143. data/lib/gera.rb +32 -0
  144. data/lib/gera/bitfinex_fetcher.rb +36 -0
  145. data/lib/gera/configuration.rb +47 -0
  146. data/lib/gera/currencies_purger.rb +28 -0
  147. data/lib/gera/currency_pair.rb +93 -0
  148. data/lib/gera/engine.rb +14 -0
  149. data/lib/gera/mathematic.rb +156 -0
  150. data/lib/gera/money_support.rb +89 -0
  151. data/lib/gera/numeric.rb +25 -0
  152. data/lib/gera/railtie.rb +8 -0
  153. data/lib/gera/rate.rb +22 -0
  154. data/lib/gera/rate_from_multiplicator.rb +54 -0
  155. data/lib/gera/repositories/currency_rate_modes_repository.rb +37 -0
  156. data/lib/gera/repositories/currency_rates_repository.rb +25 -0
  157. data/lib/gera/repositories/direction_rates_repository.rb +46 -0
  158. data/lib/gera/repositories/exchange_rates_repository.rb +23 -0
  159. data/lib/gera/repositories/payment_systems_repository.rb +21 -0
  160. data/lib/gera/repositories/universe.rb +47 -0
  161. data/lib/gera/version.rb +3 -0
  162. data/lib/tasks/auto_generate_diagram.rake +6 -0
  163. data/lib/tasks/gera_tasks.rake +4 -0
  164. metadata +765 -0
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gera
4
+ class RateSourceBitfinex < RateSource
5
+ def self.supported_currencies
6
+ %i[NEO BTC ETH EUR USD].map { |m| Money::Currency.find! m }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gera
4
+ class RateSourceCBR < RateSource
5
+ def self.supported_currencies
6
+ %i[RUB KZT USD EUR UAH].map { |m| Money::Currency.find! m }
7
+ end
8
+
9
+ def self.available_pairs
10
+ ['KZT/RUB', 'USD/RUB', 'EUR/RUB', 'UAH/RUB'].map { |cp| Gera::CurrencyPair.new cp }.freeze
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gera
4
+ class RateSourceCBRAvg < RateSourceCBR
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gera
4
+ class RateSourceEXMO < RateSource
5
+ def self.supported_currencies
6
+ %i[BTC BCH DSH ETH ETC LTC XRP XMR USD RUB ZEC EUR USDT NEO EOS ADA XEM WAVES TRX DOGE].map { |m| Money::Currency.find! m }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gera
4
+ class RateSourceManual < RateSource
5
+ def self.supported_currencies
6
+ Money::Currency.all
7
+ end
8
+
9
+ def self.available_pairs
10
+ CurrencyPair.all
11
+ end
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ pre rate monitor (replace) for exchange_rate #{exchange_rate_id}
@@ -0,0 +1,5 @@
1
+ table.table.table-condensed.table-narrow
2
+ - columns.each do |column|
3
+ tr
4
+ th= object.class.attribute_title column
5
+ td= object.send column
@@ -0,0 +1,18 @@
1
+ - currencies ||= Money::Currency.all
2
+ - min_width ||= 80
3
+
4
+ .table-sticky-container
5
+ table.table.table-condensed.table-narrow.text-right.table-cross
6
+ thead.bg-white
7
+ tr
8
+ th.text-center colspan=currencies.count+1 Отдаем &rarr;
9
+ tr
10
+ th.text-nowrap Получаем &darr;
11
+ - currencies.each do |cur|
12
+ th.text-right style="min-width: #{min_width}px"= cur
13
+ tbody
14
+ - currencies.each do |cur2|
15
+ tr
16
+ th.text-right= cur2
17
+ - currencies.each do |cur1|
18
+ = yield Gera::CurrencyPair.new cur2, cur1
@@ -0,0 +1,6 @@
1
+ = link_to 'Создать новый', currency_rate_mode_snapshots_path, method: :post, class: 'btn btn-success'
2
+ ul.nav.nav-pills.nav-stacked.m-t-lg
3
+ - Gera::CurrencyRateModeSnapshot.ordered.each do |crms|
4
+ = active_link_to currency_rate_mode_snapshot_path(crms), wrap_tag: :li, active: current_snapshot == crms do
5
+ = crms.title
6
+ span.m-l-md= crms_status_label crms.status
@@ -0,0 +1,6 @@
1
+ - object = Gera::DirectionRateDecorator.decorate (direction_rate)
2
+
3
+ h2= t '.title', id: direction_rate.id
4
+ - columns = %i(direction inverse_direction created_at base_rate_value rate_percent ps_comission rate_value)
5
+
6
+ = render 'attributes_table', object: object, columns: columns
@@ -0,0 +1,11 @@
1
+ h1.m-b-md Управление обменом
2
+ hr
3
+ ul.nav.nav-tabs
4
+ -# TODO
5
+ -# = active_link_to 'Управление обменом', operator_exchange_managers_url, wrap_tag: :li
6
+ - if Gera::DirectionRate.readable_by? current_user
7
+ = active_link_to 'Конечные курсы', direction_rates_url, wrap_tag: :li, active: controller_name == 'direction_rates' && action_name == 'index'
8
+
9
+ -# TODO minimals
10
+ /- if Gera::DirectionRate.readable_by? current_user
11
+ /= active_link_to 'Минималки', minimals_direction_rates_url, wrap_tag: :li, active: controller_name == 'direction_rates' && action_name == 'minimals'
@@ -0,0 +1,15 @@
1
+ .container-scrollable
2
+ .table-sticky-container
3
+ table.table-condensed.table-comission.table-cross.table-bordered.table-directions
4
+ thead.bg-white
5
+ tr
6
+ th
7
+ - payment_systems.each do |ps_to|
8
+ th.text-center title="(#{ps_to.id}) #{ps_to.name}"
9
+ = ps_icon ps_to
10
+ tbody
11
+ - payment_systems.each do |ps_from|
12
+ tr
13
+ th.text-center title="(#{ps_from.id}) #{ps_from.name}"= ps_icon ps_from
14
+ - payment_systems.each do |ps_to|
15
+ = yield Gera::Direction.new(ps_from: ps_from, ps_to: ps_to).freeze
@@ -0,0 +1,6 @@
1
+ - object = ExchangeRateDecorator.decorate exchange_rate
2
+
3
+ h2 Курс направления (#{object.title})
4
+ - columns = %i(id comission_percents)
5
+
6
+ = render 'attributes_table', object: object, columns: columns
@@ -0,0 +1,6 @@
1
+ - object = ExternalRateDecorator.decorate external_rate
2
+
3
+ h2 Внешний курс (#{object.title})
4
+ - columns = %i(id snapshot created_at source sell_price buy_price)
5
+
6
+ = render 'attributes_table', object: object, columns: columns
@@ -0,0 +1,12 @@
1
+ = render 'topnav' do
2
+ = active_link_to 'Базовый курс', currency_rates_path, wrap_tag: :li
3
+ = active_link_to 'Конечный курс', direction_rates_path, wrap_tag: :li
4
+ li.dropdown
5
+ = link_to '#', class: 'dropdown-toggle', data: { toggle: :dropdown }, role: :button, 'aria-haspopup' => true, 'aria-expanded' => false do
6
+ | Настройки
7
+ .m-l-sm.span.caret
8
+ ul.dropdown-menu
9
+ = active_link_to 'Валюты', currencies_path, wrap_tag: :li
10
+ = active_link_to 'Платежные системы', payment_systems_path, wrap_tag: :li
11
+ = active_link_to 'Методы расчета', currency_rate_mode_snapshots_path, wrap_tag: :li
12
+ = active_link_to 'Источники курсов', rate_sources_path, wrap_tag: :li
@@ -0,0 +1,28 @@
1
+ - allow_edit = false unless defined? :allow_edit
2
+ - parent = nil unless defined? :parent
3
+ - if scope.empty?
4
+ p.text-info Пусто
5
+ - else
6
+ .table-sticky-container
7
+ table.table.table-condensed.table-striped.table-narrow
8
+ thead.bg-white
9
+ tr
10
+ - columns.each do |column|
11
+ th title=column
12
+ = decorator_class.attribute_title column
13
+ - if params[:show_attribute]
14
+ br
15
+ code.text-small= column
16
+ tbody
17
+ - scope.each do |record|
18
+ - decorated = decorator_class.decorate record
19
+ tr class=decorated.try(:row_class)
20
+ - columns.each do |column|
21
+ td class=(decorated.try(:column_class, column) || 'text-nowrap')
22
+ - if allow_edit && allow_edit_column?(record, column)
23
+ - value = record.send column
24
+ = smart_best_in_place [namespace, parent, decorated].compact, column, value
25
+ - else
26
+ = decorated.send column
27
+
28
+ = paginate scope if scope.respond_to? :total_pages
@@ -0,0 +1,21 @@
1
+ nav.navbar.navbar-default.navbar-fixed-top
2
+ .container-fluid
3
+ .navbar-header
4
+ button.navbar-toggle.collapsed aria-controls="navbar" aria-expanded="false" data-target="#navbar" data-toggle="collapse" type="button"
5
+ span.sr-only Toggle navigation
6
+ span.icon-bar
7
+ span.icon-bar
8
+ span.icon-bar
9
+ = link_to app_title, root_path, class: 'navbar-brand'
10
+ #navbar.collapse.navbar-collapse
11
+ ul.nav.navbar-nav
12
+ = yield
13
+
14
+ - if logged_in?
15
+ ul.nav.navbar-nav.navbar-right
16
+ li.dropdown
17
+ = link_to '#', class: 'dropdown-toggle', data: { toggle: 'dropdown' }, role: :button, 'aria-haspopup' => true, 'aria-expanded' => false do
18
+ = ion_icon :user, text: current_user.email
19
+ .m-l-sm.span.caret
20
+ ul.dropdown-menu
21
+ li= link_to t('.exit'), main_app.sessions_path, method: :delete
@@ -0,0 +1,75 @@
1
+ - ps_from = direction.ps_from
2
+ - ps_to = direction.ps_to
3
+ - exchange_rate = direction.exchange_rate
4
+ - direction_rate = direction.direction_rate
5
+ .row
6
+ .col-md-3
7
+ dl
8
+ dt Конечный курс
9
+ dd= rate_humanized_description(direction_rate.rate_value, ps_from.currency, ps_to.currency)
10
+ dt Направление
11
+ dd
12
+ = direction_with_icons direction
13
+ dt Статус
14
+ dd
15
+ - if exchange_rate.is_enabled?
16
+ .label.label-success Включено
17
+ - else
18
+ .label.label-default Отключено
19
+
20
+ /- if legacy_rate.present?
21
+ /dt В пыхе
22
+ /= rate_humanized_description(legacy_rate, ps_from.currency, ps_to.currency)
23
+
24
+ .col-md-3
25
+ dl
26
+ dt Базовый курс
27
+ dd= rate_humanized_description direction_rate.base_rate_value, ps_from.currency, ps_to.currency
28
+ dt Комиссия
29
+ dd= '%.3f%' % direction_rate.rate_percent
30
+
31
+ dt Обратный конечный курс: #{direction_with_icons direction_rate.inverse_direction_rate}
32
+ dd= rate_humanized_description(direction_rate.inverse_direction_rate.rate_value, ps_from.currency, ps_to.currency)
33
+ .col-md-3
34
+ - status = BestChangeService.new( exchange_rate: exchange_rate ).status
35
+ dt
36
+ dt На bestchange.ru
37
+ - if status.present?
38
+ dd
39
+ span.m-r-md = '%.3f%' % status.bestchange_base_percent_rate
40
+ - if status.state == BestChangeStatus::STATE_ACTUAL
41
+ span.label.label.success OK
42
+ - else
43
+ span.label.label-danger Комиссия отличается (#{status.state})
44
+ =
45
+ dt Позиция
46
+ dd= status.position + 1
47
+ dt Курс
48
+ dd= status.finite_rate
49
+ - else
50
+ dd
51
+ span.label.label-warning В списке отсутствует
52
+ .col-md-3
53
+ dl
54
+ dt Публичные резервы
55
+ dd= humanized_money_with_currency ps_to.reserve_amount
56
+
57
+ dt Минимальная сумма на обмен (расчет)
58
+ dd= humanized_money_with_currency direction_rate.minimal_income_amount
59
+
60
+ dt Максимальная сумма на обмен (расчет)
61
+ dd= humanized_money_with_currency direction_rate.maximal_income_amount
62
+
63
+ /dt Минималка на прием (#{direction.currency_from})
64
+ /dd
65
+ /= humanized_money_with_currency direction.minimal_income_amount
66
+ /span.m-l-md= "(#{humanized_money_with_currency direction.minimal_income_amount.exchange_to(direction.currency_to)})".html_safe
67
+
68
+ /dt Минималка на отдачу (#{direction.currency_to})
69
+ /dd
70
+ /= humanized_money_with_currency direction.minimal_out_amount
71
+ /span.m-l-md= "(#{humanized_money_with_currency direction.minimal_out_amount.exchange_to(direction.currency_from)})".html_safe
72
+
73
+
74
+
75
+ div.text-small.text-muted Расчет за #{l direction_rate.created_at, format: :long}, direction_rate_snapshot_id=#{Gera::Universe.direction_rates_repository.snapshot.id}
@@ -0,0 +1 @@
1
+ p= message
@@ -0,0 +1,20 @@
1
+ h1 Валюта
2
+
3
+ table.table.table-narrow.table-striped.table-condensed
4
+ thead.bg-white
5
+ tr
6
+ th Валюта
7
+ th iso number
8
+ th Локальный ID
9
+ th Минимальная сумма на ввод
10
+ th Минимальная сумма на вывод
11
+ th Знаков после запятой для хранения
12
+ th Разрешенное округление
13
+ - Money::Currency.each do |c|
14
+ tr
15
+ td= c
16
+ td= c.iso_numeric
17
+ td= c.local_id
18
+ td= c.minimal_input_value.format
19
+ td= c.minimal_output_value.format
20
+ td= c.decimal_places
@@ -0,0 +1,11 @@
1
+ = simple_form_for filter, url: currency_rate_history_intervals_path, method: :GET do |f|
2
+ .row
3
+ .col-md-3
4
+ = f.input :cur_from, collection: currencies_enum, include_blank: false, label: false, hint: 'Входящая валюты'
5
+ .col-md-3
6
+ = f.input :cur_to, collection: currencies_enum, include_blank: false, label: false, hint: 'Исходящая валюта'
7
+ .col-md-3
8
+ = f.input :value_type, collection: [['Значение курса','rate']], include_blank: false, label: false, hint: 'Что смотрим?'
9
+ .col-md-3
10
+ = f.button :submit, 'Обновить', class: 'btn btn-primary'
11
+
@@ -0,0 +1,39 @@
1
+ = render 'filter'
2
+
3
+ #container style="height: 400px; min-width: 310px"
4
+
5
+ = javascript_include_tag 'https://code.highcharts.com/stock/highstock.js'
6
+ = javascript_include_tag 'https://code.highcharts.com/stock/modules/exporting.js'
7
+
8
+ javascript:
9
+ $.getJSON('#{currency_rate_history_intervals_path(format: :json, currency_rate_history_interval_filter: filter.to_param)}', function (data) {
10
+ // create the chart
11
+ Highcharts.stockChart('container', {
12
+ rangeSelector: {
13
+ buttons: [{
14
+ type: 'hour',
15
+ count: 1,
16
+ text: '1ч'
17
+ }, {
18
+ type: 'day',
19
+ count: 1,
20
+ text: '1д'
21
+ }, {
22
+ type: 'all',
23
+ count: 1,
24
+ text: 'Всё'
25
+ }],
26
+ selected: 1,
27
+ inputEnabled: false
28
+ },
29
+
30
+ series: [{
31
+ name: 'Базовый курс',
32
+ type: 'candlestick',
33
+ data: data,
34
+ tooltip: {
35
+ valueDecimals: #{value_decimals}
36
+ }
37
+ }]
38
+ });
39
+ });
@@ -0,0 +1,20 @@
1
+ = render layout: 'currencies_table', locals: { min_width: 50 } do |pair|
2
+ - currency_rate_mode = snapshot.currency_rate_modes.find_by_currency_pair(pair) || snapshot.currency_rate_modes.build(currency_pair: pair)
3
+ td.rate-popover data=crms_cell_data_attr(currency_rate_mode) class=(currency_rate_mode.build_result.error? ? 'text-danger' : '')
4
+ - if currency_rate_mode.currency_pair.same?
5
+ .text-muted 1
6
+ - elsif currency_rate_mode.persisted?
7
+ - if view_mode == :calculations
8
+ - if currency_rate_mode.build_result.error?
9
+ .text-danger= currency_rate_mode.build_result.error
10
+ - else
11
+ - buffer = currency_rate_mode_detailed(currency_rate_mode.build_result.currency_rate).html_safe
12
+ - if currency_rate_mode.mode_auto?
13
+ .text-success
14
+ = buffer
15
+ - else
16
+ = buffer
17
+ - else
18
+ = render currency_rate_mode
19
+ - else
20
+ | авто
@@ -0,0 +1,30 @@
1
+ .row
2
+ .col-md-10
3
+ .row.m-b-md
4
+ .col-md-6
5
+ h2
6
+ | Матрица методов расчета
7
+
8
+ p Название:
9
+ = best_in_place snapshot, :title
10
+ hr
11
+ p Описание:
12
+ = best_in_place snapshot, :details
13
+ .col-md-3
14
+ = crms_status_label snapshot.status
15
+ .col-md-3
16
+ - unless snapshot.status_active?
17
+ = link_to 'Активировать', activate_currency_rate_mode_snapshot_path(snapshot), method: :post, class: 'btn btn-primary'
18
+
19
+ ul.nav.nav-tabs
20
+ = active_link_to 'Режимы', url_for(view_mode: :methods), wrap_tag: :li, active: view_mode == :methods
21
+ = active_link_to 'Расчеты', url_for(view_mode: :calculations), wrap_tag: :li, active: view_mode == :calculations
22
+
23
+ = render 'snapshot', snapshot: snapshot
24
+ .col-md-2
25
+ = render 'currency_rate_mode_snapshots', current_snapshot: snapshot
26
+ ul
27
+ - if view_mode == :calculations
28
+ li.text-success Зеленым цветом автоматический расчет
29
+ li.text-muted Создан: #{l snapshot.created_at, format: :long}
30
+ li.text-muted Изменен: #{l snapshot.updated_at, format: :long}
@@ -0,0 +1,21 @@
1
+ .nested-fields
2
+ .row
3
+ .col-md-3
4
+ = f.input "cur_from",
5
+ collection: currencies_enum,
6
+ label: 'Вход',
7
+ include_blank: false
8
+ .col-md-3
9
+ = f.input "cur_to",
10
+ collection: currencies_enum,
11
+ label: 'Выход',
12
+ include_blank: false
13
+
14
+ .col-md-3
15
+ = f.input "rate_source_id",
16
+ collection: Gera::RateSource.all,
17
+ label: 'Из источника',
18
+ include_blank: 'Авто'
19
+
20
+ .col-md-3
21
+ = link_to_remove_association "Удалить", f, class: 'btn btn-sm btn-danger'