kaui 0.15.5 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -37
- data/app/assets/javascripts/application.js +1 -2
- data/app/assets/javascripts/kaui/kaui.js +87 -0
- data/app/assets/stylesheets/{bootstrap_and_overrides.less → bootstrap_and_overrides.css.less} +6 -6
- data/app/assets/stylesheets/kaui/account.less +20 -0
- data/app/assets/stylesheets/kaui/kaui.less +3 -0
- data/app/assets/stylesheets/kaui/overdue.less +9 -0
- data/app/assets/stylesheets/kaui/payment.less +10 -0
- data/app/controllers/kaui/account_children_controller.rb +50 -0
- data/app/controllers/kaui/account_tags_controller.rb +4 -3
- data/app/controllers/kaui/account_timelines_controller.rb +1 -3
- data/app/controllers/kaui/accounts_controller.rb +160 -17
- data/app/controllers/kaui/admin_allowed_users_controller.rb +11 -5
- data/app/controllers/kaui/admin_controller.rb +16 -3
- data/app/controllers/kaui/admin_tenants_controller.rb +56 -8
- data/app/controllers/kaui/bundle_tags_controller.rb +4 -3
- data/app/controllers/kaui/bundles_controller.rb +12 -6
- data/app/controllers/kaui/charges_controller.rb +4 -1
- data/app/controllers/kaui/credits_controller.rb +1 -0
- data/app/controllers/kaui/engine_controller.rb +8 -11
- data/app/controllers/kaui/engine_controller_util.rb +30 -18
- data/app/controllers/kaui/invoices_controller.rb +19 -8
- data/app/controllers/kaui/payment_methods_controller.rb +20 -1
- data/app/controllers/kaui/payments_controller.rb +15 -9
- data/app/controllers/kaui/queues_controller.rb +8 -1
- data/app/controllers/kaui/refunds_controller.rb +7 -4
- data/app/controllers/kaui/registrations_controller.rb +15 -1
- data/app/controllers/kaui/sessions_controller.rb +2 -1
- data/app/controllers/kaui/subscriptions_controller.rb +27 -5
- data/app/controllers/kaui/tenants_controller.rb +1 -1
- data/app/controllers/kaui/transactions_controller.rb +11 -1
- data/app/helpers/kaui/account_helper.rb +7 -0
- data/app/helpers/kaui/date_helper.rb +30 -2
- data/app/helpers/kaui/locale_helper.rb +20 -0
- data/app/helpers/kaui/locale_helper.yml +581 -0
- data/app/helpers/kaui/payment_helper.rb +12 -0
- data/app/helpers/kaui/subscription_helper.rb +3 -3
- data/app/helpers/kaui/us_states_helper.rb +11 -0
- data/app/helpers/kaui/us_states_helper.yml +103 -0
- data/app/models/kaui/ability.rb +1 -1
- data/app/models/kaui/account.rb +1 -1
- data/app/models/kaui/admin.rb +11 -9
- data/app/models/kaui/allowed_user.rb +3 -4
- data/app/models/kaui/allowed_user_tenant.rb +2 -2
- data/app/models/kaui/application_record.rb +5 -0
- data/app/models/kaui/base.rb +1 -1
- data/app/models/kaui/bundle.rb +2 -2
- data/app/models/kaui/catalog.rb +4 -24
- data/app/models/kaui/chargeback.rb +0 -23
- data/app/models/kaui/credit.rb +0 -4
- data/app/models/kaui/invoice_item.rb +0 -4
- data/app/models/kaui/invoice_payment.rb +16 -21
- data/app/models/kaui/killbill_authenticatable.rb +2 -2
- data/app/models/kaui/overdue.rb +4 -0
- data/app/models/kaui/payment.rb +0 -3
- data/app/models/kaui/refund.rb +0 -5
- data/app/models/kaui/tenant.rb +1 -2
- data/app/models/kaui/user.rb +1 -3
- data/app/views/kaui/account_children/index.html.erb +47 -0
- data/app/views/kaui/accounts/_account_info.html.erb +16 -1
- data/app/views/kaui/accounts/_billing_info.html.erb +18 -9
- data/app/views/kaui/accounts/_form.html.erb +26 -18
- data/app/views/kaui/accounts/_link_parent_modal.html.erb +34 -0
- data/app/views/kaui/accounts/_parent.html.erb +16 -0
- data/app/views/kaui/accounts/_payment_methods.html.erb +3 -1
- data/app/views/kaui/accounts/index.html.erb +17 -2
- data/app/views/kaui/accounts/show.html.erb +6 -0
- data/app/views/kaui/admin/index.html.erb +1 -1
- data/app/views/kaui/admin_allowed_users/_form.html.erb +22 -0
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +12 -9
- data/app/views/kaui/admin_tenants/_show_catalog_xml.erb +1 -1
- data/app/views/kaui/admin_tenants/_show_overdue.erb +10 -0
- data/app/views/kaui/admin_tenants/new.html.erb +8 -4
- data/app/views/kaui/admin_tenants/new_catalog.html.erb +16 -4
- data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +25 -5
- data/app/views/kaui/bundles/index.html.erb +3 -0
- data/app/views/kaui/chargebacks/_form.html.erb +1 -1
- data/app/views/kaui/charges/_form.html.erb +11 -0
- data/app/views/kaui/credits/_form.html.erb +2 -2
- data/app/views/kaui/custom_fields/_list_bar.html.erb +12 -0
- data/app/views/kaui/invoice_items/_edit_form.html.erb +1 -1
- data/app/views/kaui/invoices/_invoice_table.html.erb +23 -18
- data/app/views/kaui/invoices/show.html.erb +9 -1
- data/app/views/kaui/layouts/kaui_navbar.html.erb +4 -1
- data/app/views/kaui/payment_methods/_form.html.erb +6 -0
- data/app/views/kaui/payment_methods/_payment_methods_table.html.erb +3 -1
- data/app/views/kaui/payment_methods/_plugin_properties.html.erb +77 -0
- data/app/views/kaui/payments/_form.html.erb +1 -1
- data/app/views/kaui/payments/_payment_table.html.erb +24 -15
- data/app/views/kaui/payments/show.html.erb +4 -1
- data/app/views/kaui/queues/index.html.erb +4 -4
- data/app/views/kaui/refunds/_form.html.erb +3 -2
- data/app/views/kaui/subscriptions/_edit_form.html.erb +3 -3
- data/app/views/kaui/subscriptions/_form.html.erb +3 -0
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +1 -1
- data/app/views/kaui/transactions/_control_plugin_names.html.erb +66 -0
- data/app/views/kaui/transactions/_form.html.erb +7 -1
- data/config/initializers/asset.rb +1 -0
- data/config/initializers/devise.rb +13 -7
- data/config/initializers/killbill_authenticatable.rb +1 -1
- data/config/locales/devise.en.yml +1 -1
- data/config/routes.rb +19 -1
- data/config/symmetric-encryption.yml +1 -1
- data/db/ddl.sql +40 -40
- data/db/migrate/20130812155313_devise_create_kaui_users.rb +12 -0
- data/db/migrate/20150109214021_create_kaui_tenants.rb +12 -0
- data/db/migrate/20150112232813_create_kaui_allowed_users.rb +19 -0
- data/lib/core_ext.rb +191 -0
- data/lib/kaui.rb +68 -5
- data/lib/kaui/engine.rb +11 -4
- data/lib/kaui/version.rb +1 -1
- data/test/dummy/app/controllers/application_controller.rb +1 -1
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +38 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/bin/yarn +11 -0
- data/test/dummy/config/application.rb +6 -53
- data/test/dummy/config/boot.rb +2 -9
- data/test/dummy/config/database.yml +15 -17
- data/test/dummy/config/environment.rb +4 -4
- data/test/dummy/config/environments/development.rb +42 -16
- data/test/dummy/config/environments/production.rb +62 -40
- data/test/dummy/config/environments/test.rb +26 -15
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +14 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +6 -5
- data/test/dummy/config/initializers/killbill_client.rb +1 -1
- data/test/dummy/config/initializers/mime_types.rb +0 -1
- data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +14 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/test/dummy/config/locales/en.yml +30 -2
- data/test/dummy/config/secrets.yml +32 -0
- data/test/dummy/config/symmetric-encryption.yml +1 -1
- data/test/dummy/db/schema.rb +1 -1
- data/{app/assets/images/kaui/.gitkeep → test/dummy/log/test.log} +0 -0
- data/test/functional/kaui/account_children_controller_test.rb +32 -0
- data/test/functional/kaui/account_tags_controller_test.rb +3 -3
- data/test/functional/kaui/accounts_controller_test.rb +127 -12
- data/test/functional/kaui/admin_allowed_users_controller_test.rb +151 -1
- data/test/functional/kaui/admin_controller_test.rb +45 -0
- data/test/functional/kaui/admin_tenants_controller_test.rb +127 -0
- data/test/functional/kaui/bundle_tags_controller_test.rb +3 -3
- data/test/functional/kaui/bundles_controller_test.rb +27 -0
- data/test/functional/kaui/chargebacks_controller_test.rb +1 -1
- data/test/functional/kaui/custom_fields_controller_test.rb +10 -3
- data/test/functional/kaui/functional_test_helper.rb +1 -1
- data/test/functional/kaui/functional_test_helper_nosetup.rb +66 -1
- data/test/functional/kaui/home_controller_test.rb +9 -0
- data/test/functional/kaui/invoices_controller_test.rb +8 -0
- data/test/functional/kaui/login_proxy_controller_test.rb +12 -0
- data/test/functional/kaui/payment_methods_controller_test.rb +23 -0
- data/test/functional/kaui/payments_controller_test.rb +15 -1
- data/test/functional/kaui/queues_controller_test.rb +17 -0
- data/test/functional/kaui/registrations_controller_test.rb +49 -0
- data/test/functional/kaui/role_definitions_controller_test.rb +47 -0
- data/test/functional/kaui/subscriptions_controller_test.rb +39 -0
- data/test/functional/kaui/tenants_controller_test.rb +6 -0
- data/test/functional/kaui/transactions_controller_test.rb +36 -3
- data/test/integration/kaui/date_helper_integration_test.rb +16 -0
- data/test/integration/kaui/navigation_test.rb +11 -5
- data/test/killbill_test_helper.rb +24 -3
- data/test/test_helper.rb +3 -0
- data/test/unit/kaui/account_email_test.rb +3 -3
- data/test/unit/kaui/date_helper_test.rb +14 -2
- data/test/unit/kaui/money_helper_test.rb +1 -1
- metadata +327 -147
- data/.gitignore +0 -18
- data/.travis.yml +0 -37
- data/Gemfile +0 -6
- data/bin/kaui +0 -4
- data/kaui.gemspec +0 -65
- data/script/rails +0 -8
- data/script/sandbox +0 -30
- data/test/dummy/.gitignore +0 -1
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '02096d784525a4eaa7d45645e56699a9c7913ee9'
|
4
|
+
data.tar.gz: 584dd82a66ca09755b318672908b013b7592c4d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2e52f6432a66ce3a535bf6c62522f475e7dfa254ae34621498f89cae7b4edf7ea8087c730968778d92bbb96991a8036e96569cf4cdee71bf0e6a39805596b3f
|
7
|
+
data.tar.gz: 6259714f3f8fc9263de0fcdb7eaf72254a0645707f99a7f7db8f219b04b809a240f7dd9223d1cd73aa75b43bf494d351548c3a9c10b9013530359c3a0a1b71c7
|
data/README.md
CHANGED
@@ -9,23 +9,32 @@ Kill Bill compatibility
|
|
9
9
|
| Kaui version | Kill Bill version |
|
10
10
|
| -----------: | ----------------: |
|
11
11
|
| 0.14.y | 0.16.z |
|
12
|
-
| 0.15.y | 0.18.z
|
12
|
+
| 0.15.y | 0.18.z (Rails 4) |
|
13
|
+
| 0.16.y | 0.18.z (Rails 5) |
|
14
|
+
|
15
|
+
|
16
|
+
Dependencies
|
17
|
+
------------
|
18
|
+
|
19
|
+
Ruby 2.2.2+ or JRuby 9.1.9.0+ required.
|
13
20
|
|
14
21
|
Running Kaui locally
|
15
22
|
---------------------
|
16
23
|
|
17
24
|
You can run Kaui locally by using the test/dummy app provided:
|
25
|
+
|
18
26
|
```
|
19
|
-
bundle install
|
20
|
-
cd test/dummy
|
21
27
|
export RAILS_ENV=development
|
22
28
|
bundle install
|
23
|
-
|
24
|
-
|
25
|
-
bundle exec rake assets:precompile
|
26
|
-
rails server
|
29
|
+
rails db:migrate
|
30
|
+
rails s
|
27
31
|
```
|
28
32
|
|
33
|
+
The Kill Bill URL can be configured through the `KILLBILL_URL` environment variable, e.g.
|
34
|
+
|
35
|
+
```
|
36
|
+
KILLBILL_URL='http://killbill.acme:8080'
|
37
|
+
```
|
29
38
|
|
30
39
|
Mounting Kaui into your own Rails app
|
31
40
|
-------------------------------------
|
@@ -35,44 +44,23 @@ The Kaui gem comes with a `kaui` script to mount it in your existing Rails app.
|
|
35
44
|
Kaui expects the container app to define the <tt>current_user</tt> method, which returns the
|
36
45
|
name of the logged-in user. This is used by Kill Bill for auditing purposes.
|
37
46
|
|
38
|
-
|
39
|
-
The default login credentials are admin/password. Users, Credentials, Roles and Permissions are
|
40
|
-
passed through to Kill Bill. It uses Basic Auth by default, but the backend is pluggable (LDAP,
|
41
|
-
ActiveDirectory, etc.).
|
42
|
-
|
43
|
-
|
44
|
-
Configuration
|
45
|
-
-------------
|
46
|
-
|
47
|
-
Specify your Kill Bill server url, api key and secret in ```config/initializers/killbill_client.rb```:
|
47
|
+
Migrations can be copied over to your app via:
|
48
48
|
|
49
49
|
```
|
50
|
-
|
50
|
+
bundle exec rake kaui:install:migrations
|
51
51
|
```
|
52
52
|
|
53
|
-
|
53
|
+
Finally, a Kill Bill server needs to be running for Kaui to fetch its information (see the Configuration section below).
|
54
|
+
The default login credentials are admin/password. Users, Credentials, Roles and Permissions are
|
55
|
+
passed through to Kill Bill. It uses Basic Auth by default, but the backend is pluggable (LDAP,
|
56
|
+
ActiveDirectory, etc.).
|
54
57
|
|
55
58
|
|
56
59
|
Running tests
|
57
60
|
-------------
|
58
61
|
|
59
|
-
Go into 'test/dummy':
|
60
62
|
```
|
61
|
-
|
62
|
-
```
|
63
|
-
|
64
|
-
Run migrations:
|
65
|
-
```
|
66
|
-
export RAILS_ENV=test
|
67
|
-
rake kaui:install:migrations
|
68
|
-
rake db:migrate
|
69
|
-
```
|
70
|
-
|
71
|
-
Run the tests:
|
72
|
-
(Move back to top level)
|
73
|
-
```
|
74
|
-
cd ../..
|
75
|
-
rake test
|
63
|
+
rails t
|
76
64
|
```
|
77
65
|
|
78
66
|
Note: functional and integration tests require an instance of Kill Bill to test against.
|
@@ -99,7 +87,7 @@ Then, install and run it from a local directory:
|
|
99
87
|
Alternatively, you can run the `kaui` script under `bin` by setting your loadpath correctly:
|
100
88
|
|
101
89
|
ruby -Ilib bin/kaui /path/to/rails/app --path=$PWD --skip-bundle
|
102
|
-
|
90
|
+
|
103
91
|
Releases
|
104
92
|
========
|
105
93
|
|
@@ -123,7 +111,7 @@ Those roles and permissions are defined the same way other permissions are defin
|
|
123
111
|
* TENANT_CAN_VIEW
|
124
112
|
* TENANT_CAN_CREATE
|
125
113
|
* OVERDUE_CAN_UPLOAD
|
126
|
-
* CATALOG_CAN_UPLOAD
|
114
|
+
* CATALOG_CAN_UPLOAD
|
127
115
|
|
128
116
|
The [enforcement in KAUI](https://github.com/killbill/killbill-admin-ui/blob/master/app/models/kaui/ability.rb) is based on the CanCan gem.
|
129
117
|
|
@@ -6,11 +6,10 @@
|
|
6
6
|
//
|
7
7
|
//= require js-routes
|
8
8
|
//= require jquery
|
9
|
-
//= require jquery-ui/autocomplete
|
9
|
+
//= require jquery-ui/widgets/autocomplete
|
10
10
|
//= require jquery_ujs
|
11
11
|
//= require dataTables/jquery.dataTables
|
12
12
|
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
|
13
|
-
//= require d3
|
14
13
|
//= require twitter/bootstrap
|
15
14
|
//= require bootstrap-datepicker
|
16
15
|
//= require kaui/bootstrap-tweaks
|
@@ -96,4 +96,91 @@ jQuery(document).ready(function ($) {
|
|
96
96
|
}
|
97
97
|
});
|
98
98
|
|
99
|
+
/*
|
100
|
+
* Toggle between combobox (US only) and text when entering the state.
|
101
|
+
*/
|
102
|
+
$('#account_country').on('change', function(e){
|
103
|
+
toggle_state_input_type($('#account_country').val());
|
104
|
+
});
|
105
|
+
|
106
|
+
function toggle_state_input_type(state){
|
107
|
+
if (state == 'US'){
|
108
|
+
$('.text-state').hide().attr('name','hide');
|
109
|
+
$('.select-state').show().attr('name','account[state]');
|
110
|
+
}else{
|
111
|
+
$('.select-state').hide().attr('name','hide');
|
112
|
+
$('.text-state').show().attr('name','account[state]');
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
toggle_state_input_type($('#account_country').val());
|
117
|
+
|
118
|
+
/*
|
119
|
+
* Calculate first name length
|
120
|
+
*/
|
121
|
+
$('#account_name').on('keyup', function(e){
|
122
|
+
set_first_name_length($(this).val());
|
123
|
+
});
|
124
|
+
|
125
|
+
$('#account_name').on('change', function(e){
|
126
|
+
if ($('#account_first_name_length').empty() ){
|
127
|
+
set_first_name_length($(this).val());
|
128
|
+
}
|
129
|
+
});
|
130
|
+
|
131
|
+
function set_first_name_length(name){
|
132
|
+
var name_in_parts = name.trim().split(' ');
|
133
|
+
|
134
|
+
if (name_in_parts.length > 1){
|
135
|
+
$('#account_first_name_length').val(name_in_parts[0].length);
|
136
|
+
}else{
|
137
|
+
$('#account_first_name_length').val('');
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
/*
|
142
|
+
* Validate external key
|
143
|
+
*/
|
144
|
+
const VALIDATE_EXTERNAL_KEY = {
|
145
|
+
account: { url: Routes.kaui_engine_accounts_validate_external_key_path(), invalid_msg_class_name: '.account_external_key_invalid_msg' },
|
146
|
+
payment_method: {url: Routes.kaui_engine_payment_methods_validate_external_key_path(), invalid_msg_class_name: '.payment_method_external_key_invalid_msg'},
|
147
|
+
subscription: {url: Routes.kaui_engine_subscriptions_validate_external_key_path(), invalid_msg_class_name: '.subscription_external_key_invalid_msg'}
|
148
|
+
}
|
149
|
+
|
150
|
+
validate_external_key($('#account_external_key').val(),'account');
|
151
|
+
$('#account_external_key').on('change', function(e){
|
152
|
+
validate_external_key($(this).val(),'account');
|
153
|
+
});
|
154
|
+
|
155
|
+
validate_external_key($('#payment_method_external_key').val(),'payment_method');
|
156
|
+
$('#payment_method_external_key').on('change', function(e){
|
157
|
+
validate_external_key($(this).val(),'payment_method');
|
158
|
+
});
|
159
|
+
|
160
|
+
validate_external_key($('#external_key').val(),'subscription');
|
161
|
+
$('#external_key').on('change', function(e){
|
162
|
+
validate_external_key($(this).val(),'subscription');
|
163
|
+
});
|
164
|
+
|
165
|
+
function validate_external_key(external_key, key_for){
|
166
|
+
if (external_key == undefined || external_key == null || external_key.trim().length == 0){
|
167
|
+
$(VALIDATE_EXTERNAL_KEY[key_for].invalid_msg_class_name).hide();
|
168
|
+
}else {
|
169
|
+
$.ajax(
|
170
|
+
{
|
171
|
+
url: VALIDATE_EXTERNAL_KEY[key_for].url,
|
172
|
+
type: "GET",
|
173
|
+
dataType: "json",
|
174
|
+
data: {external_key: external_key},
|
175
|
+
success: function (data) {
|
176
|
+
if (data.is_found) {
|
177
|
+
$(VALIDATE_EXTERNAL_KEY[key_for].invalid_msg_class_name).show();
|
178
|
+
} else {
|
179
|
+
$(VALIDATE_EXTERNAL_KEY[key_for].invalid_msg_class_name).hide();
|
180
|
+
}
|
181
|
+
}
|
182
|
+
});
|
183
|
+
}
|
184
|
+
}
|
185
|
+
|
99
186
|
})
|
data/app/assets/stylesheets/{bootstrap_and_overrides.less → bootstrap_and_overrides.css.less}
RENAMED
@@ -12,16 +12,16 @@
|
|
12
12
|
@fontAwesomeSvgPath: font-url("fontawesome-webfont.svg#fontawesomeregular");
|
13
13
|
|
14
14
|
// Font Awesome
|
15
|
-
@import "
|
15
|
+
@import "font-awesome.css";
|
16
16
|
|
17
17
|
/* Override Bootstrap 3 font locations */
|
18
18
|
@font-face {
|
19
19
|
font-family: 'Glyphicons Halflings';
|
20
|
-
src: url('
|
21
|
-
src: url('
|
22
|
-
url('
|
23
|
-
url('
|
24
|
-
url('
|
20
|
+
src: image-url('glyphicons-halflings-regular.eot');
|
21
|
+
src: image-url('glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
|
22
|
+
image-url('glyphicons-halflings-regular.woff') format('woff'),
|
23
|
+
image-url('glyphicons-halflings-regular.ttf') format('truetype'),
|
24
|
+
image-url('glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
|
25
25
|
}
|
26
26
|
|
27
27
|
// Glyphicons
|
@@ -0,0 +1,20 @@
|
|
1
|
+
h1 span.account-child-label{
|
2
|
+
float: right;
|
3
|
+
}
|
4
|
+
|
5
|
+
.account-child-label{
|
6
|
+
color: white !important;
|
7
|
+
}
|
8
|
+
|
9
|
+
.naked {
|
10
|
+
background-color: transparent;
|
11
|
+
color: #00919d;
|
12
|
+
padding: 0;
|
13
|
+
font-size: inherit;
|
14
|
+
}
|
15
|
+
|
16
|
+
.naked:hover{
|
17
|
+
background-color: transparent;
|
18
|
+
color: #2a6496;
|
19
|
+
|
20
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
class Kaui::AccountChildrenController < Kaui::EngineController
|
3
|
+
|
4
|
+
def index
|
5
|
+
|
6
|
+
# check that the required parent account id is provided and get its data
|
7
|
+
begin
|
8
|
+
@account = Kaui::Account::find_by_id(params.require(:account_id), false, false, options_for_klient)
|
9
|
+
rescue KillBillClient::API::NotFound
|
10
|
+
flash[:error] = "Invalid parent account id supplied #{params.require(:account_id)}"
|
11
|
+
redirect_to kaui_engine.home_path and return
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
# It will fetch all the children. It use the paginate to fetch all children as permitting for future exchange
|
17
|
+
# when killbill account/{account_id}/children endpoint includes offset and limit parameters.
|
18
|
+
def pagination
|
19
|
+
|
20
|
+
searcher = lambda do |parent_account_id, offset, limit|
|
21
|
+
Kaui::Account.find_children(parent_account_id, true, true, 'NONE', options_for_klient)
|
22
|
+
end
|
23
|
+
|
24
|
+
data_extractor = lambda do |account_child, column|
|
25
|
+
[
|
26
|
+
account_child.name,
|
27
|
+
account_child.account_id,
|
28
|
+
account_child.external_key,
|
29
|
+
account_child.account_balance,
|
30
|
+
account_child.city,
|
31
|
+
account_child.country
|
32
|
+
][column]
|
33
|
+
end
|
34
|
+
|
35
|
+
formatter = lambda do |account_child|
|
36
|
+
[
|
37
|
+
view_context.link_to(account_child.name || '(not set)', account_path(account_child.account_id)),
|
38
|
+
view_context.truncate_uuid(account_child.account_id),
|
39
|
+
account_child.external_key,
|
40
|
+
view_context.humanized_money_with_symbol(account_child.balance_to_money),
|
41
|
+
account_child.city,
|
42
|
+
account_child.country
|
43
|
+
]
|
44
|
+
end
|
45
|
+
|
46
|
+
paginate searcher, data_extractor, formatter
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
@@ -3,10 +3,11 @@ class Kaui::AccountTagsController < Kaui::EngineController
|
|
3
3
|
def edit
|
4
4
|
@account_id = params.require(:account_id)
|
5
5
|
|
6
|
-
fetch_tag_names =
|
7
|
-
fetch_available_tags =
|
6
|
+
fetch_tag_names = promise { (Kaui::Tag.all_for_account(@account_id, false, 'NONE', options_for_klient).map { |tag| tag.tag_definition_name }).sort }
|
7
|
+
fetch_available_tags = promise { Kaui::TagDefinition.all_for_account(options_for_klient) }
|
8
8
|
|
9
|
-
|
9
|
+
@tag_names = wait(fetch_tag_names)
|
10
|
+
@available_tags = wait(fetch_available_tags)
|
10
11
|
end
|
11
12
|
|
12
13
|
def update
|
@@ -25,9 +25,7 @@ class Kaui::AccountTimelinesController < Kaui::EngineController
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
@selected_bundle = @bundle_names[params[:external_key]]
|
30
|
-
end
|
28
|
+
@selected_bundle = params.has_key?(:external_key) ? @bundle_names[params[:external_key]] : nil
|
31
29
|
end
|
32
30
|
|
33
31
|
private
|
@@ -27,6 +27,7 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
27
27
|
|
28
28
|
data_extractor = lambda do |account, column|
|
29
29
|
[
|
30
|
+
account.parent_account_id,
|
30
31
|
account.name,
|
31
32
|
account.account_id,
|
32
33
|
account.external_key,
|
@@ -38,6 +39,7 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
38
39
|
|
39
40
|
formatter = lambda do |account|
|
40
41
|
[
|
42
|
+
account.parent_account_id.nil? ? 0 : 1,
|
41
43
|
view_context.link_to(account.name || '(not set)', view_context.url_for(:action => :show, :account_id => account.account_id)),
|
42
44
|
view_context.truncate_uuid(account.account_id),
|
43
45
|
account.external_key,
|
@@ -59,10 +61,10 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
59
61
|
|
60
62
|
# Transform "1" into boolean
|
61
63
|
@account.is_migrated = @account.is_migrated == '1'
|
62
|
-
@account.is_notified_for_invoices = @account.is_notified_for_invoices == '1'
|
63
64
|
|
64
65
|
begin
|
65
66
|
@account = @account.create(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
67
|
+
|
66
68
|
redirect_to account_path(@account.account_id), :notice => 'Account was successfully created'
|
67
69
|
rescue => e
|
68
70
|
flash.now[:error] = "Error while creating account: #{as_string(e)}"
|
@@ -71,15 +73,73 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
71
73
|
end
|
72
74
|
|
73
75
|
def show
|
76
|
+
# Go to the database once
|
77
|
+
cached_options_for_klient = options_for_klient
|
78
|
+
|
74
79
|
# Re-fetch the account with balance and CBA
|
75
|
-
@account = Kaui::Account::find_by_id_or_key(params.require(:account_id), true, true,
|
80
|
+
@account = Kaui::Account::find_by_id_or_key(params.require(:account_id), true, true, cached_options_for_klient)
|
81
|
+
|
82
|
+
fetch_children = promise { @account.children(false, false, 'NONE',cached_options_for_klient)}
|
83
|
+
fetch_parent = promise (!@account.parent_account_id.nil?){ Kaui::Account::find_by_id(@account.parent_account_id,false,false,cached_options_for_klient)}
|
84
|
+
fetch_overdue_state = promise { @account.overdue(cached_options_for_klient) }
|
85
|
+
fetch_account_tags = promise { @account.tags(false, 'NONE', cached_options_for_klient).sort { |tag_a, tag_b| tag_a <=> tag_b } }
|
86
|
+
fetch_account_fields = promise { @account.custom_fields('NONE', cached_options_for_klient).sort { |cf_a, cf_b| cf_a.name.downcase <=> cf_b.name.downcase } }
|
87
|
+
fetch_account_emails = promise { Kaui::AccountEmail.find_all_sorted_by_account_id(@account.account_id, 'NONE', cached_options_for_klient) }
|
88
|
+
fetch_payments = promise { @account.payments(cached_options_for_klient).map! { |payment| Kaui::Payment.build_from_raw_payment(payment) } }
|
89
|
+
fetch_payment_methods = promise(false) { Kaui::PaymentMethod.find_all_by_account_id(@account.account_id, false, cached_options_for_klient) }
|
90
|
+
|
91
|
+
# is email notification plugin available
|
92
|
+
is_email_notifications_plugin_available = Kenui::EmailNotificationService.email_notification_plugin_available?(cached_options_for_klient).first
|
93
|
+
fetch_email_notification_configuration = promise(is_email_notifications_plugin_available) do
|
94
|
+
Kenui::EmailNotificationService.get_configuration_per_account(params.require(:account_id),cached_options_for_klient)
|
95
|
+
end.then do |configuration|
|
96
|
+
if configuration.first.is_a?(FalseClass)
|
97
|
+
Rails.logger.warn(configuration[1])
|
98
|
+
configuration = []
|
99
|
+
end
|
100
|
+
configuration
|
101
|
+
end
|
102
|
+
|
103
|
+
fetch_payment_methods_with_details = fetch_payment_methods.then do |pms|
|
104
|
+
ops = []
|
105
|
+
pms.each do |pm|
|
106
|
+
ops << promise(false) {
|
107
|
+
begin
|
108
|
+
Kaui::PaymentMethod.find_by_id(pm.payment_method_id, true, cached_options_for_klient)
|
109
|
+
rescue => e
|
110
|
+
# Maybe the plugin is not registered or the plugin threw an exception
|
111
|
+
Rails.logger.warn(e)
|
112
|
+
nil
|
113
|
+
end
|
114
|
+
}
|
115
|
+
end
|
116
|
+
ops
|
117
|
+
end
|
118
|
+
fetch_available_tags = promise { Kaui::TagDefinition.all_for_account(cached_options_for_klient) }
|
119
|
+
|
120
|
+
@overdue_state = wait(fetch_overdue_state)
|
121
|
+
@tags = wait(fetch_account_tags)
|
122
|
+
@custom_fields = wait(fetch_account_fields)
|
123
|
+
@account_emails = wait(fetch_account_emails)
|
124
|
+
wait(fetch_payment_methods)
|
125
|
+
@payment_methods = wait(fetch_payment_methods_with_details).map { |pm_f| pm_f.execute }.map { |pm_f| wait(pm_f) }.reject { |pm| pm.nil? }
|
126
|
+
@available_tags = wait(fetch_available_tags)
|
127
|
+
@children = wait(fetch_children)
|
128
|
+
@account_parent = wait(fetch_parent) unless @account.parent_account_id.nil?
|
129
|
+
@email_notification_configuration = wait(fetch_email_notification_configuration) if is_email_notifications_plugin_available
|
130
|
+
|
131
|
+
@last_transaction_by_payment_method_id = {}
|
132
|
+
wait(fetch_payments).each do |payment|
|
133
|
+
transaction = payment.transactions.last
|
134
|
+
transaction_date = Date.parse(transaction.effective_date)
|
135
|
+
|
136
|
+
last_seen_transaction_date = @last_transaction_by_payment_method_id[payment.payment_method_id]
|
137
|
+
if last_seen_transaction_date.nil? || Date.parse(last_seen_transaction_date.effective_date) < transaction_date
|
138
|
+
@last_transaction_by_payment_method_id[payment.payment_method_id] = transaction
|
139
|
+
end
|
140
|
+
end
|
76
141
|
|
77
|
-
|
78
|
-
fetch_account_tags = lambda { @tags = @account.tags(false, 'NONE', options_for_klient).sort { |tag_a, tag_b| tag_a <=> tag_b } }
|
79
|
-
fetch_account_emails = lambda { @account_emails = Kaui::AccountEmail.find_all_sorted_by_account_id(@account.account_id, 'NONE', options_for_klient) }
|
80
|
-
fetch_payment_methods = lambda { @payment_methods = Kaui::PaymentMethod.find_all_safely_by_account_id(@account.account_id, options_for_klient) }
|
81
|
-
fetch_available_tags = lambda { @available_tags = Kaui::TagDefinition.all_for_account(options_for_klient) }
|
82
|
-
run_in_parallel fetch_overdue_state, fetch_account_tags, fetch_account_emails, fetch_payment_methods, fetch_available_tags
|
142
|
+
params.permit!
|
83
143
|
end
|
84
144
|
|
85
145
|
def trigger_invoice
|
@@ -124,7 +184,6 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
124
184
|
|
125
185
|
# Transform "1" into boolean
|
126
186
|
@account.is_migrated = @account.is_migrated == '1'
|
127
|
-
@account.is_notified_for_invoices = @account.is_notified_for_invoices == '1'
|
128
187
|
|
129
188
|
@account.update(true, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
130
189
|
|
@@ -143,14 +202,6 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
143
202
|
redirect_to account_path(account_id), :notice => "Successfully set #{payment_method_id} as default"
|
144
203
|
end
|
145
204
|
|
146
|
-
def toggle_email_notifications
|
147
|
-
account = Kaui::Account.new(:account_id => params.require(:account_id), :is_notified_for_invoices => params[:is_notified] == 'true')
|
148
|
-
|
149
|
-
account.update_email_notifications(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
150
|
-
|
151
|
-
redirect_to account_path(account.account_id), :notice => 'Email preferences updated'
|
152
|
-
end
|
153
|
-
|
154
205
|
def pay_all_invoices
|
155
206
|
payment = Kaui::InvoicePayment.new(:account_id => params.require(:account_id))
|
156
207
|
|
@@ -158,4 +209,96 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
158
209
|
|
159
210
|
redirect_to account_path(payment.account_id), :notice => 'Successfully triggered a payment for all unpaid invoices'
|
160
211
|
end
|
212
|
+
|
213
|
+
def validate_external_key
|
214
|
+
external_key = params.require(:external_key)
|
215
|
+
|
216
|
+
begin
|
217
|
+
account = Kaui::Account::find_by_external_key(external_key, false, false, options_for_klient)
|
218
|
+
rescue KillBillClient::API::NotFound
|
219
|
+
account = nil
|
220
|
+
end
|
221
|
+
render json: {:is_found => !account.nil?}
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
def link_to_parent
|
226
|
+
@account = Kaui::Account.new(params.require(:account).delete_if { |key, value| value.blank? })
|
227
|
+
@account.account_id = params.require(:account_id)
|
228
|
+
@account.is_payment_delegated_to_parent = @account.is_payment_delegated_to_parent == '1'
|
229
|
+
|
230
|
+
raise('Account id and account parent id cannot be equal.') if @account.account_id == @account.parent_account_id
|
231
|
+
|
232
|
+
# check if parent id is valid
|
233
|
+
Kaui::Account.find_by_id(@account.parent_account_id,false,false,options_for_klient)
|
234
|
+
|
235
|
+
@account.update(false, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
236
|
+
|
237
|
+
redirect_to account_path(@account.account_id), :notice => 'Account successfully updated'
|
238
|
+
rescue => e
|
239
|
+
if e.is_a?(KillBillClient::API::NotFound)
|
240
|
+
flash[:error] = "Parent account id not found: #{@account.parent_account_id}"
|
241
|
+
else
|
242
|
+
flash[:error] = "Error while linking parent account: #{as_string(e)}"
|
243
|
+
end
|
244
|
+
redirect_to account_path(@account.account_id)
|
245
|
+
end
|
246
|
+
|
247
|
+
def unlink_to_parent
|
248
|
+
account_id = params.require(:account_id)
|
249
|
+
|
250
|
+
# search for the account and remove the parent account id
|
251
|
+
# check if parent id is valid
|
252
|
+
account = Kaui::Account.find_by_id(account_id,false,false,options_for_klient)
|
253
|
+
account.is_payment_delegated_to_parent = false
|
254
|
+
account.parent_account_id = nil
|
255
|
+
account.update(true, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
256
|
+
|
257
|
+
redirect_to account_path(@account.account_id), :notice => 'Account successfully updated'
|
258
|
+
rescue => e
|
259
|
+
flash[:error] = "Error while un-linking parent account: #{as_string(e)}"
|
260
|
+
redirect_to account_path(@account.account_id)
|
261
|
+
end
|
262
|
+
|
263
|
+
def set_email_notifications_configuration
|
264
|
+
configuration = params.require(:configuration)
|
265
|
+
account_id = configuration[:account_id]
|
266
|
+
event_types = configuration[:event_types]
|
267
|
+
cached_options_for_klient = options_for_klient
|
268
|
+
|
269
|
+
is_success, message = email_notification_plugin_available?(cached_options_for_klient)
|
270
|
+
|
271
|
+
is_success, message = Kenui::EmailNotificationService.set_configuration_per_account(account_id,
|
272
|
+
event_types,
|
273
|
+
current_user.kb_username,
|
274
|
+
params[:reason],
|
275
|
+
params[:comment],
|
276
|
+
cached_options_for_klient) if is_success
|
277
|
+
if is_success
|
278
|
+
flash[:notice] = message
|
279
|
+
else
|
280
|
+
flash[:error] = message
|
281
|
+
end
|
282
|
+
redirect_to account_path(account_id)
|
283
|
+
end
|
284
|
+
|
285
|
+
def events_to_consider
|
286
|
+
data = Kenui::EmailNotificationService.get_events_to_consider(options_for_klient)
|
287
|
+
|
288
|
+
respond_to do |format|
|
289
|
+
format.json { render json: { data: data} }
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
private
|
294
|
+
|
295
|
+
def email_notification_plugin_available?(options_for_klient)
|
296
|
+
error_message = 'Email notification plugin is not installed'
|
297
|
+
|
298
|
+
is_available = Kenui::EmailNotificationService.email_notification_plugin_available?(options_for_klient).first
|
299
|
+
return is_available, is_available ? nil : error_message
|
300
|
+
rescue => e
|
301
|
+
return false, error_message
|
302
|
+
end
|
303
|
+
|
161
304
|
end
|