kaui 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -101,7 +101,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
101
101
  subscription.billing_period = plan["billingPeriod"]
102
102
  subscription.product_category = plan["productCategory"]
103
103
  subscription.product_name = plan["productName"]
104
- subscription.price_list = plan["priceListName"]
104
+ subscription.price_list = params[:subscription][:price_list]
105
105
  subscription.subscription_id = params[:subscription][:subscription_id]
106
106
  # TODO: need to use entered start_date (or current date if none entered)
107
107
 
@@ -37,7 +37,7 @@ module Kaui
37
37
 
38
38
  def self.get_account_timeline(account_id)
39
39
  begin
40
- data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/timeline"
40
+ data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/timeline?audit=true"
41
41
  process_response(data, :single) {|json| Kaui::AccountTimeline.new(json) }
42
42
  rescue => e
43
43
  puts "#{$!}\n\t" + e.backtrace.join("\n\t")
@@ -103,10 +103,10 @@ module Kaui
103
103
  end
104
104
  end
105
105
 
106
- def self.transfer_bundle(bundle_id, new_account_id, current_user = nil, reason = nil, comment = nil)
106
+ def self.transfer_bundle(bundle_id, new_account_id, cancel_immediately = false, transfer_addons = true, current_user = nil, reason = nil, comment = nil)
107
107
  begin
108
108
  data = call_killbill :put,
109
- "/1.0/kb/bundles/#{bundle_id}",
109
+ "/1.0/kb/bundles/#{bundle_id}?cancelImmediately=#{cancel_immediately}&transferAddOn=#{transfer_addons}",
110
110
  ActiveSupport::JSON.encode("accountId" => new_account_id),
111
111
  :content_type => :json,
112
112
  "X-Killbill-CreatedBy" => current_user,
@@ -0,0 +1,28 @@
1
+ require 'active_model'
2
+
3
+ class Kaui::AuditLog < Kaui::Base
4
+ define_attr :change_date
5
+ define_attr :change_type
6
+ define_attr :changed_by
7
+ define_attr :comments
8
+ define_attr :reason_code
9
+
10
+ def initialize(data = {})
11
+ super(:change_date => data['changeDate'],
12
+ :change_type => data['changeType'],
13
+ :changed_by => data['changedBy'],
14
+ :comments => data['comments'],
15
+ :reason_code => data['reasonCode'])
16
+ end
17
+
18
+ def description
19
+ changed_str = "Performed by #{changed_by} on #{ActionController::Base.helpers.format_date(change_date)}"
20
+ if reason_code.blank? && comments.blank?
21
+ changed_str
22
+ elsif reason_code.blank?
23
+ "#{changed_str}: #{comments}"
24
+ else
25
+ "#{changed_str} (#{reason_code} #{comments})"
26
+ end
27
+ end
28
+ end
@@ -4,12 +4,15 @@ class Kaui::Bundle < Kaui::Base
4
4
  define_attr :account_id
5
5
  define_attr :external_key
6
6
  define_attr :bundle_id
7
+
7
8
  has_many :subscriptions, Kaui::Subscription
9
+ has_many :audit_logs, Kaui::AuditLog
8
10
 
9
11
  def initialize(data = {})
10
12
  super(:external_key => data['externalKey'],
11
13
  :bundle_id => data['bundleId'],
12
14
  :account_id => data['accountId'],
13
- :subscriptions => data['subscriptions'])
15
+ :subscriptions => data['subscriptions'],
16
+ :audit_logs => data['auditLogs'])
14
17
  end
15
18
  end
@@ -28,11 +28,14 @@ class Kaui::Chargeback < Kaui::Base
28
28
  define_attr :effective_dt
29
29
  define_attr :reason
30
30
 
31
+ has_many :audit_logs, Kaui::AuditLog
32
+
31
33
  def initialize(data = {})
32
34
  super(:payment_id => data['paymentId'] || data['payment_id'],
33
35
  :chargeback_amount => data['chargebackAmount'] || data['chargeback_amount'],
34
36
  :requested_dt => data['requestedDate'] || data['requested_date'] || data['requested_dt'],
35
37
  :effective_dt => data['effectiveDate'] || data['effective_date'] || data['effective_dt'],
36
- :reason => data['reason'])
38
+ :reason => data['reason'],
39
+ :audit_logs => data['auditLogs'])
37
40
  end
38
41
  end
@@ -8,6 +8,8 @@ class Kaui::Event < Kaui::Base
8
8
  define_attr :product
9
9
  define_attr :requested_dt
10
10
 
11
+ has_many :audit_logs, Kaui::AuditLog
12
+
11
13
  def initialize(data = {})
12
14
  super(:event_id => data['eventId'],
13
15
  :billing_period => data['billingPeriod'],
@@ -16,6 +18,7 @@ class Kaui::Event < Kaui::Base
16
18
  :phase => data['phase'],
17
19
  :price_list => data['priceList'],
18
20
  :product => data['product'],
19
- :requested_dt => data['requestedDate'])
21
+ :requested_dt => data['requestedDate'],
22
+ :audit_logs => data['auditLogs'])
20
23
  end
21
24
  end
@@ -14,7 +14,9 @@ class Kaui::Invoice < Kaui::Base
14
14
  define_attr :payment_dt
15
15
  define_attr :target_dt
16
16
  define_attr :bundle_keys
17
+
17
18
  has_many :items, Kaui::InvoiceItem
19
+ has_many :audit_logs, Kaui::AuditLog
18
20
 
19
21
  def initialize(data = {})
20
22
  super(
@@ -29,6 +31,7 @@ class Kaui::Invoice < Kaui::Base
29
31
  :refund_adjustment => data['refundAdj'],
30
32
  :target_dt => data['targetDate'],
31
33
  :items => data['items'],
32
- :bundle_keys => data['bundleKeys'])
34
+ :bundle_keys => data['bundleKeys'],
35
+ :audit_logs => data['auditLogs'])
33
36
  end
34
37
  end
@@ -21,6 +21,7 @@ class Kaui::Payment < Kaui::Base
21
21
 
22
22
  has_many :refunds, Kaui::Refund
23
23
  has_many :chargebacks, Kaui::Chargeback
24
+ has_many :audit_logs, Kaui::AuditLog
24
25
 
25
26
  def initialize(data = {})
26
27
  super(:account_id => data['accountId'] || data['account_id'],
@@ -37,6 +38,7 @@ class Kaui::Payment < Kaui::Base
37
38
  :status => data['status'],
38
39
  :bundle_keys => data['bundleKeys'] || data['bundle_keys'],
39
40
  :refunds => data['refunds'],
40
- :chargebacks => data['chargebacks'])
41
+ :chargebacks => data['chargebacks'],
42
+ :audit_logs => data['auditLogs'])
41
43
  end
42
44
  end
@@ -13,12 +13,15 @@ class Kaui::Refund < Kaui::Base
13
13
  define_attr :requested_dt
14
14
  define_attr :effective_dt
15
15
 
16
+ has_many :audit_logs, Kaui::AuditLog
17
+
16
18
  def initialize(data = {})
17
19
  super(:refund_id => data['refundId'] || data['refund_id'],
18
20
  :payment_id => data['paymentId'] || data['payment_id'],
19
21
  :adjusted => data['adjusted'],
20
22
  :refund_amount => data['refundAmount'] || data['refund_amount'],
21
23
  :requested_dt => data['requestedDate'] || data['requested_date'] || data['requested_dt'],
22
- :effective_dt => data['effectiveDate'] || data['effective_date'] || data['effective_dt'])
24
+ :effective_dt => data['effectiveDate'] || data['effective_date'] || data['effective_dt'],
25
+ :audit_logs => data['auditLogs'])
23
26
  end
24
27
  end
@@ -8,6 +8,7 @@ class Kaui::Subscription < Kaui::Base
8
8
  define_attr :price_list
9
9
  define_attr :start_date
10
10
  define_attr :canceled_date
11
+
11
12
  has_many :events, Kaui::Event
12
13
 
13
14
  def initialize(data = {})
@@ -76,7 +76,13 @@
76
76
  <%= "Invoice #" %>
77
77
  <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
78
78
  </td>
79
- <td></td>
79
+ <td>
80
+ <% if invoice_stub.audit_logs.present? %>
81
+ <% invoice_stub.audit_logs.each do |entry| %>
82
+ <%= entry.description unless entry.changed_by == 'Transition' %><br/>
83
+ <% end %>
84
+ <% end %>
85
+ </td>
80
86
  <td>
81
87
  <% if invoice.balance > 0 %>
82
88
  <nobr>
@@ -126,7 +132,11 @@
126
132
  <%= "Payment id:" %> <%= refund.payment_id %><br/>
127
133
  <%= "Refund Amount:" %> <%= refund.refund_amount %><br/>
128
134
  </td>
129
- <td></td>
135
+ <td>
136
+ <% if refund.audit_logs.present? %>
137
+ <%= refund.audit_logs[0].description %><br/>
138
+ <% end %>
139
+ </td>
130
140
  <td></td>
131
141
  </tr>
132
142
  <% end %>
@@ -161,7 +171,11 @@
161
171
  <%= "Payment id:" %> <%= chargeback.payment_id %><br/>
162
172
  <%= "Chargeback Amount:" %> <%= chargeback.chargeback_amount %><br/>
163
173
  </td>
164
- <td></td>
174
+ <td>
175
+ <% if chargeback.audit_logs.present? %>
176
+ <%= chargeback.audit_logs[0].description %><br/>
177
+ <% end %>
178
+ </td>
165
179
  <td></td>
166
180
  <% end %>
167
181
  <% end %>
@@ -198,6 +212,7 @@
198
212
  </td>
199
213
  <td><%= "PAYMENT" %></td>
200
214
  <td>
215
+ <%= "Payment id:" %> <%= payment.id %><br/>
201
216
  <%= "Total amount:" %> <%= payment.amount %> <%= @account.currency if payment.amount.present? %><br/>
202
217
  <%= "Paid amount:" %> <%= payment.paid_amount %> <%= @account.currency %><br/>
203
218
  <span <% if payment.status == 'FAILED' %>class="alert-error" <% elsif payment.status == 'SUCCESS' %>class="alert-success" <% end %>>
@@ -206,7 +221,11 @@
206
221
  <br/>
207
222
  <%= "Invoice #" %> <%= link_to invoice.invoice_number, invoice_path(:id => invoice.invoice_id) %>
208
223
  </td>
209
- <td></td>
224
+ <td>
225
+ <% payment.audit_logs.each do |entry| %>
226
+ <%= entry.description unless entry.changed_by == 'PaymentRequestProcessor' %><br/>
227
+ <% end %>
228
+ </td>
210
229
  <td>
211
230
  <% if payment.payment_id.present? %>
212
231
  <nobr>
@@ -220,9 +239,9 @@
220
239
  :class => "btn btn-mini" %>
221
240
  </nobr>
222
241
  <% elsif invoice.balance > 0 %>
223
- <%= link_to 'Pay', kaui_engine.new_chargeback_path(:params => { :payment_id => payment.payment_id,
224
- :account_id => @account.account_id,
225
- :invoice_id => payment.invoice_id }),
242
+ <%= link_to 'Pay', kaui_engine.new_payment_path(:params => { :payment_id => payment.payment_id,
243
+ :account_id => @account.account_id,
244
+ :invoice_id => payment.invoice_id }),
226
245
  :class => "btn btn-mini" %>
227
246
  <% end %>
228
247
  </td>
@@ -16,6 +16,12 @@
16
16
  <%= text_field_tag :new_account_key, nil, :class => "input-xlarge" %>
17
17
  </div>
18
18
  </div>
19
+ <div class="control-group">
20
+ <%= label_tag :comment, "Comment", :class => "control-label" %>
21
+ <div class="controls">
22
+ <%= text_area_tag :comment, "", :rows => 3, :class => 'input-xlarge' %>
23
+ </div>
24
+ </div>
19
25
  <div class="form-actions">
20
26
  <%= submit_tag "Change", :class => 'btn btn-primary' %>
21
27
  <%= link_to 'Back', :back, :class => 'btn' %>
@@ -1,6 +1,7 @@
1
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
+ <%= f.hidden_field :price_list %>
4
5
  <div class="control-group">
5
6
  <%= label_tag :current_plan, 'Current plan:', :class => "control-label" %>
6
7
  <div class="controls">
data/lib/kaui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaui
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
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: 13
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 9
10
- version: 0.0.9
10
+ version: 0.1.0
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-08-06 00:00:00 Z
18
+ date: 2012-08-10 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/helpers/kaui/killbill_helper.rb
68
68
  - app/models/kaui/account.rb
69
69
  - app/models/kaui/account_timeline.rb
70
+ - app/models/kaui/audit_log.rb
70
71
  - app/models/kaui/base.rb
71
72
  - app/models/kaui/bill_cycle_day.rb
72
73
  - app/models/kaui/bundle.rb