kaui 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/kaui/account_tags_controller.rb +38 -27
- data/app/controllers/kaui/account_timelines_controller.rb +10 -4
- data/app/controllers/kaui/accounts_controller.rb +31 -12
- data/app/controllers/kaui/bundle_tags_controller.rb +5 -1
- data/app/controllers/kaui/bundles_controller.rb +6 -3
- data/app/controllers/kaui/chargebacks_controller.rb +21 -12
- data/app/controllers/kaui/charges_controller.rb +15 -13
- data/app/controllers/kaui/credits_controller.rb +19 -9
- data/app/controllers/kaui/invoice_items_controller.rb +9 -5
- data/app/controllers/kaui/invoices_controller.rb +28 -20
- data/app/controllers/kaui/payments_controller.rb +11 -6
- data/app/controllers/kaui/refunds_controller.rb +9 -4
- data/app/controllers/kaui/subscriptions_controller.rb +50 -38
- data/app/helpers/kaui/killbill_helper.rb +202 -332
- data/app/models/kaui/account_email.rb +22 -11
- data/app/views/kaui/chargebacks/new.html.erb +3 -1
- data/app/views/kaui/refunds/new.html.erb +4 -2
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +2 -4
- data/lib/kaui/version.rb +1 -1
- data/test/dummy/log/test.log +997 -113084
- metadata +2 -67
- data/app/controllers/kaui/tags_controller.rb +0 -85
- data/app/views/kaui/account_emails/edit.html.erb +0 -6
- data/app/views/kaui/tags/_form.html.erb +0 -25
- data/app/views/kaui/tags/edit.html.erb +0 -6
- data/app/views/kaui/tags/index.html.erb +0 -25
- data/app/views/kaui/tags/new.html.erb +0 -5
- data/app/views/kaui/tags/show.html.erb +0 -15
- data/test/dummy/log/development.log +0 -60886
- data/test/dummy/test/fixtures/bill_cycle_days.yml +0 -3
- data/test/dummy/tmp/cache/assets/C94/4E0/sprockets%2Fea1476dc10a3348303f74d111f70441a +0 -0
- data/test/dummy/tmp/cache/assets/C95/690/sprockets%2Fc4b083702793f7599f4a3069c50f89a8 +0 -0
- data/test/dummy/tmp/cache/assets/CAA/680/sprockets%2F3824d037523f650518fb22acab75559d +0 -0
- data/test/dummy/tmp/cache/assets/CC2/520/sprockets%2F9637f46d37325381f96d96d94ae0bc50 +0 -0
- data/test/dummy/tmp/cache/assets/CD0/9D0/sprockets%2F5c9508c21501c73fbe00473a09b1f5f4 +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CDF/1F0/sprockets%2F76ac5628a0c4d1b976cb622ec4493751 +0 -381
- data/test/dummy/tmp/cache/assets/CEA/300/sprockets%2Fdf2ad5c9d0990441c2bf59883383d652 +0 -0
- data/test/dummy/tmp/cache/assets/CF7/710/sprockets%2F86d43448e1fc383cb6f3d752ef288882 +0 -0
- data/test/dummy/tmp/cache/assets/D17/DD0/sprockets%2F665455ecdc7609b23f4ecb366d86055a +0 -9409
- data/test/dummy/tmp/cache/assets/D32/200/sprockets%2Ffa467106e01bda5d6246baea72159d64 +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D39/5E0/sprockets%2F59fd338be48a81a17a2a785cbd1612b4 +0 -0
- data/test/dummy/tmp/cache/assets/D44/170/sprockets%2Fac15571bce3f926a498da7cd09322d97 +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D6C/710/sprockets%2F1765773caead06c0a6a19ea9de2453f7 +0 -0
- data/test/dummy/tmp/cache/assets/D76/910/sprockets%2Ff99b4bdc434e11e8634e6af62fe805e0 +0 -0
- data/test/dummy/tmp/cache/assets/D9F/160/sprockets%2F510462e1ebd5dbb7ae20888b77f9bed2 +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E07/1E0/sprockets%2F5a3fe6e98fdf72bbe75c605e54ebc5b0 +0 -9409
- data/test/dummy/tmp/cache/assets/E20/230/sprockets%2F7d3b1348fdf74cf1b6ba2107fbbac5af +0 -0
- data/test/dummy/tmp/cache/assets/E22/F40/sprockets%2Faffacf2e6be325520bd3bfd2096b6dd4 +0 -0
- data/test/dummy/tmp/cache/assets/E24/9D0/sprockets%2Fb966ab0a50fda3c156fbad4d8ab73ef6 +0 -381
- data/test/functional/kaui/account_emails_controller_test.rb +0 -51
- data/test/functional/kaui/tags_controller_test.rb +0 -51
@@ -8,10 +8,14 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def show
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
begin
|
12
|
+
@subscription = Kaui::KillbillHelper.get_subscription(params[:id])
|
13
|
+
unless @subscription.present?
|
14
|
+
flash[:error] = "No subscription id given or subscription not found"
|
15
|
+
redirect_to :back
|
16
|
+
end
|
17
|
+
rescue => e
|
18
|
+
flash[:error] = "Error while getting subscription information: #{e.message} #{e.response}"
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
@@ -34,23 +38,24 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
34
38
|
|
35
39
|
def create
|
36
40
|
@base_subscription = params[:base_subscription]
|
37
|
-
@subscription = Kaui::Subscription.new(params[:subscription])
|
38
|
-
@bundle = Kaui::KillbillHelper::get_bundle(@subscription.bundle_id)
|
39
41
|
@plan_name = params[:plan_name]
|
40
|
-
if @base_subscription.present?
|
41
|
-
@catalog = Kaui::KillbillHelper::get_available_addons(@base_subscription)
|
42
|
-
@subscription.product_category = "ADD_ON"
|
43
|
-
else
|
44
|
-
@catalog = Kaui::KillbillHelper::get_available_base_plans()
|
45
|
-
@subscription.product_category = "BASE"
|
46
|
-
end
|
47
|
-
|
48
|
-
plan = @catalog[@plan_name]
|
49
|
-
@subscription.billing_period = plan["billingPeriod"]
|
50
|
-
@subscription.product_name = plan["productName"]
|
51
|
-
@subscription.price_list = plan["priceListName"]
|
52
42
|
|
53
43
|
begin
|
44
|
+
@subscription = Kaui::Subscription.new(params[:subscription])
|
45
|
+
@bundle = Kaui::KillbillHelper::get_bundle(@subscription.bundle_id)
|
46
|
+
if @base_subscription.present?
|
47
|
+
@catalog = Kaui::KillbillHelper::get_available_addons(@base_subscription)
|
48
|
+
@subscription.product_category = "ADD_ON"
|
49
|
+
else
|
50
|
+
@catalog = Kaui::KillbillHelper::get_available_base_plans()
|
51
|
+
@subscription.product_category = "BASE"
|
52
|
+
end
|
53
|
+
|
54
|
+
plan = @catalog[@plan_name]
|
55
|
+
@subscription.billing_period = plan["billingPeriod"]
|
56
|
+
@subscription.product_name = plan["productName"]
|
57
|
+
@subscription.price_list = plan["priceListName"]
|
58
|
+
|
54
59
|
Kaui::KillbillHelper::create_subscription(@subscription, current_user)
|
55
60
|
redirect_to Kaui.bundle_home_path.call(@bundle.bundle_id)
|
56
61
|
rescue => e
|
@@ -83,21 +88,25 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
83
88
|
end
|
84
89
|
|
85
90
|
def edit
|
86
|
-
|
91
|
+
begin
|
92
|
+
@subscription = Kaui::KillbillHelper.get_subscription(params[:id])
|
87
93
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
94
|
+
if @subscription.present?
|
95
|
+
@bundle = Kaui::KillbillHelper::get_bundle(@subscription.bundle_id)
|
96
|
+
@account = Kaui::KillbillHelper::get_account(@bundle.account_id)
|
97
|
+
@catalog = Kaui::KillbillHelper::get_available_base_plans
|
92
98
|
|
93
|
-
|
99
|
+
@current_plan = "#{@subscription.product_name} #{@subscription.billing_period}".humanize
|
94
100
|
|
95
|
-
|
96
|
-
|
101
|
+
if @subscription.price_list != "DEFAULT"
|
102
|
+
@current_plan += " (price list #{@subscription.price_list})"
|
103
|
+
end
|
104
|
+
else
|
105
|
+
flash[:error] = "No subscription id given or subscription not found"
|
106
|
+
redirect_to :back
|
97
107
|
end
|
98
|
-
|
99
|
-
flash[:error] = "
|
100
|
-
redirect_to :back
|
108
|
+
rescue => e
|
109
|
+
flash[:error] = "Error while editing subscription: #{e.message} #{e.response}"
|
101
110
|
end
|
102
111
|
end
|
103
112
|
|
@@ -119,38 +128,41 @@ class Kaui::SubscriptionsController < Kaui::EngineController
|
|
119
128
|
subscription.subscription_id = params[:subscription][:subscription_id]
|
120
129
|
|
121
130
|
Kaui::KillbillHelper::update_subscription(subscription, requested_date, current_user)
|
122
|
-
redirect_to Kaui.bundle_home_path.call(bundle.bundle_id)
|
123
131
|
rescue => e
|
124
132
|
flash[:error] = "Error while updating subscription: #{e.message} #{e.response}"
|
125
133
|
end
|
126
134
|
else
|
127
135
|
flash[:error] = "No subscription given"
|
128
|
-
redirect_to :back
|
129
136
|
end
|
137
|
+
redirect_to Kaui.bundle_home_path.call(bundle.bundle_id)
|
130
138
|
end
|
131
139
|
|
132
140
|
def reinstate
|
133
141
|
subscription_id = params[:id]
|
134
142
|
if subscription_id.present?
|
135
|
-
|
136
|
-
|
143
|
+
begin
|
144
|
+
Kaui::KillbillHelper::reinstate_subscription(subscription_id, current_user)
|
137
145
|
flash[:info] = "Subscription reinstated"
|
138
|
-
|
139
|
-
flash[:error] = "Error reinstating subscription"
|
146
|
+
rescue => e
|
147
|
+
flash[:error] = "Error while reinstating subscription: #{e.message} #{e.response}"
|
140
148
|
end
|
141
|
-
redirect_to :back
|
142
149
|
else
|
143
150
|
flash[:error] = "No subscription id given"
|
144
151
|
end
|
152
|
+
redirect_to :back
|
145
153
|
end
|
146
154
|
|
147
155
|
def destroy
|
148
156
|
subscription_id = params[:id]
|
149
157
|
if subscription_id.present?
|
150
|
-
|
151
|
-
|
158
|
+
begin
|
159
|
+
Kaui::KillbillHelper::delete_subscription(subscription_id, current_user)
|
160
|
+
rescue => e
|
161
|
+
flash[:error] = "Error while reinstating subscription: #{e.message} #{e.response}"
|
162
|
+
end
|
152
163
|
else
|
153
164
|
flash[:error] = "No subscription id given"
|
154
165
|
end
|
166
|
+
redirect_to :back
|
155
167
|
end
|
156
168
|
end
|