kaui 2.0.4 → 3.0.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 +132 -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 +4 -3
- 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 +9 -6
- 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 +76 -23
- data/lib/tasks/kaui_tasks.rake +1 -0
- metadata +141 -436
- 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,20 +1,22 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
module Kaui
|
4
|
+
class TenantsController < Kaui::EngineController
|
5
|
+
skip_before_action :check_for_redirect_to_tenant_screen
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def index
|
8
|
+
# Retrieve current user and extract allowed list of tenants
|
9
|
+
allowed_user = Kaui::AllowedUser.find_by_kb_username(current_user.kb_username)
|
10
|
+
@tenants = allowed_user&.kaui_tenants || []
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
#
|
13
|
+
# If there is nothing, we check for override with KillBillClient.api_key/KillBillClient.api_secret
|
14
|
+
# If there is only one, we skip the tenant screen since the choice is obvious
|
15
|
+
# If not, we allow user to choose what he wants
|
16
|
+
#
|
17
|
+
case @tenants.size
|
16
18
|
when 0
|
17
|
-
tenant = KillBillClient.api_key.nil? ? nil : KillBillClient::Model::Tenant.find_by_api_key(KillBillClient.api_key, :
|
19
|
+
tenant = KillBillClient.api_key.nil? ? nil : KillBillClient::Model::Tenant.find_by_api_key(KillBillClient.api_key, session_id: current_user.kb_session_id)
|
18
20
|
if tenant.present?
|
19
21
|
select_tenant_for_tenant_id(tenant.tenant_id, tenant.external_key, nil)
|
20
22
|
else
|
@@ -23,25 +25,25 @@ class Kaui::TenantsController < Kaui::EngineController
|
|
23
25
|
when 1
|
24
26
|
# If there is only one tenant defined we skip the screen and set the tenant for the user
|
25
27
|
select_tenant_for_tenant_id(@tenants[0].kb_tenant_id, @tenants[0].name, @tenants[0].id)
|
26
|
-
|
27
|
-
|
28
|
+
# else jump to default view allowing to chose which tenant to pick
|
29
|
+
end
|
28
30
|
end
|
29
|
-
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
def select_tenant
|
33
|
+
tenant = Kaui::Tenant.find_by_kb_tenant_id(params.require(:kb_tenant_id))
|
34
|
+
select_tenant_for_tenant_id(tenant.kb_tenant_id, tenant.name, tenant.id)
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
+
private
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
def select_tenant_for_tenant_id(kb_tenant_id, kb_tenant_name_or_key, tenant_id)
|
40
|
+
# Set kb_tenant_id in the session
|
41
|
+
session[:kb_tenant_id] = kb_tenant_id
|
42
|
+
session[:kb_tenant_name] = kb_tenant_name_or_key
|
43
|
+
session[:tenant_id] = tenant_id
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
# Devise will have stored the requested url while signed-out
|
46
|
+
redirect_to stored_location_for(:user) || Kaui.home_path.call
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
@@ -1,51 +1,56 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Kaui
|
4
|
+
class TransactionsController < Kaui::EngineController
|
5
|
+
def restful_show
|
6
|
+
payment = Kaui::Payment.find_by_transaction_id(params.require(:id), false, true, options_for_klient)
|
7
|
+
redirect_to account_payment_path(payment.account_id, payment.payment_id)
|
8
|
+
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
def new
|
11
|
+
@account_id = params[:account_id]
|
12
|
+
@payment_method_id = params[:payment_method_id]
|
13
|
+
|
14
|
+
transaction_id = params[:transaction_id].presence
|
15
|
+
if transaction_id.nil?
|
16
|
+
@transaction = Kaui::Transaction.new(payment_id: params[:payment_id],
|
17
|
+
amount: params[:amount],
|
18
|
+
currency: params[:currency],
|
19
|
+
transaction_type: params[:transaction_type])
|
20
|
+
else
|
21
|
+
payment = Kaui::Payment.find_by_transaction_id(transaction_id, false, false, options_for_klient)
|
22
|
+
@transaction = Kaui::Transaction.build_from_raw_transaction(payment.transactions.find { |tx| tx.transaction_id == transaction_id })
|
23
|
+
end
|
21
24
|
end
|
22
|
-
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
def create
|
27
|
+
transaction = Kaui::Transaction.new(params[:transaction].delete_if { |_key, value| value.blank? })
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
plugin_properties = params[:plugin_properties].values.reject { |item| (item['value'].blank? || item['key'].blank?) } unless params[:plugin_properties].blank?
|
30
|
+
unless plugin_properties.blank?
|
31
|
+
plugin_properties.map! do |property|
|
32
|
+
KillBillClient::Model::PluginPropertyAttributes.new(property)
|
33
|
+
end
|
34
|
+
end
|
31
35
|
|
32
|
-
|
36
|
+
options = plugin_properties.blank? ? options_for_klient : { pluginProperty: plugin_properties }.merge(options_for_klient)
|
33
37
|
|
34
|
-
|
35
|
-
|
38
|
+
control_plugin_names = params[:control_plugin_names].reject(&:blank?) unless params[:control_plugin_names].blank?
|
39
|
+
options.merge!({ controlPluginNames: control_plugin_names }) unless control_plugin_names.blank?
|
36
40
|
|
37
|
-
|
38
|
-
|
39
|
-
|
41
|
+
payment = transaction.create(params.require(:account_id), params[:payment_method_id], current_user.kb_username, params[:reason], params[:comment], options)
|
42
|
+
redirect_to kaui_engine.account_payment_path(payment.account_id, payment.payment_id), notice: 'Transaction successfully created'
|
43
|
+
end
|
40
44
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
def fix_transaction_state
|
46
|
+
transaction = Kaui::Transaction.new(params[:transaction].delete_if { |_key, value| value.blank? })
|
47
|
+
payment_id = transaction.payment_id
|
48
|
+
transaction_id = transaction.transaction_id
|
49
|
+
transaction_status = transaction.status
|
46
50
|
|
47
|
-
|
51
|
+
Kaui::Admin.fix_transaction_state(payment_id, transaction_id, transaction_status, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
48
52
|
|
49
|
-
|
53
|
+
redirect_to kaui_engine.account_payment_path(params.require(:account_id), payment_id), notice: "Transaction successfully transitioned to #{transaction_status}"
|
54
|
+
end
|
50
55
|
end
|
51
56
|
end
|
@@ -1,20 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kaui
|
2
4
|
module AccountHelper
|
3
|
-
|
4
5
|
def pretty_account_identifier
|
5
6
|
return nil if @account.nil?
|
6
|
-
|
7
|
+
|
8
|
+
Kaui.pretty_account_identifier.call(@account)
|
7
9
|
end
|
8
10
|
|
9
11
|
def email_notifications_plugin_available?
|
10
12
|
Kenui::EmailNotificationService.email_notification_plugin_available?(Kaui.current_tenant_user_options(current_user, session)).first
|
11
|
-
rescue
|
12
|
-
|
13
|
+
rescue StandardError
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def deposit_plugin_available?
|
18
|
+
Killbill::Deposit::DepositClient.deposit_plugin_available?(Kaui.current_tenant_user_options(current_user, session)).first
|
19
|
+
rescue StandardError
|
20
|
+
false
|
13
21
|
end
|
14
22
|
|
15
23
|
def account_closed?
|
16
24
|
return false if @account.nil?
|
17
|
-
|
25
|
+
|
26
|
+
# NOTE: we ignore errors here, so that the call doesn't prevent the screen to load. While the error isn't surfaced, if there is an error with the catalog for instance,
|
27
|
+
# the AJAX call to compute the next invoice date should hopefully trigger a flash error.
|
28
|
+
blocking_states = begin
|
29
|
+
@account.blocking_states('ACCOUNT', 'account-service', 'NONE', Kaui.current_tenant_user_options(current_user, session))
|
30
|
+
rescue StandardError
|
31
|
+
[]
|
32
|
+
end
|
18
33
|
|
19
34
|
is_account_closed = false
|
20
35
|
blocking_states.each do |blocking_state|
|
@@ -28,17 +43,12 @@ module Kaui
|
|
28
43
|
|
29
44
|
def billing_info_margin
|
30
45
|
style = ''
|
31
|
-
unless can?(:trigger, Kaui::Payment) && can?(:credit, Kaui::Account) && can?(:charge, Kaui::Account)
|
32
|
-
style = "#{style}margin-top:15px;"
|
33
|
-
end
|
46
|
+
style = "#{style}margin-top:15px;" unless can?(:trigger, Kaui::Payment) && can?(:credit, Kaui::Account) && can?(:charge, Kaui::Account)
|
34
47
|
|
35
|
-
unless can? :trigger, Kaui::Invoice
|
36
|
-
style = "#{style}margin-bottom:15px;"
|
37
|
-
end
|
48
|
+
style = "#{style}margin-bottom:15px;" unless can? :trigger, Kaui::Invoice
|
38
49
|
|
39
50
|
style = "style='#{style}'" unless style.empty?
|
40
51
|
style
|
41
52
|
end
|
42
|
-
|
43
53
|
end
|
44
54
|
end
|
@@ -1,13 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kaui
|
2
4
|
module ApplicationHelper
|
3
|
-
|
4
5
|
def tenant_selected?
|
5
6
|
session[:kb_tenant_id].present?
|
6
7
|
end
|
7
8
|
|
8
|
-
def truncate_class_name(klass, with_abbr
|
9
|
+
def truncate_class_name(klass, with_abbr)
|
9
10
|
splitted = klass.split('.')
|
10
|
-
with_abbr
|
11
|
+
if with_abbr
|
12
|
+
splitted.each_with_index.map { |k, idx| idx == splitted.size - 1 ? k : "#{k[0]}." }.join
|
13
|
+
else
|
14
|
+
splitted[-1]
|
15
|
+
end
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
@@ -1,6 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kaui
|
2
4
|
module DateHelper
|
3
|
-
|
4
5
|
LOCAL_DATE_RE = /^\d+-\d+-\d+$/
|
5
6
|
|
6
7
|
def format_date(date, timezone)
|
@@ -16,7 +17,7 @@ module Kaui
|
|
16
17
|
|
17
18
|
# If not, convert into account timezone and return the date part only
|
18
19
|
parsed_date = DateTime.parse(date.to_s).in_time_zone(timezone)
|
19
|
-
parsed_date.
|
20
|
+
parsed_date.to_fs(:date_only)
|
20
21
|
end
|
21
22
|
|
22
23
|
def truncate_millis(date_s)
|
@@ -30,7 +31,7 @@ module Kaui
|
|
30
31
|
# +time_zone+:: The time zone of the current time to return.
|
31
32
|
# +options+:: A hash that contains credentials needed to retrieve the time from the
|
32
33
|
# killbill server.
|
33
|
-
def current_time(time_zone=nil, options=nil)
|
34
|
+
def current_time(time_zone = nil, options = nil)
|
34
35
|
current_utc_time = nil
|
35
36
|
begin
|
36
37
|
# fetch time from killbill server
|
@@ -1,20 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kaui
|
2
4
|
module LocaleHelper
|
3
|
-
|
4
|
-
def get_available_locales
|
5
|
+
def all_available_locales
|
5
6
|
locale_yaml_file = File.join(File.dirname(__FILE__), 'locale_helper.yml')
|
6
|
-
available_locales = YAML
|
7
|
+
available_locales = YAML.load_file(locale_yaml_file)
|
7
8
|
|
8
9
|
favorites = []
|
9
10
|
locales = []
|
10
11
|
|
11
12
|
available_locales.each do |locale|
|
12
|
-
option = ["#{locale[:language]} #{locale[:country]} (#{locale[:language_tag]})", locale[:language_tag]
|
13
|
+
option = ["#{locale[:language]} #{locale[:country]} (#{locale[:language_tag]})", locale[:language_tag]]
|
13
14
|
locales << option unless locale[:favorite]
|
14
15
|
favorites << option if locale[:favorite]
|
15
16
|
end
|
16
17
|
|
17
|
-
favorites.
|
18
|
+
favorites.push('---------------').concat(locales)
|
18
19
|
end
|
19
20
|
end
|
20
|
-
end
|
21
|
+
end
|
@@ -1,19 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kaui
|
2
4
|
module ObjectHelper
|
3
|
-
|
4
5
|
# Because we don't have access to the account_id, we use the restful_show routes
|
5
6
|
def url_for_object(object_id, object_type)
|
6
|
-
|
7
|
+
case object_type
|
8
|
+
when 'ACCOUNT'
|
7
9
|
account_path(object_id)
|
8
|
-
|
10
|
+
when 'BUNDLE'
|
9
11
|
bundle_path(object_id)
|
10
|
-
|
12
|
+
when 'SUBSCRIPTION'
|
11
13
|
subscription_path(object_id)
|
12
|
-
|
14
|
+
when 'INVOICE'
|
13
15
|
invoice_path(object_id)
|
14
|
-
|
16
|
+
when 'PAYMENT'
|
15
17
|
payment_path(object_id)
|
16
|
-
|
18
|
+
when 'PAYMENT_METHOD'
|
17
19
|
payment_method_path(object_id)
|
18
20
|
else
|
19
21
|
nil
|
@@ -21,12 +23,11 @@ module Kaui
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def object_types
|
24
|
-
[
|
26
|
+
%i[ACCOUNT BUNDLE INVOICE INVOICE_ITEM INVOICE_PAYMENT PAYMENT SUBSCRIPTION TRANSACTION]
|
25
27
|
end
|
26
28
|
|
27
29
|
def object_types_for_advanced_search
|
28
|
-
[
|
30
|
+
%i[ACCOUNT BUNDLE INVOICE CREDIT CUSTOM_FIELD INVOICE_PAYMENT INVOICE PAYMENT SUBSCRIPTION TRANSACTION TAG TAG_DEFINITION]
|
29
31
|
end
|
30
|
-
|
31
32
|
end
|
32
33
|
end
|
@@ -1,17 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kaui
|
2
4
|
module PaymentHelper
|
3
|
-
|
4
5
|
def transaction_statuses
|
5
6
|
Kaui::Payment::TRANSACTION_STATUSES
|
6
7
|
end
|
7
8
|
|
8
9
|
def colored_transaction_status(transaction_status)
|
9
10
|
data = "<span class='alert-"
|
10
|
-
if transaction_status
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
data += if transaction_status == 'SUCCESS'
|
12
|
+
"success'>"
|
13
|
+
else
|
14
|
+
"danger'>"
|
15
|
+
end
|
15
16
|
data += transaction_status
|
16
17
|
data += '</span>'
|
17
18
|
data.html_safe
|
@@ -1,15 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kaui
|
2
4
|
module PermissionsHelper
|
3
|
-
|
4
5
|
def can_close_account?
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
is_authorized_when = true
|
7
|
+
is_authorized_when &= can? :cancel, Kaui::Subscription
|
8
|
+
is_authorized_when &= can? :pause_resume, Kaui::Subscription
|
9
|
+
is_authorized_when &= can? :add, Kaui::Tag
|
10
|
+
is_authorized_when &= can? :item_adjust, Kaui::Invoice
|
10
11
|
|
11
|
-
|
12
|
+
is_authorized_when
|
12
13
|
end
|
13
|
-
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end
|
@@ -1,36 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kaui
|
2
4
|
module PluginHelper
|
3
|
-
|
4
5
|
def plugin_repository
|
5
6
|
installed_plugins
|
6
7
|
end
|
7
8
|
|
8
9
|
private
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
def installed_plugins
|
12
|
+
installed_plugins = []
|
13
|
+
nodes_info = KillBillClient::Model::NodesInfo.nodes_info(Kaui.current_tenant_user_options(current_user, session)) || []
|
14
|
+
plugins_info = nodes_info.empty? ? [] : (nodes_info.first.plugins_info || [])
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
plugin_key = plugin.plugin_key
|
20
|
-
installed_plugins << {
|
21
|
-
# Unique identifier chosen by the user and used for kpm operations
|
22
|
-
plugin_key: plugin_key,
|
23
|
-
# Notes:
|
24
|
-
# * plugin.plugin_name comes from kpm and is arbitrary (see Utils.get_plugin_name_from_file_path in the kpm codebase for instance)
|
25
|
-
# * plugin_name here is the plugin name as seen by Kill Bill and is typically defined in the Activator.java (this value is the one that matters for plugin configuration)
|
26
|
-
# * The mapping here is a convention we've used over the years and is no way enforced anywhere - it likely won't work for proprietary plugins (the user would need to specify it by toggling the input on the UI)
|
27
|
-
plugin_name: "killbill-#{plugin_key}",
|
28
|
-
installed: true
|
29
|
-
}
|
30
|
-
end
|
16
|
+
plugins_info.each do |plugin|
|
17
|
+
next if plugin.version.nil?
|
18
|
+
# do not allow duplicate
|
19
|
+
next if installed_plugins.any? { |p| p[:plugin_name].eql?(plugin.plugin_name) }
|
31
20
|
|
32
|
-
|
33
|
-
installed_plugins
|
21
|
+
plugin_key = plugin.plugin_key
|
22
|
+
installed_plugins << {
|
23
|
+
# Unique identifier chosen by the user and used for kpm operations
|
24
|
+
plugin_key:,
|
25
|
+
# Notes:
|
26
|
+
# * plugin.plugin_name comes from kpm and is arbitrary (see Utils.get_plugin_name_from_file_path in the kpm codebase for instance)
|
27
|
+
# * plugin_name here is the plugin name as seen by Kill Bill and is typically defined in the Activator.java (this value is the one that matters for plugin configuration)
|
28
|
+
# * The mapping here is a convention we've used over the years and is no way enforced anywhere - it likely won't work for proprietary plugins (the user would need to specify it by toggling the input on the UI)
|
29
|
+
plugin_name: "killbill-#{plugin_key}",
|
30
|
+
installed: true
|
31
|
+
}
|
34
32
|
end
|
33
|
+
|
34
|
+
# to_s to handle nil
|
35
|
+
installed_plugins.sort! { |a, b| a[:plugin_key].to_s <=> b[:plugin_key].to_s }
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kaui
|
2
4
|
module SubscriptionHelper
|
3
|
-
|
4
5
|
def humanized_subscription_product_category(sub)
|
5
|
-
if !sub.present?
|
6
|
+
if !sub.present? || !sub.product_category.present?
|
6
7
|
nil
|
7
8
|
else
|
8
9
|
humanized_product_category(sub.product_category)
|
@@ -23,7 +24,7 @@ module Kaui
|
|
23
24
|
if !sub.present? || !sub.product_name.present?
|
24
25
|
nil
|
25
26
|
else
|
26
|
-
product = catalog
|
27
|
+
product = catalog&.products&.find { |p| p.name == sub.product_name }
|
27
28
|
humanized_product_name(!product.nil? && !product.pretty_name.blank? ? product.pretty_name : sub.product_name)
|
28
29
|
end
|
29
30
|
end
|
@@ -32,7 +33,7 @@ module Kaui
|
|
32
33
|
if !sub.present? || !sub.product_name.present?
|
33
34
|
nil
|
34
35
|
else
|
35
|
-
product = catalog
|
36
|
+
product = catalog&.products&.find { |p| p.name == sub.product_name }
|
36
37
|
return nil if product.nil?
|
37
38
|
|
38
39
|
plan = product.plans.find { |p| p.name == sub.plan_name }
|
@@ -46,7 +47,7 @@ module Kaui
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def humanized_subscription_billing_period(sub)
|
49
|
-
if !sub.present?
|
50
|
+
if !sub.present? || !sub.billing_period.present?
|
50
51
|
nil
|
51
52
|
else
|
52
53
|
humanized_billing_period(sub.billing_period)
|
@@ -61,8 +62,8 @@ module Kaui
|
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
64
|
-
def humanized_subscription_price_list(sub, show_default
|
65
|
-
if !sub.present?
|
65
|
+
def humanized_subscription_price_list(sub, show_default)
|
66
|
+
if !sub.present? || !sub.price_list.present? || (!show_default && (sub.price_list.upcase == 'DEFAULT'))
|
66
67
|
nil
|
67
68
|
else
|
68
69
|
sub.price_list.downcase.capitalize
|
@@ -77,19 +78,17 @@ module Kaui
|
|
77
78
|
humanized_billing_period = humanized_subscription_billing_period(sub)
|
78
79
|
humanized_price_list = humanized_subscription_price_list(sub, false)
|
79
80
|
|
80
|
-
if humanized_billing_period.nil?
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
92
|
-
end
|
81
|
+
humanized_product_name = if humanized_billing_period.nil?
|
82
|
+
if humanized_price_list.nil?
|
83
|
+
humanized_product_name + humanized_price_override(sub, '', '(', ')')
|
84
|
+
else
|
85
|
+
"#{humanized_product_name} (#{humanized_price_list.downcase}#{humanized_price_override(sub)})"
|
86
|
+
end
|
87
|
+
elsif humanized_price_list.nil?
|
88
|
+
"#{humanized_product_name} (#{humanized_billing_period.downcase}#{humanized_price_override(sub)})"
|
89
|
+
else
|
90
|
+
"#{humanized_product_name} (#{humanized_billing_period.downcase}, #{humanized_price_list.downcase}#{humanized_price_override(sub)})"
|
91
|
+
end
|
93
92
|
|
94
93
|
humanized_product_name.html_safe
|
95
94
|
end
|
@@ -115,7 +114,7 @@ module Kaui
|
|
115
114
|
end
|
116
115
|
|
117
116
|
def humanized_subscription_start_date(sub, account)
|
118
|
-
if !sub.present?
|
117
|
+
if !sub.present? || !sub.start_date.present? || !account.present? || !account.time_zone.present?
|
119
118
|
nil
|
120
119
|
else
|
121
120
|
format_date(sub.start_date, account.time_zone).html_safe
|
@@ -123,7 +122,7 @@ module Kaui
|
|
123
122
|
end
|
124
123
|
|
125
124
|
def humanized_subscription_charged_through_date(sub, account)
|
126
|
-
if !sub.present?
|
125
|
+
if !sub.present? || !sub.charged_through_date.present? || !account.present? || !account.time_zone.present?
|
127
126
|
nil
|
128
127
|
else
|
129
128
|
format_date(sub.charged_through_date, account.time_zone).html_safe
|
@@ -131,7 +130,7 @@ module Kaui
|
|
131
130
|
end
|
132
131
|
|
133
132
|
def humanized_subscription_cancelled_date(sub, account)
|
134
|
-
if !sub.present?
|
133
|
+
if !sub.present? || !sub.cancelled_date.present? || !account.present? || !account.time_zone.present?
|
135
134
|
nil
|
136
135
|
else
|
137
136
|
"Entitlement date: #{format_date(sub.cancelled_date, account.time_zone)}"
|
@@ -139,7 +138,7 @@ module Kaui
|
|
139
138
|
end
|
140
139
|
|
141
140
|
def humanized_subscription_billing_start_date(sub, account)
|
142
|
-
if !sub.present?
|
141
|
+
if !sub.present? || !sub.billing_start_date.present? || !account.present? || !account.time_zone.present?
|
143
142
|
nil
|
144
143
|
else
|
145
144
|
format_date(sub.billing_start_date, account.time_zone).html_safe
|
@@ -147,7 +146,7 @@ module Kaui
|
|
147
146
|
end
|
148
147
|
|
149
148
|
def humanized_subscription_billing_end_date(sub, account)
|
150
|
-
if !sub.present?
|
149
|
+
if !sub.present? || !sub.billing_end_date.present? || !account.present? || !account.time_zone.present?
|
151
150
|
nil
|
152
151
|
else
|
153
152
|
"Billing date: #{format_date(sub.billing_end_date, account.time_zone)}"
|
@@ -155,7 +154,7 @@ module Kaui
|
|
155
154
|
end
|
156
155
|
|
157
156
|
def humanized_subscription_cancelled_information(sub, account)
|
158
|
-
if !sub.present?
|
157
|
+
if !sub.present? || !sub.cancelled_date.present? || !account.present? || !account.time_zone.present?
|
159
158
|
nil
|
160
159
|
else
|
161
160
|
"#{humanized_subscription_cancelled_date(sub, account)}<br/>#{humanized_subscription_billing_end_date(sub, account)}".html_safe
|
@@ -166,12 +165,11 @@ module Kaui
|
|
166
165
|
time_unit.downcase.capitalize
|
167
166
|
end
|
168
167
|
|
169
|
-
|
170
|
-
def is_subscription_future_cancelled?(sub, account)
|
168
|
+
def subscription_future_cancelled?(sub, account)
|
171
169
|
sub.present? && sub.state != 'CANCELLED' && sub.billing_end_date.present? && Time.parse(sub.billing_end_date) > current_time(account.time_zone)
|
172
170
|
end
|
173
171
|
|
174
|
-
def
|
172
|
+
def subscription_cancelled?(sub)
|
175
173
|
sub.present? and sub.billing_end_date.present?
|
176
174
|
end
|
177
175
|
end
|