kaui 1.4.0 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -1
  3. data/app/assets/javascripts/kaui/kaui.js +8 -2
  4. data/app/assets/stylesheets/kaui/common.less +44 -1
  5. data/app/controllers/kaui/admin_tenants_controller.rb +77 -106
  6. data/app/controllers/kaui/audit_logs_controller.rb +23 -1
  7. data/app/controllers/kaui/charges_controller.rb +1 -1
  8. data/app/controllers/kaui/credits_controller.rb +5 -5
  9. data/app/controllers/kaui/home_controller.rb +2 -2
  10. data/app/controllers/kaui/invoice_items_controller.rb +1 -1
  11. data/app/controllers/kaui/invoices_controller.rb +6 -4
  12. data/app/controllers/kaui/payment_methods_controller.rb +9 -3
  13. data/app/controllers/kaui/payments_controller.rb +1 -1
  14. data/app/controllers/kaui/refunds_controller.rb +2 -2
  15. data/app/controllers/kaui/sessions_controller.rb +6 -0
  16. data/app/controllers/kaui/subscriptions_controller.rb +29 -5
  17. data/app/helpers/kaui/payment_method_helper.rb +5 -3
  18. data/app/helpers/kaui/plugin_helper.rb +9 -48
  19. data/app/helpers/kaui/subscription_helper.rb +5 -4
  20. data/app/models/kaui/admin_tenant.rb +8 -84
  21. data/app/models/kaui/catalog.rb +14 -2
  22. data/app/views/kaui/account_emails/_form.html.erb +1 -1
  23. data/app/views/kaui/accounts/_form.html.erb +1 -1
  24. data/app/views/kaui/admin_tenants/_form_plugin_config.erb +48 -240
  25. data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +6 -6
  26. data/app/views/kaui/admin_tenants/new_catalog.html.erb +16 -15
  27. data/app/views/kaui/bundles/index.html.erb +1 -1
  28. data/app/views/kaui/chargebacks/_form.html.erb +1 -1
  29. data/app/views/kaui/charges/_form.html.erb +1 -1
  30. data/app/views/kaui/credits/_form.html.erb +2 -2
  31. data/app/views/kaui/invoices/show.html.erb +0 -1
  32. data/app/views/kaui/payments/_form.html.erb +1 -1
  33. data/app/views/kaui/payments/_payment_table.html.erb +2 -2
  34. data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
  35. data/app/views/kaui/subscriptions/_form.html.erb +16 -4
  36. data/config/routes.rb +1 -1
  37. data/lib/kaui/version.rb +1 -1
  38. data/test/dummy/config/initializers/cookies_serializer.rb +1 -1
  39. data/test/functional/kaui/admin_tenants_controller_test.rb +2 -22
  40. data/test/functional/kaui/credits_controller_test.rb +3 -3
  41. data/test/functional/kaui/home_controller_test.rb +5 -5
  42. data/test/functional/kaui/subscriptions_controller_test.rb +1 -1
  43. data/test/killbill_test_helper.rb +6 -6
  44. data/test/unit/helpers/kaui/payment_method_helper_test.rb +17 -0
  45. data/test/unit/kaui/admin_tenant_test.rb +10 -47
  46. metadata +8 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b872df3f942d9f2a4e5efc1f1fd93ebb8e37e956
4
- data.tar.gz: f25ca3f933403dea99fd1c776330ec7966c190c4
3
+ metadata.gz: c998eb4ff14442f28a18da7cab14072cc7d19dfc
4
+ data.tar.gz: 660dbac2ba54d6d0c853b63c697587e486a5c2ed
5
5
  SHA512:
6
- metadata.gz: 65ae3a7873e00c75ff89a88b0b44fc9bbd8c02f5e68ced24a4f1eb9a696dbfe9b6c0522d360afc2dde9af93fff0c04f8acb9c717a4e6f8a8b6ba18febda005aa
7
- data.tar.gz: 7e1f005312d0697fb899dee663e7d89af286b2e22242c4ee66488dc2e92d0a873883a67ca7ba158916e6366fa7c462b2f05cac4762ff3af0883593d0d262647c
6
+ metadata.gz: 714a6e0da369b82570551cd082b7fd9b8d62ab18e906756a4194e31dfa5f90d47dd5b8624f5ca070915e45308d31839f451cca5a343895642d50ba47c89d1716
7
+ data.tar.gz: bc72e0c1b8febf3d413d1191e48431a2d330aff546e84493953e0697b043258365973d3fd5d0ea6dddab244b4c9a5d4cc6a92d9ce9e60155cf9663f7acc92b60
data/README.md CHANGED
@@ -11,7 +11,8 @@ 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
- | 1.x.y | 0.20.z |
14
+ | 1.x.y | 0.20.z (Rails 5) |
15
+ | 2.x.y | 0.22.z (Rails 5) |
15
16
 
16
17
  Dependencies
17
18
  ------------
@@ -25,10 +26,32 @@ You can run Kaui locally by using the test/dummy app provided:
25
26
 
26
27
  ```
27
28
  export RAILS_ENV=development
29
+ export DATABASE_URL=mysql://root:killbill@<MySQL Host IP>/killbill
28
30
  bundle install
29
31
  rails db:migrate
30
32
  rails s
31
33
  ```
34
+ If you experience an error of;
35
+
36
+ ```
37
+ You must use Bundler 2 or greater with this lockfile.
38
+ ```
39
+
40
+ Then run the following commands to update your environment.
41
+
42
+ Update Rubygems;
43
+
44
+ ```
45
+ gem update --system
46
+ ```
47
+ Update bundler;
48
+ ```
49
+ gem install bundler
50
+ ```
51
+ Update the Gemfile.lock file;
52
+ ```
53
+ bundler update --bundler
54
+ ```
32
55
 
33
56
  The Kill Bill URL can be configured through the `KILLBILL_URL` environment variable, e.g.
34
57
 
@@ -144,6 +144,7 @@ jQuery(document).ready(function ($) {
144
144
  const VALIDATE_EXTERNAL_KEY = {
145
145
  account: { url: Routes.kaui_engine_accounts_validate_external_key_path(), invalid_msg_class_name: '.account_external_key_invalid_msg' },
146
146
  payment_method: {url: Routes.kaui_engine_payment_methods_validate_external_key_path(), invalid_msg_class_name: '.payment_method_external_key_invalid_msg'},
147
+ bundle: {url: Routes.kaui_engine_subscriptions_validate_bundle_external_key_path(), invalid_msg_class_name: '.subscription_bundle_external_key_invalid_msg'},
147
148
  subscription: {url: Routes.kaui_engine_subscriptions_validate_external_key_path(), invalid_msg_class_name: '.subscription_external_key_invalid_msg'}
148
149
  }
149
150
 
@@ -157,8 +158,13 @@ jQuery(document).ready(function ($) {
157
158
  validate_external_key($(this).val(),'payment_method');
158
159
  });
159
160
 
160
- validate_external_key($('#external_key').val(),'subscription');
161
- $('#external_key').on('change', function(e){
161
+ validate_external_key($('#bundle_external_key').val(),'bundle');
162
+ $('#bundle_external_key').on('change', function(e){
163
+ validate_external_key($(this).val(),'bundle');
164
+ });
165
+
166
+ validate_external_key($('#subscription_external_key').val(),'subscription');
167
+ $('#subscription_external_key').on('change', function(e){
162
168
  validate_external_key($(this).val(),'subscription');
163
169
  });
164
170
 
@@ -717,4 +717,47 @@ form[id^="new_tag_definition"] {
717
717
 
718
718
  .switch-tenant-active {
719
719
  color: #00919d;
720
- }
720
+ }
721
+
722
+ /* Required for https://github.com/killbill/killbill-admin-ui/issues/262 */
723
+ .ui-autocomplete {
724
+ position: absolute;
725
+ z-index: 1000;
726
+ float: left;
727
+ display: none;
728
+ min-width: 160px;
729
+ padding: 4px 0;
730
+ margin: 2px 0 0 0;
731
+ list-style: none;
732
+ background-color: #ffffff;
733
+ border-color: rgba(0, 0, 0, 0.2);
734
+ border-style: solid;
735
+ border-width: 1px;
736
+ border-radius: 5px;
737
+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
738
+ background-clip: padding-box;
739
+
740
+ .ui-menu-item {
741
+ display: block;
742
+ padding: 3px 15px;
743
+ clear: both;
744
+ font-weight: normal;
745
+ line-height: 18px;
746
+ color: #555555;
747
+ white-space: nowrap;
748
+
749
+ .ui-state-active, .ui-state-hover {
750
+ color: #ffffff;
751
+ text-decoration: none;
752
+ background-color: #0088cc;
753
+ border-radius: 0px;
754
+ -webkit-border-radius: 0px;
755
+ -moz-border-radius: 0px;
756
+ background-image: none;
757
+ }
758
+ }
759
+ }
760
+
761
+ .ui-helper-hidden-accessible {
762
+ display: none;
763
+ }
@@ -81,12 +81,7 @@ class Kaui::AdminTenantsController < Kaui::EngineController
81
81
  fetch_overdue = promise { Kaui::Overdue::get_overdue_json(options) rescue @overdue = nil }
82
82
  fetch_overdue_xml = promise { Kaui::Overdue::get_tenant_overdue_config('xml', options) rescue @overdue_xml = nil }
83
83
 
84
- plugin_repository = Kaui::AdminTenant::get_plugin_repository
85
- # hack:: replace paypal key with paypal_express, to set configuration and allow the ui to find the right configuration inputs
86
- plugin_repository = plugin_repository.inject({}) { |p, (k,v)| p[k.to_s.sub(/\Apaypal/, 'paypal_express').to_sym] = v; p }
87
-
88
- fetch_plugin_config = promise { Kaui::AdminTenant::get_oss_plugin_info(plugin_repository) }
89
- fetch_tenant_plugin_config = promise { Kaui::AdminTenant::get_tenant_plugin_config(plugin_repository, options) }
84
+ fetch_tenant_plugin_config = promise { Kaui::AdminTenant::get_tenant_plugin_config(options) }
90
85
 
91
86
  @catalog_versions = []
92
87
  wait(fetch_catalog_versions).each_with_index do |effective_date, idx|
@@ -98,7 +93,6 @@ class Kaui::AdminTenantsController < Kaui::EngineController
98
93
 
99
94
  @overdue = wait(fetch_overdue)
100
95
  @overdue_xml = wait(fetch_overdue_xml)
101
- @plugin_config = wait(fetch_plugin_config) rescue ''
102
96
  @tenant_plugin_config = wait(fetch_tenant_plugin_config) rescue ''
103
97
 
104
98
  # When reloading page from the view, it sends the last tab that was active
@@ -121,27 +115,15 @@ class Kaui::AdminTenantsController < Kaui::EngineController
121
115
  end
122
116
 
123
117
  def new_catalog
124
- @tenant = safely_find_tenant_by_id(params[:id])
125
-
126
118
  options = tenant_options_for_client
127
- options[:api_key] = @tenant.api_key
128
- options[:api_secret] = @tenant.api_secret
129
-
130
- latest_catalog = Kaui::Catalog::get_catalog_json(true, nil, options)
131
-
132
- @ao_mapping = Kaui::Catalog::build_ao_mapping(latest_catalog)
133
-
134
- @available_base_products = latest_catalog && latest_catalog.products ?
135
- latest_catalog.products.select { |p| p.type == 'BASE' }.map { |p| p.name } : []
136
- @available_ao_products = latest_catalog && latest_catalog.products ?
137
- latest_catalog.products.select { |p| p.type == 'ADD_ON' }.map { |p| p.name } : []
138
- @available_standalone_products = latest_catalog && latest_catalog.products ?
139
- latest_catalog.products.select { |p| p.type == 'STANDALONE' }.map { |p| p.name } : []
140
- @product_categories = [:BASE, :ADD_ON, :STANDALONE]
141
- @billing_period = [:DAILY, :WEEKLY, :BIWEEKLY, :THIRTY_DAYS, :MONTHLY, :QUARTERLY, :BIANNUAL, :ANNUAL, :BIENNIAL]
142
- @time_units = [:UNLIMITED, :DAYS, :WEEKS, :MONTHS, :YEARS]
143
-
144
- @simple_plan = Kaui::SimplePlan.new
119
+ fetch_state_for_new_catalog_screen(options)
120
+ @simple_plan = Kaui::SimplePlan.new({
121
+ :product_category => 'BASE',
122
+ :amount => 0,
123
+ :trial_length => 0,
124
+ :currency => 'USD',
125
+ :billing_period => 'MONTHLY'
126
+ })
145
127
  end
146
128
 
147
129
  def delete_catalog
@@ -189,21 +171,55 @@ class Kaui::AdminTenantsController < Kaui::EngineController
189
171
  end
190
172
 
191
173
  def create_simple_plan
192
- current_tenant = safely_find_tenant_by_id(params[:id])
193
-
194
174
  options = tenant_options_for_client
195
- options[:api_key] = current_tenant.api_key
196
- options[:api_secret] = current_tenant.api_secret
175
+ fetch_state_for_new_catalog_screen(options)
197
176
 
198
177
  simple_plan = params.require(:simple_plan).delete_if { |e, value| value.blank? }
199
178
  # Fix issue in Rails where first entry in the multi-select array is an empty string
200
179
  simple_plan["available_base_products"].reject!(&:blank?) if simple_plan["available_base_products"]
201
180
 
202
- simple_plan = KillBillClient::Model::SimplePlanAttributes.new(simple_plan)
203
-
204
- Kaui::Catalog.add_tenant_catalog_simple_plan(simple_plan, options[:username], nil, comment, options)
181
+ @simple_plan = Kaui::SimplePlan.new(simple_plan)
182
+
183
+ valid = true
184
+ # Validate new simple plan
185
+ # https://github.com/killbill/killbill-admin-ui/issues/247
186
+ if @available_base_products.include?(@simple_plan.plan_id)
187
+ flash.now[:error] = "Error while creating plan: invalid plan name (#{@simple_plan.plan_id} is a BASE product already)"
188
+ valid = false
189
+ elsif @available_ao_products.include?(@simple_plan.plan_id)
190
+ flash.now[:error] = "Error while creating plan: invalid plan name (#{@simple_plan.plan_id} is an ADD_ON product already)"
191
+ valid = false
192
+ elsif @available_standalone_products.include?(@simple_plan.plan_id)
193
+ flash.now[:error] = "Error while creating plan: invalid plan name (#{@simple_plan.plan_id} is a STANDALONE product already)"
194
+ valid = false
195
+ elsif @all_plans.include?(@simple_plan.product_name)
196
+ flash.now[:error] = "Error while creating plan: invalid product name (#{@simple_plan.product_name} is a plan name already)"
197
+ valid = false
198
+ elsif @all_plans.include?(@simple_plan.plan_id)
199
+ flash.now[:error] = "Error while creating plan: plan #{@simple_plan.plan_id} already exists"
200
+ valid = false
201
+ elsif @available_base_products.include?(@simple_plan.product_name) && @simple_plan.product_category != 'BASE'
202
+ flash.now[:error] = "Error while creating plan: product #{@simple_plan.product_name} is a BASE product"
203
+ valid = false
204
+ elsif @available_ao_products.include?(@simple_plan.product_name) && @simple_plan.product_category != 'ADD_ON'
205
+ flash.now[:error] = "Error while creating plan: product #{@simple_plan.product_name} is an ADD_ON product"
206
+ valid = false
207
+ elsif @available_standalone_products.include?(@simple_plan.product_name) && @simple_plan.product_category != 'STANDALONE'
208
+ flash.now[:error] = "Error while creating plan: product #{@simple_plan.product_name} is a STANDALONE product"
209
+ valid = false
210
+ end
205
211
 
206
- redirect_to admin_tenant_path(current_tenant.id), :notice => 'Catalog plan was successfully added'
212
+ if valid
213
+ begin
214
+ Kaui::Catalog.add_tenant_catalog_simple_plan(@simple_plan, options[:username], nil, comment, options)
215
+ redirect_to admin_tenant_path(@tenant.id), :notice => 'Catalog plan was successfully added'
216
+ rescue => e
217
+ flash.now[:error] = "Error while creating plan: #{as_string(e)}"
218
+ render :action => :new_catalog
219
+ end
220
+ else
221
+ render :action => :new_catalog
222
+ end
207
223
  end
208
224
 
209
225
  def new_overdue_config
@@ -307,6 +323,8 @@ class Kaui::AdminTenantsController < Kaui::EngineController
307
323
 
308
324
  if plugin_properties.blank?
309
325
  flash[:error] = 'Plugin properties cannot be blank'
326
+ elsif plugin_name.blank?
327
+ flash[:error] = 'Plugin name cannot be blank'
310
328
  else
311
329
  plugin_config = Kaui::AdminTenant.format_plugin_config(plugin_key, plugin_type, plugin_properties)
312
330
 
@@ -314,7 +332,7 @@ class Kaui::AdminTenantsController < Kaui::EngineController
314
332
  flash[:notice] = 'Config for plugin was successfully uploaded'
315
333
  end
316
334
 
317
- redirect_to admin_tenant_path(current_tenant.id)
335
+ redirect_to admin_tenant_path(current_tenant.id, :active_tab => 'PluginConfig')
318
336
  end
319
337
 
320
338
  def remove_allowed_user
@@ -406,28 +424,6 @@ class Kaui::AdminTenantsController < Kaui::EngineController
406
424
  end
407
425
  end
408
426
 
409
- def suggest_plugin_name
410
- json_response do
411
- message = nil
412
- entered_plugin_name = params.require(:plugin_name)
413
- plugin_repository = view_context.plugin_repository
414
-
415
- found_plugin, weights = fuzzy_match(entered_plugin_name, plugin_repository)
416
-
417
- if weights.size > 0
418
- plugin_anchor = view_context.link_to(weights[0][:plugin_name], '#', id: 'suggested',
419
- data: {
420
- plugin_name: weights[0][:plugin_name],
421
- plugin_key: weights[0][:plugin_key],
422
- plugin_type: weights[0][:plugin_type],
423
- })
424
- message = "Similar plugin already installed: '#{plugin_anchor}'" if weights[0][:worth_weight].to_f >= 1.0 && weights[0][:installed]
425
- message = "Did you mean '#{plugin_anchor}'?" if weights[0][:worth_weight].to_f < 1.0 || !weights[0][:installed]
426
- end
427
- { suggestion: message, plugin: found_plugin }
428
- end
429
- end
430
-
431
427
  def switch_tenant
432
428
  tenant = Kaui::Tenant.find_by_kb_tenant_id(params.require(:kb_tenant_id))
433
429
 
@@ -441,6 +437,29 @@ class Kaui::AdminTenantsController < Kaui::EngineController
441
437
 
442
438
  private
443
439
 
440
+ # Share code to handle render on error
441
+ def fetch_state_for_new_catalog_screen(options)
442
+ @tenant = safely_find_tenant_by_id(params[:id])
443
+
444
+ options[:api_key] = @tenant.api_key
445
+ options[:api_secret] = @tenant.api_secret
446
+
447
+ latest_catalog = Kaui::Catalog::get_catalog_json(true, nil, options)
448
+ @all_plans = latest_catalog ? (latest_catalog.products || []).map(&:plans).flatten.map(&:name) : []
449
+
450
+ @ao_mapping = Kaui::Catalog::build_ao_mapping(latest_catalog)
451
+
452
+ @available_base_products = latest_catalog && latest_catalog.products ?
453
+ latest_catalog.products.select { |p| p.type == 'BASE' }.map { |p| p.name } : []
454
+ @available_ao_products = latest_catalog && latest_catalog.products ?
455
+ latest_catalog.products.select { |p| p.type == 'ADD_ON' }.map { |p| p.name } : []
456
+ @available_standalone_products = latest_catalog && latest_catalog.products ?
457
+ latest_catalog.products.select { |p| p.type == 'STANDALONE' }.map { |p| p.name } : []
458
+ @product_categories = [:BASE, :ADD_ON, :STANDALONE]
459
+ @billing_period = [:DAILY, :WEEKLY, :BIWEEKLY, :THIRTY_DAYS, :MONTHLY, :QUARTERLY, :BIANNUAL, :ANNUAL, :BIENNIAL]
460
+ @time_units = [:UNLIMITED, :DAYS, :WEEKS, :MONTHS, :YEARS]
461
+ end
462
+
444
463
  def safely_find_tenant_by_id(tenant_id)
445
464
  tenant = Kaui::Tenant.find_by_id(tenant_id)
446
465
  raise ActiveRecord::RecordNotFound.new('Could not find tenant ' + tenant_id) unless retrieve_tenants_for_current_user.include?(tenant.kb_tenant_id)
@@ -473,54 +492,6 @@ class Kaui::AdminTenantsController < Kaui::EngineController
473
492
  data.to_s.split(/(?=[A-Z])|(?=[_])|(?=[-])|(?=[ ])/).select {|member| !member.gsub(/[_-]/,'').strip.empty?}.map { |member| member.gsub(/[_-]/,'').strip.downcase }
474
493
  end
475
494
 
476
- def fuzzy_match(entered_plugin_name, plugin_repository)
477
- splitted_entered_plugin_name = split_camel_dash_underscore_space(entered_plugin_name)
478
- worth_of_non_words = 0.5 / splitted_entered_plugin_name.size.to_i
479
-
480
- weights = []
481
-
482
- plugin_repository.each do |plugin|
483
- return plugin, [] if plugin[:plugin_name] == entered_plugin_name || plugin[:plugin_key] == entered_plugin_name
484
- weight = { :plugin_name => plugin[:plugin_name], :plugin_key => plugin[:plugin_key],
485
- :plugin_type => plugin[:plugin_type], :installed => plugin[:installed], :worth_weight => 0.0 }
486
-
487
- splitted_plugin_name = split_camel_dash_underscore_space(plugin[:plugin_name])
488
- splitted_entered_plugin_name.each do |entered|
489
- if splitted_plugin_name.include?(entered)
490
- weight[:worth_weight] = weight[:worth_weight] + 1.0
491
- end
492
-
493
- splitted_plugin_name.each do |splitted|
494
- if entered.chars.all? { |ch| splitted.include?(ch) }
495
- weight[:worth_weight] = weight[:worth_weight] + worth_of_non_words
496
- break
497
- end
498
- end
499
-
500
- # perform a plugin key search, if weight is zero
501
- next unless weight[:worth_weight] == 0
502
- splitted_plugin_key = split_camel_dash_underscore_space(plugin[:plugin_key])
503
-
504
- if splitted_plugin_key.include?(entered)
505
- weight[:worth_weight] = weight[:worth_weight] + 1.0
506
- end
507
-
508
- splitted_plugin_key.each do |splitted|
509
- if entered.chars.all? { |ch| splitted.include?(ch) }
510
- weight[:worth_weight] = weight[:worth_weight] + worth_of_non_words
511
- break
512
- end
513
- end
514
- end
515
-
516
- weights << weight if weight[:worth_weight] > 0
517
-
518
- end
519
-
520
- weights.sort! { |a,b| b[:worth_weight] <=> a[:worth_weight] } if weights.size > 1
521
- return nil, weights
522
- end
523
-
524
495
  def fetch_catalog_xml(tenant_id, effective_date)
525
496
  current_tenant = safely_find_tenant_by_id(tenant_id)
526
497
 
@@ -1,5 +1,5 @@
1
1
  class Kaui::AuditLogsController < Kaui::EngineController
2
- OBJECT_WITH_HISTORY = %w[ACCOUNT ACCOUNT_EMAIL CUSTOM_FIELD PAYMENT_ATTEMPT PAYMENT PAYMENT_METHOD TRANSACTION TAG TAG_DEFINITION]
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]
3
3
 
4
4
  def index
5
5
  cached_options_for_klient = options_for_klient
@@ -57,8 +57,25 @@ class Kaui::AuditLogsController < Kaui::EngineController
57
57
  elsif object_type == 'ACCOUNT_EMAIL'
58
58
  account = Kaui::Account::find_by_id_or_key(account_id, false, false, cached_options_for_klient)
59
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)
60
65
  elsif object_type == 'CUSTOM_FIELD'
61
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
+ =end
78
+ audit_logs_with_history = invoice_payment.audit_logs_with_history(cached_options_for_klient)
62
79
  elsif object_type == 'PAYMENT_ATTEMPT'
63
80
  audit_logs_with_history = Kaui::Payment::attempt_audit_logs_with_history(object_id, cached_options_for_klient)
64
81
  elsif object_type == 'PAYMENT'
@@ -67,6 +84,11 @@ class Kaui::AuditLogsController < Kaui::EngineController
67
84
  elsif object_type == 'PAYMENT_METHOD'
68
85
  payment_method = Kaui::PaymentMethod::find_by_id(object_id, false, cached_options_for_klient)
69
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)
70
92
  elsif object_type == 'TRANSACTION'
71
93
  audit_logs_with_history = Kaui::Transaction::new({:transaction_id => object_id}).audit_logs_with_history(cached_options_for_klient)
72
94
  elsif object_type == 'TAG'
@@ -5,7 +5,7 @@ class Kaui::ChargesController < Kaui::EngineController
5
5
  amount = params[:amount]
6
6
 
7
7
  if invoice_id.present?
8
- @invoice = Kaui::Invoice.find_by_id(invoice_id, true, 'NONE', options_for_klient)
8
+ @invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
9
9
  amount ||= @invoice.balance
10
10
  currency = @invoice.currency
11
11
  else
@@ -5,7 +5,7 @@ class Kaui::CreditsController < Kaui::EngineController
5
5
  amount = params[:amount]
6
6
 
7
7
  if invoice_id.present?
8
- @invoice = Kaui::Invoice.find_by_id(invoice_id, true, 'NONE', options_for_klient)
8
+ @invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
9
9
  amount ||= @invoice.balance
10
10
  currency = @invoice.currency
11
11
  else
@@ -13,7 +13,7 @@ class Kaui::CreditsController < Kaui::EngineController
13
13
  currency = params[:currency] || 'USD'
14
14
  end
15
15
 
16
- @credit = Kaui::Credit.new(:account_id => params.require(:account_id), :invoice_id => invoice_id, :credit_amount => amount, :currency => currency)
16
+ @credit = Kaui::Credit.new(:account_id => params.require(:account_id), :invoice_id => invoice_id, :amount => amount, :currency => currency)
17
17
  end
18
18
 
19
19
  def create
@@ -23,13 +23,13 @@ class Kaui::CreditsController < Kaui::EngineController
23
23
  # No need to show the newly created invoice for account level credits
24
24
  should_redirect_to_invoice = credit.invoice_id.present?
25
25
 
26
- credit = credit.create(true, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
26
+ credits = credit.create(true, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
27
27
  flash[:notice] = 'Credit was successfully created'
28
28
 
29
29
  if should_redirect_to_invoice
30
- redirect_to kaui_engine.account_invoice_path(credit.account_id, credit.invoice_id)
30
+ redirect_to kaui_engine.account_invoice_path(credits[0].account_id, credits[0].invoice_id)
31
31
  else
32
- redirect_to kaui_engine.account_path(credit.account_id)
32
+ redirect_to kaui_engine.account_path(credits[0].account_id)
33
33
  end
34
34
  end
35
35
  end