kaui 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/stylesheets/kaui/subscription.less +4 -0
- data/app/assets/stylesheets/kaui/tags.less +1 -1
- data/app/controllers/kaui/account_children_controller.rb +2 -2
- data/app/controllers/kaui/account_tags_controller.rb +3 -2
- data/app/controllers/kaui/accounts_controller.rb +9 -5
- data/app/controllers/kaui/admin_tenants_controller.rb +0 -10
- data/app/controllers/kaui/bundle_tags_controller.rb +3 -2
- data/app/controllers/kaui/bundles_controller.rb +13 -9
- data/app/controllers/kaui/chargebacks_controller.rb +6 -4
- data/app/controllers/kaui/invoices_controller.rb +9 -6
- data/app/controllers/kaui/payments_controller.rb +8 -5
- data/app/controllers/kaui/refunds_controller.rb +5 -3
- data/app/controllers/kaui/subscriptions_controller.rb +34 -7
- data/app/helpers/kaui/subscription_helper.rb +22 -4
- data/app/models/kaui/admin_tenant.rb +6 -5
- data/app/models/kaui/base.rb +2 -2
- data/app/views/kaui/admin_tenants/_form_plugin_config.erb +25 -16
- data/app/views/kaui/invoices/show.html.erb +6 -1
- data/app/views/kaui/subscriptions/_edit_form.html.erb +15 -9
- data/app/views/kaui/subscriptions/_form.html.erb +6 -0
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +5 -0
- data/lib/kaui/version.rb +1 -1
- data/test/functional/kaui/bundle_tags_controller_test.rb +0 -11
- data/test/functional/kaui/subscriptions_controller_test.rb +28 -7
- data/test/unit/kaui/admin_tenant_test.rb +25 -5
- data/test/unit/kaui/base_test.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b872df3f942d9f2a4e5efc1f1fd93ebb8e37e956
|
4
|
+
data.tar.gz: f25ca3f933403dea99fd1c776330ec7966c190c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65ae3a7873e00c75ff89a88b0b44fc9bbd8c02f5e68ced24a4f1eb9a696dbfe9b6c0522d360afc2dde9af93fff0c04f8acb9c717a4e6f8a8b6ba18febda005aa
|
7
|
+
data.tar.gz: 7e1f005312d0697fb899dee663e7d89af286b2e22242c4ee66488dc2e92d0a873883a67ca7ba158916e6366fa7c462b2f05cac4762ff3af0883593d0d262647c
|
data/README.md
CHANGED
@@ -16,9 +16,9 @@ class Kaui::AccountChildrenController < Kaui::EngineController
|
|
16
16
|
# It will fetch all the children. It use the paginate to fetch all children as permitting for future exchange
|
17
17
|
# when killbill account/{account_id}/children endpoint includes offset and limit parameters.
|
18
18
|
def pagination
|
19
|
-
|
19
|
+
cached_options_for_klient = options_for_klient
|
20
20
|
searcher = lambda do |parent_account_id, offset, limit|
|
21
|
-
Kaui::Account.find_children(parent_account_id, true, true, 'NONE',
|
21
|
+
Kaui::Account.find_children(parent_account_id, true, true, 'NONE', cached_options_for_klient)
|
22
22
|
end
|
23
23
|
|
24
24
|
data_extractor = lambda do |account_child, column|
|
@@ -24,8 +24,9 @@ class Kaui::AccountTagsController < Kaui::EngineController
|
|
24
24
|
def edit
|
25
25
|
@account_id = params.require(:account_id)
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
cached_options_for_klient = options_for_klient
|
28
|
+
fetch_tag_names = promise { (Kaui::Tag.all_for_account(@account_id, false, 'NONE', cached_options_for_klient).map { |tag| tag.tag_definition_name }).sort }
|
29
|
+
fetch_available_tags = promise { Kaui::TagDefinition.all_for_account(cached_options_for_klient) }
|
29
30
|
|
30
31
|
@tag_names = wait(fetch_tag_names)
|
31
32
|
@available_tags = wait(fetch_available_tags)
|
@@ -21,8 +21,9 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def pagination
|
24
|
+
cached_options_for_klient = options_for_klient
|
24
25
|
searcher = lambda do |search_key, offset, limit|
|
25
|
-
Kaui::Account.list_or_search(search_key, offset, limit,
|
26
|
+
Kaui::Account.list_or_search(search_key, offset, limit, cached_options_for_klient)
|
26
27
|
end
|
27
28
|
|
28
29
|
data_extractor = lambda do |account, column|
|
@@ -255,10 +256,12 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
255
256
|
|
256
257
|
raise('Account id and account parent id cannot be equal.') if @account.account_id == @account.parent_account_id
|
257
258
|
|
259
|
+
cached_options_for_klient = options_for_klient
|
260
|
+
|
258
261
|
# check if parent id is valid
|
259
|
-
Kaui::Account.find_by_id(@account.parent_account_id,false,false,
|
262
|
+
Kaui::Account.find_by_id(@account.parent_account_id, false, false, cached_options_for_klient)
|
260
263
|
|
261
|
-
@account.update(false, current_user.kb_username, params[:reason], params[:comment],
|
264
|
+
@account.update(false, current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
262
265
|
|
263
266
|
redirect_to account_path(@account.account_id), :notice => 'Account successfully updated'
|
264
267
|
rescue => e
|
@@ -272,13 +275,14 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
272
275
|
|
273
276
|
def unlink_to_parent
|
274
277
|
account_id = params.require(:account_id)
|
278
|
+
cached_options_for_klient = options_for_klient
|
275
279
|
|
276
280
|
# search for the account and remove the parent account id
|
277
281
|
# check if parent id is valid
|
278
|
-
account = Kaui::Account.find_by_id(account_id,false,false,
|
282
|
+
account = Kaui::Account.find_by_id(account_id, false, false, cached_options_for_klient)
|
279
283
|
account.is_payment_delegated_to_parent = false
|
280
284
|
account.parent_account_id = nil
|
281
|
-
account.update(true, current_user.kb_username, params[:reason], params[:comment],
|
285
|
+
account.update(true, current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
282
286
|
|
283
287
|
redirect_to account_path(@account.account_id), :notice => 'Account successfully updated'
|
284
288
|
rescue => e
|
@@ -121,8 +121,6 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def new_catalog
|
124
|
-
|
125
|
-
|
126
124
|
@tenant = safely_find_tenant_by_id(params[:id])
|
127
125
|
|
128
126
|
options = tenant_options_for_client
|
@@ -147,7 +145,6 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
147
145
|
end
|
148
146
|
|
149
147
|
def delete_catalog
|
150
|
-
|
151
148
|
tenant = safely_find_tenant_by_id(params[:id])
|
152
149
|
|
153
150
|
options = tenant_options_for_client
|
@@ -191,9 +188,7 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
191
188
|
@simple_plan.plan_id = params[:plan_id]
|
192
189
|
end
|
193
190
|
|
194
|
-
|
195
191
|
def create_simple_plan
|
196
|
-
|
197
192
|
current_tenant = safely_find_tenant_by_id(params[:id])
|
198
193
|
|
199
194
|
options = tenant_options_for_client
|
@@ -221,7 +216,6 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
221
216
|
end
|
222
217
|
|
223
218
|
def modify_overdue_config
|
224
|
-
|
225
219
|
current_tenant = safely_find_tenant_by_id(params[:id])
|
226
220
|
|
227
221
|
options = tenant_options_for_client
|
@@ -236,7 +230,6 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
236
230
|
redirect_to admin_tenant_path(current_tenant.id), :notice => 'Overdue config was successfully added '
|
237
231
|
end
|
238
232
|
|
239
|
-
|
240
233
|
def upload_overdue_config
|
241
234
|
current_tenant = safely_find_tenant_by_id(params[:id])
|
242
235
|
|
@@ -252,7 +245,6 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
252
245
|
redirect_to admin_tenant_path(current_tenant.id), :notice => 'Overdue config was successfully uploaded'
|
253
246
|
end
|
254
247
|
|
255
|
-
|
256
248
|
def upload_invoice_template
|
257
249
|
current_tenant = safely_find_tenant_by_id(params[:id])
|
258
250
|
|
@@ -449,7 +441,6 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
449
441
|
|
450
442
|
private
|
451
443
|
|
452
|
-
|
453
444
|
def safely_find_tenant_by_id(tenant_id)
|
454
445
|
tenant = Kaui::Tenant.find_by_id(tenant_id)
|
455
446
|
raise ActiveRecord::RecordNotFound.new('Could not find tenant ' + tenant_id) unless retrieve_tenants_for_current_user.include?(tenant.kb_tenant_id)
|
@@ -470,7 +461,6 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
470
461
|
end
|
471
462
|
|
472
463
|
def set_tenant_if_nil(tenant)
|
473
|
-
|
474
464
|
if session[:kb_tenant_id].nil?
|
475
465
|
session[:kb_tenant_id] = tenant.kb_tenant_id
|
476
466
|
session[:kb_tenant_name] = tenant.name
|
@@ -3,8 +3,9 @@ class Kaui::BundleTagsController < Kaui::EngineController
|
|
3
3
|
def edit
|
4
4
|
@bundle_id = params.require(:bundle_id)
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
cached_options_for_klient = options_for_klient
|
7
|
+
fetch_tag_names = promise { (Kaui::Tag.all_for_bundle(@bundle_id, false, 'NONE', cached_options_for_klient).map { |tag| tag.tag_definition_name }).sort }
|
8
|
+
fetch_available_tags = promise { Kaui::TagDefinition.all_for_bundle(cached_options_for_klient) }
|
8
9
|
|
9
10
|
@tag_names = wait(fetch_tag_names)
|
10
11
|
@available_tags = wait(fetch_available_tags)
|
@@ -1,25 +1,27 @@
|
|
1
1
|
class Kaui::BundlesController < Kaui::EngineController
|
2
2
|
|
3
3
|
def index
|
4
|
-
|
4
|
+
cached_options_for_klient = options_for_klient
|
5
|
+
|
6
|
+
fetch_bundles = promise { @account.bundles(cached_options_for_klient) }
|
5
7
|
fetch_bundle_tags = promise {
|
6
|
-
all_bundle_tags = @account.all_tags(:BUNDLE, false, 'NONE',
|
8
|
+
all_bundle_tags = @account.all_tags(:BUNDLE, false, 'NONE', cached_options_for_klient)
|
7
9
|
all_bundle_tags.inject({}) {|hsh, entry| (hsh[entry.object_id] ||= []) << entry; hsh}
|
8
10
|
}
|
9
11
|
fetch_subscription_tags = promise {
|
10
|
-
all_subscription_tags = @account.all_tags(:SUBSCRIPTION, false, 'NONE',
|
12
|
+
all_subscription_tags = @account.all_tags(:SUBSCRIPTION, false, 'NONE', cached_options_for_klient)
|
11
13
|
all_subscription_tags.inject({}) {|hsh, entry| (hsh[entry.object_id] ||= []) << entry; hsh}
|
12
14
|
}
|
13
15
|
fetch_bundle_fields = promise {
|
14
|
-
all_bundle_fields = @account.all_custom_fields(:BUNDLE, 'NONE',
|
16
|
+
all_bundle_fields = @account.all_custom_fields(:BUNDLE, 'NONE', cached_options_for_klient)
|
15
17
|
all_bundle_fields.inject({}) {|hsh, entry| (hsh[entry.object_id] ||= []) << entry; hsh}
|
16
18
|
}
|
17
19
|
fetch_subscription_fields = promise {
|
18
|
-
all_subscription_fields = @account.all_custom_fields(:SUBSCRIPTION, 'NONE',
|
20
|
+
all_subscription_fields = @account.all_custom_fields(:SUBSCRIPTION, 'NONE', cached_options_for_klient)
|
19
21
|
all_subscription_fields.inject({}) {|hsh, entry| (hsh[entry.object_id] ||= []) << entry; hsh}
|
20
22
|
}
|
21
|
-
fetch_available_tags = promise { Kaui::TagDefinition.all_for_bundle(
|
22
|
-
fetch_available_subscription_tags = promise { Kaui::TagDefinition.all_for_subscription(
|
23
|
+
fetch_available_tags = promise { Kaui::TagDefinition.all_for_bundle(cached_options_for_klient) }
|
24
|
+
fetch_available_subscription_tags = promise { Kaui::TagDefinition.all_for_subscription(cached_options_for_klient) }
|
23
25
|
|
24
26
|
@bundles = wait(fetch_bundles)
|
25
27
|
@tags_per_bundle = wait(fetch_bundle_tags)
|
@@ -44,10 +46,12 @@ class Kaui::BundlesController < Kaui::EngineController
|
|
44
46
|
end
|
45
47
|
|
46
48
|
def do_transfer
|
47
|
-
|
49
|
+
cached_options_for_klient = options_for_klient
|
50
|
+
|
51
|
+
new_account = Kaui::Account::find_by_id_or_key(params.require(:new_account_key), false, false, cached_options_for_klient)
|
48
52
|
|
49
53
|
bundle = Kaui::Bundle::new(:bundle_id => params.require(:id), :account_id => new_account.account_id)
|
50
|
-
bundle.transfer(nil, params[:billing_policy], current_user.kb_username, params[:reason], params[:comment],
|
54
|
+
bundle.transfer(nil, params[:billing_policy], current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
51
55
|
|
52
56
|
redirect_to kaui_engine.account_bundles_path(new_account.account_id), :notice => 'Bundle was successfully transferred'
|
53
57
|
end
|
@@ -8,11 +8,13 @@ class Kaui::ChargebacksController < Kaui::EngineController
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def create
|
11
|
+
cached_options_for_klient = options_for_klient
|
12
|
+
|
11
13
|
@chargeback = Kaui::Chargeback.new(params.require(:chargeback))
|
12
14
|
should_cancel_subs = (params[:cancel_all_subs] == '1')
|
13
15
|
|
14
16
|
begin
|
15
|
-
payment = @chargeback.chargeback(current_user.kb_username, params[:reason], params[:comment],
|
17
|
+
payment = @chargeback.chargeback(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
16
18
|
rescue => e
|
17
19
|
flash.now[:error] = "Error while creating a new chargeback: #{as_string(e)}"
|
18
20
|
render :action => :new and return
|
@@ -21,15 +23,15 @@ class Kaui::ChargebacksController < Kaui::EngineController
|
|
21
23
|
# Cancel all subscriptions on the account, if required
|
22
24
|
if should_cancel_subs
|
23
25
|
begin
|
24
|
-
account = Kaui::Account.find_by_id(payment.account_id, false, false,
|
25
|
-
account.bundles(
|
26
|
+
account = Kaui::Account.find_by_id(payment.account_id, false, false, cached_options_for_klient)
|
27
|
+
account.bundles(cached_options_for_klient).each do |bundle|
|
26
28
|
bundle.subscriptions.each do |subscription|
|
27
29
|
# Already cancelled?
|
28
30
|
next unless subscription.billing_end_date.blank?
|
29
31
|
|
30
32
|
# Cancel the entitlement immediately but use the default billing policy
|
31
33
|
entitlement = Kaui::Subscription.new(:subscription_id => subscription.subscription_id)
|
32
|
-
entitlement.cancel_entitlement_immediately(current_user.kb_username, params[:reason], params[:comment],
|
34
|
+
entitlement.cancel_entitlement_immediately(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
rescue => e
|
@@ -11,12 +11,14 @@ class Kaui::InvoicesController < Kaui::EngineController
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def pagination
|
14
|
+
cached_options_for_klient = options_for_klient
|
15
|
+
|
14
16
|
searcher = lambda do |search_key, offset, limit|
|
15
|
-
account = Kaui::Account::find_by_id_or_key(search_key, false, false,
|
17
|
+
account = Kaui::Account::find_by_id_or_key(search_key, false, false, cached_options_for_klient) rescue nil
|
16
18
|
if account.nil?
|
17
|
-
Kaui::Invoice.list_or_search(search_key, offset, limit,
|
19
|
+
Kaui::Invoice.list_or_search(search_key, offset, limit, cached_options_for_klient)
|
18
20
|
else
|
19
|
-
account.invoices(true,
|
21
|
+
account.invoices(true, cached_options_for_klient).map! { |invoice| Kaui::Invoice.build_from_raw_invoice(invoice) }
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -81,12 +83,13 @@ class Kaui::InvoicesController < Kaui::EngineController
|
|
81
83
|
end
|
82
84
|
|
83
85
|
def show_html
|
84
|
-
render :
|
86
|
+
render :html => Kaui::Invoice.as_html(params.require(:id), options_for_klient).html_safe
|
85
87
|
end
|
86
88
|
|
87
89
|
def commit_invoice
|
88
|
-
|
89
|
-
invoice.
|
90
|
+
cached_options_for_klient = options_for_klient
|
91
|
+
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), false, 'NONE', cached_options_for_klient)
|
92
|
+
invoice.commit(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
90
93
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id), :notice => 'Invoice successfully committed'
|
91
94
|
end
|
92
95
|
end
|
@@ -73,8 +73,9 @@ class Kaui::PaymentsController < Kaui::EngineController
|
|
73
73
|
end
|
74
74
|
|
75
75
|
def new
|
76
|
-
|
77
|
-
|
76
|
+
cached_options_for_klient = options_for_klient
|
77
|
+
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), true, 'NONE', cached_options_for_klient) }
|
78
|
+
fetch_payment_methods = promise { Kaui::PaymentMethod.find_all_by_account_id(params.require(:account_id), false, cached_options_for_klient) }
|
78
79
|
|
79
80
|
@invoice = wait(fetch_invoice)
|
80
81
|
@payment_methods = wait(fetch_payment_methods)
|
@@ -91,15 +92,17 @@ class Kaui::PaymentsController < Kaui::EngineController
|
|
91
92
|
end
|
92
93
|
|
93
94
|
def show
|
94
|
-
|
95
|
+
cached_options_for_klient = options_for_klient
|
96
|
+
|
97
|
+
invoice_payment = Kaui::InvoicePayment.find_safely_by_id(params.require(:id), cached_options_for_klient)
|
95
98
|
@payment = Kaui::InvoicePayment.build_from_raw_payment(invoice_payment)
|
96
99
|
|
97
100
|
fetch_payment_fields = promise {
|
98
101
|
direct_payment = Kaui::Payment.new(:payment_id => @payment.payment_id)
|
99
|
-
direct_payment.custom_fields('NONE',
|
102
|
+
direct_payment.custom_fields('NONE', cached_options_for_klient).sort { |cf_a, cf_b| cf_a.name.downcase <=> cf_b.name.downcase }
|
100
103
|
}
|
101
104
|
# The payment method may have been deleted
|
102
|
-
fetch_payment_method = promise { Kaui::PaymentMethod.find_safely_by_id(@payment.payment_method_id,
|
105
|
+
fetch_payment_method = promise { Kaui::PaymentMethod.find_safely_by_id(@payment.payment_method_id, cached_options_for_klient) }
|
103
106
|
|
104
107
|
@custom_fields = wait(fetch_payment_fields)
|
105
108
|
@payment_method = wait(fetch_payment_method)
|
@@ -1,9 +1,11 @@
|
|
1
1
|
class Kaui::RefundsController < Kaui::EngineController
|
2
2
|
|
3
3
|
def new
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
cached_options_for_klient = options_for_klient
|
5
|
+
|
6
|
+
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), true, 'NONE', cached_options_for_klient) }
|
7
|
+
fetch_payment = promise { Kaui::InvoicePayment::find_by_id(params.require(:payment_id), false, false, cached_options_for_klient) }
|
8
|
+
fetch_bundles = promise { @account.bundles(cached_options_for_klient) }
|
7
9
|
|
8
10
|
@invoice = wait(fetch_invoice)
|
9
11
|
@payment = wait(fetch_payment)
|
@@ -33,6 +33,13 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
33
33
|
@subscription.plan_name = plan_name
|
34
34
|
requested_date = params[:type_change] == "DATE" ? params[:requested_date].presence : nil
|
35
35
|
|
36
|
+
# price override?
|
37
|
+
override_fixed_price = plan_details.phases.first.prices.blank? rescue false
|
38
|
+
override_recurring_price = !override_fixed_price
|
39
|
+
phase_type = @bundle.nil? ? plan_details.phases.first.type : @bundle.subscriptions.first.phase_type
|
40
|
+
overrides = price_overrides(phase_type, override_fixed_price, override_recurring_price)
|
41
|
+
@subscription.price_overrides = overrides unless overrides.blank?
|
42
|
+
|
36
43
|
# un-set product_category since is not needed if plan name exist
|
37
44
|
@subscription.product_category = nil
|
38
45
|
@subscription = @subscription.create(current_user.kb_username, params[:reason], params[:comment], requested_date, false, options_for_klient)
|
@@ -49,13 +56,9 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
49
56
|
_, plans_details = lookup_bundle_and_plan_details(@subscription)
|
50
57
|
# Use a Set to deal with multiple pricelists
|
51
58
|
@plans = Set.new.merge(plans_details.map { |p| p.plan })
|
52
|
-
|
53
|
-
@current_plan = "#{@subscription.product_name} #{@subscription.billing_period}".humanize
|
54
|
-
@current_plan += " (price list #{@subscription.price_list})" if @subscription.price_list != 'DEFAULT'
|
55
59
|
end
|
56
60
|
|
57
61
|
def update
|
58
|
-
|
59
62
|
plan_name = params.require(:plan_name)
|
60
63
|
|
61
64
|
requested_date = params[:type_change] == "DATE" ? params[:requested_date].presence : nil
|
@@ -65,9 +68,16 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
65
68
|
|
66
69
|
subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
67
70
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
+
input = { :planName => plan_name }
|
72
|
+
|
73
|
+
# price override?
|
74
|
+
current_plan = subscription.prices.select { |price| price['phaseType'] == subscription.phase_type }
|
75
|
+
override_fixed_price = current_plan.last['recurringPrice'].nil?
|
76
|
+
override_recurring_price = !override_fixed_price
|
77
|
+
overrides = price_overrides(subscription.phase_type, override_fixed_price, override_recurring_price)
|
78
|
+
input[:priceOverrides] = overrides unless overrides.blank?
|
79
|
+
|
80
|
+
subscription.change_plan(input,
|
71
81
|
current_user.kb_username,
|
72
82
|
params[:reason],
|
73
83
|
params[:comment],
|
@@ -78,6 +88,8 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
78
88
|
options_for_klient)
|
79
89
|
|
80
90
|
redirect_to kaui_engine.account_bundles_path(subscription.account_id), :notice => 'Subscription plan successfully changed'
|
91
|
+
rescue => e
|
92
|
+
redirect_to edit_subscription_path(params.require(:id)), :flash => { :error => "Error while changing subscription: #{as_string(e)}" }
|
81
93
|
end
|
82
94
|
|
83
95
|
def destroy
|
@@ -206,4 +218,19 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
206
218
|
|
207
219
|
end
|
208
220
|
end
|
221
|
+
|
222
|
+
def price_overrides(phase_type, override_fixed_price = true, override_recurring_price = false)
|
223
|
+
return nil if params[:price_override].blank?
|
224
|
+
|
225
|
+
price_override = params[:price_override]
|
226
|
+
overrides = []
|
227
|
+
override = KillBillClient::Model::PhasePriceAttributes.new
|
228
|
+
override.phase_type = phase_type
|
229
|
+
override.fixed_price = price_override if override_fixed_price
|
230
|
+
override.recurring_price = price_override if override_recurring_price
|
231
|
+
|
232
|
+
overrides << override
|
233
|
+
|
234
|
+
overrides
|
235
|
+
end
|
209
236
|
end
|
@@ -62,15 +62,33 @@ module Kaui
|
|
62
62
|
|
63
63
|
if humanized_billing_period.nil?
|
64
64
|
if humanized_price_list.nil?
|
65
|
-
humanized_product_name
|
65
|
+
humanized_product_name = humanized_product_name + humanized_price_override(sub, '', '(', ')')
|
66
66
|
else
|
67
|
-
humanized_product_name+ ' (' + humanized_price_list.downcase + ')'
|
67
|
+
humanized_product_name = humanized_product_name + ' (' + humanized_price_list.downcase + humanized_price_override(sub) + ')'
|
68
68
|
end
|
69
69
|
else
|
70
70
|
if humanized_price_list.nil?
|
71
|
-
humanized_product_name + ' (' + humanized_billing_period.downcase + ')'
|
71
|
+
humanized_product_name = humanized_product_name + ' (' + humanized_billing_period.downcase + humanized_price_override(sub) + ')'
|
72
72
|
else
|
73
|
-
humanized_product_name+ ' (' + humanized_billing_period.downcase + ', ' + humanized_price_list.downcase + ')'
|
73
|
+
humanized_product_name = humanized_product_name + ' (' + humanized_billing_period.downcase + ', ' + humanized_price_list.downcase + humanized_price_override(sub) + ')'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
humanized_product_name.html_safe
|
78
|
+
end
|
79
|
+
|
80
|
+
def humanized_price_override(sub, separation = ', ', open_bracket = '', close_bracket = '')
|
81
|
+
if sub.plan_name.scan(/ *-\d+$/).empty?
|
82
|
+
''
|
83
|
+
else
|
84
|
+
current_plan = sub.prices.select { |price| price['phaseType'] == sub.phase_type && price['planName'] == sub.plan_name }
|
85
|
+
price_override = current_plan.last['fixedPrice'] || current_plan.last['recurringPrice']
|
86
|
+
|
87
|
+
if price_override.blank?
|
88
|
+
''
|
89
|
+
else
|
90
|
+
span = "<span data-toggle=\"popover\" class=\"price-override-popover\" data-content=\"#{price_override}\"><b>price override</b></span>"
|
91
|
+
"#{open_bracket}#{separation}#{span}#{close_bracket}"
|
74
92
|
end
|
75
93
|
end
|
76
94
|
end
|
@@ -75,6 +75,7 @@ class Kaui::AdminTenant < KillBillClient::Model::Tenant
|
|
75
75
|
else
|
76
76
|
hsh[plugin_key] = yml[plugin_key.to_sym]
|
77
77
|
end
|
78
|
+
hsh[plugin_key][:_raw] = e.values[0]
|
78
79
|
elsif is_an_official_plugin && is_kv?(e.values[0])
|
79
80
|
# Construct hash of properties based on java properties (k1=v1\nk2=v2\n...)
|
80
81
|
hsh[plugin_key] = e.values[0].split("\n").inject({}) do |h, p0|
|
@@ -82,9 +83,10 @@ class Kaui::AdminTenant < KillBillClient::Model::Tenant
|
|
82
83
|
h[k] = v;
|
83
84
|
h
|
84
85
|
end
|
86
|
+
hsh[plugin_key][:_raw] = e.values[0]
|
85
87
|
else
|
86
88
|
# Construct simple hash with one property :raw_config
|
87
|
-
hsh[killbill_key] = {:raw_config => e.values[0]}
|
89
|
+
hsh[killbill_key] = {:raw_config => e.values[0], :_raw => e.values[0]}
|
88
90
|
end
|
89
91
|
hsh
|
90
92
|
end
|
@@ -99,21 +101,20 @@ class Kaui::AdminTenant < KillBillClient::Model::Tenant
|
|
99
101
|
end
|
100
102
|
"#{plugin_key}::#{serialized_props}"
|
101
103
|
end.join(";")
|
102
|
-
|
103
104
|
end
|
104
105
|
|
105
|
-
|
106
106
|
def format_plugin_config(plugin_key, plugin_type, props)
|
107
107
|
return nil unless props.present?
|
108
|
+
return props['raw_config'].gsub(/\r\n?/, "\n") if props['raw_config']
|
109
|
+
|
108
110
|
if plugin_type == 'ruby'
|
109
111
|
require 'yaml'
|
110
112
|
props = reformat_plugin_config(plugin_type, props)
|
111
113
|
hsh = {}
|
112
114
|
hsh[plugin_key.to_sym] = {}
|
113
115
|
props.each do |k,v|
|
114
|
-
hsh[plugin_key.to_sym][k.to_sym] = v
|
116
|
+
hsh[plugin_key.to_sym][k.to_sym] = v
|
115
117
|
end
|
116
|
-
hsh[plugin_key.to_sym]
|
117
118
|
hsh.to_yaml
|
118
119
|
elsif plugin_type == 'java'
|
119
120
|
props = reformat_plugin_config(plugin_type, props)
|
data/app/models/kaui/base.rb
CHANGED
@@ -2,9 +2,9 @@ class Kaui::Base
|
|
2
2
|
|
3
3
|
def self.to_money(amount, currency)
|
4
4
|
begin
|
5
|
-
return Money.
|
5
|
+
return Money.from_amount(amount.to_f, currency)
|
6
6
|
rescue => _
|
7
7
|
end if currency.present?
|
8
|
-
Money.
|
8
|
+
Money.from_amount(amount.to_f, 'USD')
|
9
9
|
end
|
10
10
|
end
|
@@ -112,12 +112,12 @@
|
|
112
112
|
if ($("#toggle_raw").prop("checked")) {
|
113
113
|
var raw = [];
|
114
114
|
raw.push({ is_raw_config: true, property: "raw_config", property_label: "Raw Config", value: ''});
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
115
|
+
|
116
|
+
var plugin_name = $('#entered_plugin_name').val();
|
117
|
+
var plugin_key = $("#plugin_key").val();
|
118
|
+
var existing_props = get_tenant_plugin_properties(plugin_key, plugin_name);
|
119
|
+
raw[0].value = existing_props['_raw'];
|
120
|
+
|
121
121
|
render_plugin_key_values(raw, plugin_key_values);
|
122
122
|
} else {
|
123
123
|
render_plugin_key_values(plugin_key_values, plugin_key_values);
|
@@ -135,6 +135,7 @@
|
|
135
135
|
$("#plugin_type").val(selectedOption[0].dataset['pluginType']);
|
136
136
|
$('#plugin_config_properties').attr('plugin_name', '');
|
137
137
|
$('#plugin_config_properties_header').hide();
|
138
|
+
$("#toggle_raw").prop('checked', false);
|
138
139
|
add_properties_for_plugin(plugin_key, plugin_name);
|
139
140
|
}
|
140
141
|
});
|
@@ -168,7 +169,7 @@
|
|
168
169
|
|
169
170
|
function get_existing_tenant_plugin_properties(entered_plugin_name) {
|
170
171
|
var tenant_plugin_properties = $('#entered_plugin_name').attr('tenant_plugin_config');
|
171
|
-
var res = {}
|
172
|
+
var res = {};
|
172
173
|
if (tenant_plugin_properties != undefined) {
|
173
174
|
$.each(tenant_plugin_properties.split(';'), function(idx, el) {
|
174
175
|
var el_parts = el.split('::');
|
@@ -180,7 +181,7 @@
|
|
180
181
|
} else {
|
181
182
|
$.map(el_props.split('|'), function(el) {
|
182
183
|
var parts = el.split('=');
|
183
|
-
res[parts[0]] = parts
|
184
|
+
res[parts[0]] = parts.slice(1).join('=');
|
184
185
|
});
|
185
186
|
}
|
186
187
|
return false;
|
@@ -215,6 +216,18 @@
|
|
215
216
|
return res;
|
216
217
|
}
|
217
218
|
|
219
|
+
function get_tenant_plugin_properties(plugin_key, plugin_name) {
|
220
|
+
/* Retrieve existing plugin properties for this tenant */
|
221
|
+
var existing_props = get_existing_tenant_plugin_properties(plugin_key);
|
222
|
+
|
223
|
+
// try by plugin name for proprietary plugins
|
224
|
+
if (isBlank(existing_props)) {
|
225
|
+
existing_props = get_existing_tenant_plugin_properties(plugin_name);
|
226
|
+
}
|
227
|
+
|
228
|
+
return existing_props;
|
229
|
+
}
|
230
|
+
|
218
231
|
function add_properties_for_plugin(plugin_key, plugin_name) {
|
219
232
|
var plugin_info = get_selected_plugin_info(plugin_key);
|
220
233
|
|
@@ -229,13 +242,7 @@
|
|
229
242
|
return;
|
230
243
|
}
|
231
244
|
|
232
|
-
|
233
|
-
var existing_props = get_existing_tenant_plugin_properties(plugin_key);
|
234
|
-
|
235
|
-
// try by plugin name for proprietary plugins
|
236
|
-
if (isBlank(existing_props)) {
|
237
|
-
existing_props = get_existing_tenant_plugin_properties(plugin_name);
|
238
|
-
}
|
245
|
+
var existing_props = get_tenant_plugin_properties(plugin_key, plugin_name);
|
239
246
|
|
240
247
|
var type = plugin_info['type'];
|
241
248
|
var props = plugin_info['props']
|
@@ -285,7 +292,9 @@
|
|
285
292
|
var plugin_props_with_values = [];
|
286
293
|
|
287
294
|
$.each(merged_props_with_values, function(p, v) {
|
288
|
-
|
295
|
+
if (p != '_raw') {
|
296
|
+
plugin_props_with_values.push({ property_label: format_label(p), property: p, value: v, is_raw_config: p == 'raw_config'});
|
297
|
+
}
|
289
298
|
});
|
290
299
|
|
291
300
|
render_plugin_key_values(plugin_props_with_values, plugin_props_with_values);
|
@@ -2,7 +2,12 @@
|
|
2
2
|
|
3
3
|
<div class="column-block">
|
4
4
|
|
5
|
-
<h1>
|
5
|
+
<h1>
|
6
|
+
Invoice <%= @invoice.invoice_number %>
|
7
|
+
<% unless @invoice.invoice_number.blank? %>
|
8
|
+
<%= link_to 'View customer invoice html', kaui_engine.show_html_invoice_path(@invoice.invoice_id), :class => 'btn', :target => '_blank' %>
|
9
|
+
<% end %>
|
10
|
+
</h1>
|
6
11
|
|
7
12
|
<% dry_run = @invoice.invoice_number.blank? %>
|
8
13
|
<% if dry_run %>
|
@@ -1,13 +1,19 @@
|
|
1
1
|
<%= form_for @subscription, :url => subscription_path(@subscription.subscription_id), :html => {:method => :put, :class => 'form-horizontal'} do |f| %>
|
2
2
|
<div class="form-group">
|
3
|
-
<%= label_tag :plan_name, 'New plan', :class => 'col-sm-
|
4
|
-
<div class="col-sm-
|
5
|
-
<%= select_tag :plan_name, options_for_select(@plans), :class => 'form-control' %>
|
3
|
+
<%= label_tag :plan_name, 'New plan', :class => 'col-sm-3 control-label' %>
|
4
|
+
<div class="col-sm-9">
|
5
|
+
<%= select_tag :plan_name, options_for_select(@plans, @subscription.plan_name.gsub(/ *-\d+$/, '')), :class => 'form-control' %>
|
6
6
|
</div>
|
7
7
|
</div>
|
8
8
|
|
9
9
|
<div class="form-group">
|
10
|
-
|
10
|
+
<%= label_tag :price_override, 'Price Override', :class => 'col-sm-3 control-label' %>
|
11
|
+
<div class="col-sm-9">
|
12
|
+
<%= number_field_tag :price_override, nil, :class => 'form-control' %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
<div class="form-group">
|
16
|
+
<div class="col-sm-offset-3 col-sm-9">
|
11
17
|
<div class="radio">
|
12
18
|
<%= label_tag :type_change do %>
|
13
19
|
<%= radio_button_tag :type_change, 'DEFAULT', :checked => true %>
|
@@ -29,20 +35,20 @@
|
|
29
35
|
</div>
|
30
36
|
</div>
|
31
37
|
<div class="form-group", id="form_requested_date" >
|
32
|
-
<%= label_tag :requested_date, 'Change Date', :class => 'col-sm-
|
33
|
-
<div class="col-sm-
|
38
|
+
<%= label_tag :requested_date, 'Change Date', :class => 'col-sm-3 control-label' %>
|
39
|
+
<div class="col-sm-9">
|
34
40
|
<%= text_field_tag :requested_date, Date.parse(Time.now.to_s).to_s, :class => 'form-control date-picker' %>
|
35
41
|
</div>
|
36
42
|
</div>
|
37
43
|
<div class="form-group", id="form_policy">
|
38
|
-
<%= label_tag :policy, 'Policy', :class => 'col-sm-
|
39
|
-
<div class="col-sm-
|
44
|
+
<%= label_tag :policy, 'Policy', :class => 'col-sm-3 control-label' %>
|
45
|
+
<div class="col-sm-9">
|
40
46
|
<%= select_tag :policy, options_for_select(['', 'IMMEDIATE', 'END_OF_TERM']), :class => 'form-control' %>
|
41
47
|
<p class="help-block">Leave blank for default</p>
|
42
48
|
</div>
|
43
49
|
</div>
|
44
50
|
<div class="form-group">
|
45
|
-
<div class="col-sm-offset-
|
51
|
+
<div class="col-sm-offset-3 col-sm-9">
|
46
52
|
<%= submit_tag 'Save', :class => 'btn btn-default' %>
|
47
53
|
</div>
|
48
54
|
</div>
|
@@ -22,6 +22,12 @@
|
|
22
22
|
<%= select_tag :plan_name, options_for_select(@plans), :class => 'form-control' %>
|
23
23
|
</div>
|
24
24
|
</div>
|
25
|
+
<div class="form-group">
|
26
|
+
<%= label_tag :price_override, 'Price Override', :class => 'col-sm-2 control-label' %>
|
27
|
+
<div class="col-sm-10">
|
28
|
+
<%= number_field_tag :price_override, nil, :class => 'form-control' %>
|
29
|
+
</div>
|
30
|
+
</div>
|
25
31
|
<div class="form-group">
|
26
32
|
<div class="col-sm-offset-2 col-sm-10">
|
27
33
|
<div class="radio">
|
data/lib/kaui/version.rb
CHANGED
@@ -20,15 +20,4 @@ class Kaui::BundleTagsControllerTest < Kaui::FunctionalTestHelper
|
|
20
20
|
assert_not_nil assigns(:tag_names)
|
21
21
|
assert_not_nil assigns(:available_tags)
|
22
22
|
end
|
23
|
-
|
24
|
-
test 'should update tags' do
|
25
|
-
post :update,
|
26
|
-
:account_id => @account.account_id,
|
27
|
-
:bundle_id => @bundle.bundle_id,
|
28
|
-
:'tag_00000000-0000-0000-0000-000000000001' => 'AUTO_PAY_OFF',
|
29
|
-
:'tag_00000000-0000-0000-0000-000000000005' => 'MANUAL_PAY',
|
30
|
-
:'tag_00000000-0000-0000-0000-000000000003' => 'OVERDUE_ENFORCEMENT_OFF'
|
31
|
-
assert_redirected_to account_bundles_path(@account.account_id)
|
32
|
-
assert_equal 'Bundle tags successfully set', flash[:notice]
|
33
|
-
end
|
34
23
|
end
|
@@ -82,22 +82,21 @@ class Kaui::SubscriptionsControllerTest < Kaui::FunctionalTestHelper
|
|
82
82
|
assert_response 200
|
83
83
|
assert_not_nil assigns(:subscription)
|
84
84
|
assert_not_nil assigns(:plans)
|
85
|
-
assert_not_nil assigns(:current_plan)
|
86
85
|
end
|
87
86
|
|
88
87
|
test 'should handle errors during update' do
|
89
88
|
post :update, :id => @bundle.subscriptions.first.subscription_id
|
90
|
-
assert_redirected_to
|
91
|
-
assert_equal '
|
89
|
+
assert_redirected_to edit_subscription_path(@bundle.subscriptions.first.subscription_id)
|
90
|
+
assert_equal 'Error while changing subscription: param is missing or the value is empty: plan_name', flash[:error]
|
92
91
|
|
93
92
|
subscription_id = SecureRandom.uuid.to_s
|
94
93
|
post :update, :id => subscription_id, :plan_name => 'super-monthly'
|
95
|
-
assert_redirected_to
|
96
|
-
assert_equal "Error while
|
94
|
+
assert_redirected_to edit_subscription_path(subscription_id)
|
95
|
+
assert_equal "Error while changing subscription: Error 404: Object id=#{subscription_id} type=SUBSCRIPTION doesn't exist!", flash[:error]
|
97
96
|
|
98
97
|
post :update, :id => @bundle.subscriptions.first.subscription_id, :plan_name => 'not-exists'
|
99
|
-
assert_redirected_to
|
100
|
-
assert_equal "Error while
|
98
|
+
assert_redirected_to edit_subscription_path(@bundle.subscriptions.first.subscription_id)
|
99
|
+
assert_equal "Error while changing subscription: Error 400: Could not find a plan matching spec: (plan: 'not-exists', product: 'undefined', billing period: 'undefined', pricelist 'undefined')", flash[:error]
|
101
100
|
end
|
102
101
|
|
103
102
|
test 'should update' do
|
@@ -170,4 +169,26 @@ class Kaui::SubscriptionsControllerTest < Kaui::FunctionalTestHelper
|
|
170
169
|
assert_equal JSON[@response.body]['is_found'], true
|
171
170
|
end
|
172
171
|
|
172
|
+
test 'should update with price override' do
|
173
|
+
post :update,
|
174
|
+
:id => @bundle.subscriptions.first.subscription_id,
|
175
|
+
:plan_name => 'super-monthly',
|
176
|
+
:price_override => 500
|
177
|
+
assert_redirected_to account_bundles_path(@bundle.subscriptions.first.account_id)
|
178
|
+
assert_equal 'Subscription plan successfully changed', flash[:notice]
|
179
|
+
end
|
180
|
+
|
181
|
+
test 'should create with price override' do
|
182
|
+
post :create,
|
183
|
+
:subscription => {
|
184
|
+
:account_id => @account.account_id,
|
185
|
+
:external_key => SecureRandom.uuid,
|
186
|
+
},
|
187
|
+
:price_override => 500,
|
188
|
+
:plan_name => 'standard-monthly'
|
189
|
+
|
190
|
+
assert_redirected_to account_bundles_path(@account.account_id)
|
191
|
+
assert_equal 'Subscription was successfully created', flash[:notice]
|
192
|
+
end
|
193
|
+
|
173
194
|
end
|
@@ -14,6 +14,30 @@ class Kaui::AdminTenantTest < ActiveSupport::TestCase
|
|
14
14
|
{"plugin_key":"payu-latam","plugin_name":"killbill-payu-latam","plugin_type":"ruby","installed":false},{"plugin_key":"payment-test","plugin_name":"killbill-payment-test","plugin_type":"ruby","installed":false},
|
15
15
|
{"plugin_key":"securenet","plugin_name":"killbill-securenet","plugin_type":"ruby","installed":false},{"plugin_key":"stripe","plugin_name":"killbill-stripe","plugin_type":"ruby","installed":false},{"plugin_key":"zendesk","plugin_name":"killbill-zendesk","plugin_type":"ruby","installed":false}]'
|
16
16
|
|
17
|
+
test 'should not reformat raw config before upload' do
|
18
|
+
props = {"raw_config" => ":paypal_express:\r\n :signature: \"THISISAREALLYLONGSIGNATGURESTRING123\"\r\n :login: \"username-facilitator_domain.com\"\r\n :password: \"SUPERSECRETPW\""}
|
19
|
+
formatted = Kaui::AdminTenant.format_plugin_config('paypal_express', 'ruby', props)
|
20
|
+
expected=<<-EOS.chomp
|
21
|
+
:paypal_express:
|
22
|
+
:signature: "THISISAREALLYLONGSIGNATGURESTRING123"
|
23
|
+
:login: "username-facilitator_domain.com"
|
24
|
+
:password: "SUPERSECRETPW"
|
25
|
+
EOS
|
26
|
+
assert_equal expected, formatted
|
27
|
+
end
|
28
|
+
|
29
|
+
test 'should reformat ruby config before upload' do
|
30
|
+
props = {"login"=>"ljskf9\"0sdf'34%", "password"=>"lskdj\"f-12;sdf'[5%"}
|
31
|
+
formatted = Kaui::AdminTenant.format_plugin_config('securenet', 'ruby', props)
|
32
|
+
expected=<<-EOS
|
33
|
+
---
|
34
|
+
:securenet:
|
35
|
+
:login: ljskf9"0sdf'34%
|
36
|
+
:password: lskdj"f-12;sdf'[5%
|
37
|
+
EOS
|
38
|
+
assert_equal expected, formatted
|
39
|
+
end
|
40
|
+
|
17
41
|
test 'can split camel dash underscore space strings' do
|
18
42
|
adminTenantController = Kaui::AdminTenantsController.new
|
19
43
|
|
@@ -36,7 +60,6 @@ class Kaui::AdminTenantTest < ActiveSupport::TestCase
|
|
36
60
|
string = 'this-IsA string_to-split'
|
37
61
|
splitted = adminTenantController.send(:split_camel_dash_underscore_space, string)
|
38
62
|
assert_split(splitted)
|
39
|
-
|
40
63
|
end
|
41
64
|
|
42
65
|
test 'can do a fuzzy match of a plugin to suggest a plugin' do
|
@@ -71,7 +94,6 @@ class Kaui::AdminTenantTest < ActiveSupport::TestCase
|
|
71
94
|
found_plugin, weights = adminTenantController.send(:fuzzy_match, plugin_name, plugins_info)
|
72
95
|
assert_equal weights.size, 0
|
73
96
|
assert_equal found_plugin[:plugin_name], 'killbill-avatax'
|
74
|
-
|
75
97
|
end
|
76
98
|
|
77
99
|
test 'should fetch proprietary plugin config' do
|
@@ -84,13 +106,12 @@ class Kaui::AdminTenantTest < ActiveSupport::TestCase
|
|
84
106
|
plugin_config = 'key=value'
|
85
107
|
Kaui::AdminTenant.upload_tenant_plugin_config(plugin_name, plugin_config, options[:username], nil, nil, options)
|
86
108
|
|
87
|
-
|
88
109
|
plugins_config = Kaui::AdminTenant.get_tenant_plugin_config({}, options)
|
89
110
|
assert_not_nil(plugins_config)
|
90
111
|
|
91
112
|
plugin_info = plugins_config.split('::')
|
92
113
|
assert_equal plugin_name, plugin_info[0]
|
93
|
-
assert_equal
|
114
|
+
assert_equal 'key=value|_raw=key=value', plugin_info[1].gsub('raw_config=','')
|
94
115
|
end
|
95
116
|
|
96
117
|
test 'should fetch plugin config' do
|
@@ -109,7 +130,6 @@ class Kaui::AdminTenantTest < ActiveSupport::TestCase
|
|
109
130
|
plugin_config = Kaui::AdminTenant.format_plugin_config(plugin_key, 'ruby', plugin_properties)
|
110
131
|
Kaui::AdminTenant.upload_tenant_plugin_config(plugin_name, plugin_config, options[:username], nil, nil, options)
|
111
132
|
|
112
|
-
|
113
133
|
plugins_config = Kaui::AdminTenant.get_tenant_plugin_config({ :paypal_express => { 'type' => 'ruby',
|
114
134
|
'artifact_id' => 'paypal-express-plugin'} }, options)
|
115
135
|
assert_not_nil(plugins_config)
|
data/test/unit/kaui/base_test.rb
CHANGED
@@ -4,11 +4,16 @@ class Kaui::BaseTest < ActiveSupport::TestCase
|
|
4
4
|
|
5
5
|
test 'can convert to money' do
|
6
6
|
# Happy path
|
7
|
-
%w(GBP MXN BRL EUR AUD USD CAD
|
7
|
+
%w(GBP MXN BRL EUR AUD USD CAD).each do |currency|
|
8
8
|
money = Kaui::Base.to_money(12.42, currency)
|
9
9
|
assert_equal 1242, money.cents
|
10
10
|
assert_equal currency, money.currency.iso_code
|
11
11
|
end
|
12
|
+
%w(JPY KRW).each do |currency|
|
13
|
+
money = Kaui::Base.to_money(12, currency)
|
14
|
+
assert_equal 12, money.cents
|
15
|
+
assert_equal currency, money.currency.iso_code
|
16
|
+
end
|
12
17
|
|
13
18
|
# Edge cases
|
14
19
|
bad_money = Kaui::Base.to_money(12.42, 'blahblah')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Killbill core team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|