kaui 2.0.4 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +8 -23
- data/Rakefile +4 -2
- data/app/assets/config/kaui_manifest.js +45 -0
- data/app/assets/javascripts/jquery.spin.js +76 -0
- data/app/assets/javascripts/kaui/kaui.js +76 -0
- data/app/assets/javascripts/kaui_application.js +25 -0
- data/app/assets/javascripts/spin.js +76 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.scss +240 -0
- data/app/assets/stylesheets/kaui/{account.less → account.scss} +13 -1
- data/app/assets/stylesheets/kaui/{audit.less → audit.scss} +5 -1
- data/app/assets/stylesheets/kaui/{common.less → common.scss} +19 -17
- data/app/assets/stylesheets/kaui/{datatable.less → datatable.scss} +6 -3
- data/app/assets/stylesheets/kaui/{header.less → header.scss} +16 -12
- data/app/assets/stylesheets/kaui/{home.less → home.scss} +7 -4
- data/app/assets/stylesheets/kaui/{invoice.less → invoice.scss} +7 -3
- data/app/assets/stylesheets/kaui/kaui.scss +265 -0
- data/app/assets/stylesheets/kaui/kaui_bootstrap.scss +3 -0
- data/app/assets/stylesheets/kaui/{overdue.less → overdue.scss} +3 -1
- data/app/assets/stylesheets/kaui/{payment.less → payment.scss} +3 -0
- data/app/assets/stylesheets/kaui/{subscription.less → subscription.scss} +4 -1
- data/app/assets/stylesheets/kaui/{tags.less → tags.scss} +9 -5
- data/app/assets/stylesheets/kaui/timeline.scss +7 -0
- data/app/assets/stylesheets/kaui/tooltip.scss +15 -0
- data/app/controllers/kaui/account_children_controller.rb +25 -28
- data/app/controllers/kaui/account_custom_fields_controller.rb +16 -15
- data/app/controllers/kaui/account_emails_controller.rb +28 -25
- data/app/controllers/kaui/account_tags_controller.rb +37 -34
- data/app/controllers/kaui/account_timelines_controller.rb +38 -33
- data/app/controllers/kaui/accounts_controller.rb +269 -255
- data/app/controllers/kaui/admin_allowed_users_controller.rb +105 -99
- data/app/controllers/kaui/admin_controller.rb +32 -31
- data/app/controllers/kaui/admin_tenants_controller.rb +434 -388
- data/app/controllers/kaui/audit_logs_controller.rb +87 -84
- data/app/controllers/kaui/bundle_tags_controller.rb +24 -20
- data/app/controllers/kaui/bundles_controller.rb +96 -82
- data/app/controllers/kaui/chargebacks_controller.rb +36 -33
- data/app/controllers/kaui/charges_controller.rb +23 -20
- data/app/controllers/kaui/credits_controller.rb +28 -25
- data/app/controllers/kaui/custom_fields_controller.rb +172 -38
- data/app/controllers/kaui/engine_controller.rb +2 -1
- data/app/controllers/kaui/engine_controller_util.rb +134 -114
- data/app/controllers/kaui/home_controller.rb +230 -217
- data/app/controllers/kaui/invoice_items_controller.rb +43 -39
- data/app/controllers/kaui/invoice_tags_controller.rb +32 -0
- data/app/controllers/kaui/invoices_controller.rb +134 -88
- data/app/controllers/kaui/login_proxy_controller.rb +2 -1
- data/app/controllers/kaui/payment_methods_controller.rb +103 -90
- data/app/controllers/kaui/payments_controller.rb +95 -92
- data/app/controllers/kaui/queues_controller.rb +47 -14
- data/app/controllers/kaui/refunds_controller.rb +36 -33
- data/app/controllers/kaui/registrations_controller.rb +7 -7
- data/app/controllers/kaui/role_definitions_controller.rb +17 -14
- data/app/controllers/kaui/sessions_controller.rb +7 -4
- data/app/controllers/kaui/subscriptions_controller.rb +197 -187
- data/app/controllers/kaui/tag_definitions_controller.rb +28 -27
- data/app/controllers/kaui/tags_controller.rb +25 -22
- data/app/controllers/kaui/tenants_controller.rb +30 -28
- data/app/controllers/kaui/transactions_controller.rb +43 -38
- data/app/helpers/kaui/account_helper.rb +22 -12
- data/app/helpers/kaui/application_helper.rb +8 -3
- data/app/helpers/kaui/date_helper.rb +3 -2
- data/app/helpers/kaui/home_helper.rb +2 -0
- data/app/helpers/kaui/locale_helper.rb +7 -6
- data/app/helpers/kaui/money_helper.rb +2 -1
- data/app/helpers/kaui/object_helper.rb +11 -10
- data/app/helpers/kaui/payment_helper.rb +7 -6
- data/app/helpers/kaui/payment_method_helper.rb +3 -2
- data/app/helpers/kaui/permissions_helper.rb +9 -9
- data/app/helpers/kaui/plugin_helper.rb +25 -23
- data/app/helpers/kaui/subscription_helper.rb +27 -29
- data/app/helpers/kaui/us_states_helper.rb +7 -6
- data/app/helpers/kaui/uuid_helper.rb +8 -5
- data/app/models/kaui/ability.rb +19 -12
- data/app/models/kaui/account.rb +45 -28
- data/app/models/kaui/account_email.rb +23 -20
- data/app/models/kaui/account_timeline.rb +5 -1
- data/app/models/kaui/admin.rb +65 -64
- data/app/models/kaui/admin_tenant.rb +81 -82
- data/app/models/kaui/allowed_user.rb +13 -9
- data/app/models/kaui/allowed_user_tenant.rb +4 -2
- data/app/models/kaui/application_record.rb +2 -0
- data/app/models/kaui/audit_log.rb +6 -3
- data/app/models/kaui/base.rb +13 -7
- data/app/models/kaui/bundle.rb +41 -24
- data/app/models/kaui/catalog.rb +118 -113
- data/app/models/kaui/chargeback.rb +5 -1
- data/app/models/kaui/credit.rb +4 -1
- data/app/models/kaui/custom_field.rb +9 -6
- data/app/models/kaui/invoice.rb +25 -22
- data/app/models/kaui/invoice_item.rb +9 -6
- data/app/models/kaui/invoice_payment.rb +49 -54
- data/app/models/kaui/killbill_authenticatable.rb +14 -8
- data/app/models/kaui/killbill_registerable.rb +7 -0
- data/app/models/kaui/overdue.rb +64 -65
- data/app/models/kaui/payment.rb +22 -19
- data/app/models/kaui/payment_method.rb +48 -39
- data/app/models/kaui/payment_state.rb +41 -38
- data/app/models/kaui/rails_methods.rb +9 -9
- data/app/models/kaui/refund.rb +7 -1
- data/app/models/kaui/role_definition.rb +5 -1
- data/app/models/kaui/simple_plan.rb +5 -3
- data/app/models/kaui/subscription.rb +10 -7
- data/app/models/kaui/tag.rb +25 -22
- data/app/models/kaui/tag_definition.rb +50 -45
- data/app/models/kaui/tenant.rb +6 -5
- data/app/models/kaui/transaction.rb +43 -31
- data/app/models/kaui/user.rb +10 -16
- data/app/models/kaui/user_role.rb +8 -5
- data/app/views/kaui/accounts/_billing_info.html.erb +5 -1
- data/app/views/kaui/accounts/_form.html.erb +2 -2
- data/app/views/kaui/accounts/_payment_methods.html.erb +3 -0
- data/app/views/kaui/accounts/index.html.erb +9 -4
- data/app/views/kaui/admin_allowed_users/_form.html.erb +3 -3
- data/app/views/kaui/admin_tenants/_form_catalog_translation.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_invoice_template.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_invoice_translation.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_plugin_config.erb +13 -3
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +11 -5
- data/app/views/kaui/admin_tenants/new_catalog.html.erb +2 -2
- data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +2 -2
- data/app/views/kaui/admin_tenants/new_plan_currency.html.erb +1 -1
- data/app/views/kaui/bundles/_bundle_details.html.erb +12 -0
- data/app/views/kaui/bundles/index.html.erb +3 -14
- data/app/views/kaui/bundles/transfer.html.erb +13 -5
- data/app/views/kaui/invoice_tags/_form.html.erb +33 -0
- data/app/views/kaui/invoice_tags/_form_bar.html.erb +21 -0
- data/app/views/kaui/invoice_tags/edit.html.erb +10 -0
- data/app/views/kaui/invoices/_invoice_table.html.erb +29 -8
- data/app/views/kaui/invoices/index.html.erb +6 -4
- data/app/views/kaui/invoices/show.html.erb +10 -1
- data/app/views/kaui/layouts/kaui_flash.html.erb +32 -1
- data/app/views/kaui/layouts/kaui_header.html.erb +19 -2
- data/app/views/kaui/payment_methods/_payment_methods_details_table.html.erb +13 -4
- data/app/views/kaui/payments/_payment_table.html.erb +21 -11
- data/app/views/kaui/payments/index.html.erb +12 -10
- data/app/views/kaui/queues/index.html.erb +1 -1
- data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +1 -4
- data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +3 -3
- data/app/views/kaui/subscriptions/edit_bcd.erb +1 -1
- data/app/views/kaui/tag_definitions/index.html.erb +2 -2
- data/app/views/kaui/tags/index.html.erb +1 -0
- data/config/initializers/bootstrap_datepicker_rails.rb +3 -0
- data/config/initializers/devise.rb +8 -6
- data/config/initializers/js_routes.rb +9 -0
- data/config/initializers/kilbill_client_init.rb +13 -0
- data/config/initializers/killbill_authenticatable.rb +71 -21
- data/config/initializers/killbill_registerable.rb +5 -3
- data/config/initializers/time_formats.rb +6 -4
- data/config/locales/en.yml +78 -1
- data/config/routes.rb +40 -32
- data/db/migrate/20130812155313_devise_create_kaui_users.rb +10 -8
- data/db/migrate/20150109214021_create_kaui_tenants.rb +10 -8
- data/db/migrate/20150112232813_create_kaui_allowed_users.rb +10 -8
- data/lib/generators/kaui/install/install_generator.rb +23 -20
- data/lib/generators/kaui/install/templates/config/initializers/kaui.rb +3 -1
- data/lib/kaui/engine.rb +17 -5
- data/lib/kaui/installer/installer.rb +27 -26
- data/lib/kaui/version.rb +3 -1
- data/lib/kaui.rb +74 -30
- data/lib/tasks/kaui_tasks.rake +1 -0
- metadata +145 -440
- data/app/assets/javascripts/application.js +0 -17
- data/app/assets/javascripts/kaui/bootstrap-tweaks.js +0 -172
- data/app/assets/stylesheets/bootstrap_and_overrides.css.less +0 -44
- data/app/assets/stylesheets/kaui/kaui.less +0 -21
- data/app/assets/stylesheets/kaui/timeline.less +0 -4
- data/config/initializers/asset.rb +0 -1
- data/config/initializers/kilbill-client-init.rb +0 -9
- data/db/schema.rb +0 -15
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/controllers/application_controller.rb +0 -9
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -38
- data/test/dummy/bin/update +0 -29
- data/test/dummy/bin/yarn +0 -11
- data/test/dummy/config/application.rb +0 -18
- data/test/dummy/config/boot.rb +0 -3
- data/test/dummy/config/database.yml +0 -27
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -58
- data/test/dummy/config/environments/production.rb +0 -91
- data/test/dummy/config/environments/test.rb +0 -49
- data/test/dummy/config/initializers/application_controller_renderer.rb +0 -6
- data/test/dummy/config/initializers/assets.rb +0 -14
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/killbill_client.rb +0 -1
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +0 -14
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -33
- data/test/dummy/config/routes.rb +0 -3
- data/test/dummy/config/secrets.yml +0 -32
- data/test/dummy/config/symmetric-encryption.yml +0 -135
- data/test/dummy/config.ru +0 -4
- data/test/dummy/db/schema.rb +0 -52
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/fixtures/SpyCarAdvanced.xml +0 -824
- data/test/fixtures/catalog-v1.xml +0 -73
- data/test/fixtures/catalog_translation_fr-v1.properties +0 -1
- data/test/fixtures/invoice_template-v1.html +0 -100
- data/test/fixtures/invoice_translation_fr-v1.properties +0 -23
- data/test/fixtures/overdue-v1.xml +0 -49
- data/test/fixtures/stripe.yml +0 -2
- data/test/functional/kaui/account_children_controller_test.rb +0 -32
- data/test/functional/kaui/account_custom_fields_controller_test.rb +0 -29
- data/test/functional/kaui/account_emails_controller_test.rb +0 -55
- data/test/functional/kaui/account_tags_controller_test.rb +0 -48
- data/test/functional/kaui/account_timelines_controller_test.rb +0 -20
- data/test/functional/kaui/accounts_controller_test.rb +0 -297
- data/test/functional/kaui/admin_allowed_users_controller_test.rb +0 -234
- data/test/functional/kaui/admin_controller_test.rb +0 -45
- data/test/functional/kaui/admin_tenants_controller_test.rb +0 -352
- data/test/functional/kaui/audit_logs_controller_test.rb +0 -71
- data/test/functional/kaui/bundle_tags_controller_test.rb +0 -23
- data/test/functional/kaui/bundles_controller_test.rb +0 -130
- data/test/functional/kaui/chargebacks_controller_test.rb +0 -42
- data/test/functional/kaui/charges_controller_test.rb +0 -60
- data/test/functional/kaui/credits_controller_test.rb +0 -54
- data/test/functional/kaui/custom_fields_controller_test.rb +0 -52
- data/test/functional/kaui/functional_test_helper.rb +0 -13
- data/test/functional/kaui/functional_test_helper_nosetup.rb +0 -120
- data/test/functional/kaui/home_controller_test.rb +0 -407
- data/test/functional/kaui/invoice_items_controller_test.rb +0 -82
- data/test/functional/kaui/invoices_controller_test.rb +0 -88
- data/test/functional/kaui/login_proxy_controller_test.rb +0 -12
- data/test/functional/kaui/payment_methods_controller_test.rb +0 -52
- data/test/functional/kaui/payments_controller_test.rb +0 -59
- data/test/functional/kaui/queues_controller_test.rb +0 -17
- data/test/functional/kaui/refunds_controller_test.rb +0 -63
- data/test/functional/kaui/registrations_controller_test.rb +0 -49
- data/test/functional/kaui/role_definitions_controller_test.rb +0 -47
- data/test/functional/kaui/subscriptions_controller_test.rb +0 -194
- data/test/functional/kaui/tag_definitions_controller_test.rb +0 -29
- data/test/functional/kaui/tags_controller_test.rb +0 -21
- data/test/functional/kaui/tenants_controller_test.rb +0 -60
- data/test/functional/kaui/transactions_controller_test.rb +0 -90
- data/test/integration/kaui/date_helper_integration_test.rb +0 -16
- data/test/integration/kaui/integration_test_helper.rb +0 -32
- data/test/integration/kaui/navigation_test.rb +0 -43
- data/test/killbill_test_helper.rb +0 -217
- data/test/test_helper.rb +0 -22
- data/test/unit/helpers/kaui/admin_allowed_users_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/admin_tenants_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/payment_method_helper_test.rb +0 -17
- data/test/unit/helpers/kaui/tenants_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/uuid_helper_test.rb +0 -16
- data/test/unit/kaui/account_email_test.rb +0 -19
- data/test/unit/kaui/account_test.rb +0 -14
- data/test/unit/kaui/admin_tenant_test.rb +0 -132
- data/test/unit/kaui/allowed_user_test.rb +0 -34
- data/test/unit/kaui/base_test.rb +0 -23
- data/test/unit/kaui/date_helper_test.rb +0 -26
- data/test/unit/kaui/invoice_item_test.rb +0 -11
- data/test/unit/kaui/invoice_payment_test.rb +0 -42
- data/test/unit/kaui/invoice_test.rb +0 -20
- data/test/unit/kaui/money_helper_test.rb +0 -16
- data/test/unit/kaui/payment_test.rb +0 -42
- data/test/unit/kaui/tag_definition_test.rb +0 -11
- data/test/unit/kaui/tenant_test.rb +0 -19
- /data/app/assets/stylesheets/{application.css → kaui_application.css} +0 -0
@@ -1,28 +1,30 @@
|
|
1
|
-
|
2
|
-
OBJECT_WITH_HISTORY = %w[ACCOUNT ACCOUNT_EMAIL BLOCKING_STATES BUNDLE CUSTOM_FIELD INVOICE INVOICE_ITEM PAYMENT_ATTEMPT PAYMENT PAYMENT_METHOD SUBSCRIPTION SUBSCRIPTION_EVENT TRANSACTION TAG TAG_DEFINITION]
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
audit_logs = @account.audit(cached_options_for_klient)
|
3
|
+
module Kaui
|
4
|
+
class AuditLogsController < Kaui::EngineController
|
5
|
+
OBJECT_WITH_HISTORY = %w[ACCOUNT ACCOUNT_EMAIL BLOCKING_STATES BUNDLE CUSTOM_FIELD INVOICE INVOICE_ITEM PAYMENT_ATTEMPT PAYMENT PAYMENT_METHOD SUBSCRIPTION SUBSCRIPTION_EVENT TRANSACTION TAG TAG_DEFINITION].freeze
|
8
6
|
|
7
|
+
def index
|
8
|
+
cached_options_for_klient = options_for_klient
|
9
|
+
@account = Kaui::Account.find_by_id_or_key(params.require(:account_id), false, false, cached_options_for_klient)
|
10
|
+
audit_logs = @account.audit(cached_options_for_klient)
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
+
formatter = lambda do |log|
|
13
|
+
object_id_text = view_context.object_id_popover(log.object_id)
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
if object_with_history?(log.object_type)
|
16
|
+
object_id_text = view_context.link_to(object_id_text, '#showHistoryModal',
|
17
|
+
data: {
|
16
18
|
toggle: 'modal',
|
17
19
|
object_id: log.object_id,
|
18
20
|
object_type: log.object_type,
|
19
21
|
change_date: log.change_date,
|
20
22
|
change_type: log.change_type,
|
21
23
|
account_id: @account.account_id
|
22
|
-
|
23
|
-
|
24
|
+
})
|
25
|
+
end
|
24
26
|
|
25
|
-
|
27
|
+
[
|
26
28
|
log.change_date,
|
27
29
|
object_id_text,
|
28
30
|
log.object_type,
|
@@ -31,86 +33,87 @@ class Kaui::AuditLogsController < Kaui::EngineController
|
|
31
33
|
log.reason_code,
|
32
34
|
log.comments,
|
33
35
|
view_context.object_id_popover(log.user_token, 'left')
|
34
|
-
|
35
|
-
|
36
|
+
]
|
37
|
+
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
+
@audit_logs_json = []
|
40
|
+
audit_logs.each { |page| @audit_logs_json << formatter.call(page) }
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
+
@audit_logs_json = @audit_logs_json.to_json
|
43
|
+
end
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
def history
|
46
|
+
json_response do
|
47
|
+
account_id = params.require(:account_id)
|
48
|
+
object_id = params.require(:object_id)
|
49
|
+
object_type = params.require(:object_type)
|
50
|
+
cached_options_for_klient = options_for_klient
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
=
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
=
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
52
|
+
audit_logs_with_history = []
|
53
|
+
error = nil
|
54
|
+
|
55
|
+
begin
|
56
|
+
case object_type
|
57
|
+
when 'ACCOUNT'
|
58
|
+
account = Kaui::Account.find_by_id_or_key(object_id, false, false, cached_options_for_klient)
|
59
|
+
audit_logs_with_history = account.audit_logs_with_history(cached_options_for_klient)
|
60
|
+
when 'ACCOUNT_EMAIL'
|
61
|
+
account = Kaui::Account.find_by_id_or_key(account_id, false, false, cached_options_for_klient)
|
62
|
+
audit_logs_with_history = account.email_audit_logs_with_history(object_id, cached_options_for_klient)
|
63
|
+
when 'BLOCKING_STATES'
|
64
|
+
audit_logs_with_history = Kaui::Account.blocking_state_audit_logs_with_history(object_id, cached_options_for_klient)
|
65
|
+
when 'BUNDLE'
|
66
|
+
bundle = Kaui::Bundle.find_by_id(object_id, cached_options_for_klient)
|
67
|
+
audit_logs_with_history = bundle.audit_logs_with_history(cached_options_for_klient)
|
68
|
+
when 'CUSTOM_FIELD'
|
69
|
+
audit_logs_with_history = Kaui::CustomField.new({ custom_field_id: object_id }).audit_logs_with_history(cached_options_for_klient)
|
70
|
+
when 'INVOICE'
|
71
|
+
invoice = Kaui::Invoice.find_by_id(object_id, 'NONE', cached_options_for_klient)
|
72
|
+
audit_logs_with_history = invoice.audit_logs_with_history(cached_options_for_klient)
|
73
|
+
when 'INVOICE_ITEM'
|
74
|
+
invoice_item = Kaui::InvoiceItem.new
|
75
|
+
invoice_item.invoice_item_id = object_id
|
76
|
+
audit_logs_with_history = invoice_item.audit_logs_with_history(cached_options_for_klient)
|
77
|
+
# See https://github.com/killbill/killbill/issues/1104
|
78
|
+
# elsif object_type == 'INVOICE_PAYMENT'
|
79
|
+
# invoice_payment = Kaui::InvoicePayment::find_by_id(object_id, false, false, cached_options_for_klient)
|
80
|
+
# audit_logs_with_history = invoice_payment.audit_logs_with_history(cached_options_for_klient)
|
81
|
+
when 'PAYMENT_ATTEMPT'
|
82
|
+
audit_logs_with_history = Kaui::Payment.attempt_audit_logs_with_history(object_id, cached_options_for_klient)
|
83
|
+
when 'PAYMENT'
|
84
|
+
payment = Kaui::Payment.find_by_id(object_id, false, false, cached_options_for_klient)
|
85
|
+
audit_logs_with_history = payment.audit_logs_with_history(cached_options_for_klient)
|
86
|
+
when 'PAYMENT_METHOD'
|
87
|
+
payment_method = Kaui::PaymentMethod.find_by_id(object_id, false, cached_options_for_klient)
|
88
|
+
audit_logs_with_history = payment_method.audit_logs_with_history(cached_options_for_klient)
|
89
|
+
when 'SUBSCRIPTION'
|
90
|
+
subscription = Kaui::Subscription.find_by_id(object_id, cached_options_for_klient)
|
91
|
+
audit_logs_with_history = subscription.audit_logs_with_history(cached_options_for_klient)
|
92
|
+
when 'SUBSCRIPTION_EVENT'
|
93
|
+
audit_logs_with_history = Kaui::Subscription.event_audit_logs_with_history(object_id, cached_options_for_klient)
|
94
|
+
when 'TRANSACTION'
|
95
|
+
audit_logs_with_history = Kaui::Transaction.new({ transaction_id: object_id }).audit_logs_with_history(cached_options_for_klient)
|
96
|
+
when 'TAG'
|
97
|
+
audit_logs_with_history = Kaui::Tag.new({ tag_id: object_id }).audit_logs_with_history(cached_options_for_klient)
|
98
|
+
when 'TAG_DEFINITION'
|
99
|
+
audit_logs_with_history = Kaui::TagDefinition.new({ id: object_id }).audit_logs_with_history(cached_options_for_klient)
|
100
|
+
else
|
101
|
+
error = "Object [#{object_type}] history is not supported."
|
102
|
+
end
|
103
|
+
rescue StandardError => e
|
104
|
+
error = e.message
|
100
105
|
end
|
101
|
-
rescue Exception => e
|
102
|
-
error = e.message
|
103
|
-
end
|
104
106
|
|
105
|
-
|
107
|
+
{ audits: audit_logs_with_history, error: error }
|
108
|
+
end
|
106
109
|
end
|
107
|
-
end
|
108
110
|
|
109
|
-
|
111
|
+
private
|
110
112
|
|
111
113
|
def object_with_history?(object_type)
|
112
114
|
return false if object_type.nil?
|
115
|
+
|
113
116
|
OBJECT_WITH_HISTORY.include?(object_type)
|
114
117
|
end
|
115
|
-
|
116
|
-
end
|
118
|
+
end
|
119
|
+
end
|
@@ -1,28 +1,32 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module Kaui
|
4
|
+
class BundleTagsController < Kaui::EngineController
|
5
|
+
def edit
|
6
|
+
@bundle_id = params.require(:bundle_id)
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
cached_options_for_klient = options_for_klient
|
9
|
+
fetch_tag_names = promise { Kaui::Tag.all_for_bundle(@bundle_id, false, 'NONE', cached_options_for_klient).map(&:tag_definition_name).sort }
|
10
|
+
fetch_available_tags = promise { Kaui::TagDefinition.all_for_bundle(cached_options_for_klient) }
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
@tag_names = wait(fetch_tag_names)
|
13
|
+
@available_tags = wait(fetch_available_tags)
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
def update
|
17
|
+
account_id = params.require(:account_id)
|
18
|
+
bundle_id = params.require(:bundle_id)
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
tags << tag_info[1]
|
23
|
-
end
|
20
|
+
tags = []
|
21
|
+
params.each do |tag, _tag_name|
|
22
|
+
tag_info = tag.split('_')
|
23
|
+
next if (tag_info.size != 2) || (tag_info[0] != 'tag')
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
tags << tag_info[1]
|
26
|
+
end
|
27
|
+
|
28
|
+
Kaui::Tag.set_for_bundle(bundle_id, tags, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
29
|
+
redirect_to kaui_engine.account_bundles_path(account_id), notice: 'Bundle tags successfully set'
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
@@ -1,99 +1,113 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kaui
|
4
|
+
class BundlesController < Kaui::EngineController
|
5
|
+
# rubocop:disable Lint/HashCompareByIdentity
|
6
|
+
def index
|
7
|
+
cached_options_for_klient = options_for_klient
|
8
|
+
|
9
|
+
fetch_bundles = promise { @account.bundles(cached_options_for_klient) }
|
10
|
+
fetch_bundle_tags = promise do
|
11
|
+
all_bundle_tags = @account.all_tags(:BUNDLE, false, 'NONE', cached_options_for_klient)
|
12
|
+
all_bundle_tags.each_with_object({}) do |entry, hsh|
|
13
|
+
(hsh[entry.object_id] ||= []) << entry
|
14
|
+
end
|
15
|
+
end
|
16
|
+
fetch_subscription_tags = promise do
|
17
|
+
all_subscription_tags = @account.all_tags(:SUBSCRIPTION, false, 'NONE', cached_options_for_klient)
|
18
|
+
all_subscription_tags.each_with_object({}) do |entry, hsh|
|
19
|
+
(hsh[entry.object_id] ||= []) << entry
|
20
|
+
end
|
21
|
+
end
|
22
|
+
fetch_bundle_fields = promise do
|
23
|
+
all_bundle_fields = @account.all_custom_fields(:BUNDLE, 'NONE', cached_options_for_klient)
|
24
|
+
all_bundle_fields.each_with_object({}) do |entry, hsh|
|
25
|
+
(hsh[entry.object_id] ||= []) << entry
|
26
|
+
end
|
27
|
+
end
|
28
|
+
fetch_subscription_fields = promise do
|
29
|
+
all_subscription_fields = @account.all_custom_fields(:SUBSCRIPTION, 'NONE', cached_options_for_klient)
|
30
|
+
all_subscription_fields.each_with_object({}) do |entry, hsh|
|
31
|
+
(hsh[entry.object_id] ||= []) << entry
|
32
|
+
end
|
33
|
+
end
|
34
|
+
fetch_available_tags = promise { Kaui::TagDefinition.all_for_bundle(cached_options_for_klient) }
|
35
|
+
fetch_available_subscription_tags = promise { Kaui::TagDefinition.all_for_subscription(cached_options_for_klient) }
|
36
|
+
|
37
|
+
@bundles = wait(fetch_bundles)
|
38
|
+
@tags_per_bundle = wait(fetch_bundle_tags)
|
39
|
+
@tags_per_subscription = wait(fetch_subscription_tags)
|
40
|
+
@custom_fields_per_bundle = wait(fetch_bundle_fields)
|
41
|
+
@custom_fields_per_subscription = wait(fetch_subscription_fields)
|
42
|
+
@available_tags = wait(fetch_available_tags)
|
43
|
+
@available_subscription_tags = wait(fetch_available_subscription_tags)
|
44
|
+
|
45
|
+
# TODO: This doesn't take into account catalog versions
|
46
|
+
catalogs = Kaui::Catalog.get_account_catalog_json(@account.account_id, nil, cached_options_for_klient) || []
|
47
|
+
@catalog = catalogs[-1]
|
48
|
+
|
49
|
+
@subscription = {}
|
50
|
+
@bundles.each do |bundle|
|
51
|
+
bundle.subscriptions.each do |sub|
|
52
|
+
next if sub.product_category == 'ADD_ON'
|
53
|
+
|
54
|
+
@subscription[bundle.bundle_id] = sub
|
55
|
+
break
|
56
|
+
end
|
44
57
|
end
|
45
58
|
end
|
46
|
-
|
59
|
+
# rubocop:enable Lint/HashCompareByIdentity
|
47
60
|
|
48
|
-
|
49
|
-
|
50
|
-
|
61
|
+
def transfer
|
62
|
+
@bundle_id = params.require(:id)
|
63
|
+
end
|
51
64
|
|
52
|
-
|
53
|
-
|
65
|
+
def do_transfer
|
66
|
+
cached_options_for_klient = options_for_klient
|
54
67
|
|
55
|
-
|
68
|
+
new_account = Kaui::Account.find_by_id_or_key(params.require(:new_account_key), false, false, cached_options_for_klient)
|
56
69
|
|
57
|
-
|
58
|
-
|
70
|
+
bundle = Kaui::Bundle.new(bundle_id: params.require(:id), account_id: new_account.account_id)
|
71
|
+
bundle.transfer(nil, params[:billing_policy], current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
59
72
|
|
60
|
-
|
61
|
-
|
73
|
+
redirect_to kaui_engine.account_bundles_path(new_account.account_id), notice: 'Bundle was successfully transferred'
|
74
|
+
end
|
62
75
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
76
|
+
def restful_show
|
77
|
+
bundle = Kaui::Bundle.find_by_id_or_key(params.require(:id), options_for_klient)
|
78
|
+
redirect_to kaui_engine.account_bundles_path(bundle.account_id)
|
79
|
+
end
|
67
80
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
81
|
+
def pause_resume
|
82
|
+
@bundle = Kaui::Bundle.find_by_id_or_key(params.require(:id), options_for_klient)
|
83
|
+
@base_subscription = @bundle.subscriptions.find { |sub| sub.product_category == 'BASE' }
|
84
|
+
end
|
72
85
|
|
73
|
-
|
74
|
-
|
86
|
+
def do_pause_resume
|
87
|
+
bundle = Kaui::Bundle.new(bundle_id: params.require(:id))
|
75
88
|
|
76
|
-
|
77
|
-
|
89
|
+
paused = false
|
90
|
+
resumed = false
|
78
91
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
92
|
+
if params[:pause_requested_date].present?
|
93
|
+
bundle.pause(params[:pause_requested_date], current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
94
|
+
paused = true
|
95
|
+
end
|
83
96
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
97
|
+
if params[:resume_requested_date].present?
|
98
|
+
bundle.resume(params[:resume_requested_date], current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
99
|
+
resumed = true
|
100
|
+
end
|
88
101
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
102
|
+
msg = 'Bundle was successfully '
|
103
|
+
msg += if paused && !resumed
|
104
|
+
'paused'
|
105
|
+
elsif !paused && resumed
|
106
|
+
'resumed'
|
107
|
+
else
|
108
|
+
'updated'
|
109
|
+
end
|
110
|
+
redirect_to kaui_engine.account_bundles_path(@account.account_id), notice: msg
|
96
111
|
end
|
97
|
-
redirect_to kaui_engine.account_bundles_path(@account.account_id), :notice => msg
|
98
112
|
end
|
99
113
|
end
|
@@ -1,45 +1,48 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
cached_options_for_klient = options_for_klient
|
3
|
+
module Kaui
|
4
|
+
class ChargebacksController < Kaui::EngineController
|
5
|
+
def new
|
6
|
+
payment = Kaui::Payment.find_by_id(params.require(:payment_id), false, false, options_for_klient)
|
7
|
+
@chargeback = Kaui::Chargeback.new(payment_id: payment.payment_id,
|
8
|
+
amount: payment.paid_amount_to_money.to_f,
|
9
|
+
currency: payment.currency)
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
12
|
+
def create
|
13
|
+
cached_options_for_klient = options_for_klient
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
rescue => e
|
19
|
-
flash.now[:error] = "Error while creating a new chargeback: #{as_string(e)}"
|
20
|
-
render :action => :new and return
|
21
|
-
end
|
15
|
+
@chargeback = Kaui::Chargeback.new(params.require(:chargeback))
|
16
|
+
should_cancel_subs = (params[:cancel_all_subs] == '1')
|
22
17
|
|
23
|
-
# Cancel all subscriptions on the account, if required
|
24
|
-
if should_cancel_subs
|
25
18
|
begin
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
19
|
+
payment = @chargeback.chargeback(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
20
|
+
rescue StandardError => e
|
21
|
+
flash.now[:error] = "Error while creating a new chargeback: #{as_string(e)}"
|
22
|
+
render action: :new and return
|
23
|
+
end
|
24
|
+
|
25
|
+
# Cancel all subscriptions on the account, if required
|
26
|
+
if should_cancel_subs
|
27
|
+
begin
|
28
|
+
account = Kaui::Account.find_by_id(payment.account_id, false, false, cached_options_for_klient)
|
29
|
+
account.bundles(cached_options_for_klient).each do |bundle|
|
30
|
+
bundle.subscriptions.each do |subscription|
|
31
|
+
# Already cancelled?
|
32
|
+
next unless subscription.billing_end_date.blank?
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
# Cancel the entitlement immediately but use the default billing policy
|
35
|
+
entitlement = Kaui::Subscription.new(subscription_id: subscription.subscription_id)
|
36
|
+
entitlement.cancel_entitlement_immediately(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
|
37
|
+
end
|
35
38
|
end
|
39
|
+
rescue StandardError => e
|
40
|
+
flash[:error] = "Error while cancelling subscriptions: #{as_string(e)}"
|
41
|
+
render action: :new and return
|
36
42
|
end
|
37
|
-
rescue => e
|
38
|
-
flash[:error] = "Error while cancelling subscriptions: #{as_string(e)}"
|
39
|
-
render :action => :new and return
|
40
43
|
end
|
41
|
-
end
|
42
44
|
|
43
|
-
|
45
|
+
redirect_to kaui_engine.account_payment_path(payment.account_id, payment.payment_id), notice: 'Chargeback created'
|
46
|
+
end
|
44
47
|
end
|
45
48
|
end
|
@@ -1,28 +1,31 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Kaui
|
4
|
+
class ChargesController < Kaui::EngineController
|
5
|
+
def new
|
6
|
+
invoice_id = params[:invoice_id]
|
7
|
+
amount = params[:amount]
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
if invoice_id.present?
|
10
|
+
@invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
|
11
|
+
amount ||= @invoice.balance
|
12
|
+
currency = @invoice.currency
|
13
|
+
else
|
14
|
+
@invoice = nil
|
15
|
+
currency = params[:currency] || 'USD'
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
+
@charge = Kaui::InvoiceItem.new(account_id: params.require(:account_id), invoice_id: invoice_id, amount: amount, currency: currency)
|
19
|
+
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
def create
|
22
|
+
charge = Kaui::InvoiceItem.new(params.require(:invoice_item).delete_if { |_key, value| value.blank? })
|
23
|
+
charge.account_id ||= params.require(:account_id)
|
22
24
|
|
23
|
-
|
25
|
+
auto_commit = params[:auto_commit] == '1'
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
+
charge = charge.create(auto_commit, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
28
|
+
redirect_to kaui_engine.account_invoice_path(charge.account_id, charge.invoice_id), notice: 'Charge was successfully created'
|
29
|
+
end
|
27
30
|
end
|
28
31
|
end
|