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,54 +1,59 @@
|
|
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
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kaui
|
4
|
+
class TagDefinition < KillBillClient::Model::TagDefinition
|
5
|
+
# See org.killbill.billing.ObjectType in killbill-api
|
6
|
+
ALL_OBJECT_TYPES = %w[ACCOUNT
|
7
|
+
ACCOUNT_EMAIL
|
8
|
+
BLOCKING_STATES
|
9
|
+
BUNDLE
|
10
|
+
CUSTOM_FIELD
|
11
|
+
INVOICE
|
12
|
+
PAYMENT
|
13
|
+
TRANSACTION
|
14
|
+
INVOICE_ITEM
|
15
|
+
INVOICE_PAYMENT
|
16
|
+
SUBSCRIPTION
|
17
|
+
SUBSCRIPTION_EVENT
|
18
|
+
PAYMENT_ATTEMPT
|
19
|
+
PAYMENT_METHOD
|
20
|
+
REFUND
|
21
|
+
TAG
|
22
|
+
TAG_DEFINITION
|
23
|
+
TENANT
|
24
|
+
TENANT_KVS].freeze
|
25
|
+
|
26
|
+
ALL_OBJECT_TYPES.each do |object_type|
|
27
|
+
define_singleton_method "all_for_#{object_type.downcase}" do |options_for_klient|
|
28
|
+
(all('NONE', options_for_klient).delete_if { |tag_definition| !tag_definition.applicable_object_types.include?(object_type) || tag_definition.is_control_tag }).sort
|
29
|
+
end
|
27
30
|
end
|
28
|
-
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
def system_tag?
|
33
|
+
return false unless id.present?
|
34
|
+
|
35
|
+
last_group = id.split('-')[4]
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
is_system_tag = true
|
38
|
+
last_group.chars.each_with_index do |c, i|
|
39
|
+
unless ((c == '0') && (i < 11)) || (c.to_i.positive? && (i == 11))
|
40
|
+
is_system_tag = false
|
41
|
+
break
|
42
|
+
end
|
39
43
|
end
|
44
|
+
is_system_tag
|
40
45
|
end
|
41
|
-
is_system_tag
|
42
|
-
end
|
43
46
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
name <=> tag_definition.name
|
49
|
-
end
|
47
|
+
def <=>(other)
|
48
|
+
# System tags last
|
49
|
+
return 1 if system_tag? && !other.system_tag?
|
50
|
+
return -1 if !system_tag? && other.system_tag?
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
name <=> other.name
|
53
|
+
end
|
54
|
+
|
55
|
+
def pretty_applicable_object_types
|
56
|
+
applicable_object_types == ALL_OBJECT_TYPES ? 'Any' : applicable_object_types.join(', ')
|
57
|
+
end
|
53
58
|
end
|
54
59
|
end
|
data/app/models/kaui/tenant.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'symmetric-encryption'
|
2
4
|
|
3
5
|
module Kaui
|
4
6
|
class Tenant < ApplicationRecord
|
7
|
+
attribute :encrypted_api_secret, :encrypted, random_iv: false
|
8
|
+
alias_attribute :api_secret, :encrypted_api_secret
|
5
9
|
|
6
|
-
|
7
|
-
|
8
|
-
has_many :kaui_allowed_user_tenants, :class_name => 'Kaui::AllowedUserTenant', :foreign_key => 'kaui_tenant_id'
|
9
|
-
has_many :kaui_allowed_users, :through => :kaui_allowed_user_tenants, :source => :kaui_allowed_user
|
10
|
-
|
10
|
+
has_many :kaui_allowed_user_tenants, class_name: 'Kaui::AllowedUserTenant', foreign_key: 'kaui_tenant_id'
|
11
|
+
has_many :kaui_allowed_users, through: :kaui_allowed_user_tenants, source: :kaui_allowed_user
|
11
12
|
end
|
12
13
|
end
|
@@ -1,40 +1,52 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
module Kaui
|
4
|
+
class Transaction < KillBillClient::Model::Transaction
|
5
|
+
attr_accessor :next_retry_date
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def self.build_from_raw_transaction(raw_transaction)
|
8
|
+
result = Kaui::Transaction.new
|
9
|
+
KillBillClient::Model::PaymentTransactionAttributes.instance_variable_get('@json_attributes').each do |attr|
|
10
|
+
result.send("#{attr}=", raw_transaction.send(attr))
|
11
|
+
end
|
12
|
+
result
|
9
13
|
end
|
10
|
-
result
|
11
|
-
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
15
|
+
def create(account_id = nil, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
|
16
|
+
case transaction_type
|
17
|
+
when 'AUTHORIZE'
|
18
|
+
auth(account_id, payment_method_id, user, reason, comment, options)
|
19
|
+
when 'CAPTURE'
|
20
|
+
capture(user, reason, comment, options)
|
21
|
+
when 'CHARGEBACK'
|
22
|
+
chargeback(user, reason, comment, options)
|
23
|
+
when 'CREDIT'
|
24
|
+
credit(account_id, payment_method_id, user, reason, comment, options)
|
25
|
+
when 'PURCHASE'
|
26
|
+
purchase(account_id, payment_method_id, user, reason, comment, options)
|
27
|
+
when 'REFUND'
|
28
|
+
refund(user, reason, comment, options)
|
29
|
+
when 'VOID'
|
30
|
+
void(user, reason, comment, options)
|
31
|
+
else
|
32
|
+
raise ArgumentError, "Unknown transaction type #{transaction_type}"
|
33
|
+
end
|
30
34
|
end
|
31
|
-
end
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
+
def amount_to_money
|
37
|
+
Kaui::Base.to_money(amount, currency)
|
38
|
+
end
|
36
39
|
|
37
|
-
|
38
|
-
|
40
|
+
def processed_amount_to_money
|
41
|
+
Kaui::Base.to_money(processed_amount, processed_currency)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.amount_to_money(transaction)
|
45
|
+
new(amount: transaction.amount, currency: transaction.currency).amount_to_money
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.processed_amount_to_money(transaction)
|
49
|
+
new(processed_amount: transaction.processed_amount, processed_currency: transaction.processed_currency).processed_amount_to_money
|
50
|
+
end
|
39
51
|
end
|
40
52
|
end
|
data/app/models/kaui/user.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'killbill_client'
|
2
4
|
|
3
5
|
module Kaui
|
@@ -9,36 +11,28 @@ module Kaui
|
|
9
11
|
|
10
12
|
# Called by Devise to perform authentication
|
11
13
|
# Throws KillBillClient::API::Unauthorized on failure
|
12
|
-
def self.find_permissions(
|
13
|
-
do_find_permissions
|
14
|
-
:password => kb_password
|
14
|
+
def self.find_permissions(options)
|
15
|
+
do_find_permissions(options)
|
15
16
|
end
|
16
17
|
|
17
18
|
# Called by CanCan to perform authorization
|
18
19
|
# Throws KillBillClient::API::Unauthorized on failure
|
19
20
|
def permissions
|
20
|
-
User.do_find_permissions :
|
21
|
+
User.do_find_permissions session_id: kb_session_id
|
21
22
|
end
|
22
23
|
|
23
|
-
# Verify the Kill Bill session hasn't timed-out
|
24
|
+
# Verify the Kill Bill session hasn't timed-out (ran as part of Warden::Proxy#set_user)
|
24
25
|
def authenticated_with_killbill?
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
rescue Errno::ECONNREFUSED => e
|
30
|
-
false
|
31
|
-
rescue KillBillClient::API::Unauthorized => e
|
32
|
-
false
|
33
|
-
end
|
26
|
+
subject = KillBillClient::Model::Security.find_subject session_id: kb_session_id
|
27
|
+
subject.is_authenticated
|
28
|
+
rescue Errno::ECONNREFUSED, KillBillClient::API::Unauthorized => _e
|
29
|
+
false
|
34
30
|
end
|
35
31
|
|
36
32
|
def root?
|
37
33
|
Kaui.root_username == kb_username
|
38
34
|
end
|
39
35
|
|
40
|
-
private
|
41
|
-
|
42
36
|
def self.do_find_permissions(options = {})
|
43
37
|
KillBillClient::Model::Security.find_permissions options
|
44
38
|
end
|
@@ -1,8 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
module Kaui
|
4
|
+
class UserRole < KillBillClient::Model::UserRoles
|
5
|
+
def self.find_roles_by_username(username, options = {})
|
6
|
+
user_role = Kaui::UserRole.new
|
7
|
+
user_role.username = username
|
8
|
+
user_role.list(options).roles
|
9
|
+
end
|
7
10
|
end
|
8
11
|
end
|
@@ -25,6 +25,10 @@
|
|
25
25
|
<%= link_to '<i class="fa fa-plus-square"></i> Create charge'.html_safe,
|
26
26
|
kaui_engine.new_account_charge_path(@account.account_id, :currency => @account.currency) %>
|
27
27
|
<% end %>
|
28
|
+
<% if deposit_plugin_available? %>
|
29
|
+
<%= link_to '<i class="fa fa-plus-square"></i> Create deposit'.html_safe,
|
30
|
+
deposit_engine.collection_index_path(:account_id => @account.account_id, :currency => @account.currency) %>
|
31
|
+
<% end %>
|
28
32
|
</div>
|
29
33
|
</div>
|
30
34
|
</div>
|
@@ -112,7 +116,7 @@
|
|
112
116
|
<div class="form-group">
|
113
117
|
<%= label_tag :target_date, 'Trigger invoice generation', :class => 'col-sm-6 control-label', :style => 'padding-left: 0;' %>
|
114
118
|
<div class="col-sm-3">
|
115
|
-
<input class="form-control" name="target_date" type="text" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-today-highlight="true">
|
119
|
+
<input class="form-control" id="target_date" name="target_date" type="text" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-today-highlight="true">
|
116
120
|
</div>
|
117
121
|
<% if can? :dry_run, Kaui::Invoice %>
|
118
122
|
<div style="width: 14.5%; float: left; padding: 0;">
|
@@ -68,7 +68,7 @@
|
|
68
68
|
<div class="form-group">
|
69
69
|
<%= f.label :locale, 'Locale', :class => 'col-sm-3 control-label' %>
|
70
70
|
<div class="col-sm-9">
|
71
|
-
<%= f.select :locale,
|
71
|
+
<%= f.select :locale, all_available_locales, {:selected => (@account.locale || 'en_US'), :disabled => '---------------'}, :class => 'form-control' %>
|
72
72
|
</div>
|
73
73
|
</div>
|
74
74
|
<div class="form-group">
|
@@ -104,7 +104,7 @@
|
|
104
104
|
<div class="form-group">
|
105
105
|
<%= f.label :state, 'State', :class => 'col-sm-3 control-label' %>
|
106
106
|
<div class="col-sm-9">
|
107
|
-
<%= f.select :state,
|
107
|
+
<%= f.select :state, all_us_states, {:include_blank => '', :selected => @account.state}, :class => 'form-control select-state' %>
|
108
108
|
<%= f.text_field :state, :class => 'form-control text-state', :style => 'display: none;' %>
|
109
109
|
</div>
|
110
110
|
</div>
|
@@ -7,6 +7,9 @@
|
|
7
7
|
<%= link_to '<i class="fa fa-plus-square"></i>'.html_safe,
|
8
8
|
kaui_engine.new_payment_method_path(:account_id => @account.account_id),
|
9
9
|
:class => 'btn btn-xs' %>
|
10
|
+
<%= form_tag kaui_engine.refresh_payment_methods_path(params.to_h), :method => :post, :class => 'form-force-inline form-right' do %>
|
11
|
+
<%= button_tag '<i class="fa fa-refresh"></i>'.html_safe, :class => 'btn btn-xs' %>
|
12
|
+
<% end %>
|
10
13
|
<% end %>
|
11
14
|
</h1>
|
12
15
|
|
@@ -13,8 +13,9 @@
|
|
13
13
|
<tr>
|
14
14
|
<th></th>
|
15
15
|
<th>ID</th>
|
16
|
-
|
17
|
-
|
16
|
+
<% Kaui.account_search_columns.call()[0].each do |title| %>
|
17
|
+
<th><%= title %></th>
|
18
|
+
<% end %>
|
18
19
|
</tr>
|
19
20
|
</thead>
|
20
21
|
<tbody>
|
@@ -30,6 +31,7 @@
|
|
30
31
|
|
31
32
|
<%= javascript_tag do %>
|
32
33
|
$(document).ready(function() {
|
34
|
+
|
33
35
|
var table = $('#accounts-table').DataTable({
|
34
36
|
"dom": "<'row'r>t<'row'<'col-md-6'i><'col-md-6'p>>",
|
35
37
|
"pagingType": <% if @max_nb_records.nil? -%>"simple"<% else -%>"full_numbers"<% end -%>,
|
@@ -39,8 +41,10 @@ $(document).ready(function() {
|
|
39
41
|
},
|
40
42
|
"pageLength": <%= @limit %>,
|
41
43
|
"displayStart": <%= @offset %>,
|
42
|
-
<%
|
43
|
-
|
44
|
+
<% if @search_query.blank? %>
|
45
|
+
"ordering": false,
|
46
|
+
<% elsif !@ordering.blank? %>
|
47
|
+
"order": [[ 1, "<%= @ordering %>" ]],
|
44
48
|
<% end %>
|
45
49
|
"processing": true,
|
46
50
|
"serverSide": true,
|
@@ -61,6 +65,7 @@ $(document).ready(function() {
|
|
61
65
|
<!-- When we don't know the total number of pages, we need to hide the legend and next button manually -->
|
62
66
|
<% if @max_nb_records.nil? %>
|
63
67
|
$('#accounts-table').on('draw.dt', function() {
|
68
|
+
$.noConflict();
|
64
69
|
var noMoreData = table.column(0)
|
65
70
|
.data()
|
66
71
|
.length == 0;
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<div class='form-group'>
|
5
5
|
<div class="col-sm-offset-2 col-sm-9">
|
6
6
|
<div class="checkbox">
|
7
|
-
<%=
|
7
|
+
<%= f.label :external do %>
|
8
8
|
<%= check_box_tag :external, '1', false, { :disabled => !@allowed_user.id.blank? } %>Managed externally (LDAP, Okta, etc.)?
|
9
9
|
<% end %>
|
10
10
|
</div>
|
@@ -17,9 +17,9 @@
|
|
17
17
|
</div>
|
18
18
|
</div>
|
19
19
|
<div class="form-group">
|
20
|
-
<%= f.
|
20
|
+
<%= f.label :password, 'Password', :class => 'col-sm-2 control-label' %>
|
21
21
|
<div class="col-sm-10">
|
22
|
-
<%=
|
22
|
+
<%= password_field_tag :password, nil, class:'form-control' %>
|
23
23
|
</div>
|
24
24
|
</div>
|
25
25
|
<div class="form-group">
|
@@ -44,8 +44,8 @@
|
|
44
44
|
</div>
|
45
45
|
<div class="form-group">
|
46
46
|
<%= label_tag :configuration, 'Configuration', :class => 'col-sm-2 control-label' %>
|
47
|
-
<div class="col-sm-
|
48
|
-
<textarea name="plugin_properties[raw_config]" id="raw_config" rows="
|
47
|
+
<div class="col-sm-6">
|
48
|
+
<textarea name="plugin_properties[raw_config]" id="raw_config" rows="20" class="form-control"></textarea>
|
49
49
|
</div>
|
50
50
|
</div>
|
51
51
|
|
@@ -170,9 +170,19 @@
|
|
170
170
|
/* Retrieve existing plugin properties for this tenant */
|
171
171
|
var existing_props = get_existing_tenant_plugin_properties(plugin_key);
|
172
172
|
|
173
|
-
//
|
173
|
+
// Try by plugin name for proprietary plugins
|
174
174
|
if (isBlank(existing_props) && !isBlank(plugin_name)) {
|
175
175
|
existing_props = get_existing_tenant_plugin_properties(plugin_name);
|
176
|
+
if (isBlank(existing_props)) {
|
177
|
+
// For proprietary plugins, the killbill- prefix likely doesn't exist (see Kaui::PluginHelper discussion)
|
178
|
+
plugin_name = plugin_name.replace('killbill-', '');
|
179
|
+
existing_props = get_existing_tenant_plugin_properties(plugin_name);
|
180
|
+
if (isBlank(existing_props)) {
|
181
|
+
// For proprietary plugins, our docs suggest acme:foo as the format for the plugin key, and often the plugin name becomes acme-foo
|
182
|
+
plugin_name = plugin_name.replace(':', '-');
|
183
|
+
existing_props = get_existing_tenant_plugin_properties(plugin_name);
|
184
|
+
}
|
185
|
+
}
|
176
186
|
}
|
177
187
|
|
178
188
|
return existing_props;
|
@@ -30,12 +30,13 @@
|
|
30
30
|
|
31
31
|
<thead>
|
32
32
|
<tr>
|
33
|
-
<th
|
34
|
-
<th
|
35
|
-
<th
|
36
|
-
<th
|
33
|
+
<th><%= I18n.translate('views.catalogs.show.plan_table.plan_id') %></th>
|
34
|
+
<th><%= I18n.translate('views.catalogs.show.plan_table.product') %></th>
|
35
|
+
<th><%= I18n.translate('views.catalogs.show.plan_table.category') %></th>
|
36
|
+
<th><%= I18n.translate('views.catalogs.show.plan_table.billing_period') %></th>
|
37
37
|
<th id="currency_select"></th>
|
38
|
-
<th
|
38
|
+
<th><%= I18n.translate('views.catalogs.show.plan_table.trial') %></th>
|
39
|
+
<th><%= I18n.translate('views.catalogs.show.plan_table.final_phase_duration') %></th>
|
39
40
|
<th></th>
|
40
41
|
</tr>
|
41
42
|
</thead>
|
@@ -72,6 +73,11 @@
|
|
72
73
|
{{#trial_length}} {{trial_length}} {{#humanized_time_unit}}{{trial_time_unit}}{{/humanized_time_unit}} {{/trial_length}}
|
73
74
|
{{^trial_length}} N/A {{/trial_length}}
|
74
75
|
</td>
|
76
|
+
|
77
|
+
<td>
|
78
|
+
{{final_phase_duration}}
|
79
|
+
</td>
|
80
|
+
|
75
81
|
<td><a class="btn btn-xs"
|
76
82
|
href="{{new_plan_currency_path}}"><i class="fa fa-plus-square"></i> currency</a></td>
|
77
83
|
</tr>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
</div>
|
8
8
|
<%= form_for @simple_plan, :url => {:action => :create_simple_plan}, :html => {:class => 'form-horizontal'} do |f| %>
|
9
9
|
|
10
|
-
<%=
|
10
|
+
<%= hidden_field_tag(:id, @tenant.id) %>
|
11
11
|
<div class="form-group" id="form_category">
|
12
12
|
<%= f.label :product_category, 'Product Category', :class => 'col-sm-3 control-label' %>
|
13
13
|
<div class="col-sm-4">
|
@@ -96,7 +96,7 @@
|
|
96
96
|
|
97
97
|
<div class="form-group">
|
98
98
|
<div class="col-sm-10">
|
99
|
-
<%= file_field_tag 'catalog', :class => 'form-control' %>
|
99
|
+
<%= file_field_tag 'catalog', :class => 'form-control', :required => true %>
|
100
100
|
</div>
|
101
101
|
</div>
|
102
102
|
<div class="form-group">
|
@@ -27,7 +27,7 @@
|
|
27
27
|
</tr>
|
28
28
|
</thead>
|
29
29
|
<tbody>
|
30
|
-
<%=
|
30
|
+
<%= hidden_field_tag(:id, @tenant.id) %>
|
31
31
|
|
32
32
|
<% @overdue.overdue_states.reverse.each_with_index do |state, idx| %>
|
33
33
|
<tr class="overdue_state_<%= state %>" id="tr_state_<%= idx %>">
|
@@ -71,7 +71,7 @@
|
|
71
71
|
|
72
72
|
<div class="form-group">
|
73
73
|
<div class="col-sm-10">
|
74
|
-
<%= file_field_tag 'overdue', :class => 'form-control' %>
|
74
|
+
<%= file_field_tag 'overdue', :class => 'form-control', :required => true %>
|
75
75
|
</div>
|
76
76
|
</div>
|
77
77
|
<div class="form-group">
|
@@ -6,7 +6,7 @@
|
|
6
6
|
</div>
|
7
7
|
<%= form_for @simple_plan, :url => {:action => :create_simple_plan}, :html => {:class => 'form-horizontal'} do |f| %>
|
8
8
|
|
9
|
-
<%=
|
9
|
+
<%= hidden_field_tag(:id, @tenant.id) %>
|
10
10
|
<div class="form-group">
|
11
11
|
<%= f.label :plan_id, 'Plan ID', :class => 'col-sm-3 control-label' %>
|
12
12
|
<div class="col-sm-4">
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<table class="transparent subtitle">
|
2
|
+
<tr>
|
3
|
+
<th>Bundle ID</th>
|
4
|
+
<td><%= bundle.bundle_id %></td>
|
5
|
+
</tr>
|
6
|
+
<% unless bundle.bundle_id == bundle.external_key %>
|
7
|
+
<tr>
|
8
|
+
<th>Bundle key</th>
|
9
|
+
<td><%= bundle.external_key %></td>
|
10
|
+
</tr>
|
11
|
+
<% end %>
|
12
|
+
</table>
|
@@ -10,19 +10,8 @@
|
|
10
10
|
|
11
11
|
<% @bundles.each_with_index do |bundle, idx| %>
|
12
12
|
<div class="row">
|
13
|
-
<div class="col-md-
|
14
|
-
|
15
|
-
<tr>
|
16
|
-
<th>Bundle ID</th>
|
17
|
-
<td><%= bundle.bundle_id %></td>
|
18
|
-
</tr>
|
19
|
-
<% unless bundle.bundle_id == bundle.external_key %>
|
20
|
-
<tr>
|
21
|
-
<th>Bundle key</th>
|
22
|
-
<td><%= bundle.external_key %></td>
|
23
|
-
</tr>
|
24
|
-
<% end %>
|
25
|
-
</table>
|
13
|
+
<div class="col-md-6">
|
14
|
+
<%= render :partial => Kaui.bundle_details_partial, :locals => { :bundle => bundle, :account => @account, :catalog => @catalog } %>
|
26
15
|
</div>
|
27
16
|
</div>
|
28
17
|
|
@@ -48,7 +37,7 @@
|
|
48
37
|
<%= render :partial => 'kaui/custom_fields/list_bar',
|
49
38
|
:locals => {:custom_fields => @custom_fields_per_bundle[bundle.bundle_id] || []} %>
|
50
39
|
|
51
|
-
<% if !
|
40
|
+
<% if !subscription_cancelled?(@subscription[bundle.bundle_id]) &&
|
52
41
|
(can?(:create, Kaui::Subscription) || can?(:transfer, Kaui::Subscription) || can?(:pause_resume, Kaui::Subscription)) %>
|
53
42
|
<div class="tag-select" onclick="void(0)">
|
54
43
|
<span><i class="fa fa-gift"></i><i class="fa fa-caret-down"></i></span>
|
@@ -2,24 +2,32 @@
|
|
2
2
|
<div class="col-md-8 col-md-offset-2">
|
3
3
|
|
4
4
|
<div class="column-block">
|
5
|
-
<h1>
|
5
|
+
<h1> <%= I18n.translate('transfer') %></h1>
|
6
6
|
|
7
7
|
<%= form_tag do_transfer_bundle_path(@bundle_id), :class => 'form-horizontal', :method => :put do %>
|
8
8
|
<div class="form-group">
|
9
|
-
<%= label_tag :new_account_key, '
|
9
|
+
<%= label_tag :new_account_key, I18n.translate('new_account'), :class => 'col-sm-2 control-label' %>
|
10
10
|
<div class="col-sm-10">
|
11
|
-
<%= text_field_tag :new_account_key, nil, :class => 'form-control', :placeholder => '
|
11
|
+
<%= text_field_tag :new_account_key, nil, :class => 'form-control', :placeholder => I18n.translate('new_account_id_or_external_key') %>
|
12
12
|
</div>
|
13
13
|
</div>
|
14
|
+
|
15
|
+
<div class="form-group">
|
16
|
+
<%= label_tag :billing_policy, I18n.translate('billing_policy'), :class => 'col-sm-2 control-label' %>
|
17
|
+
<div class="col-sm-10">
|
18
|
+
<%= select_tag :billing_policy, options_for_select(Kaui::Bundle.list_transfer_policy_params, selected: "IMMEDIATE") %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
|
14
22
|
<div class="form-group">
|
15
|
-
<%= label_tag :comment, '
|
23
|
+
<%= label_tag :comment, I18n.translate('comment'), :class => 'col-sm-2 control-label' %>
|
16
24
|
<div class="col-sm-10">
|
17
25
|
<%= text_area_tag :comment, nil, :rows => 3, :class => 'form-control' %>
|
18
26
|
</div>
|
19
27
|
</div>
|
20
28
|
<div class="form-group">
|
21
29
|
<div class="col-sm-offset-2 col-sm-10">
|
22
|
-
<%= submit_tag '
|
30
|
+
<%= submit_tag I18n.translate('change'), :class => 'btn btn-default' %>
|
23
31
|
</div>
|
24
32
|
</div>
|
25
33
|
<% end %>
|