kaui 3.0.2 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/kaui/logo.svg +37 -0
  3. data/app/controllers/kaui/account_timelines_controller.rb +121 -0
  4. data/app/controllers/kaui/accounts_controller.rb +51 -14
  5. data/app/controllers/kaui/admin_tenants_controller.rb +19 -6
  6. data/app/controllers/kaui/audit_logs_controller.rb +40 -3
  7. data/app/controllers/kaui/bundles_controller.rb +5 -1
  8. data/app/controllers/kaui/charges_controller.rb +1 -1
  9. data/app/controllers/kaui/credits_controller.rb +1 -1
  10. data/app/controllers/kaui/custom_fields_controller.rb +3 -3
  11. data/app/controllers/kaui/engine_controller.rb +3 -28
  12. data/app/controllers/kaui/engine_controller_util.rb +8 -2
  13. data/app/controllers/kaui/home_controller.rb +5 -5
  14. data/app/controllers/kaui/invoice_items_controller.rb +1 -1
  15. data/app/controllers/kaui/invoices_controller.rb +59 -34
  16. data/app/controllers/kaui/payment_methods_controller.rb +3 -3
  17. data/app/controllers/kaui/payments_controller.rb +66 -10
  18. data/app/controllers/kaui/refunds_controller.rb +3 -2
  19. data/app/controllers/kaui/sessions_controller.rb +7 -0
  20. data/app/controllers/kaui/subscriptions_controller.rb +8 -8
  21. data/app/controllers/kaui/transactions_controller.rb +2 -2
  22. data/app/helpers/kaui/exception_helper.rb +25 -0
  23. data/app/helpers/kaui/subscription_helper.rb +4 -0
  24. data/app/models/kaui/account.rb +2 -0
  25. data/app/models/kaui/custom_field.rb +1 -1
  26. data/app/models/kaui/invoice.rb +2 -0
  27. data/app/models/kaui/payment_method.rb +4 -4
  28. data/app/views/kaui/account_timelines/_multi_functions_bar.html.erb +184 -0
  29. data/app/views/kaui/account_timelines/show.html.erb +2 -0
  30. data/app/views/kaui/accounts/_account_info.html.erb +7 -0
  31. data/app/views/kaui/accounts/_multi_functions_bar.html.erb +347 -0
  32. data/app/views/kaui/accounts/index.html.erb +46 -33
  33. data/app/views/kaui/audit_logs/_multi_functions_bar.html.erb +218 -0
  34. data/app/views/kaui/audit_logs/index.html.erb +1 -0
  35. data/app/views/kaui/bundles/index.html.erb +34 -0
  36. data/app/views/kaui/errors/500.html.erb +29 -0
  37. data/app/views/kaui/invoices/_multi_functions_bar.html.erb +340 -0
  38. data/app/views/kaui/invoices/index.html.erb +41 -19
  39. data/app/views/kaui/layouts/kaui_navbar.html.erb +1 -1
  40. data/app/views/kaui/payments/_multi_functions_bar.html.erb +344 -0
  41. data/app/views/kaui/payments/index.html.erb +64 -25
  42. data/config/locales/en.yml +3 -0
  43. data/config/routes.rb +7 -0
  44. data/lib/kaui/error_handler.rb +37 -0
  45. data/lib/kaui/version.rb +1 -1
  46. data/lib/kaui.rb +105 -29
  47. data/lib/tasks/kaui_tasks.rake +1 -0
  48. metadata +11 -3
  49. data/app/assets/images/kaui/logo.png +0 -0
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,117 @@ 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,
65
+ original_fields = KillBillClient::Model::AccountAttributes.instance_variable_get('@json_attributes')
66
+ # Add additional fields if needed
67
+ fields = original_fields.dup
68
+
69
+ headers = fields.map { |attr| attr.split('_').join(' ').capitalize }
70
+ values = fields.map do |attr|
71
+ case attr
72
+ 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))
74
+ 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))
76
+ when 'account_balance'
67
77
  account.nil? || view_context.nil? ? nil : view_context.humanized_money_with_symbol(account.balance_to_money)
68
- ]
69
- ]
78
+ else
79
+ account&.send(attr.downcase)
80
+ end
81
+ end
82
+ [headers, values, fields]
70
83
  end
71
84
 
72
85
  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,
86
+ fields = %w[invoice_number invoice_date status]
87
+ headers = fields.map { |attr| attr.split('_').join(' ').capitalize }
88
+ values = fields.map do |attr|
89
+ case attr
90
+ when 'status'
91
+ default_label = 'label-info'
92
+ default_label = 'label-default' if invoice&.status == 'DRAFT'
93
+ default_label = 'label-success' if invoice&.status == 'COMMITTED'
94
+ default_label = 'label-danger' if invoice&.status == 'VOID'
81
95
  invoice.nil? || view_context.nil? ? nil : view_context.content_tag(:span, invoice.status, class: ['label', default_label])
82
- ]
83
- ]
96
+ else
97
+ invoice&.send(attr.downcase)
98
+ end
99
+ end
100
+ [headers, values]
84
101
  end
85
102
 
86
103
  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
- ]
104
+ fields = KillBillClient::Model::InvoiceAttributes.instance_variable_get('@json_attributes')
105
+ # Change the order if needed
106
+ fields -= Kaui::Invoice::TABLE_IGNORE_COLUMNS
107
+ fields.delete('invoice_id')
108
+ fields.unshift('invoice_id')
109
+
110
+ headers = fields.map { |attr| attr.split('_').join(' ').capitalize }
111
+ # Add additional headers if needed
112
+
113
+ values = fields.map do |attr|
114
+ next nil if invoice.nil? || view_context.nil?
115
+
116
+ case attr
117
+ when 'account_id'
118
+ view_context.link_to(invoice.account_id, view_context.url_for(controller: :accounts, action: :show, account_id: invoice.account_id))
119
+ when 'amount'
120
+ view_context.humanized_money_with_symbol(invoice.amount_to_money)
121
+ when 'balance'
122
+ view_context.humanized_money_with_symbol(invoice.balance_to_money)
123
+ 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))
125
+ when 'status'
126
+ default_label = 'label-info'
127
+ default_label = 'label-default' if invoice&.status == 'DRAFT'
128
+ default_label = 'label-success' if invoice&.status == 'COMMITTED'
129
+ default_label = 'label-danger' if invoice&.status == 'VOID'
130
+ view_context.content_tag(:span, invoice.status, class: ['label', default_label])
131
+ else
132
+ invoice&.send(attr.downcase)
133
+ end
134
+ end
135
+ # Add additional values if needed
136
+ [headers, values]
137
+ end
138
+
139
+ self.account_payments_columns = lambda do |account = nil, payment = nil, view_context = nil|
140
+ fields = KillBillClient::Model::PaymentAttributes.instance_variable_get('@json_attributes')
141
+ # Change the order if needed
142
+ fields = %w[payment_date total_authed_amount_to_money paid_amount_to_money returned_amount_to_money] + fields
143
+ fields -= %w[payment_number transactions audit_logs]
144
+ fields.unshift('status')
145
+ fields.unshift('payment_number')
146
+
147
+ headers = fields.map { |attr| attr.split('_').join(' ').capitalize }
148
+ return [headers, []] if payment.nil?
149
+
150
+ values = fields.map do |attr|
151
+ case attr
152
+ when 'payment_number'
153
+ 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
+ when 'payment_date'
155
+ 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
+ when 'status'
163
+ payment.transactions.empty? ? nil : view_context.colored_transaction_status(payment.transactions[-1].status)
164
+ else
165
+ payment&.send(attr.downcase)
166
+ end
167
+ end
168
+
169
+ # Add additional values if needed
170
+ [headers, values]
171
+ end
172
+
173
+ self.account_audit_logs_columns = lambda do
174
+ headers = %w[CreatedDate ObjectID ObjectType ChangeType Username Reason Comment UserToken]
175
+ [headers, []]
100
176
  end
101
177
 
102
178
  self.refund_invoice_description = lambda { |index, ii, bundle_result|
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # desc "Explaining what the task does"
3
4
  # task :kaui do
4
5
  # # Task goes here
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.2
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kill Bill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-30 00:00:00.000000000 Z
11
+ date: 2024-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -329,7 +329,7 @@ files:
329
329
  - Rakefile
330
330
  - app/assets/config/kaui_manifest.js
331
331
  - app/assets/images/kaui/duck.png
332
- - app/assets/images/kaui/logo.png
332
+ - app/assets/images/kaui/logo.svg
333
333
  - app/assets/images/kaui/search.png
334
334
  - app/assets/images/kaui/search_white.png
335
335
  - app/assets/javascripts/application.js
@@ -388,6 +388,7 @@ files:
388
388
  - app/helpers/kaui/account_helper.rb
389
389
  - app/helpers/kaui/application_helper.rb
390
390
  - app/helpers/kaui/date_helper.rb
391
+ - app/helpers/kaui/exception_helper.rb
391
392
  - app/helpers/kaui/home_helper.rb
392
393
  - app/helpers/kaui/locale_helper.rb
393
394
  - app/helpers/kaui/locale_helper.yml
@@ -446,12 +447,14 @@ files:
446
447
  - app/views/kaui/account_tags/_form_bar.html.erb
447
448
  - app/views/kaui/account_tags/edit.html.erb
448
449
  - app/views/kaui/account_tags/index.html.erb
450
+ - app/views/kaui/account_timelines/_multi_functions_bar.html.erb
449
451
  - app/views/kaui/account_timelines/show.html.erb
450
452
  - app/views/kaui/accounts/_account_info.html.erb
451
453
  - app/views/kaui/accounts/_billing_info.html.erb
452
454
  - app/views/kaui/accounts/_close_account_modal.html.erb
453
455
  - app/views/kaui/accounts/_form.html.erb
454
456
  - app/views/kaui/accounts/_link_parent_modal.html.erb
457
+ - app/views/kaui/accounts/_multi_functions_bar.html.erb
455
458
  - app/views/kaui/accounts/_parent.html.erb
456
459
  - app/views/kaui/accounts/_payment_methods.html.erb
457
460
  - app/views/kaui/accounts/_personal_info.html.erb
@@ -485,6 +488,7 @@ files:
485
488
  - app/views/kaui/admin_tenants/new_overdue_config.html.erb
486
489
  - app/views/kaui/admin_tenants/new_plan_currency.html.erb
487
490
  - app/views/kaui/admin_tenants/show.html.erb
491
+ - app/views/kaui/audit_logs/_multi_functions_bar.html.erb
488
492
  - app/views/kaui/audit_logs/_show_history_modal.html.erb
489
493
  - app/views/kaui/audit_logs/index.html.erb
490
494
  - app/views/kaui/bundle_tags/_form.html.erb
@@ -504,6 +508,7 @@ files:
504
508
  - app/views/kaui/custom_fields/_list_bar.html.erb
505
509
  - app/views/kaui/custom_fields/index.html.erb
506
510
  - app/views/kaui/custom_fields/new.html.erb
511
+ - app/views/kaui/errors/500.html.erb
507
512
  - app/views/kaui/home/_advanced_search_modal.html.erb
508
513
  - app/views/kaui/home/index.html.erb
509
514
  - app/views/kaui/invoice_items/_edit_form.html.erb
@@ -512,6 +517,7 @@ files:
512
517
  - app/views/kaui/invoice_tags/_form_bar.html.erb
513
518
  - app/views/kaui/invoice_tags/edit.html.erb
514
519
  - app/views/kaui/invoices/_invoice_table.html.erb
520
+ - app/views/kaui/invoices/_multi_functions_bar.html.erb
515
521
  - app/views/kaui/invoices/index.html.erb
516
522
  - app/views/kaui/invoices/show.html.erb
517
523
  - app/views/kaui/layouts/kaui_account_navbar.html.erb
@@ -527,6 +533,7 @@ files:
527
533
  - app/views/kaui/payment_methods/_plugin_properties.html.erb
528
534
  - app/views/kaui/payment_methods/new.html.erb
529
535
  - app/views/kaui/payments/_form.html.erb
536
+ - app/views/kaui/payments/_multi_functions_bar.html.erb
530
537
  - app/views/kaui/payments/_payment_table.html.erb
531
538
  - app/views/kaui/payments/index.html.erb
532
539
  - app/views/kaui/payments/new.html.erb
@@ -578,6 +585,7 @@ files:
578
585
  - lib/generators/kaui/install/templates/config/initializers/kaui.rb
579
586
  - lib/kaui.rb
580
587
  - lib/kaui/engine.rb
588
+ - lib/kaui/error_handler.rb
581
589
  - lib/kaui/installer/installer.rb
582
590
  - lib/kaui/version.rb
583
591
  - lib/tasks/kaui_tasks.rake
Binary file