kaui 3.0.1 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/app/assets/config/kaui_manifest.js +2 -44
- data/app/assets/images/kaui/logo.svg +37 -0
- data/app/assets/javascripts/application.js +12 -0
- data/app/assets/javascripts/kaui/kaui.js +7 -452
- data/app/assets/javascripts/kaui/kaui_override.js +441 -0
- data/app/assets/stylesheets/application.css +23 -0
- data/app/assets/stylesheets/kaui/account.css +34 -0
- data/app/assets/stylesheets/kaui/audit.css +19 -0
- data/app/assets/stylesheets/kaui/common.css +550 -0
- data/app/assets/stylesheets/kaui/datatable.css +71 -0
- data/app/assets/stylesheets/kaui/header.css +129 -0
- data/app/assets/stylesheets/kaui/home.css +72 -0
- data/app/assets/stylesheets/kaui/invoice.css +37 -0
- data/app/assets/stylesheets/kaui/kaui.css +152 -0
- data/app/assets/stylesheets/kaui/overdue.css +7 -0
- data/app/assets/stylesheets/kaui/payment.css +28 -0
- data/app/assets/stylesheets/kaui/subscription.css +15 -0
- data/app/assets/stylesheets/kaui/tags.css +137 -0
- data/app/assets/stylesheets/kaui/timeline.css +5 -0
- data/app/assets/stylesheets/kaui/tooltip.css +16 -0
- data/app/controllers/kaui/account_tags_controller.rb +1 -1
- data/app/controllers/kaui/accounts_controller.rb +5 -6
- data/app/controllers/kaui/admin_allowed_users_controller.rb +1 -1
- data/app/controllers/kaui/admin_tenants_controller.rb +22 -9
- data/app/controllers/kaui/audit_logs_controller.rb +3 -3
- data/app/controllers/kaui/bundle_tags_controller.rb +1 -1
- data/app/controllers/kaui/charges_controller.rb +1 -1
- data/app/controllers/kaui/credits_controller.rb +1 -1
- data/app/controllers/kaui/custom_fields_controller.rb +3 -3
- data/app/controllers/kaui/engine_controller_util.rb +1 -1
- data/app/controllers/kaui/home_controller.rb +25 -16
- data/app/controllers/kaui/invoice_items_controller.rb +1 -1
- data/app/controllers/kaui/invoice_tags_controller.rb +1 -1
- data/app/controllers/kaui/invoices_controller.rb +10 -5
- data/app/controllers/kaui/payment_methods_controller.rb +4 -4
- data/app/controllers/kaui/payments_controller.rb +1 -1
- data/app/controllers/kaui/refunds_controller.rb +3 -2
- data/app/controllers/kaui/subscriptions_controller.rb +17 -16
- data/app/controllers/kaui/transactions_controller.rb +3 -3
- data/app/helpers/kaui/object_helper.rb +16 -1
- data/app/models/kaui/admin_tenant.rb +1 -1
- data/app/models/kaui/catalog.rb +2 -2
- data/app/models/kaui/custom_field.rb +1 -1
- data/app/models/kaui/invoice_payment.rb +1 -1
- data/app/models/kaui/overdue.rb +2 -2
- data/app/models/kaui/payment_method.rb +4 -4
- data/app/models/kaui/tag.rb +2 -2
- data/app/models/kaui/tag_definition.rb +1 -1
- data/app/views/kaui/accounts/_billing_info.html.erb +2 -4
- data/app/views/kaui/accounts/_form.html.erb +3 -3
- data/app/views/kaui/accounts/index.html.erb +0 -1
- data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +5 -5
- data/app/views/kaui/home/_advanced_search_modal.html.erb +22 -1
- data/app/views/kaui/invoices/show.html.erb +2 -1
- data/app/views/kaui/layouts/kaui_header.html.erb +2 -18
- data/app/views/kaui/layouts/kaui_navbar.html.erb +1 -1
- data/app/views/kaui/refunds/_form.html.erb +50 -2
- data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +1 -1
- data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/edit_bcd.erb +1 -1
- data/app/views/kaui/tag_definitions/_form.html.erb +1 -2
- data/config/routes.rb +1 -0
- data/lib/kaui/engine.rb +1 -4
- data/lib/kaui/version.rb +1 -1
- data/lib/kaui.rb +10 -10
- data/lib/tasks/kaui_tasks.rake +1 -0
- metadata +30 -131
- data/app/assets/images/kaui/logo.png +0 -0
- data/app/assets/javascripts/jquery.spin.js +0 -76
- data/app/assets/javascripts/kaui_application.js +0 -25
- data/app/assets/javascripts/spin.js +0 -76
- data/app/assets/stylesheets/bootstrap_and_overrides.scss +0 -240
- data/app/assets/stylesheets/kaui/account.scss +0 -52
- data/app/assets/stylesheets/kaui/audit.scss +0 -42
- data/app/assets/stylesheets/kaui/common.scss +0 -765
- data/app/assets/stylesheets/kaui/datatable.scss +0 -115
- data/app/assets/stylesheets/kaui/header.scss +0 -197
- data/app/assets/stylesheets/kaui/home.scss +0 -89
- data/app/assets/stylesheets/kaui/invoice.scss +0 -58
- data/app/assets/stylesheets/kaui/kaui.scss +0 -265
- data/app/assets/stylesheets/kaui/kaui_bootstrap.scss +0 -3
- data/app/assets/stylesheets/kaui/overdue.scss +0 -11
- data/app/assets/stylesheets/kaui/payment.scss +0 -43
- data/app/assets/stylesheets/kaui/subscription.scss +0 -27
- data/app/assets/stylesheets/kaui/tags.scss +0 -208
- data/app/assets/stylesheets/kaui/timeline.scss +0 -7
- data/app/assets/stylesheets/kaui/tooltip.scss +0 -15
- data/app/assets/stylesheets/kaui_application.css +0 -12
@@ -130,9 +130,23 @@ module Kaui
|
|
130
130
|
uploaded_catalog = params.require(:catalog)
|
131
131
|
catalog_xml = uploaded_catalog.read
|
132
132
|
|
133
|
-
Kaui::
|
134
|
-
|
135
|
-
|
133
|
+
validate_response = Kaui::Catalog.validate_catalog(catalog_xml, options[:username], nil, comment, options)
|
134
|
+
catalog_validation_errors = begin
|
135
|
+
JSON.parse(validate_response.response.body)['catalogValidationErrors']
|
136
|
+
rescue StandardError
|
137
|
+
nil
|
138
|
+
end
|
139
|
+
if catalog_validation_errors.blank?
|
140
|
+
Kaui::AdminTenant.upload_catalog(catalog_xml, options[:username], nil, comment, options)
|
141
|
+
redirect_to admin_tenant_path(current_tenant.id), notice: I18n.translate('flashes.notices.catalog_uploaded_successfully')
|
142
|
+
else
|
143
|
+
errors = ''
|
144
|
+
catalog_validation_errors.each do |validation_error|
|
145
|
+
errors += (validation_error['errorDescription'])
|
146
|
+
end
|
147
|
+
flash[:error] = errors
|
148
|
+
redirect_to admin_tenant_new_catalog_path(id: current_tenant.id)
|
149
|
+
end
|
136
150
|
end
|
137
151
|
|
138
152
|
def new_catalog
|
@@ -174,7 +188,7 @@ module Kaui
|
|
174
188
|
options[:api_key] = @tenant.api_key
|
175
189
|
options[:api_secret] = @tenant.api_secret
|
176
190
|
|
177
|
-
catalog = Kaui::Catalog.get_catalog_json(true, nil, options)
|
191
|
+
catalog = Kaui::Catalog.get_catalog_json(true, nil, nil, options)
|
178
192
|
|
179
193
|
# seek if plan id exists
|
180
194
|
catalog.products.each do |product|
|
@@ -434,16 +448,15 @@ module Kaui
|
|
434
448
|
|
435
449
|
catalog = []
|
436
450
|
result = begin
|
437
|
-
Kaui::Catalog.get_catalog_json(false, effective_date, options)
|
451
|
+
Kaui::Catalog.get_catalog_json(false, effective_date, nil, options)
|
438
452
|
rescue StandardError
|
439
453
|
catalog = []
|
440
454
|
end
|
441
455
|
|
442
456
|
# convert result to a full hash since dynamic attributes of a class are ignored when converting to json
|
443
457
|
result.each do |data|
|
444
|
-
plans = []
|
445
|
-
|
446
|
-
plans << plan.instance_variables.each_with_object({}) { |var, hash_plan| hash_plan[var.to_s.delete('@')] = plan.instance_variable_get(var) }
|
458
|
+
plans = data[:plans].map do |plan|
|
459
|
+
plan.instance_variables.each_with_object({}) { |var, hash_plan| hash_plan[var.to_s.delete('@')] = plan.instance_variable_get(var) }
|
447
460
|
end
|
448
461
|
|
449
462
|
catalog << { version_date: data[:version_date],
|
@@ -475,7 +488,7 @@ module Kaui
|
|
475
488
|
options[:api_key] = @tenant.api_key
|
476
489
|
options[:api_secret] = @tenant.api_secret
|
477
490
|
|
478
|
-
latest_catalog = Kaui::Catalog.get_catalog_json(true, nil, options)
|
491
|
+
latest_catalog = Kaui::Catalog.get_catalog_json(true, nil, nil, options)
|
479
492
|
@all_plans = latest_catalog ? (latest_catalog.products || []).map(&:plans).flatten.map(&:name) : []
|
480
493
|
|
481
494
|
@ao_mapping = Kaui::Catalog.build_ao_mapping(latest_catalog)
|
@@ -68,7 +68,7 @@ module Kaui
|
|
68
68
|
when 'CUSTOM_FIELD'
|
69
69
|
audit_logs_with_history = Kaui::CustomField.new({ custom_field_id: object_id }).audit_logs_with_history(cached_options_for_klient)
|
70
70
|
when 'INVOICE'
|
71
|
-
invoice = Kaui::Invoice.find_by_id(object_id, 'NONE', cached_options_for_klient)
|
71
|
+
invoice = Kaui::Invoice.find_by_id(object_id, false, 'NONE', cached_options_for_klient)
|
72
72
|
audit_logs_with_history = invoice.audit_logs_with_history(cached_options_for_klient)
|
73
73
|
when 'INVOICE_ITEM'
|
74
74
|
invoice_item = Kaui::InvoiceItem.new
|
@@ -84,10 +84,10 @@ module Kaui
|
|
84
84
|
payment = Kaui::Payment.find_by_id(object_id, false, false, cached_options_for_klient)
|
85
85
|
audit_logs_with_history = payment.audit_logs_with_history(cached_options_for_klient)
|
86
86
|
when 'PAYMENT_METHOD'
|
87
|
-
payment_method = Kaui::PaymentMethod.find_by_id(object_id, false, cached_options_for_klient)
|
87
|
+
payment_method = Kaui::PaymentMethod.find_by_id(object_id, false, false, [], 'NONE', cached_options_for_klient)
|
88
88
|
audit_logs_with_history = payment_method.audit_logs_with_history(cached_options_for_klient)
|
89
89
|
when 'SUBSCRIPTION'
|
90
|
-
subscription = Kaui::Subscription.find_by_id(object_id, cached_options_for_klient)
|
90
|
+
subscription = Kaui::Subscription.find_by_id(object_id, 'NONE', cached_options_for_klient)
|
91
91
|
audit_logs_with_history = subscription.audit_logs_with_history(cached_options_for_klient)
|
92
92
|
when 'SUBSCRIPTION_EVENT'
|
93
93
|
audit_logs_with_history = Kaui::Subscription.event_audit_logs_with_history(object_id, cached_options_for_klient)
|
@@ -7,7 +7,7 @@ module Kaui
|
|
7
7
|
amount = params[:amount]
|
8
8
|
|
9
9
|
if invoice_id.present?
|
10
|
-
@invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
|
10
|
+
@invoice = Kaui::Invoice.find_by_id(invoice_id, false, 'NONE', options_for_klient)
|
11
11
|
amount ||= @invoice.balance
|
12
12
|
currency = @invoice.currency
|
13
13
|
else
|
@@ -7,7 +7,7 @@ module Kaui
|
|
7
7
|
amount = params[:amount]
|
8
8
|
|
9
9
|
if invoice_id.present?
|
10
|
-
@invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
|
10
|
+
@invoice = Kaui::Invoice.find_by_id(invoice_id, false, 'NONE', options_for_klient)
|
11
11
|
amount ||= @invoice.balance
|
12
12
|
currency = @invoice.currency
|
13
13
|
else
|
@@ -71,7 +71,7 @@ module Kaui
|
|
71
71
|
end
|
72
72
|
when :SUBSCRIPTION
|
73
73
|
begin
|
74
|
-
test_uuid = Kaui::Subscription.find_by_id(param_uuid, options_for_klient)
|
74
|
+
test_uuid = Kaui::Subscription.find_by_id(param_uuid, 'NONE', options_for_klient)
|
75
75
|
rescue StandardError
|
76
76
|
# Ignore
|
77
77
|
end
|
@@ -163,7 +163,7 @@ module Kaui
|
|
163
163
|
end
|
164
164
|
when 'SUBSCRIPTION'
|
165
165
|
begin
|
166
|
-
test_uuid = Kaui::Subscription.find_by_id(param_uuid, options_for_klient)
|
166
|
+
test_uuid = Kaui::Subscription.find_by_id(param_uuid, 'NONE', options_for_klient)
|
167
167
|
rescue StandardError
|
168
168
|
# Ignore
|
169
169
|
ensure
|
@@ -172,7 +172,7 @@ module Kaui
|
|
172
172
|
when 'INVOICE'
|
173
173
|
begin
|
174
174
|
cached_options_for_klient = options_for_klient
|
175
|
-
test_uuid = Kaui::Invoice.find_by_id(param_uuid, 'FULL', cached_options_for_klient)
|
175
|
+
test_uuid = Kaui::Invoice.find_by_id(param_uuid, false, 'FULL', cached_options_for_klient)
|
176
176
|
rescue StandardError
|
177
177
|
# Ignore
|
178
178
|
ensure
|
@@ -37,7 +37,7 @@ module Kaui
|
|
37
37
|
pages ||= []
|
38
38
|
|
39
39
|
# Until we support server-side sorting
|
40
|
-
ordering = (
|
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?
|
@@ -52,15 +52,23 @@ module Kaui
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def invoice_search(search_query, search_by = nil, fast = 0, options = {})
|
55
|
-
|
55
|
+
case search_by
|
56
|
+
when 'ID'
|
56
57
|
begin
|
57
|
-
invoice = Kaui::Invoice.find_by_id(search_query, 'NONE', options)
|
58
|
+
invoice = Kaui::Invoice.find_by_id(search_query, false, '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
|
-
|
63
|
-
|
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, false, '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?
|
@@ -108,14 +116,14 @@ module Kaui
|
|
108
116
|
def transaction_search(search_query, search_by = nil, _fast = 0, options = {})
|
109
117
|
if search_by.blank? || search_by == 'ID'
|
110
118
|
begin
|
111
|
-
payment = Kaui::Payment.find_by_transaction_id(search_query, false, true, options)
|
119
|
+
payment = Kaui::Payment.find_by_transaction_id(search_query, false, true, [], 'NONE', options)
|
112
120
|
redirect_to account_payment_path(payment.account_id, payment.payment_id) and return
|
113
121
|
rescue KillBillClient::API::NotFound => _e
|
114
122
|
search_error("No transaction matches \"#{search_query}\"")
|
115
123
|
end
|
116
124
|
else
|
117
125
|
begin
|
118
|
-
payment = Kaui::Payment.find_by_transaction_external_key(search_query, false, true, 'NONE', options)
|
126
|
+
payment = Kaui::Payment.find_by_transaction_external_key(search_query, false, true, [], 'NONE', options)
|
119
127
|
redirect_to account_payment_path(payment.account_id, payment.payment_id) and return
|
120
128
|
rescue KillBillClient::API::NotFound => _e
|
121
129
|
search_error("No transaction matches \"#{search_query}\"")
|
@@ -157,7 +165,7 @@ module Kaui
|
|
157
165
|
search_error("No credit matches \"#{search_query}\"")
|
158
166
|
end
|
159
167
|
else
|
160
|
-
|
168
|
+
unsupported_search_field('CREDIT', search_by)
|
161
169
|
end
|
162
170
|
end
|
163
171
|
|
@@ -170,7 +178,7 @@ module Kaui
|
|
170
178
|
redirect_to custom_fields_path(q: search_query, fast:)
|
171
179
|
end
|
172
180
|
else
|
173
|
-
|
181
|
+
unsupported_search_field('CUSTOM FIELD', search_by)
|
174
182
|
end
|
175
183
|
end
|
176
184
|
|
@@ -183,20 +191,20 @@ module Kaui
|
|
183
191
|
search_error("No invoice payment matches \"#{search_query}\"")
|
184
192
|
end
|
185
193
|
else
|
186
|
-
|
194
|
+
unsupported_search_field('INVOICE PAYMENT', search_by)
|
187
195
|
end
|
188
196
|
end
|
189
197
|
|
190
198
|
def subscription_search(search_query, search_by = nil, _fast = 0, options = {})
|
191
199
|
if search_by.blank? || search_by == 'ID'
|
192
200
|
begin
|
193
|
-
subscription = Kaui::Subscription.find_by_id(search_query, options)
|
201
|
+
subscription = Kaui::Subscription.find_by_id(search_query, 'NONE', options)
|
194
202
|
redirect_to account_bundles_path(subscription.account_id) and return
|
195
203
|
rescue KillBillClient::API::NotFound => _e
|
196
204
|
search_error("No subscription matches \"#{search_query}\"")
|
197
205
|
end
|
198
206
|
else
|
199
|
-
|
207
|
+
unsupported_search_field('SUBSCRIPTION', search_by)
|
200
208
|
end
|
201
209
|
end
|
202
210
|
|
@@ -209,7 +217,7 @@ module Kaui
|
|
209
217
|
redirect_to tags_path(q: search_query, fast:)
|
210
218
|
end
|
211
219
|
else
|
212
|
-
|
220
|
+
unsupported_search_field('TAG', search_by)
|
213
221
|
end
|
214
222
|
end
|
215
223
|
|
@@ -222,7 +230,7 @@ module Kaui
|
|
222
230
|
search_error("No tag definition matches \"#{search_query}\"")
|
223
231
|
end
|
224
232
|
elsif search_by == 'EXTERNAL_KEY'
|
225
|
-
|
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?
|
@@ -238,8 +246,9 @@ module Kaui
|
|
238
246
|
end
|
239
247
|
end
|
240
248
|
|
241
|
-
def
|
242
|
-
|
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? &&
|
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
|
@@ -7,7 +7,7 @@ module Kaui
|
|
7
7
|
invoice_id = params.require(:invoice_id)
|
8
8
|
|
9
9
|
# See https://github.com/killbill/killbill/issues/7
|
10
|
-
invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
|
10
|
+
invoice = Kaui::Invoice.find_by_id(invoice_id, false, 'NONE', options_for_klient)
|
11
11
|
@invoice_item = invoice.items.find { |ii| ii.invoice_item_id == invoice_item_id }
|
12
12
|
|
13
13
|
return unless @invoice_item.nil?
|
@@ -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
|
@@ -67,7 +67,7 @@ module Kaui
|
|
67
67
|
# Go to the database once
|
68
68
|
cached_options_for_klient = options_for_klient
|
69
69
|
|
70
|
-
@invoice = Kaui::Invoice.find_by_id(params.require(:id), 'FULL', cached_options_for_klient)
|
70
|
+
@invoice = Kaui::Invoice.find_by_id(params.require(:id), false, 'FULL', cached_options_for_klient)
|
71
71
|
# This will put the TAX items at the bottom
|
72
72
|
precedence = {
|
73
73
|
'EXTERNAL_CHARGE' => 0,
|
@@ -132,7 +132,7 @@ module Kaui
|
|
132
132
|
|
133
133
|
def void_invoice
|
134
134
|
cached_options_for_klient = options_for_klient
|
135
|
-
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), 'NONE', cached_options_for_klient)
|
135
|
+
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), false, 'NONE', cached_options_for_klient)
|
136
136
|
begin
|
137
137
|
invoice.void(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
138
138
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id), notice: 'Invoice successfully voided'
|
@@ -143,7 +143,12 @@ module Kaui
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def restful_show
|
146
|
-
invoice = Kaui::Invoice.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
146
|
+
invoice = Kaui::Invoice.find_by_id(params.require(:id), false, 'NONE', options_for_klient)
|
147
|
+
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id)
|
148
|
+
end
|
149
|
+
|
150
|
+
def restful_show_by_number
|
151
|
+
invoice = Kaui::Invoice.find_by_number(params.require(:number), false, 'NONE', options_for_klient)
|
147
152
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id)
|
148
153
|
end
|
149
154
|
|
@@ -153,7 +158,7 @@ module Kaui
|
|
153
158
|
|
154
159
|
def commit_invoice
|
155
160
|
cached_options_for_klient = options_for_klient
|
156
|
-
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), 'NONE', cached_options_for_klient)
|
161
|
+
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), false, 'NONE', cached_options_for_klient)
|
157
162
|
invoice.commit(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
158
163
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id), notice: 'Invoice successfully committed'
|
159
164
|
end
|
@@ -47,7 +47,7 @@ module Kaui
|
|
47
47
|
}
|
48
48
|
|
49
49
|
@plugin_properties = begin
|
50
|
-
params[:plugin_properties].values.reject { |item|
|
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
|
@@ -74,7 +74,7 @@ module Kaui
|
|
74
74
|
def destroy
|
75
75
|
payment_method_id = params[:id]
|
76
76
|
|
77
|
-
payment_method = Kaui::PaymentMethod.find_by_id(payment_method_id, false, options_for_klient)
|
77
|
+
payment_method = Kaui::PaymentMethod.find_by_id(payment_method_id, false, false, [], 'NONE', options_for_klient)
|
78
78
|
begin
|
79
79
|
Kaui::PaymentMethod.destroy(payment_method_id, params[:set_auto_pay_off], false, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
80
80
|
redirect_to kaui_engine.account_path(payment_method.account_id), notice: "Payment method #{payment_method_id} successfully deleted"
|
@@ -89,7 +89,7 @@ module Kaui
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def restful_show
|
92
|
-
payment_method = Kaui::PaymentMethod.find_by_id(params.require(:id), false, options_for_klient)
|
92
|
+
payment_method = Kaui::PaymentMethod.find_by_id(params.require(:id), false, false, [], 'NONE', options_for_klient)
|
93
93
|
redirect_to kaui_engine.account_path(payment_method.account_id)
|
94
94
|
end
|
95
95
|
|
@@ -98,7 +98,7 @@ module Kaui
|
|
98
98
|
external_key = params.require(:external_key)
|
99
99
|
|
100
100
|
begin
|
101
|
-
payment_methods = Kaui::PaymentMethod.find_by_external_key(external_key, false, false, 'NONE', options_for_klient)
|
101
|
+
payment_methods = Kaui::PaymentMethod.find_by_external_key(external_key, false, false, [], 'NONE', options_for_klient)
|
102
102
|
rescue KillBillClient::API::NotFound
|
103
103
|
payment_methods = nil
|
104
104
|
end
|
@@ -78,7 +78,7 @@ module Kaui
|
|
78
78
|
|
79
79
|
def new
|
80
80
|
cached_options_for_klient = options_for_klient
|
81
|
-
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', cached_options_for_klient) }
|
81
|
+
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), false, 'NONE', cached_options_for_klient) }
|
82
82
|
fetch_payment_methods = promise { Kaui::PaymentMethod.find_all_by_account_id(params.require(:account_id), false, cached_options_for_klient) }
|
83
83
|
|
84
84
|
@invoice = wait(fetch_invoice)
|
@@ -5,8 +5,9 @@ module Kaui
|
|
5
5
|
def new
|
6
6
|
cached_options_for_klient = options_for_klient
|
7
7
|
|
8
|
-
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', cached_options_for_klient) }
|
8
|
+
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), false, 'NONE', cached_options_for_klient) }
|
9
9
|
fetch_payment = promise { Kaui::InvoicePayment.find_by_id(params.require(:payment_id), false, false, cached_options_for_klient) }
|
10
|
+
|
10
11
|
fetch_bundles = promise { @account.bundles(cached_options_for_klient) }
|
11
12
|
|
12
13
|
@invoice = wait(fetch_invoice)
|
@@ -18,7 +19,7 @@ module Kaui
|
|
18
19
|
|
19
20
|
# rubocop:disable Lint/FloatComparison
|
20
21
|
def create
|
21
|
-
invoice = Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', options_for_klient)
|
22
|
+
invoice = Kaui::Invoice.find_by_id(params.require(:invoice_id), false, 'NONE', options_for_klient)
|
22
23
|
|
23
24
|
if params[:adjustment_type] == 'invoiceItemAdjustment'
|
24
25
|
items = []
|
@@ -72,7 +72,7 @@ module Kaui
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def edit
|
75
|
-
@subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
75
|
+
@subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
76
76
|
_, plans_details = lookup_bundle_and_plan_details(@subscription)
|
77
77
|
# Use a Set to deal with multiple pricelists
|
78
78
|
@plans = Set.new.merge(plans_details.map(&:plan))
|
@@ -86,7 +86,7 @@ module Kaui
|
|
86
86
|
|
87
87
|
wait_for_completion = params[:wait_for_completion] == '1'
|
88
88
|
|
89
|
-
subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
89
|
+
subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
90
90
|
|
91
91
|
input = { planName: plan_name }
|
92
92
|
|
@@ -124,13 +124,13 @@ module Kaui
|
|
124
124
|
else
|
125
125
|
nil
|
126
126
|
end
|
127
|
-
subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
127
|
+
subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
128
128
|
subscription.cancel(current_user.kb_username, params[:reason], params[:comment], requested_date, entitlement_policy, billing_policy, use_requested_date_for_billing, options_for_klient)
|
129
129
|
redirect_to kaui_engine.account_bundles_path(subscription.account_id), notice: 'Subscription was successfully cancelled'
|
130
130
|
end
|
131
131
|
|
132
132
|
def reinstate
|
133
|
-
subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
133
|
+
subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
134
134
|
|
135
135
|
subscription.uncancel(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
136
136
|
|
@@ -138,7 +138,7 @@ module Kaui
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def edit_bcd
|
141
|
-
@subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
141
|
+
@subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
142
142
|
end
|
143
143
|
|
144
144
|
def update_bcd
|
@@ -158,7 +158,7 @@ module Kaui
|
|
158
158
|
end
|
159
159
|
|
160
160
|
def restful_show
|
161
|
-
subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
161
|
+
subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
162
162
|
redirect_to kaui_engine.account_bundles_path(subscription.account_id)
|
163
163
|
end
|
164
164
|
|
@@ -181,7 +181,7 @@ module Kaui
|
|
181
181
|
external_key = params.require(:external_key)
|
182
182
|
|
183
183
|
begin
|
184
|
-
subscription = Kaui::Subscription.find_by_external_key(external_key, options_for_klient)
|
184
|
+
subscription = Kaui::Subscription.find_by_external_key(external_key, 'NONE', options_for_klient)
|
185
185
|
rescue KillBillClient::API::NotFound
|
186
186
|
subscription = nil
|
187
187
|
end
|
@@ -192,11 +192,12 @@ module Kaui
|
|
192
192
|
|
193
193
|
def update_tags
|
194
194
|
subscription_id = params.require(:id)
|
195
|
-
subscription = Kaui::Subscription.find_by_id(subscription_id, options_for_klient)
|
196
|
-
|
195
|
+
subscription = Kaui::Subscription.find_by_id(subscription_id, 'NONE', options_for_klient)
|
197
196
|
tags = []
|
198
|
-
params.
|
199
|
-
|
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(
|
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(
|
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,
|
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 = []
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Kaui
|
4
4
|
class TransactionsController < Kaui::EngineController
|
5
5
|
def restful_show
|
6
|
-
payment = Kaui::Payment.find_by_transaction_id(params.require(:id), false, true, options_for_klient)
|
6
|
+
payment = Kaui::Payment.find_by_transaction_id(params.require(:id), false, true, [], 'NONE', options_for_klient)
|
7
7
|
redirect_to account_payment_path(payment.account_id, payment.payment_id)
|
8
8
|
end
|
9
9
|
|
@@ -18,7 +18,7 @@ module Kaui
|
|
18
18
|
currency: params[:currency],
|
19
19
|
transaction_type: params[:transaction_type])
|
20
20
|
else
|
21
|
-
payment = Kaui::Payment.find_by_transaction_id(transaction_id, false, false, options_for_klient)
|
21
|
+
payment = Kaui::Payment.find_by_transaction_id(transaction_id, false, false, [], 'NONE', options_for_klient)
|
22
22
|
@transaction = Kaui::Transaction.build_from_raw_transaction(payment.transactions.find { |tx| tx.transaction_id == transaction_id })
|
23
23
|
end
|
24
24
|
end
|
@@ -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|
|
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)
|
@@ -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
|
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
|
@@ -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!(
|
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]
|
data/app/models/kaui/catalog.rb
CHANGED
@@ -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,
|
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 =
|
24
|
+
original_transactions = result.transactions || []
|
25
25
|
result.transactions = []
|
26
26
|
original_transactions.each do |transaction|
|
27
27
|
new_transaction = Kaui::Transaction.new
|
data/app/models/kaui/overdue.rb
CHANGED
@@ -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!(
|
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}"
|
63
|
+
state.subscription_cancellation_policy ? :"POLICY_#{state.subscription_cancellation_policy}" : :NONE
|
64
64
|
else
|
65
65
|
:NONE
|
66
66
|
end
|