kaui 0.4.9 → 0.5.0

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.
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kaui (0.4.9)
4
+ kaui (0.5.0)
5
5
  cancan (~> 1.6.10)
6
6
  d3_rails (~> 3.2.8)
7
7
  devise (~> 3.0.2)
8
8
  jquery-rails (~> 3.0.4)
9
- killbill-client (~> 0.4.1)
9
+ killbill-client (~> 0.4.2)
10
10
  money-rails (~> 0.8.1)
11
11
  rails (~> 3.2.14)
12
12
  rest-client (~> 1.6.7)
@@ -60,7 +60,7 @@ GEM
60
60
  railties (>= 3.0, < 5.0)
61
61
  thor (>= 0.14, < 2.0)
62
62
  json (1.8.0)
63
- killbill-client (0.4.1)
63
+ killbill-client (0.4.2)
64
64
  mail (2.5.4)
65
65
  mime-types (~> 1.16)
66
66
  treetop (~> 1.4.8)
@@ -34,7 +34,7 @@ class Kaui::CreditsController < Kaui::EngineController
34
34
  credit_amount = @invoice.balance unless @invoice.nil?
35
35
 
36
36
  @credit = Kaui::Credit.new("accountId" => @account_id, "invoiceId" => @invoice_id,
37
- "creditAmount" => credit_amount, "effectiveDate" => Time.now.utc.iso8601)
37
+ "creditAmount" => credit_amount, "effectiveDate" => Date.parse(Time.now.to_s).to_s)
38
38
  end
39
39
 
40
40
  def create
@@ -103,7 +103,6 @@ class Kaui::SubscriptionsController < Kaui::EngineController
103
103
  def edit
104
104
  begin
105
105
  @subscription = Kaui::KillbillHelper.get_subscription(params[:id], options_for_klient)
106
-
107
106
  if @subscription.present?
108
107
  @bundle = Kaui::KillbillHelper::get_bundle(@subscription.bundle_id, options_for_klient)
109
108
  @account = Kaui::KillbillHelper::get_account(@bundle.account_id, false, false, options_for_klient)
@@ -133,7 +132,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
133
132
 
134
133
  plan = catalog[params[:plan_name]]
135
134
  requested_date = params[:requested_date]
136
- policy = params[:policy]
135
+ policy = params[:policy] unless params[:policy].empty?
137
136
 
138
137
  subscription.billing_period = plan["billingPeriod"]
139
138
  subscription.product_category = plan["productCategory"]
@@ -180,7 +180,7 @@ module Kaui
180
180
  end
181
181
 
182
182
  def self.get_subscription(subscription_id, options = {})
183
- data = call_killbill :get, "/1.0/kb/subscriptions/#{subscription_id}", options
183
+ data = call_killbill :get, "/1.0/kb/entitlements/#{subscription_id}", options
184
184
  process_response(data, :single) { |json| Kaui::Subscription.new(json) }
185
185
  end
186
186
 
@@ -397,14 +397,20 @@ module Kaui
397
397
  def self.create_refund(payment_id, refund, current_user = nil, reason = nil, comment = nil, options = {})
398
398
 
399
399
  new_refund = KillBillClient::Model::Refund.new
400
+ new_refund.payment_id = payment_id
400
401
  new_refund.amount = refund["amount"]
401
402
  new_refund.adjusted = refund["adjusted"]
402
- new_refund.adjustments = refund["adjustments"]
403
+ if ! refund["adjustments"].nil?
404
+ new_refund.adjustments = []
405
+ refund["adjustments"].each do |a|
406
+ item = KillBillClient::Model::InvoiceItemAttributes.new
407
+ item.invoice_item_id = a.invoice_item_id
408
+ item.amount = a.amount
409
+ new_refund.adjustments << item
410
+ end
411
+ end
403
412
  #no need to pass adjustment_type
404
-
405
- new_refund.create(payment_id,
406
- refund,
407
- extract_created_by(current_user),
413
+ new_refund.create(extract_created_by(current_user),
408
414
  extract_reason_code(reason),
409
415
  comment,
410
416
  options)
@@ -418,12 +424,14 @@ module Kaui
418
424
  end
419
425
 
420
426
  def self.create_chargeback(chargeback, current_user = nil, reason = nil, comment = nil, options = {})
421
- chargeback_data = Kaui::Refund.camelize(chargeback.to_hash)
422
427
 
423
- call_killbill :post,
424
- "/1.0/kb/chargebacks",
425
- ActiveSupport::JSON.encode(chargeback_data, :root => false),
426
- build_audit_headers(current_user, reason, comment, options)
428
+ new_chargeback = KillBillClient::Model::Chargeback.new
429
+ new_chargeback.payment_id = chargeback.payment_id
430
+ new_chargeback.amount = chargeback.chargeback_amount
431
+ new_chargeback.create(extract_created_by(current_user),
432
+ extract_reason_code(reason),
433
+ comment,
434
+ options)
427
435
  end
428
436
 
429
437
  ############## CREDIT ##############
@@ -505,8 +513,9 @@ module Kaui
505
513
  ############## OVERDUE ##############
506
514
 
507
515
  def self.get_overdue_state_for_account(account_id, options = {})
508
- data = call_killbill :get, "/1.0/kb/overdue/accounts/#{account_id}", options
509
- process_response(data, :single) { |json| Kaui::OverdueState.new(json) }
516
+ account = KillBillClient::Model::Account.new
517
+ account.account_id = account_id
518
+ account.overdue(options)
510
519
  end
511
520
 
512
521
  ############## ANALYTICS ##############
@@ -69,7 +69,7 @@
69
69
  <td><%= "INVOICE" %></td>
70
70
  <td><span class="hide" title="<%= invoice.invoice_number %>"></span>
71
71
  <%= "Amount:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(invoice.amount, @account.currency) %> (<%= @account.currency %>)<br/>
72
- <%= "Balance:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(invoice.amount, @account.currency) %> (<%= @account.currency %>)<br/>
72
+ <%= "Balance:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(invoice.balance, @account.currency) %> (<%= @account.currency %>)<br/>
73
73
  <% if invoice.credit_adj.present? && invoice.credit_adj > 0 %>
74
74
  <%= "Credit adjustment:" %> <%= humanized_money_with_symbol Kaui::Base.to_money(invoice.credit_adj, @account.currency) %> (<%= @account.currency %>)<br/>
75
75
  <% end %>
@@ -64,7 +64,7 @@
64
64
  <div class="control-group">
65
65
  <%= label_tag :requested_date, 'Requested Date:', :class => "control-label" %>
66
66
  <div class="controls">
67
- <%= text_field_tag :requested_date, Time.now.utc.iso8601, :class => 'input-xlarge date-picker' %>
67
+ <%= text_field_tag :requested_date, Date.parse(Time.now.to_s).to_s, :class => 'input-xlarge date-picker' %>
68
68
  </div>
69
69
  </div>
70
70
  <div class="control-group">
@@ -25,7 +25,7 @@
25
25
  <div class="control-group">
26
26
  <%= label_tag :requested_date, 'Change Date:', :class => "control-label" %>
27
27
  <div class="controls">
28
- <%= text_field_tag :requested_date, Time.now.utc.iso8601, :class => 'input-xlarge date-picker' %>
28
+ <%= text_field_tag :requested_date, Date.parse(Time.now.to_s).to_s, :class => 'input-xlarge date-picker' %>
29
29
  </div>
30
30
  </div>
31
31
  <div class="control-group">
data/kaui.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.add_dependency 'rest-client', '~> 1.6.7'
28
28
  s.add_dependency 'money-rails', '~> 0.8.1'
29
29
  s.add_dependency 'd3_rails', '~> 3.2.8'
30
- s.add_dependency 'killbill-client', '~> 0.4.1'
30
+ s.add_dependency 'killbill-client', '~> 0.4.2'
31
31
  s.add_dependency 'devise', '~> 3.0.2'
32
32
  s.add_dependency 'cancan', '~> 1.6.10'
33
33
 
data/lib/kaui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaui
2
- VERSION = "0.4.9"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 0.4.1
101
+ version: 0.4.2
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 0.4.1
109
+ version: 0.4.2
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: devise
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -435,7 +435,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
435
435
  version: '0'
436
436
  segments:
437
437
  - 0
438
- hash: 11207357591109144
438
+ hash: -4397666947542555501
439
439
  requirements: []
440
440
  rubyforge_project:
441
441
  rubygems_version: 1.8.25