kaui 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,46 +9,52 @@ class Kaui::AccountTimelinesController < ApplicationController
9
9
  @account_id = params[:id]
10
10
  if @account_id.present?
11
11
  @account = Kaui::KillbillHelper::get_account(@account_id)
12
- @timeline = Kaui::KillbillHelper::get_account_timeline(@account_id)
13
- # @payment_attempts_by_payment_id = {}
14
- @invoices_by_id = {}
15
- @bundle_names = {}
16
- unless @timeline.nil?
17
- @timeline.payments.each do |payment|
18
- if payment.invoice_id.present? &&
19
- payment.payment_id.present? &&
20
- # !@payment_attempts_by_payment_id.has_key?(payment.payment_id)
21
12
 
22
- @invoices_by_id[payment.invoice_id] = Kaui::KillbillHelper::get_invoice(payment.invoice_id)
23
- # payment_attempt = Kaui::KillbillHelper::get_payment_attempt(@timeline.account.external_key,
24
- # payment.invoice_id,
25
- # payment.payment_id)
26
- # @payment_attempts_by_payment_id[payment.payment_id] = payment_attempt
27
- payment.bundle_keys.split(",").each do |bundle_key|
28
- unless @bundle_names.has_key?(bundle_key)
29
- @bundle_names[bundle_key] = Kaui.bundle_key_display_string.call(bundle_key)
13
+ if @account.present?
14
+ @timeline = Kaui::KillbillHelper::get_account_timeline(@account_id)
15
+ # @payment_attempts_by_payment_id = {}
16
+ @invoices_by_id = {}
17
+ @bundle_names = {}
18
+ unless @timeline.nil?
19
+ @timeline.payments.each do |payment|
20
+ if payment.invoice_id.present? &&
21
+ payment.payment_id.present? &&
22
+ # !@payment_attempts_by_payment_id.has_key?(payment.payment_id)
23
+
24
+ @invoices_by_id[payment.invoice_id] = Kaui::KillbillHelper::get_invoice(payment.invoice_id)
25
+ # payment_attempt = Kaui::KillbillHelper::get_payment_attempt(@timeline.account.external_key,
26
+ # payment.invoice_id,
27
+ # payment.payment_id)
28
+ # @payment_attempts_by_payment_id[payment.payment_id] = payment_attempt
29
+ payment.bundle_keys.split(",").each do |bundle_key|
30
+ unless @bundle_names.has_key?(bundle_key)
31
+ @bundle_names[bundle_key] = Kaui.bundle_key_display_string.call(bundle_key)
32
+ end
30
33
  end
31
34
  end
32
35
  end
33
- end
34
- @timeline.invoices.each do |invoice|
35
- if invoice.invoice_id.present? && !@invoices_by_id.has_key?(invoice.invoice_id)
36
- @invoices_by_id[invoice.invoice_id] = Kaui::KillbillHelper::get_invoice(invoice.invoice_id)
37
- invoice.bundle_keys.split(",").each do |bundle_key|
38
- unless @bundle_names.has_key?(bundle_key)
39
- @bundle_names[bundle_key] = Kaui.bundle_key_display_string.call(bundle_key)
36
+ @timeline.invoices.each do |invoice|
37
+ if invoice.invoice_id.present? && !@invoices_by_id.has_key?(invoice.invoice_id)
38
+ @invoices_by_id[invoice.invoice_id] = Kaui::KillbillHelper::get_invoice(invoice.invoice_id)
39
+ invoice.bundle_keys.split(",").each do |bundle_key|
40
+ unless @bundle_names.has_key?(bundle_key)
41
+ @bundle_names[bundle_key] = Kaui.bundle_key_display_string.call(bundle_key)
42
+ end
40
43
  end
41
44
  end
42
45
  end
43
- end
44
- @timeline.bundles.each do |bundle|
45
- unless @bundle_names.has_key?(bundle.external_key)
46
- @bundle_names[bundle.external_key] = Kaui.bundle_key_display_string.call(bundle.external_key)
46
+ @timeline.bundles.each do |bundle|
47
+ unless @bundle_names.has_key?(bundle.external_key)
48
+ @bundle_names[bundle.external_key] = Kaui.bundle_key_display_string.call(bundle.external_key)
49
+ end
50
+ end
51
+ if params.has_key?(:external_key)
52
+ @selected_bundle = @bundle_names[params[:external_key]]
47
53
  end
48
54
  end
49
- if params.has_key?(:external_key)
50
- @selected_bundle = @bundle_names[params[:external_key]]
51
- end
55
+ else
56
+ flash[:error] = "Account #{@account_id} not found"
57
+ redirect_to :action => :index
52
58
  end
53
59
  else
54
60
  flash[:notice] = "No id given"
@@ -9,9 +9,15 @@ class Kaui::AccountsController < ApplicationController
9
9
  end
10
10
 
11
11
  def show
12
- @account_id = params[:id]
13
- if @account_id.present?
14
- @account = Kaui::KillbillHelper.get_account(@account_id)
12
+ key = params[:id]
13
+ if key.present?
14
+ # support id (UUID) and external key search
15
+ if key =~ /[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}/
16
+ @account = Kaui::KillbillHelper.get_account(key)
17
+ else
18
+ @account = Kaui::KillbillHelper.get_account_by_external_key(key)
19
+ end
20
+
15
21
  if @account.present?
16
22
  # TODO: add when payment methods are implemented
17
23
  # @payment_methods = Kaui::KillbillHelper.get_payment_methods(@account_id)
@@ -7,13 +7,19 @@ class Kaui::BundlesController < ApplicationController
7
7
  end
8
8
 
9
9
  def show
10
- @external_key = params[:id]
11
- if @external_key.present?
12
- @bundle = Kaui::KillbillHelper.get_bundle_by_external_key(@external_key)
10
+ key = params[:id]
11
+ if key.present?
12
+ # support id (UUID) and external key search
13
+ if key =~ /[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}/
14
+ @bundle = Kaui::KillbillHelper.get_bundle(key)
15
+ else
16
+ @bundle = Kaui::KillbillHelper.get_bundle_by_external_key(key)
17
+ end
18
+
13
19
  if @bundle.present?
14
20
  @subscriptions = Kaui::KillbillHelper.get_subscriptions_for_bundle(@bundle.bundle_id)
15
21
  else
16
- flash[:error] = "Bundle #{@external_key} not found"
22
+ flash[:error] = "Bundle #{key} not found"
17
23
  redirect_to :action => :index
18
24
  end
19
25
  else
@@ -15,24 +15,30 @@ class Kaui::ChargebacksController < ApplicationController
15
15
 
16
16
  def new
17
17
  @payment_id = params[:payment_id]
18
- @invoice_id = params[:invoice_id]
19
18
  @account_id = params[:account_id]
20
-
21
- @chargeback = Kaui::Chargeback.new(:payment_id => @payment_id,
22
- :invoice_id => @invoice_id,
23
- :account_id => @account_id)
19
+ @invoice_id = params[:invoice_id]
24
20
 
25
21
  # @payment_attempt = Kaui::KillbillHelper::get_payment_attempt(@external_key, @invoice_id, @payment_id)
26
22
  @account = Kaui::KillbillHelper::get_account(@account_id)
27
23
  # TODO: get payment by payment id (no api at the moment)
28
24
  @payment = Kaui::KillbillHelper::get_payment(@invoice_id, @payment_id)
29
25
  @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
26
+ @chargeback = Kaui::Chargeback.new("payment_id" => @payment_id,
27
+ "chargeback_amount" => @payment.amount)
30
28
  end
31
29
 
32
30
  def create
31
+ account_id = params[:account_id]
33
32
  chargeback = Kaui::Chargeback.new(params[:chargeback])
34
- # TODO: read chargeback object from post params
35
- #Kaui::KillbillHelper::create_chargeback(@payment_id)
36
- redirect_to account_timeline_path(:id => chargeback.account_id)
33
+ if chargeback.present?
34
+ success = Kaui::KillbillHelper::create_chargeback(chargeback, params[:reason], params[:comment])
35
+ if success
36
+ flash[:info] = "Chargeback created"
37
+ end
38
+ end
39
+ flash[:error] = "Could not process chargeback"
40
+ redirect_to account_timeline_path(:id => params[:account_id])
37
41
  end
42
+
43
+
38
44
  end
@@ -18,21 +18,24 @@ class Kaui::RefundsController < ApplicationController
18
18
  @invoice_id = params[:invoice_id]
19
19
  @account_id = params[:account_id]
20
20
 
21
- @refund = Kaui::Refund.new(:payment_id => @payment_id,
22
- :invoice_id => @invoice_id,
23
- :account_id => @account_id)
21
+ @refund = Kaui::Refund.new('adjusted' => true)
24
22
 
25
23
  @account = Kaui::KillbillHelper::get_account(@account_id)
26
- # @payment_attempt = Kaui::KillbillHelper::get_payment_attempt(@external_key, @invoice_id, @payment_id)
27
24
  @payment = Kaui::KillbillHelper::get_payment(@invoice_id, @payment_id)
28
- puts "payment is #{@payment.to_yaml}"
29
25
  @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
30
26
  end
31
27
 
32
28
  def create
29
+ payment_id = params[:payment_id]
30
+ account_id = params[:account_id]
31
+
33
32
  refund = Kaui::Refund.new(params[:refund])
34
- # TODO: read refund object from post params
35
- #Kaui::KillbillHelper::create_refund(refund)
36
- redirect_to account_timeline_path(:id => refund.account_id)
33
+ refund.adjusted = (refund.adjusted == "1")
34
+ if refund.present?
35
+ Kaui::KillbillHelper::create_refund(params[:payment_id], refund, params[:reason], params[:comment])
36
+ redirect_to account_timeline_path(:id => params[:account_id])
37
+ else
38
+ flash[:error] = "No refund given to process"
39
+ end
37
40
  end
38
41
  end
@@ -2,6 +2,9 @@ require 'kaui/product'
2
2
 
3
3
  class Kaui::SubscriptionsController < ApplicationController
4
4
  def index
5
+ if params[:subscription_id].present?
6
+ redirect_to subscription_path(params[:subscription_id])
7
+ end
5
8
  end
6
9
 
7
10
  def show
@@ -19,7 +22,7 @@ class Kaui::SubscriptionsController < ApplicationController
19
22
  @billing_period = params[:billing_period]
20
23
  @price_list = params[:price_list]
21
24
 
22
- @subscription = Kaui::Subscription.new(:bundle_id => @bundle_id,
25
+ @subscription = Kaui::Subscription.new(:bundle_id => @bundle_id,
23
26
  :product_name => @product_name,
24
27
  :product_category => @product_category,
25
28
  :billing_period => @billing_period,
@@ -40,14 +43,14 @@ class Kaui::SubscriptionsController < ApplicationController
40
43
  flash[:error] = "No subscription id given or subscription not found"
41
44
  redirect_to :back
42
45
  end
43
- @products = Kaui::BASE_PRODUCTS
46
+ @products = Kaui::SAMPLE_BASE_PRODUCTS
44
47
  end
45
48
 
46
49
  def update
47
50
  if params.has_key?(:subscription) && params[:subscription].has_key?(:subscription_id)
48
51
  subscription = Kaui::KillbillHelper.get_subscription(params[:subscription][:subscription_id])
49
52
  product_id = params[:subscription][:product_name]
50
- products = Kaui::BASE_PRODUCTS.select{|p| p.id == product_id}
53
+ products = Kaui::SAMPLE_BASE_PRODUCTS.select{|p| p.id == product_id}
51
54
  unless products.empty?
52
55
  subscription.product_name = products[0].product_name
53
56
  subscription.billing_period = products[0].billing_period
@@ -7,11 +7,12 @@ module Kaui
7
7
  url = Kaui.killbill_finder.call + uri
8
8
  Rails.logger.info "Performing #{method} request to #{url}"
9
9
  response = RestClient.send(method.to_sym, url, *args)
10
- if response.code < 300
11
- return JSON.parse(response.body) if response.body.present?
10
+ data = { :code => response.code }
11
+ if response.code < 300 && response.body.present?
12
+ data[:json] = JSON.parse(response.body)
12
13
  end
13
14
  # TODO: error handling
14
- nil
15
+ data
15
16
  end
16
17
 
17
18
  ############## ACCOUNT ##############
@@ -19,7 +20,7 @@ module Kaui
19
20
  def self.get_account_timeline(account_id)
20
21
  begin
21
22
  data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/timeline"
22
- data.nil? ? nil : Kaui::AccountTimeline.new(data)
23
+ process_response(data, :single) {|json| Kaui::AccountTimeline.new(json) }
23
24
  rescue => e
24
25
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
25
26
  end
@@ -28,7 +29,7 @@ module Kaui
28
29
  def self.get_account(account_id)
29
30
  begin
30
31
  data = call_killbill :get, "/1.0/kb/accounts/#{account_id}"
31
- data.nil? ? nil : Kaui::Account.new(data)
32
+ process_response(data, :single) {|json| Kaui::Account.new(json) }
32
33
  rescue => e
33
34
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
34
35
  end
@@ -37,22 +38,19 @@ module Kaui
37
38
  def self.get_account_by_external_key(external_key)
38
39
  begin
39
40
  data = call_killbill :get, "/1.0/kb/accounts?external_key=#{external_key}"
40
- data.nil? ? nil : Kaui::Account.new(data)
41
+ process_response(data, :single) {|json| Kaui::Account.new(json) }
41
42
  rescue => e
42
43
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
43
44
  end
44
45
  end
45
46
 
47
+
46
48
  ############## BUNDLE ##############
47
49
 
48
50
  def self.get_bundles(account_id)
49
51
  begin
50
52
  data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/bundles"
51
- if data.nil?
52
- []
53
- else
54
- data.collect {|item| Kaui::Bundle.new(item) }
55
- end
53
+ process_response(data, :multiple) {|json| Kaui::Bundle.new(json) }
56
54
  rescue RestClient::BadRequest
57
55
  []
58
56
  rescue => e
@@ -63,7 +61,7 @@ module Kaui
63
61
  def self.get_bundle_by_external_key(external_key)
64
62
  begin
65
63
  data = call_killbill :get, "/1.0/kb/bundles?external_key=#{external_key}"
66
- data.nil? ? nil : Kaui::Bundle.new(data)
64
+ process_response(data, :single) {|json| Kaui::Bundle.new(json) }
67
65
  rescue => e
68
66
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
69
67
  end
@@ -72,7 +70,7 @@ module Kaui
72
70
  def self.get_bundle(bundle_id)
73
71
  begin
74
72
  data = call_killbill :get, "/1.0/kb/bundles/#{bundle_id}"
75
- data.nil? ? nil : Kaui::Bundle.new(data)
73
+ process_response(data, :single) {|json| Kaui::Bundle.new(json) }
76
74
  rescue => e
77
75
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
78
76
  end
@@ -81,11 +79,8 @@ module Kaui
81
79
  def self.get_bundles(account_id)
82
80
  begin
83
81
  data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/bundles"
84
- if data.nil?
85
- []
86
- else
87
- data.collect {|item| Kaui::Bundle.new(item) }
88
- end
82
+ process_response(data, :multiple) {|json| Kaui::Bundle.new(json) }
83
+
89
84
  rescue => e
90
85
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
91
86
  end
@@ -96,11 +91,7 @@ module Kaui
96
91
  def self.get_subscriptions_for_bundle(bundle_id)
97
92
  begin
98
93
  data = call_killbill :get, "/1.0/kb/bundles/#{bundle_id}/subscriptions"
99
- if data.nil?
100
- []
101
- else
102
- data.collect {|item| Kaui::Subscription.new(item) }
103
- end
94
+ process_response(data, :multiple) {|json| Kaui::Subscription.new(json) }
104
95
  rescue RestClient::BadRequest
105
96
  []
106
97
  rescue => e
@@ -127,7 +118,7 @@ module Kaui
127
118
  def self.get_subscription(subscription_id)
128
119
  begin
129
120
  data = call_killbill :get, "/1.0/kb/subscriptions/#{subscription_id}"
130
- data.nil? ? nil : Kaui::Subscription.new(data)
121
+ process_response(data, :single) {|json| Kaui::Subscription.new(json) }
131
122
  rescue => e
132
123
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
133
124
  end
@@ -135,14 +126,15 @@ module Kaui
135
126
 
136
127
  def self.create_subscription(subscription)
137
128
  begin
138
- data = Kaui::Subscription.camelize(subscription.to_hash)
139
- call_killbill :post,
140
- "/1.0/kb/subscriptions",
141
- ActiveSupport::JSON.encode(subscription, :root => false),
142
- :content_type => "application/json",
143
- "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
144
- "X-Killbill-Reason" => "Very special reason",
145
- "X-Killbill-Comment" => "Very special comment"
129
+ subscription_data = Kaui::Subscription.camelize(subscription.to_hash)
130
+ data = call_killbill :post,
131
+ "/1.0/kb/subscriptions",
132
+ ActiveSupport::JSON.encode(subscription_data, :root => false),
133
+ :content_type => "application/json",
134
+ "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
135
+ "X-Killbill-Reason" => "Very special reason",
136
+ "X-Killbill-Comment" => "Very special comment"
137
+ return data[:code] == 201
146
138
  rescue => e
147
139
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
148
140
  end
@@ -150,14 +142,15 @@ module Kaui
150
142
 
151
143
  def self.update_subscription(subscription)
152
144
  begin
153
- data = Kaui::Subscription.camelize(subscription.to_hash)
154
- call_killbill :put,
155
- "/1.0/kb/subscriptions/#{subscription.subscription_id}",
156
- ActiveSupport::JSON.encode(data, :root => false),
157
- :content_type => :json,
158
- "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
159
- "X-Killbill-Reason" => "Very special reason",
160
- "X-Killbill-Comment" => "Very special comment"
145
+ subscription_data = Kaui::Subscription.camelize(subscription.to_hash)
146
+ data = call_killbill :put,
147
+ "/1.0/kb/subscriptions/#{subscription.subscription_id}",
148
+ ActiveSupport::JSON.encode(subscription_data, :root => false),
149
+ :content_type => :json,
150
+ "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
151
+ "X-Killbill-Reason" => "Very special reason",
152
+ "X-Killbill-Comment" => "Very special comment"
153
+ return data[:code] == 200
161
154
  rescue => e
162
155
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
163
156
  end
@@ -165,12 +158,13 @@ module Kaui
165
158
 
166
159
  def self.reinstate_subscription(subscription_id)
167
160
  begin
168
- call_killbill :put,
169
- "/1.0/subscriptions/#{subscription_id}/uncancel",
170
- :content_type => :json,
171
- "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
172
- "X-Killbill-Reason" => "Very special reason",
173
- "X-Killbill-Comment" => "Very special comment"
161
+ data = call_killbill :put,
162
+ "/1.0/subscriptions/#{subscription_id}/uncancel",
163
+ :content_type => :json,
164
+ "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
165
+ "X-Killbill-Reason" => "Very special reason",
166
+ "X-Killbill-Comment" => "Very special comment"
167
+ return data[:code] == 200
174
168
  rescue => e
175
169
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
176
170
  end
@@ -178,40 +172,34 @@ module Kaui
178
172
 
179
173
  def self.delete_subscription(subscription_id)
180
174
  begin
181
- call_killbill :delete,
182
- "/1.0/kb/subscriptions/#{subscription_id}",
183
- "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
184
- "X-Killbill-Reason" => "Very special reason",
185
- "X-Killbill-Comment" => "Very special comment"
175
+ data = call_killbill :delete,
176
+ "/1.0/kb/subscriptions/#{subscription_id}",
177
+ "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
178
+ "X-Killbill-Reason" => "Very special reason",
179
+ "X-Killbill-Comment" => "Very special comment"
180
+ return data[:code] == 200
186
181
  rescue => e
187
182
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
188
183
  end
189
184
  end
190
185
 
191
- def self.create_addon(subscription_id)
192
- begin
193
- call_killbill :post, "/1.0/kb/payments/#{payment_id}/chargebacks"
194
- rescue => e
195
- puts "#{$!}\n\t" + e.backtrace.join("\n\t")
196
- end
197
- end
198
-
199
186
  ############## INVOICE ##############
200
187
 
201
188
  def self.get_invoice(invoice_id)
202
189
  begin
203
190
  data = call_killbill :get, "/1.0/kb/invoices/#{invoice_id}?withItems=true"
204
- data.nil? ? nil : Kaui::Invoice.new(data)
191
+ process_response(data, :single) {|json| Kaui::Invoice.new(json) }
205
192
  rescue => e
206
193
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
207
194
  end
208
195
  end
209
-
196
+
210
197
  ############## CATALOG ##############
211
198
 
212
199
  def self.get_available_addons
213
200
  begin
214
- call_killbill :get, "/1.0/catalog"
201
+ data = call_killbill :get, "/1.0/catalog/availableAddons"
202
+ return data[:json]
215
203
  rescue => e
216
204
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
217
205
  end
@@ -252,11 +240,7 @@ module Kaui
252
240
  def self.get_payments(invoice_id)
253
241
  begin
254
242
  data = call_killbill :get, "/1.0/kb/invoices/#{invoice_id}/payments"
255
- if data.nil?
256
- []
257
- else
258
- data.collect {|item| Kaui::Payment.new(item) }
259
- end
243
+ process_response(data, :single) {|json| Kaui::Payment.new(json) }
260
244
  rescue => e
261
245
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
262
246
  []
@@ -276,11 +260,7 @@ module Kaui
276
260
  def self.get_payment_methods(account_id)
277
261
  begin
278
262
  data = call_killbill :get, "/1.0/accounts/#{account_id}/paymentMethods"
279
- if data.nil?
280
- []
281
- else
282
- data.collect { |item| Kaui::PaymentMethod.new(item) }
283
- end
263
+ process_response(data, :single) {|json| Kaui::PaymentMethod.new(json) }
284
264
  rescue => e
285
265
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
286
266
  end
@@ -296,11 +276,19 @@ module Kaui
296
276
  end
297
277
  end
298
278
 
299
- def self.create_refund(payment_id)
279
+ def self.create_refund(payment_id, refund, reason, comment)
300
280
  begin
301
- # TODO: add handling when implemented
302
- #call_killbill :post, "/1.0/kb/payments/#{payment_id}/refunds"
303
- rescue
281
+ refund_data = Kaui::Refund.camelize(refund.to_hash)
282
+ data = call_killbill :post,
283
+ "/1.0/kb/payments/#{payment_id}/refunds",
284
+ ActiveSupport::JSON.encode(refund_data, :root => false),
285
+ :content_type => "application/json",
286
+ "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
287
+ "X-Killbill-Reason" => "#{reason}",
288
+ "X-Killbill-Comment" => "#{comment}"
289
+ return response[:code] == 201
290
+ rescue => e
291
+ puts "#{$!}\n\t" + e.backtrace.join("\n\t")
304
292
  end
305
293
  end
306
294
 
@@ -308,30 +296,35 @@ module Kaui
308
296
 
309
297
  def self.get_chargebacks_for_payment(payment_id)
310
298
  begin
311
- call_killbill :get, "/1.0/kb/payments/#{payment_id}/chargebacks"
299
+ data = call_killbill :get, "/1.0/kb/chargebacks/payments/#{payment_id}"
300
+ process_response(data, :single) {|json| Kaui::Chargeback.new(json) }
312
301
  rescue => e
313
302
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
314
303
  end
315
304
  end
316
305
 
317
- def self.create_chargeback(payment_id)
306
+ def self.create_chargeback(chargeback, reason, comment)
318
307
  begin
319
- call_killbill :post, "/1.0/kb/payments/#{payment_id}/chargebacks"
308
+ chargeback_data = Kaui::Refund.camelize(chargeback.to_hash)
309
+ data = call_killbill :post,
310
+ "/1.0/kb/chargebacks",
311
+ ActiveSupport::JSON.encode(chargeback_data, :root => false),
312
+ :content_type => "application/json",
313
+ "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
314
+ "X-Killbill-Reason" => "#{reason}",
315
+ "X-Killbill-Comment" => "#{comment}"
316
+ return data[:code] == 201
320
317
  rescue => e
321
318
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
322
319
  end
323
320
  end
324
321
 
325
- ############## TAG ##############
322
+ ############## TAG ##############
326
323
 
327
324
  def self.get_tag_definitions
328
325
  begin
329
326
  data = call_killbill :get, "/1.0/kb/tagDefinitions"
330
- if data.nil?
331
- []
332
- else
333
- data.collect {|item| Kaui::Tag.new(item) }
334
- end
327
+ process_response(data, :single) {|json| Kaui::Tag.new(json) }
335
328
  rescue => e
336
329
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
337
330
  []
@@ -341,6 +334,7 @@ module Kaui
341
334
  def self.get_tags_for_account(account_id)
342
335
  begin
343
336
  data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/tags"
337
+ return data[:json]
344
338
  rescue => e
345
339
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
346
340
  end
@@ -349,6 +343,7 @@ module Kaui
349
343
  def self.get_tags_for_bundle(bundle_id)
350
344
  begin
351
345
  data = call_killbill :get, "/1.0/kb/bundles/#{bundle_id}/tags"
346
+ return data[:json]
352
347
  rescue => e
353
348
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
354
349
  end
@@ -359,12 +354,13 @@ module Kaui
359
354
  begin
360
355
  if tags.nil? || tags.empty?
361
356
  else
362
- call_killbill :post,
363
- "/1.0/kb/accounts/#{account_id}/tags?" + RestClient::Payload.generate(:tag_list => tags.join(",")).to_s,
364
- nil,
365
- "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
366
- "X-Killbill-Reason" => "Very special reason",
367
- "X-Killbill-Comment" => "Very special comment"
357
+ data = call_killbill :post,
358
+ "/1.0/kb/accounts/#{account_id}/tags?" + RestClient::Payload.generate(:tag_list => tags.join(",")).to_s,
359
+ nil,
360
+ "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
361
+ "X-Killbill-Reason" => "Very special reason",
362
+ "X-Killbill-Comment" => "Very special comment"
363
+ return data[:code] == 201
368
364
  end
369
365
  rescue => e
370
366
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
@@ -375,17 +371,30 @@ module Kaui
375
371
  begin
376
372
  if tags.nil? || tags.empty?
377
373
  else
378
- call_killbill :post,
379
- "/1.0/kb/bundles/#{bundle_id}/tags?" + RestClient::Payload.generate(:tag_list => tags.join(",")).to_s,
380
- nil,
381
- "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
382
- "X-Killbill-Reason" => "Very special reason",
383
- "X-Killbill-Comment" => "Very special comment"
374
+ data = call_killbill :post,
375
+ "/1.0/kb/bundles/#{bundle_id}/tags?" + RestClient::Payload.generate(:tag_list => tags.join(",")).to_s,
376
+ nil,
377
+ "X-Killbill-CreatedBy" => Kaui.current_user.call.to_s,
378
+ "X-Killbill-Reason" => "Very special reason",
379
+ "X-Killbill-Comment" => "Very special comment"
380
+ return data[:code] == 201
384
381
  end
385
382
  rescue => e
386
383
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
387
384
  end
388
385
  end
389
386
 
387
+ private
388
+
389
+ def self.process_response(response, arity, &block)
390
+ if response.nil? || response[:json].nil?
391
+ arity == :single ? nil : []
392
+ elsif block_given?
393
+ arity == :single ? yield(response[:json]) : response[:json].collect {|item| yield(item) }
394
+ else
395
+ response[:json]
396
+ end
397
+ end
398
+
390
399
  end
391
400
  end
@@ -22,10 +22,11 @@ class Kaui::Chargeback < Kaui::Base
22
22
  "420 - Not as Described",
23
23
  "499 - OTHER" ]
24
24
 
25
- define_attr :account_id
26
25
  define_attr :payment_id
27
- define_attr :invoice_id
28
- define_attr :amount
29
- define_attr :comment
30
- define_attr :reason
26
+ define_attr :chargeback_amount
27
+
28
+ def initialize(data = {})
29
+ super(:payment_id => data['paymentId'] || data['payment_id'],
30
+ :chargeback_amount => data['chargebackAmount'] || data['chargeback_amount'])
31
+ end
31
32
  end
@@ -7,6 +7,9 @@ class Kaui::Invoice < Kaui::Base
7
7
  define_attr :account_id
8
8
  define_attr :invoice_number
9
9
  define_attr :payment_amount
10
+ define_attr :refund_adjustment
11
+ define_attr :credit_balance_adjustment
12
+ define_attr :credit_adjustment
10
13
  define_attr :invoice_dt
11
14
  define_attr :payment_dt
12
15
  define_attr :target_dt
@@ -20,6 +23,9 @@ class Kaui::Invoice < Kaui::Base
20
23
  :account_id => data['accountId'],
21
24
  :invoice_number => data['invoiceNumber'],
22
25
  :payment_amount => data['paymentAmount'],
26
+ :refund_adjustment => data['refundAdj'],
27
+ :credit_balance_adjustment => data['cba'],
28
+ :credit_adjustment => data['creditAdj'],
23
29
  :invoice_dt => data['invoiceDate'],
24
30
  :payment_dt => data['paymentDate'],
25
31
  :target_dt => data['targetDate'],
@@ -13,7 +13,7 @@ module Kaui
13
13
  end
14
14
  end
15
15
 
16
- SAMPLE_SAMPLE_BASE_PRODUCTS = [
16
+ SAMPLE_BASE_PRODUCTS = [
17
17
  Kaui::Product.new(:id => "product1", :product_category => "Base", :product_name => "OneBase", :billing_period => "ANNUAL"),
18
18
  Kaui::Product.new(:id => "product2", :product_category => "Base", :product_name => "TwoBase", :billing_period => "MONTHLY"),
19
19
  ]
@@ -1,14 +1,18 @@
1
+ require 'active_model'
2
+
1
3
  class Kaui::Refund < Kaui::Base
2
4
  SAMPLE_REASON_CODES = [ "500 - Courtesy",
3
- "501 - Billing Error",
4
- "502 - Alt payment method",
5
- "599 - OTHER" ]
5
+ "501 - Billing Error",
6
+ "502 - Alt payment method",
7
+ "599 - OTHER" ]
8
+
9
+ define_attr :refund_id
10
+ define_attr :adjusted
11
+ define_attr :refund_amount
6
12
 
7
- define_attr :account_id
8
- define_attr :external_key
9
- define_attr :payment_id
10
- define_attr :invoice_id
11
- define_attr :amount
12
- define_attr :comment
13
- define_attr :reason
13
+ def initialize(data = {})
14
+ super(:refund_id => data['refundId'] || data['refund_id'],
15
+ :adjusted => data['adjusted'],
16
+ :refund_amount => data['refundAmount'] || data['refund_amount'])
17
+ end
14
18
  end
@@ -7,7 +7,7 @@ class Kaui::Subscription < Kaui::Base
7
7
  define_attr :charged_through_date
8
8
  define_attr :price_list
9
9
  define_attr :start_date
10
- define_attr :cancelledDate
10
+ define_attr :canceledDate
11
11
  has_many :events, Kaui::Event
12
12
 
13
13
  def initialize(data = {})
@@ -19,7 +19,7 @@ class Kaui::Subscription < Kaui::Base
19
19
  :charged_through_date => data['chargedThroughDate'],
20
20
  :price_list => data['priceList'],
21
21
  :start_date => data['startDate'],
22
- :cancelledDate => data['cancelledDate'],
22
+ :canceledDate => data['cancelledDate'],
23
23
  :events => data['events'])
24
24
  end
25
25
  end
@@ -1,5 +1,5 @@
1
1
  <div class="page-header">
2
- <h3>Account <%= @account.name %></h3>
2
+ <h3>Account <%= @account.name %></h3>
3
3
  <%= link_to @account.email, Kaui.account_home_path.call(@account.external_key) %>
4
4
  </div>
5
5
  <form class="form-horizontal">
@@ -56,20 +56,29 @@
56
56
  <%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %><br/>
57
57
  <% end %>
58
58
  <% end %>
59
- </td>
59
+ </td>
60
60
  <td><%= "INVOICE" %></td>
61
- <td><%= "Amount:" %> <%= invoice.amount %><br/>
62
- <%= "Balance:" %> <%= invoice.balance %><br/>
63
- <%= "Invoice #" %>
61
+ <td><%= "Amount:" %> <%= invoice.amount %> <%= @account.currency %><br/>
62
+ <%= "Balance:" %> <%= invoice.balance %> <%= @account.currency %><br/>
63
+ <% if invoice.credit_adjustment.present? && invoice.credit_adjustment > 0 %>
64
+ <%= "Credit adjustment:" %> <%= invoice.credit_adjustment %> <%= @account.currency %> <br/>
65
+ <% end %>
66
+ <% if invoice.credit_balance_adjustment.present? && invoice.credit_balance_adjustment > 0 %>
67
+ <%= "Credit balance adjustment:" %> <%= invoice.credit_balance_adjustment %> <%= @account.currency %> <br/>
68
+ <% end %>
69
+ <% if invoice.refund_adjustment.present? && invoice.refund_adjustment < 0 %>
70
+ <%= "Refund adjustment:" %> <%= invoice.refund_adjustment %> <%= @account.currency %> <br/>
71
+ <% end %>
72
+ <%= "Invoice #" %>
64
73
  <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
65
- </td>
74
+ </td>
66
75
  <td></td>
67
76
  <td>
68
77
  <% if invoice.balance > 0 %>
69
78
  <nobr>
70
79
  <%= link_to "External Payment",
71
80
  kaui_engine.new_credit_path(:params => { :account_id => @account.account_id,
72
- :invoice_id => invoice.invoice_id }),
81
+ :invoice_id => invoice.invoice_id }),
73
82
  :class => "btn btn-mini" %>
74
83
  </nobr>
75
84
  <% end %>
@@ -106,34 +115,34 @@
106
115
  <% payment.bundle_keys.split(",").each do |bundle_key| %>
107
116
  <%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %><br/>
108
117
  <% end %>
109
- </td>
118
+ </td>
110
119
  <td><%= "PAYMENT" %></td>
111
120
  <td>
112
- <%= "Total amount:" %> <%= payment.amount %> <%= @account.currency %><br/>
113
- <%= "Paid amount:" %> <%= payment.amount %> <%= @account.currency %><br/>
121
+ <%= "Total amount:" %> <%= payment.amount %> <%= @account.currency %><br/>
122
+ <%= "Paid amount:" %> <%= payment.amount %> <%= @account.currency %><br/>
114
123
  <span <% if payment.status == 'Failed' %>class="alert-error" <% elsif payment.status == 'Success' %>class="alert-success" <% end %>>
115
124
  <%= payment.status %>
116
- </span>
125
+ </span>
117
126
  <br/>
118
127
  <%= "Invoice #" %> <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
119
128
  <td></td>
120
129
  <td>
121
130
  <% if payment.payment_id.present? %>
122
131
  <nobr>
123
- <%= link_to 'Refund', kaui_engine.new_refund_path(:params => { :payment_id => payment.payment_id,
132
+ <%= link_to 'Refund', kaui_engine.new_refund_path(:params => { :payment_id => payment.payment_id,
124
133
  :account_id => @account.account_id,
125
- :invoice_id => payment.invoice_id }),
134
+ :invoice_id => payment.invoice_id }),
126
135
  :class => "btn btn-mini" %>
127
- <%= link_to 'Chargeback', kaui_engine.new_chargeback_path(:params => { :payment_id => payment.payment_id,
136
+ <%= link_to 'Chargeback', kaui_engine.new_chargeback_path(:params => { :payment_id => payment.payment_id,
128
137
  :account_id => @account.account_id,
129
- :invoice_id => payment.invoice_id }),
138
+ :invoice_id => payment.invoice_id }),
130
139
  :class => "btn btn-mini" %>
131
140
  </nobr>
132
141
  <% elsif invoice.balance > 0 %>
133
- <%= link_to 'Pay', kaui_engine.new_chargeback_path(:params => { :payment_id => payment.payment_id,
142
+ <%= link_to 'Pay', kaui_engine.new_chargeback_path(:params => { :payment_id => payment.payment_id,
134
143
  :account_id => @account.account_id,
135
- :invoice_id => payment.invoice_id }),
136
- :class => "btn btn-mini" %>
144
+ :invoice_id => payment.invoice_id }),
145
+ :class => "btn btn-mini" %>
137
146
  <% end %>
138
147
  </td>
139
148
  </tr>
@@ -21,9 +21,9 @@
21
21
  <dt>State:</dt>
22
22
  <dd><%= @account.state %>&nbsp;</dd>
23
23
  <dt>Country:</dt>
24
- <dd><%= @account.country %>&nbsp;</dd>
24
+ <dd><%= @account.country %>&nbsp;</dd>
25
25
  <dt>Phone:</dt>
26
- <dd><%= @account.phone %>&nbsp;</dd>
26
+ <dd><%= @account.phone %>&nbsp;</dd>
27
27
  <dt>External key:</dt>
28
28
  <dd><%= @account.external_key %>&nbsp;</dd>
29
29
  <%= render :partial => "kaui/tags/tags_table",
@@ -1,8 +1,9 @@
1
1
  <div class="page-header">
2
- <h1>Create Payment Chargeback</h1>
2
+ <h1>Apply Payment Chargeback</h1>
3
3
  </div>
4
4
  <%= form_for(@chargeback, :url => { :action => :create }, :html => { :class => "form-horizontal" }) do |f| %>
5
- <%= f.hidden_field :account_id %>
5
+ <%= hidden_field_tag :account_id, @account_id %>
6
+ <%= hidden_field_tag :invoice_id, @invoice_id %>
6
7
  <%= f.hidden_field :payment_id %>
7
8
  <fieldset>
8
9
  <div class="control-group">
@@ -55,26 +56,26 @@
55
56
  </div>
56
57
  </div>
57
58
  <div class="control-group">
58
- <%= f.label :amount, "Chargeback amount", :class => "control-label" %>
59
+ <%= f.label :chaergeback_amount, "Chargeback amount", :class => "control-label" %>
59
60
  <div class="controls">
60
- <%= f.text_field :amount, :default => @payment.amount, :class => 'input-small' %>
61
+ <%= f.text_field :chargeback_amount, :class => 'input-small' %>
61
62
  <p class="help-inline"><%= @account.currency %></p>
62
63
  </div>
63
64
  </div>
64
65
  <div class="control-group">
65
- <%= f.label :reason, "Reason", :class => "control-label" %>
66
+ <%= label_tag :reason, "Reason", :class => "control-label" %>
66
67
  <div class="controls">
67
- <%= f.select :reason, Kaui::Chargeback::SAMPLE_REASON_CODES, {}, :class => 'input-xxlarge' %>
68
+ <%= select_tag :reason, options_for_select(Kaui::Chargeback::SAMPLE_REASON_CODES) %>
68
69
  </div>
69
70
  </div>
70
71
  <div class="control-group">
71
- <%= f.label :comment, :class => "control-label" %>
72
+ <%= label_tag :comment, "Comment", :class => "control-label" %>
72
73
  <div class="controls">
73
- <%= f.text_area :comment, :rows => 3, :class => 'input-xxlarge' %>
74
+ <%= text_area_tag :comment, "", :rows => 3, :class => 'input-xlarge' %>
74
75
  </div>
75
76
  </div>
76
77
  <div class="form-actions">
77
- <%= button_tag "Create refund", :class =>"btn btn-primary" %>
78
+ <%= button_tag "Apply chargeback", :class =>"btn btn-primary" %>
78
79
  <%= link_to 'Back', :back, :class => 'btn' %>
79
80
  </div>
80
81
  </fieldset>
@@ -2,8 +2,8 @@
2
2
  <h1>Refund Payment</h1>
3
3
  </div>
4
4
  <%= form_for(@refund, :url => { :action => :create }, :html => { :class => "form-horizontal" }) do |f| %>
5
- <%= f.hidden_field :account_id %>
6
- <%= f.hidden_field :payment_id %>
5
+ <%= hidden_field_tag :account_id, @account_id %>
6
+ <%= hidden_field_tag :payment_id, @payment_id %>
7
7
  <fieldset>
8
8
  <div class="control-group">
9
9
  <label class="control-label">Date</label>
@@ -46,6 +46,14 @@
46
46
  </label>
47
47
  </div>
48
48
  </div>
49
+ <div class="control-group">
50
+ <%= f.label :adjusted, "Adjust Invoice?", :class => "control-label" %>
51
+ <div class="controls">
52
+ <label class="checkbox">
53
+ <%= f.check_box :adjusted %>
54
+ </label>
55
+ </div>
56
+ </div>
49
57
  <div class="control-group">
50
58
  <label class="control-label">Payment</label>
51
59
  <div class="controls">
@@ -55,22 +63,22 @@
55
63
  </div>
56
64
  </div>
57
65
  <div class="control-group">
58
- <%= f.label :amount, "Refund amount", :class => "control-label" %>
66
+ <%= f.label :refund_amount, "Refund amount", :class => "control-label" %>
59
67
  <div class="controls">
60
- <%= f.text_field :amount, :value => @payment.amount, :class => 'input-small' %>
68
+ <%= f.text_field :refund_amount, :value => @payment.amount, :class => 'input-small' %>
61
69
  <p class="help-inline"><%= @account.currency %></p>
62
70
  </div>
63
71
  </div>
64
72
  <div class="control-group">
65
- <%= f.label :reason, "Reason", :class => "control-label" %>
73
+ <%= label_tag :reason, "Reason", :class => "control-label" %>
66
74
  <div class="controls">
67
- <%= f.select :reason, Kaui::Refund::SAMPLE_REASON_CODES %>
75
+ <%= select_tag :reason, options_for_select(Kaui::Refund::SAMPLE_REASON_CODES) %>
68
76
  </div>
69
77
  </div>
70
78
  <div class="control-group">
71
- <%= f.label :comment, :class => "control-label" %>
79
+ <%= label_tag :comment, "Comment", :class => "control-label" %>
72
80
  <div class="controls">
73
- <%= f.text_area :comment, :rows => 3, :class => 'input-xlarge' %>
81
+ <%= text_area_tag :comment, "", :rows => 3, :class => 'input-xlarge' %>
74
82
  </div>
75
83
  </div>
76
84
  <div class="form-actions">
@@ -9,8 +9,9 @@
9
9
  <th>Billing period</th>
10
10
  <th>Start date</th>
11
11
  <th>Charged through date</th>
12
+ <th>Notes</th>
12
13
  <th>Actions</th>
13
- </tr>
14
+ </tr>
14
15
  </thead>
15
16
  <tbody>
16
17
  <% if @subscriptions.present? && !@subscriptions.nil? %>
@@ -21,15 +22,21 @@
21
22
  <td><%= sub.billing_period.downcase.capitalize if sub.billing_period.present? %></td>
22
23
  <td><%= format_date(sub.start_date).html_safe %></td>
23
24
  <td><%= format_date(sub.charged_through_date).html_safe %></td>
25
+ <td>
26
+ <% if sub.canceledDate.present? %>
27
+ <%= "Canceled as of #{sub.canceledDate}" %>
28
+ <% end %>
29
+ </td>
24
30
  <td>
25
31
  <% if sub.product_category == 'BASE' %>
26
- <%= link_to "Change", kaui_engine.edit_subscription_path(sub.subscription_id), :class => "btn btn-mini" %>
32
+ <%= link_to "Change", kaui_engine.edit_subscription_path(sub.subscription_id), :class => "btn btn-mini" unless sub.canceledDate.present? %>
27
33
  <%= link_to "Cancel", kaui_engine.subscription_path(:id => sub.subscription_id), :method => :delete, :class => "btn btn-mini" %>
28
34
  <%= link_to "Add Addons", kaui_engine.subscription_path(sub.subscription_id), :method => :post, :class => "btn btn-mini" %>
29
35
  <% else %>
30
36
  <% end %>
31
37
  <% if sub.product_category == 'ADD_ON' %>
32
- <%= link_to "Cancel", kaui_engine.subscription_path(:id => sub.subscription_id), :method => :delete, :class => "btn btn-mini" %>
38
+ <%= link_to "Cancel", kaui_engine.subscription_path(:id => sub.subscription_id), :method => :delete, :class => "btn btn-mini" unless sub.canceledDate.present? %>
39
+ <%= link_to "Reinstate", kaui_engine.subscription_path(:id => sub.subscription_id), :method => :put, :class => "btn btn-mini" if sub.canceledDate.present? %>
33
40
  <% end %>
34
41
  </td>
35
42
  </tr>
@@ -1,4 +1,4 @@
1
- <% @page_title = "Edit Subscription: #{@subscription.subscription_id}" %>
1
+ <% @page_title = "Edit Subscription" %>
2
2
  <%= form_for(@subscription, :url => subscription_path(@subscription.subscription_id), :html => { :method => :put, :class => "form-horizontal" }) do |f| %>
3
3
  <%= f.hidden_field :subscription_id %>
4
4
  <div class="control-group">
@@ -21,7 +21,6 @@
21
21
  </div>
22
22
  <div class="form-actions">
23
23
  <%= f.submit "Change", :class => 'btn btn-primary' %>
24
- <%= link_to 'Show', kaui_engine.subscription_path(@subscription.subscription_id), :class => 'btn' %>
25
24
  <%= link_to 'Back', :back, :class => 'btn' %>
26
25
  </div>
27
26
  <% end %>
@@ -1,10 +1,10 @@
1
1
  <%= form_tag subscriptions_path, :class => "form-horizontal", :method => :get do %>
2
2
  <fieldset>
3
- <legend>Please enter bundle id</legend>
3
+ <legend>Please enter subsciption id</legend>
4
4
  <div class="control-group">
5
- <label class="control-label" for="bundle_id">Bundle</label>
5
+ <label class="control-label" for="subscription_id">Subscription</label>
6
6
  <div class="controls">
7
- <%= text_field_tag 'bundle_id', nil, :class => "input-xlarge", :id => "bundle_id" %>
7
+ <%= text_field_tag 'subscription_id', nil, :class => "input-xlarge", :id => "subscription_id" %>
8
8
  </div>
9
9
  </div>
10
10
  <div class="form-actions">
@@ -10,13 +10,12 @@
10
10
  <dd><%= @subscription.billing_period.downcase.capitalize %></dd>
11
11
  <dt>Charged through</dt>
12
12
  <dd> <%= format_date(@subscription.charged_through_date).html_safe %>
13
- <dd><%= DateTime.parse(@subscription.charged_through_date).utc.to_s(:pretty) %>&nbsp;UTC</dd>
14
13
  <dt>Price List</dt>
15
14
  <dd><%= @subscription.price_list %></dd>
16
15
  <dt>Start Date</dt>
17
- <dd><%= DateTime.parse(@subscription.start_date).utc.to_s(:pretty) %>&nbsp;UTC</dd>
16
+ <dd> <%= format_date(@subscription.start_date).html_safe %>
18
17
  </dl>
19
18
  <hr/>
20
19
  <%= link_to "Change", kaui_engine.edit_subscription_path(@subscription.subscription_id), :class => "btn btn-mini" %>
21
- <%= link_to "Cancel", kaui_engine.subscription_path(@subscription.subscription_id), :method => :delete, :confirm => "Are you sure ?", :class => "btn btn-mini" %>
20
+ <%= link_to "Cancel", kaui_engine.subscription_path(@subscription.subscription_id), :method => :delete, :confirm => "Are you sure?", :class => "btn btn-mini" %>
22
21
  <%= link_to "Add Addons", kaui_engine.subscription_path(@subscription.subscription_id), :method => :post, :class => "btn btn-mini" %>
data/lib/kaui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaui
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaui
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alena Dudzinskaya
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-09 00:00:00 Z
18
+ date: 2012-07-17 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Rails UI plugin for Killbill administration.