kaui 2.0.1 → 2.0.2
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/app/controllers/kaui/admin_tenants_controller.rb +73 -28
- data/app/controllers/kaui/payment_methods_controller.rb +9 -3
- data/app/helpers/kaui/subscription_helper.rb +5 -4
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +2 -2
- data/app/views/kaui/admin_tenants/new_catalog.html.erb +16 -15
- data/app/views/kaui/chargebacks/_form.html.erb +1 -1
- data/app/views/kaui/charges/_form.html.erb +1 -1
- data/app/views/kaui/payments/_form.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/lib/kaui/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2de0a1cf9deebfbdae2781d8bfe36637ecd1bf6e01877c6d88ddbc95a77cb05
|
4
|
+
data.tar.gz: c8089c093f566b916137637e53b56a409d7e5bee8e74d0ed16f2bdaabf76d262
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d26ede3ecdbfdc270234d94c374271bbb47bb94bd90e3d4f98e93706f77b623a7a6236c00ce28d354508cd378402bc60a55a2734695f5f88b8a4d7cdf44d1692
|
7
|
+
data.tar.gz: 870b1a5e19fed59434aec7c4a7a1f4374c834a2e8208689301c7554f91d95ab2f8dd43efc1c989bf679b1426a5eba2365fa8d2a675376f904d3db3dd9baad3fc
|
@@ -115,27 +115,15 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def new_catalog
|
118
|
-
@tenant = safely_find_tenant_by_id(params[:id])
|
119
|
-
|
120
118
|
options = tenant_options_for_client
|
121
|
-
options
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
latest_catalog.products.select { |p| p.type == 'BASE' }.map { |p| p.name } : []
|
130
|
-
@available_ao_products = latest_catalog && latest_catalog.products ?
|
131
|
-
latest_catalog.products.select { |p| p.type == 'ADD_ON' }.map { |p| p.name } : []
|
132
|
-
@available_standalone_products = latest_catalog && latest_catalog.products ?
|
133
|
-
latest_catalog.products.select { |p| p.type == 'STANDALONE' }.map { |p| p.name } : []
|
134
|
-
@product_categories = [:BASE, :ADD_ON, :STANDALONE]
|
135
|
-
@billing_period = [:DAILY, :WEEKLY, :BIWEEKLY, :THIRTY_DAYS, :MONTHLY, :QUARTERLY, :BIANNUAL, :ANNUAL, :BIENNIAL]
|
136
|
-
@time_units = [:UNLIMITED, :DAYS, :WEEKS, :MONTHS, :YEARS]
|
137
|
-
|
138
|
-
@simple_plan = Kaui::SimplePlan.new
|
119
|
+
fetch_state_for_new_catalog_screen(options)
|
120
|
+
@simple_plan = Kaui::SimplePlan.new({
|
121
|
+
:product_category => 'BASE',
|
122
|
+
:amount => 0,
|
123
|
+
:trial_length => 0,
|
124
|
+
:currency => 'USD',
|
125
|
+
:billing_period => 'MONTHLY'
|
126
|
+
})
|
139
127
|
end
|
140
128
|
|
141
129
|
def delete_catalog
|
@@ -183,21 +171,55 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
183
171
|
end
|
184
172
|
|
185
173
|
def create_simple_plan
|
186
|
-
current_tenant = safely_find_tenant_by_id(params[:id])
|
187
|
-
|
188
174
|
options = tenant_options_for_client
|
189
|
-
options
|
190
|
-
options[:api_secret] = current_tenant.api_secret
|
175
|
+
fetch_state_for_new_catalog_screen(options)
|
191
176
|
|
192
177
|
simple_plan = params.require(:simple_plan).delete_if { |e, value| value.blank? }
|
193
178
|
# Fix issue in Rails where first entry in the multi-select array is an empty string
|
194
179
|
simple_plan["available_base_products"].reject!(&:blank?) if simple_plan["available_base_products"]
|
195
180
|
|
196
|
-
simple_plan =
|
197
|
-
|
198
|
-
|
181
|
+
@simple_plan = Kaui::SimplePlan.new(simple_plan)
|
182
|
+
|
183
|
+
valid = true
|
184
|
+
# Validate new simple plan
|
185
|
+
# https://github.com/killbill/killbill-admin-ui/issues/247
|
186
|
+
if @available_base_products.include?(@simple_plan.plan_id)
|
187
|
+
flash.now[:error] = "Error while creating plan: invalid plan name (#{@simple_plan.plan_id} is a BASE product already)"
|
188
|
+
valid = false
|
189
|
+
elsif @available_ao_products.include?(@simple_plan.plan_id)
|
190
|
+
flash.now[:error] = "Error while creating plan: invalid plan name (#{@simple_plan.plan_id} is an ADD_ON product already)"
|
191
|
+
valid = false
|
192
|
+
elsif @available_standalone_products.include?(@simple_plan.plan_id)
|
193
|
+
flash.now[:error] = "Error while creating plan: invalid plan name (#{@simple_plan.plan_id} is a STANDALONE product already)"
|
194
|
+
valid = false
|
195
|
+
elsif @all_plans.include?(@simple_plan.product_name)
|
196
|
+
flash.now[:error] = "Error while creating plan: invalid product name (#{@simple_plan.product_name} is a plan name already)"
|
197
|
+
valid = false
|
198
|
+
elsif @all_plans.include?(@simple_plan.plan_id)
|
199
|
+
flash.now[:error] = "Error while creating plan: plan #{@simple_plan.plan_id} already exists"
|
200
|
+
valid = false
|
201
|
+
elsif @available_base_products.include?(@simple_plan.product_name) && @simple_plan.product_category != 'BASE'
|
202
|
+
flash.now[:error] = "Error while creating plan: product #{@simple_plan.product_name} is a BASE product"
|
203
|
+
valid = false
|
204
|
+
elsif @available_ao_products.include?(@simple_plan.product_name) && @simple_plan.product_category != 'ADD_ON'
|
205
|
+
flash.now[:error] = "Error while creating plan: product #{@simple_plan.product_name} is an ADD_ON product"
|
206
|
+
valid = false
|
207
|
+
elsif @available_standalone_products.include?(@simple_plan.product_name) && @simple_plan.product_category != 'STANDALONE'
|
208
|
+
flash.now[:error] = "Error while creating plan: product #{@simple_plan.product_name} is a STANDALONE product"
|
209
|
+
valid = false
|
210
|
+
end
|
199
211
|
|
200
|
-
|
212
|
+
if valid
|
213
|
+
begin
|
214
|
+
Kaui::Catalog.add_tenant_catalog_simple_plan(@simple_plan, options[:username], nil, comment, options)
|
215
|
+
redirect_to admin_tenant_path(@tenant.id), :notice => 'Catalog plan was successfully added'
|
216
|
+
rescue => e
|
217
|
+
flash.now[:error] = "Error while creating plan: #{as_string(e)}"
|
218
|
+
render :action => :new_catalog
|
219
|
+
end
|
220
|
+
else
|
221
|
+
render :action => :new_catalog
|
222
|
+
end
|
201
223
|
end
|
202
224
|
|
203
225
|
def new_overdue_config
|
@@ -415,6 +437,29 @@ class Kaui::AdminTenantsController < Kaui::EngineController
|
|
415
437
|
|
416
438
|
private
|
417
439
|
|
440
|
+
# Share code to handle render on error
|
441
|
+
def fetch_state_for_new_catalog_screen(options)
|
442
|
+
@tenant = safely_find_tenant_by_id(params[:id])
|
443
|
+
|
444
|
+
options[:api_key] = @tenant.api_key
|
445
|
+
options[:api_secret] = @tenant.api_secret
|
446
|
+
|
447
|
+
latest_catalog = Kaui::Catalog::get_catalog_json(true, nil, options)
|
448
|
+
@all_plans = latest_catalog ? (latest_catalog.products || []).map(&:plans).flatten.map(&:name) : []
|
449
|
+
|
450
|
+
@ao_mapping = Kaui::Catalog::build_ao_mapping(latest_catalog)
|
451
|
+
|
452
|
+
@available_base_products = latest_catalog && latest_catalog.products ?
|
453
|
+
latest_catalog.products.select { |p| p.type == 'BASE' }.map { |p| p.name } : []
|
454
|
+
@available_ao_products = latest_catalog && latest_catalog.products ?
|
455
|
+
latest_catalog.products.select { |p| p.type == 'ADD_ON' }.map { |p| p.name } : []
|
456
|
+
@available_standalone_products = latest_catalog && latest_catalog.products ?
|
457
|
+
latest_catalog.products.select { |p| p.type == 'STANDALONE' }.map { |p| p.name } : []
|
458
|
+
@product_categories = [:BASE, :ADD_ON, :STANDALONE]
|
459
|
+
@billing_period = [:DAILY, :WEEKLY, :BIWEEKLY, :THIRTY_DAYS, :MONTHLY, :QUARTERLY, :BIANNUAL, :ANNUAL, :BIENNIAL]
|
460
|
+
@time_units = [:UNLIMITED, :DAYS, :WEEKS, :MONTHS, :YEARS]
|
461
|
+
end
|
462
|
+
|
418
463
|
def safely_find_tenant_by_id(tenant_id)
|
419
464
|
tenant = Kaui::Tenant.find_by_id(tenant_id)
|
420
465
|
raise ActiveRecord::RecordNotFound.new('Could not find tenant ' + tenant_id) unless retrieve_tenants_for_current_user.include?(tenant.kb_tenant_id)
|
@@ -45,9 +45,15 @@ class Kaui::PaymentMethodsController < Kaui::EngineController
|
|
45
45
|
}
|
46
46
|
|
47
47
|
@plugin_properties = params[:plugin_properties].values.select{ |item| !(item['value'].blank? || item['key'].blank?) } rescue @plugin_properties = nil
|
48
|
-
@plugin_properties.
|
49
|
-
|
50
|
-
|
48
|
+
if @plugin_properties.blank?
|
49
|
+
# In case of error, we want the view to receive nil, not [], so that at least the first row is populated (required to make the JS work)
|
50
|
+
# See https://github.com/killbill/killbill-admin-ui/issues/258
|
51
|
+
@plugin_properties = nil
|
52
|
+
else
|
53
|
+
@plugin_properties.map! do |property|
|
54
|
+
KillBillClient::Model::PluginPropertyAttributes.new(property)
|
55
|
+
end
|
56
|
+
end
|
51
57
|
|
52
58
|
begin
|
53
59
|
@payment_method = @payment_method.create(@payment_method.is_default, current_user.kb_username, params[:reason], params[:comment],
|
@@ -10,12 +10,12 @@ module Kaui
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def humanized_product_category(product_category)
|
13
|
-
if product_category == 'BASE'
|
13
|
+
if product_category.to_s == 'BASE'
|
14
14
|
'Base'
|
15
|
-
elsif product_category == 'ADD_ON'
|
15
|
+
elsif product_category.to_s == 'ADD_ON'
|
16
16
|
'Add-on'
|
17
17
|
else
|
18
|
-
product_category.downcase.capitalize
|
18
|
+
product_category.to_s.downcase.capitalize
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -28,7 +28,8 @@ module Kaui
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def humanized_product_name(product_name)
|
31
|
-
|
31
|
+
# Don't change the casing to avoid confusions (could lead to different products with different casing)
|
32
|
+
product_name
|
32
33
|
end
|
33
34
|
|
34
35
|
def humanized_subscription_billing_period(sub)
|
@@ -106,8 +106,8 @@
|
|
106
106
|
plan['new_plan_currency_path'] = Routes.kaui_engine_admin_tenant_new_plan_currency_path(<%= @tenant.id %>, {plan_id: plan['plan_id']});
|
107
107
|
plan['humanized_product_name'] = function(){
|
108
108
|
return function (input, render) {
|
109
|
-
|
110
|
-
return
|
109
|
+
// Keep the product name as-is to avoid confusing with casing
|
110
|
+
return render(input);
|
111
111
|
}
|
112
112
|
}
|
113
113
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<div class="form-group" id="form_category">
|
12
12
|
<%= f.label :product_category, 'Product Category', :class => 'col-sm-3 control-label' %>
|
13
13
|
<div class="col-sm-4">
|
14
|
-
<%= f.select :product_category, options_for_select(@product_categories.map {|p| [humanized_product_category(p), p] },
|
14
|
+
<%= f.select :product_category, options_for_select(@product_categories.map {|p| [humanized_product_category(p), p] }, @simple_plan.product_category), :class => 'form-control' %>
|
15
15
|
</div>
|
16
16
|
</div>
|
17
17
|
<div class="form-group">
|
@@ -47,31 +47,31 @@
|
|
47
47
|
<div class="form-group">
|
48
48
|
<%= f.label :amount, 'Amount', :class => 'col-sm-3 control-label' %>
|
49
49
|
<div class="col-sm-4">
|
50
|
-
<%= f.number_field :amount, :class => 'form-control', :
|
50
|
+
<%= f.number_field :amount, :class => 'form-control', :step => :any %>
|
51
51
|
</div>
|
52
52
|
</div>
|
53
53
|
<div class="form-group">
|
54
54
|
<%= f.label :currency, 'Currency', :class => 'col-sm-3 control-label' %>
|
55
55
|
<div class="col-sm-4">
|
56
|
-
<%= f.select :currency, currencies, {:selected =>
|
56
|
+
<%= f.select :currency, currencies, {:selected => @simple_plan.currency}, :class => 'form-control' %>
|
57
57
|
</div>
|
58
58
|
</div>
|
59
59
|
<div class="form-group">
|
60
60
|
<%= f.label :billing_period, 'Billing Period', :class => 'col-sm-3 control-label' %>
|
61
61
|
<div class="col-sm-4">
|
62
|
-
<%= f.select :billing_period, options_for_select(@billing_period.map {|bp| [humanized_billing_period(bp), bp] },
|
62
|
+
<%= f.select :billing_period, options_for_select(@billing_period.map {|bp| [humanized_billing_period(bp), bp] }, @simple_plan.billing_period), :class => 'form-control' %>
|
63
63
|
</div>
|
64
64
|
</div>
|
65
65
|
<div class="form-group">
|
66
66
|
<%= f.label :trial_length, 'Trial Length', :class => 'col-sm-3 control-label' %>
|
67
67
|
<div class="col-sm-4">
|
68
|
-
<%= f.number_field :trial_length, :class => 'form-control', :
|
68
|
+
<%= f.number_field :trial_length, :class => 'form-control', :type => 'number', :min => 0, :step => 1 %>
|
69
69
|
</div>
|
70
70
|
</div>
|
71
71
|
<div class="form-group">
|
72
72
|
<%= f.label :trial_time_unit, 'Trial Time Unit', :class => 'col-sm-3 control-label' %>
|
73
73
|
<div class="col-sm-4">
|
74
|
-
<%= f.select :trial_time_unit, options_for_select(@time_units.map {|tu| [humanized_time_unit(tu), tu]},
|
74
|
+
<%= f.select :trial_time_unit, options_for_select(@time_units.map {|tu| [humanized_time_unit(tu), tu]}, @simple_plan.trial_time_unit), :class => 'form-control' %>
|
75
75
|
</div>
|
76
76
|
</div>
|
77
77
|
<div class="form-group">
|
@@ -111,15 +111,19 @@
|
|
111
111
|
|
112
112
|
function known_products() {
|
113
113
|
var result = [];
|
114
|
-
var selected_category = $("#simple_plan_product_category option:selected"
|
115
|
-
if (selected_category == '
|
114
|
+
var selected_category = $("#simple_plan_product_category option:selected").val();
|
115
|
+
if (selected_category == 'BASE') {
|
116
116
|
result = $('#simple_plan_product_name').attr('known_base');
|
117
|
-
} else if (selected_category == '
|
117
|
+
} else if (selected_category == 'ADD_ON') {
|
118
118
|
result = $('#simple_plan_product_name').attr('known_ao');
|
119
119
|
} else {
|
120
120
|
result = $('#simple_plan_product_name').attr('known_std');
|
121
121
|
}
|
122
|
-
|
122
|
+
if (result) {
|
123
|
+
return result.split(",");
|
124
|
+
} else {
|
125
|
+
return [];
|
126
|
+
}
|
123
127
|
}
|
124
128
|
|
125
129
|
function switch_xml_config() {
|
@@ -128,7 +132,7 @@ function switch_xml_config() {
|
|
128
132
|
}
|
129
133
|
|
130
134
|
function recompute_available_base_products_for_ao() {
|
131
|
-
if ($("#simple_plan_product_category option:selected" ).
|
135
|
+
if ($("#simple_plan_product_category option:selected" ).val() != 'ADD_ON') {
|
132
136
|
return;
|
133
137
|
}
|
134
138
|
var product_name = $('#simple_plan_product_name').val();
|
@@ -147,10 +151,7 @@ function recompute_available_base_products_for_ao() {
|
|
147
151
|
}
|
148
152
|
|
149
153
|
function display_available_base_products_for_ao() {
|
150
|
-
|
151
|
-
$('#simple_plan_product_name').val('');
|
152
|
-
|
153
|
-
if ($("#simple_plan_product_category option:selected" ).text() == 'Add_on') {
|
154
|
+
if ($("#simple_plan_product_category option:selected" ).val() == 'ADD_ON') {
|
154
155
|
$('#form_base_products').show();
|
155
156
|
} else {
|
156
157
|
$('#form_base_products').hide();
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<div class="form-group">
|
6
6
|
<%= f.label :amount, 'Amount', :class => 'col-sm-2 control-label' %>
|
7
7
|
<div class="col-sm-10">
|
8
|
-
<%= f.number_field :amount, :id => 'chargeback_amount', :class => 'form-control' %>
|
8
|
+
<%= f.number_field :amount, :step => :any, :id => 'chargeback_amount', :class => 'form-control' %>
|
9
9
|
<p class="help-block">Currency: <%= @chargeback.currency %></p>
|
10
10
|
</div>
|
11
11
|
</div>
|
@@ -15,7 +15,7 @@
|
|
15
15
|
<div class="form-group">
|
16
16
|
<%= f.label :amount, 'Amount', :class => 'col-sm-2 control-label' %>
|
17
17
|
<div class="col-sm-10">
|
18
|
-
<%= f.number_field :amount, :id => 'charge_amount', :class => 'form-control' %>
|
18
|
+
<%= f.number_field :amount, :step => :any, :id => 'charge_amount', :class => 'form-control' %>
|
19
19
|
<% if @invoice.present? %>
|
20
20
|
<p class="help-block">Currency: <%= @invoice.currency %></p>
|
21
21
|
<% end %>
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<div class="form-group">
|
15
15
|
<%= f.label :purchased_amount, 'Amount', :class => 'col-sm-3 control-label' %>
|
16
16
|
<div class="col-sm-9">
|
17
|
-
<%= f.number_field :purchased_amount, :id => 'payment_amount', :class => 'form-control' %>
|
17
|
+
<%= f.number_field :purchased_amount, :step => :any, :id => 'payment_amount', :class => 'form-control' %>
|
18
18
|
<p class="help-block">Currency: <%= @invoice.present? ? @invoice.currency : @account.currency %></p>
|
19
19
|
</div>
|
20
20
|
</div>
|
@@ -9,7 +9,7 @@
|
|
9
9
|
<div class="form-group">
|
10
10
|
<%= label_tag :price_override, 'Price Override', :class => 'col-sm-3 control-label' %>
|
11
11
|
<div class="col-sm-9">
|
12
|
-
<%= number_field_tag :price_override, nil, :class => 'form-control' %>
|
12
|
+
<%= number_field_tag :price_override, nil, :step => :any, :class => 'form-control' %>
|
13
13
|
</div>
|
14
14
|
</div>
|
15
15
|
<div class="form-group">
|
@@ -37,7 +37,7 @@
|
|
37
37
|
<div class="form-group">
|
38
38
|
<%= label_tag :price_override, 'Price Override', :class => 'col-sm-2 control-label' %>
|
39
39
|
<div class="col-sm-10">
|
40
|
-
<%= number_field_tag :price_override, nil, :class => 'form-control' %>
|
40
|
+
<%= number_field_tag :price_override, nil, :step => :any, :class => 'form-control' %>
|
41
41
|
</div>
|
42
42
|
</div>
|
43
43
|
<div class="form-group">
|
data/lib/kaui/version.rb
CHANGED
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: 2.0.
|
4
|
+
version: 2.0.2
|
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: 2020-01
|
11
|
+
date: 2020-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|