kaui 0.6.6 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/Gemfile.lock +51 -37
- data/README.md +5 -0
- data/Rakefile +1 -1
- data/app/controllers/kaui/account_emails_controller.rb +26 -44
- data/app/controllers/kaui/account_tags_controller.rb +26 -38
- data/app/controllers/kaui/account_timelines_controller.rb +47 -50
- data/app/controllers/kaui/accounts_controller.rb +68 -148
- data/app/controllers/kaui/bundle_tags_controller.rb +32 -21
- data/app/controllers/kaui/bundles_controller.rb +44 -69
- data/app/controllers/kaui/chargebacks_controller.rb +31 -61
- data/app/controllers/kaui/charges_controller.rb +19 -21
- data/app/controllers/kaui/credits_controller.rb +22 -36
- data/app/controllers/kaui/custom_fields_controller.rb +15 -13
- data/app/controllers/kaui/engine_controller.rb +8 -10
- data/app/controllers/kaui/invoice_items_controller.rb +24 -41
- data/app/controllers/kaui/invoices_controller.rb +36 -46
- data/app/controllers/kaui/payment_methods_controller.rb +84 -28
- data/app/controllers/kaui/payments_controller.rb +64 -26
- data/app/controllers/kaui/refunds_controller.rb +27 -107
- data/app/controllers/kaui/subscriptions_controller.rb +88 -132
- data/app/controllers/kaui/tag_definitions_controller.rb +32 -79
- data/app/controllers/kaui/tags_controller.rb +16 -14
- data/app/controllers/kaui/transactions_controller.rb +25 -0
- data/app/helpers/kaui/money_helper.rb +8 -0
- data/app/helpers/kaui/subscription_helper.rb +115 -0
- data/app/helpers/kaui/uuid_helper.rb +9 -0
- data/app/models/kaui/ability.rb +2 -2
- data/app/models/kaui/account.rb +25 -42
- data/app/models/kaui/account_email.rb +11 -48
- data/app/models/kaui/account_timeline.rb +1 -5
- data/app/models/kaui/audit_log.rb +1 -15
- data/app/models/kaui/base.rb +1 -126
- data/app/models/kaui/bundle.rb +47 -14
- data/app/models/kaui/catalog.rb +2 -0
- data/app/models/kaui/chargeback.rb +24 -36
- data/app/models/kaui/credit.rb +5 -20
- data/app/models/kaui/custom_field.rb +9 -5
- data/app/models/kaui/invoice.rb +9 -53
- data/app/models/kaui/invoice_item.rb +8 -18
- data/app/models/kaui/invoice_payment.rb +24 -0
- data/app/models/kaui/payment.rb +14 -32
- data/app/models/kaui/payment_method.rb +36 -0
- data/app/models/kaui/rails_methods.rb +7 -9
- data/app/models/kaui/refund.rb +5 -20
- data/app/models/kaui/subscription.rb +7 -27
- data/app/models/kaui/tag.rb +10 -6
- data/app/models/kaui/tag_definition.rb +26 -34
- data/app/models/kaui/transaction.rb +30 -0
- data/app/models/kaui/user.rb +2 -0
- data/app/views/kaui/account_emails/_form.html.erb +8 -28
- data/app/views/kaui/account_emails/show.html.erb +10 -10
- data/app/views/kaui/account_tags/_account_tags_table.html.erb +20 -18
- data/app/views/kaui/account_tags/_form.html.erb +42 -0
- data/app/views/kaui/account_tags/edit.html.erb +1 -41
- data/app/views/kaui/account_tags/show.html.erb +6 -3
- data/app/views/kaui/account_timelines/show.html.erb +273 -302
- data/app/views/kaui/accounts/_form.html.erb +116 -0
- data/app/views/kaui/accounts/index.html.erb +13 -11
- data/app/views/kaui/accounts/new.html.erb +5 -0
- data/app/views/kaui/accounts/show.html.erb +101 -99
- data/app/views/kaui/bundle_tags/_bundle_tags_table.html.erb +29 -9
- data/app/views/kaui/bundle_tags/_form.html.erb +41 -0
- data/app/views/kaui/bundle_tags/edit.html.erb +2 -34
- data/app/views/kaui/bundle_tags/show.html.erb +6 -0
- data/app/views/kaui/bundles/index.html.erb +9 -9
- data/app/views/kaui/bundles/show.html.erb +17 -15
- data/app/views/kaui/bundles/transfer.html.erb +25 -24
- data/app/views/kaui/chargebacks/_form.html.erb +44 -0
- data/app/views/kaui/chargebacks/new.html.erb +3 -115
- data/app/views/kaui/charges/_form.html.erb +73 -0
- data/app/views/kaui/charges/new.html.erb +2 -91
- data/app/views/kaui/credits/_form.html.erb +73 -0
- data/app/views/kaui/credits/new.html.erb +2 -85
- data/app/views/kaui/invoice_items/edit.html.erb +77 -78
- data/app/views/kaui/invoices/show.html.erb +3 -10
- data/app/views/kaui/layouts/kaui_application.html.erb +0 -2
- data/app/views/kaui/payment_methods/_form.html.erb +30 -0
- data/app/views/kaui/payment_methods/_new_creditcard_payment_method.html.erb +19 -18
- data/app/views/kaui/payment_methods/_payment_methods_table.html.erb +8 -5
- data/app/views/kaui/payment_methods/index.html.erb +10 -10
- data/app/views/kaui/payment_methods/new.html.erb +2 -20
- data/app/views/kaui/payment_methods/show.html.erb +2 -1
- data/app/views/kaui/payments/_payments_table.html.erb +30 -22
- data/app/views/kaui/payments/index.html.erb +1 -1
- data/app/views/kaui/payments/new.html.erb +5 -5
- data/app/views/kaui/payments/show.html.erb +3 -0
- data/app/views/kaui/refunds/new.html.erb +96 -104
- data/app/views/kaui/subscriptions/_form.html.erb +36 -0
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +39 -44
- data/app/views/kaui/subscriptions/edit.html.erb +24 -35
- data/app/views/kaui/subscriptions/index.html.erb +13 -12
- data/app/views/kaui/subscriptions/new.html.erb +6 -43
- data/app/views/kaui/subscriptions/show.html.erb +32 -25
- data/app/views/kaui/tag_definitions/_form.html.erb +10 -37
- data/app/views/kaui/tag_definitions/index.html.erb +3 -5
- data/app/views/kaui/tag_definitions/show.html.erb +1 -2
- data/app/views/kaui/transactions/_form.html.erb +77 -0
- data/app/views/kaui/transactions/new.html.erb +3 -0
- data/config/initializers/kilbill-client-init.rb +1 -1
- data/config/routes.rb +4 -15
- data/kaui.gemspec +8 -6
- data/lib/kaui/engine.rb +4 -1
- data/lib/kaui/version.rb +1 -1
- data/lib/kaui.rb +2 -2
- data/test/functional/kaui/account_emails_controller_test.rb +28 -0
- data/test/functional/kaui/account_tags_controller_test.rb +29 -0
- data/test/functional/kaui/account_timelines_controller_test.rb +21 -0
- data/test/functional/kaui/accounts_controller_test.rb +56 -50
- data/test/functional/kaui/bundle_tags_controller_test.rb +29 -0
- data/test/functional/kaui/bundles_controller_test.rb +58 -13
- data/test/functional/kaui/chargebacks_controller_test.rb +16 -5
- data/test/functional/kaui/charges_controller_test.rb +39 -0
- data/test/functional/kaui/credits_controller_test.rb +35 -0
- data/test/functional/kaui/custom_fields_controller_test.rb +21 -0
- data/test/functional/kaui/functional_test_helper.rb +61 -0
- data/test/functional/kaui/invoice_items_controller_test.rb +24 -10
- data/test/functional/kaui/invoices_controller_test.rb +41 -13
- data/test/functional/kaui/payment_methods_controller_test.rb +49 -0
- data/test/functional/kaui/payments_controller_test.rb +32 -5
- data/test/functional/kaui/refunds_controller_test.rb +40 -5
- data/test/functional/kaui/subscriptions_controller_test.rb +82 -0
- data/test/functional/kaui/tag_definitions_controller_test.rb +27 -53
- data/test/functional/kaui/tags_controller_test.rb +21 -0
- data/test/functional/kaui/transactions_controller_test.rb +32 -0
- data/test/integration/kaui/integration_test_helper.rb +31 -0
- data/test/integration/kaui/navigation_test.rb +43 -0
- data/test/killbill_test_helper.rb +143 -0
- data/test/test_helper.rb +10 -227
- data/test/unit/kaui/account_email_test.rb +19 -0
- data/test/unit/kaui/account_test.rb +7 -35
- data/test/unit/kaui/base_test.rb +5 -46
- data/test/unit/kaui/date_helper_test.rb +6 -5
- data/test/unit/kaui/invoice_item_test.rb +5 -17
- data/test/unit/kaui/invoice_payment_test.rb +42 -0
- data/test/unit/kaui/invoice_test.rb +15 -15
- data/test/unit/kaui/money_helper_test.rb +10 -0
- data/test/unit/kaui/payment_test.rb +42 -0
- data/test/unit/kaui/tag_definition_test.rb +5 -28
- data/test/unit/kaui/uuid_helper_test.rb +10 -0
- metadata +134 -159
- data/app/controllers/kaui/analytics_controller.rb +0 -28
- data/app/helpers/kaui/killbill_helper.rb +0 -611
- data/app/models/kaui/analytics.rb +0 -19
- data/app/models/kaui/analytics_sanity.rb +0 -7
- data/app/models/kaui/business_account.rb +0 -12
- data/app/models/kaui/business_field.rb +0 -6
- data/app/models/kaui/business_invoice.rb +0 -31
- data/app/models/kaui/business_invoice_item.rb +0 -17
- data/app/models/kaui/business_invoice_payment.rb +0 -25
- data/app/models/kaui/business_overdue_status.rb +0 -8
- data/app/models/kaui/business_snapshot.rb +0 -9
- data/app/models/kaui/business_subscription_transition.rb +0 -53
- data/app/models/kaui/business_tag.rb +0 -5
- data/app/models/kaui/charge.rb +0 -14
- data/app/models/kaui/entitlement.rb +0 -2
- data/app/models/kaui/event.rb +0 -13
- data/app/models/kaui/external_payment.rb +0 -15
- data/app/models/kaui/overdue_state.rb +0 -10
- data/app/models/kaui/payment_attempt.rb +0 -27
- data/app/models/kaui/product.rb +0 -24
- data/app/models/kaui/time_series_data.rb +0 -8
- data/app/views/kaui/analytics/account_snapshot.html.erb +0 -211
- data/app/views/kaui/analytics/index.html.erb +0 -17
- data/app/views/kaui/chargebacks/index.html.erb +0 -14
- data/app/views/kaui/chargebacks/show.html.erb +0 -19
- data/app/views/kaui/credits/index.html.erb +0 -14
- data/app/views/kaui/credits/show.html.erb +0 -19
- data/app/views/kaui/invoice_items/index.html.erb +0 -20
- data/app/views/kaui/invoice_items/show.html.erb +0 -31
- data/app/views/kaui/refunds/_refunds_table.html.erb +0 -31
- data/app/views/kaui/refunds/index.html.erb +0 -43
- data/app/views/kaui/refunds/show.html.erb +0 -33
- data/app/views/kaui/tag_definitions/edit.html.erb +0 -3
- data/test/dummy/test/fixtures/accounts.yml +0 -32
- data/test/dummy/test/fixtures/bill_cycle_days.yml +0 -3
- data/test/dummy/test/fixtures/bundles.yml +0 -4
- data/test/dummy/test/fixtures/invoice_items.yml +0 -13
- data/test/dummy/test/fixtures/invoices.yml +0 -11
- data/test/dummy/test/fixtures/overdue_states.yml +0 -8
- data/test/dummy/test/fixtures/payment_methods.yml +0 -5
- data/test/dummy/test/fixtures/plugin_info_properties.yml +0 -59
- data/test/dummy/test/fixtures/plugin_infos.yml +0 -2
- data/test/dummy/test/fixtures/refunds.yml +0 -9
- data/test/dummy/test/fixtures/tag_definitions.yml +0 -20
- data/test/functional/kaui/account_timeline_controller_test.rb +0 -9
- data/test/functional/kaui/extpayments_controller_test.rb +0 -9
- data/test/functional/kaui/home_controller_test.rb +0 -11
- data/test/integration/navigation_test.rb +0 -10
- data/test/kaui_test.rb +0 -7
- data/test/unit/helpers/kaui/account_timeline_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/bundles_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/chargebacks_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/extpayments_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/home_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/invoices_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/payments_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/refunds_helper_test.rb +0 -6
- data/test/unit/kaui/overdue_state_test.rb +0 -18
- data/test/unit/kaui/refund_test.rb +0 -20
- data/test/unit/model_test.rb +0 -151
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4dfe42ad2548ff670bed0e9282f8b311156d2e5e
|
4
|
+
data.tar.gz: 9b06404c20ea0f49392971aa3c93eb75ce51e5de
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a1039d8c8b644990de6ac798aa5ebea4e8f0cda5d548d742103eba5ff2a9bcc34d353f5299d48afa080f699cb212816d822f2758fe08046542da726062bcec15
|
7
|
+
data.tar.gz: 67b84718f67dda80b67de237483d406fee007b9f1baca451d79836d624e3633dcae3bf325af25509b8db2286fa2b7dddd8bc81dcd382e19d551f0d0f70767200
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kaui (0.
|
4
|
+
kaui (0.7.0)
|
5
5
|
cancan (~> 1.6.10)
|
6
|
+
carmen-rails (~> 1.0.0)
|
6
7
|
d3_rails (~> 3.2.8)
|
7
8
|
devise (~> 3.0.2)
|
8
9
|
jquery-rails (~> 3.0.4)
|
9
|
-
killbill-client (~> 0.
|
10
|
+
killbill-client (~> 0.7.3)
|
10
11
|
money-rails (~> 0.8.1)
|
11
12
|
rails (~> 3.2.14)
|
12
|
-
rest-client (~> 1.6.7)
|
13
13
|
|
14
14
|
GEM
|
15
15
|
remote: http://rubygems.org/
|
16
16
|
specs:
|
17
|
-
actionmailer (3.2.
|
18
|
-
actionpack (= 3.2.
|
17
|
+
actionmailer (3.2.19)
|
18
|
+
actionpack (= 3.2.19)
|
19
19
|
mail (~> 2.5.4)
|
20
|
-
actionpack (3.2.
|
21
|
-
activemodel (= 3.2.
|
22
|
-
activesupport (= 3.2.
|
20
|
+
actionpack (3.2.19)
|
21
|
+
activemodel (= 3.2.19)
|
22
|
+
activesupport (= 3.2.19)
|
23
23
|
builder (~> 3.0.0)
|
24
24
|
erubis (~> 2.7.0)
|
25
25
|
journey (~> 1.0.4)
|
@@ -27,24 +27,31 @@ GEM
|
|
27
27
|
rack-cache (~> 1.2)
|
28
28
|
rack-test (~> 0.6.1)
|
29
29
|
sprockets (~> 2.2.1)
|
30
|
-
activemodel (3.2.
|
31
|
-
activesupport (= 3.2.
|
30
|
+
activemodel (3.2.19)
|
31
|
+
activesupport (= 3.2.19)
|
32
32
|
builder (~> 3.0.0)
|
33
|
-
activerecord (3.2.
|
34
|
-
activemodel (= 3.2.
|
35
|
-
activesupport (= 3.2.
|
33
|
+
activerecord (3.2.19)
|
34
|
+
activemodel (= 3.2.19)
|
35
|
+
activesupport (= 3.2.19)
|
36
36
|
arel (~> 3.0.2)
|
37
37
|
tzinfo (~> 0.3.29)
|
38
|
-
activeresource (3.2.
|
39
|
-
activemodel (= 3.2.
|
40
|
-
activesupport (= 3.2.
|
41
|
-
activesupport (3.2.
|
38
|
+
activeresource (3.2.19)
|
39
|
+
activemodel (= 3.2.19)
|
40
|
+
activesupport (= 3.2.19)
|
41
|
+
activesupport (3.2.19)
|
42
42
|
i18n (~> 0.6, >= 0.6.4)
|
43
43
|
multi_json (~> 1.0)
|
44
44
|
arel (3.0.3)
|
45
|
-
bcrypt
|
45
|
+
bcrypt (3.1.7)
|
46
|
+
bcrypt-ruby (3.1.5)
|
47
|
+
bcrypt (>= 3.1.3)
|
46
48
|
builder (3.0.4)
|
47
49
|
cancan (1.6.10)
|
50
|
+
carmen (1.0.1)
|
51
|
+
unicode_utils (~> 1.4.0)
|
52
|
+
carmen-rails (1.0.1)
|
53
|
+
carmen (~> 1.0.0)
|
54
|
+
rails
|
48
55
|
d3_rails (3.2.8)
|
49
56
|
railties (>= 3.1.0)
|
50
57
|
devise (3.0.4)
|
@@ -52,16 +59,17 @@ GEM
|
|
52
59
|
orm_adapter (~> 0.1)
|
53
60
|
railties (>= 3.2.6, < 5)
|
54
61
|
warden (~> 1.2.3)
|
62
|
+
docile (1.1.5)
|
55
63
|
erubis (2.7.0)
|
56
64
|
fakeweb (1.3.0)
|
57
65
|
hike (1.2.3)
|
58
|
-
i18n (0.6.
|
66
|
+
i18n (0.6.11)
|
59
67
|
journey (1.0.4)
|
60
68
|
jquery-rails (3.0.4)
|
61
69
|
railties (>= 3.0, < 5.0)
|
62
70
|
thor (>= 0.14, < 2.0)
|
63
71
|
json (1.8.1)
|
64
|
-
killbill-client (0.
|
72
|
+
killbill-client (0.7.3)
|
65
73
|
json (~> 1.8.0)
|
66
74
|
mail (2.5.4)
|
67
75
|
mime-types (~> 1.16)
|
@@ -73,28 +81,28 @@ GEM
|
|
73
81
|
activesupport (>= 3.0)
|
74
82
|
money (~> 5.1.0)
|
75
83
|
railties (>= 3.0)
|
76
|
-
multi_json (1.
|
84
|
+
multi_json (1.9.2)
|
77
85
|
mysql2 (0.3.13)
|
78
86
|
orm_adapter (0.5.0)
|
79
|
-
polyglot (0.3.
|
87
|
+
polyglot (0.3.5)
|
80
88
|
rack (1.4.5)
|
81
89
|
rack-cache (1.2)
|
82
90
|
rack (>= 0.4)
|
83
|
-
rack-ssl (1.3.
|
91
|
+
rack-ssl (1.3.4)
|
84
92
|
rack
|
85
93
|
rack-test (0.6.2)
|
86
94
|
rack (>= 1.0)
|
87
|
-
rails (3.2.
|
88
|
-
actionmailer (= 3.2.
|
89
|
-
actionpack (= 3.2.
|
90
|
-
activerecord (= 3.2.
|
91
|
-
activeresource (= 3.2.
|
92
|
-
activesupport (= 3.2.
|
95
|
+
rails (3.2.19)
|
96
|
+
actionmailer (= 3.2.19)
|
97
|
+
actionpack (= 3.2.19)
|
98
|
+
activerecord (= 3.2.19)
|
99
|
+
activeresource (= 3.2.19)
|
100
|
+
activesupport (= 3.2.19)
|
93
101
|
bundler (~> 1.0)
|
94
|
-
railties (= 3.2.
|
95
|
-
railties (3.2.
|
96
|
-
actionpack (= 3.2.
|
97
|
-
activesupport (= 3.2.
|
102
|
+
railties (= 3.2.19)
|
103
|
+
railties (3.2.19)
|
104
|
+
actionpack (= 3.2.19)
|
105
|
+
activesupport (= 3.2.19)
|
98
106
|
rack-ssl (~> 1.3.2)
|
99
107
|
rake (>= 0.8.7)
|
100
108
|
rdoc (~> 3.4)
|
@@ -102,20 +110,24 @@ GEM
|
|
102
110
|
rake (10.1.1)
|
103
111
|
rdoc (3.12.2)
|
104
112
|
json (~> 1.4)
|
105
|
-
|
106
|
-
|
113
|
+
simplecov (0.9.0)
|
114
|
+
docile (~> 1.1.0)
|
115
|
+
multi_json
|
116
|
+
simplecov-html (~> 0.8.0)
|
117
|
+
simplecov-html (0.8.0)
|
107
118
|
sprockets (2.2.2)
|
108
119
|
hike (~> 1.2)
|
109
120
|
multi_json (~> 1.0)
|
110
121
|
rack (~> 1.0)
|
111
122
|
tilt (~> 1.1, != 1.3.0)
|
112
123
|
sqlite3 (1.3.8)
|
113
|
-
thor (0.
|
124
|
+
thor (0.19.1)
|
114
125
|
tilt (1.4.1)
|
115
126
|
treetop (1.4.15)
|
116
127
|
polyglot
|
117
128
|
polyglot (>= 0.3.1)
|
118
|
-
tzinfo (0.3.
|
129
|
+
tzinfo (0.3.40)
|
130
|
+
unicode_utils (1.4.0)
|
119
131
|
warden (1.2.3)
|
120
132
|
rack (>= 1.0)
|
121
133
|
|
@@ -126,4 +138,6 @@ DEPENDENCIES
|
|
126
138
|
fakeweb (~> 1.3)
|
127
139
|
kaui!
|
128
140
|
mysql2
|
141
|
+
rake (>= 0.8.7)
|
142
|
+
simplecov
|
129
143
|
sqlite3
|
data/README.md
CHANGED
@@ -28,6 +28,9 @@ name of the logged-in user. This is used by Killbill for auditing purposes.
|
|
28
28
|
|
29
29
|
Finally, Killbill server needs to be running for Kaui to fetch its information. Set the `KILLBILL_URL`
|
30
30
|
variable to point to your existing Killbill installation (e.g. http://killbill.company.com:8080).
|
31
|
+
The default login credentials are admin/password. Users, Credentials, Roles and Permissions are
|
32
|
+
passed through to Kill Bill. It uses Basic Auth by default, but the backend is pluggable (LDAP,
|
33
|
+
ActiveDirectory, etc.).
|
31
34
|
|
32
35
|
|
33
36
|
Multi-Tenancy
|
@@ -36,6 +39,7 @@ Multi-Tenancy
|
|
36
39
|
If you are using Kaui against a single tenant, specify your api key and secret in ```config/initializers/killbill_client.rb```:
|
37
40
|
|
38
41
|
```
|
42
|
+
KillBillClient.url = 'http://127.0.0.1:8080/'
|
39
43
|
KillBillClient.api_key = 'bob'
|
40
44
|
KillBillClient.api_secret = 'lazar'
|
41
45
|
```
|
@@ -59,6 +63,7 @@ Run the tests:
|
|
59
63
|
> cd ../..
|
60
64
|
> rake test
|
61
65
|
|
66
|
+
Note: functional and integration tests require an instance of Kill Bill to test against.
|
62
67
|
|
63
68
|
Development
|
64
69
|
===========
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ rescue LoadError
|
|
5
5
|
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
6
|
end
|
7
7
|
|
8
|
-
APP_RAKEFILE = File.expand_path(
|
8
|
+
APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
|
9
9
|
load 'rails/tasks/engine.rake'
|
10
10
|
|
11
11
|
Bundler::GemHelper.install_tasks
|
@@ -1,54 +1,36 @@
|
|
1
|
-
|
2
|
-
class AccountEmailsController < EngineController
|
3
|
-
# GET /account_emails/1
|
4
|
-
# GET /account_emails/1.json
|
5
|
-
def show
|
6
|
-
@account_id = params[:id]
|
7
|
-
@account_emails = AccountEmail.where({ :account_id => @account_id }, options_for_klient)
|
1
|
+
class Kaui::AccountEmailsController < Kaui::EngineController
|
8
2
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
# GET /account_emails/new
|
16
|
-
# GET /account_emails/new.json
|
17
|
-
def new
|
18
|
-
@account_email = AccountEmail.new(:account_id => params[:account_id])
|
3
|
+
def show
|
4
|
+
@account_id = params[:id]
|
5
|
+
@account_emails = Kaui::AccountEmail.find_all_sorted_by_account_id(@account_id, 'NONE', options_for_klient)
|
6
|
+
end
|
19
7
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
8
|
+
def new
|
9
|
+
@account_email = Kaui::AccountEmail.new(:account_id => params[:account_id])
|
10
|
+
end
|
25
11
|
|
26
|
-
|
27
|
-
|
28
|
-
def create
|
29
|
-
@account_email = AccountEmail.new(params[:account_email])
|
12
|
+
def create
|
13
|
+
@account_email = Kaui::AccountEmail.new(params[:account_email])
|
30
14
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
15
|
+
account = Kaui::Account.new(:account_id => @account_email.account_id)
|
16
|
+
begin
|
17
|
+
account.add_email(@account_email.email, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
18
|
+
redirect_to account_email_path(account.account_id), :notice => 'Account email was successfully added'
|
19
|
+
rescue => e
|
20
|
+
flash.now[:error] = "Error while adding the email: #{as_string(e)}"
|
21
|
+
render :action => :new
|
40
22
|
end
|
23
|
+
end
|
41
24
|
|
42
|
-
|
43
|
-
|
44
|
-
def destroy
|
45
|
-
@account_email = AccountEmail.where({ :account_id => params[:id], :email => params[:email] }, options_for_klient)
|
46
|
-
@account_email.destroy(current_user, params[:reason], params[:comment], options_for_klient)
|
25
|
+
def destroy
|
26
|
+
account = Kaui::Account.new(:account_id => params[:id])
|
47
27
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
28
|
+
begin
|
29
|
+
account.remove_email(params[:email], current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
30
|
+
redirect_to account_email_path(account.account_id), :notice => 'Account email was successfully deleted'
|
31
|
+
rescue => e
|
32
|
+
flash.now[:error] = "Error while deleting account email: #{as_string(e)}"
|
33
|
+
render :action => :show, :id => account.account_id
|
52
34
|
end
|
53
35
|
end
|
54
36
|
end
|
@@ -1,59 +1,47 @@
|
|
1
1
|
class Kaui::AccountTagsController < Kaui::EngineController
|
2
2
|
|
3
3
|
def show
|
4
|
-
|
4
|
+
account_id_or_key = params[:account_id]
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
else
|
14
|
-
flash.now[:error] = "No account id given"
|
6
|
+
begin
|
7
|
+
@account = Kaui::Account::find_by_id_or_key(account_id_or_key, false, false, options_for_klient)
|
8
|
+
@tags = @account.tags(true, 'FULL', options_for_klient).sort { |tag_a, tag_b| tag_a <=> tag_b }
|
9
|
+
rescue => e
|
10
|
+
flash[:error] = "Error while getting tags: #{as_string(e)}"
|
11
|
+
redirect_to :back
|
15
12
|
end
|
16
13
|
end
|
17
14
|
|
18
15
|
def edit
|
19
|
-
|
16
|
+
account_id_or_key = params[:account_id]
|
17
|
+
|
20
18
|
begin
|
21
|
-
@
|
22
|
-
@
|
23
|
-
@
|
19
|
+
@account = Kaui::Account::find_by_id_or_key(account_id_or_key, false, false, options_for_klient)
|
20
|
+
@tag_names = (@account.tags(false, 'NONE', options_for_klient).map { |tag| tag.tag_definition_name }).sort
|
21
|
+
@available_tags = Kaui::TagDefinition.all_for_account(options_for_klient)
|
24
22
|
rescue => e
|
25
|
-
flash
|
23
|
+
flash[:error] = "Error while editing tags: #{as_string(e)}"
|
24
|
+
redirect_to kaui_engine.account_tags_path(:account_id => account_id_or_key)
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
28
|
def update
|
30
|
-
|
31
|
-
current_tags = Kaui::KillbillHelper::get_tags_for_account(params[:account_id], false, "NONE", options_for_klient).map { |tag| tag.tag_definition_id }
|
32
|
-
|
33
|
-
new_tags = []
|
34
|
-
params.each do |tag, tag_name|
|
35
|
-
tag_info = tag.split('_')
|
36
|
-
next if tag_info.size != 2 or tag_info[0] != 'tag'
|
37
|
-
new_tags << tag_info[1]
|
38
|
-
end
|
39
|
-
|
40
|
-
# Find tags to remove
|
41
|
-
tags_to_remove = []
|
42
|
-
current_tags.each do |current_tag_definition_id|
|
43
|
-
tags_to_remove << current_tag_definition_id unless new_tags.include?(current_tag_definition_id)
|
44
|
-
end
|
29
|
+
account_id = params[:account_id]
|
45
30
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
31
|
+
tags = []
|
32
|
+
params.each do |tag, tag_name|
|
33
|
+
tag_info = tag.split('_')
|
34
|
+
next if tag_info.size != 2 or tag_info[0] != 'tag'
|
35
|
+
tags << tag_info[1]
|
36
|
+
end
|
51
37
|
|
52
|
-
|
53
|
-
Kaui::
|
38
|
+
begin
|
39
|
+
account = Kaui::Account.new(:account_id => account_id)
|
40
|
+
account.set_tags(tags, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
41
|
+
redirect_to kaui_engine.account_tags_path(:account_id => account_id), :notice => 'Account tags successfully set'
|
54
42
|
rescue => e
|
55
43
|
flash[:error] = "Error while updating tags: #{as_string(e)}"
|
44
|
+
redirect_to kaui_engine.account_tags_path(:account_id => account_id)
|
56
45
|
end
|
57
|
-
redirect_to kaui_engine.account_path(params[:account_id])
|
58
46
|
end
|
59
47
|
end
|
@@ -1,66 +1,63 @@
|
|
1
1
|
class Kaui::AccountTimelinesController < Kaui::EngineController
|
2
|
+
|
2
3
|
def index
|
3
|
-
if params[:account_id].present?
|
4
|
-
redirect_to kaui_engine.account_timeline_path(params[:account_id])
|
5
|
-
end
|
6
4
|
end
|
7
5
|
|
8
6
|
def show
|
9
7
|
@account_id = params[:id]
|
10
|
-
|
11
|
-
flash[:notice] = "No id given"
|
12
|
-
redirect_to :back
|
13
|
-
return
|
14
|
-
end
|
8
|
+
|
15
9
|
begin
|
16
|
-
@account
|
17
|
-
@timeline = Kaui::
|
10
|
+
@account = Kaui::Account.find_by_id(@account_id, false, false, options_for_klient)
|
11
|
+
@timeline = Kaui::AccountTimeline.find_by_account_id(@account_id, 'MINIMAL', options_for_klient)
|
18
12
|
rescue => e
|
19
13
|
flash[:error] = "Could not load the account timeline for #{@account_id}: #{as_string(e)}"
|
20
|
-
|
21
|
-
return
|
14
|
+
render :action => :index and return
|
22
15
|
end
|
23
16
|
|
24
|
-
|
25
|
-
@bundle_names
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
@timeline.invoices.each do |invoice|
|
42
|
-
if invoice.invoice_id.present? && !@invoices_by_id.has_key?(invoice.invoice_id)
|
43
|
-
begin
|
44
|
-
@invoices_by_id[invoice.invoice_id] = Kaui::KillbillHelper::get_invoice(invoice.invoice_id, true, "NONE", options_for_klient)
|
45
|
-
rescue => e
|
46
|
-
flash.now[:error] = "Could not get invoice information for the timeline #{@account_id}: #{as_string(e)}"
|
47
|
-
end
|
48
|
-
invoice.bundle_keys.split(",").each do |bundle_key|
|
49
|
-
unless @bundle_names.has_key?(bundle_key)
|
50
|
-
@bundle_names[bundle_key] = Kaui.bundle_key_display_string.call(bundle_key)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
@timeline.bundles.each do |bundle|
|
56
|
-
unless @bundle_names.has_key?(bundle.external_key)
|
57
|
-
@bundle_names[bundle.external_key] = Kaui.bundle_key_display_string.call(bundle.external_key)
|
58
|
-
end
|
17
|
+
# Lookup all bundle names
|
18
|
+
@bundle_names = {}
|
19
|
+
@bundle_names_by_invoice_id = {}
|
20
|
+
@bundle_keys_by_invoice_id = {}
|
21
|
+
@timeline.bundles.each do |bundle|
|
22
|
+
load_bundle_name_for_timeline(bundle.external_key)
|
23
|
+
end
|
24
|
+
@timeline.invoices.each do |invoice|
|
25
|
+
@bundle_names_by_invoice_id[invoice.invoice_id] = Set.new
|
26
|
+
@bundle_keys_by_invoice_id[invoice.invoice_id] = Set.new
|
27
|
+
(invoice.bundle_keys || '').split(',').each do |bundle_key|
|
28
|
+
load_bundle_name_for_timeline(bundle_key)
|
29
|
+
@bundle_names_by_invoice_id[invoice.invoice_id] << @bundle_names[bundle_key]
|
30
|
+
@bundle_keys_by_invoice_id[invoice.invoice_id] << bundle_key
|
59
31
|
end
|
32
|
+
end
|
60
33
|
|
61
|
-
|
62
|
-
|
63
|
-
|
34
|
+
# Lookup all invoices
|
35
|
+
@invoices_by_id = {}
|
36
|
+
@timeline.payments.each do |payment|
|
37
|
+
load_invoice_id_for_timeline(payment.target_invoice_id)
|
38
|
+
end
|
39
|
+
@timeline.invoices.each do |invoice|
|
40
|
+
load_invoice_id_for_timeline(invoice.invoice_id)
|
41
|
+
end
|
42
|
+
|
43
|
+
if params.has_key?(:external_key)
|
44
|
+
@selected_bundle = @bundle_names[params[:external_key]]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def load_bundle_name_for_timeline(bundle_key)
|
51
|
+
@bundle_names[bundle_key] ||= Kaui.bundle_key_display_string.call(bundle_key)
|
52
|
+
end
|
53
|
+
|
54
|
+
def load_invoice_id_for_timeline(invoice_id)
|
55
|
+
return if invoice_id.blank? or @invoices_by_id.has_key?(invoice_id)
|
56
|
+
|
57
|
+
begin
|
58
|
+
@invoices_by_id[invoice_id] = Kaui::Invoice.find_by_id_or_number(invoice_id, true, 'NONE', options_for_klient)
|
59
|
+
rescue => e
|
60
|
+
flash.now[:error] = "Could not get invoice information for the timeline #{@account_id}: #{as_string(e)}"
|
64
61
|
end
|
65
62
|
end
|
66
63
|
end
|