kaui 3.0.1 → 3.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/README.md +2 -1
- data/app/assets/config/kaui_manifest.js +2 -44
- 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/admin_allowed_users_controller.rb +1 -1
- data/app/controllers/kaui/admin_tenants_controller.rb +3 -3
- data/app/controllers/kaui/bundle_tags_controller.rb +1 -1
- data/app/controllers/kaui/engine_controller_util.rb +1 -1
- data/app/controllers/kaui/home_controller.rb +21 -12
- data/app/controllers/kaui/invoice_tags_controller.rb +1 -1
- data/app/controllers/kaui/invoices_controller.rb +6 -1
- data/app/controllers/kaui/payment_methods_controller.rb +1 -1
- data/app/controllers/kaui/subscriptions_controller.rb +9 -8
- data/app/controllers/kaui/transactions_controller.rb +1 -1
- 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/invoice_payment.rb +1 -1
- data/app/models/kaui/overdue.rb +2 -2
- 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/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
- metadata +29 -130
- 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
@@ -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
58
|
invoice = Kaui::Invoice.find_by_id(search_query, 'NONE', options)
|
58
59
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return
|
59
60
|
rescue KillBillClient::API::NotFound => _e
|
60
61
|
search_error("No invoice matches \"#{search_query}\"")
|
61
62
|
end
|
62
|
-
|
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, '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?
|
@@ -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,7 +191,7 @@ 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
|
|
@@ -196,7 +204,7 @@ module Kaui
|
|
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
|
@@ -39,7 +39,7 @@ module Kaui
|
|
39
39
|
end
|
40
40
|
formatter = lambda do |invoice|
|
41
41
|
row = [view_context.link_to(invoice.invoice_number, view_context.url_for(controller: :invoices, action: :show, account_id: invoice.account_id, id: invoice.invoice_id))]
|
42
|
-
row += Kaui.invoice_search_columns.call(invoice, view_context)[1]
|
42
|
+
row += Kaui.invoice_search_columns.call(invoice, view_context, cached_options_for_klient)[1]
|
43
43
|
row
|
44
44
|
end
|
45
45
|
else
|
@@ -147,6 +147,11 @@ module Kaui
|
|
147
147
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id)
|
148
148
|
end
|
149
149
|
|
150
|
+
def restful_show_by_number
|
151
|
+
invoice = Kaui::Invoice.find_by_number(params.require(:number), 'NONE', options_for_klient)
|
152
|
+
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id)
|
153
|
+
end
|
154
|
+
|
150
155
|
def show_html
|
151
156
|
render html: Kaui::Invoice.as_html(params.require(:id), options_for_klient).html_safe
|
152
157
|
end
|
@@ -47,7 +47,7 @@ module Kaui
|
|
47
47
|
}
|
48
48
|
|
49
49
|
@plugin_properties = begin
|
50
|
-
params[:plugin_properties].values.reject { |item|
|
50
|
+
params[:plugin_properties].values.reject { |item| item['value'].blank? || item['key'].blank? }
|
51
51
|
rescue StandardError
|
52
52
|
@plugin_properties = nil
|
53
53
|
end
|
@@ -193,10 +193,11 @@ module Kaui
|
|
193
193
|
def update_tags
|
194
194
|
subscription_id = params.require(:id)
|
195
195
|
subscription = Kaui::Subscription.find_by_id(subscription_id, options_for_klient)
|
196
|
-
|
197
196
|
tags = []
|
198
|
-
params.
|
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 = []
|
@@ -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
|
data/app/models/kaui/tag.rb
CHANGED
@@ -13,12 +13,12 @@ module Kaui
|
|
13
13
|
class << self
|
14
14
|
%i[account bundle subscription invoice].each do |model|
|
15
15
|
define_method "all_for_#{model}" do |model_id, included_deleted, audit, options|
|
16
|
-
instance = Kaui.const_get(model.to_s.camelize).new("#{model}_id"
|
16
|
+
instance = Kaui.const_get(model.to_s.camelize).new("#{model}_id": model_id)
|
17
17
|
instance.tags(included_deleted, audit, options)
|
18
18
|
end
|
19
19
|
|
20
20
|
define_method "set_for_#{model}" do |model_id, tags, user, reason, comment, options|
|
21
|
-
instance = Kaui.const_get(model.to_s.camelize).new("#{model}_id"
|
21
|
+
instance = Kaui.const_get(model.to_s.camelize).new("#{model}_id": model_id)
|
22
22
|
instance.set_tags(tags, user, reason, comment, options)
|
23
23
|
end
|
24
24
|
end
|
@@ -25,7 +25,7 @@ module Kaui
|
|
25
25
|
|
26
26
|
ALL_OBJECT_TYPES.each do |object_type|
|
27
27
|
define_singleton_method "all_for_#{object_type.downcase}" do |options_for_klient|
|
28
|
-
(all('NONE', options_for_klient).delete_if { |tag_definition| !tag_definition.applicable_object_types.include?(object_type)
|
28
|
+
(all('NONE', options_for_klient).delete_if { |tag_definition| !tag_definition.applicable_object_types.include?(object_type) }).sort
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -110,7 +110,7 @@
|
|
110
110
|
<% end %>
|
111
111
|
</table>
|
112
112
|
|
113
|
-
<% if can? :trigger, Kaui::Invoice %>
|
113
|
+
<% if (can? :trigger, Kaui::Invoice) || (can? :dry_run, Kaui::Invoice) %>
|
114
114
|
<div style="padding-bottom: 50px;">
|
115
115
|
<%= form_tag kaui_engine.trigger_invoice_path(params.to_h), :method => :post do %>
|
116
116
|
<div class="form-group">
|
@@ -118,13 +118,11 @@
|
|
118
118
|
<div class="col-sm-3">
|
119
119
|
<input class="form-control" id="target_date" name="target_date" type="text" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-today-highlight="true">
|
120
120
|
</div>
|
121
|
-
<% if can? :dry_run, Kaui::Invoice %>
|
122
121
|
<div style="width: 14.5%; float: left; padding: 0;">
|
123
122
|
<%= label_tag :dry_run do %>
|
124
|
-
<%= check_box_tag :dry_run, '1', true %> <small>Dry-run</small>
|
123
|
+
<%= check_box_tag :dry_run, '1', true, :disabled => !can?(:trigger, Kaui::Invoice) %> <small>Dry-run</small>
|
125
124
|
<% end %>
|
126
125
|
</div>
|
127
|
-
<% end %>
|
128
126
|
<div class="col-xs-1" style="padding: 0;">
|
129
127
|
<%= button_tag '<i class="fa fa-magic"></i>'.html_safe, :class => 'btn btn-xs' %>
|
130
128
|
</div>
|
@@ -45,7 +45,7 @@
|
|
45
45
|
<div class="form-group">
|
46
46
|
<%= f.label :bill_cycle_day_local, 'Bill cycle day', :class => 'col-sm-3 control-label' %>
|
47
47
|
<div class="col-sm-9">
|
48
|
-
<%= f.
|
48
|
+
<%= f.number_field :bill_cycle_day_local, :class => 'form-control', :min => 0, max: 31 %>
|
49
49
|
</div>
|
50
50
|
</div>
|
51
51
|
<div class="form-group">
|
@@ -111,13 +111,13 @@
|
|
111
111
|
<div class="form-group">
|
112
112
|
<%= f.label :country, 'Country', :class => 'col-sm-3 control-label' %>
|
113
113
|
<div class="col-sm-9">
|
114
|
-
<%= f.country_select :country, {:priority_countries => %w(US CA), :selected => @account.country}, :class => 'form-control' %>
|
114
|
+
<%= f.country_select :country, {:priority_countries => %w(US CA), :selected => @account.country, :sort_provided => false}, :class => 'form-control' %>
|
115
115
|
</div>
|
116
116
|
</div>
|
117
117
|
<div class="form-group">
|
118
118
|
<%= f.label :phone, 'Phone', :class => 'col-sm-3 control-label' %>
|
119
119
|
<div class="col-sm-9">
|
120
|
-
<%= f.
|
120
|
+
<%= f.number_field :phone, :class => 'form-control' %>
|
121
121
|
</div>
|
122
122
|
</div>
|
123
123
|
<div class="form-group">
|
@@ -65,7 +65,6 @@ $(document).ready(function() {
|
|
65
65
|
<!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
|
66
66
|
<% if @max_nb_records.nil? %>
|
67
67
|
$('#accounts-table').on('draw.dt', function() {
|
68
|
-
$.noConflict();
|
69
68
|
var noMoreData = table.column(0)
|
70
69
|
.data()
|
71
70
|
.length == 0;
|
@@ -38,11 +38,11 @@
|
|
38
38
|
<td><%= state_form.select :is_block_changes, options_for_select([true, false ], state.is_block_changes), :class => 'form-control' %></td>
|
39
39
|
<td><%= state_form.select :subscription_cancellation_policy, options_for_select([:NONE, :POLICY_NONE, :POLICY_IMMEDIATE, :POLICY_END_OF_TERM], state.subscription_cancellation), :class => 'form-control' %></td>
|
40
40
|
<%= state_form.fields_for 'condition' do |condition| %>
|
41
|
-
<td><%= condition.number_field :time_since_earliest_unpaid_invoice_equals_or_exceeds, :value => state.condition.time_since_earliest_unpaid_invoice_equals_or_exceeds
|
42
|
-
<td><%= condition.select :control_tag_inclusion, options_for_select([:NONE, :AUTO_PAY_OFF, :AUTO_INVOICING_OFF, :OVERDUE_ENFORCEMENT_OFF, :MANUAL_PAY, :TEST, :PARTNER], state.condition
|
43
|
-
<td><%= condition.select :control_tag_exclusion, options_for_select([:NONE, :AUTO_PAY_OFF, :AUTO_INVOICING_OFF, :OVERDUE_ENFORCEMENT_OFF, :MANUAL_PAY, :TEST, :PARTNER], state.condition
|
44
|
-
<td><%= condition.number_field :number_of_unpaid_invoices_equals_or_exceeds, :value => state.condition
|
45
|
-
<td><%= condition.number_field :total_unpaid_invoice_balance_equals_or_exceeds, :step => :any, :value => state.condition
|
41
|
+
<td><%= condition.number_field :time_since_earliest_unpaid_invoice_equals_or_exceeds, :value => state.condition.time_since_earliest_unpaid_invoice_equals_or_exceeds&.number %></td>
|
42
|
+
<td><%= condition.select :control_tag_inclusion, options_for_select([:NONE, :AUTO_PAY_OFF, :AUTO_INVOICING_OFF, :OVERDUE_ENFORCEMENT_OFF, :MANUAL_PAY, :TEST, :PARTNER], state.condition&.control_tag_inclusion), :class => 'form-control' %></td>
|
43
|
+
<td><%= condition.select :control_tag_exclusion, options_for_select([:NONE, :AUTO_PAY_OFF, :AUTO_INVOICING_OFF, :OVERDUE_ENFORCEMENT_OFF, :MANUAL_PAY, :TEST, :PARTNER], state.condition&.control_tag_exclusion), :class => 'form-control'%></td>
|
44
|
+
<td><%= condition.number_field :number_of_unpaid_invoices_equals_or_exceeds, :value => state.condition&.number_of_unpaid_invoices_equals_or_exceeds %></td>
|
45
|
+
<td><%= condition.number_field :total_unpaid_invoice_balance_equals_or_exceeds, :step => :any, :value => state.condition&.total_unpaid_invoice_balance_equals_or_exceeds %></td>
|
46
46
|
<% end %>
|
47
47
|
<% end %>
|
48
48
|
<% end %>
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<div class="form-group">
|
24
24
|
<%= label_tag :search_by, 'Search by', :class => 'col-sm-4 control-label' %>
|
25
25
|
<div class="col-sm-8">
|
26
|
-
<%= select_tag :search_by, options_for_select(
|
26
|
+
<%= select_tag :search_by, options_for_select(object_fields_for_advanced_search,''), :class => 'form-control' %>
|
27
27
|
</div>
|
28
28
|
</div>
|
29
29
|
<div class="form-group">
|
@@ -68,13 +68,34 @@
|
|
68
68
|
$('#advancedQuery').val(query);
|
69
69
|
}
|
70
70
|
|
71
|
+
const searchByFieldsMap = <%= advanced_search_object_fields_map.to_json.html_safe %>;
|
72
|
+
function refresh_search_by() {
|
73
|
+
var objectType = $('#object_type').val();
|
74
|
+
|
75
|
+
// Clears the selected field if it's not supported by the selected object type
|
76
|
+
var searchBy = $('#search_by').val();
|
77
|
+
if (searchByFieldsMap[searchBy] && !searchByFieldsMap[searchBy].includes(objectType)) {
|
78
|
+
$('#search_by').val(' ');
|
79
|
+
refresh_query();
|
80
|
+
}
|
81
|
+
|
82
|
+
// Updates search options to only show fields supported by the selected object type
|
83
|
+
for (field in searchByFieldsMap) {
|
84
|
+
var isSupported = searchByFieldsMap[field].includes(objectType);
|
85
|
+
var fieldOption = $(`#search_by > option[value=${field}]`);
|
86
|
+
isSupported ? fieldOption.show() : fieldOption.hide();
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
71
90
|
$('#search_for').keyup(function(){ refresh_query(); });
|
72
91
|
$('#search_for').change(function(){ refresh_query(); });
|
73
92
|
$('#object_type').change(function(){ refresh_query(); });
|
93
|
+
$('#object_type').change(function(){ refresh_search_by(); });
|
74
94
|
$('#search_by').change(function(){ refresh_query(); });
|
75
95
|
$('#fast').change(function(){ refresh_query(); });
|
76
96
|
|
77
97
|
refresh_query();
|
98
|
+
refresh_search_by();
|
78
99
|
|
79
100
|
});
|
80
101
|
<% end %>
|
@@ -4,8 +4,9 @@
|
|
4
4
|
|
5
5
|
<h1>
|
6
6
|
Invoice <%= @invoice.invoice_number %>
|
7
|
-
<%
|
7
|
+
<% if !@invoice.invoice_number.blank? %>
|
8
8
|
<%= Kaui.customer_invoice_link.call(@invoice, self) %>
|
9
|
+
<%= Kaui.additional_invoice_links.call(@invoice, self) %>
|
9
10
|
<% end %>
|
10
11
|
</h1>
|
11
12
|
|
@@ -4,8 +4,8 @@
|
|
4
4
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
5
|
|
6
6
|
<title>Kaui</title>
|
7
|
-
<%= stylesheet_link_tag '
|
8
|
-
|
7
|
+
<%= stylesheet_link_tag 'application', :media => 'all' %>
|
8
|
+
<%= javascript_include_tag 'application' %>
|
9
9
|
|
10
10
|
<%= csrf_meta_tags %>
|
11
11
|
|
@@ -14,21 +14,5 @@
|
|
14
14
|
<!--[if lt IE 9]>
|
15
15
|
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
16
16
|
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
17
|
-
|
18
17
|
<![endif]-->
|
19
|
-
|
20
|
-
<%= javascript_include_tag "routes" %>
|
21
|
-
<%= javascript_include_tag "jquery" %>
|
22
|
-
<%= javascript_include_tag "jquery-ui" %>
|
23
|
-
<%= javascript_include_tag "popper" %>
|
24
|
-
<%= javascript_include_tag "spin" %>
|
25
|
-
<%= javascript_include_tag "jquery.spin" %>
|
26
|
-
<%= javascript_include_tag "bootstrap-sprockets" %>
|
27
|
-
<%= javascript_include_tag "bootstrap-datepicker" %>
|
28
|
-
<%= javascript_include_tag "dataTables/jquery.dataTables" %>
|
29
|
-
<%= javascript_include_tag "dataTables/bootstrap/3/jquery.dataTables.bootstrap" %>
|
30
|
-
<%= javascript_include_tag "mustache" %>
|
31
|
-
<%= javascript_include_tag "bootstrap-datepicker" %>
|
32
|
-
<%= javascript_include_tag "kaui/kaui" %>
|
33
|
-
|
34
18
|
</head>
|
@@ -23,6 +23,13 @@
|
|
23
23
|
</div>
|
24
24
|
|
25
25
|
<div id="invoiceItems" style="display:none">
|
26
|
+
<div class="form-group">
|
27
|
+
<label class="col-sm-2 control-label"></label>
|
28
|
+
<div class="col-sm-10">
|
29
|
+
<input type="checkbox" id="selectAll">
|
30
|
+
<%="Select All" %>
|
31
|
+
</div>
|
32
|
+
</div>
|
26
33
|
<% @invoice.items.each_with_index do |ii, index| %>
|
27
34
|
<% if ii.amount > 0 %>
|
28
35
|
<div id=<%= "div_#{ii.invoice_item_id}" %> class="form-group">
|
@@ -31,7 +38,7 @@
|
|
31
38
|
<% bundle_result = @bundles.find { |bundle| bundle.bundle_id == ii.bundle_id } %>
|
32
39
|
<div class="col-sm-10">
|
33
40
|
<input type="checkbox" id=<%= "cb_adj_#{ii.invoice_item_id}" %>>
|
34
|
-
<%=
|
41
|
+
<%= Kaui.refund_invoice_description.call(index, ii, bundle_result) %>
|
35
42
|
<%= text_field_tag "adjustments[#{ii.invoice_item_id}]", index, :id => "tf_adj_#{ii.invoice_item_id}", :value => ii.amount, :class => 'form-control' %>
|
36
43
|
</div>
|
37
44
|
</div>
|
@@ -144,9 +151,23 @@
|
|
144
151
|
}
|
145
152
|
validateRefundAmount();
|
146
153
|
};
|
154
|
+
/*
|
155
|
+
* Check status of all items check-box check/uncheck status for select all chec-kbox
|
156
|
+
*/
|
157
|
+
var checkSelectAllCheckboxStatus = function(){
|
158
|
+
var checkedCheckBoxCount = 0;
|
159
|
+
var checkboxList = $('input').filter(function() { return this.id.match(/cb_adj_/) });
|
160
|
+
var checkboxListCount = checkboxList.length;
|
161
|
+
checkboxList.each(function() {
|
162
|
+
if ($(this).is(':checked')) {
|
163
|
+
checkedCheckBoxCount++;
|
164
|
+
}
|
165
|
+
});
|
166
|
+
$("#selectAll").prop('checked', checkedCheckBoxCount == checkboxListCount);
|
167
|
+
}
|
147
168
|
|
148
169
|
/*
|
149
|
-
* When clicking checkbox for each item, disable amount and recompute total refund amount
|
170
|
+
* When clicking checkbox for each item, disable amount, Changes SelectAll status and recompute total refund amount
|
150
171
|
*/
|
151
172
|
var onClickInvoiceItemAdjustment = function(event) {
|
152
173
|
var id = checkboxToTextId(this.id);
|
@@ -158,8 +179,30 @@
|
|
158
179
|
}
|
159
180
|
recomputeRefundAmountAndValidateAmount();
|
160
181
|
validateInvoiceItemAmount(id);
|
182
|
+
checkSelectAllCheckboxStatus();
|
161
183
|
};
|
162
184
|
|
185
|
+
/*
|
186
|
+
* When clicking select all checkbox - select each items, disable amount and recompute total refund amount
|
187
|
+
*/
|
188
|
+
var onClickInvoiceItemsSelectAll = function(event){
|
189
|
+
var isChecked = $('#selectAll').prop('checked');
|
190
|
+
$('input').filter(function() { return this.id.match(/tf_adj_/) }).each(function() {
|
191
|
+
var textFieldId = this.id;
|
192
|
+
var textFieldIdElm = $("#" + textFieldId);
|
193
|
+
var checkboxId = textToCheckboxId(this.id);
|
194
|
+
if(checkboxId){
|
195
|
+
$("#" + checkboxId).prop('checked', isChecked);
|
196
|
+
textFieldIdElm.prop('readonly', isChecked);
|
197
|
+
if(!isChecked){
|
198
|
+
textFieldIdElm.attr('value', textFieldIdElm.attr('originalValue'));
|
199
|
+
}
|
200
|
+
validateInvoiceItemAmount(textFieldId);
|
201
|
+
}
|
202
|
+
});
|
203
|
+
recomputeRefundAmountAndValidateAmount();
|
204
|
+
}
|
205
|
+
|
163
206
|
/*
|
164
207
|
* When selecting Invoice Adjustment or No Adjustment, hide invoice items and recompute refund Amount
|
165
208
|
*/
|
@@ -213,6 +256,11 @@
|
|
213
256
|
return this.id.match(/cb_adj_/);
|
214
257
|
}).click(onClickInvoiceItemAdjustment);
|
215
258
|
|
259
|
+
/*
|
260
|
+
* Attach handler onClickInvoiceItemsSelectAll for selectall checkbox
|
261
|
+
*/
|
262
|
+
$('#selectAll').click(onClickInvoiceItemsSelectAll);
|
263
|
+
|
216
264
|
/*
|
217
265
|
* Attach handler for all invoice item text areas so that:
|
218
266
|
* - We disable posting form when pressing 'ENTER'
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<div class="form-group">
|
11
11
|
<%= label_tag :requested_date, 'Date', :class => 'col-sm-2 control-label' %>
|
12
12
|
<div class="col-sm-10">
|
13
|
-
|
13
|
+
<input class="form-control" value="<%=Date.parse(Time.now.to_s).to_s%>" name="requested_date" type="text" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-today-highlight="true">
|
14
14
|
</div>
|
15
15
|
</div>
|
16
16
|
<div class="form-group">
|
@@ -37,7 +37,7 @@
|
|
37
37
|
<div class="form-group", id="form_requested_date" >
|
38
38
|
<%= label_tag :requested_date, 'Change Date', :class => 'col-sm-3 control-label' %>
|
39
39
|
<div class="col-sm-9">
|
40
|
-
|
40
|
+
<input class="form-control" value="<%=Date.parse(Time.now.to_s).to_s%>" name="requested_date" type="text" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-today-highlight="true">
|
41
41
|
</div>
|
42
42
|
</div>
|
43
43
|
<div class="form-group", id="form_policy">
|
@@ -59,7 +59,7 @@
|
|
59
59
|
<div class="form-group" id="form_requested_date">
|
60
60
|
<%= label_tag :requested_date, 'Date', :class => 'col-sm-2 control-label' %>
|
61
61
|
<div class="col-sm-10">
|
62
|
-
|
62
|
+
<input class="form-control" value="<%=Date.parse(Time.now.to_s).to_s%>" name="requested_date" type="text" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-today-highlight="true">
|
63
63
|
</div>
|
64
64
|
</div>
|
65
65
|
<div class="form-group">
|
@@ -15,7 +15,7 @@
|
|
15
15
|
<div class="form-group" , id="form_effective_from_date">
|
16
16
|
<%= label_tag :effective_from_date, 'Effective Date', :class => 'col-sm-2 control-label' %>
|
17
17
|
<div class="col-sm-10">
|
18
|
-
|
18
|
+
<input class="form-control" value="<%=Date.parse(Time.now.to_s).to_s%>" id="effective_from_date" name="effective_from_date" type="text" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-today-highlight="true">
|
19
19
|
</div>
|
20
20
|
</div>
|
21
21
|
<div class="form-group">
|
@@ -10,8 +10,7 @@
|
|
10
10
|
<div class="col-sm-10" id="object_types">
|
11
11
|
<% (@tag_definition.applicable_object_types || [:account]).each_with_index do |object_type, index| %>
|
12
12
|
<div id="object_type_line_<%= index %>">
|
13
|
-
|
14
|
-
{:selected => object_type, :id => "object_type_#{index}"}, :class => 'form-control tag-definition-select' %>
|
13
|
+
<%= select_tag "tag_definition[applicable_object_types][#{index}]", options_for_select(object_types), {:selected => object_type, :id => "object_type_#{index}", :class => 'form-control tag-definition-select'} %>
|
15
14
|
<a class='btn btn-xs' href="javascript:void(0);" onclick="delete_object_type(this);" id="delete_object_type_<%= index %>" <%= "style='display: none;'".html_safe if index == 0 %>>
|
16
15
|
<%= '<i class="fa fa-times"></i>'.html_safe %>
|
17
16
|
</a>
|
data/config/routes.rb
CHANGED
@@ -98,6 +98,7 @@ Kaui::Engine.routes.draw do
|
|
98
98
|
scope '/invoices' do
|
99
99
|
match '/pagination' => 'invoices#pagination', :via => :get, :as => 'invoices_pagination'
|
100
100
|
match '/:id/show_html' => 'invoices#show_html', :via => :get, :as => 'show_html_invoice'
|
101
|
+
match '/:number' => 'invoices#restful_show_by_number', :via => :get, :constraints => { number: /\d+/ }
|
101
102
|
match '/:id' => 'invoices#restful_show', :via => :get, :as => 'invoice'
|
102
103
|
match '/commit' => 'invoices#commit_invoice', :via => :post, :as => 'commit_invoice'
|
103
104
|
match '/void' => 'invoices#void_invoice', :via => :delete, :as => 'void_invoice'
|