kaui 3.0.4 → 3.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 381a1791f9fc6c1d64886d34dca17905a83ec38322043735a2437d83d8516d35
4
- data.tar.gz: ee79517525bb910a58c1996621171c0600c113e98215e016f283f5d3ee9d2c0e
3
+ metadata.gz: 4f1640604b51f6dc5c1d70ed464a59445fd16fc830d69797bb73c18a351db03f
4
+ data.tar.gz: b385394d51aed523a26d34b437a7e4f8f869de07447b18a0fcce3d81948e275f
5
5
  SHA512:
6
- metadata.gz: bce25f97853968fb171263eb1513ca6588d4884e0045232880bc24bc10cd55057b36e72cd89a7ef86996c4c9ec045a0b37aa7f39a35c2c9dfe0137866e1d7255
7
- data.tar.gz: 371aa14f4390357331e257e9735a1c4f2ac940069b041f7bf595f68c960fec3c3ca32af274ba39b3abf4047a5e8d789590bbb6b90b079a11236bd7ee1b89de1a
6
+ metadata.gz: ca50c69637a9fa3e7b7bd866ad3ac638bf676e8f8a61ff8b56e68eb7591f59fefa6536739b8c326523cf7013502586b23edc7fe62a08766e586cbcc73996aa07
7
+ data.tar.gz: 2ef386342bd738b4089d50dd1621c2e5e0542c37099435ef8a80f5419a30dd956d478ea3762a553b741985c5f6e1878686d502915b02b2f47f471d671ff11746
@@ -132,12 +132,7 @@ jQuery(document).ready(function ($) {
132
132
 
133
133
  function set_first_name_length(name){
134
134
  var name_in_parts = name.trim().split(' ');
135
-
136
- if (name_in_parts.length > 1){
137
- $('#account_first_name_length').val(name_in_parts[0].length);
138
- }else{
139
- $('#account_first_name_length').val('');
140
- }
135
+ $('#account_first_name_length').val(name_in_parts[0].length);
141
136
  }
142
137
 
143
138
 
@@ -34,20 +34,16 @@ module Kaui
34
34
 
35
35
  def download
36
36
  timeline = Kaui::AccountTimeline.find_by_account_id(params.require(:account_id), 'FULL', options_for_klient)
37
- start_date = params[:startDate]
38
- end_date = params[:endDate]
39
37
  start_date = begin
40
- Date.parse(start_date)
38
+ Date.parse(params[:startDate])
41
39
  rescue StandardError
42
40
  nil
43
41
  end
44
42
  end_date = begin
45
- Date.parse(end_date)
43
+ Date.parse(params[:endDate])
46
44
  rescue StandardError
47
45
  nil
48
46
  end
49
- start_date = params[:startDate].present? ? Date.parse(params[:startDate]) : nil
50
- end_date = params[:endDate].present? ? Date.parse(params[:endDate]) : nil
51
47
 
52
48
  event_type = params[:eventType]
53
49
  @account = timeline.account
@@ -53,11 +53,16 @@ module Kaui
53
53
  end_date = params[:endDate]
54
54
  all_fields_checked = params[:allFieldsChecked] == 'true'
55
55
 
56
- columns = if all_fields_checked
57
- KillBillClient::Model::AccountAttributes.instance_variable_get('@json_attributes')
58
- else
59
- params.require(:columnsString).split(',').map { |attr| attr.split.join('_').downcase }
60
- end
56
+ if all_fields_checked
57
+ columns = KillBillClient::Model::AccountAttributes.instance_variable_get('@json_attributes')
58
+ else
59
+ columns = params.require(:columnsString).split(',').map { |attr| attr.split.join('_').downcase }
60
+ Kaui::Account::REMAPPING_FIELDS.each do |k, v|
61
+ index = columns.index(v)
62
+ columns[index] = k if index
63
+ end
64
+ end
65
+
61
66
  start_date = begin
62
67
  Date.parse(start_date)
63
68
  rescue StandardError
@@ -130,12 +135,10 @@ module Kaui
130
135
  fetch_account_emails = promise { Kaui::AccountEmail.find_all_sorted_by_account_id(@account.account_id, 'NONE', cached_options_for_klient) }
131
136
  fetch_payments = promise { @account.payments(cached_options_for_klient).map! { |payment| Kaui::Payment.build_from_raw_payment(payment) } }
132
137
  fetch_payment_methods = promise { Kaui::PaymentMethod.find_all_by_account_id(@account.account_id, false, cached_options_for_klient) }
133
-
134
- # is email notification plugin available
135
- is_email_notifications_plugin_available = Kenui::EmailNotificationService.email_notification_plugin_available?(cached_options_for_klient).first
138
+ is_email_notifications_plugin_available = Dependencies::Kenui::EmailNotification.email_notification_plugin_available?(cached_options_for_klient).first
136
139
  fetch_email_notification_configuration = if is_email_notifications_plugin_available
137
140
  promise do
138
- Kenui::EmailNotificationService.get_configuration_per_account(params.require(:account_id), cached_options_for_klient)
141
+ Dependencies::Kenui::EmailNotification.get_configuration_per_account(params.require(:account_id), cached_options_for_klient)
139
142
  end.then do |configuration|
140
143
  if configuration.first.is_a?(FalseClass)
141
144
  Rails.logger.warn(configuration[1])
@@ -170,7 +173,7 @@ module Kaui
170
173
  @available_tags = wait(fetch_available_tags)
171
174
  @children = wait(fetch_children)
172
175
  @account_parent = @account.parent_account_id.nil? ? nil : wait(fetch_parent)
173
- @email_notification_configuration = wait(fetch_email_notification_configuration) if is_email_notifications_plugin_available
176
+ @email_notification_configuration = is_email_notifications_plugin_available ? wait(fetch_email_notification_configuration) : []
174
177
 
175
178
  @last_transaction_by_payment_method_id = {}
176
179
  wait(fetch_payments).each do |payment|
@@ -340,15 +343,15 @@ module Kaui
340
343
  event_types = configuration[:event_types]
341
344
  cached_options_for_klient = options_for_klient
342
345
 
343
- is_success, message = email_notification_plugin_available?(cached_options_for_klient)
346
+ is_success, message = Dependencies::Kenui::EmailNotification.email_notification_plugin_available?(cached_options_for_klient)
344
347
 
345
348
  if is_success
346
- is_success, message = Kenui::EmailNotificationService.set_configuration_per_account(account_id,
347
- event_types,
348
- current_user.kb_username,
349
- params[:reason],
350
- params[:comment],
351
- cached_options_for_klient)
349
+ is_success, message = Dependencies::Kenui::EmailNotification.set_configuration_per_account(account_id,
350
+ event_types,
351
+ current_user.kb_username,
352
+ params[:reason],
353
+ params[:comment],
354
+ cached_options_for_klient)
352
355
  end
353
356
  if is_success
354
357
  flash[:notice] = message
@@ -360,7 +363,7 @@ module Kaui
360
363
 
361
364
  def events_to_consider
362
365
  json_response do
363
- { data: Kenui::EmailNotificationService.get_events_to_consider(options_for_klient) }
366
+ { data: Dependencies::Kenui::EmailNotification.get_events_to_consider(options_for_klient) }
364
367
  end
365
368
  end
366
369
 
@@ -368,16 +371,5 @@ module Kaui
368
371
  data = KillBillClient::Model::Export.find_by_account_id(params[:account_id], current_user.kb_username, options_for_klient)
369
372
  send_data data, filename: "account#{params[:account_id]}.txt", type: :txt
370
373
  end
371
-
372
- private
373
-
374
- def email_notification_plugin_available?(options_for_klient)
375
- error_message = 'Email notification plugin is not installed'
376
-
377
- is_available = Kenui::EmailNotificationService.email_notification_plugin_available?(options_for_klient).first
378
- [is_available, is_available ? nil : error_message]
379
- rescue StandardError
380
- [false, error_message]
381
- end
382
374
  end
383
375
  end
@@ -142,7 +142,7 @@ module Kaui
142
142
  else
143
143
  errors = ''
144
144
  catalog_validation_errors.each do |validation_error|
145
- errors += (validation_error['errorDescription'])
145
+ errors += validation_error['errorDescription']
146
146
  end
147
147
  flash[:error] = errors
148
148
  redirect_to admin_tenant_new_catalog_path(id: current_tenant.id)
@@ -76,7 +76,7 @@ module Kaui
76
76
  end
77
77
  end
78
78
 
79
- send_data csv_file, type: 'text/csv', filename: "audit_logs_#{account_id}.csv"
79
+ send_data csv_file, type: 'text/csv', filename: "audit-logs-#{Date.today}.csv"
80
80
  end
81
81
 
82
82
  def history
@@ -41,6 +41,7 @@ module Kaui
41
41
  # Until we support server-side sorting
42
42
  ordering = (params[:order] || {})[:'0'] || {}
43
43
  ordering_column = (ordering[:column] || 0).to_i
44
+ ordering_column = params[:colum_order][ordering_column].to_i if params[:colum_order].present?
44
45
  ordering_dir = ordering[:dir] || 'asc'
45
46
  unless search_key.nil?
46
47
  pages.sort! do |a, b|
@@ -70,13 +70,7 @@ module Kaui
70
70
  end
71
71
  else
72
72
  lambda do |invoice, column|
73
- [
74
- invoice.invoice_number.to_i,
75
- invoice.invoice_date,
76
- invoice.amount,
77
- invoice.balance,
78
- invoice.status
79
- ][column]
73
+ Kaui.account_invoices_columns.call(invoice, view_context)[2][column]
80
74
  end
81
75
  end
82
76
 
@@ -19,11 +19,15 @@ module Kaui
19
19
  start_date = params[:startDate]
20
20
  end_date = params[:endDate]
21
21
  all_fields_checked = params[:allFieldsChecked] == 'true'
22
- columns = if all_fields_checked
23
- KillBillClient::Model::PaymentAttributes.instance_variable_get('@json_attributes') - %w[transactions audit_logs]
24
- else
25
- params.require(:columnsString).split(',').map { |attr| attr.split.join('_').downcase }
26
- end
22
+ if all_fields_checked
23
+ columns = KillBillClient::Model::PaymentAttributes.instance_variable_get('@json_attributes') - %w[transactions audit_logs]
24
+ else
25
+ columns = params.require(:columnsString).split(',').map { |attr| attr.split.join('_').downcase }
26
+ Kaui::Payment::REMAPPING_FIELDS.each do |k, v|
27
+ index = columns.index(v)
28
+ columns[index] = k if index
29
+ end
30
+ end
27
31
 
28
32
  kb_params = {}
29
33
  kb_params[:startDate] = Date.parse(start_date).strftime('%Y-%m-%d') if start_date
@@ -39,7 +43,7 @@ module Kaui
39
43
  created_date = nil
40
44
  payment.transactions.each do |transaction|
41
45
  transaction_date = Date.parse(transaction.effective_date)
42
- created_date ||= transaction_date if transaction_date < created_date
46
+ created_date = transaction_date if created_date.nil? || (transaction_date < created_date)
43
47
  end
44
48
  payment.payment_date = created_date
45
49
  end
@@ -114,15 +118,7 @@ module Kaui
114
118
  end
115
119
 
116
120
  data_extractor = lambda do |payment, column|
117
- [
118
- payment.payment_number.to_i,
119
- payment.payment_date,
120
- payment.total_authed_amount_to_money,
121
- payment.paid_amount_to_money,
122
- payment.returned_amount_to_money,
123
- payment.transactions.empty? ? nil : payment.transactions[-1].status,
124
- payment.payment_external_key
125
- ][column]
121
+ Kaui.account_payments_columns.call(account, payment, view_context)[2][column]
126
122
  end
127
123
 
128
124
  formatter = lambda do |payment|
@@ -98,7 +98,7 @@ module Kaui
98
98
  ''
99
99
  else
100
100
  current_plan = sub.prices.select { |price| price['phaseType'] == sub.phase_type && price['planName'] == sub.plan_name }
101
- price_override = current_plan.last['fixedPrice'] || current_plan.last['recurringPrice']
101
+ price_override = current_plan.last ? (current_plan.last['fixedPrice'] || current_plan.last['recurringPrice']) : nil
102
102
 
103
103
  if price_override.blank?
104
104
  ''
@@ -5,6 +5,13 @@ module Kaui
5
5
  attr_accessor :phone, :bill_cycle_day_local
6
6
 
7
7
  SENSIVITE_DATA_FIELDS = %w[name email].freeze
8
+ REMAPPING_FIELDS = {
9
+ 'is_payment_delegated_to_parent' => 'pay_via_parent',
10
+ 'bill_cycle_day_local' => 'bcd',
11
+ 'account_balance' => 'balance',
12
+ 'account_cba' => 'cba',
13
+ 'is_migrated' => 'migrated'
14
+ }.freeze
8
15
 
9
16
  def check_account_details_phone
10
17
  return true if phone =~ /\A(?:\+?\d{1,3}\s*-?)?\(?(?:\d{3})?\)?[- ]?\d{3}[- ]?\d{4}\z/i
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Kaui
4
4
  class Invoice < KillBillClient::Model::Invoice
5
- TABLE_IGNORE_COLUMNS = %w[amount balance credit_adj refund_adj items is_parent_invoice parent_invoice_id parent_account_id].freeze
5
+ TABLE_IGNORE_COLUMNS = %w[amount balance credit_adj refund_adj items is_parent_invoice parent_invoice_id parent_account_id audit_logs bundle_keys].freeze
6
6
 
7
7
  def self.build_from_raw_invoice(raw_invoice)
8
8
  result = Kaui::Invoice.new
@@ -7,6 +7,13 @@ module Kaui
7
7
  attr_accessor :payment_date, :target_invoice_id
8
8
 
9
9
  TRANSACTION_STATUSES = %w[SUCCESS PENDING PAYMENT_FAILURE PLUGIN_FAILURE UNKNOWN].freeze
10
+ REMAPPING_FIELDS = {
11
+ 'auth_amount' => 'auth',
12
+ 'captured_amount' => 'capture',
13
+ 'purchased_amount' => 'purchase',
14
+ 'credited_amount' => 'credit',
15
+ 'refunded_amount' => 'refund'
16
+ }.freeze
10
17
 
11
18
  def self.build_from_raw_payment(raw_payment)
12
19
  result = Kaui::Payment.new
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dependencies
4
+ module Kenui
5
+ class EmailNotification
6
+ ERROR_MESSAGE = I18n.translate('errors.messages.email_notification_plugin_not_available')
7
+ class << self
8
+ def email_notification_plugin_available?(options_for_klient)
9
+ is_available = ::Kenui::EmailNotificationService.email_notification_plugin_available?(options_for_klient)
10
+ [is_available, is_available ? nil : ERROR_MESSAGE]
11
+ rescue StandardError
12
+ [false, ERROR_MESSAGE]
13
+ end
14
+
15
+ def set_configuration_per_account(account_id, event_types, kb_username, reason, comment, options_for_klient)
16
+ ::Kenui::EmailNotificationService.set_configuration_per_account(account_id,
17
+ event_types,
18
+ kb_username,
19
+ reason,
20
+ comment,
21
+ options_for_klient)
22
+ rescue StandardError
23
+ [false, ERROR_MESSAGE]
24
+ end
25
+
26
+ def get_events_to_consider(options_for_klient)
27
+ ::Kenui::EmailNotificationService.get_events_to_consider(options_for_klient)
28
+ rescue StandardError
29
+ {}
30
+ end
31
+
32
+ def get_configuration_per_account(account_id, options_for_klient)
33
+ ::Kenui::EmailNotificationService.get_configuration_per_account(account_id, options_for_klient)
34
+ rescue StandardError
35
+ []
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -107,38 +107,9 @@ $(document).ready(function() {
107
107
  $('#allData').change(function() {
108
108
  $('#startDate').val(null);
109
109
  $('#endDate').val(null);
110
- var isChecked = $(this).is(':checked');
111
110
  $('#startDate, #endDate').prop('disabled', true);
112
111
  });
113
112
 
114
- function setDateRange(option) {
115
- var currentDate = new Date();
116
- var startDate, endDate;
117
-
118
- if (option === "day") {
119
- startDate = new Date();
120
- endDate = new Date();
121
- endDate.setDate(endDate.getDate() + 1);
122
- } else if (option === "week") {
123
- startDate = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 1));
124
- currentDate = new Date();
125
- endDate = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 7));
126
- } else if (option === "month") {
127
- startDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
128
- endDate = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
129
- } else if (option === "year") {
130
- startDate = new Date(currentDate.getFullYear(), 0, 1);
131
- endDate = new Date(currentDate.getFullYear(), 11, 31);
132
- }
133
-
134
- var startDateFormatted = startDate.toISOString().split('T')[0];
135
- var endDateFormatted = endDate.toISOString().split('T')[0];
136
-
137
- $('#startDate').val(startDateFormatted);
138
- $('#endDate').val(endDateFormatted);
139
- $('#startDate, #endDate').prop('disabled', true);
140
- }
141
-
142
113
  $('#thisWeek').change(function() {
143
114
  if ($(this).is(':checked')) {
144
115
  setDateRange("week");
@@ -101,6 +101,15 @@
101
101
  width: 200px;
102
102
  overflow-y: auto;
103
103
  }
104
+
105
+ .dropdown-menu#column-visibility::before {
106
+ content: 'Drag to reorder columns';
107
+ display: block;
108
+ height: 30px;
109
+ text-align: center;
110
+ color: darkgrey;
111
+ padding-top: 5px;
112
+ }
104
113
 
105
114
  .dropdown-menu {
106
115
  padding: 5px;
@@ -170,38 +179,11 @@ $(document).ready(function() {
170
179
  });
171
180
 
172
181
  $('#allData').change(function() {
173
- var isChecked = $(this).is(':checked');
182
+ $('#startDate').val(null);
183
+ $('#endDate').val(null);
174
184
  $('#startDate, #endDate').prop('disabled', true);
175
185
  });
176
186
 
177
- function setDateRange(option) {
178
- var currentDate = new Date();
179
- var startDate, endDate;
180
-
181
- if (option === "day") {
182
- startDate = new Date();
183
- endDate = new Date();
184
- endDate.setDate(endDate.getDate() + 1);
185
- } else if (option === "week") {
186
- startDate = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 1));
187
- currentDate = new Date();
188
- endDate = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 7));
189
- } else if (option === "month") {
190
- startDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
191
- endDate = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
192
- } else if (option === "year") {
193
- startDate = new Date(currentDate.getFullYear(), 0, 1);
194
- endDate = new Date(currentDate.getFullYear(), 11, 31);
195
- }
196
-
197
- var startDateFormatted = startDate.toISOString().split('T')[0];
198
- var endDateFormatted = endDate.toISOString().split('T')[0];
199
-
200
- $('#startDate').val(startDateFormatted);
201
- $('#endDate').val(endDateFormatted);
202
- $('#startDate, #endDate').prop('disabled', true);
203
- }
204
-
205
187
  $('#thisWeek').change(function() {
206
188
  if ($(this).is(':checked')) {
207
189
  setDateRange("week");
@@ -26,53 +26,54 @@
26
26
  </div>
27
27
  </div>
28
28
 
29
+ <style>
30
+ #accounts-table td, #accounts-table tr {
31
+ white-space: nowrap;
32
+ }
33
+ .custom-checkbox {
34
+ pointer-events: none;
35
+ }
36
+ </style>
37
+
29
38
  <%= javascript_tag do %>
30
39
  $(document).ready(function() {
31
- $.ajax({
32
- url: "<%= accounts_pagination_path(:ordering => @ordering, :format => :json) %>",
33
- type: "GET",
34
- success: function(response) {
35
- const visibleColumns = response.columns;
36
-
37
- var table = $('#accounts-table').DataTable({
38
- "colReorder": {
39
- "enable": false
40
- },
41
- "stateSave": true,
42
- "scrollX": true,
43
- "dom": "<'row'r>t<'row'<'col-md-6'i><'col-md-6'p>>",
44
- "pagingType": <% if @max_nb_records.nil? -%>"simple"<% else -%>"full_numbers"<% end -%>,
45
- "language": {
46
- <!-- See DefaultPaginationSqlDaoHelper.java -->
47
- "info": <% if @max_nb_records.nil? -%>"Showing _START_ to _END_ of <%= number_with_delimiter(Kaui::EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD) -%>+ entries"<% else -%>"Showing _START_ to _END_ of _TOTAL_ entries"<% end -%>
48
- },
49
- "pageLength": <%= @limit %>,
50
- "displayStart": <%= @offset %>,
51
- <% if @search_query.blank? %>
52
- "ordering": false,
53
- <% elsif !@ordering.blank? %>
54
- "order": [[ 1, "<%= @ordering %>" ]],
55
- <% end %>
56
- "processing": true,
57
- "serverSide": true,
58
- "search": {"search": "<%= @search_query %>"},
59
- "ajax": {
60
- url: "<%= accounts_pagination_path(:ordering => @ordering, :format => :json) %>",
61
- dataSrc: function(json) {
62
- var colOrder = $('#accounts-table').DataTable().colReorder.order();
63
- var reorderedData = json.data.map(function(row) {
64
- var newRow = [];
65
- for (var i = 0; i < colOrder.length; i++) {
66
- newRow.push(row[colOrder[i]]);
67
- }
68
- return newRow;
69
- });
70
- return reorderedData;
40
+ var table = $('#accounts-table').DataTable({
41
+ "colReorder": {
42
+ "enable": false
43
+ },
44
+ "stateSave": true,
45
+ "scrollX": true,
46
+ "dom": "<'row'r>t<'row'<'col-md-6'i><'col-md-6'p>>",
47
+ "pagingType": <% if @max_nb_records.nil? -%>"simple"<% else -%>"full_numbers"<% end -%>,
48
+ "language": {
49
+ <!-- See DefaultPaginationSqlDaoHelper.java -->
50
+ "info": <% if @max_nb_records.nil? -%>"Showing _START_ to _END_ of <%= number_with_delimiter(Kaui::EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD) -%>+ entries"<% else -%>"Showing _START_ to _END_ of _TOTAL_ entries"<% end -%>
51
+ },
52
+ "pageLength": <%= @limit %>,
53
+ "displayStart": <%= @offset %>,
54
+ <% if @search_query.blank? %>
55
+ "ordering": false,
56
+ <% elsif !@ordering.blank? %>
57
+ "order": [[ 1, "<%= @ordering %>" ]],
58
+ <% end %>
59
+ "processing": true,
60
+ "serverSide": true,
61
+ "search": {"search": "<%= @search_query %>"},
62
+ "ajax": {
63
+ url: "<%= accounts_pagination_path(:ordering => @ordering, :format => :json) %>",
64
+ dataSrc: function(json) {
65
+ var colOrder = table.colReorder.order();
66
+ var reorderedData = json.data.map(function(row) {
67
+ var newRow = [];
68
+ for (var i = 0; i < colOrder.length; i++) {
69
+ newRow.push(row[colOrder[i]]);
71
70
  }
72
- },
73
- "columns": visibleColumns
74
- });
75
- }
71
+ return newRow;
72
+ });
73
+ return reorderedData;
74
+ }
75
+ },
76
+ "columns": <%= raw @visible_columns.to_json %>
76
77
  });
77
78
 
78
79
  <!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
@@ -142,38 +142,9 @@ $(document).ready(function() {
142
142
  $('#allData').change(function() {
143
143
  $('#startDate').val(null);
144
144
  $('#endDate').val(null);
145
- var isChecked = $(this).is(':checked');
146
145
  $('#startDate, #endDate').prop('disabled', true);
147
146
  });
148
147
 
149
- function setDateRange(option) {
150
- var currentDate = new Date();
151
- var startDate, endDate;
152
-
153
- if (option === "day") {
154
- startDate = new Date();
155
- endDate = new Date();
156
- endDate.setDate(endDate.getDate() + 1);
157
- } else if (option === "week") {
158
- startDate = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 1));
159
- currentDate = new Date();
160
- endDate = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 7));
161
- } else if (option === "month") {
162
- startDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
163
- endDate = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
164
- } else if (option === "year") {
165
- startDate = new Date(currentDate.getFullYear(), 0, 1);
166
- endDate = new Date(currentDate.getFullYear(), 11, 31);
167
- }
168
-
169
- var startDateFormatted = startDate.toISOString().split('T')[0];
170
- var endDateFormatted = endDate.toISOString().split('T')[0];
171
-
172
- $('#startDate').val(startDateFormatted);
173
- $('#endDate').val(endDateFormatted);
174
- $('#startDate, #endDate').prop('disabled', true);
175
- }
176
-
177
148
  $('#thisWeek').change(function() {
178
149
  if ($(this).is(':checked')) {
179
150
  setDateRange("week");
@@ -31,6 +31,12 @@
31
31
 
32
32
  </div>
33
33
 
34
+ <style>
35
+ #audit-logs-table td, #audit-logs-table tr {
36
+ white-space: nowrap;
37
+ }
38
+ </style>
39
+
34
40
 
35
41
  <%= javascript_tag do %>
36
42
  $(document).ready(function() {
@@ -38,6 +44,7 @@
38
44
  $('#audit-logs-table').DataTable({
39
45
  dom: "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
40
46
  data: auditLogs,
47
+ "scrollX": true,
41
48
  order: [[ 0, 'desc' ]],
42
49
  createdRow: function( row, data, dataIndex ) {
43
50
  if ( data[3] == "INSERT" ) {
@@ -105,6 +105,16 @@
105
105
  .dropdown-menu {
106
106
  padding: 5px;
107
107
  }
108
+
109
+ .dropdown-menu#column-visibility::before {
110
+ content: 'Drag to reorder columns';
111
+ display: block;
112
+ height: 30px;
113
+ text-align: center;
114
+ color: darkgrey;
115
+ padding-top: 5px;
116
+ }
117
+
108
118
  .toggle-button-right {
109
119
  float: right;
110
120
  margin-bottom: 10px;
@@ -173,34 +183,6 @@ $(document).ready(function() {
173
183
  $('#startDate, #endDate').prop('disabled', true);
174
184
  });
175
185
 
176
- function setDateRange(option) {
177
- var currentDate = new Date();
178
- var startDate, endDate;
179
-
180
- if (option === "day") {
181
- startDate = new Date();
182
- endDate = new Date();
183
- endDate.setDate(endDate.getDate() + 1);
184
- } else if (option === "week") {
185
- startDate = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 1));
186
- currentDate = new Date();
187
- endDate = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 7));
188
- } else if (option === "month") {
189
- startDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
190
- endDate = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
191
- } else if (option === "year") {
192
- startDate = new Date(currentDate.getFullYear(), 0, 1);
193
- endDate = new Date(currentDate.getFullYear(), 11, 31);
194
- }
195
-
196
- var startDateFormatted = startDate.toISOString().split('T')[0];
197
- var endDateFormatted = endDate.toISOString().split('T')[0];
198
-
199
- $('#startDate').val(startDateFormatted);
200
- $('#endDate').val(endDateFormatted);
201
- $('#startDate, #endDate').prop('disabled', true);
202
- }
203
-
204
186
  $('#thisWeek').change(function() {
205
187
  if ($(this).is(':checked')) {
206
188
  setDateRange("week");
@@ -1,11 +1,7 @@
1
1
  <div class="search">
2
-
3
2
  <div class="column-block">
4
-
5
3
  <h1>Invoices</h1>
6
-
7
4
  <%= render :partial => 'multi_functions_bar' %>
8
-
9
5
  <table id="invoices-table" class="table table-condensed mobile-data" style="width:100%">
10
6
  <thead>
11
7
  <tr>
@@ -20,13 +16,25 @@
20
16
  </tr>
21
17
  </tbody>
22
18
  </table>
23
-
24
19
  </div>
25
-
26
20
  </div>
27
21
 
22
+ <style>
23
+ #invoices-table td, #invoices-table tr {
24
+ white-space: nowrap;
25
+ }
26
+ </style>
27
+
28
28
  <%= javascript_tag do %>
29
29
  $(document).ready(function() {
30
+ var stateKey = 'DataTables_invoices-table';
31
+ var state = JSON.parse(localStorage.getItem(stateKey));
32
+ if (state) {
33
+ state.start = <%= @offset %>;
34
+ state.search = { search: "<%= @search_query %>" };
35
+ localStorage.setItem(stateKey, JSON.stringify(state));
36
+ }
37
+
30
38
  var table = $('#invoices-table').DataTable({
31
39
  "colReorder": {
32
40
  "enable": false
@@ -56,8 +64,11 @@ $(document).ready(function() {
56
64
  "search": {"search": "<%= @search_query %>"},
57
65
  "ajax": {
58
66
  url: "<%= invoices_pagination_path(:ordering => @ordering, :format => :json) %>",
67
+ data: function(d) {
68
+ d.colum_order = $('#invoices-table').DataTable().colReorder.order();
69
+ },
59
70
  dataSrc: function(json) {
60
- var colOrder = $('#invoices-table').DataTable().colReorder.order();
71
+ var colOrder = table.colReorder.order();
61
72
  var reorderedData = json.data.map(function(row) {
62
73
  var newRow = [];
63
74
  for (var i = 0; i < colOrder.length; i++) {
@@ -70,11 +81,6 @@ $(document).ready(function() {
70
81
  }
71
82
  });
72
83
 
73
- var searchQuery = "<%= @search_query %>";
74
- if (searchQuery) {
75
- table.search(searchQuery).draw();
76
- }
77
-
78
84
  <!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
79
85
  <% if @max_nb_records.nil? %>
80
86
  $('#invoices-table').on('draw.dt', function() {
@@ -1,10 +1,8 @@
1
1
  <div class="dropdown-container">
2
- <% unless @account.account_id.blank? %>
3
2
  <button class="btn btn-default download-button-right" type="button" id="modalDownloadButton">
4
3
  <i class="glyphicon glyphicon-download-alt"></i>
5
4
  <strong>Download CSV</strong>
6
5
  </button>
7
- <% end %>
8
6
  <div class="dropdown">
9
7
  <button class="btn btn-default dropdown-toggle toggle-button-right" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
10
8
  <i class="glyphicon glyphicon-cog"></i>
@@ -107,6 +105,16 @@
107
105
  .dropdown-menu {
108
106
  padding: 5px;
109
107
  }
108
+
109
+ .dropdown-menu#column-visibility::before {
110
+ content: 'Drag to reorder columns';
111
+ display: block;
112
+ height: 30px;
113
+ text-align: center;
114
+ color: darkgrey;
115
+ padding-top: 5px;
116
+ }
117
+
110
118
  .toggle-button-right {
111
119
  float: right;
112
120
  margin-bottom: 10px;
@@ -173,38 +181,9 @@ $(document).ready(function() {
173
181
  $('#allData').change(function() {
174
182
  $('#startDate').val(null);
175
183
  $('#endDate').val(null);
176
- var isChecked = $(this).is(':checked');
177
184
  $('#startDate, #endDate').prop('disabled', true);
178
185
  });
179
186
 
180
- function setDateRange(option) {
181
- var currentDate = new Date();
182
- var startDate, endDate;
183
-
184
- if (option === "day") {
185
- startDate = new Date();
186
- endDate = new Date();
187
- endDate.setDate(endDate.getDate() + 1);
188
- } else if (option === "week") {
189
- startDate = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 1));
190
- currentDate = new Date();
191
- endDate = new Date(currentDate.setDate(currentDate.getDate() - currentDate.getDay() + 7));
192
- } else if (option === "month") {
193
- startDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), 1);
194
- endDate = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0);
195
- } else if (option === "year") {
196
- startDate = new Date(currentDate.getFullYear(), 0, 1);
197
- endDate = new Date(currentDate.getFullYear(), 11, 31);
198
- }
199
-
200
- var startDateFormatted = startDate.toISOString().split('T')[0];
201
- var endDateFormatted = endDate.toISOString().split('T')[0];
202
-
203
- $('#startDate').val(startDateFormatted);
204
- $('#endDate').val(endDateFormatted);
205
- $('#startDate, #endDate').prop('disabled', true);
206
- }
207
-
208
187
  $('#thisWeek').change(function() {
209
188
  if ($(this).is(':checked')) {
210
189
  setDateRange("week");
@@ -1,10 +1,7 @@
1
1
  <div class="search">
2
-
3
2
  <div class="column-block">
4
-
5
3
  <h1><%= I18n.translate('payments') %></h1>
6
4
  <%= render :partial => 'multi_functions_bar' %>
7
-
8
5
  <table id="payments-table" class="table table-condensed mobile-data" style="width:100%">
9
6
  <thead>
10
7
  <tr>
@@ -19,13 +16,25 @@
19
16
  </tr>
20
17
  </tbody>
21
18
  </table>
22
-
23
19
  </div>
24
-
25
20
  </div>
26
21
 
22
+ <style>
23
+ #payments-table td, #payments-table tr {
24
+ white-space: nowrap;
25
+ }
26
+ </style>
27
+
27
28
  <%= javascript_tag do %>
28
29
  $(document).ready(function() {
30
+ var stateKey = 'DataTables_payments-table';
31
+ var state = JSON.parse(localStorage.getItem(stateKey));
32
+ if (state) {
33
+ state.start = <%= @offset %>;
34
+ state.search = { search: "<%= @search_query %>" };
35
+ localStorage.setItem(stateKey, JSON.stringify(state));
36
+ }
37
+
29
38
  var table = $('#payments-table').DataTable({
30
39
  "colReorder": {
31
40
  "enable": false
@@ -67,6 +76,9 @@ $(document).ready(function() {
67
76
  "paging": false,
68
77
  "ajax": {
69
78
  url: "<%= payments_pagination_path(:format => :json) %>",
79
+ data: function(d) {
80
+ d.colum_order = $('#payments-table').DataTable().colReorder.order();
81
+ },
70
82
  dataSrc: function(json) {
71
83
  var colOrder = $('#payments-table').DataTable().colReorder.order();
72
84
  var reorderedData = json.data.map(function(row) {
@@ -90,11 +102,6 @@ $(document).ready(function() {
90
102
  "search": {"search": "<%= @search_query %>"},
91
103
  });
92
104
 
93
- var searchQuery = "<%= @search_query %>";
94
- if (searchQuery) {
95
- table.search(searchQuery).draw();
96
- }
97
-
98
105
  <!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
99
106
  <% if @max_nb_records.nil? %>
100
107
  $('#payments-table').on('draw.dt', function() {
data/lib/kaui/engine.rb CHANGED
@@ -14,7 +14,6 @@ require 'bootstrap-datepicker-rails'
14
14
  require 'json'
15
15
  require 'money-rails'
16
16
  require 'killbill_client'
17
- require 'kenui'
18
17
  require 'devise'
19
18
  require 'cancan'
20
19
  require 'country_select'
data/lib/kaui/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kaui
4
- VERSION = '3.0.4'
4
+ VERSION = '3.0.6'
5
5
  end
data/lib/kaui.rb CHANGED
@@ -65,20 +65,30 @@ module Kaui
65
65
  original_fields = KillBillClient::Model::AccountAttributes.instance_variable_get('@json_attributes')
66
66
  # Add additional fields if needed
67
67
  fields = original_fields.dup
68
+ fields -= %w[audit_logs first_name_length]
69
+ headers = fields.dup
70
+ Kaui::Account::REMAPPING_FIELDS.each do |k, v|
71
+ headers[fields.index(k)] = v
72
+ end
73
+ headers.map! { |attr| attr.split('_').join(' ').capitalize }
68
74
 
69
- headers = fields.map { |attr| attr.split('_').join(' ').capitalize }
70
75
  values = fields.map do |attr|
76
+ next if account.nil? || view_context.nil?
77
+
71
78
  case attr
79
+ when 'is_payment_delegated_to_parent', 'is_migrated'
80
+ "<div style='text-align: center;'><input type='checkbox' class='custom-checkbox' #{account&.send(attr.downcase) ? 'checked' : ''}></div>"
72
81
  when 'account_id'
73
- account.nil? || view_context.nil? ? nil : view_context.link_to(account.account_id, view_context.url_for(action: :show, account_id: account.account_id))
82
+ view_context.link_to(account.account_id, view_context.url_for(action: :show, account_id: account.account_id))
74
83
  when 'parent_account_id'
75
- account.nil? || view_context.nil? || account.parent_account_id.nil? ? nil : view_context.link_to(account.account_id, view_context.url_for(action: :show, account_id: account.parent_account_id))
84
+ account.parent_account_id.nil? ? nil : view_context.link_to(account.account_id, view_context.url_for(action: :show, account_id: account.parent_account_id))
76
85
  when 'account_balance'
77
- account.nil? || view_context.nil? ? nil : view_context.humanized_money_with_symbol(account.balance_to_money)
86
+ view_context.humanized_money_with_symbol(account.balance_to_money)
78
87
  else
79
88
  account&.send(attr.downcase)
80
89
  end
81
90
  end
91
+
82
92
  [headers, values, fields]
83
93
  end
84
94
 
@@ -121,7 +131,7 @@ module Kaui
121
131
  when 'balance'
122
132
  view_context.humanized_money_with_symbol(invoice.balance_to_money)
123
133
  when 'invoice_id'
124
- view_context.link_to(invoice.invoice_number, view_context.url_for(controller: :invoices, action: :show, account_id: invoice.account_id, id: invoice.invoice_id))
134
+ view_context.link_to(invoice.invoice_id, view_context.url_for(controller: :invoices, action: :show, account_id: invoice.account_id, id: invoice.invoice_id))
125
135
  when 'status'
126
136
  default_label = 'label-info'
127
137
  default_label = 'label-default' if invoice&.status == 'DRAFT'
@@ -132,33 +142,36 @@ module Kaui
132
142
  invoice&.send(attr.downcase)
133
143
  end
134
144
  end
135
- # Add additional values if needed
136
- [headers, values]
145
+
146
+ raw_data = fields.map { |attr| invoice&.send(attr.downcase) }
147
+
148
+ [headers, values, raw_data]
137
149
  end
138
150
 
139
151
  self.account_payments_columns = lambda do |account = nil, payment = nil, view_context = nil|
140
152
  fields = KillBillClient::Model::PaymentAttributes.instance_variable_get('@json_attributes')
141
153
  # Change the order if needed
142
- fields = %w[payment_date total_authed_amount_to_money paid_amount_to_money returned_amount_to_money] + fields
154
+ fields = %w[payment_date] + fields
143
155
  fields -= %w[payment_number transactions audit_logs]
144
156
  fields.unshift('status')
145
157
  fields.unshift('payment_number')
146
158
 
147
- headers = fields.map { |attr| attr.split('_').join(' ').capitalize }
159
+ headers = fields.dup
160
+ Kaui::Payment::REMAPPING_FIELDS.each do |k, v|
161
+ headers[fields.index(k)] = v
162
+ end
163
+ headers.map! { |attr| attr.split('_').join(' ').capitalize }
164
+
148
165
  return [headers, []] if payment.nil?
149
166
 
150
167
  values = fields.map do |attr|
151
168
  case attr
169
+ when 'auth_amount', 'captured_amount', 'purchased_amount', 'refunded_amount', 'credited_amount'
170
+ view_context.humanized_money_with_symbol(payment&.send(attr.downcase))
152
171
  when 'payment_number'
153
172
  view_context.link_to(payment.payment_number, view_context.url_for(controller: :payments, action: :show, account_id: payment.account_id, id: payment.payment_id))
154
173
  when 'payment_date'
155
174
  view_context.format_date(payment.payment_date, account&.time_zone)
156
- when 'total_authed_amount_to_money'
157
- view_context.humanized_money_with_symbol(payment.total_authed_amount_to_money)
158
- when 'paid_amount_to_money'
159
- view_context.humanized_money_with_symbol(payment.paid_amount_to_money)
160
- when 'returned_amount_to_money'
161
- view_context.humanized_money_with_symbol(payment.returned_amount_to_money)
162
175
  when 'status'
163
176
  payment.transactions.empty? ? nil : view_context.colored_transaction_status(payment.transactions[-1].status)
164
177
  else
@@ -166,8 +179,17 @@ module Kaui
166
179
  end
167
180
  end
168
181
 
182
+ raw_data = fields.map do |attr|
183
+ case attr
184
+ when 'status'
185
+ payment.transactions.empty? ? nil : payment.transactions[-1].status
186
+ else
187
+ payment&.send(attr.downcase)
188
+ end
189
+ end
190
+
169
191
  # Add additional values if needed
170
- [headers, values]
192
+ [headers, values, raw_data]
171
193
  end
172
194
 
173
195
  self.account_audit_logs_columns = lambda do
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: 3.0.4
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-22 00:00:00.000000000 Z
11
+ date: 2025-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: bootsnap
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: cancan
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -164,20 +150,6 @@ dependencies:
164
150
  - - ">="
165
151
  - !ruby/object:Gem::Version
166
152
  version: '0'
167
- - !ruby/object:Gem::Dependency
168
- name: kenui
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- type: :runtime
175
- prerelease: false
176
- version_requirements: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: '0'
181
153
  - !ruby/object:Gem::Dependency
182
154
  name: killbill-assets-ui
183
155
  requirement: !ruby/object:Gem::Requirement
@@ -438,6 +410,7 @@ files:
438
410
  - app/models/kaui/transaction.rb
439
411
  - app/models/kaui/user.rb
440
412
  - app/models/kaui/user_role.rb
413
+ - app/services/dependencies/kenui.rb
441
414
  - app/views/kaui/account_children/index.html.erb
442
415
  - app/views/kaui/account_custom_fields/index.html.erb
443
416
  - app/views/kaui/account_emails/_account_emails_table.html.erb
@@ -594,7 +567,7 @@ licenses:
594
567
  - Apache License (2.0)
595
568
  metadata:
596
569
  rubygems_mfa_required: 'true'
597
- post_install_message:
570
+ post_install_message:
598
571
  rdoc_options: []
599
572
  require_paths:
600
573
  - lib
@@ -610,7 +583,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
610
583
  version: '0'
611
584
  requirements: []
612
585
  rubygems_version: 3.4.10
613
- signing_key:
586
+ signing_key:
614
587
  specification_version: 4
615
588
  summary: Killbill Admin UI mountable engine
616
589
  test_files: []