kaui 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,7 @@ class Kaui::AccountsController < Kaui::EngineController
19
19
  end
20
20
 
21
21
  if @account.present?
22
- @payment_methods = Kaui::KillbillHelper.get_payment_methods(@account_id)
22
+ @payment_methods = Kaui::KillbillHelper.get_payment_methods(@account.account_id)
23
23
  else
24
24
  flash[:error] = "Account #{@account_id} not found"
25
25
  redirect_to :action => :index
@@ -30,31 +30,26 @@ class Kaui::AccountsController < Kaui::EngineController
30
30
  end
31
31
 
32
32
  def payment_methods
33
- @external_key = params[:id]
34
- if @external_key.present?
35
- @payment_methods = Kaui::KillbillHelper::get_payment_methods(@external_key)
33
+ @account_id = params[:id]
34
+ if @account_id.present?
35
+ @payment_methods = Kaui::KillbillHelper.get_payment_methods(@account_id)
36
36
  unless @payment_methods.is_a?(Array)
37
- flash[:notice] = "No payment methods for external_key '#{@external_key}'"
37
+ flash[:notice] = "No payment methods for account_id '#{@account_id}'"
38
38
  redirect_to :action => :index
39
39
  return
40
40
  end
41
41
  else
42
- flash[:notice] = "No id given"
42
+ flash[:notice] = "No account_id given"
43
43
  end
44
44
  end
45
45
 
46
46
  def set_default_payment_method
47
47
  @account_id = params[:id]
48
- # TODO
49
- redirect_to :back
50
- end
51
-
52
- def delete_payment_method
53
48
  @payment_method_id = params[:payment_method_id]
54
- if @payment_method_id.present?
55
- Kaui::KillbillHelper::delete_payment_method(@payment_method_id)
49
+ if @account_id.present? && @payment_method_id.present?
50
+ @payment_methods = Kaui::KillbillHelper.set_payment_method_as_default(@account_id, @payment_method_id)
56
51
  else
57
- flash[:notice] = "No id given"
52
+ flash[:notice] = "No account_id or payment_method_id given"
58
53
  end
59
54
  redirect_to :back
60
55
  end
@@ -1,4 +1,5 @@
1
1
  class Kaui::ChargebacksController < Kaui::EngineController
2
+
2
3
  def show
3
4
  @payment_id = params[:id]
4
5
  if @payment_id.present?
@@ -42,6 +43,4 @@ class Kaui::ChargebacksController < Kaui::EngineController
42
43
  end
43
44
  redirect_to account_timeline_path(:id => params[:account_id])
44
45
  end
45
-
46
-
47
46
  end
@@ -20,8 +20,7 @@ class Kaui::CreditsController < Kaui::EngineController
20
20
  @account_id = params[:account_id]
21
21
  @invoice_id = params[:invoice_id]
22
22
 
23
- @credit = Kaui::Credit.new(:invoice_id => @invoice_id,
24
- :account_id => @account_id)
23
+ @credit = Kaui::Credit.new("accountId" => @account_id, "invoiceId" => @invoice_id)
25
24
 
26
25
  @account = Kaui::KillbillHelper::get_account(@account_id)
27
26
  @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
@@ -29,8 +28,12 @@ class Kaui::CreditsController < Kaui::EngineController
29
28
 
30
29
  def create
31
30
  credit = Kaui::Credit.new(params[:credit])
32
- # TODO: read credit object from post params
33
- #Kaui::KillbillHelper::create_credit(@payment_id)
34
- redirect_to account_timeline_path(:id => credit.account_id)
31
+ success = Kaui::KillbillHelper::create_credit(credit, current_user, params[:reason], params[:comment])
32
+ if success
33
+ flash[:info] = "Credit created"
34
+ else
35
+ flash[:error] = "Error while creating credit"
36
+ end
37
+ redirect_to account_timeline_path(credit.account_id)
35
38
  end
36
39
  end
@@ -0,0 +1,23 @@
1
+ class Kaui::ExternalPaymentsController < Kaui::EngineController
2
+ def new
3
+ invoice_id = params[:invoice_id]
4
+ @account_id = params[:account_id]
5
+
6
+ @external_payment = Kaui::ExternalPayment.new("invoiceId" => invoice_id, "accountId" => @account_id)
7
+
8
+ @account = Kaui::KillbillHelper::get_account(@account_id)
9
+ @invoice = Kaui::KillbillHelper::get_invoice(invoice_id)
10
+ end
11
+
12
+ def create
13
+ external_payment = Kaui::ExternalPayment.new(params[:external_payment])
14
+
15
+ success = Kaui::KillbillHelper::create_external_payment(external_payment, current_user, params[:reason], params[:comment])
16
+ if success
17
+ flash[:info] = "External Payment created"
18
+ # else
19
+ # flash[:error] = "Error while creating external payment"
20
+ end
21
+ redirect_to account_timeline_path(external_payment.account_id)
22
+ end
23
+ end
@@ -4,4 +4,14 @@ class Kaui::PaymentMethodsController < Kaui::EngineController
4
4
  def show
5
5
  # TODO: show payment method details
6
6
  end
7
+
8
+ def destroy
9
+ @payment_method_id = params[:id]
10
+ if @payment_method_id.present?
11
+ Kaui::KillbillHelper.delete_payment_method(@payment_method_id)
12
+ else
13
+ flash[:notice] = "Did not get the payment method id"
14
+ end
15
+ redirect_to :back
16
+ end
7
17
  end
@@ -1,4 +1,29 @@
1
- module Kaui
2
- class PaymentsController < ApplicationController
1
+ class Kaui::PaymentsController < Kaui::EngineController
2
+
3
+ def new
4
+ @invoice_id = params[:invoice_id]
5
+ @account_id = params[:account_id]
6
+
7
+ @payment = Kaui::Payment.new("invoiceId" => @invoice_id)
8
+
9
+ @account = Kaui::KillbillHelper::get_account(@account_id)
10
+ @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
3
11
  end
12
+
13
+ def create
14
+ external_payment = Kaui::Payment.new(params[:external_payment])
15
+
16
+ if external_payment.present?
17
+ success = Kaui::KillbillHelper::create_external_payment(payment, current_user, params[:reason], params[:comment])
18
+ if success
19
+ flash[:info] = "External Payment created"
20
+ # else
21
+ # flash[:error] = "Error while creating external payment"
22
+ end
23
+ else
24
+ flash[:error] = "No external payment to process"
25
+ end
26
+ redirect_to account_timeline_path(:id => params[:account_id])
27
+ end
28
+
4
29
  end
@@ -32,7 +32,7 @@ class Kaui::RefundsController < Kaui::EngineController
32
32
  refund = Kaui::Refund.new(params[:refund])
33
33
  refund.adjusted = (refund.adjusted == "1")
34
34
  if refund.present?
35
- success = Kaui::KillbillHelper::create_refund(params[:payment_id], refund, params[:reason], params[:comment])
35
+ success = Kaui::KillbillHelper::create_refund(params[:payment_id], refund, current_user, params[:reason], params[:comment])
36
36
  if success
37
37
  flash[:info] = "Refund created"
38
38
  else
@@ -77,8 +77,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
77
77
  def edit
78
78
  @subscription = Kaui::KillbillHelper.get_subscription(params[:id])
79
79
  if @subscription.present?
80
- bundle_id = params[:bundle_id]
81
- @bundle = Kaui::KillbillHelper::get_bundle(bundle_id)
80
+ @bundle = Kaui::KillbillHelper::get_bundle(@subscription.bundle_id)
82
81
  @catalog = Kaui::KillbillHelper::get_available_base_plans
83
82
  @current_plan = "#{@subscription.product_name} #{@subscription.billing_period}".humanize
84
83
  if @subscription.price_list != "DEFAULT"
@@ -92,10 +91,13 @@ class Kaui::SubscriptionsController < Kaui::EngineController
92
91
 
93
92
  def update
94
93
  if params.has_key?(:subscription) && params[:subscription].has_key?(:subscription_id)
95
- subscription = Kaui::KillbillHelper.get_subscription(params[:subscription][:subscription_id])
94
+ subscription = Kaui::KillbillHelper::get_subscription(params[:subscription][:subscription_id])
95
+ bundle = Kaui::KillbillHelper::get_bundle(subscription.bundle_id)
96
96
  catalog = Kaui::KillbillHelper::get_available_base_plans
97
+
97
98
  plan = catalog[params[:plan_name]]
98
99
  start_date = params[:start_date]
100
+
99
101
  subscription.billing_period = plan["billingPeriod"]
100
102
  subscription.product_category = plan["productCategory"]
101
103
  subscription.product_name = plan["productName"]
@@ -103,9 +105,8 @@ class Kaui::SubscriptionsController < Kaui::EngineController
103
105
  subscription.subscription_id = params[:subscription][:subscription_id]
104
106
  # TODO: need to use entered start_date (or current date if none entered)
105
107
 
106
- Kaui::KillbillHelper.update_subscription(subscription)
107
-
108
- redirect_to :back
108
+ Kaui::KillbillHelper::update_subscription(subscription)
109
+ redirect_to Kaui.bundle_home_path.call(bundle.external_key)
109
110
  else
110
111
  flash[:error] = "No subscription given"
111
112
  redirect_to :back
@@ -115,7 +116,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
115
116
  def reinstate
116
117
  subscription_id = params[:id]
117
118
  if subscription_id.present?
118
- success = Kaui::KillbillHelper.reinstate_subscription(subscription_id, current_user)
119
+ success = Kaui::KillbillHelper::reinstate_subscription(subscription_id, current_user)
119
120
  if success
120
121
  flash[:info] = "Subscription reinstated"
121
122
  else
@@ -130,7 +131,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
130
131
  def destroy
131
132
  subscription_id = params[:id]
132
133
  if subscription_id.present?
133
- Kaui::KillbillHelper.delete_subscription(subscription_id)
134
+ Kaui::KillbillHelper::delete_subscription(subscription_id)
134
135
  redirect_to :back
135
136
  else
136
137
  flash[:error] = "No subscription id given"
@@ -55,7 +55,7 @@ module Kaui
55
55
 
56
56
  def self.get_account_by_external_key(external_key)
57
57
  begin
58
- data = call_killbill :get, "/1.0/kb/accounts?external_key=#{external_key}"
58
+ data = call_killbill :get, "/1.0/kb/accounts?externalKey=#{external_key}"
59
59
  process_response(data, :single) {|json| Kaui::Account.new(json) }
60
60
  rescue => e
61
61
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
@@ -76,9 +76,9 @@ module Kaui
76
76
  end
77
77
  end
78
78
 
79
- def self.get_bundle_by_external_key(external_key)
79
+ def self.get_bundle_by_external_key(account_id, external_key)
80
80
  begin
81
- data = call_killbill :get, "/1.0/kb/bundles?external_key=#{external_key}"
81
+ data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/bundles?externalKey=#{external_key}"
82
82
  process_response(data, :single) {|json| Kaui::Bundle.new(json) }
83
83
  rescue => e
84
84
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
@@ -221,6 +221,28 @@ module Kaui
221
221
  end
222
222
  end
223
223
 
224
+ ############## EXTERNAL PAYMENT ##############
225
+
226
+ def self.create_external_payment(payment, current_user = nil, reason = nil, comment = nil)
227
+ begin
228
+ payment_data = Kaui::ExternalPayment.camelize(payment.to_hash)
229
+ if payment.invoice_id.present?
230
+ data = call_killbill :post,
231
+ "/1.0/kb/invoices/#{payment.invoice_id}/payments?externalPayment=true",
232
+ ActiveSupport::JSON.encode(payment_data, :root => false),
233
+ :content_type => "application/json",
234
+ "X-Killbill-CreatedBy" => current_user,
235
+ "X-Killbill-Reason" => extract_reason_code(reason),
236
+ "X-Killbill-Comment" => "#{comment}"
237
+ return data[:code] < 300
238
+ else
239
+ return false
240
+ end
241
+ rescue => e
242
+ puts "#{$!}\n\t" + e.backtrace.join("\n\t")
243
+ end
244
+ end
245
+
224
246
  ############## CATALOG ##############
225
247
 
226
248
  def self.get_available_addons(base_product_name)
@@ -294,10 +316,10 @@ module Kaui
294
316
 
295
317
  ############## PAYMENT METHOD ##############
296
318
 
297
- def self.delete_payment_method(account_id, payment_method_id, current_user = nil, reason = nil, comment = nil)
319
+ def self.delete_payment_method(payment_method_id, current_user = nil, reason = nil, comment = nil)
298
320
  begin
299
321
  call_killbill :delete,
300
- "/1.0/kb/accounts/#{account_id}/paymentMethods/#{payment_method_id}",
322
+ "/1.0/kb/paymentMethods/#{payment_method_id}",
301
323
  "X-Killbill-CreatedBy" => current_user,
302
324
  "X-Killbill-Reason" => "#{reason}",
303
325
  "X-Killbill-Comment" => "#{comment}"
@@ -315,6 +337,20 @@ module Kaui
315
337
  end
316
338
  end
317
339
 
340
+ def self.set_payment_method_as_default(account_id, payment_method_id, current_user = nil, reason = nil, comment = nil)
341
+ begin
342
+ data = call_killbill :put, "/1.0/kb/accounts/#{account_id}/paymentMethods/#{payment_method_id}/setDefault",
343
+ "",
344
+ :content_type => :json,
345
+ "X-Killbill-CreatedBy" => current_user,
346
+ "X-Killbill-Reason" => extract_reason_code(reason),
347
+ "X-Killbill-Comment" => "#{comment}"
348
+ return data[:code] < 300
349
+ rescue => e
350
+ puts "#{$!}\n\t" + e.backtrace.join("\n\t")
351
+ end
352
+ end
353
+
318
354
  ############## REFUND ##############
319
355
 
320
356
  def self.get_refunds_for_payment(payment_id)
@@ -6,8 +6,8 @@ class Kaui::Credit < Kaui::Base
6
6
  define_attr :account_id
7
7
  define_attr :invoice_id
8
8
  define_attr :credit_amount
9
- define_attr :requested_dt
10
- define_attr :effective_dt
9
+ define_attr :requested_date
10
+ define_attr :effective_date
11
11
  define_attr :comment
12
12
  define_attr :reason
13
13
 
@@ -15,7 +15,7 @@ class Kaui::Credit < Kaui::Base
15
15
  super(:account_id => data['accountId'] || data['account_id'],
16
16
  :invoice_id => data['invoiceId'] || data['invoice_id'],
17
17
  :credit_amount => data['creditAmount'] || data['credit_amount'],
18
- :requested_dt => data['requestedDate'],
19
- :effective_dt => data['effectiveDate'])
18
+ :requested_date => data['requestedDate'] || data['requested_date'],
19
+ :effective_date => data['effectiveDate'] || data['effective_date'])
20
20
  end
21
21
  end
@@ -0,0 +1,15 @@
1
+ class Kaui::ExternalPayment < Kaui::Base
2
+
3
+ SAMPLE_REASON_CODES = [ "600 - Alt payment method",
4
+ "699 - OTHER" ]
5
+
6
+ define_attr :amount
7
+ define_attr :invoice_id
8
+ define_attr :account_id
9
+
10
+ def initialize(data = {})
11
+ super(:amount => data['amount'],
12
+ :invoice_id => data['invoiceId'] || data['invoice_id'],
13
+ :account_id => data['accountId'] || data['account_id'])
14
+ end
15
+ end
@@ -1,6 +1,10 @@
1
1
  require 'active_model'
2
2
 
3
3
  class Kaui::Payment < Kaui::Base
4
+
5
+ SAMPLE_REASON_CODES = [ "600 - Alt payment method",
6
+ "699 - OTHER" ]
7
+
4
8
  define_attr :account_id
5
9
  define_attr :amount
6
10
  define_attr :currency
@@ -19,19 +23,19 @@ class Kaui::Payment < Kaui::Base
19
23
  has_many :chargebacks, Kaui::Chargeback
20
24
 
21
25
  def initialize(data = {})
22
- super(:account_id => data['accountId'],
26
+ super(:account_id => data['accountId'] || data['account_id'],
23
27
  :amount => data['amount'],
24
28
  :currency => data['currency'],
25
- :effective_dt => data['effectiveDate'],
26
- :invoice_id => data['invoiceId'],
27
- :paid_amount => data['paidAmount'],
28
- :payment_id => data['paymentId'],
29
- :payment_method_id => data['paymentMethodId'],
30
- :refund_amount => data['refundAmount'],
31
- :requested_dt => data['requestedDate'],
32
- :retry_count => data['retryCount'],
29
+ :effective_dt => data['effectiveDate'] || data['effective_dt'],
30
+ :invoice_id => data['invoiceId'] || data['invoice_id'],
31
+ :paid_amount => data['paidAmount'] || data['paid_amount'],
32
+ :payment_id => data['paymentId'] || data['payment_id'],
33
+ :payment_method_id => data['paymentMethodId'] || data['payment_method_id'],
34
+ :refund_amount => data['refundAmount'] || data['refund_amount'],
35
+ :requested_dt => data['requestedDate'] || data['requested_dt'],
36
+ :retry_count => data['retryCount'] || data['retry_count'],
33
37
  :status => data['status'],
34
- :bundle_keys => data['bundleKeys'],
38
+ :bundle_keys => data['bundleKeys'] || data['bundle_keys'],
35
39
  :refunds => data['refunds'],
36
40
  :chargebacks => data['chargebacks'])
37
41
  end
@@ -81,10 +81,16 @@
81
81
  <% if invoice.balance > 0 %>
82
82
  <nobr>
83
83
  <%= link_to "Credit",
84
- kaui_engine.new_credit_path(:params => { :account_id => @account.account_id,
84
+ kaui_engine.new_credit_path(:params => { :account_id => invoice.account_id,
85
85
  :invoice_id => invoice.invoice_id }),
86
86
  :class => "btn btn-mini" %>
87
87
  </nobr>
88
+ <nobr>
89
+ <%= link_to "External Payment",
90
+ kaui_engine.new_external_payment_path(:params => { :account_id => invoice.account_id,
91
+ :invoice_id => invoice.invoice_id }),
92
+ :class => "btn btn-mini" %>
93
+ </nobr>
88
94
  <% end %>
89
95
  </td>
90
96
  </tr>
@@ -49,22 +49,28 @@
49
49
  </div>
50
50
  <% end %>
51
51
  <div class="control-group">
52
- <%= f.label :amount, "Credit amount", :class => "control-label" %>
52
+ <%= f.label :credit_amount, "Credit amount", :class => "control-label" %>
53
53
  <div class="controls">
54
- <%= f.text_field :amount, :class => 'input-small' %>
54
+ <%= f.text_field :credit_amount, :class => 'input-small' %>
55
55
  <p class="help-inline"><%= @account.currency %></p>
56
56
  </div>
57
57
  </div>
58
58
  <div class="control-group">
59
- <%= f.label :reason, "Reason", :class => "control-label" %>
59
+ <%= f.label :effective_date, 'Effective Date:', :class => "control-label" %>
60
60
  <div class="controls">
61
- <%= f.select :reason, Kaui::Credit::SAMPLE_REASON_CODES %>
61
+ <%= f.text_field :effective_date, :class => 'input-xlarge date-picker' %>
62
62
  </div>
63
63
  </div>
64
64
  <div class="control-group">
65
- <%= f.label :comment, :class => "control-label" %>
65
+ <%= label_tag :reason, "Reason", :class => "control-label" %>
66
66
  <div class="controls">
67
- <%= f.text_area :comment, :rows => 3, :class => 'input-xlarge' %>
67
+ <%= select_tag :reason, options_for_select(Kaui::Credit::SAMPLE_REASON_CODES) %>
68
+ </div>
69
+ </div>
70
+ <div class="control-group">
71
+ <%= label_tag :comment, "Comment", :class => "control-label" %>
72
+ <div class="controls">
73
+ <%= text_area_tag :comment, "", :rows => 3, :class => 'input-xlarge' %>
68
74
  </div>
69
75
  </div>
70
76
  <div class="form-actions">
@@ -0,0 +1,56 @@
1
+ <div class="page-header">
2
+ <h1>Apply External Payment</h1>
3
+ </div>
4
+ <%= form_for(@external_payment, :url => { :action => :create }, :html => { :class => "form-horizontal" }) do |f| %>
5
+ <%= f.hidden_field :invoice_id %>
6
+ <%= f.hidden_field :account_id %>
7
+ <fieldset>
8
+ <div class="control-group">
9
+ <label class="control-label">Date</label>
10
+ <div class="controls">
11
+ <label class="checkbox">
12
+ <%= DateTime.now.to_s(:pretty) %>
13
+ </label>
14
+ </div>
15
+ </div>
16
+ <div class="control-group">
17
+ <label class="control-label">Invoice number</label>
18
+ <div class="controls">
19
+ <label class="checkbox">
20
+ <%= @invoice.invoice_number %><br/>
21
+ </label>
22
+ </div>
23
+ </div>
24
+ <div class="control-group">
25
+ <label class="control-label">Account name</label>
26
+ <div class="controls">
27
+ <label class="checkbox">
28
+ <%= @account.name %><br/>
29
+ <%= @account.email %>
30
+ </label>
31
+ </div>
32
+ <div class="control-group">
33
+ <%= f.label :amount, "Amount", :class => "control-label" %>
34
+ <div class="controls">
35
+ <%= f.text_field :amount, :class => 'input-small' %>
36
+ <p class="help-inline"><%= @account.currency %></p>
37
+ </div>
38
+ </div>
39
+ <div class="control-group">
40
+ <%= label_tag :reason, "Reason", :class => "control-label" %>
41
+ <div class="controls">
42
+ <%= select_tag :reason, options_for_select(Kaui::ExternalPayment::SAMPLE_REASON_CODES) %>
43
+ </div>
44
+ </div>
45
+ <div class="control-group">
46
+ <%= label_tag :comment, "Comment", :class => "control-label" %>
47
+ <div class="controls">
48
+ <%= text_area_tag :comment, "", :rows => 3, :class => 'input-xlarge' %>
49
+ </div>
50
+ </div>
51
+ <div class="form-actions">
52
+ <%= button_tag "Create payment", :class =>"btn btn-primary" %>
53
+ <%= link_to 'Back', :back, :class => 'btn' %>
54
+ </div>
55
+ </fieldset>
56
+ <% end %>
@@ -25,9 +25,14 @@
25
25
  <td>
26
26
  <% if payment_method.is_default %>
27
27
  <i class="icon-ok"></i>
28
+ <% else %>
29
+ <%= link_to "Make Default", kaui_engine.set_default_payment_method_account_path(payment_method.account_id, :params => { :payment_method_id => payment_method.payment_method_id }), :method => :put, :confirm => "Are you sure you want to make this payment method default?", :class => "btn btn-mini" %>
28
30
  <% end %>
29
31
  </td>
30
32
  <td>
33
+ <% unless payment_method.is_default %>
34
+ <%= link_to "Delete", kaui_engine.payment_method_path(payment_method.payment_method_id), :method => :delete, :confirm => "Are you sure you want to delete this payment method?", :class => "btn btn-mini" %>
35
+ <% end %>
31
36
  </td>
32
37
  </tr>
33
38
  <% end %>
@@ -0,0 +1,56 @@
1
+ <div class="page-header">
2
+ <h1>Apply External Payment</h1>
3
+ </div>
4
+ <%= form_for(@payment, :url => { :action => :create }, :html => { :class => "form-horizontal" }) do |f| %>
5
+ <%= hidden_field_tag :account_id, @account_id %>
6
+ <%= hidden_field_tag :invoice_id, @invoice_id %>
7
+ <fieldset>
8
+ <div class="control-group">
9
+ <label class="control-label">Date</label>
10
+ <div class="controls">
11
+ <label class="checkbox">
12
+ <%= DateTime.now.to_s(:pretty) %>
13
+ </label>
14
+ </div>
15
+ </div>
16
+ <div class="control-group">
17
+ <label class="control-label">Invoice number</label>
18
+ <div class="controls">
19
+ <label class="checkbox">
20
+ <%= @invoice.invoice_number %><br/>
21
+ </label>
22
+ </div>
23
+ </div>
24
+ <div class="control-group">
25
+ <label class="control-label">Account name</label>
26
+ <div class="controls">
27
+ <label class="checkbox">
28
+ <%= @account.name %><br/>
29
+ <%= @account.email %>
30
+ </label>
31
+ </div>
32
+ <div class="control-group">
33
+ <%= f.label :amount, "Amount", :class => "control-label" %>
34
+ <div class="controls">
35
+ <%= f.text_field :amount, :class => 'input-small' %>
36
+ <p class="help-inline"><%= @account.currency %></p>
37
+ </div>
38
+ </div>
39
+ <div class="control-group">
40
+ <%= label_tag :reason, "Reason", :class => "control-label" %>
41
+ <div class="controls">
42
+ <%= select_tag :reason, options_for_select(Kaui::Payment::SAMPLE_REASON_CODES) %>
43
+ </div>
44
+ </div>
45
+ <div class="control-group">
46
+ <%= label_tag :comment, "Comment", :class => "control-label" %>
47
+ <div class="controls">
48
+ <%= text_area_tag :comment, "", :rows => 3, :class => 'input-xlarge' %>
49
+ </div>
50
+ </div>
51
+ <div class="form-actions">
52
+ <%= button_tag "Create refund", :class =>"btn btn-primary" %>
53
+ <%= link_to 'Back', :back, :class => 'btn' %>
54
+ </div>
55
+ </fieldset>
56
+ <% end %>
@@ -23,8 +23,8 @@
23
23
  <td><%= format_date(sub.start_date).html_safe if sub.start_date.present? %></td>
24
24
  <td><%= format_date(sub.charged_through_date).html_safe if sub.charged_through_date.present? %></td>
25
25
  <td>
26
- <% if sub.canceled_date.present? %>
27
- <%= "Pending cancellation on " %> <%= format_date(sub.canceled_date).html_safe %>
26
+ <% if sub.canceled_date.present? && !sub.canceled_date.nil? %>
27
+ <% if Time.parse(sub.canceled_date) > Time.now %> <%= "Pending cancellation on " %> <% else %> <%= "Canceled on " %> <% end %> <%= format_date(sub.canceled_date).html_safe %>
28
28
  <% end %>
29
29
  </td>
30
30
  <td>
data/config/routes.rb CHANGED
@@ -21,7 +21,9 @@ Kaui::Engine.routes.draw do
21
21
 
22
22
  resources :credits, :only => [ :create, :new ]
23
23
 
24
- resources :payment_methods, :only => [ :show ]
24
+ resources :external_payments, :only => [ :create, :new ]
25
+
26
+ resources :payment_methods, :only => [ :show, :destroy ]
25
27
 
26
28
  resources :refunds, :only => [ :show, :create, :new ]
27
29
 
data/lib/kaui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaui
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
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: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
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-26 00:00:00 Z
18
+ date: 2012-07-31 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Rails UI plugin for Killbill administration.
@@ -54,6 +54,7 @@ files:
54
54
  - app/controllers/kaui/chargebacks_controller.rb
55
55
  - app/controllers/kaui/credits_controller.rb
56
56
  - app/controllers/kaui/engine_controller.rb
57
+ - app/controllers/kaui/external_payments_controller.rb
57
58
  - app/controllers/kaui/home_controller.rb
58
59
  - app/controllers/kaui/invoices_controller.rb
59
60
  - app/controllers/kaui/payment_methods_controller.rb
@@ -72,6 +73,7 @@ files:
72
73
  - app/models/kaui/chargeback.rb
73
74
  - app/models/kaui/credit.rb
74
75
  - app/models/kaui/event.rb
76
+ - app/models/kaui/external_payment.rb
75
77
  - app/models/kaui/invoice.rb
76
78
  - app/models/kaui/invoice_item.rb
77
79
  - app/models/kaui/payment.rb
@@ -99,6 +101,7 @@ files:
99
101
  - app/views/kaui/credits/index.html.erb
100
102
  - app/views/kaui/credits/new.html.erb
101
103
  - app/views/kaui/credits/show.html.erb
104
+ - app/views/kaui/external_payments/new.html.erb
102
105
  - app/views/kaui/home/index.html.erb
103
106
  - app/views/kaui/invoices/index.html.erb
104
107
  - app/views/kaui/invoices/show.html.erb
@@ -106,6 +109,7 @@ files:
106
109
  - app/views/kaui/payment_methods/index.html.erb
107
110
  - app/views/kaui/payment_methods/show.html.erb
108
111
  - app/views/kaui/payments/_payments_table.html.erb
112
+ - app/views/kaui/payments/new.html.erb
109
113
  - app/views/kaui/refunds/index.html.erb
110
114
  - app/views/kaui/refunds/new.html.erb
111
115
  - app/views/kaui/refunds/show.html.erb