kaui 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/kaui/kaui.js +118 -11
- data/app/assets/stylesheets/kaui/common.less +91 -6
- data/app/assets/stylesheets/kaui/payment.less +1 -0
- data/app/controllers/kaui/account_children_controller.rb +1 -4
- data/app/controllers/kaui/accounts_controller.rb +4 -7
- data/app/controllers/kaui/admin_allowed_users_controller.rb +24 -7
- data/app/controllers/kaui/admin_tenants_controller.rb +59 -20
- data/app/controllers/kaui/audit_logs_controller.rb +3 -2
- data/app/controllers/kaui/charges_controller.rb +1 -1
- data/app/controllers/kaui/credits_controller.rb +1 -1
- data/app/controllers/kaui/home_controller.rb +273 -10
- data/app/controllers/kaui/invoice_items_controller.rb +1 -1
- data/app/controllers/kaui/invoices_controller.rb +3 -3
- data/app/controllers/kaui/payments_controller.rb +5 -3
- data/app/controllers/kaui/refunds_controller.rb +2 -2
- data/app/controllers/kaui/subscriptions_controller.rb +2 -1
- data/app/helpers/kaui/object_helper.rb +4 -0
- data/app/helpers/kaui/plugin_helper.rb +36 -20
- data/app/helpers/kaui/uuid_helper.rb +9 -0
- data/app/models/kaui/admin.rb +3 -1
- data/app/models/kaui/admin_tenant.rb +58 -10
- data/app/models/kaui/allowed_user.rb +1 -0
- data/app/models/kaui/catalog.rb +2 -2
- data/app/models/kaui/credit.rb +0 -2
- data/app/models/kaui/overdue.rb +5 -5
- data/app/views/kaui/account_children/index.html.erb +3 -3
- data/app/views/kaui/accounts/_account_info.html.erb +45 -91
- data/app/views/kaui/accounts/_billing_info.html.erb +12 -8
- data/app/views/kaui/accounts/_parent.html.erb +1 -1
- data/app/views/kaui/accounts/_payment_methods.html.erb +1 -1
- data/app/views/kaui/accounts/_personal_info.html.erb +74 -0
- data/app/views/kaui/accounts/index.html.erb +4 -4
- data/app/views/kaui/accounts/show.html.erb +9 -3
- data/app/views/kaui/admin_allowed_users/_form.html.erb +38 -10
- data/app/views/kaui/admin_tenants/_form_plugin_config.erb +82 -17
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +11 -3
- data/app/views/kaui/admin_tenants/_show_overdue.erb +4 -4
- data/app/views/kaui/admin_tenants/_tenant_details.html.erb +7 -1
- data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +1 -1
- data/app/views/kaui/audit_logs/_show_history_modal.html.erb +1 -1
- data/app/views/kaui/audit_logs/index.html.erb +4 -0
- data/app/views/kaui/home/_advanced_search_modal.html.erb +80 -0
- data/app/views/kaui/home/index.html.erb +18 -5
- data/app/views/kaui/invoices/show.html.erb +7 -1
- data/app/views/kaui/layouts/kaui_flash.html.erb +14 -3
- data/app/views/kaui/layouts/kaui_navbar.html.erb +11 -9
- data/app/views/kaui/payments/_form.html.erb +8 -10
- data/app/views/kaui/payments/_payment_table.html.erb +40 -37
- data/app/views/kaui/payments/index.html.erb +1 -0
- data/app/views/kaui/payments/show.html.erb +5 -7
- data/app/views/kaui/queues/index.html.erb +22 -4
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +1 -1
- data/app/views/kaui/tag_definitions/index.html.erb +1 -1
- data/config/routes.rb +2 -0
- data/lib/kaui/version.rb +1 -1
- data/test/functional/kaui/accounts_controller_test.rb +35 -0
- data/test/functional/kaui/admin_allowed_users_controller_test.rb +55 -2
- data/test/functional/kaui/admin_tenants_controller_test.rb +67 -6
- data/test/functional/kaui/home_controller_test.rb +389 -15
- data/test/functional/kaui/subscriptions_controller_test.rb +1 -1
- data/test/killbill_test_helper.rb +2 -2
- data/test/unit/helpers/kaui/uuid_helper_test.rb +16 -0
- data/test/unit/kaui/admin_tenant_test.rb +49 -0
- metadata +6 -4
- data/test/unit/kaui/uuid_helper_test.rb +0 -10
@@ -8,7 +8,8 @@ class Kaui::AuditLogsController < Kaui::EngineController
|
|
8
8
|
|
9
9
|
|
10
10
|
formatter = lambda do |log|
|
11
|
-
object_id_text = view_context.
|
11
|
+
object_id_text = view_context.object_id_popover(log.object_id)
|
12
|
+
|
12
13
|
if object_with_history?(log.object_type)
|
13
14
|
object_id_text = view_context.link_to(object_id_text, '#showHistoryModal',
|
14
15
|
data: {
|
@@ -29,7 +30,7 @@ class Kaui::AuditLogsController < Kaui::EngineController
|
|
29
30
|
log.changed_by,
|
30
31
|
log.reason_code,
|
31
32
|
log.comments,
|
32
|
-
view_context.
|
33
|
+
view_context.object_id_popover(log.user_token, 'left')
|
33
34
|
]
|
34
35
|
end
|
35
36
|
|
@@ -5,7 +5,7 @@ class Kaui::ChargesController < Kaui::EngineController
|
|
5
5
|
amount = params[:amount]
|
6
6
|
|
7
7
|
if invoice_id.present?
|
8
|
-
@invoice = Kaui::Invoice.
|
8
|
+
@invoice = Kaui::Invoice.find_by_id(invoice_id, true, 'NONE', options_for_klient)
|
9
9
|
amount ||= @invoice.balance
|
10
10
|
currency = @invoice.currency
|
11
11
|
else
|
@@ -5,7 +5,7 @@ class Kaui::CreditsController < Kaui::EngineController
|
|
5
5
|
amount = params[:amount]
|
6
6
|
|
7
7
|
if invoice_id.present?
|
8
|
-
@invoice = Kaui::Invoice.
|
8
|
+
@invoice = Kaui::Invoice.find_by_id(invoice_id, true, 'NONE', options_for_klient)
|
9
9
|
amount ||= @invoice.balance
|
10
10
|
currency = @invoice.currency
|
11
11
|
else
|
@@ -1,25 +1,288 @@
|
|
1
1
|
class Kaui::HomeController < Kaui::EngineController
|
2
2
|
|
3
|
+
QUERY_PARSE_REGEX = ['FIND:(?<object_type>.*) BY:(?<search_by>.*) FOR:(?<search_for>.*) ONLY_FIRST:(?<fast>.*)',
|
4
|
+
'FIND:(?<object_type>.*) BY:(?<search_by>.*) FOR:(?<search_for>.*)',
|
5
|
+
'FIND:(?<object_type>.*) FOR:(?<search_for>.*) ONLY_FIRST:(?<fast>.*)',
|
6
|
+
'FIND:(?<object_type>.*) FOR:(?<search_for>.*)']
|
7
|
+
|
8
|
+
SIMPLE_PARSE_REGEX = '(?<search_for>.*)'
|
9
|
+
|
3
10
|
def index
|
4
11
|
@search_query = params[:q]
|
5
12
|
end
|
6
13
|
|
7
14
|
def search
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
elsif search_type == 'transaction'
|
14
|
-
redirect_to transaction_path(:id => search_query)
|
15
|
-
else
|
16
|
-
redirect_to accounts_path(:q => search_query, :fast => params[:fast])
|
15
|
+
object_type, search_query, search_by, fast = parse_query(params[:q])
|
16
|
+
|
17
|
+
unless object_type.nil?
|
18
|
+
cached_options_for_klient = options_for_klient
|
19
|
+
send("#{object_type}_search", search_query, search_by, fast, cached_options_for_klient)
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
20
23
|
private
|
21
24
|
|
25
|
+
def account_search(search_query, search_by = nil, fast = 0, options = {})
|
26
|
+
if search_by == 'ID'
|
27
|
+
begin
|
28
|
+
account = Kaui::Account.find_by_id(search_query, false, false, options)
|
29
|
+
redirect_to account_path(account.account_id) and return
|
30
|
+
rescue KillBillClient::API::NotFound => _
|
31
|
+
search_error("No account matches \"#{search_query}\"")
|
32
|
+
end
|
33
|
+
elsif search_by == 'EXTERNAL_KEY'
|
34
|
+
begin
|
35
|
+
account = Kaui::Account.find_by_external_key(search_query, false, false, options)
|
36
|
+
redirect_to account_path(account.account_id) and return
|
37
|
+
rescue KillBillClient::API::NotFound => _
|
38
|
+
search_error("No account matches \"#{search_query}\"")
|
39
|
+
end
|
40
|
+
else
|
41
|
+
account = Kaui::Account.list_or_search(search_query, 0, 1, options).first
|
42
|
+
if account.blank?
|
43
|
+
search_error("No account matches \"#{search_query}\"")
|
44
|
+
elsif true?(fast)
|
45
|
+
redirect_to account_path(account.account_id) and return
|
46
|
+
else
|
47
|
+
redirect_to accounts_path(:q => search_query, :fast => fast) and return
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def invoice_search(search_query, search_by = nil, fast = 0, options = {})
|
53
|
+
if search_by == 'ID'
|
54
|
+
begin
|
55
|
+
invoice = Kaui::Invoice.find_by_id(search_query, false, 'NONE', options)
|
56
|
+
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return
|
57
|
+
rescue KillBillClient::API::NotFound => _
|
58
|
+
search_error("No invoice matches \"#{search_query}\"")
|
59
|
+
end
|
60
|
+
elsif search_by == 'EXTERNAL_KEY'
|
61
|
+
unsupported_external_key_search('INVOICE')
|
62
|
+
else
|
63
|
+
invoice = Kaui::Invoice.list_or_search(search_query, 0, 1, options).first
|
64
|
+
if invoice.blank?
|
65
|
+
begin
|
66
|
+
invoice = Kaui::Invoice.find_by_invoice_item_id(search_query, false, false, 'NONE', options)
|
67
|
+
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return
|
68
|
+
rescue KillBillClient::API::NotFound => _
|
69
|
+
search_error("No invoice matches \"#{search_query}\"")
|
70
|
+
end
|
71
|
+
elsif true?(fast)
|
72
|
+
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return
|
73
|
+
else
|
74
|
+
redirect_to account_invoices_path(:account_id => invoice.account_id, :q => search_query, :fast => fast) and return
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def payment_search(search_query, search_by = nil, fast = 0, options = {})
|
80
|
+
if search_by == 'ID'
|
81
|
+
begin
|
82
|
+
payment = Kaui::Payment.find_by_id(search_query, false, false, options)
|
83
|
+
redirect_to account_payment_path(payment.account_id, payment.payment_id) and return
|
84
|
+
rescue KillBillClient::API::NotFound => _
|
85
|
+
search_error("No payment matches \"#{search_query}\"")
|
86
|
+
end
|
87
|
+
elsif search_by == 'EXTERNAL_KEY'
|
88
|
+
begin
|
89
|
+
payment = Kaui::Payment.find_by_external_key(search_query, false, false, options)
|
90
|
+
redirect_to account_payment_path(payment.account_id, payment.payment_id) and return
|
91
|
+
rescue KillBillClient::API::NotFound => _
|
92
|
+
search_error("No payment matches \"#{search_query}\"")
|
93
|
+
end
|
94
|
+
else
|
95
|
+
payment = Kaui::Payment.list_or_search(search_query, 0, 1, options).first
|
96
|
+
if payment.blank?
|
97
|
+
search_error("No payment matches \"#{search_query}\"")
|
98
|
+
elsif true?(fast)
|
99
|
+
redirect_to account_payment_path(payment.account_id, payment.payment_id) and return
|
100
|
+
else
|
101
|
+
redirect_to account_payments_path(:account_id => payment.account_id, :q => search_query, :fast => fast) and return
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def transaction_search(search_query, search_by = nil, fast = 0, options = {})
|
107
|
+
if search_by.blank? || search_by == 'ID'
|
108
|
+
begin
|
109
|
+
payment = Kaui::Payment.find_by_transaction_id(search_query, false, true, options)
|
110
|
+
redirect_to account_payment_path(payment.account_id, payment.payment_id) and return
|
111
|
+
rescue KillBillClient::API::NotFound => _
|
112
|
+
search_error("No transaction matches \"#{search_query}\"")
|
113
|
+
end
|
114
|
+
else
|
115
|
+
begin
|
116
|
+
payment = Kaui::Payment.find_by_transaction_external_key(search_query, false, true, 'NONE', options)
|
117
|
+
redirect_to account_payment_path(payment.account_id, payment.payment_id) and return
|
118
|
+
rescue KillBillClient::API::NotFound => _
|
119
|
+
search_error("No transaction matches \"#{search_query}\"")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def bundle_search(search_query, search_by = nil, fast = 0, options = {})
|
125
|
+
if search_by == 'ID'
|
126
|
+
begin
|
127
|
+
bundle = Kaui::Bundle.find_by_id(search_query, options)
|
128
|
+
redirect_to kaui_engine.account_bundles_path(bundle.account_id) and return
|
129
|
+
rescue KillBillClient::API::NotFound => _
|
130
|
+
search_error("No bundle matches \"#{search_query}\"")
|
131
|
+
end
|
132
|
+
elsif search_by == 'EXTERNAL_KEY'
|
133
|
+
begin
|
134
|
+
bundle = Kaui::Bundle.find_by_external_key(search_query, false, options)
|
135
|
+
redirect_to kaui_engine.account_bundles_path(bundle.account_id) and return
|
136
|
+
rescue KillBillClient::API::NotFound => _
|
137
|
+
search_error("No bundle matches \"#{search_query}\"")
|
138
|
+
end
|
139
|
+
else
|
140
|
+
bundle = Kaui::Bundle.list_or_search(search_query, 0, 1, options).first
|
141
|
+
if bundle.blank?
|
142
|
+
search_error("No bundle matches \"#{search_query}\"")
|
143
|
+
else
|
144
|
+
redirect_to kaui_engine.account_bundles_path(bundle.account_id) and return
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def credit_search(search_query, search_by = nil, fast = 0, options = {})
|
150
|
+
if search_by.blank? || search_by == 'ID'
|
151
|
+
begin
|
152
|
+
credit = Kaui::Credit.find_by_id(search_query, options)
|
153
|
+
redirect_to account_invoice_path(credit.account_id, credit.invoice_id) and return
|
154
|
+
rescue KillBillClient::API::NotFound => _
|
155
|
+
search_error("No credit matches \"#{search_query}\"")
|
156
|
+
end
|
157
|
+
else
|
158
|
+
unsupported_external_key_search('CREDIT')
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def custom_field_search(search_query, search_by = nil, fast = 0, options = {})
|
163
|
+
if search_by.blank? || search_by == 'ID'
|
164
|
+
custom_field = Kaui::CustomField.list_or_search(search_query, 0, 1, options)
|
165
|
+
if custom_field.blank?
|
166
|
+
search_error("No custom field matches \"#{search_query}\"")
|
167
|
+
else
|
168
|
+
redirect_to custom_fields_path(:q => search_query, :fast => fast) and return
|
169
|
+
end
|
170
|
+
else
|
171
|
+
unsupported_external_key_search('CUSTOM FIELD')
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def invoice_payment_search(search_query, search_by = nil, fast = 0, options = {})
|
176
|
+
if search_by.blank? || search_by == 'ID'
|
177
|
+
begin
|
178
|
+
invoice_payment = Kaui::InvoicePayment.find_safely_by_id(search_query, options)
|
179
|
+
redirect_to account_payment_path(invoice_payment.account_id, invoice_payment.payment_id) and return
|
180
|
+
rescue KillBillClient::API::NotFound => _
|
181
|
+
search_error("No invoice payment matches \"#{search_query}\"")
|
182
|
+
end
|
183
|
+
else
|
184
|
+
unsupported_external_key_search('INVOICE PAYMENT')
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def subscription_search(search_query, search_by = nil, fast = 0, options = {})
|
189
|
+
if search_by.blank? || search_by == 'ID'
|
190
|
+
begin
|
191
|
+
subscription = Kaui::Subscription.find_by_id(search_query, options)
|
192
|
+
redirect_to account_bundles_path(subscription.account_id) and return
|
193
|
+
rescue KillBillClient::API::NotFound => _
|
194
|
+
search_error("No subscription matches \"#{search_query}\"")
|
195
|
+
end
|
196
|
+
else
|
197
|
+
unsupported_external_key_search('SUBSCRIPTION')
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def tag_search(search_query, search_by = nil, fast = 0, options = {})
|
202
|
+
if search_by.blank? || search_by == 'ID'
|
203
|
+
tag = Kaui::Tag.list_or_search(search_query, 0, 1, options)
|
204
|
+
if tag.blank?
|
205
|
+
search_error("No tag matches \"#{search_query}\"")
|
206
|
+
else
|
207
|
+
redirect_to tags_path(:q => search_query, :fast => fast) and return
|
208
|
+
end
|
209
|
+
else
|
210
|
+
unsupported_external_key_search('TAG')
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def tag_definition_search(search_query, search_by = nil, fast = 0, options = {})
|
215
|
+
if search_by == 'ID'
|
216
|
+
begin
|
217
|
+
Kaui::TagDefinition.find_by_id(search_query, 'NONE', options)
|
218
|
+
redirect_to tag_definitions_path(:q => search_query, :fast => fast) and return
|
219
|
+
rescue KillBillClient::API::NotFound => _
|
220
|
+
search_error("No tag definition matches \"#{search_query}\"")
|
221
|
+
end
|
222
|
+
elsif search_by == 'EXTERNAL_KEY'
|
223
|
+
unsupported_external_key_search('TAG DEFINITION')
|
224
|
+
else
|
225
|
+
tag_definition = Kaui::TagDefinition.find_by_name(search_query, 'NONE', options)
|
226
|
+
if tag_definition.blank?
|
227
|
+
begin
|
228
|
+
Kaui::TagDefinition.find_by_id(search_query, 'NONE', options)
|
229
|
+
redirect_to tag_definitions_path(:q => search_query, :fast => fast) and return
|
230
|
+
rescue KillBillClient::API::NotFound => _
|
231
|
+
search_error("No tag definition matches \"#{search_query}\"")
|
232
|
+
end
|
233
|
+
else
|
234
|
+
redirect_to tag_definitions_path(:q => search_query, :fast => fast) and return
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
def unsupported_external_key_search(object_type)
|
240
|
+
search_error("\"#{object_type}\": Search by \"EXTERNAL KEY\" is not supported.")
|
241
|
+
end
|
242
|
+
|
243
|
+
def search_error(message)
|
244
|
+
flash[:error] = message
|
245
|
+
redirect_to kaui_engine.home_path and return
|
246
|
+
end
|
247
|
+
|
22
248
|
def parse_query(query)
|
23
|
-
|
249
|
+
statements, simple_regex_used = regex_parse_query(query)
|
250
|
+
|
251
|
+
object_type = statements[:object_type].strip.downcase rescue 'account'
|
252
|
+
search_for = statements[:search_for].strip
|
253
|
+
search_by = statements[:search_by].strip.upcase rescue simple_regex_used && uuid?(search_for) ? 'ID' : nil
|
254
|
+
fast = statements[:fast] rescue '0'
|
255
|
+
|
256
|
+
if !search_by.blank? && !(search_by == 'ID' || search_by == 'EXTERNAL_KEY')
|
257
|
+
search_error("\"#{search_by}\" is not a valid search by value")
|
258
|
+
end
|
259
|
+
|
260
|
+
return object_type, search_for, search_by, fast
|
261
|
+
end
|
262
|
+
|
263
|
+
def regex_parse_query(query)
|
264
|
+
statements = nil
|
265
|
+
simple_regex_used = false
|
266
|
+
QUERY_PARSE_REGEX.each do |query_regex|
|
267
|
+
regex_exp = Regexp.new(query_regex, true)
|
268
|
+
statements = regex_exp.match(query)
|
269
|
+
break unless statements.nil?
|
270
|
+
end
|
271
|
+
|
272
|
+
if statements.nil?
|
273
|
+
regex_exp = Regexp.new(SIMPLE_PARSE_REGEX, true)
|
274
|
+
statements = regex_exp.match(query)
|
275
|
+
simple_regex_used = true
|
276
|
+
end
|
277
|
+
|
278
|
+
return statements, simple_regex_used
|
279
|
+
end
|
280
|
+
|
281
|
+
def true?(statement)
|
282
|
+
[1,'1',true,'true'].include? ((statement.instance_of? String) ? statement.downcase : statement)
|
283
|
+
end
|
284
|
+
|
285
|
+
def uuid?(value)
|
286
|
+
value =~ /[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}/
|
24
287
|
end
|
25
288
|
end
|
@@ -5,7 +5,7 @@ class Kaui::InvoiceItemsController < Kaui::EngineController
|
|
5
5
|
invoice_id = params.require(:invoice_id)
|
6
6
|
|
7
7
|
# See https://github.com/killbill/killbill/issues/7
|
8
|
-
invoice = Kaui::Invoice.
|
8
|
+
invoice = Kaui::Invoice.find_by_id(invoice_id, true, 'NONE', options_for_klient)
|
9
9
|
@invoice_item = invoice.items.find { |ii| ii.invoice_item_id == invoice_item_id }
|
10
10
|
|
11
11
|
if @invoice_item.nil?
|
@@ -45,7 +45,7 @@ class Kaui::InvoicesController < Kaui::EngineController
|
|
45
45
|
# Go to the database once
|
46
46
|
cached_options_for_klient = options_for_klient
|
47
47
|
|
48
|
-
@invoice = Kaui::Invoice.
|
48
|
+
@invoice = Kaui::Invoice.find_by_id(params.require(:id), true, 'FULL', cached_options_for_klient)
|
49
49
|
|
50
50
|
fetch_payments = promise { @invoice.payments(true, true, 'FULL', cached_options_for_klient).map { |payment| Kaui::InvoicePayment.build_from_raw_payment(payment) } }
|
51
51
|
fetch_pms = fetch_payments.then { |payments| Kaui::PaymentMethod.payment_methods_for_payments(payments, cached_options_for_klient) }
|
@@ -76,7 +76,7 @@ class Kaui::InvoicesController < Kaui::EngineController
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def restful_show
|
79
|
-
invoice = Kaui::Invoice.
|
79
|
+
invoice = Kaui::Invoice.find_by_id(params.require(:id), false, 'NONE', options_for_klient)
|
80
80
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id)
|
81
81
|
end
|
82
82
|
|
@@ -85,7 +85,7 @@ class Kaui::InvoicesController < Kaui::EngineController
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def commit_invoice
|
88
|
-
invoice = KillBillClient::Model::Invoice.
|
88
|
+
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), false, 'NONE', options_for_klient)
|
89
89
|
invoice.commit(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
90
90
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id), :notice => 'Invoice successfully committed'
|
91
91
|
end
|
@@ -52,7 +52,8 @@ class Kaui::PaymentsController < Kaui::EngineController
|
|
52
52
|
payment.total_authed_amount_to_money,
|
53
53
|
payment.paid_amount_to_money,
|
54
54
|
payment.returned_amount_to_money,
|
55
|
-
payment.transactions.empty? ? nil : payment.transactions[-1].status
|
55
|
+
payment.transactions.empty? ? nil : payment.transactions[-1].status,
|
56
|
+
payment.payment_external_key
|
56
57
|
][column]
|
57
58
|
end
|
58
59
|
|
@@ -63,7 +64,8 @@ class Kaui::PaymentsController < Kaui::EngineController
|
|
63
64
|
view_context.humanized_money_with_symbol(payment.total_authed_amount_to_money),
|
64
65
|
view_context.humanized_money_with_symbol(payment.paid_amount_to_money),
|
65
66
|
view_context.humanized_money_with_symbol(payment.returned_amount_to_money),
|
66
|
-
payment.transactions.empty? ? nil : view_context.colored_transaction_status(payment.transactions[-1].status)
|
67
|
+
payment.transactions.empty? ? nil : view_context.colored_transaction_status(payment.transactions[-1].status),
|
68
|
+
payment.payment_external_key
|
67
69
|
]
|
68
70
|
end
|
69
71
|
|
@@ -71,7 +73,7 @@ class Kaui::PaymentsController < Kaui::EngineController
|
|
71
73
|
end
|
72
74
|
|
73
75
|
def new
|
74
|
-
fetch_invoice = promise { Kaui::Invoice.
|
76
|
+
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), true, 'NONE', options_for_klient) }
|
75
77
|
fetch_payment_methods = promise { Kaui::PaymentMethod.find_all_by_account_id(params.require(:account_id), false, options_for_klient) }
|
76
78
|
|
77
79
|
@invoice = wait(fetch_invoice)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Kaui::RefundsController < Kaui::EngineController
|
2
2
|
|
3
3
|
def new
|
4
|
-
fetch_invoice = promise { Kaui::Invoice.
|
4
|
+
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), true, 'NONE', options_for_klient) }
|
5
5
|
fetch_payment = promise { Kaui::InvoicePayment::find_by_id(params.require(:payment_id), false, false, options_for_klient) }
|
6
6
|
fetch_bundles = promise { @account.bundles(options_for_klient) }
|
7
7
|
|
@@ -13,7 +13,7 @@ class Kaui::RefundsController < Kaui::EngineController
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def create
|
16
|
-
invoice = Kaui::Invoice.
|
16
|
+
invoice = Kaui::Invoice.find_by_id(params.require(:invoice_id), true, 'NONE', options_for_klient)
|
17
17
|
|
18
18
|
if params[:adjustment_type] == 'invoiceItemAdjustment'
|
19
19
|
items = []
|
@@ -73,6 +73,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
73
73
|
params[:comment],
|
74
74
|
requested_date,
|
75
75
|
billing_policy,
|
76
|
+
nil,
|
76
77
|
wait_for_completion,
|
77
78
|
options_for_klient)
|
78
79
|
|
@@ -184,7 +185,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
184
185
|
else
|
185
186
|
options = options_for_klient
|
186
187
|
|
187
|
-
catalog = Kaui::Catalog.
|
188
|
+
catalog = Kaui::Catalog.get_tenant_catalog_json( DateTime.now.to_s, options)
|
188
189
|
|
189
190
|
return [] if catalog.blank?
|
190
191
|
|
@@ -24,5 +24,9 @@ module Kaui
|
|
24
24
|
[:ACCOUNT, :BUNDLE, :INVOICE, :INVOICE_ITEM, :INVOICE_PAYMENT, :PAYMENT, :SUBSCRIPTION, :TRANSACTION]
|
25
25
|
end
|
26
26
|
|
27
|
+
def object_types_for_advanced_search
|
28
|
+
[:ACCOUNT, :BUNDLE, :INVOICE, :CREDIT, :CUSTOM_FIELD, :INVOICE_PAYMENT, :INVOICE, :PAYMENT, :SUBSCRIPTION, :TRANSACTION, :TAG, :TAG_DEFINITION]
|
29
|
+
end
|
30
|
+
|
27
31
|
end
|
28
32
|
end
|
@@ -3,30 +3,22 @@ module Kaui
|
|
3
3
|
# including plugin that are installed
|
4
4
|
def plugin_repository
|
5
5
|
plugins = []
|
6
|
-
plugin_repository = Kaui::AdminTenant
|
7
|
-
installed_plugins = installed_plugins()
|
8
|
-
|
6
|
+
plugin_repository = Kaui::AdminTenant.get_plugin_repository
|
9
7
|
plugin_repository.each_pair do |key, info|
|
10
|
-
found_plugin = installed_plugins.reject! { |p| p.plugin_key.eql?(key.to_s) }
|
11
8
|
plugins << {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
plugin_key: plugin_key(key.to_s, info),
|
10
|
+
plugin_name: plugin_name(key.to_s, info),
|
11
|
+
plugin_type: info[:type],
|
12
|
+
installed: false
|
16
13
|
}
|
17
14
|
end
|
18
15
|
|
19
|
-
installed_plugins
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
plugin_type: nil,
|
24
|
-
installed: true
|
25
|
-
}
|
26
|
-
end
|
16
|
+
installed_plugins = installed_plugins(plugins)
|
17
|
+
|
18
|
+
plugins.sort! { |a, b| a[:plugin_key] <=> b[:plugin_key] }
|
19
|
+
plugins.each { |plugin| installed_plugins << plugin }
|
27
20
|
|
28
|
-
|
29
|
-
plugins
|
21
|
+
installed_plugins
|
30
22
|
end
|
31
23
|
|
32
24
|
private
|
@@ -48,11 +40,35 @@ module Kaui
|
|
48
40
|
end
|
49
41
|
end
|
50
42
|
|
51
|
-
def installed_plugins
|
43
|
+
def installed_plugins(plugins)
|
44
|
+
installed_plugins = []
|
52
45
|
nodes_info = KillBillClient::Model::NodesInfo.nodes_info(Kaui.current_tenant_user_options(current_user, session)) || []
|
53
46
|
plugins_info = nodes_info.first.plugins_info || []
|
54
47
|
|
55
|
-
plugins_info.
|
48
|
+
plugins_info.each do |plugin|
|
49
|
+
next if plugin.version.nil?
|
50
|
+
# do not allow duplicate
|
51
|
+
next if installed_plugins.any? { |p| p[:plugin_name].eql?(plugin.plugin_name) }
|
52
|
+
plugin_key = Kaui::AdminTenant.rewrite_plugin_key(plugin.plugin_key)
|
53
|
+
installed_plugins << {
|
54
|
+
plugin_key: plugin_key,
|
55
|
+
plugin_name: plugin.plugin_name,
|
56
|
+
plugin_type: find_plugin_type(plugins, plugin_key),
|
57
|
+
installed: true
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
installed_plugins.sort! { |a,b| a[:plugin_key] <=> b[:plugin_key] }
|
62
|
+
end
|
63
|
+
|
64
|
+
def find_plugin_type(plugins, plugin_key_to_search)
|
65
|
+
plugins.each do |plugin|
|
66
|
+
if plugin[:plugin_key] == plugin_key_to_search
|
67
|
+
return plugin[:plugin_type]
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
return nil
|
56
72
|
end
|
57
73
|
end
|
58
74
|
end
|