kaui 0.16.2 → 1.0.0

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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/assets/javascripts/application.js +1 -1
  4. data/app/assets/javascripts/kaui/kaui.js +78 -1
  5. data/app/assets/stylesheets/bootstrap_and_overrides.css.less +5 -0
  6. data/app/assets/stylesheets/kaui/account.less +20 -0
  7. data/app/assets/stylesheets/kaui/audit.less +38 -0
  8. data/app/assets/stylesheets/kaui/common.less +103 -0
  9. data/app/assets/stylesheets/kaui/datatable.less +19 -0
  10. data/app/assets/stylesheets/kaui/kaui.less +3 -1
  11. data/app/assets/stylesheets/kaui/subscription.less +15 -0
  12. data/app/assets/stylesheets/kaui/tags.less +30 -1
  13. data/app/controllers/kaui/account_custom_fields_controller.rb +24 -0
  14. data/app/controllers/kaui/account_tags_controller.rb +21 -0
  15. data/app/controllers/kaui/accounts_controller.rb +43 -16
  16. data/app/controllers/kaui/admin_tenants_controller.rb +152 -11
  17. data/app/controllers/kaui/audit_logs_controller.rb +93 -0
  18. data/app/controllers/kaui/bundles_controller.rb +15 -3
  19. data/app/controllers/kaui/custom_fields_controller.rb +2 -0
  20. data/app/controllers/kaui/engine_controller_util.rb +14 -0
  21. data/app/controllers/kaui/invoice_items_controller.rb +17 -0
  22. data/app/controllers/kaui/invoices_controller.rb +22 -5
  23. data/app/controllers/kaui/payment_methods_controller.rb +10 -9
  24. data/app/controllers/kaui/subscriptions_controller.rb +54 -7
  25. data/app/controllers/kaui/tag_definitions_controller.rb +1 -0
  26. data/app/helpers/kaui/account_helper.rb +28 -0
  27. data/app/helpers/kaui/object_helper.rb +4 -0
  28. data/app/helpers/kaui/permissions_helper.rb +15 -0
  29. data/app/helpers/kaui/plugin_helper.rb +58 -0
  30. data/app/helpers/kaui/subscription_helper.rb +9 -7
  31. data/app/models/kaui/admin_tenant.rb +20 -6
  32. data/app/models/kaui/catalog.rb +4 -4
  33. data/app/models/kaui/tag.rb +1 -1
  34. data/app/models/kaui/tag_definition.rb +1 -1
  35. data/app/views/kaui/account_custom_fields/index.html.erb +35 -0
  36. data/app/views/kaui/account_tags/index.html.erb +35 -0
  37. data/app/views/kaui/accounts/_account_info.html.erb +5 -0
  38. data/app/views/kaui/accounts/_billing_info.html.erb +1 -1
  39. data/app/views/kaui/accounts/_close_account_modal.html.erb +98 -0
  40. data/app/views/kaui/accounts/index.html.erb +0 -7
  41. data/app/views/kaui/accounts/show.html.erb +4 -0
  42. data/app/views/kaui/admin_tenants/_add_allowed_user_modal.html.erb +64 -0
  43. data/app/views/kaui/admin_tenants/_form_plugin_config.erb +257 -151
  44. data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +133 -48
  45. data/app/views/kaui/admin_tenants/_show_catalog_xml.erb +3 -2
  46. data/app/views/kaui/admin_tenants/show.html.erb +6 -1
  47. data/app/views/kaui/audit_logs/_show_history_modal.html.erb +177 -0
  48. data/app/views/kaui/audit_logs/index.html.erb +52 -0
  49. data/app/views/kaui/bundle_tags/_form_bar.html.erb +4 -2
  50. data/app/views/kaui/bundles/index.html.erb +21 -14
  51. data/app/views/kaui/chargebacks/_form.html.erb +1 -9
  52. data/app/views/kaui/charges/_form.html.erb +2 -10
  53. data/app/views/kaui/credits/_form.html.erb +1 -9
  54. data/app/views/kaui/custom_fields/_form.html.erb +1 -1
  55. data/app/views/kaui/custom_fields/_list_bar.html.erb +1 -1
  56. data/app/views/kaui/invoices/_invoice_table.html.erb +30 -2
  57. data/app/views/kaui/layouts/kaui_account_navbar.html.erb +7 -0
  58. data/app/views/kaui/layouts/kaui_flash.html.erb +13 -2
  59. data/app/views/kaui/payment_methods/_new_creditcard_payment_method.html.erb +11 -11
  60. data/app/views/kaui/payment_methods/_plugin_properties.html.erb +1 -1
  61. data/app/views/kaui/payments/_form.html.erb +1 -9
  62. data/app/views/kaui/refunds/_form.html.erb +4 -6
  63. data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +62 -0
  64. data/app/views/kaui/subscriptions/_form.html.erb +7 -13
  65. data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +50 -11
  66. data/app/views/kaui/subscriptions/new.html.erb +3 -1
  67. data/app/views/kaui/tag_definitions/_form.html.erb +139 -0
  68. data/app/views/kaui/tags/index.html.erb +1 -1
  69. data/app/views/kaui/transactions/_control_plugin_names.html.erb +1 -1
  70. data/config/routes.rb +18 -2
  71. data/db/migrate/20130812155313_devise_create_kaui_users.rb +9 -7
  72. data/db/migrate/20150109214021_create_kaui_tenants.rb +8 -6
  73. data/db/migrate/20150112232813_create_kaui_allowed_users.rb +15 -11
  74. data/lib/kaui/engine.rb +1 -0
  75. data/lib/kaui/version.rb +1 -1
  76. data/test/dummy/config/database.yml +6 -1
  77. data/test/fixtures/SpyCarAdvanced.xml +824 -0
  78. data/test/functional/kaui/account_children_controller_test.rb +1 -1
  79. data/test/functional/kaui/account_custom_fields_controller_test.rb +29 -0
  80. data/test/functional/kaui/account_tags_controller_test.rb +19 -0
  81. data/test/functional/kaui/accounts_controller_test.rb +23 -6
  82. data/test/functional/kaui/admin_controller_test.rb +2 -2
  83. data/test/functional/kaui/admin_tenants_controller_test.rb +76 -5
  84. data/test/functional/kaui/audit_logs_controller_test.rb +71 -0
  85. data/test/functional/kaui/bundles_controller_test.rb +2 -1
  86. data/test/functional/kaui/payments_controller_test.rb +1 -1
  87. data/test/functional/kaui/subscriptions_controller_test.rb +1 -2
  88. data/test/functional/kaui/tag_definitions_controller_test.rb +2 -1
  89. data/test/killbill_test_helper.rb +5 -2
  90. data/test/unit/kaui/admin_tenant_test.rb +100 -0
  91. data/test/unit/kaui/money_helper_test.rb +1 -1
  92. metadata +58 -13
  93. data/app/assets/javascripts/kaui/validation.js +0 -21
  94. data/test/dummy/log/test.log +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a923f6331603867ff6a37998ee73e2d4a16dadf3
4
- data.tar.gz: a2a8c31f3eb0eb667dc9a2399f2c4ed1a85bf79a
3
+ metadata.gz: e87e62224a7eee3e9ee134db6f88824cbe6efdbf
4
+ data.tar.gz: 1f762a4df672efbaee3182d0eca916405cf057cc
5
5
  SHA512:
6
- metadata.gz: df9c817add8adfc78f8ae46b2dc0b34a815b661a23fc23b5da456dad46576c4fa7dab47f4ee11c0c0021cfe4b7d85d0d616b2b9f6cc669743ec567ca9305ab69
7
- data.tar.gz: a565252fa7a573b4715dbcd42f83e26145c14533bed9ae8a92cb5c8116565359c3092ed9441c4509a2c95c17e0c13856c0b91c5e7d641bbc225cb1abde966664
6
+ metadata.gz: 38bdfc7f29ad2711fec6a566ac962cbb2d0ecdadf60754522a0c786f4446433c71191dbabb40f9a80f8220da7c07da694e9f10077f2d6248030c1ab70d08b4d6
7
+ data.tar.gz: d5fbd8de69aeeef43f4690e3ad84dff02c89dbe7215bb95b87dbd451915f88f5bf73a4a25499b186376b089b0afad5fc1c80e738fc89e24610102ecb47d61199
data/README.md CHANGED
@@ -11,12 +11,12 @@ Kill Bill compatibility
11
11
  | 0.14.y | 0.16.z |
12
12
  | 0.15.y | 0.18.z (Rails 4) |
13
13
  | 0.16.y | 0.18.z (Rails 5) |
14
-
14
+ | 1.x.y | 0.19.z |
15
15
 
16
16
  Dependencies
17
17
  ------------
18
18
 
19
- Ruby 2.2.2+ or JRuby 9.1.9.0+ required.
19
+ Ruby 2.4.2+ or JRuby 9.1.14.0+ required.
20
20
 
21
21
  Running Kaui locally
22
22
  ---------------------
@@ -13,5 +13,5 @@
13
13
  //= require twitter/bootstrap
14
14
  //= require bootstrap-datepicker
15
15
  //= require kaui/bootstrap-tweaks
16
- //= require kaui/validation
16
+ //= require mustache
17
17
  //= require kaui/kaui
@@ -183,4 +183,81 @@ jQuery(document).ready(function ($) {
183
183
  }
184
184
  }
185
185
 
186
- })
186
+ // Restrict numeric input for a text field
187
+ // Using "constraint validation API" to restrict input
188
+ $("input[type=number]").keydown(function(event) {
189
+ $(this).data('oldData', $(this).val());
190
+ }).keyup(function(event) {
191
+ if (event.currentTarget.validity.badInput) {
192
+ $(this).val($(this).data('oldData'));
193
+ }
194
+ });
195
+
196
+ // this will register a global ajax error for all jquery ajax requests (not including DataTable)
197
+ $( document ).ajaxError(function( event, jqxhr, settings, thrownError ) {
198
+ if (jqxhr.status == 0) {
199
+ return;
200
+ }
201
+
202
+ var message = 'Request Status: ' + jqxhr.status + ' Status Text: ' + jqxhr.statusText + ' ' + jqxhr.responseText;
203
+
204
+ if (jqxhr.status == 200) {
205
+ message = thrownError.message == undefined ? thrownError : thrownError.message;
206
+ }
207
+ ajaxAlert(message);
208
+ });
209
+
210
+ // this will prevent DataTable to show an alert message box when an error occurs
211
+ $.fn.dataTable.ext.errMode = 'none';
212
+ // this will try to register a DataTable error event to all tables, and if an error occurs will display the error on screen
213
+ $( document ).find(".table").on('error.dt', function ( e, settings, techNote, message ) {
214
+ ajaxAlert('An error has been reported by DataTables: ' + message);
215
+ })
216
+
217
+ });
218
+
219
+ // global function used to show a error message that occurs on a Ajax call
220
+ function ajaxAlert(message) {
221
+ // do not show ajax alert if there is already an server alert
222
+ var serverAlertStatus = $(".server-alert").css("display");
223
+ if (serverAlertStatus != undefined && serverAlertStatus != "none") {
224
+ return;
225
+ }
226
+
227
+ var messageBox = $("#ajaxAlert");
228
+ messageBox.find("#ajaxErrorMessage").text(message);
229
+ messageBox.show();
230
+ messageBox.find("button").click(function(){
231
+ ajaxCloseAlert(messageBox);
232
+ });
233
+ }
234
+
235
+ function ajaxCloseAlert(messageBox) {
236
+ var messageBox = messageBox || $("#ajaxAlert");
237
+ messageBox.find("#ajaxErrorMessage").text('');
238
+ messageBox.hide();
239
+ }
240
+
241
+ // global helper function to validate if a variable is null or empty or undefined
242
+ function isNullOrUndefined(value) {
243
+ if (value == undefined || value == null) {
244
+ return true;
245
+ }
246
+ return false;
247
+ }
248
+
249
+ function isBlank(value) {
250
+ if (isNullOrUndefined(value)) {
251
+ return true;
252
+ }
253
+
254
+ if (jQuery.type(value) === "string" && value.trim().length == 0) {
255
+ return true;
256
+ } else if (jQuery.type(value) === "array" && value.length == 0) {
257
+ return true;
258
+ } else if (jQuery.type(value) === "object" && jQuery.isEmptyObject(value)) {
259
+ return true;
260
+ } else {
261
+ return false;
262
+ }
263
+ }
@@ -37,3 +37,8 @@
37
37
  //
38
38
  // Example:
39
39
  // @link-color: #ff0000;
40
+
41
+ // popover max width
42
+ .popover {
43
+ max-width: 350px;
44
+ }
@@ -17,4 +17,24 @@ h1 span.account-child-label{
17
17
  background-color: transparent;
18
18
  color: #2a6496;
19
19
 
20
+ }
21
+
22
+ .title-nav-area {
23
+ .container {
24
+ p {
25
+ padding-left: 20px;
26
+ padding-right: 20px;
27
+ }
28
+
29
+ a {
30
+ max-width: 125px;
31
+ min-width: 90px;
32
+ padding: 12px 12px;
33
+ text-align: center;
34
+ }
35
+
36
+ span.label-danger {
37
+ margin: 8px;
38
+ }
39
+ }
20
40
  }
@@ -0,0 +1,38 @@
1
+ #showHistoryModal
2
+ {
3
+ #templatesPlaceHolder
4
+ {
5
+ display: flex;
6
+
7
+ .panel {
8
+ margin-left: 5px;
9
+
10
+ .panel-heading {
11
+ white-space: nowrap;
12
+ }
13
+ }
14
+
15
+ .list-group-item {
16
+ padding: 5px;
17
+ min-height: 32px;
18
+ overflow-x: hidden;
19
+ white-space: nowrap;
20
+ }
21
+
22
+ #templateFieldsPlaceHolder {
23
+ .list-group-item {
24
+ span {
25
+ text-transform: capitalize;
26
+ font-weight: bold;
27
+ }
28
+ }
29
+ }
30
+
31
+ #templatePlaceHolder
32
+ {
33
+ display: flex;
34
+ overflow-x: auto;
35
+ }
36
+
37
+ }
38
+ }
@@ -530,3 +530,106 @@ hr.breathe {
530
530
  margin-top: 45px;
531
531
  margin-bottom: 45px;
532
532
  }
533
+
534
+ form[id^="new_tag_definition"] {
535
+ div:first-of-type {
536
+ margin-bottom: 0;
537
+ }
538
+
539
+ #object_types {
540
+ div {
541
+ margin-bottom: 15px;
542
+
543
+ .tag-definition-add-link {
544
+ padding-right: 0;
545
+ }
546
+
547
+ .tag-definition-select {
548
+ display: inline-block;
549
+ width: calc(~"100% - 25px");
550
+ }
551
+ }
552
+ }
553
+ }
554
+
555
+ /* The switch - the box around the slider */
556
+ .switch {
557
+ position: relative;
558
+ display: inline-block;
559
+ width: 36px;
560
+ height: 20px;
561
+
562
+
563
+ /* Hide default HTML checkbox */
564
+ input {display:none;}
565
+
566
+ /* The slider */
567
+ .slider {
568
+ position: absolute;
569
+ cursor: pointer;
570
+ top: 0;
571
+ left: 0;
572
+ right: 0;
573
+ bottom: 0;
574
+ background-color: #ccc;
575
+ -webkit-transition: .4s;
576
+ transition: .4s;
577
+ }
578
+
579
+ .slider:before {
580
+ position: absolute;
581
+ content: "";
582
+ height: 16px;
583
+ width: 16px;
584
+ left: 2px;
585
+ bottom: 2px;
586
+ background-color: white;
587
+ -webkit-transition: .4s;
588
+ transition: .4s;
589
+ }
590
+
591
+ input:checked + .slider {
592
+ background-color: #00919d;
593
+ }
594
+
595
+ input:focus + .slider {
596
+ box-shadow: 0 0 1px #2196F3;
597
+ }
598
+ }
599
+
600
+ input:checked + .slider:before {
601
+ -webkit-transform: translateX(16px);
602
+ -ms-transform: translateX(16px);
603
+ transform: translateX(16px);
604
+ }
605
+
606
+ /* Rounded sliders */
607
+ .slider.round {
608
+ border-radius: 26px;
609
+ }
610
+
611
+ .slider.round:before {
612
+ border-radius: 50%;
613
+ }
614
+
615
+ .ui-helper-hidden-accessible {
616
+ display: none;
617
+ }
618
+
619
+ .autocomplete-allowed-user, .autocomplete-override {
620
+ list-style: none;
621
+ padding-left: 10px;
622
+ }
623
+
624
+ .plugin-suggestion{
625
+ white-space: nowrap;
626
+ }
627
+
628
+ .toggle-container{
629
+ padding-right: 0;
630
+ width: 55px;
631
+ }
632
+
633
+ .toggle-label {
634
+ text-align: left !important;
635
+ }
@@ -23,6 +23,25 @@
23
23
  }
24
24
  }
25
25
 
26
+ table.table-colored-rows {
27
+ tr.insert {
28
+ background-color: #dff0d8;
29
+ }
30
+ tr.update {
31
+ background-color: #fcf8e3;
32
+ }
33
+ tr.delete {
34
+ background-color: #f2dede;
35
+ }
36
+
37
+ th, td {
38
+
39
+ &:first-of-type {
40
+ padding-left: 20px;
41
+ }
42
+ }
43
+ }
44
+
26
45
  tr.disabled {
27
46
  background-color: #f5f5f5;
28
47
  }
@@ -16,4 +16,6 @@
16
16
  @import "datatable.less";
17
17
 
18
18
  @import "account.less";
19
- @import "overdue.less";
19
+ @import "overdue.less";
20
+
21
+ @import "audit.less";
@@ -2,4 +2,19 @@ table tr.expired {
2
2
  td {
3
3
  color: #cccccc;
4
4
  }
5
+ }
6
+
7
+ #cancel_subscription_by_date_modal {
8
+ .modal-footer {
9
+ text-align: left;
10
+ padding-bottom: 0;
11
+
12
+ .alert {
13
+ margin-bottom: 0;
14
+
15
+ .label-default {
16
+ color: white;
17
+ }
18
+ }
19
+ }
5
20
  }
@@ -169,7 +169,36 @@
169
169
  position: relative;
170
170
  }
171
171
  .tag-select-box {
172
- width: 170px;
172
+ word-break: keep-all;
173
+ white-space: nowrap;
173
174
  }
174
175
  }
175
176
  }
177
+
178
+ .inline-row-tag-bar{
179
+ padding-left: 10px !important;
180
+
181
+ .tag-bar {
182
+
183
+ .tag-select {
184
+ span {
185
+ padding: 5px;
186
+ border-right: none;
187
+
188
+ i {
189
+ margin: 0 3px;
190
+ font-size: 12px;
191
+
192
+ &.fa-tag {
193
+ font-size: 12px;
194
+ }
195
+ }
196
+ }
197
+ }
198
+ .tag-select-box {
199
+ label {
200
+ white-space: nowrap;
201
+ }
202
+ }
203
+ }
204
+ }
@@ -0,0 +1,24 @@
1
+ class Kaui::AccountCustomFieldsController < Kaui::EngineController
2
+
3
+ def index
4
+ cached_options_for_klient = options_for_klient
5
+ account = Kaui::Account::find_by_id_or_key(params.require(:account_id), true, true, cached_options_for_klient)
6
+ custom_fields = account.all_custom_fields(nil, 'NONE', cached_options_for_klient)
7
+
8
+
9
+ formatter = lambda do |custom_field|
10
+ url_for_object = view_context.url_for_object(custom_field.object_id, custom_field.object_type)
11
+ [
12
+ url_for_object ? view_context.link_to(custom_field.object_id, url_for_object) : custom_field.object_id,
13
+ custom_field.object_type,
14
+ custom_field.name,
15
+ custom_field.value
16
+ ]
17
+ end
18
+ @custom_fields_json = []
19
+ custom_fields.each { |page| @custom_fields_json << formatter.call(page) }
20
+
21
+ @custom_fields_json = @custom_fields_json.to_json
22
+ end
23
+
24
+ end
@@ -1,5 +1,26 @@
1
1
  class Kaui::AccountTagsController < Kaui::EngineController
2
2
 
3
+ def index
4
+ cached_options_for_klient = options_for_klient
5
+ account = Kaui::Account::find_by_id_or_key(params.require(:account_id), true, true, cached_options_for_klient)
6
+ tags = account.all_tags(nil, false, 'NONE', cached_options_for_klient)
7
+
8
+
9
+ formatter = lambda do |tag|
10
+ url_for_object = view_context.url_for_object(tag.object_id, tag.object_type)
11
+ [
12
+ tag.tag_id,
13
+ url_for_object ? view_context.link_to(tag.object_id, url_for_object) : tag.object_id,
14
+ tag.object_type,
15
+ tag.tag_definition_name
16
+ ]
17
+ end
18
+ @tags_json = []
19
+ tags.each { |page| @tags_json << formatter.call(page) }
20
+
21
+ @tags_json = @tags_json.to_json
22
+ end
23
+
3
24
  def edit
4
25
  @account_id = params.require(:account_id)
5
26
 
@@ -38,8 +38,13 @@ class Kaui::AccountsController < Kaui::EngineController
38
38
  end
39
39
 
40
40
  formatter = lambda do |account|
41
+ child_label = ''
42
+ unless account.parent_account_id.nil?
43
+ child_label = account.parent_account_id.nil? ? '' : view_context.content_tag(:span, 'Child', class: ['label', 'label-info', 'account-child-label'])
44
+ end
45
+
41
46
  [
42
- account.parent_account_id.nil? ? 0 : 1,
47
+ child_label,
43
48
  view_context.link_to(account.name || '(not set)', view_context.url_for(:action => :show, :account_id => account.account_id)),
44
49
  view_context.truncate_uuid(account.account_id),
45
50
  account.external_key,
@@ -125,7 +130,7 @@ class Kaui::AccountsController < Kaui::EngineController
125
130
  @payment_methods = wait(fetch_payment_methods_with_details).map { |pm_f| pm_f.execute }.map { |pm_f| wait(pm_f) }.reject { |pm| pm.nil? }
126
131
  @available_tags = wait(fetch_available_tags)
127
132
  @children = wait(fetch_children)
128
- @account_parent = wait(fetch_parent) unless @account.parent_account_id.nil?
133
+ @account_parent = @account.parent_account_id.nil? ? nil : wait(fetch_parent)
129
134
  @email_notification_configuration = wait(fetch_email_notification_configuration) if is_email_notifications_plugin_available
130
135
 
131
136
  @last_transaction_by_payment_method_id = {}
@@ -142,6 +147,27 @@ class Kaui::AccountsController < Kaui::EngineController
142
147
  params.permit!
143
148
  end
144
149
 
150
+ def destroy
151
+ account_id = params.require(:account_id)
152
+ options = params[:options] || []
153
+
154
+ cancel_subscriptions = options.include?('cancel_all_subscriptions')
155
+ writeoff_unpaid_invoices = options.include?('writeoff_unpaid_invoices')
156
+ item_adjust_unpaid_invoices = options.include?('item_adjust_unpaid_invoices')
157
+ cached_options_for_klient = options_for_klient
158
+
159
+ begin
160
+ @account = Kaui::Account::find_by_id_or_key(account_id, false, false, cached_options_for_klient)
161
+ @account.close(cancel_subscriptions, writeoff_unpaid_invoices, item_adjust_unpaid_invoices, current_user.kb_username, nil, nil, cached_options_for_klient );
162
+
163
+ flash[:notice] = "Account #{account_id} successfully closed"
164
+ rescue => e
165
+ flash[:error] = "Error while closing account: #{as_string(e)}"
166
+ end
167
+
168
+ redirect_to account_path(account_id)
169
+ end
170
+
145
171
  def trigger_invoice
146
172
  account_id = params.require(:account_id)
147
173
  target_date = params[:target_date].presence
@@ -171,8 +197,10 @@ class Kaui::AccountsController < Kaui::EngineController
171
197
 
172
198
  # Fetched asynchronously, as it takes time. This also helps with enforcing permissions.
173
199
  def next_invoice_date
174
- next_invoice = Kaui::Invoice.trigger_invoice_dry_run(params.require(:account_id), nil, true, options_for_klient)
175
- render :json => next_invoice ? next_invoice.target_date.to_json : nil
200
+ json_response do
201
+ next_invoice = Kaui::Invoice.trigger_invoice_dry_run(params.require(:account_id), nil, true, options_for_klient)
202
+ next_invoice ? next_invoice.target_date.to_json : nil
203
+ end
176
204
  end
177
205
 
178
206
  def edit
@@ -211,15 +239,16 @@ class Kaui::AccountsController < Kaui::EngineController
211
239
  end
212
240
 
213
241
  def validate_external_key
214
- external_key = params.require(:external_key)
242
+ json_response do
243
+ external_key = params.require(:external_key)
215
244
 
216
- begin
217
- account = Kaui::Account::find_by_external_key(external_key, false, false, options_for_klient)
218
- rescue KillBillClient::API::NotFound
219
- account = nil
245
+ begin
246
+ account = Kaui::Account::find_by_external_key(external_key, false, false, options_for_klient)
247
+ rescue KillBillClient::API::NotFound
248
+ account = nil
249
+ end
250
+ {:is_found => !account.nil?}
220
251
  end
221
- render json: {:is_found => !account.nil?}
222
-
223
252
  end
224
253
 
225
254
  def link_to_parent
@@ -283,10 +312,8 @@ class Kaui::AccountsController < Kaui::EngineController
283
312
  end
284
313
 
285
314
  def events_to_consider
286
- data = Kenui::EmailNotificationService.get_events_to_consider(options_for_klient)
287
-
288
- respond_to do |format|
289
- format.json { render json: { data: data} }
315
+ json_response do
316
+ { data: Kenui::EmailNotificationService.get_events_to_consider(options_for_klient) }
290
317
  end
291
318
  end
292
319
 
@@ -297,7 +324,7 @@ class Kaui::AccountsController < Kaui::EngineController
297
324
 
298
325
  is_available = Kenui::EmailNotificationService.email_notification_plugin_available?(options_for_klient).first
299
326
  return is_available, is_available ? nil : error_message
300
- rescue => e
327
+ rescue
301
328
  return false, error_message
302
329
  end
303
330