kaui 2.0.4 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (276) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +8 -23
  3. data/Rakefile +4 -2
  4. data/app/assets/config/kaui_manifest.js +45 -0
  5. data/app/assets/javascripts/jquery.spin.js +76 -0
  6. data/app/assets/javascripts/kaui/kaui.js +76 -0
  7. data/app/assets/javascripts/kaui_application.js +25 -0
  8. data/app/assets/javascripts/spin.js +76 -0
  9. data/app/assets/stylesheets/bootstrap_and_overrides.scss +240 -0
  10. data/app/assets/stylesheets/kaui/{account.less → account.scss} +13 -1
  11. data/app/assets/stylesheets/kaui/{audit.less → audit.scss} +5 -1
  12. data/app/assets/stylesheets/kaui/{common.less → common.scss} +19 -17
  13. data/app/assets/stylesheets/kaui/{datatable.less → datatable.scss} +6 -3
  14. data/app/assets/stylesheets/kaui/{header.less → header.scss} +16 -12
  15. data/app/assets/stylesheets/kaui/{home.less → home.scss} +7 -4
  16. data/app/assets/stylesheets/kaui/{invoice.less → invoice.scss} +7 -3
  17. data/app/assets/stylesheets/kaui/kaui.scss +265 -0
  18. data/app/assets/stylesheets/kaui/kaui_bootstrap.scss +3 -0
  19. data/app/assets/stylesheets/kaui/{overdue.less → overdue.scss} +3 -1
  20. data/app/assets/stylesheets/kaui/{payment.less → payment.scss} +3 -0
  21. data/app/assets/stylesheets/kaui/{subscription.less → subscription.scss} +4 -1
  22. data/app/assets/stylesheets/kaui/{tags.less → tags.scss} +9 -5
  23. data/app/assets/stylesheets/kaui/timeline.scss +7 -0
  24. data/app/assets/stylesheets/kaui/tooltip.scss +15 -0
  25. data/app/controllers/kaui/account_children_controller.rb +25 -28
  26. data/app/controllers/kaui/account_custom_fields_controller.rb +16 -15
  27. data/app/controllers/kaui/account_emails_controller.rb +28 -25
  28. data/app/controllers/kaui/account_tags_controller.rb +37 -34
  29. data/app/controllers/kaui/account_timelines_controller.rb +38 -33
  30. data/app/controllers/kaui/accounts_controller.rb +269 -255
  31. data/app/controllers/kaui/admin_allowed_users_controller.rb +105 -99
  32. data/app/controllers/kaui/admin_controller.rb +32 -31
  33. data/app/controllers/kaui/admin_tenants_controller.rb +434 -388
  34. data/app/controllers/kaui/audit_logs_controller.rb +87 -84
  35. data/app/controllers/kaui/bundle_tags_controller.rb +24 -20
  36. data/app/controllers/kaui/bundles_controller.rb +96 -82
  37. data/app/controllers/kaui/chargebacks_controller.rb +36 -33
  38. data/app/controllers/kaui/charges_controller.rb +23 -20
  39. data/app/controllers/kaui/credits_controller.rb +28 -25
  40. data/app/controllers/kaui/custom_fields_controller.rb +172 -38
  41. data/app/controllers/kaui/engine_controller.rb +2 -1
  42. data/app/controllers/kaui/engine_controller_util.rb +134 -114
  43. data/app/controllers/kaui/home_controller.rb +230 -217
  44. data/app/controllers/kaui/invoice_items_controller.rb +43 -39
  45. data/app/controllers/kaui/invoice_tags_controller.rb +32 -0
  46. data/app/controllers/kaui/invoices_controller.rb +134 -88
  47. data/app/controllers/kaui/login_proxy_controller.rb +2 -1
  48. data/app/controllers/kaui/payment_methods_controller.rb +103 -90
  49. data/app/controllers/kaui/payments_controller.rb +95 -92
  50. data/app/controllers/kaui/queues_controller.rb +47 -14
  51. data/app/controllers/kaui/refunds_controller.rb +36 -33
  52. data/app/controllers/kaui/registrations_controller.rb +7 -7
  53. data/app/controllers/kaui/role_definitions_controller.rb +17 -14
  54. data/app/controllers/kaui/sessions_controller.rb +7 -4
  55. data/app/controllers/kaui/subscriptions_controller.rb +197 -187
  56. data/app/controllers/kaui/tag_definitions_controller.rb +28 -27
  57. data/app/controllers/kaui/tags_controller.rb +25 -22
  58. data/app/controllers/kaui/tenants_controller.rb +30 -28
  59. data/app/controllers/kaui/transactions_controller.rb +43 -38
  60. data/app/helpers/kaui/account_helper.rb +22 -12
  61. data/app/helpers/kaui/application_helper.rb +8 -3
  62. data/app/helpers/kaui/date_helper.rb +3 -2
  63. data/app/helpers/kaui/home_helper.rb +2 -0
  64. data/app/helpers/kaui/locale_helper.rb +7 -6
  65. data/app/helpers/kaui/money_helper.rb +2 -1
  66. data/app/helpers/kaui/object_helper.rb +11 -10
  67. data/app/helpers/kaui/payment_helper.rb +7 -6
  68. data/app/helpers/kaui/payment_method_helper.rb +3 -2
  69. data/app/helpers/kaui/permissions_helper.rb +9 -9
  70. data/app/helpers/kaui/plugin_helper.rb +25 -23
  71. data/app/helpers/kaui/subscription_helper.rb +27 -29
  72. data/app/helpers/kaui/us_states_helper.rb +7 -6
  73. data/app/helpers/kaui/uuid_helper.rb +8 -5
  74. data/app/models/kaui/ability.rb +19 -12
  75. data/app/models/kaui/account.rb +45 -28
  76. data/app/models/kaui/account_email.rb +23 -20
  77. data/app/models/kaui/account_timeline.rb +5 -1
  78. data/app/models/kaui/admin.rb +65 -64
  79. data/app/models/kaui/admin_tenant.rb +81 -82
  80. data/app/models/kaui/allowed_user.rb +13 -9
  81. data/app/models/kaui/allowed_user_tenant.rb +4 -2
  82. data/app/models/kaui/application_record.rb +2 -0
  83. data/app/models/kaui/audit_log.rb +6 -3
  84. data/app/models/kaui/base.rb +13 -7
  85. data/app/models/kaui/bundle.rb +41 -24
  86. data/app/models/kaui/catalog.rb +118 -113
  87. data/app/models/kaui/chargeback.rb +5 -1
  88. data/app/models/kaui/credit.rb +4 -1
  89. data/app/models/kaui/custom_field.rb +9 -6
  90. data/app/models/kaui/invoice.rb +25 -22
  91. data/app/models/kaui/invoice_item.rb +9 -6
  92. data/app/models/kaui/invoice_payment.rb +49 -54
  93. data/app/models/kaui/killbill_authenticatable.rb +14 -8
  94. data/app/models/kaui/killbill_registerable.rb +7 -0
  95. data/app/models/kaui/overdue.rb +64 -65
  96. data/app/models/kaui/payment.rb +22 -19
  97. data/app/models/kaui/payment_method.rb +48 -39
  98. data/app/models/kaui/payment_state.rb +41 -38
  99. data/app/models/kaui/rails_methods.rb +9 -9
  100. data/app/models/kaui/refund.rb +7 -1
  101. data/app/models/kaui/role_definition.rb +5 -1
  102. data/app/models/kaui/simple_plan.rb +5 -3
  103. data/app/models/kaui/subscription.rb +10 -7
  104. data/app/models/kaui/tag.rb +25 -22
  105. data/app/models/kaui/tag_definition.rb +50 -45
  106. data/app/models/kaui/tenant.rb +6 -5
  107. data/app/models/kaui/transaction.rb +43 -31
  108. data/app/models/kaui/user.rb +10 -16
  109. data/app/models/kaui/user_role.rb +8 -5
  110. data/app/views/kaui/accounts/_billing_info.html.erb +5 -1
  111. data/app/views/kaui/accounts/_form.html.erb +2 -2
  112. data/app/views/kaui/accounts/_payment_methods.html.erb +3 -0
  113. data/app/views/kaui/accounts/index.html.erb +9 -4
  114. data/app/views/kaui/admin_allowed_users/_form.html.erb +3 -3
  115. data/app/views/kaui/admin_tenants/_form_catalog_translation.erb +1 -1
  116. data/app/views/kaui/admin_tenants/_form_invoice_template.erb +1 -1
  117. data/app/views/kaui/admin_tenants/_form_invoice_translation.erb +1 -1
  118. data/app/views/kaui/admin_tenants/_form_plugin_config.erb +13 -3
  119. data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +11 -5
  120. data/app/views/kaui/admin_tenants/new_catalog.html.erb +2 -2
  121. data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +2 -2
  122. data/app/views/kaui/admin_tenants/new_plan_currency.html.erb +1 -1
  123. data/app/views/kaui/bundles/_bundle_details.html.erb +12 -0
  124. data/app/views/kaui/bundles/index.html.erb +3 -14
  125. data/app/views/kaui/bundles/transfer.html.erb +13 -5
  126. data/app/views/kaui/invoice_tags/_form.html.erb +33 -0
  127. data/app/views/kaui/invoice_tags/_form_bar.html.erb +21 -0
  128. data/app/views/kaui/invoice_tags/edit.html.erb +10 -0
  129. data/app/views/kaui/invoices/_invoice_table.html.erb +29 -8
  130. data/app/views/kaui/invoices/index.html.erb +6 -4
  131. data/app/views/kaui/invoices/show.html.erb +10 -1
  132. data/app/views/kaui/layouts/kaui_flash.html.erb +32 -1
  133. data/app/views/kaui/layouts/kaui_header.html.erb +19 -2
  134. data/app/views/kaui/payment_methods/_payment_methods_details_table.html.erb +13 -4
  135. data/app/views/kaui/payments/_payment_table.html.erb +21 -11
  136. data/app/views/kaui/payments/index.html.erb +12 -10
  137. data/app/views/kaui/queues/index.html.erb +1 -1
  138. data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +1 -4
  139. data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
  140. data/app/views/kaui/subscriptions/_form.html.erb +1 -1
  141. data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +3 -3
  142. data/app/views/kaui/subscriptions/edit_bcd.erb +1 -1
  143. data/app/views/kaui/tag_definitions/index.html.erb +2 -2
  144. data/app/views/kaui/tags/index.html.erb +1 -0
  145. data/config/initializers/bootstrap_datepicker_rails.rb +3 -0
  146. data/config/initializers/devise.rb +8 -6
  147. data/config/initializers/js_routes.rb +9 -0
  148. data/config/initializers/kilbill_client_init.rb +13 -0
  149. data/config/initializers/killbill_authenticatable.rb +71 -21
  150. data/config/initializers/killbill_registerable.rb +5 -3
  151. data/config/initializers/time_formats.rb +6 -4
  152. data/config/locales/en.yml +78 -1
  153. data/config/routes.rb +40 -32
  154. data/db/migrate/20130812155313_devise_create_kaui_users.rb +10 -8
  155. data/db/migrate/20150109214021_create_kaui_tenants.rb +10 -8
  156. data/db/migrate/20150112232813_create_kaui_allowed_users.rb +10 -8
  157. data/lib/generators/kaui/install/install_generator.rb +23 -20
  158. data/lib/generators/kaui/install/templates/config/initializers/kaui.rb +3 -1
  159. data/lib/kaui/engine.rb +17 -5
  160. data/lib/kaui/installer/installer.rb +27 -26
  161. data/lib/kaui/version.rb +3 -1
  162. data/lib/kaui.rb +74 -30
  163. data/lib/tasks/kaui_tasks.rake +1 -0
  164. metadata +145 -440
  165. data/app/assets/javascripts/application.js +0 -17
  166. data/app/assets/javascripts/kaui/bootstrap-tweaks.js +0 -172
  167. data/app/assets/stylesheets/bootstrap_and_overrides.css.less +0 -44
  168. data/app/assets/stylesheets/kaui/kaui.less +0 -21
  169. data/app/assets/stylesheets/kaui/timeline.less +0 -4
  170. data/config/initializers/asset.rb +0 -1
  171. data/config/initializers/kilbill-client-init.rb +0 -9
  172. data/db/schema.rb +0 -15
  173. data/test/dummy/README.rdoc +0 -261
  174. data/test/dummy/Rakefile +0 -7
  175. data/test/dummy/app/controllers/application_controller.rb +0 -9
  176. data/test/dummy/app/helpers/application_helper.rb +0 -2
  177. data/test/dummy/bin/bundle +0 -3
  178. data/test/dummy/bin/rails +0 -4
  179. data/test/dummy/bin/rake +0 -4
  180. data/test/dummy/bin/setup +0 -38
  181. data/test/dummy/bin/update +0 -29
  182. data/test/dummy/bin/yarn +0 -11
  183. data/test/dummy/config/application.rb +0 -18
  184. data/test/dummy/config/boot.rb +0 -3
  185. data/test/dummy/config/database.yml +0 -27
  186. data/test/dummy/config/environment.rb +0 -5
  187. data/test/dummy/config/environments/development.rb +0 -58
  188. data/test/dummy/config/environments/production.rb +0 -91
  189. data/test/dummy/config/environments/test.rb +0 -49
  190. data/test/dummy/config/initializers/application_controller_renderer.rb +0 -6
  191. data/test/dummy/config/initializers/assets.rb +0 -14
  192. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  193. data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
  194. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  195. data/test/dummy/config/initializers/inflections.rb +0 -16
  196. data/test/dummy/config/initializers/killbill_client.rb +0 -1
  197. data/test/dummy/config/initializers/mime_types.rb +0 -4
  198. data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +0 -14
  199. data/test/dummy/config/initializers/secret_token.rb +0 -7
  200. data/test/dummy/config/initializers/session_store.rb +0 -8
  201. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  202. data/test/dummy/config/locales/en.yml +0 -33
  203. data/test/dummy/config/routes.rb +0 -3
  204. data/test/dummy/config/secrets.yml +0 -32
  205. data/test/dummy/config/symmetric-encryption.yml +0 -135
  206. data/test/dummy/config.ru +0 -4
  207. data/test/dummy/db/schema.rb +0 -52
  208. data/test/dummy/public/404.html +0 -26
  209. data/test/dummy/public/422.html +0 -26
  210. data/test/dummy/public/500.html +0 -25
  211. data/test/dummy/public/favicon.ico +0 -0
  212. data/test/dummy/script/rails +0 -6
  213. data/test/fixtures/SpyCarAdvanced.xml +0 -824
  214. data/test/fixtures/catalog-v1.xml +0 -73
  215. data/test/fixtures/catalog_translation_fr-v1.properties +0 -1
  216. data/test/fixtures/invoice_template-v1.html +0 -100
  217. data/test/fixtures/invoice_translation_fr-v1.properties +0 -23
  218. data/test/fixtures/overdue-v1.xml +0 -49
  219. data/test/fixtures/stripe.yml +0 -2
  220. data/test/functional/kaui/account_children_controller_test.rb +0 -32
  221. data/test/functional/kaui/account_custom_fields_controller_test.rb +0 -29
  222. data/test/functional/kaui/account_emails_controller_test.rb +0 -55
  223. data/test/functional/kaui/account_tags_controller_test.rb +0 -48
  224. data/test/functional/kaui/account_timelines_controller_test.rb +0 -20
  225. data/test/functional/kaui/accounts_controller_test.rb +0 -297
  226. data/test/functional/kaui/admin_allowed_users_controller_test.rb +0 -234
  227. data/test/functional/kaui/admin_controller_test.rb +0 -45
  228. data/test/functional/kaui/admin_tenants_controller_test.rb +0 -352
  229. data/test/functional/kaui/audit_logs_controller_test.rb +0 -71
  230. data/test/functional/kaui/bundle_tags_controller_test.rb +0 -23
  231. data/test/functional/kaui/bundles_controller_test.rb +0 -130
  232. data/test/functional/kaui/chargebacks_controller_test.rb +0 -42
  233. data/test/functional/kaui/charges_controller_test.rb +0 -60
  234. data/test/functional/kaui/credits_controller_test.rb +0 -54
  235. data/test/functional/kaui/custom_fields_controller_test.rb +0 -52
  236. data/test/functional/kaui/functional_test_helper.rb +0 -13
  237. data/test/functional/kaui/functional_test_helper_nosetup.rb +0 -120
  238. data/test/functional/kaui/home_controller_test.rb +0 -407
  239. data/test/functional/kaui/invoice_items_controller_test.rb +0 -82
  240. data/test/functional/kaui/invoices_controller_test.rb +0 -88
  241. data/test/functional/kaui/login_proxy_controller_test.rb +0 -12
  242. data/test/functional/kaui/payment_methods_controller_test.rb +0 -52
  243. data/test/functional/kaui/payments_controller_test.rb +0 -59
  244. data/test/functional/kaui/queues_controller_test.rb +0 -17
  245. data/test/functional/kaui/refunds_controller_test.rb +0 -63
  246. data/test/functional/kaui/registrations_controller_test.rb +0 -49
  247. data/test/functional/kaui/role_definitions_controller_test.rb +0 -47
  248. data/test/functional/kaui/subscriptions_controller_test.rb +0 -194
  249. data/test/functional/kaui/tag_definitions_controller_test.rb +0 -29
  250. data/test/functional/kaui/tags_controller_test.rb +0 -21
  251. data/test/functional/kaui/tenants_controller_test.rb +0 -60
  252. data/test/functional/kaui/transactions_controller_test.rb +0 -90
  253. data/test/integration/kaui/date_helper_integration_test.rb +0 -16
  254. data/test/integration/kaui/integration_test_helper.rb +0 -32
  255. data/test/integration/kaui/navigation_test.rb +0 -43
  256. data/test/killbill_test_helper.rb +0 -217
  257. data/test/test_helper.rb +0 -22
  258. data/test/unit/helpers/kaui/admin_allowed_users_helper_test.rb +0 -6
  259. data/test/unit/helpers/kaui/admin_tenants_helper_test.rb +0 -6
  260. data/test/unit/helpers/kaui/payment_method_helper_test.rb +0 -17
  261. data/test/unit/helpers/kaui/tenants_helper_test.rb +0 -6
  262. data/test/unit/helpers/kaui/uuid_helper_test.rb +0 -16
  263. data/test/unit/kaui/account_email_test.rb +0 -19
  264. data/test/unit/kaui/account_test.rb +0 -14
  265. data/test/unit/kaui/admin_tenant_test.rb +0 -132
  266. data/test/unit/kaui/allowed_user_test.rb +0 -34
  267. data/test/unit/kaui/base_test.rb +0 -23
  268. data/test/unit/kaui/date_helper_test.rb +0 -26
  269. data/test/unit/kaui/invoice_item_test.rb +0 -11
  270. data/test/unit/kaui/invoice_payment_test.rb +0 -42
  271. data/test/unit/kaui/invoice_test.rb +0 -20
  272. data/test/unit/kaui/money_helper_test.rb +0 -16
  273. data/test/unit/kaui/payment_test.rb +0 -42
  274. data/test/unit/kaui/tag_definition_test.rb +0 -11
  275. data/test/unit/kaui/tenant_test.rb +0 -19
  276. /data/app/assets/stylesheets/{application.css → kaui_application.css} +0 -0
@@ -1,28 +1,30 @@
1
- class Kaui::AuditLogsController < Kaui::EngineController
2
- OBJECT_WITH_HISTORY = %w[ACCOUNT ACCOUNT_EMAIL BLOCKING_STATES BUNDLE CUSTOM_FIELD INVOICE INVOICE_ITEM PAYMENT_ATTEMPT PAYMENT PAYMENT_METHOD SUBSCRIPTION SUBSCRIPTION_EVENT TRANSACTION TAG TAG_DEFINITION]
1
+ # frozen_string_literal: true
3
2
 
4
- def index
5
- cached_options_for_klient = options_for_klient
6
- @account = Kaui::Account::find_by_id_or_key(params.require(:account_id), false, false, cached_options_for_klient)
7
- audit_logs = @account.audit(cached_options_for_klient)
3
+ module Kaui
4
+ class AuditLogsController < Kaui::EngineController
5
+ OBJECT_WITH_HISTORY = %w[ACCOUNT ACCOUNT_EMAIL BLOCKING_STATES BUNDLE CUSTOM_FIELD INVOICE INVOICE_ITEM PAYMENT_ATTEMPT PAYMENT PAYMENT_METHOD SUBSCRIPTION SUBSCRIPTION_EVENT TRANSACTION TAG TAG_DEFINITION].freeze
8
6
 
7
+ def index
8
+ cached_options_for_klient = options_for_klient
9
+ @account = Kaui::Account.find_by_id_or_key(params.require(:account_id), false, false, cached_options_for_klient)
10
+ audit_logs = @account.audit(cached_options_for_klient)
9
11
 
10
- formatter = lambda do |log|
11
- object_id_text = view_context.object_id_popover(log.object_id)
12
+ formatter = lambda do |log|
13
+ object_id_text = view_context.object_id_popover(log.object_id)
12
14
 
13
- if object_with_history?(log.object_type)
14
- object_id_text = view_context.link_to(object_id_text, '#showHistoryModal',
15
- data: {
15
+ if object_with_history?(log.object_type)
16
+ object_id_text = view_context.link_to(object_id_text, '#showHistoryModal',
17
+ data: {
16
18
  toggle: 'modal',
17
19
  object_id: log.object_id,
18
20
  object_type: log.object_type,
19
21
  change_date: log.change_date,
20
22
  change_type: log.change_type,
21
23
  account_id: @account.account_id
22
- })
23
- end
24
+ })
25
+ end
24
26
 
25
- [
27
+ [
26
28
  log.change_date,
27
29
  object_id_text,
28
30
  log.object_type,
@@ -31,86 +33,87 @@ class Kaui::AuditLogsController < Kaui::EngineController
31
33
  log.reason_code,
32
34
  log.comments,
33
35
  view_context.object_id_popover(log.user_token, 'left')
34
- ]
35
- end
36
+ ]
37
+ end
36
38
 
37
- @audit_logs_json = []
38
- audit_logs.each { |page| @audit_logs_json << formatter.call(page) }
39
+ @audit_logs_json = []
40
+ audit_logs.each { |page| @audit_logs_json << formatter.call(page) }
39
41
 
40
- @audit_logs_json = @audit_logs_json.to_json
41
- end
42
+ @audit_logs_json = @audit_logs_json.to_json
43
+ end
42
44
 
43
- def history
44
- json_response do
45
- account_id = params.require(:account_id)
46
- object_id = params.require(:object_id)
47
- object_type = params.require(:object_type)
48
- cached_options_for_klient = options_for_klient
45
+ def history
46
+ json_response do
47
+ account_id = params.require(:account_id)
48
+ object_id = params.require(:object_id)
49
+ object_type = params.require(:object_type)
50
+ cached_options_for_klient = options_for_klient
49
51
 
50
- audit_logs_with_history = []
51
- error = nil
52
-
53
- begin
54
- if object_type == 'ACCOUNT'
55
- account = Kaui::Account::find_by_id_or_key(object_id, false, false, cached_options_for_klient)
56
- audit_logs_with_history = account.audit_logs_with_history(cached_options_for_klient)
57
- elsif object_type == 'ACCOUNT_EMAIL'
58
- account = Kaui::Account::find_by_id_or_key(account_id, false, false, cached_options_for_klient)
59
- audit_logs_with_history = account.email_audit_logs_with_history(object_id, cached_options_for_klient)
60
- elsif object_type == 'BLOCKING_STATES'
61
- audit_logs_with_history = Kaui::Account::blocking_state_audit_logs_with_history(object_id, cached_options_for_klient)
62
- elsif object_type == 'BUNDLE'
63
- bundle = Kaui::Bundle::find_by_id(object_id, cached_options_for_klient)
64
- audit_logs_with_history = bundle.audit_logs_with_history(cached_options_for_klient)
65
- elsif object_type == 'CUSTOM_FIELD'
66
- audit_logs_with_history = Kaui::CustomField.new({:custom_field_id => object_id}).audit_logs_with_history(cached_options_for_klient)
67
- elsif object_type == 'INVOICE'
68
- invoice = Kaui::Invoice::find_by_id(object_id, false, "NONE", cached_options_for_klient)
69
- audit_logs_with_history = invoice.audit_logs_with_history(cached_options_for_klient)
70
- elsif object_type == 'INVOICE_ITEM'
71
- invoice_item = Kaui::InvoiceItem.new
72
- invoice_item.invoice_item_id = object_id
73
- audit_logs_with_history = invoice_item.audit_logs_with_history(cached_options_for_klient)
74
- =begin See https://github.com/killbill/killbill/issues/1104
75
- elsif object_type == 'INVOICE_PAYMENT'
76
- invoice_payment = Kaui::InvoicePayment::find_by_id(object_id, false, false, cached_options_for_klient)
77
- audit_logs_with_history = invoice_payment.audit_logs_with_history(cached_options_for_klient)
78
- =end
79
- elsif object_type == 'PAYMENT_ATTEMPT'
80
- audit_logs_with_history = Kaui::Payment::attempt_audit_logs_with_history(object_id, cached_options_for_klient)
81
- elsif object_type == 'PAYMENT'
82
- payment = Kaui::Payment::find_by_id(object_id, false, false, cached_options_for_klient)
83
- audit_logs_with_history = payment.audit_logs_with_history(cached_options_for_klient)
84
- elsif object_type == 'PAYMENT_METHOD'
85
- payment_method = Kaui::PaymentMethod::find_by_id(object_id, false, cached_options_for_klient)
86
- audit_logs_with_history = payment_method.audit_logs_with_history(cached_options_for_klient)
87
- elsif object_type == 'SUBSCRIPTION'
88
- subscription = Kaui::Subscription::find_by_id(object_id, cached_options_for_klient)
89
- audit_logs_with_history = subscription.audit_logs_with_history(cached_options_for_klient)
90
- elsif object_type == 'SUBSCRIPTION_EVENT'
91
- audit_logs_with_history = Kaui::Subscription::event_audit_logs_with_history(object_id, cached_options_for_klient)
92
- elsif object_type == 'TRANSACTION'
93
- audit_logs_with_history = Kaui::Transaction::new({:transaction_id => object_id}).audit_logs_with_history(cached_options_for_klient)
94
- elsif object_type == 'TAG'
95
- audit_logs_with_history = Kaui::Tag.new({:tag_id => object_id}).audit_logs_with_history(cached_options_for_klient)
96
- elsif object_type == 'TAG_DEFINITION'
97
- audit_logs_with_history = Kaui::TagDefinition.new({:id => object_id}).audit_logs_with_history(cached_options_for_klient)
98
- else
99
- error = "Object [#{object_type}] history is not supported."
52
+ audit_logs_with_history = []
53
+ error = nil
54
+
55
+ begin
56
+ case object_type
57
+ when 'ACCOUNT'
58
+ account = Kaui::Account.find_by_id_or_key(object_id, false, false, cached_options_for_klient)
59
+ audit_logs_with_history = account.audit_logs_with_history(cached_options_for_klient)
60
+ when 'ACCOUNT_EMAIL'
61
+ account = Kaui::Account.find_by_id_or_key(account_id, false, false, cached_options_for_klient)
62
+ audit_logs_with_history = account.email_audit_logs_with_history(object_id, cached_options_for_klient)
63
+ when 'BLOCKING_STATES'
64
+ audit_logs_with_history = Kaui::Account.blocking_state_audit_logs_with_history(object_id, cached_options_for_klient)
65
+ when 'BUNDLE'
66
+ bundle = Kaui::Bundle.find_by_id(object_id, cached_options_for_klient)
67
+ audit_logs_with_history = bundle.audit_logs_with_history(cached_options_for_klient)
68
+ when 'CUSTOM_FIELD'
69
+ audit_logs_with_history = Kaui::CustomField.new({ custom_field_id: object_id }).audit_logs_with_history(cached_options_for_klient)
70
+ when 'INVOICE'
71
+ invoice = Kaui::Invoice.find_by_id(object_id, 'NONE', cached_options_for_klient)
72
+ audit_logs_with_history = invoice.audit_logs_with_history(cached_options_for_klient)
73
+ when 'INVOICE_ITEM'
74
+ invoice_item = Kaui::InvoiceItem.new
75
+ invoice_item.invoice_item_id = object_id
76
+ audit_logs_with_history = invoice_item.audit_logs_with_history(cached_options_for_klient)
77
+ # See https://github.com/killbill/killbill/issues/1104
78
+ # elsif object_type == 'INVOICE_PAYMENT'
79
+ # invoice_payment = Kaui::InvoicePayment::find_by_id(object_id, false, false, cached_options_for_klient)
80
+ # audit_logs_with_history = invoice_payment.audit_logs_with_history(cached_options_for_klient)
81
+ when 'PAYMENT_ATTEMPT'
82
+ audit_logs_with_history = Kaui::Payment.attempt_audit_logs_with_history(object_id, cached_options_for_klient)
83
+ when 'PAYMENT'
84
+ payment = Kaui::Payment.find_by_id(object_id, false, false, cached_options_for_klient)
85
+ audit_logs_with_history = payment.audit_logs_with_history(cached_options_for_klient)
86
+ when 'PAYMENT_METHOD'
87
+ payment_method = Kaui::PaymentMethod.find_by_id(object_id, false, cached_options_for_klient)
88
+ audit_logs_with_history = payment_method.audit_logs_with_history(cached_options_for_klient)
89
+ when 'SUBSCRIPTION'
90
+ subscription = Kaui::Subscription.find_by_id(object_id, cached_options_for_klient)
91
+ audit_logs_with_history = subscription.audit_logs_with_history(cached_options_for_klient)
92
+ when 'SUBSCRIPTION_EVENT'
93
+ audit_logs_with_history = Kaui::Subscription.event_audit_logs_with_history(object_id, cached_options_for_klient)
94
+ when 'TRANSACTION'
95
+ audit_logs_with_history = Kaui::Transaction.new({ transaction_id: object_id }).audit_logs_with_history(cached_options_for_klient)
96
+ when 'TAG'
97
+ audit_logs_with_history = Kaui::Tag.new({ tag_id: object_id }).audit_logs_with_history(cached_options_for_klient)
98
+ when 'TAG_DEFINITION'
99
+ audit_logs_with_history = Kaui::TagDefinition.new({ id: object_id }).audit_logs_with_history(cached_options_for_klient)
100
+ else
101
+ error = "Object [#{object_type}] history is not supported."
102
+ end
103
+ rescue StandardError => e
104
+ error = e.message
100
105
  end
101
- rescue Exception => e
102
- error = e.message
103
- end
104
106
 
105
- { audits: audit_logs_with_history, error: error }
107
+ { audits: audit_logs_with_history, error: error }
108
+ end
106
109
  end
107
- end
108
110
 
109
- private
111
+ private
110
112
 
111
113
  def object_with_history?(object_type)
112
114
  return false if object_type.nil?
115
+
113
116
  OBJECT_WITH_HISTORY.include?(object_type)
114
117
  end
115
-
116
- end
118
+ end
119
+ end
@@ -1,28 +1,32 @@
1
- class Kaui::BundleTagsController < Kaui::EngineController
1
+ # frozen_string_literal: true
2
2
 
3
- def edit
4
- @bundle_id = params.require(:bundle_id)
3
+ module Kaui
4
+ class BundleTagsController < Kaui::EngineController
5
+ def edit
6
+ @bundle_id = params.require(:bundle_id)
5
7
 
6
- cached_options_for_klient = options_for_klient
7
- fetch_tag_names = promise { (Kaui::Tag.all_for_bundle(@bundle_id, false, 'NONE', cached_options_for_klient).map { |tag| tag.tag_definition_name }).sort }
8
- fetch_available_tags = promise { Kaui::TagDefinition.all_for_bundle(cached_options_for_klient) }
8
+ cached_options_for_klient = options_for_klient
9
+ fetch_tag_names = promise { Kaui::Tag.all_for_bundle(@bundle_id, false, 'NONE', cached_options_for_klient).map(&:tag_definition_name).sort }
10
+ fetch_available_tags = promise { Kaui::TagDefinition.all_for_bundle(cached_options_for_klient) }
9
11
 
10
- @tag_names = wait(fetch_tag_names)
11
- @available_tags = wait(fetch_available_tags)
12
- end
12
+ @tag_names = wait(fetch_tag_names)
13
+ @available_tags = wait(fetch_available_tags)
14
+ end
13
15
 
14
- def update
15
- account_id = params.require(:account_id)
16
- bundle_id = params.require(:bundle_id)
16
+ def update
17
+ account_id = params.require(:account_id)
18
+ bundle_id = params.require(:bundle_id)
17
19
 
18
- tags = []
19
- params.each do |tag, tag_name|
20
- tag_info = tag.split('_')
21
- next if tag_info.size != 2 or tag_info[0] != 'tag'
22
- tags << tag_info[1]
23
- end
20
+ tags = []
21
+ params.each do |tag, _tag_name|
22
+ tag_info = tag.split('_')
23
+ next if (tag_info.size != 2) || (tag_info[0] != 'tag')
24
24
 
25
- Kaui::Tag.set_for_bundle(bundle_id, tags, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
26
- redirect_to kaui_engine.account_bundles_path(account_id), :notice => 'Bundle tags successfully set'
25
+ tags << tag_info[1]
26
+ end
27
+
28
+ Kaui::Tag.set_for_bundle(bundle_id, tags, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
29
+ redirect_to kaui_engine.account_bundles_path(account_id), notice: 'Bundle tags successfully set'
30
+ end
27
31
  end
28
32
  end
@@ -1,99 +1,113 @@
1
- class Kaui::BundlesController < Kaui::EngineController
2
-
3
- def index
4
- cached_options_for_klient = options_for_klient
5
-
6
- fetch_bundles = promise { @account.bundles(cached_options_for_klient) }
7
- fetch_bundle_tags = promise {
8
- all_bundle_tags = @account.all_tags(:BUNDLE, false, 'NONE', cached_options_for_klient)
9
- all_bundle_tags.inject({}) {|hsh, entry| (hsh[entry.object_id] ||= []) << entry; hsh}
10
- }
11
- fetch_subscription_tags = promise {
12
- all_subscription_tags = @account.all_tags(:SUBSCRIPTION, false, 'NONE', cached_options_for_klient)
13
- all_subscription_tags.inject({}) {|hsh, entry| (hsh[entry.object_id] ||= []) << entry; hsh}
14
- }
15
- fetch_bundle_fields = promise {
16
- all_bundle_fields = @account.all_custom_fields(:BUNDLE, 'NONE', cached_options_for_klient)
17
- all_bundle_fields.inject({}) {|hsh, entry| (hsh[entry.object_id] ||= []) << entry; hsh}
18
- }
19
- fetch_subscription_fields = promise {
20
- all_subscription_fields = @account.all_custom_fields(:SUBSCRIPTION, 'NONE', cached_options_for_klient)
21
- all_subscription_fields.inject({}) {|hsh, entry| (hsh[entry.object_id] ||= []) << entry; hsh}
22
- }
23
- fetch_available_tags = promise { Kaui::TagDefinition.all_for_bundle(cached_options_for_klient) }
24
- fetch_available_subscription_tags = promise { Kaui::TagDefinition.all_for_subscription(cached_options_for_klient) }
25
-
26
- @bundles = wait(fetch_bundles)
27
- @tags_per_bundle = wait(fetch_bundle_tags)
28
- @tags_per_subscription = wait(fetch_subscription_tags)
29
- @custom_fields_per_bundle = wait(fetch_bundle_fields)
30
- @custom_fields_per_subscription = wait(fetch_subscription_fields)
31
- @available_tags = wait(fetch_available_tags)
32
- @available_subscription_tags = wait(fetch_available_subscription_tags)
33
-
34
- # TODO This doesn't take into account catalog versions
35
- catalogs = Kaui::Catalog.get_account_catalog_json(@account.account_id, nil, cached_options_for_klient) || []
36
- @catalog = catalogs[-1]
37
-
38
- @subscription = {}
39
- @bundles.each do |bundle|
40
- bundle.subscriptions.each do |sub|
41
- next if sub.product_category == 'ADD_ON'
42
- @subscription[bundle.bundle_id] = sub
43
- break
1
+ # frozen_string_literal: true
2
+
3
+ module Kaui
4
+ class BundlesController < Kaui::EngineController
5
+ # rubocop:disable Lint/HashCompareByIdentity
6
+ def index
7
+ cached_options_for_klient = options_for_klient
8
+
9
+ fetch_bundles = promise { @account.bundles(cached_options_for_klient) }
10
+ fetch_bundle_tags = promise do
11
+ all_bundle_tags = @account.all_tags(:BUNDLE, false, 'NONE', cached_options_for_klient)
12
+ all_bundle_tags.each_with_object({}) do |entry, hsh|
13
+ (hsh[entry.object_id] ||= []) << entry
14
+ end
15
+ end
16
+ fetch_subscription_tags = promise do
17
+ all_subscription_tags = @account.all_tags(:SUBSCRIPTION, false, 'NONE', cached_options_for_klient)
18
+ all_subscription_tags.each_with_object({}) do |entry, hsh|
19
+ (hsh[entry.object_id] ||= []) << entry
20
+ end
21
+ end
22
+ fetch_bundle_fields = promise do
23
+ all_bundle_fields = @account.all_custom_fields(:BUNDLE, 'NONE', cached_options_for_klient)
24
+ all_bundle_fields.each_with_object({}) do |entry, hsh|
25
+ (hsh[entry.object_id] ||= []) << entry
26
+ end
27
+ end
28
+ fetch_subscription_fields = promise do
29
+ all_subscription_fields = @account.all_custom_fields(:SUBSCRIPTION, 'NONE', cached_options_for_klient)
30
+ all_subscription_fields.each_with_object({}) do |entry, hsh|
31
+ (hsh[entry.object_id] ||= []) << entry
32
+ end
33
+ end
34
+ fetch_available_tags = promise { Kaui::TagDefinition.all_for_bundle(cached_options_for_klient) }
35
+ fetch_available_subscription_tags = promise { Kaui::TagDefinition.all_for_subscription(cached_options_for_klient) }
36
+
37
+ @bundles = wait(fetch_bundles)
38
+ @tags_per_bundle = wait(fetch_bundle_tags)
39
+ @tags_per_subscription = wait(fetch_subscription_tags)
40
+ @custom_fields_per_bundle = wait(fetch_bundle_fields)
41
+ @custom_fields_per_subscription = wait(fetch_subscription_fields)
42
+ @available_tags = wait(fetch_available_tags)
43
+ @available_subscription_tags = wait(fetch_available_subscription_tags)
44
+
45
+ # TODO: This doesn't take into account catalog versions
46
+ catalogs = Kaui::Catalog.get_account_catalog_json(@account.account_id, nil, cached_options_for_klient) || []
47
+ @catalog = catalogs[-1]
48
+
49
+ @subscription = {}
50
+ @bundles.each do |bundle|
51
+ bundle.subscriptions.each do |sub|
52
+ next if sub.product_category == 'ADD_ON'
53
+
54
+ @subscription[bundle.bundle_id] = sub
55
+ break
56
+ end
44
57
  end
45
58
  end
46
- end
59
+ # rubocop:enable Lint/HashCompareByIdentity
47
60
 
48
- def transfer
49
- @bundle_id = params.require(:id)
50
- end
61
+ def transfer
62
+ @bundle_id = params.require(:id)
63
+ end
51
64
 
52
- def do_transfer
53
- cached_options_for_klient = options_for_klient
65
+ def do_transfer
66
+ cached_options_for_klient = options_for_klient
54
67
 
55
- new_account = Kaui::Account::find_by_id_or_key(params.require(:new_account_key), false, false, cached_options_for_klient)
68
+ new_account = Kaui::Account.find_by_id_or_key(params.require(:new_account_key), false, false, cached_options_for_klient)
56
69
 
57
- bundle = Kaui::Bundle::new(:bundle_id => params.require(:id), :account_id => new_account.account_id)
58
- bundle.transfer(nil, params[:billing_policy], current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
70
+ bundle = Kaui::Bundle.new(bundle_id: params.require(:id), account_id: new_account.account_id)
71
+ bundle.transfer(nil, params[:billing_policy], current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
59
72
 
60
- redirect_to kaui_engine.account_bundles_path(new_account.account_id), :notice => 'Bundle was successfully transferred'
61
- end
73
+ redirect_to kaui_engine.account_bundles_path(new_account.account_id), notice: 'Bundle was successfully transferred'
74
+ end
62
75
 
63
- def restful_show
64
- bundle = Kaui::Bundle.find_by_id_or_key(params.require(:id), options_for_klient)
65
- redirect_to kaui_engine.account_bundles_path(bundle.account_id)
66
- end
76
+ def restful_show
77
+ bundle = Kaui::Bundle.find_by_id_or_key(params.require(:id), options_for_klient)
78
+ redirect_to kaui_engine.account_bundles_path(bundle.account_id)
79
+ end
67
80
 
68
- def pause_resume
69
- @bundle = Kaui::Bundle.find_by_id_or_key(params.require(:id), options_for_klient)
70
- @base_subscription = @bundle.subscriptions.find { |sub| sub.product_category == 'BASE' }
71
- end
81
+ def pause_resume
82
+ @bundle = Kaui::Bundle.find_by_id_or_key(params.require(:id), options_for_klient)
83
+ @base_subscription = @bundle.subscriptions.find { |sub| sub.product_category == 'BASE' }
84
+ end
72
85
 
73
- def do_pause_resume
74
- bundle = Kaui::Bundle::new(:bundle_id => params.require(:id))
86
+ def do_pause_resume
87
+ bundle = Kaui::Bundle.new(bundle_id: params.require(:id))
75
88
 
76
- paused = false
77
- resumed = false
89
+ paused = false
90
+ resumed = false
78
91
 
79
- if params[:pause_requested_date].present?
80
- bundle.pause(params[:pause_requested_date], current_user.kb_username, params[:reason], params[:comment], options_for_klient)
81
- paused = true
82
- end
92
+ if params[:pause_requested_date].present?
93
+ bundle.pause(params[:pause_requested_date], current_user.kb_username, params[:reason], params[:comment], options_for_klient)
94
+ paused = true
95
+ end
83
96
 
84
- if params[:resume_requested_date].present?
85
- bundle.resume(params[:resume_requested_date], current_user.kb_username, params[:reason], params[:comment], options_for_klient)
86
- resumed = true
87
- end
97
+ if params[:resume_requested_date].present?
98
+ bundle.resume(params[:resume_requested_date], current_user.kb_username, params[:reason], params[:comment], options_for_klient)
99
+ resumed = true
100
+ end
88
101
 
89
- msg = 'Bundle was successfully '
90
- if paused && !resumed
91
- msg += 'paused'
92
- elsif !paused && resumed
93
- msg += 'resumed'
94
- else
95
- msg += 'updated'
102
+ msg = 'Bundle was successfully '
103
+ msg += if paused && !resumed
104
+ 'paused'
105
+ elsif !paused && resumed
106
+ 'resumed'
107
+ else
108
+ 'updated'
109
+ end
110
+ redirect_to kaui_engine.account_bundles_path(@account.account_id), notice: msg
96
111
  end
97
- redirect_to kaui_engine.account_bundles_path(@account.account_id), :notice => msg
98
112
  end
99
113
  end
@@ -1,45 +1,48 @@
1
- class Kaui::ChargebacksController < Kaui::EngineController
1
+ # frozen_string_literal: true
2
2
 
3
- def new
4
- payment = Kaui::Payment::find_by_id(params.require(:payment_id), false, false, options_for_klient)
5
- @chargeback = Kaui::Chargeback.new(:payment_id => payment.payment_id,
6
- :amount => payment.paid_amount_to_money.to_f,
7
- :currency => payment.currency)
8
- end
9
-
10
- def create
11
- cached_options_for_klient = options_for_klient
3
+ module Kaui
4
+ class ChargebacksController < Kaui::EngineController
5
+ def new
6
+ payment = Kaui::Payment.find_by_id(params.require(:payment_id), false, false, options_for_klient)
7
+ @chargeback = Kaui::Chargeback.new(payment_id: payment.payment_id,
8
+ amount: payment.paid_amount_to_money.to_f,
9
+ currency: payment.currency)
10
+ end
12
11
 
13
- @chargeback = Kaui::Chargeback.new(params.require(:chargeback))
14
- should_cancel_subs = (params[:cancel_all_subs] == '1')
12
+ def create
13
+ cached_options_for_klient = options_for_klient
15
14
 
16
- begin
17
- payment = @chargeback.chargeback(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
18
- rescue => e
19
- flash.now[:error] = "Error while creating a new chargeback: #{as_string(e)}"
20
- render :action => :new and return
21
- end
15
+ @chargeback = Kaui::Chargeback.new(params.require(:chargeback))
16
+ should_cancel_subs = (params[:cancel_all_subs] == '1')
22
17
 
23
- # Cancel all subscriptions on the account, if required
24
- if should_cancel_subs
25
18
  begin
26
- account = Kaui::Account.find_by_id(payment.account_id, false, false, cached_options_for_klient)
27
- account.bundles(cached_options_for_klient).each do |bundle|
28
- bundle.subscriptions.each do |subscription|
29
- # Already cancelled?
30
- next unless subscription.billing_end_date.blank?
19
+ payment = @chargeback.chargeback(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
20
+ rescue StandardError => e
21
+ flash.now[:error] = "Error while creating a new chargeback: #{as_string(e)}"
22
+ render action: :new and return
23
+ end
24
+
25
+ # Cancel all subscriptions on the account, if required
26
+ if should_cancel_subs
27
+ begin
28
+ account = Kaui::Account.find_by_id(payment.account_id, false, false, cached_options_for_klient)
29
+ account.bundles(cached_options_for_klient).each do |bundle|
30
+ bundle.subscriptions.each do |subscription|
31
+ # Already cancelled?
32
+ next unless subscription.billing_end_date.blank?
31
33
 
32
- # Cancel the entitlement immediately but use the default billing policy
33
- entitlement = Kaui::Subscription.new(:subscription_id => subscription.subscription_id)
34
- entitlement.cancel_entitlement_immediately(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
34
+ # Cancel the entitlement immediately but use the default billing policy
35
+ entitlement = Kaui::Subscription.new(subscription_id: subscription.subscription_id)
36
+ entitlement.cancel_entitlement_immediately(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
37
+ end
35
38
  end
39
+ rescue StandardError => e
40
+ flash[:error] = "Error while cancelling subscriptions: #{as_string(e)}"
41
+ render action: :new and return
36
42
  end
37
- rescue => e
38
- flash[:error] = "Error while cancelling subscriptions: #{as_string(e)}"
39
- render :action => :new and return
40
43
  end
41
- end
42
44
 
43
- redirect_to kaui_engine.account_payment_path(payment.account_id, payment.payment_id), :notice => 'Chargeback created'
45
+ redirect_to kaui_engine.account_payment_path(payment.account_id, payment.payment_id), notice: 'Chargeback created'
46
+ end
44
47
  end
45
48
  end
@@ -1,28 +1,31 @@
1
- class Kaui::ChargesController < Kaui::EngineController
1
+ # frozen_string_literal: true
2
2
 
3
- def new
4
- invoice_id = params[:invoice_id]
5
- amount = params[:amount]
3
+ module Kaui
4
+ class ChargesController < Kaui::EngineController
5
+ def new
6
+ invoice_id = params[:invoice_id]
7
+ amount = params[:amount]
6
8
 
7
- if invoice_id.present?
8
- @invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
9
- amount ||= @invoice.balance
10
- currency = @invoice.currency
11
- else
12
- @invoice = nil
13
- currency = params[:currency] || 'USD'
14
- end
9
+ if invoice_id.present?
10
+ @invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
11
+ amount ||= @invoice.balance
12
+ currency = @invoice.currency
13
+ else
14
+ @invoice = nil
15
+ currency = params[:currency] || 'USD'
16
+ end
15
17
 
16
- @charge = Kaui::InvoiceItem.new(:account_id => params.require(:account_id), :invoice_id => invoice_id, :amount => amount, :currency => currency)
17
- end
18
+ @charge = Kaui::InvoiceItem.new(account_id: params.require(:account_id), invoice_id: invoice_id, amount: amount, currency: currency)
19
+ end
18
20
 
19
- def create
20
- charge = Kaui::InvoiceItem.new(params.require(:invoice_item).delete_if { |key, value| value.blank? })
21
- charge.account_id ||= params.require(:account_id)
21
+ def create
22
+ charge = Kaui::InvoiceItem.new(params.require(:invoice_item).delete_if { |_key, value| value.blank? })
23
+ charge.account_id ||= params.require(:account_id)
22
24
 
23
- auto_commit = params[:auto_commit] == '1'
25
+ auto_commit = params[:auto_commit] == '1'
24
26
 
25
- charge = charge.create(auto_commit, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
26
- redirect_to kaui_engine.account_invoice_path(charge.account_id, charge.invoice_id), :notice => 'Charge was successfully created'
27
+ charge = charge.create(auto_commit, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
28
+ redirect_to kaui_engine.account_invoice_path(charge.account_id, charge.invoice_id), notice: 'Charge was successfully created'
29
+ end
27
30
  end
28
31
  end