kaui 1.4.1 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -5
  3. data/app/assets/javascripts/kaui/kaui.js +9 -3
  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/bundles_controller.rb +4 -0
  8. data/app/controllers/kaui/charges_controller.rb +1 -1
  9. data/app/controllers/kaui/credits_controller.rb +5 -5
  10. data/app/controllers/kaui/engine_controller_util.rb +2 -1
  11. data/app/controllers/kaui/home_controller.rb +2 -2
  12. data/app/controllers/kaui/invoice_items_controller.rb +1 -1
  13. data/app/controllers/kaui/invoices_controller.rb +24 -4
  14. data/app/controllers/kaui/payment_methods_controller.rb +9 -3
  15. data/app/controllers/kaui/payments_controller.rb +1 -1
  16. data/app/controllers/kaui/refunds_controller.rb +2 -2
  17. data/app/controllers/kaui/sessions_controller.rb +6 -0
  18. data/app/controllers/kaui/subscriptions_controller.rb +29 -5
  19. data/app/helpers/kaui/payment_method_helper.rb +5 -3
  20. data/app/helpers/kaui/plugin_helper.rb +9 -48
  21. data/app/helpers/kaui/subscription_helper.rb +26 -9
  22. data/app/models/kaui/admin_tenant.rb +8 -84
  23. data/app/models/kaui/catalog.rb +28 -2
  24. data/app/views/kaui/account_emails/_form.html.erb +1 -1
  25. data/app/views/kaui/accounts/_form.html.erb +1 -1
  26. data/app/views/kaui/admin_tenants/_form_plugin_config.erb +48 -240
  27. data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +2 -2
  28. data/app/views/kaui/admin_tenants/new_catalog.html.erb +16 -15
  29. data/app/views/kaui/bundles/index.html.erb +2 -2
  30. data/app/views/kaui/chargebacks/_form.html.erb +1 -1
  31. data/app/views/kaui/charges/_form.html.erb +1 -1
  32. data/app/views/kaui/credits/_form.html.erb +2 -2
  33. data/app/views/kaui/invoices/_invoice_table.html.erb +2 -2
  34. data/app/views/kaui/invoices/show.html.erb +1 -1
  35. data/app/views/kaui/payments/_form.html.erb +1 -1
  36. data/app/views/kaui/payments/_payment_table.html.erb +2 -2
  37. data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
  38. data/app/views/kaui/subscriptions/_form.html.erb +16 -4
  39. data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +3 -3
  40. data/config/routes.rb +1 -1
  41. data/lib/kaui/version.rb +1 -1
  42. data/test/dummy/config/database.yml +2 -2
  43. data/test/dummy/config/initializers/cookies_serializer.rb +1 -1
  44. data/test/functional/kaui/admin_tenants_controller_test.rb +2 -22
  45. data/test/functional/kaui/credits_controller_test.rb +3 -3
  46. data/test/functional/kaui/home_controller_test.rb +5 -5
  47. data/test/functional/kaui/subscriptions_controller_test.rb +1 -1
  48. data/test/killbill_test_helper.rb +6 -6
  49. data/test/unit/helpers/kaui/payment_method_helper_test.rb +17 -0
  50. data/test/unit/kaui/admin_tenant_test.rb +10 -47
  51. metadata +94 -78
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e742130946b631b91580c426cdcb8ee8dfd07d5a
4
- data.tar.gz: fdbf1ab93ef8dc3e1a7680f51779cdf1a958fe9d
3
+ metadata.gz: 062f8cf3943a8a8cae8f80490cac4c2545ed68bd
4
+ data.tar.gz: 398c6df309bdd8bf44eaddcac3273e9cfc394d17
5
5
  SHA512:
6
- metadata.gz: 2f27c656b5b034092471fb10989c134fc0bd6cbbe7694a75fe8461c81459bbf3f8d83145cfe6c130e025218ecfa39284fcc3bb80d378417db33c1c3809c15dba
7
- data.tar.gz: 4cf31c31fec9d8071830403b990187e282221b6c6c2d2f6fb861400c9cebf33c240f0045988b52ebe83bc970c409b5364026a4bcae4815c2fbe4228c14493238
6
+ metadata.gz: df121d5c0caa28f819c2678c7abf61a4ed161ee16dc6f047f7e6ca0279348f682de5dd8ce57e6bd31ad70f164892a44d911f22da2eaaa3689c4bf06dd560b302
7
+ data.tar.gz: 405d0913456d27232ee1518fb1637efc35423f62f5a948e3312e817c2547fe8f04f38029b5e8d4785522480ef261853640bddf728143e3f84a45408ff26b1219
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
  ------------
@@ -21,13 +22,15 @@ Ruby 2.4.2+ or JRuby 9.1.14.0+ required.
21
22
  Running Kaui locally
22
23
  ---------------------
23
24
 
25
+ Note: use Ruby, not JRuby, for running the app locally.
26
+
24
27
  You can run Kaui locally by using the test/dummy app provided:
25
28
 
26
29
  ```
27
- export RAILS_ENV=development
30
+ export RAILS_ENV=development DB_HOST=127.0.0.1 DB_USER=root DB_PASSWORD=root DB_PORT=3306
28
31
  bundle install
29
- rails db:migrate
30
- rails s
32
+ bundle exec rails db:migrate
33
+ bundle exec rails s
31
34
  ```
32
35
 
33
36
  The Kill Bill URL can be configured through the `KILLBILL_URL` environment variable, e.g.
@@ -91,7 +94,19 @@ Alternatively, you can run the `kaui` script under `bin` by setting your loadpat
91
94
  Releases
92
95
  ========
93
96
 
94
- The releases are done using Jruby and require the following property `export JRUBY_OPTS='--2.0 -J-Xmx1024m'`
97
+ To trigger a release, run (update `patch` as needed):
98
+
99
+ ```
100
+ bundle exec gem bump -c -p -t -v patch
101
+ ```
102
+
103
+ This will:
104
+
105
+ * Update the `version.rb` file
106
+ * Commit the changes
107
+ * Create the new tag and push the changes
108
+
109
+ GitHub Actions will automatically push the new gem to Rubygems.
95
110
 
96
111
  Multi-Tenancy
97
112
  =============
@@ -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
 
@@ -199,7 +205,7 @@ jQuery(document).ready(function ($) {
199
205
  return;
200
206
  }
201
207
 
202
- var message = 'Request Status: ' + jqxhr.status + ', Status Text: ' + jqxhr.statusText + ': ' + getMessageFromResponse(jqxhr);
208
+ var message = 'Request error: ' + getMessageFromResponse(jqxhr);
203
209
 
204
210
  if (jqxhr.status == 200) {
205
211
  message = thrownError.message == undefined ? thrownError : thrownError.message;
@@ -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
+ audit_logs_with_history = invoice_payment.audit_logs_with_history(cached_options_for_klient)
78
+ =end
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'
@@ -31,6 +31,10 @@ class Kaui::BundlesController < Kaui::EngineController
31
31
  @available_tags = wait(fetch_available_tags)
32
32
  @available_subscription_tags = wait(fetch_available_subscription_tags)
33
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
+
34
38
  @subscription = {}
35
39
  @bundles.each do |bundle|
36
40
  bundle.subscriptions.each do |sub|