kaui 0.0.3 → 0.0.4

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.
@@ -1,8 +1,10 @@
1
1
  class Kaui::CreditsController < Kaui::EngineController
2
2
  def show
3
- @payment_id = params[:id]
4
- if @payment_id.present?
5
- data = Kaui::KillbillHelper::get_credits_for_payment(@payment_id)
3
+ @account_id = params[:account_id]
4
+ @invoice_id = params[:invoice_id]
5
+
6
+ # invoice id can be nil for account level credit
7
+ data = Kaui::KillbillHelper::get_credits(@account_id, @invoice_id)
6
8
  if data.present?
7
9
  @credit = Kaui::Credit.new(data)
8
10
  else
@@ -11,6 +11,7 @@ class Kaui::InvoicesController < Kaui::EngineController
11
11
  @invoice = Kaui::KillbillHelper.get_invoice(@invoice_id)
12
12
  if @invoice.present?
13
13
  @account = Kaui::KillbillHelper.get_account(@invoice.account_id)
14
+ @payments = Kaui::KillbillHelper.get_payments(@invoice_id)
14
15
  @subscriptions = {}
15
16
  @bundles = {}
16
17
  if @invoice.items.present?
@@ -33,4 +34,8 @@ class Kaui::InvoicesController < Kaui::EngineController
33
34
  flash[:error] = "No id given"
34
35
  end
35
36
  end
37
+
38
+ def show_html
39
+ render :text => Kaui::KillbillHelper.get_invoice_html(params[:id])
40
+ end
36
41
  end
@@ -22,7 +22,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
22
22
  if @base_subscription.present?
23
23
  @catalog = Kaui::KillbillHelper::get_available_addons(@base_subscription)
24
24
  else
25
- # TODO: call catalog to get base subscription types
25
+ @catalog = Kaui::KillbillHelper::get_available_base_plans()
26
26
  end
27
27
 
28
28
  @subscription = Kaui::Subscription.new("bundleId" => bundle_id)
@@ -37,7 +37,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
37
37
  @catalog = Kaui::KillbillHelper::get_available_addons(@base_subscription)
38
38
  @subscription.product_category = "ADD_ON"
39
39
  else
40
- # TODO: call catalog to get base subscription types
40
+ @catalog = Kaui::KillbillHelper::get_available_base_plans()
41
41
  @subscription.product_category = "BASE"
42
42
  end
43
43
 
@@ -76,25 +76,36 @@ class Kaui::SubscriptionsController < Kaui::EngineController
76
76
 
77
77
  def edit
78
78
  @subscription = Kaui::KillbillHelper.get_subscription(params[:id])
79
- unless @subscription.present?
79
+ if @subscription.present?
80
+ bundle_id = params[:bundle_id]
81
+ @bundle = Kaui::KillbillHelper::get_bundle(bundle_id)
82
+ @catalog = Kaui::KillbillHelper::get_available_base_plans
83
+ @current_plan = "#{@subscription.product_name} #{@subscription.billing_period}".humanize
84
+ if @subscription.price_list != "DEFAULT"
85
+ @current_plan += " (price list #{@subscription.price_list})"
86
+ end
87
+ else
80
88
  flash[:error] = "No subscription id given or subscription not found"
81
89
  redirect_to :back
82
90
  end
83
- @products = Kaui::SAMPLE_BASE_PRODUCTS
84
91
  end
85
92
 
86
93
  def update
87
94
  if params.has_key?(:subscription) && params[:subscription].has_key?(:subscription_id)
88
95
  subscription = Kaui::KillbillHelper.get_subscription(params[:subscription][:subscription_id])
89
- product_id = params[:subscription][:product_name]
90
- products = Kaui::SAMPLE_BASE_PRODUCTS.select{|p| p.id == product_id}
91
- unless products.empty?
92
- subscription.product_name = products[0].product_name
93
- subscription.billing_period = products[0].billing_period
94
- subscription.start_date = params[:subscription][:start_date]
95
- Kaui::KillbillHelper.update_subscription(subscription)
96
- end
97
- redirect_to :action => :show, :id => subscription.subscription_id
96
+ catalog = Kaui::KillbillHelper::get_available_base_plans
97
+ plan = catalog[params[:plan_name]]
98
+ start_date = params[:start_date]
99
+ subscription.billing_period = plan["billingPeriod"]
100
+ subscription.product_category = plan["productCategory"]
101
+ subscription.product_name = plan["productName"]
102
+ subscription.price_list = plan["priceListName"]
103
+ subscription.subscription_id = params[:subscription][:subscription_id]
104
+ # TODO: need to use entered start_date (or current date if none entered)
105
+
106
+ Kaui::KillbillHelper.update_subscription(subscription)
107
+
108
+ redirect_to :back
98
109
  else
99
110
  flash[:error] = "No subscription given"
100
111
  redirect_to :back
@@ -9,7 +9,11 @@ module Kaui
9
9
  response = RestClient.send(method.to_sym, url, *args)
10
10
  data = { :code => response.code }
11
11
  if response.code < 300 && response.body.present?
12
- data[:json] = JSON.parse(response.body)
12
+ if response.headers[:content_type] =~ /application\/json.*/
13
+ data[:json] = JSON.parse(response.body)
14
+ else
15
+ data[:body] = response.body
16
+ end
13
17
  end
14
18
  # TODO: error handling
15
19
  data
@@ -208,6 +212,15 @@ module Kaui
208
212
  end
209
213
  end
210
214
 
215
+ def self.get_invoice_html(invoice_id)
216
+ begin
217
+ data = call_killbill :get, "/1.0/kb/invoices/#{invoice_id}/html"
218
+ data[:body] if data.present?
219
+ rescue => e
220
+ puts "#{$!}\n\t" + e.backtrace.join("\n\t")
221
+ end
222
+ end
223
+
211
224
  ############## CATALOG ##############
212
225
 
213
226
  def self.get_available_addons(base_product_name)
@@ -221,6 +234,17 @@ module Kaui
221
234
  end
222
235
  end
223
236
 
237
+ def self.get_available_base_plans()
238
+ begin
239
+ data = call_killbill :get, "/1.0/kb/catalog/availableBasePlans"
240
+ if data.has_key?(:json)
241
+ data[:json].inject({}) {|catalog_hash, item| catalog_hash.merge!(item["planName"] => item) }
242
+ end
243
+ rescue => e
244
+ puts "#{$!}\n\t" + e.backtrace.join("\n\t")
245
+ end
246
+ end
247
+
224
248
  ############## PAYMENT ##############
225
249
 
226
250
  # def self.get_payment_attempt(external_key, invoice_id, payment_id)
@@ -15,6 +15,7 @@ class Kaui::Account < Kaui::Base
15
15
  define_attr :state
16
16
  define_attr :country
17
17
  define_attr :phone
18
+ has_one :bill_cycle_day, Kaui::BillCycleDay
18
19
 
19
20
  def initialize(data = {})
20
21
  super(:account_id => data['accountId'],
@@ -30,6 +31,7 @@ class Kaui::Account < Kaui::Base
30
31
  :company => data['company'],
31
32
  :state => data['state'],
32
33
  :country => data['country'],
33
- :phone => data['phone'])
34
+ :phone => data['phone'],
35
+ :bill_cycle_day => data['billCycleDay'])
34
36
  end
35
37
  end
@@ -0,0 +1,9 @@
1
+ class Kaui::BillCycleDay < Kaui::Base
2
+ define_attr :day_of_month_local
3
+ define_attr :day_of_month_utc
4
+
5
+ def initialize(data = {})
6
+ super(:day_of_month_local => data['dayOfMonthLocal'],
7
+ :day_of_month_utc => data['dayOfMonthUTC'])
8
+ end
9
+ end
@@ -24,9 +24,15 @@ class Kaui::Chargeback < Kaui::Base
24
24
 
25
25
  define_attr :payment_id
26
26
  define_attr :chargeback_amount
27
+ define_attr :requested_dt
28
+ define_attr :effective_dt
29
+ define_attr :reason
27
30
 
28
31
  def initialize(data = {})
29
32
  super(:payment_id => data['paymentId'] || data['payment_id'],
30
- :chargeback_amount => data['chargebackAmount'] || data['chargeback_amount'])
33
+ :chargeback_amount => data['chargebackAmount'] || data['chargeback_amount'],
34
+ :requested_dt => data['requestedDate'] || data['requested_date'] || data['requested_dt'],
35
+ :effective_dt => data['effectiveDate'] || data['effective_date'] || data['effective_dt'],
36
+ :reason => data['reason'])
31
37
  end
32
38
  end
@@ -1,11 +1,21 @@
1
1
  class Kaui::Credit < Kaui::Base
2
2
  SAMPLE_REASON_CODES = [ "100 - Courtesy",
3
- "101 - Billing Error",
4
- "199 - OTHER" ]
3
+ "101 - Billing Error",
4
+ "199 - OTHER" ]
5
5
 
6
6
  define_attr :account_id
7
7
  define_attr :invoice_id
8
- define_attr :amount
8
+ define_attr :credit_amount
9
+ define_attr :requested_dt
10
+ define_attr :effective_dt
9
11
  define_attr :comment
10
12
  define_attr :reason
13
+
14
+ def initialize(data = {})
15
+ super(:account_id => data['accountId'] || data['account_id'],
16
+ :invoice_id => data['invoiceId'] || data['invoice_id'],
17
+ :credit_amount => data['creditAmount'] || data['credit_amount'],
18
+ :requested_dt => data['requestedDate'],
19
+ :effective_dt => data['effectiveDate'])
20
+ end
11
21
  end
@@ -15,9 +15,11 @@ class Kaui::Payment < Kaui::Base
15
15
  define_attr :status
16
16
  define_attr :bundle_keys
17
17
 
18
+ has_many :refunds, Kaui::Refund
19
+ has_many :chargebacks, Kaui::Chargeback
20
+
18
21
  def initialize(data = {})
19
- super(
20
- :account_id => data['accountId'],
22
+ super(:account_id => data['accountId'],
21
23
  :amount => data['amount'],
22
24
  :currency => data['currency'],
23
25
  :effective_dt => data['effectiveDate'],
@@ -29,6 +31,8 @@ class Kaui::Payment < Kaui::Base
29
31
  :requested_dt => data['requestedDate'],
30
32
  :retry_count => data['retryCount'],
31
33
  :status => data['status'],
32
- :bundle_keys => data['bundleKeys'])
34
+ :bundle_keys => data['bundleKeys'],
35
+ :refunds => data['refunds'],
36
+ :chargebacks => data['chargebacks'])
33
37
  end
34
38
  end
@@ -7,12 +7,18 @@ class Kaui::Refund < Kaui::Base
7
7
  "599 - OTHER" ]
8
8
 
9
9
  define_attr :refund_id
10
+ define_attr :payment_id
10
11
  define_attr :adjusted
11
12
  define_attr :refund_amount
13
+ define_attr :requested_dt
14
+ define_attr :effective_dt
12
15
 
13
16
  def initialize(data = {})
14
17
  super(:refund_id => data['refundId'] || data['refund_id'],
18
+ :payment_id => data['paymentId'] || data['payment_id'],
15
19
  :adjusted => data['adjusted'],
16
- :refund_amount => data['refundAmount'] || data['refund_amount'])
20
+ :refund_amount => data['refundAmount'] || data['refund_amount'],
21
+ :requested_dt => data['requestedDate'] || data['requested_date'] || data['requested_dt'],
22
+ :effective_dt => data['effectiveDate'] || data['effective_date'] || data['effective_dt'])
17
23
  end
18
24
  end
@@ -14,8 +14,8 @@
14
14
  <table id="timeline-table" class="table table-condensed data-table">
15
15
  <thead>
16
16
  <tr>
17
- <th class="data-table-sort-desc sort-title-string">Requested Date</th>
18
- <th class="sort-title-string">Effective Date</th>
17
+ <th class="sort-title-string">Requested Date</th>
18
+ <th class="data-table-sort-desc sort-title-string">Effective Date</th>
19
19
  <th>Bundle Name</th>
20
20
  <th>Event Type</th>
21
21
  <th>Details</th>
@@ -38,14 +38,14 @@
38
38
  <td>
39
39
  <% if invoice.invoice_dt.present? %>
40
40
  <span class="hide" title="<%= invoice.invoice_dt %>"></span>
41
- <%= format_date(invoice.invoice_dt).html_safe %>
41
+ <%= invoice.invoice_dt %>
42
42
  <% else %>
43
43
  [unknown]
44
44
  <% end %>
45
45
  <td>
46
46
  <% if invoice.target_dt.present? %>
47
47
  <span class="hide" title="<%= invoice.target_dt %>"></span>
48
- <%= format_date(invoice.target_dt).html_safe %>
48
+ <%= invoice.target_dt %>
49
49
  <% else %>
50
50
  [unknown]
51
51
  <% end %>
@@ -76,7 +76,7 @@
76
76
  <td>
77
77
  <% if invoice.balance > 0 %>
78
78
  <nobr>
79
- <%= link_to "External Payment",
79
+ <%= link_to "Credit",
80
80
  kaui_engine.new_credit_path(:params => { :account_id => @account.account_id,
81
81
  :invoice_id => invoice.invoice_id }),
82
82
  :class => "btn btn-mini" %>
@@ -85,6 +85,76 @@
85
85
  </td>
86
86
  </tr>
87
87
  <% end %>
88
+ <% @timeline.payments.each do |payment| %>
89
+ <% payment.refunds.each do |refund| %>
90
+ <% bundles = payment.bundle_keys.split(",").map {|bundle_key| @bundle_names[bundle_key] }.join(",") %>
91
+ <tr title="<%= bundles %>">
92
+ <td>
93
+ <% if refund.requested_dt.present? %>
94
+ <span class="hide" title="<%= refund.requested_dt %>"></span>
95
+ <%= format_date(refund.requested_dt).html_safe %>
96
+ <% else %>
97
+ [unknown]
98
+ <% end %>
99
+ </td>
100
+ <td>
101
+ <% if refund.requested_dt.present? %>
102
+ <span class="hide" title="<%= refund.requested_dt %>"></span>
103
+ <%= format_date(refund.requested_dt).html_safe %>
104
+ <% else %>
105
+ [unknown]
106
+ <% end %>
107
+ </td>
108
+ <td>
109
+ <% payment.bundle_keys.split(",").each do |bundle_key| %>
110
+ <%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %><br/>
111
+ <% end %>
112
+ </td>
113
+ <td><%= "REFUND" %></td>
114
+ <td>
115
+ <%= "Adjusted:" %> <% if refund.adjusted %>yes<% else %>no<% end %><br/>
116
+ <%= "Payment id:" %> <%= refund.payment_id %><br/>
117
+ <%= "Refund Amount:" %> <%= refund.refund_amount %><br/>
118
+ </td>
119
+ <td></td>
120
+ <td></td>
121
+ </tr>
122
+ <% end %>
123
+ <% end %>
124
+ <% @timeline.payments.each do |payment| %>
125
+ <% payment.chargebacks.each do |chargeback| %>
126
+ <% bundles = payment.bundle_keys.split(",").map {|bundle_key| @bundle_names[bundle_key] }.join(",") %>
127
+ <tr title="<%= bundles %>">
128
+ <td>
129
+ <% if chargeback.effective_dt.present? %>
130
+ <span class="hide" title="<%= chargeback.effective_dt %>"></span>
131
+ <%= format_date(chargeback.effective_dt).html_safe %>
132
+ <% else %>
133
+ [unknown]
134
+ <% end %>
135
+ </td>
136
+ <td>
137
+ <% if chargeback.effective_dt.present? %>
138
+ <span class="hide" title="<%= chargeback.effective_dt %>"></span>
139
+ <%= format_date(chargeback.effective_dt).html_safe %>
140
+ <% else %>
141
+ [unknown]
142
+ <% end %>
143
+ </td>
144
+ <td>
145
+ <% payment.bundle_keys.split(",").each do |bundle_key| %>
146
+ <%= link_to @bundle_names[bundle_key], Kaui.bundle_home_path.call(bundle_key) %><br/>
147
+ <% end %>
148
+ </td>
149
+ <td><%= "CHARGEBACK" %></td>
150
+ <td>
151
+ <%= "Payment id:" %> <%= chargeback.payment_id %><br/>
152
+ <%= "Chargeback Amount:" %> <%= chargeback.chargeback_amount %><br/>
153
+ </td>
154
+ <td></td>
155
+ <td></td>
156
+ <% end %>
157
+ <% end %>
88
158
  <% @timeline.payments.each do |payment| %>
89
159
  <% if payment.bundle_keys.present? %>
90
160
  <% bundles = payment.bundle_keys.split(",").map {|bundle_key| @bundle_names[bundle_key] }.join(",") %>
@@ -118,13 +188,14 @@
118
188
  </td>
119
189
  <td><%= "PAYMENT" %></td>
120
190
  <td>
121
- <%= "Total amount:" %> <%= payment.amount %> <%= @account.currency %><br/>
122
- <%= "Paid amount:" %> <%= payment.amount %> <%= @account.currency %><br/>
123
- <span <% if payment.status == 'Failed' %>class="alert-error" <% elsif payment.status == 'Success' %>class="alert-success" <% end %>>
191
+ <%= "Total amount:" %> <%= payment.amount %> <%= @account.currency if payment.amount.present? %><br/>
192
+ <%= "Paid amount:" %> <%= payment.paid_amount %> <%= @account.currency %><br/>
193
+ <span <% if payment.status == 'FAILED' %>class="alert-error" <% elsif payment.status == 'SUCCESS' %>class="alert-success" <% end %>>
124
194
  <%= payment.status %>
125
195
  </span>
126
196
  <br/>
127
197
  <%= "Invoice #" %> <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
198
+ </td>
128
199
  <td></td>
129
200
  <td>
130
201
  <% if payment.payment_id.present? %>
@@ -6,8 +6,8 @@
6
6
  <dd><%= @account.name %>&nbsp;</dd>
7
7
  <dt>Email:</dt>
8
8
  <dd><%= @account.email %>&nbsp;</dd>
9
- <dt>Billing day:</dt>
10
- <dd><%= @account.billing_day %>&nbsp;</dd>
9
+ <dt>Bill cycle day:</dt>
10
+ <dd><%= @account.bill_cycle_day.day_of_month_local %> (user timezone) / <%= @account.bill_cycle_day.day_of_month_utc %> (UTC)</dd>
11
11
  <dt>Currency:</dt>
12
12
  <dd><%= @account.currency %>&nbsp;</dd>
13
13
  <dt>Timezone:</dt>
@@ -1,5 +1,5 @@
1
1
  <div class="page-header">
2
- <h1>Apply External Payment</h1>
2
+ <h1>Apply Credit</h1>
3
3
  </div>
4
4
  <%= form_for(@credit, :url => { :action => :create }, :html => { :class => "form-horizontal" }) do |f| %>
5
5
  <%= f.hidden_field :account_id %>
@@ -13,14 +13,6 @@
13
13
  </label>
14
14
  </div>
15
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
16
  <div class="control-group">
25
17
  <label class="control-label">Account name</label>
26
18
  <div class="controls">
@@ -30,26 +22,36 @@
30
22
  </label>
31
23
  </div>
32
24
  </div>
33
- <div class="control-group">
34
- <label class="control-label">Invoice amount</label>
35
- <div class="controls">
36
- <label class="checkbox">
37
- <%= @invoice.amount %> <%= @account.currency %>
38
- </label>
25
+ <% if @invoice.present? %>
26
+ <div class="control-group">
27
+ <label class="control-label">Invoice number</label>
28
+ <div class="controls">
29
+ <label class="checkbox">
30
+ <%= @invoice.invoice_number %><br/>
31
+ </label>
32
+ </div>
39
33
  </div>
40
- </div>
41
- <div class="control-group">
42
- <label class="control-label">Balance</label>
43
- <div class="controls">
44
- <label class="checkbox">
45
- <%= @invoice.balance.nil? ? "0.00" : @invoice.balance %> <%= @account.currency %>
46
- </label>
34
+ <div class="control-group">
35
+ <label class="control-label">Invoice amount</label>
36
+ <div class="controls">
37
+ <label class="checkbox">
38
+ <%= @invoice.amount %> <%= @account.currency %>
39
+ </label>
40
+ </div>
47
41
  </div>
48
- </div>
42
+ <div class="control-group">
43
+ <label class="control-label">Balance</label>
44
+ <div class="controls">
45
+ <label class="checkbox">
46
+ <%= @invoice.balance.nil? ? "0.00" : @invoice.balance %> <%= @account.currency %>
47
+ </label>
48
+ </div>
49
+ </div>
50
+ <% end %>
49
51
  <div class="control-group">
50
52
  <%= f.label :amount, "Credit amount", :class => "control-label" %>
51
53
  <div class="controls">
52
- <%= f.text_field :amount, :value => @invoice.amount, :class => 'input-small' %>
54
+ <%= f.text_field :amount, :class => 'input-small' %>
53
55
  <p class="help-inline"><%= @account.currency %></p>
54
56
  </div>
55
57
  </div>
@@ -58,7 +60,7 @@
58
60
  <div class="controls">
59
61
  <%= f.select :reason, Kaui::Credit::SAMPLE_REASON_CODES %>
60
62
  </div>
61
- </div>
63
+ </div>
62
64
  <div class="control-group">
63
65
  <%= f.label :comment, :class => "control-label" %>
64
66
  <div class="controls">
@@ -1,5 +1,5 @@
1
1
  <% if @invoice.present? %>
2
- <h3>Invoice number: <%= @invoice.invoice_number %></h3>
2
+ <h3>Invoice number: INV<%= @invoice.invoice_number %></h3>
3
3
  <dl class="dl-horizontal">
4
4
  <dt>Account Name:</dt>
5
5
  <dd><%= @account.name %>&nbsp;</dd>
@@ -49,9 +49,12 @@
49
49
  </tbody>
50
50
  </table>
51
51
  <div class="page-header">
52
- <h3>Payments</h3>
52
+ <% if @payments.present? %>
53
+ <%= render :partial => "kaui/payments/payments_table" %>
54
+ <% end %>
53
55
  </div>
54
56
  <% else %>
55
57
  <p>Invoice not found</p>
56
58
  <% end %>
57
59
  <%= link_to 'Back', :back, :class => 'btn' %>
60
+ <%= link_to "View customer invoice html", kaui_engine.show_html_invoice_path(@invoice.invoice_id), :class => 'btn', :target => "_blank" %>
@@ -0,0 +1,31 @@
1
+ <div class="page-header">
2
+ <h3>Payments</h3>
3
+ </div>
4
+ <table class="table table-condensed table-striped data-table">
5
+ <thead>
6
+ <tr>
7
+ <th>Requested date</th>
8
+ <th>Effective date</th>
9
+ <th>Total amount</th>
10
+ <th>Paid amount</th>
11
+ <th>Payment method</th>
12
+ <th>Retry count</th>
13
+ <th>Status</th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <% if @payments.present? %>
18
+ <% @payments.each do |payment| %>
19
+ <tr>
20
+ <td><%= format_date(payment.requested_dt).html_safe if payment.requested_dt.present? %></td>
21
+ <td><%= format_date(payment.effective_dt).html_safe if payment.effective_dt.present? %></td>
22
+ <td><%= payment.amount %> <%= @account.currency if payment.amount.present? %></td>
23
+ <td><%= payment.paid_amount %> <%= @account.currency if payment.paid_amount.present? %></td>
24
+ <td></td>
25
+ <td><%= payment.retry_count %></td>
26
+ <td><%= payment.status %></td>
27
+ </tr>
28
+ <% end %>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
@@ -20,8 +20,8 @@
20
20
  <td><%= sub.product_category.downcase.capitalize if sub.product_category.present? %></td>
21
21
  <td><%= sub.product_name.downcase.capitalize if sub.product_name.present? %></td>
22
22
  <td><%= sub.billing_period.downcase.capitalize if sub.billing_period.present? %></td>
23
- <td><%= format_date(sub.start_date).html_safe %></td>
24
- <td><%= format_date(sub.charged_through_date).html_safe %></td>
23
+ <td><%= format_date(sub.start_date).html_safe if sub.start_date.present? %></td>
24
+ <td><%= format_date(sub.charged_through_date).html_safe if sub.charged_through_date.present? %></td>
25
25
  <td>
26
26
  <% if sub.canceled_date.present? %>
27
27
  <%= "Pending cancellation on " %> <%= format_date(sub.canceled_date).html_safe %>
@@ -2,21 +2,21 @@
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">
5
- <%= label_tag 'plan', 'Current product:', :class => "control-label" %>
5
+ <%= label_tag :current_plan, 'Current plan:', :class => "control-label" %>
6
6
  <div class="controls">
7
- <input class="input-xlarge disabled" disabled="disabled" value="<%= "#{@subscription.product_name} #{@subscription.billing_period}".humanize %>"/>
7
+ <%= text_field_tag :current_plan, @current_plan, :class => 'input-xlarge disabled', :disabled => "disabled" %>
8
8
  </div>
9
9
  </div>
10
10
  <div class="control-group">
11
- <%= f.label :product_name, "New product:", :class => "control-label" %>
11
+ <%= label_tag :plan_name, "New plan:", :class => "control-label" %>
12
12
  <div class="controls">
13
- <%= select :subscription, :product_name, @products.collect { |p| ["#{p.product_name} #{p.billing_period}".humanize, p.id] }, { :include_blank => true }, { :class => 'input-xlarge' } %>
13
+ <%= select_tag :plan_name, options_for_select(@catalog.keys, @plan_name) %>
14
14
  </div>
15
15
  </div>
16
16
  <div class="control-group">
17
- <%= f.label :start_date, 'Change Date:', :class => "control-label" %>
17
+ <%= label_tag :start_date, 'Change Date:', :class => "control-label" %>
18
18
  <div class="controls">
19
- <%= text_field :subscription, :start_date, :value => nil ,:class => 'input-xlarge date-picker' %>
19
+ <%= text_field_tag :start_date, nil, :class => 'input-xlarge date-picker' %>
20
20
  </div>
21
21
  </div>
22
22
  <div class="form-actions">
@@ -1,5 +1,5 @@
1
1
  <div class="page-header">
2
- <h1>Add subscription to <%= Kaui.bundle_key_display_string.call(@bundle.external_key) %></h1>
2
+ <h1>Add subscription <% if @bundle.external_key %> to <%= Kaui.bundle_key_display_string.call(@bundle.external_key) %> <% end %></h1>
3
3
  </div>
4
4
  <%= form_for(@subscription, :url => { :action => :create }, :html => { :class => "form-horizontal" }) do |f| %>
5
5
  <fieldset>
@@ -1,21 +1,26 @@
1
- <div class="page-header">
2
- <h2>Subscription <%= @subscription.id %></h2>
3
- </div>
4
- <dl class="dl-horizontal">
5
- <dt>Category</dt>
6
- <dd><%= @subscription.product_category.downcase.capitalize %></dd>
7
- <dt>Product</dt>
8
- <dd><%= @subscription.product_name.downcase.capitalize %></dd>
9
- <dt>Period</dt>
10
- <dd><%= @subscription.billing_period.downcase.capitalize %></dd>
11
- <dt>Charged through</dt>
12
- <dd> <%= format_date(@subscription.charged_through_date).html_safe %>
13
- <dt>Price List</dt>
14
- <dd><%= @subscription.price_list %></dd>
15
- <dt>Start Date</dt>
16
- <dd> <%= format_date(@subscription.start_date).html_safe %>
17
- </dl>
18
- <hr/>
19
- <%= link_to "Change", kaui_engine.edit_subscription_path(@subscription.subscription_id), :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" %>
21
- <%= link_to "Add Addons", kaui_engine.new_subscription_path(:params => { :bundle_id => @subscription.bundle_id, :base_subscription => @subscription.product_name }), :class => "btn btn-mini" %>
1
+ <% if @invoice.present? %>
2
+ <div class="page-header">
3
+ <h2>Subscription <%= @subscription.id %></h2>
4
+ </div>
5
+ <dl class="dl-horizontal">
6
+ <dt>Category</dt>
7
+ <dd><%= @subscription.product_category.downcase.capitalize if @subscription.product_category.present? %></dd>
8
+ <dt>Product</dt>
9
+ <dd><%= @subscription.product_name.downcase.capitalize if @subscription.product_name.present? %></dd>
10
+ <dt>Period</dt>
11
+ <dd><%= @subscription.billing_period.downcase.capitalize if @subscription.billing_period.present? %></dd>
12
+ <dt>Charged through</dt>
13
+ <dd> <%= format_date(@subscription.charged_through_date).html_safe if @subscription.charged_through_date.present? %>
14
+ <dt>Price List</dt>
15
+ <dd><%= @subscription.price_list %></dd>
16
+ <dt>Start Date</dt>
17
+ <dd> <%= format_date(@subscription.start_date).html_safe if @subscription.start_date.present? %>
18
+ </dl>
19
+ <hr/>
20
+ <%= 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" %>
22
+ <%= link_to "Add Addons", kaui_engine.new_subscription_path(:params => { :bundle_id => @subscription.bundle_id, :base_subscription => @subscription.product_name }), :class => "btn btn-mini" %>
23
+ <% else %>
24
+ <p>Subscription not found</p>
25
+ <% end %>
26
+ <%= link_to 'Back', :back, :class => 'btn' %>
data/config/routes.rb CHANGED
@@ -25,7 +25,11 @@ Kaui::Engine.routes.draw do
25
25
 
26
26
  resources :refunds, :only => [ :show, :create, :new ]
27
27
 
28
- resources :invoices, :only => [ :index, :show ]
28
+ resources :invoices, :only => [ :index, :show ] do
29
+ member do
30
+ get :show_html
31
+ end
32
+ end
29
33
 
30
34
  resources :bundles, :only => [ :index, :show ]
31
35
 
data/lib/kaui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaui
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
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: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
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-23 00:00:00 Z
18
+ date: 2012-07-24 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Rails UI plugin for Killbill administration.
@@ -67,6 +67,7 @@ files:
67
67
  - app/models/kaui/account.rb
68
68
  - app/models/kaui/account_timeline.rb
69
69
  - app/models/kaui/base.rb
70
+ - app/models/kaui/bill_cycle_day.rb
70
71
  - app/models/kaui/bundle.rb
71
72
  - app/models/kaui/chargeback.rb
72
73
  - app/models/kaui/credit.rb
@@ -101,6 +102,7 @@ files:
101
102
  - app/views/kaui/payment_methods/_payment_methods_table.html.erb
102
103
  - app/views/kaui/payment_methods/index.html.erb
103
104
  - app/views/kaui/payment_methods/show.html.erb
105
+ - app/views/kaui/payments/_payments_table.html.erb
104
106
  - app/views/kaui/refunds/index.html.erb
105
107
  - app/views/kaui/refunds/new.html.erb
106
108
  - app/views/kaui/refunds/show.html.erb