kaui 2.2.1 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/app/assets/config/kaui_manifest.js +2 -44
  4. data/app/assets/javascripts/application.js +12 -0
  5. data/app/assets/javascripts/kaui/kaui.js +7 -452
  6. data/app/assets/javascripts/kaui/kaui_override.js +441 -0
  7. data/app/assets/stylesheets/application.css +23 -0
  8. data/app/assets/stylesheets/kaui/account.css +34 -0
  9. data/app/assets/stylesheets/kaui/audit.css +19 -0
  10. data/app/assets/stylesheets/kaui/common.css +550 -0
  11. data/app/assets/stylesheets/kaui/datatable.css +71 -0
  12. data/app/assets/stylesheets/kaui/header.css +129 -0
  13. data/app/assets/stylesheets/kaui/home.css +72 -0
  14. data/app/assets/stylesheets/kaui/invoice.css +37 -0
  15. data/app/assets/stylesheets/kaui/kaui.css +152 -0
  16. data/app/assets/stylesheets/kaui/overdue.css +7 -0
  17. data/app/assets/stylesheets/kaui/payment.css +28 -0
  18. data/app/assets/stylesheets/kaui/subscription.css +15 -0
  19. data/app/assets/stylesheets/kaui/tags.css +137 -0
  20. data/app/assets/stylesheets/kaui/timeline.css +5 -0
  21. data/app/assets/stylesheets/kaui/tooltip.css +16 -0
  22. data/app/controllers/kaui/account_tags_controller.rb +1 -1
  23. data/app/controllers/kaui/accounts_controller.rb +1 -1
  24. data/app/controllers/kaui/admin_allowed_users_controller.rb +1 -1
  25. data/app/controllers/kaui/admin_tenants_controller.rb +5 -5
  26. data/app/controllers/kaui/audit_logs_controller.rb +1 -1
  27. data/app/controllers/kaui/bundle_tags_controller.rb +1 -1
  28. data/app/controllers/kaui/charges_controller.rb +1 -1
  29. data/app/controllers/kaui/credits_controller.rb +1 -1
  30. data/app/controllers/kaui/engine_controller_util.rb +4 -6
  31. data/app/controllers/kaui/home_controller.rb +29 -20
  32. data/app/controllers/kaui/invoice_tags_controller.rb +2 -2
  33. data/app/controllers/kaui/invoices_controller.rb +6 -1
  34. data/app/controllers/kaui/payment_methods_controller.rb +1 -1
  35. data/app/controllers/kaui/subscriptions_controller.rb +9 -8
  36. data/app/controllers/kaui/transactions_controller.rb +1 -1
  37. data/app/helpers/kaui/date_helper.rb +1 -1
  38. data/app/helpers/kaui/object_helper.rb +16 -1
  39. data/app/helpers/kaui/plugin_helper.rb +1 -1
  40. data/app/helpers/kaui/uuid_helper.rb +2 -2
  41. data/app/models/kaui/account_email.rb +3 -3
  42. data/app/models/kaui/admin.rb +3 -3
  43. data/app/models/kaui/admin_tenant.rb +1 -1
  44. data/app/models/kaui/catalog.rb +2 -2
  45. data/app/models/kaui/invoice_payment.rb +1 -1
  46. data/app/models/kaui/killbill_authenticatable.rb +2 -2
  47. data/app/models/kaui/overdue.rb +2 -2
  48. data/app/models/kaui/tag.rb +2 -2
  49. data/app/models/kaui/tag_definition.rb +1 -1
  50. data/app/views/kaui/accounts/_billing_info.html.erb +2 -4
  51. data/app/views/kaui/accounts/_form.html.erb +3 -3
  52. data/app/views/kaui/accounts/index.html.erb +0 -1
  53. data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +5 -5
  54. data/app/views/kaui/home/_advanced_search_modal.html.erb +22 -1
  55. data/app/views/kaui/invoices/show.html.erb +2 -1
  56. data/app/views/kaui/layouts/kaui_header.html.erb +2 -18
  57. data/app/views/kaui/refunds/_form.html.erb +50 -2
  58. data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +1 -1
  59. data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
  60. data/app/views/kaui/subscriptions/_form.html.erb +1 -1
  61. data/app/views/kaui/subscriptions/edit_bcd.erb +1 -1
  62. data/app/views/kaui/tag_definitions/_form.html.erb +1 -2
  63. data/config/initializers/killbill_authenticatable.rb +2 -2
  64. data/config/routes.rb +1 -0
  65. data/lib/kaui/engine.rb +1 -4
  66. data/lib/kaui/version.rb +1 -1
  67. data/lib/kaui.rb +10 -1
  68. metadata +34 -135
  69. data/app/assets/javascripts/jquery.spin.js +0 -76
  70. data/app/assets/javascripts/kaui_application.js +0 -25
  71. data/app/assets/javascripts/spin.js +0 -76
  72. data/app/assets/stylesheets/bootstrap_and_overrides.scss +0 -240
  73. data/app/assets/stylesheets/kaui/account.scss +0 -52
  74. data/app/assets/stylesheets/kaui/audit.scss +0 -42
  75. data/app/assets/stylesheets/kaui/common.scss +0 -765
  76. data/app/assets/stylesheets/kaui/datatable.scss +0 -115
  77. data/app/assets/stylesheets/kaui/header.scss +0 -197
  78. data/app/assets/stylesheets/kaui/home.scss +0 -89
  79. data/app/assets/stylesheets/kaui/invoice.scss +0 -58
  80. data/app/assets/stylesheets/kaui/kaui.scss +0 -265
  81. data/app/assets/stylesheets/kaui/kaui_bootstrap.scss +0 -3
  82. data/app/assets/stylesheets/kaui/overdue.scss +0 -11
  83. data/app/assets/stylesheets/kaui/payment.scss +0 -43
  84. data/app/assets/stylesheets/kaui/subscription.scss +0 -27
  85. data/app/assets/stylesheets/kaui/tags.scss +0 -208
  86. data/app/assets/stylesheets/kaui/timeline.scss +0 -7
  87. data/app/assets/stylesheets/kaui/tooltip.scss +0 -15
  88. data/app/assets/stylesheets/kaui_application.css +0 -12
@@ -15,7 +15,7 @@ module Kaui
15
15
  currency = params[:currency] || 'USD'
16
16
  end
17
17
 
18
- @charge = Kaui::InvoiceItem.new(account_id: params.require(:account_id), invoice_id: invoice_id, amount: amount, currency: currency)
18
+ @charge = Kaui::InvoiceItem.new(account_id: params.require(:account_id), invoice_id:, amount:, currency:)
19
19
  end
20
20
 
21
21
  def create
@@ -15,7 +15,7 @@ module Kaui
15
15
  currency = params[:currency] || 'USD'
16
16
  end
17
17
 
18
- @credit = Kaui::Credit.new(account_id: params.require(:account_id), invoice_id: invoice_id, amount: amount, currency: currency)
18
+ @credit = Kaui::Credit.new(account_id: params.require(:account_id), invoice_id:, amount:, currency:)
19
19
  end
20
20
 
21
21
  def create
@@ -37,7 +37,7 @@ module Kaui
37
37
  pages ||= []
38
38
 
39
39
  # Until we support server-side sorting
40
- ordering = ((params[:order] || {})[:'0'] || {})
40
+ ordering = (params[:order] || {})[:'0'] || {}
41
41
  ordering_column = (ordering[:column] || 0).to_i
42
42
  ordering_dir = ordering[:dir] || 'asc'
43
43
  unless search_key.nil?
@@ -53,17 +53,15 @@ module Kaui
53
53
  pages.each { |page| json[:data] << formatter.call(page) }
54
54
 
55
55
  respond_to do |format|
56
- format.json { render json: json }
56
+ format.json { render json: }
57
57
  end
58
58
  end
59
59
 
60
- def promise
60
+ def promise(&)
61
61
  # Evaluation starts immediately
62
62
  ::Concurrent::Promises.future do
63
63
  # https://github.com/rails/rails/issues/26847
64
- Rails.application.executor.wrap do
65
- yield
66
- end
64
+ Rails.application.executor.wrap(&)
67
65
  end
68
66
  end
69
67
 
@@ -46,21 +46,29 @@ module Kaui
46
46
  elsif true?(fast)
47
47
  redirect_to account_path(account.account_id) and return
48
48
  else
49
- redirect_to accounts_path(q: search_query, fast: fast) and return
49
+ redirect_to accounts_path(q: search_query, fast:) and return
50
50
  end
51
51
  end
52
52
  end
53
53
 
54
54
  def invoice_search(search_query, search_by = nil, fast = 0, options = {})
55
- if search_by == 'ID'
55
+ case search_by
56
+ when 'ID'
56
57
  begin
57
58
  invoice = Kaui::Invoice.find_by_id(search_query, 'NONE', options)
58
59
  redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return
59
60
  rescue KillBillClient::API::NotFound => _e
60
61
  search_error("No invoice matches \"#{search_query}\"")
61
62
  end
62
- elsif search_by == 'EXTERNAL_KEY'
63
- unsupported_external_key_search('INVOICE')
63
+ when 'EXTERNAL_KEY'
64
+ unsupported_search_field('INVOICE', search_by)
65
+ when 'NUMBER'
66
+ begin
67
+ invoice = Kaui::Invoice.find_by_number(search_query, 'NONE', options)
68
+ redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return
69
+ rescue KillBillClient::API::NotFound, KillBillClient::API::BadRequest => _e
70
+ search_error("No invoice matches \"#{search_query}\"")
71
+ end
64
72
  else
65
73
  invoice = Kaui::Invoice.list_or_search(search_query, 0, 1, options).first
66
74
  if invoice.blank?
@@ -73,7 +81,7 @@ module Kaui
73
81
  elsif true?(fast)
74
82
  redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return
75
83
  else
76
- redirect_to account_invoices_path(account_id: invoice.account_id, q: search_query, fast: fast) and return
84
+ redirect_to account_invoices_path(account_id: invoice.account_id, q: search_query, fast:) and return
77
85
  end
78
86
  end
79
87
  end
@@ -100,7 +108,7 @@ module Kaui
100
108
  elsif true?(fast)
101
109
  redirect_to account_payment_path(payment.account_id, payment.payment_id) and return
102
110
  else
103
- redirect_to account_payments_path(account_id: payment.account_id, q: search_query, fast: fast) and return
111
+ redirect_to account_payments_path(account_id: payment.account_id, q: search_query, fast:) and return
104
112
  end
105
113
  end
106
114
  end
@@ -157,7 +165,7 @@ module Kaui
157
165
  search_error("No credit matches \"#{search_query}\"")
158
166
  end
159
167
  else
160
- unsupported_external_key_search('CREDIT')
168
+ unsupported_search_field('CREDIT', search_by)
161
169
  end
162
170
  end
163
171
 
@@ -167,10 +175,10 @@ module Kaui
167
175
  if custom_field.blank?
168
176
  search_error("No custom field matches \"#{search_query}\"")
169
177
  else
170
- redirect_to custom_fields_path(q: search_query, fast: fast)
178
+ redirect_to custom_fields_path(q: search_query, fast:)
171
179
  end
172
180
  else
173
- unsupported_external_key_search('CUSTOM FIELD')
181
+ unsupported_search_field('CUSTOM FIELD', search_by)
174
182
  end
175
183
  end
176
184
 
@@ -183,7 +191,7 @@ module Kaui
183
191
  search_error("No invoice payment matches \"#{search_query}\"")
184
192
  end
185
193
  else
186
- unsupported_external_key_search('INVOICE PAYMENT')
194
+ unsupported_search_field('INVOICE PAYMENT', search_by)
187
195
  end
188
196
  end
189
197
 
@@ -196,7 +204,7 @@ module Kaui
196
204
  search_error("No subscription matches \"#{search_query}\"")
197
205
  end
198
206
  else
199
- unsupported_external_key_search('SUBSCRIPTION')
207
+ unsupported_search_field('SUBSCRIPTION', search_by)
200
208
  end
201
209
  end
202
210
 
@@ -206,10 +214,10 @@ module Kaui
206
214
  if tag.blank?
207
215
  search_error("No tag matches \"#{search_query}\"")
208
216
  else
209
- redirect_to tags_path(q: search_query, fast: fast)
217
+ redirect_to tags_path(q: search_query, fast:)
210
218
  end
211
219
  else
212
- unsupported_external_key_search('TAG')
220
+ unsupported_search_field('TAG', search_by)
213
221
  end
214
222
  end
215
223
 
@@ -217,29 +225,30 @@ module Kaui
217
225
  if search_by == 'ID'
218
226
  begin
219
227
  Kaui::TagDefinition.find_by_id(search_query, 'NONE', options)
220
- redirect_to tag_definitions_path(q: search_query, fast: fast)
228
+ redirect_to tag_definitions_path(q: search_query, fast:)
221
229
  rescue KillBillClient::API::NotFound => _e
222
230
  search_error("No tag definition matches \"#{search_query}\"")
223
231
  end
224
232
  elsif search_by == 'EXTERNAL_KEY'
225
- unsupported_external_key_search('TAG DEFINITION')
233
+ unsupported_search_field('TAG DEFINITION', search_by)
226
234
  else
227
235
  tag_definition = Kaui::TagDefinition.find_by_name(search_query, 'NONE', options)
228
236
  if tag_definition.blank?
229
237
  begin
230
238
  Kaui::TagDefinition.find_by_id(search_query, 'NONE', options)
231
- redirect_to tag_definitions_path(q: search_query, fast: fast) and return
239
+ redirect_to tag_definitions_path(q: search_query, fast:) and return
232
240
  rescue KillBillClient::API::NotFound => _e
233
241
  search_error("No tag definition matches \"#{search_query}\"")
234
242
  end
235
243
  else
236
- redirect_to tag_definitions_path(q: search_query, fast: fast)
244
+ redirect_to tag_definitions_path(q: search_query, fast:)
237
245
  end
238
246
  end
239
247
  end
240
248
 
241
- def unsupported_external_key_search(object_type)
242
- search_error("\"#{object_type}\": Search by \"EXTERNAL KEY\" is not supported.")
249
+ def unsupported_search_field(object_type, object_field)
250
+ field_name = object_field.gsub('_', ' ')
251
+ search_error("\"#{object_type}\": Search by \"#{field_name}\" is not supported.")
243
252
  end
244
253
 
245
254
  def search_error(message)
@@ -267,7 +276,7 @@ module Kaui
267
276
  '0'
268
277
  end
269
278
 
270
- search_error("\"#{search_by}\" is not a valid search by value") if !search_by.blank? && !%w[ID EXTERNAL_KEY].include?(search_by)
279
+ search_error("\"#{search_by}\" is not a valid search by value") if !search_by.blank? && !search_by.in?(Kaui::ObjectHelper::ADVANCED_SEARCH_OBJECT_FIELDS)
271
280
 
272
281
  [object_type, search_for, search_by, fast]
273
282
  end
@@ -18,7 +18,7 @@ module Kaui
18
18
  invoice_id = params.require(:invoice_id)
19
19
 
20
20
  tags = []
21
- params.each do |tag, _tag_name|
21
+ params.each_key do |tag|
22
22
  tag_info = tag.split('_')
23
23
  next if (tag_info.size != 2) || (tag_info[0] != 'tag')
24
24
 
@@ -26,7 +26,7 @@ module Kaui
26
26
  end
27
27
 
28
28
  Kaui::Tag.set_for_invoice(invoice_id, tags, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
29
- redirect_to kaui_engine.invoice_path(invoice_id, account_id: account_id), notice: 'Invoice tags successfully set'
29
+ redirect_to kaui_engine.invoice_path(invoice_id, account_id:), notice: 'Invoice tags successfully set'
30
30
  end
31
31
  end
32
32
  end
@@ -39,7 +39,7 @@ module Kaui
39
39
  end
40
40
  formatter = lambda do |invoice|
41
41
  row = [view_context.link_to(invoice.invoice_number, view_context.url_for(controller: :invoices, action: :show, account_id: invoice.account_id, id: invoice.invoice_id))]
42
- row += Kaui.invoice_search_columns.call(invoice, view_context)[1]
42
+ row += Kaui.invoice_search_columns.call(invoice, view_context, cached_options_for_klient)[1]
43
43
  row
44
44
  end
45
45
  else
@@ -147,6 +147,11 @@ module Kaui
147
147
  redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id)
148
148
  end
149
149
 
150
+ def restful_show_by_number
151
+ invoice = Kaui::Invoice.find_by_number(params.require(:number), 'NONE', options_for_klient)
152
+ redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id)
153
+ end
154
+
150
155
  def show_html
151
156
  render html: Kaui::Invoice.as_html(params.require(:id), options_for_klient).html_safe
152
157
  end
@@ -47,7 +47,7 @@ module Kaui
47
47
  }
48
48
 
49
49
  @plugin_properties = begin
50
- params[:plugin_properties].values.reject { |item| (item['value'].blank? || item['key'].blank?) }
50
+ params[:plugin_properties].values.reject { |item| item['value'].blank? || item['key'].blank? }
51
51
  rescue StandardError
52
52
  @plugin_properties = nil
53
53
  end
@@ -193,10 +193,11 @@ module Kaui
193
193
  def update_tags
194
194
  subscription_id = params.require(:id)
195
195
  subscription = Kaui::Subscription.find_by_id(subscription_id, options_for_klient)
196
-
197
196
  tags = []
198
- params.each do |tag|
199
- tag_info = tag.split('_')
197
+ params.each_key do |key|
198
+ next unless key.include? 'tag'
199
+
200
+ tag_info = key.split('_')
200
201
  next if (tag_info.size != 2) || (tag_info[0] != 'tag')
201
202
 
202
203
  tags << tag_info[1]
@@ -210,7 +211,7 @@ module Kaui
210
211
 
211
212
  def lookup_bundle_and_plan_details(subscription, base_product_name = nil)
212
213
  if subscription.product_category == 'ADD_ON'
213
- bundle = Kaui::Bundle.find_by_id(@subscription.bundle_id, options_for_klient)
214
+ bundle = Kaui::Bundle.find_by_id(subscription.bundle_id, options_for_klient)
214
215
  if base_product_name.blank?
215
216
  bundle.subscriptions.each do |sub|
216
217
  if sub.product_category == 'BASE'
@@ -222,17 +223,17 @@ module Kaui
222
223
  plans_details = Kaui::Catalog.available_addons(base_product_name, subscription.account_id, options_for_klient)
223
224
  else
224
225
  bundle = nil
225
- plans_details = catalog_plans(subscription.product_category == 'BASE' ? nil : subscription.product_category)
226
+ plans_details = catalog_plans(subscription.product_category == 'BASE' ? nil : subscription.product_category, subscription.account_id)
226
227
  end
227
228
  [bundle, plans_details]
228
229
  end
229
230
 
230
- def catalog_plans(product_category = nil)
231
- return Kaui::Catalog.available_base_plans(@subscription.account_id, options_for_klient) if product_category == 'BASE'
231
+ def catalog_plans(product_category = nil, account_id = nil)
232
+ return Kaui::Catalog.available_base_plans(account_id, options_for_klient) if product_category == 'BASE'
232
233
 
233
234
  options = options_for_klient
234
235
 
235
- catalog = Kaui::Catalog.get_tenant_catalog_json(DateTime.now.to_s, @subscription.account_id, options)
236
+ catalog = Kaui::Catalog.get_tenant_catalog_json(DateTime.now.to_s, account_id, options)
236
237
  return [] if catalog.blank?
237
238
 
238
239
  plans = []
@@ -26,7 +26,7 @@ module Kaui
26
26
  def create
27
27
  transaction = Kaui::Transaction.new(params[:transaction].delete_if { |_key, value| value.blank? })
28
28
 
29
- plugin_properties = params[:plugin_properties].values.reject { |item| (item['value'].blank? || item['key'].blank?) } unless params[:plugin_properties].blank?
29
+ plugin_properties = params[:plugin_properties].values.reject { |item| item['value'].blank? || item['key'].blank? } unless params[:plugin_properties].blank?
30
30
  unless plugin_properties.blank?
31
31
  plugin_properties.map! do |property|
32
32
  KillBillClient::Model::PluginPropertyAttributes.new(property)
@@ -17,7 +17,7 @@ module Kaui
17
17
 
18
18
  # If not, convert into account timezone and return the date part only
19
19
  parsed_date = DateTime.parse(date.to_s).in_time_zone(timezone)
20
- parsed_date.to_s(:date_only)
20
+ parsed_date.to_fs(:date_only)
21
21
  end
22
22
 
23
23
  def truncate_millis(date_s)
@@ -2,6 +2,13 @@
2
2
 
3
3
  module Kaui
4
4
  module ObjectHelper
5
+ ADVANCED_SEARCH_OBJECT_FIELDS = %w[ID EXTERNAL_KEY NUMBER].freeze
6
+ ADVANCED_SEARCH_OBJECT_FIELDS_MAP = {
7
+ # ID is supported by all object types, hence not listed.
8
+ EXTERNAL_KEY: %w[ACCOUNT PAYMENT TRANSACTION BUNDLE],
9
+ NUMBER: %w[INVOICE]
10
+ }.freeze
11
+
5
12
  # Because we don't have access to the account_id, we use the restful_show routes
6
13
  def url_for_object(object_id, object_type)
7
14
  case object_type
@@ -27,7 +34,15 @@ module Kaui
27
34
  end
28
35
 
29
36
  def object_types_for_advanced_search
30
- %i[ACCOUNT BUNDLE INVOICE CREDIT CUSTOM_FIELD INVOICE_PAYMENT INVOICE PAYMENT SUBSCRIPTION TRANSACTION TAG TAG_DEFINITION]
37
+ %i[ACCOUNT BUNDLE INVOICE CREDIT CUSTOM_FIELD INVOICE_PAYMENT PAYMENT SUBSCRIPTION TRANSACTION TAG TAG_DEFINITION]
38
+ end
39
+
40
+ def object_fields_for_advanced_search
41
+ [' '] + ADVANCED_SEARCH_OBJECT_FIELDS
42
+ end
43
+
44
+ def advanced_search_object_fields_map
45
+ ADVANCED_SEARCH_OBJECT_FIELDS_MAP
31
46
  end
32
47
  end
33
48
  end
@@ -21,7 +21,7 @@ module Kaui
21
21
  plugin_key = plugin.plugin_key
22
22
  installed_plugins << {
23
23
  # Unique identifier chosen by the user and used for kpm operations
24
- plugin_key: plugin_key,
24
+ plugin_key:,
25
25
  # Notes:
26
26
  # * plugin.plugin_name comes from kpm and is arbitrary (see Utils.get_plugin_name_from_file_path in the kpm codebase for instance)
27
27
  # * plugin_name here is the plugin name as seen by Kill Bill and is typically defined in the Activator.java (this value is the one that matters for plugin configuration)
@@ -12,10 +12,10 @@ module Kaui
12
12
 
13
13
  def object_id_popover(object_id, placement = 'right', title = nil)
14
14
  content_tag(:span, truncate_uuid(object_id),
15
- id: "#{object_id}-popover", class: 'object-id-popover', title: title,
15
+ id: "#{object_id}-popover", class: 'object-id-popover', title:,
16
16
  data: {
17
17
  id: object_id,
18
- placement: placement
18
+ placement:
19
19
  })
20
20
  end
21
21
  end
@@ -3,17 +3,17 @@
3
3
  module Kaui
4
4
  class AccountEmail < KillBillClient::Model::AccountEmailAttributes
5
5
  def self.find_all_sorted_by_account_id(account_id, audit = 'NONE', options = {})
6
- emails = Kaui::Account.new(account_id: account_id).emails(audit, options)
6
+ emails = Kaui::Account.new(account_id:).emails(audit, options)
7
7
  emails.map { |email| Kaui::AccountEmail.new(email.to_hash) }.sort
8
8
  end
9
9
 
10
10
  def create(user = nil, reason = nil, comment = nil, options = {})
11
- account = Kaui::Account.new(account_id: account_id)
11
+ account = Kaui::Account.new(account_id:)
12
12
  account.add_email(email, user, reason, comment, options)
13
13
  end
14
14
 
15
15
  def destroy(user = nil, reason = nil, comment = nil, options = {})
16
- account = Kaui::Account.new(account_id: account_id)
16
+ account = Kaui::Account.new(account_id:)
17
17
  account.remove_email(email, user, reason, comment, options)
18
18
  end
19
19
 
@@ -27,9 +27,9 @@ module Kaui
27
27
  { transactionStatus: transaction_status }.to_json,
28
28
  {},
29
29
  {
30
- user: user,
31
- reason: reason,
32
- comment: comment
30
+ user:,
31
+ reason:,
32
+ comment:
33
33
  }.merge(options)
34
34
  end
35
35
 
@@ -33,7 +33,7 @@ module Kaui
33
33
 
34
34
  raw_tenant_config.each_with_object({}) do |e, hsh|
35
35
  # Strip prefix '/PLUGIN_CONFIG_'
36
- plugin_name = e.key.gsub!(/PLUGIN_CONFIG_/, '')
36
+ plugin_name = e.key.gsub!('PLUGIN_CONFIG_', '')
37
37
 
38
38
  # Construct simple hash with one property (first value)
39
39
  hsh[plugin_name] = e.values[0]
@@ -35,8 +35,8 @@ module Kaui
35
35
  raise e
36
36
  end
37
37
 
38
- def get_catalog_json(latest, requested_date, options)
39
- catalogs = get_tenant_catalog_json(requested_date, nil, options)
38
+ def get_catalog_json(latest, requested_date, account_id, options)
39
+ catalogs = get_tenant_catalog_json(requested_date, account_id, options)
40
40
  return catalogs.length.positive? ? catalogs[catalogs.length - 1] : nil if latest
41
41
 
42
42
  # Order by latest
@@ -21,7 +21,7 @@ module Kaui
21
21
  result.send("#{attr}=", raw_payment.send(attr))
22
22
  end
23
23
  # Use Kaui::Transaction to benefit from additional fields (e.g next_retry_date)
24
- original_transactions = (result.transactions || [])
24
+ original_transactions = result.transactions || []
25
25
  result.transactions = []
26
26
  original_transactions.each do |transaction|
27
27
  new_transaction = Kaui::Transaction.new
@@ -31,8 +31,8 @@ module Devise
31
31
  # Invoked by the KillbillAuthenticatable strategy to lookup the user
32
32
  # before attempting authentication
33
33
  def find_for_killbill_authentication(kb_username)
34
- find_for_authentication(kb_username: kb_username) ||
35
- new(kb_username: kb_username)
34
+ find_for_authentication(kb_username:) ||
35
+ new(kb_username:)
36
36
  rescue KillBillClient::API::Unauthorized => _e
37
37
  # Multi-Tenancy was enabled, but the tenant_id couldn't be retrieved because of bad credentials
38
38
  nil
@@ -19,7 +19,7 @@ module Kaui
19
19
  state.subscription_cancellation_policy = nil
20
20
  else
21
21
  state.is_disable_entitlement = true
22
- state.subscription_cancellation_policy = state_model['subscription_cancellation_policy'].blank? ? :NONE : state_model['subscription_cancellation_policy'].to_s.gsub!(/POLICY_/, '')
22
+ state.subscription_cancellation_policy = state_model['subscription_cancellation_policy'].blank? ? :NONE : state_model['subscription_cancellation_policy'].to_s.gsub!('POLICY_', '')
23
23
  end
24
24
 
25
25
  if state_model['condition']
@@ -60,7 +60,7 @@ module Kaui
60
60
  attr_accessor :subscription_cancellation
61
61
  end
62
62
  state.subscription_cancellation = if state.is_disable_entitlement
63
- state.subscription_cancellation_policy ? "POLICY_#{state.subscription_cancellation_policy}".to_sym : :NONE
63
+ state.subscription_cancellation_policy ? :"POLICY_#{state.subscription_cancellation_policy}" : :NONE
64
64
  else
65
65
  :NONE
66
66
  end
@@ -13,12 +13,12 @@ module Kaui
13
13
  class << self
14
14
  %i[account bundle subscription invoice].each do |model|
15
15
  define_method "all_for_#{model}" do |model_id, included_deleted, audit, options|
16
- instance = Kaui.const_get(model.to_s.camelize).new("#{model}_id".to_sym => model_id)
16
+ instance = Kaui.const_get(model.to_s.camelize).new("#{model}_id": model_id)
17
17
  instance.tags(included_deleted, audit, options)
18
18
  end
19
19
 
20
20
  define_method "set_for_#{model}" do |model_id, tags, user, reason, comment, options|
21
- instance = Kaui.const_get(model.to_s.camelize).new("#{model}_id".to_sym => model_id)
21
+ instance = Kaui.const_get(model.to_s.camelize).new("#{model}_id": model_id)
22
22
  instance.set_tags(tags, user, reason, comment, options)
23
23
  end
24
24
  end
@@ -25,7 +25,7 @@ module Kaui
25
25
 
26
26
  ALL_OBJECT_TYPES.each do |object_type|
27
27
  define_singleton_method "all_for_#{object_type.downcase}" do |options_for_klient|
28
- (all('NONE', options_for_klient).delete_if { |tag_definition| !tag_definition.applicable_object_types.include?(object_type) || tag_definition.is_control_tag }).sort
28
+ (all('NONE', options_for_klient).delete_if { |tag_definition| !tag_definition.applicable_object_types.include?(object_type) }).sort
29
29
  end
30
30
  end
31
31
 
@@ -110,7 +110,7 @@
110
110
  <% end %>
111
111
  </table>
112
112
 
113
- <% if can? :trigger, Kaui::Invoice %>
113
+ <% if (can? :trigger, Kaui::Invoice) || (can? :dry_run, Kaui::Invoice) %>
114
114
  <div style="padding-bottom: 50px;">
115
115
  <%= form_tag kaui_engine.trigger_invoice_path(params.to_h), :method => :post do %>
116
116
  <div class="form-group">
@@ -118,13 +118,11 @@
118
118
  <div class="col-sm-3">
119
119
  <input class="form-control" id="target_date" name="target_date" type="text" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-today-highlight="true">
120
120
  </div>
121
- <% if can? :dry_run, Kaui::Invoice %>
122
121
  <div style="width: 14.5%; float: left; padding: 0;">
123
122
  <%= label_tag :dry_run do %>
124
- <%= check_box_tag :dry_run, '1', true %>&nbsp;<small>Dry-run</small>
123
+ <%= check_box_tag :dry_run, '1', true, :disabled => !can?(:trigger, Kaui::Invoice) %>&nbsp;<small>Dry-run</small>
125
124
  <% end %>
126
125
  </div>
127
- <% end %>
128
126
  <div class="col-xs-1" style="padding: 0;">
129
127
  <%= button_tag '<i class="fa fa-magic"></i>'.html_safe, :class => 'btn btn-xs' %>
130
128
  </div>
@@ -45,7 +45,7 @@
45
45
  <div class="form-group">
46
46
  <%= f.label :bill_cycle_day_local, 'Bill cycle day', :class => 'col-sm-3 control-label' %>
47
47
  <div class="col-sm-9">
48
- <%= f.text_field :bill_cycle_day_local, :class => 'form-control' %>
48
+ <%= f.number_field :bill_cycle_day_local, :class => 'form-control', :min => 0, max: 31 %>
49
49
  </div>
50
50
  </div>
51
51
  <div class="form-group">
@@ -111,13 +111,13 @@
111
111
  <div class="form-group">
112
112
  <%= f.label :country, 'Country', :class => 'col-sm-3 control-label' %>
113
113
  <div class="col-sm-9">
114
- <%= f.country_select :country, {:priority_countries => %w(US CA), :selected => @account.country}, :class => 'form-control' %>
114
+ <%= f.country_select :country, {:priority_countries => %w(US CA), :selected => @account.country, :sort_provided => false}, :class => 'form-control' %>
115
115
  </div>
116
116
  </div>
117
117
  <div class="form-group">
118
118
  <%= f.label :phone, 'Phone', :class => 'col-sm-3 control-label' %>
119
119
  <div class="col-sm-9">
120
- <%= f.text_field :phone, :class => 'form-control' %>
120
+ <%= f.number_field :phone, :class => 'form-control' %>
121
121
  </div>
122
122
  </div>
123
123
  <div class="form-group">
@@ -65,7 +65,6 @@ $(document).ready(function() {
65
65
  <!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
66
66
  <% if @max_nb_records.nil? %>
67
67
  $('#accounts-table').on('draw.dt', function() {
68
- $.noConflict();
69
68
  var noMoreData = table.column(0)
70
69
  .data()
71
70
  .length == 0;
@@ -38,11 +38,11 @@
38
38
  <td><%= state_form.select :is_block_changes, options_for_select([true, false ], state.is_block_changes), :class => 'form-control' %></td>
39
39
  <td><%= state_form.select :subscription_cancellation_policy, options_for_select([:NONE, :POLICY_NONE, :POLICY_IMMEDIATE, :POLICY_END_OF_TERM], state.subscription_cancellation), :class => 'form-control' %></td>
40
40
  <%= state_form.fields_for 'condition' do |condition| %>
41
- <td><%= condition.number_field :time_since_earliest_unpaid_invoice_equals_or_exceeds, :value => state.condition.time_since_earliest_unpaid_invoice_equals_or_exceeds.number %></td>
42
- <td><%= condition.select :control_tag_inclusion, options_for_select([:NONE, :AUTO_PAY_OFF, :AUTO_INVOICING_OFF, :OVERDUE_ENFORCEMENT_OFF, :MANUAL_PAY, :TEST, :PARTNER], state.condition.control_tag_inclusion), :class => 'form-control' %></td>
43
- <td><%= condition.select :control_tag_exclusion, options_for_select([:NONE, :AUTO_PAY_OFF, :AUTO_INVOICING_OFF, :OVERDUE_ENFORCEMENT_OFF, :MANUAL_PAY, :TEST, :PARTNER], state.condition.control_tag_exclusion), :class => 'form-control'%></td>
44
- <td><%= condition.number_field :number_of_unpaid_invoices_equals_or_exceeds, :value => state.condition.number_of_unpaid_invoices_equals_or_exceeds %></td>
45
- <td><%= condition.number_field :total_unpaid_invoice_balance_equals_or_exceeds, :step => :any, :value => state.condition.total_unpaid_invoice_balance_equals_or_exceeds %></td>
41
+ <td><%= condition.number_field :time_since_earliest_unpaid_invoice_equals_or_exceeds, :value => state.condition.time_since_earliest_unpaid_invoice_equals_or_exceeds&.number %></td>
42
+ <td><%= condition.select :control_tag_inclusion, options_for_select([:NONE, :AUTO_PAY_OFF, :AUTO_INVOICING_OFF, :OVERDUE_ENFORCEMENT_OFF, :MANUAL_PAY, :TEST, :PARTNER], state.condition&.control_tag_inclusion), :class => 'form-control' %></td>
43
+ <td><%= condition.select :control_tag_exclusion, options_for_select([:NONE, :AUTO_PAY_OFF, :AUTO_INVOICING_OFF, :OVERDUE_ENFORCEMENT_OFF, :MANUAL_PAY, :TEST, :PARTNER], state.condition&.control_tag_exclusion), :class => 'form-control'%></td>
44
+ <td><%= condition.number_field :number_of_unpaid_invoices_equals_or_exceeds, :value => state.condition&.number_of_unpaid_invoices_equals_or_exceeds %></td>
45
+ <td><%= condition.number_field :total_unpaid_invoice_balance_equals_or_exceeds, :step => :any, :value => state.condition&.total_unpaid_invoice_balance_equals_or_exceeds %></td>
46
46
  <% end %>
47
47
  <% end %>
48
48
  <% end %>
@@ -23,7 +23,7 @@
23
23
  <div class="form-group">
24
24
  <%= label_tag :search_by, 'Search by', :class => 'col-sm-4 control-label' %>
25
25
  <div class="col-sm-8">
26
- <%= select_tag :search_by, options_for_select(['', 'ID', 'EXTERNAL_KEY'],''), :class => 'form-control' %>
26
+ <%= select_tag :search_by, options_for_select(object_fields_for_advanced_search,''), :class => 'form-control' %>
27
27
  </div>
28
28
  </div>
29
29
  <div class="form-group">
@@ -68,13 +68,34 @@
68
68
  $('#advancedQuery').val(query);
69
69
  }
70
70
 
71
+ const searchByFieldsMap = <%= advanced_search_object_fields_map.to_json.html_safe %>;
72
+ function refresh_search_by() {
73
+ var objectType = $('#object_type').val();
74
+
75
+ // Clears the selected field if it's not supported by the selected object type
76
+ var searchBy = $('#search_by').val();
77
+ if (searchByFieldsMap[searchBy] && !searchByFieldsMap[searchBy].includes(objectType)) {
78
+ $('#search_by').val(' ');
79
+ refresh_query();
80
+ }
81
+
82
+ // Updates search options to only show fields supported by the selected object type
83
+ for (field in searchByFieldsMap) {
84
+ var isSupported = searchByFieldsMap[field].includes(objectType);
85
+ var fieldOption = $(`#search_by > option[value=${field}]`);
86
+ isSupported ? fieldOption.show() : fieldOption.hide();
87
+ }
88
+ }
89
+
71
90
  $('#search_for').keyup(function(){ refresh_query(); });
72
91
  $('#search_for').change(function(){ refresh_query(); });
73
92
  $('#object_type').change(function(){ refresh_query(); });
93
+ $('#object_type').change(function(){ refresh_search_by(); });
74
94
  $('#search_by').change(function(){ refresh_query(); });
75
95
  $('#fast').change(function(){ refresh_query(); });
76
96
 
77
97
  refresh_query();
98
+ refresh_search_by();
78
99
 
79
100
  });
80
101
  <% end %>
@@ -4,8 +4,9 @@
4
4
 
5
5
  <h1>
6
6
  Invoice <%= @invoice.invoice_number %>
7
- <% unless @invoice.invoice_number.blank? %>
7
+ <% if !@invoice.invoice_number.blank? %>
8
8
  <%= Kaui.customer_invoice_link.call(@invoice, self) %>
9
+ <%= Kaui.additional_invoice_links.call(@invoice, self) %>
9
10
  <% end %>
10
11
  </h1>
11
12