kaui 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/kaui/accounts_controller.rb +6 -2
- data/app/controllers/kaui/bundles_controller.rb +1 -0
- data/app/helpers/kaui/killbill_helper.rb +11 -0
- data/app/models/kaui/bill_cycle_day.rb +1 -5
- data/app/models/kaui/overdue_state.rb +10 -0
- data/app/views/kaui/accounts/show.html.erb +8 -1
- data/app/views/kaui/bundles/show.html.erb +9 -1
- data/lib/kaui/version.rb +1 -1
- data/test/dummy/log/development.log +3305 -0
- data/test/dummy/log/test.log +3833 -0
- data/test/dummy/test/fixtures/overdue_states.yml +8 -0
- data/test/dummy/tmp/cache/assets/D04/1D0/sprockets%2F3baf64d90ead2434455d2296227ba8a2 +7038 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D79/1E0/sprockets%2F97b08ebe07a73d8195ba124ffb45f98b +7038 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/unit/kaui/bill_cycle_day_test.rb +13 -0
- data/test/unit/kaui/overdue_state_test.rb +18 -0
- metadata +12 -1
@@ -28,11 +28,15 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
28
28
|
begin
|
29
29
|
@tags = Kaui::KillbillHelper::get_tags_for_account(@account.account_id).sort
|
30
30
|
@account_emails = Kaui::AccountEmail.where(:account_id => @account.account_id)
|
31
|
-
@payment_methods = Kaui::KillbillHelper::
|
31
|
+
@payment_methods = Kaui::KillbillHelper::get_non_external_payment_methods(@account.account_id)
|
32
32
|
@bundles = Kaui::KillbillHelper::get_bundles(@account.account_id)
|
33
|
+
|
34
|
+
@overdue_state_by_bundle_id = {}
|
33
35
|
@subscriptions_by_bundle_id = {}
|
34
36
|
|
35
37
|
@bundles.each do |bundle|
|
38
|
+
@overdue_state_by_bundle_id[bundle.bundle_id] = Kaui::KillbillHelper::get_overdue_state_for_bundle(bundle.bundle_id)
|
39
|
+
|
36
40
|
subscriptions = Kaui::KillbillHelper::get_subscriptions_for_bundle(bundle.bundle_id)
|
37
41
|
if subscriptions.present?
|
38
42
|
@subscriptions_by_bundle_id[bundle.bundle_id.to_s] = (@subscriptions_by_bundle_id[bundle.bundle_id.to_s] || []) + subscriptions
|
@@ -54,7 +58,7 @@ class Kaui::AccountsController < Kaui::EngineController
|
|
54
58
|
@account_id = params[:id]
|
55
59
|
if @account_id.present?
|
56
60
|
begin
|
57
|
-
@payment_methods = Kaui::KillbillHelper::
|
61
|
+
@payment_methods = Kaui::KillbillHelper::get_non_external_payment_methods(@account_id)
|
58
62
|
rescue => e
|
59
63
|
flash[:error] = "Error while getting payment methods: #{as_string(e)}"
|
60
64
|
end
|
@@ -15,6 +15,7 @@ class Kaui::BundlesController < Kaui::EngineController
|
|
15
15
|
if @bundle.present?
|
16
16
|
@account = Kaui::KillbillHelper::get_account_by_bundle_id(@bundle.bundle_id)
|
17
17
|
@subscriptions = Kaui::KillbillHelper::get_subscriptions_for_bundle(@bundle.bundle_id)
|
18
|
+
@overdue_state = Kaui::KillbillHelper::get_overdue_state_for_bundle(@bundle.bundle_id)
|
18
19
|
else
|
19
20
|
flash[:error] = "Bundle #{key} not found"
|
20
21
|
render :action => :index
|
@@ -331,6 +331,10 @@ module Kaui
|
|
331
331
|
"X-Killbill-Comment" => "#{comment}"
|
332
332
|
end
|
333
333
|
|
334
|
+
def self.get_non_external_payment_methods(account_id)
|
335
|
+
self.get_payment_methods(account_id).reject { |x| x.plugin_name == '__EXTERNAL_PAYMENT__' }
|
336
|
+
end
|
337
|
+
|
334
338
|
def self.get_payment_methods(account_id)
|
335
339
|
data = call_killbill :get, "/1.0/kb/accounts/#{account_id}/paymentMethods?withPluginInfo=true"
|
336
340
|
process_response(data, :multiple) {|json| Kaui::PaymentMethod.new(json) }
|
@@ -490,6 +494,13 @@ module Kaui
|
|
490
494
|
end
|
491
495
|
end
|
492
496
|
|
497
|
+
############## OVERDUE ##############
|
498
|
+
|
499
|
+
def self.get_overdue_state_for_bundle(bundle_id)
|
500
|
+
data = call_killbill :get, "/1.0/kb/overdue/bundles/#{bundle_id}"
|
501
|
+
process_response(data, :single) { |json| Kaui::OverdueState.new(json) }
|
502
|
+
end
|
503
|
+
|
493
504
|
############## ANALYTICS ##############
|
494
505
|
|
495
506
|
def self.get_accounts_created_over_time
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class Kaui::OverdueState < Kaui::Base
|
2
|
+
|
3
|
+
define_attr :name
|
4
|
+
define_attr :external_message
|
5
|
+
define_attr :days_between_payment_retries
|
6
|
+
define_attr :disable_entitlement_and_changes_blocked
|
7
|
+
define_attr :block_changes
|
8
|
+
define_attr :clear_state
|
9
|
+
define_attr :reevaluation_interval_days
|
10
|
+
end
|
@@ -65,7 +65,14 @@
|
|
65
65
|
<% @bundles.each do |bundle| %>
|
66
66
|
<% subs = @subscriptions_by_bundle_id[bundle.bundle_id] %>
|
67
67
|
<% if subs.present? %>
|
68
|
-
<h2>Bundle <%= link_to Kaui.bundle_key_display_string.call(bundle.external_key), Kaui.bundle_home_path.call(bundle.bundle_id) if bundle.external_key.present? %> </h2>
|
68
|
+
<h2>Bundle <%= link_to Kaui.bundle_key_display_string.call(bundle.external_key), Kaui.bundle_home_path.call(bundle.bundle_id) if bundle.external_key.present? %> </h2>Overdue state:
|
69
|
+
<% if @overdue_state_by_bundle_id[bundle.bundle_id].nil? %>
|
70
|
+
unknown
|
71
|
+
<% elsif @overdue_state_by_bundle_id[bundle.bundle_id].clear_state %>
|
72
|
+
<span class='label label-success'>Good</span>
|
73
|
+
<% else %>
|
74
|
+
<span class='label label-important'><%= @overdue_state_by_bundle_id[bundle.bundle_id].name %></span>
|
75
|
+
<% end %>
|
69
76
|
<%= render :partial => "kaui/subscriptions/subscriptions_table", :locals => { :subscriptions => subs } %>
|
70
77
|
<% end %>
|
71
78
|
<% end %>
|
@@ -7,7 +7,15 @@
|
|
7
7
|
<dd><%= link_to @account.email, Kaui.account_home_path.call(@account.external_key) %> </dd>
|
8
8
|
<dt>Bundle key:</dt>
|
9
9
|
<dd><%= @bundle.external_key %> </dd>
|
10
|
-
<
|
10
|
+
<dt>Overdue status:</dt>
|
11
|
+
<% if @overdue_state.nil? %>
|
12
|
+
<dd>unknown<dd>
|
13
|
+
<% elsif @overdue_state.clear_state %>
|
14
|
+
<dd><span class='label label-success'>Good</span><dd>
|
15
|
+
<% else %>
|
16
|
+
<dd><span class='label label-important'><%= @overdue_state.name %></span><dd>
|
17
|
+
<% end %>
|
18
|
+
<%= link_to "Transfer Ownership", kaui_engine.transfer_bundle_path(@bundle.bundle_id), :class => "btn btn-mini" %></dd>
|
11
19
|
<% if @subscriptions.present? %>
|
12
20
|
<%= render :partial => "kaui/subscriptions/subscriptions_table", :locals => { :subscriptions => @subscriptions } %>
|
13
21
|
<% end %>
|
data/lib/kaui/version.rb
CHANGED