kaui 3.0.5 → 3.0.7

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: f1d09c53f971465792983fa62e85842cf0f7807e429793bcfaf298129fc30720
4
- data.tar.gz: 4536845ab8261e1e16ef4d9a8caba638e62fd4b02090fe0142430fb4d988e8ed
3
+ metadata.gz: 23207942c5d84c906aa3e23e06c74e86f278b7889088efb260bbb7d591043b4b
4
+ data.tar.gz: 56df3037f7210cffd9521a410df4302d93da6e5c3989bc5717fbad37033fcb9b
5
5
  SHA512:
6
- metadata.gz: a3f5018cfde24d5a5a53634a3b4098bb45cd439e0bcad1497163bb928737e6b628b6af430f4e3ff4ba792ed0e72c25c57f7a34f20a49480480383c35e4ddf741
7
- data.tar.gz: e4079ed0b2ec629b9fb1ea6fbbc4d617515ec78e2cc75cc4b2742578164c14e8b2d344ebeebba5e3ca83a7a100cf844f0d65cef93d0d770d7743c94444bbb8a9
6
+ metadata.gz: 5542399f26a14547366266fd4047b78cada6204033610005d9901e8d1a8c7a2367423809e468f599d602e1e59880c0f08cfded1298deeef41bc593e4203592de
7
+ data.tar.gz: eff5e260361d301bf8cc10ac973320c25f9fb76347aa57b3792017acc6fb4d817cea4e798eb797bf6d7c575862b5e1b4bf62ceed2d036ab33611f66f62a28e15
@@ -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
 
@@ -0,0 +1,132 @@
1
+ // Function to map operators to user-friendly text
2
+ function searchFormatOperator(operator) {
3
+ var operatorMapping = {
4
+ 'eq': 'Equals',
5
+ 'neq': 'Not Equals',
6
+ 'gt': 'Greater Than',
7
+ 'gte': 'Greater Than Or Equal',
8
+ 'lt': 'Less Than',
9
+ 'lte': 'Less Than Or Equal',
10
+ 'like': 'Like'
11
+ };
12
+ return operatorMapping[operator] || operator;
13
+ }
14
+
15
+ // Function to parse URL parameters
16
+ function getUrlParams() {
17
+ var params = {};
18
+ var queryString = window.location.search.substring(1);
19
+ queryString = queryString.replace(/ac_id/g, 'account_id');
20
+ var regex = /([^&=]+)=([^&]*)/g;
21
+ var m;
22
+ while (m = regex.exec(queryString)) {
23
+ params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);
24
+ }
25
+ return params;
26
+ }
27
+
28
+ // Function to populate search labels from URL parameters
29
+ function populateSearchLabelsFromUrl() {
30
+ var params = getUrlParams();
31
+ var searchLabelsContainer = $('#search-labels-container');
32
+ searchLabelsContainer.empty();
33
+
34
+ var hasBalanceFilter = window.location.search.includes('balance');
35
+
36
+ for (var key in params) {
37
+ if (params.hasOwnProperty(key)) {
38
+ var value = params[key];
39
+ value = value.replace(/%/g, '');
40
+ var match = key.match(/(.*)\[(.*)\]/);
41
+ if (match) {
42
+ var columnName = match[1].replace(/_/g, ' ').replace(/^\w/, function(l) { return l.toUpperCase(); });
43
+ var filter = searchFormatOperator(match[2]);
44
+ var label = $('<span>', {
45
+ class: 'label label-info',
46
+ text: columnName + ' [' + filter + '] ' + value
47
+ });
48
+
49
+ if (hasBalanceFilter && columnName.toLowerCase() !== 'balance') {
50
+ label.attr('class', 'label label-default');
51
+ }
52
+
53
+ searchLabelsContainer.append(label);
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ function searchQuery(account_id){
60
+ var searchFields = $('.search-field');
61
+ var searchLabelsContainer = $('#search-labels-container');
62
+ searchLabelsContainer.empty();
63
+
64
+ var searchLabels = searchFields.map(function() {
65
+ var filter = $(this).find('.search-field-filter').val();
66
+ var value = $(this).find('.search-field-value').val();
67
+ var columnName = $(this).find('.search-field-filter').attr('name').replace('Filter', '').toLowerCase().replace(/\s+/g, '_');
68
+
69
+ if (value !== '') {
70
+ if (filter === 'like') {
71
+ return columnName + encodeURIComponent('[' + filter + ']') + '=' + encodeURIComponent('%' + value + '%');
72
+ } else {
73
+ return columnName + encodeURIComponent('[' + filter + ']') + '=' + encodeURIComponent(value);
74
+ }
75
+ }
76
+ }).get().join('&');
77
+
78
+ if (account_id !== undefined && account_id !== '') {
79
+ searchLabels += '&' + encodeURIComponent('account_id[eq]') + '=' + encodeURIComponent(account_id);
80
+ }
81
+
82
+ var searchLabelString = searchLabels.length > 0 ? ('_q=1&' + searchLabels) : '';
83
+ if (searchLabelString == '') {
84
+ clearAdvanceSearch();
85
+ }
86
+ return searchLabelString;
87
+ };
88
+
89
+ function clearAdvanceSearch() {
90
+ // Clear all search fields
91
+ $('#search-fields-container').empty();
92
+
93
+ // Remove all search labels
94
+ $('#search-labels-container').empty();
95
+
96
+ // Reload the page with the original URL (no parameters)
97
+ window.location.href = window.location.pathname;
98
+
99
+ // Hide the modal
100
+ $('#advanceSearchModal').modal('hide');
101
+ }
102
+
103
+ function showAdvanceSearchModal() {
104
+ var searchLabelsContainer = $('#search-labels-container');
105
+ var searchFieldsContainer = $('#search-fields-container');
106
+ searchFieldsContainer.empty();
107
+
108
+ // Populate the search fields with the current filters
109
+ searchLabelsContainer.find('.label').each(function() {
110
+ var labelText = $(this).text();
111
+ var parts = labelText.split(' [');
112
+ var columnName = parts[0].trim();
113
+ var filterAndValue = parts[1].split('] ');
114
+ var filter = filterAndValue[0].trim();
115
+ var value = filterAndValue[1].trim();
116
+
117
+ var template = document.getElementById('search-field-template').content.cloneNode(true);
118
+ template.querySelector('.search-field-label').textContent = columnName.replace(/([A-Z])/g, ' $1').trim();
119
+ template.querySelector('.search-field-filter').name = columnName + 'Filter';
120
+ template.querySelector('.search-field-filter').value = filter;
121
+ template.querySelector('.search-field-value').name = columnName;
122
+ template.querySelector('.search-field-value').value = value;
123
+
124
+ searchFieldsContainer.append(template);
125
+ var dropdown = searchFieldsContainer.find('.search-field:last-child .search-field-filter');
126
+ dropdown.find('option').each(function() {
127
+ if ($(this).text().trim().toLowerCase() === filter.toLowerCase()) {
128
+ $(this).prop('selected', true);
129
+ }
130
+ });
131
+ });
132
+ }
@@ -146,7 +146,7 @@ module Kaui
146
146
  rescue StandardError
147
147
  nil
148
148
  end
149
- target_date >= start_date && target_date <= end_date
149
+ target_date.between?(start_date, end_date)
150
150
  end
151
151
 
152
152
  def load_bundle_name_for_timeline(bundle_key)
@@ -5,7 +5,7 @@ module Kaui
5
5
  class AccountsController < Kaui::EngineController
6
6
  def index
7
7
  @search_query = params[:q]
8
-
8
+ @advance_search_query = request.query_string
9
9
  if params[:fast] == '1' && !@search_query.blank?
10
10
  account = Kaui::Account.list_or_search(@search_query, -1, 1, options_for_klient).first
11
11
  if account.nil?
@@ -16,7 +16,7 @@ module Kaui
16
16
  end
17
17
  return
18
18
  end
19
-
19
+ @search_fields = Kaui::Account::ADVANCED_SEARCH_COLUMNS.map { |attr| [attr, attr.split('_').join(' ').capitalize] }
20
20
  @dropdown_default = default_columns(Kaui.account_search_columns.call[2], Kaui::Account::SENSIVITE_DATA_FIELDS)
21
21
 
22
22
  @ordering = params[:ordering] || (@search_query.blank? ? 'desc' : 'asc')
@@ -29,6 +29,7 @@ module Kaui
29
29
  def pagination
30
30
  cached_options_for_klient = options_for_klient
31
31
  searcher = lambda do |search_key, offset, limit|
32
+ search_key = remapping_addvanced_search_fields(search_key, Kaui::Account::ADVANCED_SEARCH_NAME_CHANGES)
32
33
  Kaui::Account.list_or_search(search_key, offset, limit, cached_options_for_klient)
33
34
  end
34
35
 
@@ -52,11 +53,18 @@ module Kaui
52
53
  start_date = params[:startDate]
53
54
  end_date = params[:endDate]
54
55
  all_fields_checked = params[:allFieldsChecked] == 'true'
56
+ query_string = params[:search]
55
57
 
56
58
  if all_fields_checked
57
59
  columns = KillBillClient::Model::AccountAttributes.instance_variable_get('@json_attributes')
60
+ csv_headers = columns.dup
61
+ Kaui::Account::REMAPPING_FIELDS.each do |k, v|
62
+ index = csv_headers.index(k)
63
+ csv_headers[index] = v if index
64
+ end
58
65
  else
59
66
  columns = params.require(:columnsString).split(',').map { |attr| attr.split.join('_').downcase }
67
+ csv_headers = columns.dup
60
68
  Kaui::Account::REMAPPING_FIELDS.each do |k, v|
61
69
  index = columns.index(v)
62
70
  columns[index] = k if index
@@ -73,10 +81,11 @@ module Kaui
73
81
  rescue StandardError
74
82
  nil
75
83
  end
76
- accounts = Kaui::Account.list_or_search(nil, 0, MAXIMUM_NUMBER_OF_RECORDS_DOWNLOAD, options_for_klient)
84
+ query_string = remapping_addvanced_search_fields(query_string, Kaui::Account::ADVANCED_SEARCH_NAME_CHANGES)
85
+ accounts = Kaui::Account.list_or_search(query_string, 0, MAXIMUM_NUMBER_OF_RECORDS_DOWNLOAD, options_for_klient)
77
86
 
78
87
  csv_string = CSV.generate(headers: true) do |csv|
79
- csv << columns
88
+ csv << csv_headers
80
89
  accounts.each do |account|
81
90
  change_date = Date.parse(account.reference_time)
82
91
  data = columns.map do |attr|
@@ -135,12 +144,10 @@ module Kaui
135
144
  fetch_account_emails = promise { Kaui::AccountEmail.find_all_sorted_by_account_id(@account.account_id, 'NONE', cached_options_for_klient) }
136
145
  fetch_payments = promise { @account.payments(cached_options_for_klient).map! { |payment| Kaui::Payment.build_from_raw_payment(payment) } }
137
146
  fetch_payment_methods = promise { Kaui::PaymentMethod.find_all_by_account_id(@account.account_id, false, cached_options_for_klient) }
138
-
139
- # is email notification plugin available
140
- is_email_notifications_plugin_available = Kenui::EmailNotificationService.email_notification_plugin_available?(cached_options_for_klient).first
147
+ is_email_notifications_plugin_available = Dependencies::Kenui::EmailNotification.email_notification_plugin_available?(cached_options_for_klient).first
141
148
  fetch_email_notification_configuration = if is_email_notifications_plugin_available
142
149
  promise do
143
- Kenui::EmailNotificationService.get_configuration_per_account(params.require(:account_id), cached_options_for_klient)
150
+ Dependencies::Kenui::EmailNotification.get_configuration_per_account(params.require(:account_id), cached_options_for_klient)
144
151
  end.then do |configuration|
145
152
  if configuration.first.is_a?(FalseClass)
146
153
  Rails.logger.warn(configuration[1])
@@ -175,7 +182,7 @@ module Kaui
175
182
  @available_tags = wait(fetch_available_tags)
176
183
  @children = wait(fetch_children)
177
184
  @account_parent = @account.parent_account_id.nil? ? nil : wait(fetch_parent)
178
- @email_notification_configuration = wait(fetch_email_notification_configuration) if is_email_notifications_plugin_available
185
+ @email_notification_configuration = is_email_notifications_plugin_available ? wait(fetch_email_notification_configuration) : []
179
186
 
180
187
  @last_transaction_by_payment_method_id = {}
181
188
  wait(fetch_payments).each do |payment|
@@ -345,15 +352,15 @@ module Kaui
345
352
  event_types = configuration[:event_types]
346
353
  cached_options_for_klient = options_for_klient
347
354
 
348
- is_success, message = email_notification_plugin_available?(cached_options_for_klient)
355
+ is_success, message = Dependencies::Kenui::EmailNotification.email_notification_plugin_available?(cached_options_for_klient)
349
356
 
350
357
  if is_success
351
- is_success, message = Kenui::EmailNotificationService.set_configuration_per_account(account_id,
352
- event_types,
353
- current_user.kb_username,
354
- params[:reason],
355
- params[:comment],
356
- cached_options_for_klient)
358
+ is_success, message = Dependencies::Kenui::EmailNotification.set_configuration_per_account(account_id,
359
+ event_types,
360
+ current_user.kb_username,
361
+ params[:reason],
362
+ params[:comment],
363
+ cached_options_for_klient)
357
364
  end
358
365
  if is_success
359
366
  flash[:notice] = message
@@ -365,7 +372,7 @@ module Kaui
365
372
 
366
373
  def events_to_consider
367
374
  json_response do
368
- { data: Kenui::EmailNotificationService.get_events_to_consider(options_for_klient) }
375
+ { data: Dependencies::Kenui::EmailNotification.get_events_to_consider(options_for_klient) }
369
376
  end
370
377
  end
371
378
 
@@ -373,16 +380,5 @@ module Kaui
373
380
  data = KillBillClient::Model::Export.find_by_account_id(params[:account_id], current_user.kb_username, options_for_klient)
374
381
  send_data data, filename: "account#{params[:account_id]}.txt", type: :txt
375
382
  end
376
-
377
- private
378
-
379
- def email_notification_plugin_available?(options_for_klient)
380
- error_message = 'Email notification plugin is not installed'
381
-
382
- is_available = Kenui::EmailNotificationService.email_notification_plugin_available?(options_for_klient).first
383
- [is_available, is_available ? nil : error_message]
384
- rescue StandardError
385
- [false, error_message]
386
- end
387
383
  end
388
384
  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)
@@ -14,8 +14,34 @@ module Kaui
14
14
  end
15
15
  # rubocop:enable Lint/UselessAssignment, Naming/AccessorMethodName
16
16
 
17
+ # Remove this when we support balance search alongside the other search
18
+ def handle_balance_search(query_string)
19
+ return nil if query_string.blank?
20
+ return query_string unless query_string.include?('balance')
21
+
22
+ CGI.unescape(query_string)
23
+ .split('&')
24
+ .grep(/_q|balance/)
25
+ .map { |param| param.split('=') }
26
+ .map { |key, value| "#{CGI.escape(key)}=#{value}" }
27
+ .join('&')
28
+ end
29
+
30
+ def remapping_addvanced_search_fields(search_string, advanced_search_name_changes)
31
+ return search_string if search_string.blank? || !(search_string.include? '_q')
32
+
33
+ advanced_search_name_changes.each do |new_name, old_name|
34
+ search_string = search_string.gsub(new_name, old_name)
35
+ end
36
+ search_string
37
+ end
38
+
17
39
  def paginate(searcher, data_extractor, formatter, table_default_columns = [])
18
40
  search_key = (params[:search] || {})[:value].presence
41
+ advance_search_query = params[:advance_search_query].presence
42
+
43
+ search_key = advance_search_query if advance_search_query
44
+ search_key = handle_balance_search(search_key) if search_key.present?
19
45
  offset = (params[:start] || 0).to_i
20
46
  limit = (params[:length] || 10).to_i
21
47
 
@@ -41,6 +67,7 @@ module Kaui
41
67
  # Until we support server-side sorting
42
68
  ordering = (params[:order] || {})[:'0'] || {}
43
69
  ordering_column = (ordering[:column] || 0).to_i
70
+ ordering_column = params[:colum_order][ordering_column].to_i if params[:colum_order].present?
44
71
  ordering_dir = ordering[:dir] || 'asc'
45
72
  unless search_key.nil?
46
73
  pages.sort! do |a, b|
@@ -5,10 +5,11 @@ module Kaui
5
5
  class InvoicesController < Kaui::EngineController
6
6
  def index
7
7
  @search_query = params[:account_id]
8
-
8
+ @advance_search_query = request.query_string
9
9
  @ordering = params[:ordering] || (@search_query.blank? ? 'desc' : 'asc')
10
10
  @offset = params[:offset] || 0
11
11
  @limit = params[:limit] || 50
12
+ @search_fields = Kaui::Invoice::ADVANCED_SEARCH_COLUMNS.map { |attr| [attr, attr.split('_').join(' ').capitalize] }
12
13
 
13
14
  @max_nb_records = @search_query.blank? ? Kaui::Invoice.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records : 0
14
15
  end
@@ -18,6 +19,7 @@ module Kaui
18
19
  start_date = params[:startDate]
19
20
  end_date = params[:endDate]
20
21
  all_fields_checked = params[:allFieldsChecked] == 'true'
22
+ query_string = handle_balance_search(params[:search])
21
23
  columns = if all_fields_checked
22
24
  KillBillClient::Model::InvoiceAttributes.instance_variable_get('@json_attributes') - Kaui::Invoice::TABLE_IGNORE_COLUMNS
23
25
  else
@@ -27,12 +29,12 @@ module Kaui
27
29
  kb_params = {}
28
30
  kb_params[:startDate] = Date.parse(start_date).strftime('%Y-%m-%d') if start_date
29
31
  kb_params[:endDate] = Date.parse(end_date).strftime('%Y-%m-%d') if end_date
30
- if account_id.present?
31
- account = Kaui::Account.find_by_id_or_key(account_id, false, false, options_for_klient)
32
- invoices = account.invoices(options_for_klient.merge(params: kb_params))
33
- else
34
- invoices = Kaui::Invoice.list_or_search(nil, 0, MAXIMUM_NUMBER_OF_RECORDS_DOWNLOAD, options_for_klient.merge(params: kb_params))
35
- end
32
+ query_string = remapping_addvanced_search_fields(query_string, Kaui::Invoice::ADVANCED_SEARCH_NAME_CHANGES)
33
+ invoices = if account_id.present? && query_string.blank?
34
+ Kaui::Account.paginated_invoices(account_id, nil, nil, 'NONE', options_for_klient).map! { |invoice| Kaui::Invoice.build_from_raw_invoice(invoice) }
35
+ else
36
+ Kaui::Invoice.list_or_search(query_string, 0, MAXIMUM_NUMBER_OF_RECORDS_DOWNLOAD, options_for_klient.merge(params: kb_params))
37
+ end
36
38
 
37
39
  csv_string = CSV.generate(headers: true) do |csv|
38
40
  csv << columns
@@ -54,6 +56,7 @@ module Kaui
54
56
  nil
55
57
  end
56
58
  if account.nil?
59
+ search_key = remapping_addvanced_search_fields(search_key, Kaui::Invoice::ADVANCED_SEARCH_NAME_CHANGES)
57
60
  Kaui::Invoice.list_or_search(search_key, offset, limit, cached_options_for_klient)
58
61
  else
59
62
  Kaui::Account.paginated_invoices(search_key, offset, limit, 'NONE', cached_options_for_klient).map! { |invoice| Kaui::Invoice.build_from_raw_invoice(invoice) }
@@ -70,13 +73,7 @@ module Kaui
70
73
  end
71
74
  else
72
75
  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]
76
+ Kaui.account_invoices_columns.call(invoice, view_context)[2][column]
80
77
  end
81
78
  end
82
79
 
@@ -6,10 +6,11 @@ module Kaui
6
6
  class PaymentsController < Kaui::EngineController
7
7
  def index
8
8
  @search_query = params[:q] || params[:account_id]
9
-
9
+ @advance_search_query = request.query_string
10
10
  @ordering = params[:ordering] || (@search_query.blank? ? 'desc' : 'asc')
11
11
  @offset = params[:offset] || 0
12
12
  @limit = params[:limit] || 50
13
+ @search_fields = Kaui::Payment::ADVANCED_SEARCH_COLUMNS.map { |attr| [attr, attr.split('_').join(' ').capitalize] }
13
14
 
14
15
  @max_nb_records = @search_query.blank? ? Kaui::Payment.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records : 0
15
16
  end
@@ -19,25 +20,34 @@ module Kaui
19
20
  start_date = params[:startDate]
20
21
  end_date = params[:endDate]
21
22
  all_fields_checked = params[:allFieldsChecked] == 'true'
23
+ query_string = params[:search]
24
+
22
25
  if all_fields_checked
23
26
  columns = KillBillClient::Model::PaymentAttributes.instance_variable_get('@json_attributes') - %w[transactions audit_logs]
27
+ csv_headers = columns.dup
28
+ Kaui::Payment::REMAPPING_FIELDS.each do |k, v|
29
+ index = csv_headers.index(k)
30
+ csv_headers[index] = v if index
31
+ end
24
32
  else
25
33
  columns = params.require(:columnsString).split(',').map { |attr| attr.split.join('_').downcase }
34
+ csv_headers = columns.dup
26
35
  Kaui::Payment::REMAPPING_FIELDS.each do |k, v|
27
36
  index = columns.index(v)
28
37
  columns[index] = k if index
29
38
  end
30
39
  end
31
-
40
+ query_string = remapping_addvanced_search_fields(query_string, Kaui::Payment::ADVANCED_SEARCH_NAME_CHANGES)
32
41
  kb_params = {}
33
42
  kb_params[:startDate] = Date.parse(start_date).strftime('%Y-%m-%d') if start_date
34
43
  kb_params[:endDate] = Date.parse(end_date).strftime('%Y-%m-%d') if end_date
35
- if account_id.present?
36
- account = Kaui::Account.find_by_id_or_key(account_id, false, false, options_for_klient)
37
- payments = account.payments(options_for_klient).map! { |payment| Kaui::Payment.build_from_raw_payment(payment) }
38
- else
39
- payments = Kaui::Payment.list_or_search(nil, 0, MAXIMUM_NUMBER_OF_RECORDS_DOWNLOAD, options_for_klient.merge(params: kb_params))
40
- end
44
+ account = account_id.present? ? Kaui::Account.find_by_id_or_key(account_id, false, false, options_for_klient) : nil
45
+
46
+ payments = if account_id.present? && query_string.blank?
47
+ Kaui::Account.paginated_payments(account_id, nil, nil, 'NONE', options_for_klient).map! { |payment| Kaui::Payment.build_from_raw_invoice(payment) }
48
+ else
49
+ Kaui::Payment.list_or_search(query_string, 0, MAXIMUM_NUMBER_OF_RECORDS_DOWNLOAD, options_for_klient.merge(params: kb_params))
50
+ end
41
51
 
42
52
  payments.each do |payment|
43
53
  created_date = nil
@@ -99,6 +109,7 @@ module Kaui
99
109
  end
100
110
 
101
111
  payments = if account.nil?
112
+ search_key = remapping_addvanced_search_fields(search_key, Kaui::Payment::ADVANCED_SEARCH_NAME_CHANGES)
102
113
  Kaui::Payment.list_or_search(search_key, offset, limit, options_for_klient)
103
114
  else
104
115
  account.payments(options_for_klient).map! { |payment| Kaui::Payment.build_from_raw_payment(payment) }
@@ -118,15 +129,7 @@ module Kaui
118
129
  end
119
130
 
120
131
  data_extractor = lambda do |payment, column|
121
- [
122
- payment.payment_number.to_i,
123
- payment.payment_date,
124
- payment.total_authed_amount_to_money,
125
- payment.paid_amount_to_money,
126
- payment.returned_amount_to_money,
127
- payment.transactions.empty? ? nil : payment.transactions[-1].status,
128
- payment.payment_external_key
129
- ][column]
132
+ Kaui.account_payments_columns.call(account, payment, view_context)[2][column]
130
133
  end
131
134
 
132
135
  formatter = lambda do |payment|
@@ -12,6 +12,8 @@ module Kaui
12
12
  # The sign-in flow eventually calls authenticate! from config/initializers/killbill_authenticatable.rb
13
13
 
14
14
  rescue_from(StandardError) do |exception|
15
+ Rails.logger.error(exception.message)
16
+ Rails.logger.error(exception.backtrace.join("\n")) if exception.backtrace
15
17
  @error = standardize_exception(exception)
16
18
  render 'kaui/errors/500', status: 500, layout: false
17
19
  end
@@ -5,8 +5,10 @@ module Kaui
5
5
  def standardize_exception(exception)
6
6
  if defined?(JRUBY_VERSION)
7
7
  case exception
8
- when ActiveRecord::JDBCError
8
+ when ActiveRecord::JDBCError, ActiveRecord::NoDatabaseError, ActiveRecord::DatabaseConnectionError, ActiveRecord::ConnectionNotEstablished
9
9
  return I18n.translate('errors.messages.unable_to_connect_database')
10
+ else
11
+ return exception.message
10
12
  end
11
13
  end
12
14
 
@@ -7,12 +7,15 @@ module Kaui
7
7
  SENSIVITE_DATA_FIELDS = %w[name email].freeze
8
8
  REMAPPING_FIELDS = {
9
9
  'is_payment_delegated_to_parent' => 'pay_via_parent',
10
- 'bill_cycle_day_local' => 'bcd',
11
10
  'account_balance' => 'balance',
11
+ 'bill_cycle_day_local' => 'bcd',
12
12
  'account_cba' => 'cba',
13
13
  'is_migrated' => 'migrated'
14
14
  }.freeze
15
15
 
16
+ ADVANCED_SEARCH_COLUMNS = %w[id external_key email name currency parent_account_id pay_via_parent payment_method_id time_zone country postal_code].freeze
17
+ ADVANCED_SEARCH_NAME_CHANGES = [%w[pay_via_parent is_payment_delegated_to_parent]].freeze
18
+
16
19
  def check_account_details_phone
17
20
  return true if phone =~ /\A(?:\+?\d{1,3}\s*-?)?\(?(?:\d{3})?\)?[- ]?\d{3}[- ]?\d{4}\z/i
18
21
 
@@ -3,6 +3,8 @@
3
3
  module Kaui
4
4
  class Invoice < KillBillClient::Model::Invoice
5
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
+ ADVANCED_SEARCH_COLUMNS = %w[id account_id invoice_date target_date currency status balance].freeze
7
+ ADVANCED_SEARCH_NAME_CHANGES = [%w[ac_id account_id]].freeze
6
8
 
7
9
  def self.build_from_raw_invoice(raw_invoice)
8
10
  result = Kaui::Invoice.new
@@ -14,6 +14,8 @@ module Kaui
14
14
  'credited_amount' => 'credit',
15
15
  'refunded_amount' => 'refund'
16
16
  }.freeze
17
+ ADVANCED_SEARCH_COLUMNS = %w[id account_id payment_method_id external_key].freeze
18
+ ADVANCED_SEARCH_NAME_CHANGES = [%w[ac_id account_id]].freeze
17
19
 
18
20
  def self.build_from_raw_payment(raw_payment)
19
21
  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