kaui 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/images/kaui/logo.svg +37 -0
- data/app/controllers/kaui/account_timelines_controller.rb +121 -0
- data/app/controllers/kaui/accounts_controller.rb +51 -14
- data/app/controllers/kaui/admin_tenants_controller.rb +19 -6
- data/app/controllers/kaui/audit_logs_controller.rb +40 -3
- data/app/controllers/kaui/bundles_controller.rb +5 -1
- data/app/controllers/kaui/charges_controller.rb +1 -1
- data/app/controllers/kaui/credits_controller.rb +1 -1
- data/app/controllers/kaui/custom_fields_controller.rb +3 -3
- data/app/controllers/kaui/engine_controller.rb +3 -28
- data/app/controllers/kaui/engine_controller_util.rb +8 -2
- data/app/controllers/kaui/home_controller.rb +5 -5
- data/app/controllers/kaui/invoice_items_controller.rb +1 -1
- data/app/controllers/kaui/invoices_controller.rb +59 -34
- data/app/controllers/kaui/payment_methods_controller.rb +3 -3
- data/app/controllers/kaui/payments_controller.rb +66 -10
- data/app/controllers/kaui/refunds_controller.rb +3 -2
- data/app/controllers/kaui/sessions_controller.rb +7 -0
- data/app/controllers/kaui/subscriptions_controller.rb +8 -8
- data/app/controllers/kaui/transactions_controller.rb +2 -2
- data/app/helpers/kaui/exception_helper.rb +25 -0
- data/app/helpers/kaui/subscription_helper.rb +4 -0
- data/app/models/kaui/account.rb +2 -0
- data/app/models/kaui/custom_field.rb +1 -1
- data/app/models/kaui/invoice.rb +2 -0
- data/app/models/kaui/payment_method.rb +4 -4
- data/app/views/kaui/account_timelines/_multi_functions_bar.html.erb +184 -0
- data/app/views/kaui/account_timelines/show.html.erb +2 -0
- data/app/views/kaui/accounts/_account_info.html.erb +7 -0
- data/app/views/kaui/accounts/_multi_functions_bar.html.erb +347 -0
- data/app/views/kaui/accounts/index.html.erb +46 -33
- data/app/views/kaui/audit_logs/_multi_functions_bar.html.erb +218 -0
- data/app/views/kaui/audit_logs/index.html.erb +1 -0
- data/app/views/kaui/bundles/index.html.erb +34 -0
- data/app/views/kaui/errors/500.html.erb +29 -0
- data/app/views/kaui/invoices/_multi_functions_bar.html.erb +340 -0
- data/app/views/kaui/invoices/index.html.erb +41 -19
- data/app/views/kaui/layouts/kaui_navbar.html.erb +1 -1
- data/app/views/kaui/payments/_multi_functions_bar.html.erb +344 -0
- data/app/views/kaui/payments/index.html.erb +64 -25
- data/config/locales/en.yml +3 -0
- data/config/routes.rb +7 -0
- data/lib/kaui/error_handler.rb +37 -0
- data/lib/kaui/version.rb +1 -1
- data/lib/kaui.rb +105 -29
- data/lib/tasks/kaui_tasks.rake +1 -0
- metadata +11 -3
- data/app/assets/images/kaui/logo.png +0 -0
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'csv'
|
3
4
|
module Kaui
|
4
5
|
class InvoicesController < Kaui::EngineController
|
5
6
|
def index
|
@@ -12,6 +13,37 @@ module Kaui
|
|
12
13
|
@max_nb_records = @search_query.blank? ? Kaui::Invoice.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records : 0
|
13
14
|
end
|
14
15
|
|
16
|
+
def download
|
17
|
+
account_id = params[:account_id]
|
18
|
+
start_date = params[:startDate]
|
19
|
+
end_date = params[:endDate]
|
20
|
+
all_fields_checked = params[:allFieldsChecked] == 'true'
|
21
|
+
columns = if all_fields_checked
|
22
|
+
KillBillClient::Model::InvoiceAttributes.instance_variable_get('@json_attributes') - Kaui::Invoice::TABLE_IGNORE_COLUMNS
|
23
|
+
else
|
24
|
+
params.require(:columnsString).split(',').map { |attr| attr.split.join('_').downcase }
|
25
|
+
end
|
26
|
+
|
27
|
+
kb_params = {}
|
28
|
+
kb_params[:startDate] = Date.parse(start_date).strftime('%Y-%m-%d') if start_date
|
29
|
+
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
|
36
|
+
|
37
|
+
csv_string = CSV.generate(headers: true) do |csv|
|
38
|
+
csv << columns
|
39
|
+
|
40
|
+
invoices.each do |invoice|
|
41
|
+
csv << columns.map { |attr| invoice&.send(attr.downcase) }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
send_data csv_string, filename: "invoices-#{Date.today}.csv", type: 'text/csv'
|
45
|
+
end
|
46
|
+
|
15
47
|
def pagination
|
16
48
|
cached_options_for_klient = options_for_klient
|
17
49
|
|
@@ -24,39 +56,32 @@ module Kaui
|
|
24
56
|
if account.nil?
|
25
57
|
Kaui::Invoice.list_or_search(search_key, offset, limit, cached_options_for_klient)
|
26
58
|
else
|
27
|
-
|
59
|
+
Kaui::Account.paginated_invoices(search_key, offset, limit, 'NONE', cached_options_for_klient).map! { |invoice| Kaui::Invoice.build_from_raw_invoice(invoice) }
|
28
60
|
end
|
29
61
|
end
|
30
62
|
|
31
63
|
account_id = (params[:search] || {})[:value]
|
32
|
-
if account_id.blank?
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
][column]
|
54
|
-
end
|
55
|
-
formatter = lambda do |invoice|
|
56
|
-
row = [view_context.link_to(invoice.invoice_number, view_context.url_for(controller: :invoices, action: :show, account_id: invoice.account_id, id: invoice.invoice_id))]
|
57
|
-
row += Kaui.account_invoices_columns.call(invoice, view_context)[1]
|
58
|
-
row
|
59
|
-
end
|
64
|
+
data_extractor = if account_id.blank?
|
65
|
+
lambda do |invoice, column|
|
66
|
+
[
|
67
|
+
invoice.invoice_number.to_i,
|
68
|
+
invoice.invoice_date
|
69
|
+
][column]
|
70
|
+
end
|
71
|
+
else
|
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]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
formatter = lambda do |invoice|
|
84
|
+
Kaui.account_invoices_columns.call(invoice, view_context)[1]
|
60
85
|
end
|
61
86
|
|
62
87
|
paginate searcher, data_extractor, formatter
|
@@ -67,7 +92,7 @@ module Kaui
|
|
67
92
|
# Go to the database once
|
68
93
|
cached_options_for_klient = options_for_klient
|
69
94
|
|
70
|
-
@invoice = Kaui::Invoice.find_by_id(params.require(:id), 'FULL', cached_options_for_klient)
|
95
|
+
@invoice = Kaui::Invoice.find_by_id(params.require(:id), false, 'FULL', cached_options_for_klient)
|
71
96
|
# This will put the TAX items at the bottom
|
72
97
|
precedence = {
|
73
98
|
'EXTERNAL_CHARGE' => 0,
|
@@ -132,7 +157,7 @@ module Kaui
|
|
132
157
|
|
133
158
|
def void_invoice
|
134
159
|
cached_options_for_klient = options_for_klient
|
135
|
-
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), 'NONE', cached_options_for_klient)
|
160
|
+
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), false, 'NONE', cached_options_for_klient)
|
136
161
|
begin
|
137
162
|
invoice.void(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
138
163
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id), notice: 'Invoice successfully voided'
|
@@ -143,12 +168,12 @@ module Kaui
|
|
143
168
|
end
|
144
169
|
|
145
170
|
def restful_show
|
146
|
-
invoice = Kaui::Invoice.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
171
|
+
invoice = Kaui::Invoice.find_by_id(params.require(:id), false, 'NONE', options_for_klient)
|
147
172
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id)
|
148
173
|
end
|
149
174
|
|
150
175
|
def restful_show_by_number
|
151
|
-
invoice = Kaui::Invoice.find_by_number(params.require(:number), 'NONE', options_for_klient)
|
176
|
+
invoice = Kaui::Invoice.find_by_number(params.require(:number), false, 'NONE', options_for_klient)
|
152
177
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id)
|
153
178
|
end
|
154
179
|
|
@@ -158,7 +183,7 @@ module Kaui
|
|
158
183
|
|
159
184
|
def commit_invoice
|
160
185
|
cached_options_for_klient = options_for_klient
|
161
|
-
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), 'NONE', cached_options_for_klient)
|
186
|
+
invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), false, 'NONE', cached_options_for_klient)
|
162
187
|
invoice.commit(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
163
188
|
redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id), notice: 'Invoice successfully committed'
|
164
189
|
end
|
@@ -74,7 +74,7 @@ module Kaui
|
|
74
74
|
def destroy
|
75
75
|
payment_method_id = params[:id]
|
76
76
|
|
77
|
-
payment_method = Kaui::PaymentMethod.find_by_id(payment_method_id, false, options_for_klient)
|
77
|
+
payment_method = Kaui::PaymentMethod.find_by_id(payment_method_id, false, false, [], 'NONE', options_for_klient)
|
78
78
|
begin
|
79
79
|
Kaui::PaymentMethod.destroy(payment_method_id, params[:set_auto_pay_off], false, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
80
80
|
redirect_to kaui_engine.account_path(payment_method.account_id), notice: "Payment method #{payment_method_id} successfully deleted"
|
@@ -89,7 +89,7 @@ module Kaui
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def restful_show
|
92
|
-
payment_method = Kaui::PaymentMethod.find_by_id(params.require(:id), false, options_for_klient)
|
92
|
+
payment_method = Kaui::PaymentMethod.find_by_id(params.require(:id), false, false, [], 'NONE', options_for_klient)
|
93
93
|
redirect_to kaui_engine.account_path(payment_method.account_id)
|
94
94
|
end
|
95
95
|
|
@@ -98,7 +98,7 @@ module Kaui
|
|
98
98
|
external_key = params.require(:external_key)
|
99
99
|
|
100
100
|
begin
|
101
|
-
payment_methods = Kaui::PaymentMethod.find_by_external_key(external_key, false, false, 'NONE', options_for_klient)
|
101
|
+
payment_methods = Kaui::PaymentMethod.find_by_external_key(external_key, false, false, [], 'NONE', options_for_klient)
|
102
102
|
rescue KillBillClient::API::NotFound
|
103
103
|
payment_methods = nil
|
104
104
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'csv'
|
4
|
+
|
3
5
|
module Kaui
|
4
6
|
class PaymentsController < Kaui::EngineController
|
5
7
|
def index
|
@@ -12,7 +14,68 @@ module Kaui
|
|
12
14
|
@max_nb_records = @search_query.blank? ? Kaui::Payment.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records : 0
|
13
15
|
end
|
14
16
|
|
17
|
+
def download
|
18
|
+
account_id = params[:account_id]
|
19
|
+
start_date = params[:startDate]
|
20
|
+
end_date = params[:endDate]
|
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
|
27
|
+
|
28
|
+
kb_params = {}
|
29
|
+
kb_params[:startDate] = Date.parse(start_date).strftime('%Y-%m-%d') if start_date
|
30
|
+
kb_params[:endDate] = Date.parse(end_date).strftime('%Y-%m-%d') if end_date
|
31
|
+
if account_id.present?
|
32
|
+
account = Kaui::Account.find_by_id_or_key(account_id, false, false, options_for_klient)
|
33
|
+
payments = account.payments(options_for_klient).map! { |payment| Kaui::Payment.build_from_raw_payment(payment) }
|
34
|
+
else
|
35
|
+
payments = Kaui::Payment.list_or_search(nil, 0, MAXIMUM_NUMBER_OF_RECORDS_DOWNLOAD, options_for_klient.merge(params: kb_params))
|
36
|
+
end
|
37
|
+
|
38
|
+
payments.each do |payment|
|
39
|
+
created_date = nil
|
40
|
+
payment.transactions.each do |transaction|
|
41
|
+
transaction_date = Date.parse(transaction.effective_date)
|
42
|
+
created_date ||= transaction_date if transaction_date < created_date
|
43
|
+
end
|
44
|
+
payment.payment_date = created_date
|
45
|
+
end
|
46
|
+
|
47
|
+
csv_string = CSV.generate(headers: true) do |csv|
|
48
|
+
csv << columns
|
49
|
+
|
50
|
+
payments.each do |payment|
|
51
|
+
next if start_date && end_date && (payment.payment_date < Date.parse(start_date) || payment.payment_date > Date.parse(end_date))
|
52
|
+
|
53
|
+
data = columns.map do |attr|
|
54
|
+
case attr
|
55
|
+
when 'payment_number'
|
56
|
+
payment.payment_number
|
57
|
+
when 'payment_date'
|
58
|
+
view_context.format_date(payment.payment_date, account&.time_zone)
|
59
|
+
when 'total_authed_amount_to_money'
|
60
|
+
view_context.humanized_money_with_symbol(payment.total_authed_amount_to_money)
|
61
|
+
when 'paid_amount_to_money'
|
62
|
+
view_context.humanized_money_with_symbol(payment.paid_amount_to_money)
|
63
|
+
when 'returned_amount_to_money'
|
64
|
+
view_context.humanized_money_with_symbol(payment.returned_amount_to_money)
|
65
|
+
when 'status'
|
66
|
+
payment.transactions.empty? ? nil : payment.transactions[-1].status
|
67
|
+
else
|
68
|
+
payment&.send(attr.downcase)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
csv << data
|
72
|
+
end
|
73
|
+
end
|
74
|
+
send_data csv_string, filename: "payments-#{Date.today}.csv", type: 'text/csv'
|
75
|
+
end
|
76
|
+
|
15
77
|
def pagination
|
78
|
+
account = nil
|
16
79
|
searcher = lambda do |search_key, offset, limit|
|
17
80
|
if Kaui::Payment::TRANSACTION_STATUSES.include?(search_key)
|
18
81
|
# Search is done by payment state on the server side, see http://docs.killbill.io/latest/userguide_payment.html#_payment_states
|
@@ -30,6 +93,7 @@ module Kaui
|
|
30
93
|
rescue StandardError
|
31
94
|
nil
|
32
95
|
end
|
96
|
+
|
33
97
|
payments = if account.nil?
|
34
98
|
Kaui::Payment.list_or_search(search_key, offset, limit, options_for_klient)
|
35
99
|
else
|
@@ -62,15 +126,7 @@ module Kaui
|
|
62
126
|
end
|
63
127
|
|
64
128
|
formatter = lambda do |payment|
|
65
|
-
[
|
66
|
-
view_context.link_to(payment.payment_number, view_context.url_for(controller: :payments, action: :show, account_id: payment.account_id, id: payment.payment_id)),
|
67
|
-
view_context.format_date(payment.payment_date, @account.time_zone),
|
68
|
-
view_context.humanized_money_with_symbol(payment.total_authed_amount_to_money),
|
69
|
-
view_context.humanized_money_with_symbol(payment.paid_amount_to_money),
|
70
|
-
view_context.humanized_money_with_symbol(payment.returned_amount_to_money),
|
71
|
-
payment.transactions.empty? ? nil : view_context.colored_transaction_status(payment.transactions[-1].status),
|
72
|
-
payment.payment_external_key
|
73
|
-
]
|
129
|
+
Kaui.account_payments_columns.call(account, payment, view_context)[1]
|
74
130
|
end
|
75
131
|
|
76
132
|
paginate searcher, data_extractor, formatter
|
@@ -78,7 +134,7 @@ module Kaui
|
|
78
134
|
|
79
135
|
def new
|
80
136
|
cached_options_for_klient = options_for_klient
|
81
|
-
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', cached_options_for_klient) }
|
137
|
+
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), false, 'NONE', cached_options_for_klient) }
|
82
138
|
fetch_payment_methods = promise { Kaui::PaymentMethod.find_all_by_account_id(params.require(:account_id), false, cached_options_for_klient) }
|
83
139
|
|
84
140
|
@invoice = wait(fetch_invoice)
|
@@ -5,8 +5,9 @@ module Kaui
|
|
5
5
|
def new
|
6
6
|
cached_options_for_klient = options_for_klient
|
7
7
|
|
8
|
-
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', cached_options_for_klient) }
|
8
|
+
fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), false, 'NONE', cached_options_for_klient) }
|
9
9
|
fetch_payment = promise { Kaui::InvoicePayment.find_by_id(params.require(:payment_id), false, false, cached_options_for_klient) }
|
10
|
+
|
10
11
|
fetch_bundles = promise { @account.bundles(cached_options_for_klient) }
|
11
12
|
|
12
13
|
@invoice = wait(fetch_invoice)
|
@@ -18,7 +19,7 @@ module Kaui
|
|
18
19
|
|
19
20
|
# rubocop:disable Lint/FloatComparison
|
20
21
|
def create
|
21
|
-
invoice = Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', options_for_klient)
|
22
|
+
invoice = Kaui::Invoice.find_by_id(params.require(:invoice_id), false, 'NONE', options_for_klient)
|
22
23
|
|
23
24
|
if params[:adjustment_type] == 'invoiceItemAdjustment'
|
24
25
|
items = []
|
@@ -3,12 +3,19 @@
|
|
3
3
|
module Kaui
|
4
4
|
# Subclassed to specify the correct layout
|
5
5
|
class SessionsController < Devise::SessionsController
|
6
|
+
include Kaui::ExceptionHelper
|
7
|
+
|
6
8
|
layout Kaui.config[:layout]
|
7
9
|
|
8
10
|
skip_before_action :check_for_redirect_to_tenant_screen, raise: false
|
9
11
|
|
10
12
|
# The sign-in flow eventually calls authenticate! from config/initializers/killbill_authenticatable.rb
|
11
13
|
|
14
|
+
rescue_from(StandardError) do |exception|
|
15
|
+
@error = standardize_exception(exception)
|
16
|
+
render 'kaui/errors/500', status: 500, layout: false
|
17
|
+
end
|
18
|
+
|
12
19
|
protected
|
13
20
|
|
14
21
|
# Override after_sign_in_path_for to not have to rely on the default 'root' config which we want to keep on home#index
|
@@ -72,7 +72,7 @@ module Kaui
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def edit
|
75
|
-
@subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
75
|
+
@subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
76
76
|
_, plans_details = lookup_bundle_and_plan_details(@subscription)
|
77
77
|
# Use a Set to deal with multiple pricelists
|
78
78
|
@plans = Set.new.merge(plans_details.map(&:plan))
|
@@ -86,7 +86,7 @@ module Kaui
|
|
86
86
|
|
87
87
|
wait_for_completion = params[:wait_for_completion] == '1'
|
88
88
|
|
89
|
-
subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
89
|
+
subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
90
90
|
|
91
91
|
input = { planName: plan_name }
|
92
92
|
|
@@ -124,13 +124,13 @@ module Kaui
|
|
124
124
|
else
|
125
125
|
nil
|
126
126
|
end
|
127
|
-
subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
127
|
+
subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
128
128
|
subscription.cancel(current_user.kb_username, params[:reason], params[:comment], requested_date, entitlement_policy, billing_policy, use_requested_date_for_billing, options_for_klient)
|
129
129
|
redirect_to kaui_engine.account_bundles_path(subscription.account_id), notice: 'Subscription was successfully cancelled'
|
130
130
|
end
|
131
131
|
|
132
132
|
def reinstate
|
133
|
-
subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
133
|
+
subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
134
134
|
|
135
135
|
subscription.uncancel(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
136
136
|
|
@@ -138,7 +138,7 @@ module Kaui
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def edit_bcd
|
141
|
-
@subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
141
|
+
@subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
142
142
|
end
|
143
143
|
|
144
144
|
def update_bcd
|
@@ -158,7 +158,7 @@ module Kaui
|
|
158
158
|
end
|
159
159
|
|
160
160
|
def restful_show
|
161
|
-
subscription = Kaui::Subscription.find_by_id(params.require(:id), options_for_klient)
|
161
|
+
subscription = Kaui::Subscription.find_by_id(params.require(:id), 'NONE', options_for_klient)
|
162
162
|
redirect_to kaui_engine.account_bundles_path(subscription.account_id)
|
163
163
|
end
|
164
164
|
|
@@ -181,7 +181,7 @@ module Kaui
|
|
181
181
|
external_key = params.require(:external_key)
|
182
182
|
|
183
183
|
begin
|
184
|
-
subscription = Kaui::Subscription.find_by_external_key(external_key, options_for_klient)
|
184
|
+
subscription = Kaui::Subscription.find_by_external_key(external_key, 'NONE', options_for_klient)
|
185
185
|
rescue KillBillClient::API::NotFound
|
186
186
|
subscription = nil
|
187
187
|
end
|
@@ -192,7 +192,7 @@ module Kaui
|
|
192
192
|
|
193
193
|
def update_tags
|
194
194
|
subscription_id = params.require(:id)
|
195
|
-
subscription = Kaui::Subscription.find_by_id(subscription_id, options_for_klient)
|
195
|
+
subscription = Kaui::Subscription.find_by_id(subscription_id, 'NONE', options_for_klient)
|
196
196
|
tags = []
|
197
197
|
params.each_key do |key|
|
198
198
|
next unless key.include? 'tag'
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Kaui
|
4
4
|
class TransactionsController < Kaui::EngineController
|
5
5
|
def restful_show
|
6
|
-
payment = Kaui::Payment.find_by_transaction_id(params.require(:id), false, true, options_for_klient)
|
6
|
+
payment = Kaui::Payment.find_by_transaction_id(params.require(:id), false, true, [], 'NONE', options_for_klient)
|
7
7
|
redirect_to account_payment_path(payment.account_id, payment.payment_id)
|
8
8
|
end
|
9
9
|
|
@@ -18,7 +18,7 @@ module Kaui
|
|
18
18
|
currency: params[:currency],
|
19
19
|
transaction_type: params[:transaction_type])
|
20
20
|
else
|
21
|
-
payment = Kaui::Payment.find_by_transaction_id(transaction_id, false, false, options_for_klient)
|
21
|
+
payment = Kaui::Payment.find_by_transaction_id(transaction_id, false, false, [], 'NONE', options_for_klient)
|
22
22
|
@transaction = Kaui::Transaction.build_from_raw_transaction(payment.transactions.find { |tx| tx.transaction_id == transaction_id })
|
23
23
|
end
|
24
24
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kaui
|
4
|
+
module ExceptionHelper
|
5
|
+
def standardize_exception(exception)
|
6
|
+
if defined?(JRUBY_VERSION)
|
7
|
+
case exception
|
8
|
+
when ActiveRecord::JDBCError
|
9
|
+
return I18n.translate('errors.messages.unable_to_connect_database')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
case exception
|
14
|
+
when ActiveRecord::DatabaseConnectionError
|
15
|
+
I18n.translate('errors.messages.unable_to_connect_database')
|
16
|
+
when Errno::ECONNREFUSED, Errno::EBADF
|
17
|
+
I18n.translate('errors.messages.unable_to_connect_killbill')
|
18
|
+
when ->(e) { e.class.name.start_with?('KillBillClient::API') }
|
19
|
+
I18n.translate('errors.messages.error_communicating_killbill')
|
20
|
+
else
|
21
|
+
nil
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/app/models/kaui/account.rb
CHANGED
@@ -4,6 +4,8 @@ module Kaui
|
|
4
4
|
class Account < KillBillClient::Model::Account
|
5
5
|
attr_accessor :phone, :bill_cycle_day_local
|
6
6
|
|
7
|
+
SENSIVITE_DATA_FIELDS = %w[name email].freeze
|
8
|
+
|
7
9
|
def check_account_details_phone
|
8
10
|
return true if phone =~ /\A(?:\+?\d{1,3}\s*-?)?\(?(?:\d{3})?\)?[- ]?\d{3}[- ]?\d{4}\z/i
|
9
11
|
|
data/app/models/kaui/invoice.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
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
|
6
|
+
|
5
7
|
def self.build_from_raw_invoice(raw_invoice)
|
6
8
|
result = Kaui::Invoice.new
|
7
9
|
KillBillClient::Model::InvoiceAttributes.instance_variable_get('@json_attributes').each do |attr|
|
@@ -11,12 +11,12 @@ module Kaui
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.find_safely_by_id(id, options = {})
|
14
|
-
Kaui::PaymentMethod.find_by_id(id, true, options)
|
14
|
+
Kaui::PaymentMethod.find_by_id(id, false, true, [], 'NONE', options)
|
15
15
|
rescue StandardError => e
|
16
16
|
# Maybe the plugin is not registered or the plugin threw an exception
|
17
17
|
Rails.logger.warn(e)
|
18
18
|
begin
|
19
|
-
Kaui::PaymentMethod.find_by_id(id, false, options)
|
19
|
+
Kaui::PaymentMethod.find_by_id(id, false, true, [], 'NONE', options)
|
20
20
|
rescue StandardError
|
21
21
|
nil
|
22
22
|
end
|
@@ -26,7 +26,7 @@ module Kaui
|
|
26
26
|
pms = Kaui::PaymentMethod.find_all_by_account_id(account_id, false, options)
|
27
27
|
|
28
28
|
pms.each_with_index do |pm, i|
|
29
|
-
pms[i] = Kaui::PaymentMethod.find_by_id(pm.payment_method_id, true, options)
|
29
|
+
pms[i] = Kaui::PaymentMethod.find_by_id(pm.payment_method_id, false, true, [], 'NONE', options)
|
30
30
|
rescue StandardError => e
|
31
31
|
# Maybe the plugin is not registered or the plugin threw an exception
|
32
32
|
Rails.logger.warn(e)
|
@@ -49,7 +49,7 @@ module Kaui
|
|
49
49
|
|
50
50
|
# The payment method may have been deleted
|
51
51
|
payment_methods_cache[payment.payment_method_id] ||= begin
|
52
|
-
Kaui::PaymentMethod.find_by_id(payment.payment_method_id, true, options)
|
52
|
+
Kaui::PaymentMethod.find_by_id(payment.payment_method_id, false, true, [], 'NONE', options)
|
53
53
|
rescue StandardError
|
54
54
|
nil
|
55
55
|
end
|