kaui 3.0.3 → 3.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/kaui/account_timelines_controller.rb +117 -0
  3. data/app/controllers/kaui/accounts_controller.rb +50 -7
  4. data/app/controllers/kaui/audit_logs_controller.rb +37 -0
  5. data/app/controllers/kaui/bundles_controller.rb +5 -1
  6. data/app/controllers/kaui/engine_controller.rb +3 -28
  7. data/app/controllers/kaui/engine_controller_util.rb +8 -2
  8. data/app/controllers/kaui/invoices_controller.rb +54 -29
  9. data/app/controllers/kaui/payments_controller.rb +69 -9
  10. data/app/controllers/kaui/sessions_controller.rb +7 -0
  11. data/app/helpers/kaui/exception_helper.rb +25 -0
  12. data/app/helpers/kaui/subscription_helper.rb +5 -1
  13. data/app/models/kaui/account.rb +9 -0
  14. data/app/models/kaui/invoice.rb +2 -0
  15. data/app/models/kaui/payment.rb +7 -0
  16. data/app/views/kaui/account_timelines/_multi_functions_bar.html.erb +155 -0
  17. data/app/views/kaui/account_timelines/show.html.erb +2 -0
  18. data/app/views/kaui/accounts/_account_info.html.erb +7 -0
  19. data/app/views/kaui/accounts/_multi_functions_bar.html.erb +329 -0
  20. data/app/views/kaui/accounts/index.html.erb +32 -18
  21. data/app/views/kaui/audit_logs/_multi_functions_bar.html.erb +189 -0
  22. data/app/views/kaui/audit_logs/index.html.erb +8 -0
  23. data/app/views/kaui/bundles/index.html.erb +34 -0
  24. data/app/views/kaui/errors/500.html.erb +29 -0
  25. data/app/views/kaui/invoices/_multi_functions_bar.html.erb +322 -0
  26. data/app/views/kaui/invoices/index.html.erb +49 -24
  27. data/app/views/kaui/payments/_multi_functions_bar.html.erb +323 -0
  28. data/app/views/kaui/payments/index.html.erb +73 -30
  29. data/config/locales/en.yml +3 -0
  30. data/config/routes.rb +7 -0
  31. data/lib/kaui/error_handler.rb +37 -0
  32. data/lib/kaui/version.rb +1 -1
  33. data/lib/kaui.rb +117 -30
  34. metadata +13 -19
data/lib/kaui.rb CHANGED
@@ -20,6 +20,8 @@ module Kaui
20
20
  mattr_accessor :account_search_columns
21
21
  mattr_accessor :invoice_search_columns
22
22
  mattr_accessor :account_invoices_columns
23
+ mattr_accessor :account_payments_columns
24
+ mattr_accessor :account_audit_logs_columns
23
25
  mattr_accessor :refund_invoice_description
24
26
 
25
27
  mattr_accessor :customer_invoice_link
@@ -60,43 +62,128 @@ module Kaui
60
62
  self.creditcard_plugin_name = -> { '__EXTERNAL_PAYMENT__' }
61
63
 
62
64
  self.account_search_columns = lambda do |account = nil, view_context = nil|
63
- [
64
- ['External key', 'Balance'],
65
- [
66
- account&.external_key,
67
- account.nil? || view_context.nil? ? nil : view_context.humanized_money_with_symbol(account.balance_to_money)
68
- ]
69
- ]
65
+ original_fields = KillBillClient::Model::AccountAttributes.instance_variable_get('@json_attributes')
66
+ # Add additional fields if needed
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 }
74
+
75
+ values = fields.map do |attr|
76
+ next if account.nil? || view_context.nil?
77
+
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>"
81
+ when 'account_id'
82
+ view_context.link_to(account.account_id, view_context.url_for(action: :show, account_id: account.account_id))
83
+ when '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))
85
+ when 'account_balance'
86
+ view_context.humanized_money_with_symbol(account.balance_to_money)
87
+ else
88
+ account&.send(attr.downcase)
89
+ end
90
+ end
91
+
92
+ [headers, values, fields]
70
93
  end
71
94
 
72
95
  self.invoice_search_columns = lambda do |invoice = nil, view_context = nil, _cached_options_for_klient = nil|
73
- default_label = 'label-info'
74
- default_label = 'label-default' if invoice&.status == 'DRAFT'
75
- default_label = 'label-success' if invoice&.status == 'COMMITTED'
76
- default_label = 'label-danger' if invoice&.status == 'VOID'
77
- [
78
- %w[Date Status],
79
- [
80
- invoice&.invoice_date,
96
+ fields = %w[invoice_number invoice_date status]
97
+ headers = fields.map { |attr| attr.split('_').join(' ').capitalize }
98
+ values = fields.map do |attr|
99
+ case attr
100
+ when 'status'
101
+ default_label = 'label-info'
102
+ default_label = 'label-default' if invoice&.status == 'DRAFT'
103
+ default_label = 'label-success' if invoice&.status == 'COMMITTED'
104
+ default_label = 'label-danger' if invoice&.status == 'VOID'
81
105
  invoice.nil? || view_context.nil? ? nil : view_context.content_tag(:span, invoice.status, class: ['label', default_label])
82
- ]
83
- ]
106
+ else
107
+ invoice&.send(attr.downcase)
108
+ end
109
+ end
110
+ [headers, values]
84
111
  end
85
112
 
86
113
  self.account_invoices_columns = lambda do |invoice = nil, view_context = nil|
87
- default_label = 'label-info'
88
- default_label = 'label-default' if invoice&.status == 'DRAFT'
89
- default_label = 'label-success' if invoice&.status == 'COMMITTED'
90
- default_label = 'label-danger' if invoice&.status == 'VOID'
91
- [
92
- %w[Date Amount Balance Status],
93
- [
94
- invoice&.invoice_date,
95
- invoice.nil? || view_context.nil? ? nil : view_context.humanized_money_with_symbol(invoice.amount_to_money),
96
- invoice.nil? || view_context.nil? ? nil : view_context.humanized_money_with_symbol(invoice.balance_to_money),
97
- invoice.nil? || view_context.nil? ? nil : view_context.content_tag(:span, invoice.status, class: ['label', default_label])
98
- ]
99
- ]
114
+ fields = KillBillClient::Model::InvoiceAttributes.instance_variable_get('@json_attributes')
115
+ # Change the order if needed
116
+ fields -= Kaui::Invoice::TABLE_IGNORE_COLUMNS
117
+ fields.delete('invoice_id')
118
+ fields.unshift('invoice_id')
119
+
120
+ headers = fields.map { |attr| attr.split('_').join(' ').capitalize }
121
+ # Add additional headers if needed
122
+
123
+ values = fields.map do |attr|
124
+ next nil if invoice.nil? || view_context.nil?
125
+
126
+ case attr
127
+ when 'account_id'
128
+ view_context.link_to(invoice.account_id, view_context.url_for(controller: :accounts, action: :show, account_id: invoice.account_id))
129
+ when 'amount'
130
+ view_context.humanized_money_with_symbol(invoice.amount_to_money)
131
+ when 'balance'
132
+ view_context.humanized_money_with_symbol(invoice.balance_to_money)
133
+ when '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))
135
+ when 'status'
136
+ default_label = 'label-info'
137
+ default_label = 'label-default' if invoice&.status == 'DRAFT'
138
+ default_label = 'label-success' if invoice&.status == 'COMMITTED'
139
+ default_label = 'label-danger' if invoice&.status == 'VOID'
140
+ view_context.content_tag(:span, invoice.status, class: ['label', default_label])
141
+ else
142
+ invoice&.send(attr.downcase)
143
+ end
144
+ end
145
+ # Add additional values if needed
146
+ [headers, values]
147
+ end
148
+
149
+ self.account_payments_columns = lambda do |account = nil, payment = nil, view_context = nil|
150
+ fields = KillBillClient::Model::PaymentAttributes.instance_variable_get('@json_attributes')
151
+ # Change the order if needed
152
+ fields = %w[payment_date] + fields
153
+ fields -= %w[payment_number transactions audit_logs]
154
+ fields.unshift('status')
155
+ fields.unshift('payment_number')
156
+
157
+ headers = fields.dup
158
+ Kaui::Payment::REMAPPING_FIELDS.each do |k, v|
159
+ headers[fields.index(k)] = v
160
+ end
161
+ headers.map! { |attr| attr.split('_').join(' ').capitalize }
162
+
163
+ return [headers, []] if payment.nil?
164
+
165
+ values = fields.map do |attr|
166
+ case attr
167
+ when 'auth_amount', 'captured_amount', 'purchased_amount', 'refunded_amount', 'credited_amount'
168
+ view_context.humanized_money_with_symbol(payment&.send(attr.downcase))
169
+ when 'payment_number'
170
+ view_context.link_to(payment.payment_number, view_context.url_for(controller: :payments, action: :show, account_id: payment.account_id, id: payment.payment_id))
171
+ when 'payment_date'
172
+ view_context.format_date(payment.payment_date, account&.time_zone)
173
+ when 'status'
174
+ payment.transactions.empty? ? nil : view_context.colored_transaction_status(payment.transactions[-1].status)
175
+ else
176
+ payment&.send(attr.downcase)
177
+ end
178
+ end
179
+
180
+ # Add additional values if needed
181
+ [headers, values]
182
+ end
183
+
184
+ self.account_audit_logs_columns = lambda do
185
+ headers = %w[CreatedDate ObjectID ObjectType ChangeType Username Reason Comment UserToken]
186
+ [headers, []]
100
187
  end
101
188
 
102
189
  self.refund_invoice_description = lambda { |index, ii, bundle_result|
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.3
4
+ version: 3.0.5
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-05-17 00:00:00.000000000 Z
11
+ date: 2025-01-22 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
@@ -388,6 +374,7 @@ files:
388
374
  - app/helpers/kaui/account_helper.rb
389
375
  - app/helpers/kaui/application_helper.rb
390
376
  - app/helpers/kaui/date_helper.rb
377
+ - app/helpers/kaui/exception_helper.rb
391
378
  - app/helpers/kaui/home_helper.rb
392
379
  - app/helpers/kaui/locale_helper.rb
393
380
  - app/helpers/kaui/locale_helper.yml
@@ -446,12 +433,14 @@ files:
446
433
  - app/views/kaui/account_tags/_form_bar.html.erb
447
434
  - app/views/kaui/account_tags/edit.html.erb
448
435
  - app/views/kaui/account_tags/index.html.erb
436
+ - app/views/kaui/account_timelines/_multi_functions_bar.html.erb
449
437
  - app/views/kaui/account_timelines/show.html.erb
450
438
  - app/views/kaui/accounts/_account_info.html.erb
451
439
  - app/views/kaui/accounts/_billing_info.html.erb
452
440
  - app/views/kaui/accounts/_close_account_modal.html.erb
453
441
  - app/views/kaui/accounts/_form.html.erb
454
442
  - app/views/kaui/accounts/_link_parent_modal.html.erb
443
+ - app/views/kaui/accounts/_multi_functions_bar.html.erb
455
444
  - app/views/kaui/accounts/_parent.html.erb
456
445
  - app/views/kaui/accounts/_payment_methods.html.erb
457
446
  - app/views/kaui/accounts/_personal_info.html.erb
@@ -485,6 +474,7 @@ files:
485
474
  - app/views/kaui/admin_tenants/new_overdue_config.html.erb
486
475
  - app/views/kaui/admin_tenants/new_plan_currency.html.erb
487
476
  - app/views/kaui/admin_tenants/show.html.erb
477
+ - app/views/kaui/audit_logs/_multi_functions_bar.html.erb
488
478
  - app/views/kaui/audit_logs/_show_history_modal.html.erb
489
479
  - app/views/kaui/audit_logs/index.html.erb
490
480
  - app/views/kaui/bundle_tags/_form.html.erb
@@ -504,6 +494,7 @@ files:
504
494
  - app/views/kaui/custom_fields/_list_bar.html.erb
505
495
  - app/views/kaui/custom_fields/index.html.erb
506
496
  - app/views/kaui/custom_fields/new.html.erb
497
+ - app/views/kaui/errors/500.html.erb
507
498
  - app/views/kaui/home/_advanced_search_modal.html.erb
508
499
  - app/views/kaui/home/index.html.erb
509
500
  - app/views/kaui/invoice_items/_edit_form.html.erb
@@ -512,6 +503,7 @@ files:
512
503
  - app/views/kaui/invoice_tags/_form_bar.html.erb
513
504
  - app/views/kaui/invoice_tags/edit.html.erb
514
505
  - app/views/kaui/invoices/_invoice_table.html.erb
506
+ - app/views/kaui/invoices/_multi_functions_bar.html.erb
515
507
  - app/views/kaui/invoices/index.html.erb
516
508
  - app/views/kaui/invoices/show.html.erb
517
509
  - app/views/kaui/layouts/kaui_account_navbar.html.erb
@@ -527,6 +519,7 @@ files:
527
519
  - app/views/kaui/payment_methods/_plugin_properties.html.erb
528
520
  - app/views/kaui/payment_methods/new.html.erb
529
521
  - app/views/kaui/payments/_form.html.erb
522
+ - app/views/kaui/payments/_multi_functions_bar.html.erb
530
523
  - app/views/kaui/payments/_payment_table.html.erb
531
524
  - app/views/kaui/payments/index.html.erb
532
525
  - app/views/kaui/payments/new.html.erb
@@ -578,6 +571,7 @@ files:
578
571
  - lib/generators/kaui/install/templates/config/initializers/kaui.rb
579
572
  - lib/kaui.rb
580
573
  - lib/kaui/engine.rb
574
+ - lib/kaui/error_handler.rb
581
575
  - lib/kaui/installer/installer.rb
582
576
  - lib/kaui/version.rb
583
577
  - lib/tasks/kaui_tasks.rake
@@ -586,7 +580,7 @@ licenses:
586
580
  - Apache License (2.0)
587
581
  metadata:
588
582
  rubygems_mfa_required: 'true'
589
- post_install_message:
583
+ post_install_message:
590
584
  rdoc_options: []
591
585
  require_paths:
592
586
  - lib
@@ -602,7 +596,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
602
596
  version: '0'
603
597
  requirements: []
604
598
  rubygems_version: 3.4.10
605
- signing_key:
599
+ signing_key:
606
600
  specification_version: 4
607
601
  summary: Killbill Admin UI mountable engine
608
602
  test_files: []