kaui 1.4.1 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e742130946b631b91580c426cdcb8ee8dfd07d5a
4
- data.tar.gz: fdbf1ab93ef8dc3e1a7680f51779cdf1a958fe9d
2
+ SHA256:
3
+ metadata.gz: 87cb8b7da87b9a90782c29d1798aeaaf02e0373fb2b12479d6ea9e705052db28
4
+ data.tar.gz: 1536ede11cba88fd15fd3a76109b7fe9c3277afb0040d98b8c9a9ab2e1198f04
5
5
  SHA512:
6
- metadata.gz: 2f27c656b5b034092471fb10989c134fc0bd6cbbe7694a75fe8461c81459bbf3f8d83145cfe6c130e025218ecfa39284fcc3bb80d378417db33c1c3809c15dba
7
- data.tar.gz: 4cf31c31fec9d8071830403b990187e282221b6c6c2d2f6fb861400c9cebf33c240f0045988b52ebe83bc970c409b5364026a4bcae4815c2fbe4228c14493238
6
+ metadata.gz: 908f46db4f8461a2f799c3eb0135824b7827a90da6a4f1e2903106c28c38c62238b93eee95bd120ad56d55a060260dead1a7569dd82bc0af0386478b5c98ee4d
7
+ data.tar.gz: 91f0d828ee558b7d2710440e3196c52a5fc080b54340569aa27538db0acf3545ccc506376ebfb54e7d786e62cd922ee6c8a3d1aab2c4a1d0a59536af7cbcb7eb
data/README.md CHANGED
@@ -11,7 +11,8 @@ Kill Bill compatibility
11
11
  | 0.14.y | 0.16.z |
12
12
  | 0.15.y | 0.18.z (Rails 4) |
13
13
  | 0.16.y | 0.18.z (Rails 5) |
14
- | 1.x.y | 0.20.z |
14
+ | 1.x.y | 0.20.z (Rails 5) |
15
+ | 2.x.y | 0.22.z (Rails 5) |
15
16
 
16
17
  Dependencies
17
18
  ------------
@@ -25,10 +26,32 @@ You can run Kaui locally by using the test/dummy app provided:
25
26
 
26
27
  ```
27
28
  export RAILS_ENV=development
29
+ export DATABASE_URL=mysql://root:killbill@<MySQL Host IP>/killbill
28
30
  bundle install
29
31
  rails db:migrate
30
32
  rails s
31
33
  ```
34
+ If you experience an error of;
35
+
36
+ ```
37
+ You must use Bundler 2 or greater with this lockfile.
38
+ ```
39
+
40
+ Then run the following commands to update your environment.
41
+
42
+ Update Rubygems;
43
+
44
+ ```
45
+ gem update --system
46
+ ```
47
+ Update bundler;
48
+ ```
49
+ gem install bundler
50
+ ```
51
+ Update the Gemfile.lock file;
52
+ ```
53
+ bundler update --bundler
54
+ ```
32
55
 
33
56
  The Kill Bill URL can be configured through the `KILLBILL_URL` environment variable, e.g.
34
57
 
@@ -144,6 +144,7 @@ jQuery(document).ready(function ($) {
144
144
  const VALIDATE_EXTERNAL_KEY = {
145
145
  account: { url: Routes.kaui_engine_accounts_validate_external_key_path(), invalid_msg_class_name: '.account_external_key_invalid_msg' },
146
146
  payment_method: {url: Routes.kaui_engine_payment_methods_validate_external_key_path(), invalid_msg_class_name: '.payment_method_external_key_invalid_msg'},
147
+ bundle: {url: Routes.kaui_engine_subscriptions_validate_bundle_external_key_path(), invalid_msg_class_name: '.subscription_bundle_external_key_invalid_msg'},
147
148
  subscription: {url: Routes.kaui_engine_subscriptions_validate_external_key_path(), invalid_msg_class_name: '.subscription_external_key_invalid_msg'}
148
149
  }
149
150
 
@@ -157,8 +158,13 @@ jQuery(document).ready(function ($) {
157
158
  validate_external_key($(this).val(),'payment_method');
158
159
  });
159
160
 
160
- validate_external_key($('#external_key').val(),'subscription');
161
- $('#external_key').on('change', function(e){
161
+ validate_external_key($('#bundle_external_key').val(),'bundle');
162
+ $('#bundle_external_key').on('change', function(e){
163
+ validate_external_key($(this).val(),'bundle');
164
+ });
165
+
166
+ validate_external_key($('#subscription_external_key').val(),'subscription');
167
+ $('#subscription_external_key').on('change', function(e){
162
168
  validate_external_key($(this).val(),'subscription');
163
169
  });
164
170
 
@@ -1,5 +1,5 @@
1
1
  class Kaui::AuditLogsController < Kaui::EngineController
2
- OBJECT_WITH_HISTORY = %w[ACCOUNT ACCOUNT_EMAIL CUSTOM_FIELD PAYMENT_ATTEMPT PAYMENT PAYMENT_METHOD TRANSACTION TAG TAG_DEFINITION]
2
+ OBJECT_WITH_HISTORY = %w[ACCOUNT ACCOUNT_EMAIL BLOCKING_STATES BUNDLE CUSTOM_FIELD INVOICE INVOICE_ITEM PAYMENT_ATTEMPT PAYMENT PAYMENT_METHOD SUBSCRIPTION SUBSCRIPTION_EVENT TRANSACTION TAG TAG_DEFINITION]
3
3
 
4
4
  def index
5
5
  cached_options_for_klient = options_for_klient
@@ -57,8 +57,25 @@ class Kaui::AuditLogsController < Kaui::EngineController
57
57
  elsif object_type == 'ACCOUNT_EMAIL'
58
58
  account = Kaui::Account::find_by_id_or_key(account_id, false, false, cached_options_for_klient)
59
59
  audit_logs_with_history = account.email_audit_logs_with_history(object_id, cached_options_for_klient)
60
+ elsif object_type == 'BLOCKING_STATES'
61
+ audit_logs_with_history = Kaui::Account::blocking_state_audit_logs_with_history(object_id, cached_options_for_klient)
62
+ elsif object_type == 'BUNDLE'
63
+ bundle = Kaui::Bundle::find_by_id(object_id, cached_options_for_klient)
64
+ audit_logs_with_history = bundle.audit_logs_with_history(cached_options_for_klient)
60
65
  elsif object_type == 'CUSTOM_FIELD'
61
66
  audit_logs_with_history = Kaui::CustomField.new({:custom_field_id => object_id}).audit_logs_with_history(cached_options_for_klient)
67
+ elsif object_type == 'INVOICE'
68
+ invoice = Kaui::Invoice::find_by_id(object_id, false, "NONE", cached_options_for_klient)
69
+ audit_logs_with_history = invoice.audit_logs_with_history(cached_options_for_klient)
70
+ elsif object_type == 'INVOICE_ITEM'
71
+ invoice_item = Kaui::InvoiceItem.new
72
+ invoice_item.invoice_item_id = object_id
73
+ audit_logs_with_history = invoice_item.audit_logs_with_history(cached_options_for_klient)
74
+ =begin See https://github.com/killbill/killbill/issues/1104
75
+ elsif object_type == 'INVOICE_PAYMENT'
76
+ invoice_payment = Kaui::InvoicePayment::find_by_id(object_id, false, false, cached_options_for_klient)
77
+ =end
78
+ audit_logs_with_history = invoice_payment.audit_logs_with_history(cached_options_for_klient)
62
79
  elsif object_type == 'PAYMENT_ATTEMPT'
63
80
  audit_logs_with_history = Kaui::Payment::attempt_audit_logs_with_history(object_id, cached_options_for_klient)
64
81
  elsif object_type == 'PAYMENT'
@@ -67,6 +84,11 @@ class Kaui::AuditLogsController < Kaui::EngineController
67
84
  elsif object_type == 'PAYMENT_METHOD'
68
85
  payment_method = Kaui::PaymentMethod::find_by_id(object_id, false, cached_options_for_klient)
69
86
  audit_logs_with_history = payment_method.audit_logs_with_history(cached_options_for_klient)
87
+ elsif object_type == 'SUBSCRIPTION'
88
+ subscription = Kaui::Subscription::find_by_id(object_id, cached_options_for_klient)
89
+ audit_logs_with_history = subscription.audit_logs_with_history(cached_options_for_klient)
90
+ elsif object_type == 'SUBSCRIPTION_EVENT'
91
+ audit_logs_with_history = Kaui::Subscription::event_audit_logs_with_history(object_id, cached_options_for_klient)
70
92
  elsif object_type == 'TRANSACTION'
71
93
  audit_logs_with_history = Kaui::Transaction::new({:transaction_id => object_id}).audit_logs_with_history(cached_options_for_klient)
72
94
  elsif object_type == 'TAG'
@@ -5,7 +5,7 @@ class Kaui::ChargesController < Kaui::EngineController
5
5
  amount = params[:amount]
6
6
 
7
7
  if invoice_id.present?
8
- @invoice = Kaui::Invoice.find_by_id(invoice_id, true, 'NONE', options_for_klient)
8
+ @invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
9
9
  amount ||= @invoice.balance
10
10
  currency = @invoice.currency
11
11
  else
@@ -5,7 +5,7 @@ class Kaui::CreditsController < Kaui::EngineController
5
5
  amount = params[:amount]
6
6
 
7
7
  if invoice_id.present?
8
- @invoice = Kaui::Invoice.find_by_id(invoice_id, true, 'NONE', options_for_klient)
8
+ @invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
9
9
  amount ||= @invoice.balance
10
10
  currency = @invoice.currency
11
11
  else
@@ -13,7 +13,7 @@ class Kaui::CreditsController < Kaui::EngineController
13
13
  currency = params[:currency] || 'USD'
14
14
  end
15
15
 
16
- @credit = Kaui::Credit.new(:account_id => params.require(:account_id), :invoice_id => invoice_id, :credit_amount => amount, :currency => currency)
16
+ @credit = Kaui::Credit.new(:account_id => params.require(:account_id), :invoice_id => invoice_id, :amount => amount, :currency => currency)
17
17
  end
18
18
 
19
19
  def create
@@ -23,13 +23,13 @@ class Kaui::CreditsController < Kaui::EngineController
23
23
  # No need to show the newly created invoice for account level credits
24
24
  should_redirect_to_invoice = credit.invoice_id.present?
25
25
 
26
- credit = credit.create(true, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
26
+ credits = credit.create(true, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
27
27
  flash[:notice] = 'Credit was successfully created'
28
28
 
29
29
  if should_redirect_to_invoice
30
- redirect_to kaui_engine.account_invoice_path(credit.account_id, credit.invoice_id)
30
+ redirect_to kaui_engine.account_invoice_path(credits[0].account_id, credits[0].invoice_id)
31
31
  else
32
- redirect_to kaui_engine.account_path(credit.account_id)
32
+ redirect_to kaui_engine.account_path(credits[0].account_id)
33
33
  end
34
34
  end
35
35
  end
@@ -52,7 +52,7 @@ class Kaui::HomeController < Kaui::EngineController
52
52
  def invoice_search(search_query, search_by = nil, fast = 0, options = {})
53
53
  if search_by == 'ID'
54
54
  begin
55
- invoice = Kaui::Invoice.find_by_id(search_query, false, 'NONE', options)
55
+ invoice = Kaui::Invoice.find_by_id(search_query, 'NONE', options)
56
56
  redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return
57
57
  rescue KillBillClient::API::NotFound => _
58
58
  search_error("No invoice matches \"#{search_query}\"")
@@ -63,7 +63,7 @@ class Kaui::HomeController < Kaui::EngineController
63
63
  invoice = Kaui::Invoice.list_or_search(search_query, 0, 1, options).first
64
64
  if invoice.blank?
65
65
  begin
66
- invoice = Kaui::Invoice.find_by_invoice_item_id(search_query, false, false, 'NONE', options)
66
+ invoice = Kaui::Invoice.find_by_invoice_item_id(search_query, false, 'NONE', options)
67
67
  redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return
68
68
  rescue KillBillClient::API::NotFound => _
69
69
  search_error("No invoice matches \"#{search_query}\"")
@@ -5,7 +5,7 @@ class Kaui::InvoiceItemsController < Kaui::EngineController
5
5
  invoice_id = params.require(:invoice_id)
6
6
 
7
7
  # See https://github.com/killbill/killbill/issues/7
8
- invoice = Kaui::Invoice.find_by_id(invoice_id, true, 'NONE', options_for_klient)
8
+ invoice = Kaui::Invoice.find_by_id(invoice_id, 'NONE', options_for_klient)
9
9
  @invoice_item = invoice.items.find { |ii| ii.invoice_item_id == invoice_item_id }
10
10
 
11
11
  if @invoice_item.nil?
@@ -18,7 +18,7 @@ class Kaui::InvoicesController < Kaui::EngineController
18
18
  if account.nil?
19
19
  Kaui::Invoice.list_or_search(search_key, offset, limit, cached_options_for_klient)
20
20
  else
21
- account.invoices(true, cached_options_for_klient).map! { |invoice| Kaui::Invoice.build_from_raw_invoice(invoice) }
21
+ account.invoices(cached_options_for_klient).map! { |invoice| Kaui::Invoice.build_from_raw_invoice(invoice) }
22
22
  end
23
23
  end
24
24
 
@@ -47,7 +47,7 @@ class Kaui::InvoicesController < Kaui::EngineController
47
47
  # Go to the database once
48
48
  cached_options_for_klient = options_for_klient
49
49
 
50
- @invoice = Kaui::Invoice.find_by_id(params.require(:id), true, 'FULL', cached_options_for_klient)
50
+ @invoice = Kaui::Invoice.find_by_id(params.require(:id), 'FULL', cached_options_for_klient)
51
51
 
52
52
  fetch_payments = promise { @invoice.payments(true, true, 'FULL', cached_options_for_klient).map { |payment| Kaui::InvoicePayment.build_from_raw_payment(payment) } }
53
53
  fetch_pms = fetch_payments.then { |payments| Kaui::PaymentMethod.payment_methods_for_payments(payments, cached_options_for_klient) }
@@ -78,7 +78,7 @@ class Kaui::InvoicesController < Kaui::EngineController
78
78
  end
79
79
 
80
80
  def restful_show
81
- invoice = Kaui::Invoice.find_by_id(params.require(:id), false, 'NONE', options_for_klient)
81
+ invoice = Kaui::Invoice.find_by_id(params.require(:id), 'NONE', options_for_klient)
82
82
  redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id)
83
83
  end
84
84
 
@@ -88,7 +88,7 @@ class Kaui::InvoicesController < Kaui::EngineController
88
88
 
89
89
  def commit_invoice
90
90
  cached_options_for_klient = options_for_klient
91
- invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), false, 'NONE', cached_options_for_klient)
91
+ invoice = KillBillClient::Model::Invoice.find_by_id(params.require(:id), 'NONE', cached_options_for_klient)
92
92
  invoice.commit(current_user.kb_username, params[:reason], params[:comment], cached_options_for_klient)
93
93
  redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id), :notice => 'Invoice successfully committed'
94
94
  end
@@ -74,7 +74,7 @@ class Kaui::PaymentsController < Kaui::EngineController
74
74
 
75
75
  def new
76
76
  cached_options_for_klient = options_for_klient
77
- fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), true, 'NONE', cached_options_for_klient) }
77
+ fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', cached_options_for_klient) }
78
78
  fetch_payment_methods = promise { Kaui::PaymentMethod.find_all_by_account_id(params.require(:account_id), false, cached_options_for_klient) }
79
79
 
80
80
  @invoice = wait(fetch_invoice)
@@ -3,7 +3,7 @@ class Kaui::RefundsController < Kaui::EngineController
3
3
  def new
4
4
  cached_options_for_klient = options_for_klient
5
5
 
6
- fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), true, 'NONE', cached_options_for_klient) }
6
+ fetch_invoice = promise { Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', cached_options_for_klient) }
7
7
  fetch_payment = promise { Kaui::InvoicePayment::find_by_id(params.require(:payment_id), false, false, cached_options_for_klient) }
8
8
  fetch_bundles = promise { @account.bundles(cached_options_for_klient) }
9
9
 
@@ -15,7 +15,7 @@ class Kaui::RefundsController < Kaui::EngineController
15
15
  end
16
16
 
17
17
  def create
18
- invoice = Kaui::Invoice.find_by_id(params.require(:invoice_id), true, 'NONE', options_for_klient)
18
+ invoice = Kaui::Invoice.find_by_id(params.require(:invoice_id), 'NONE', options_for_klient)
19
19
 
20
20
  if params[:adjustment_type] == 'invoiceItemAdjustment'
21
21
  items = []
@@ -141,7 +141,7 @@ class Kaui::SubscriptionsController < Kaui::EngineController
141
141
  redirect_to kaui_engine.account_bundles_path(subscription.account_id)
142
142
  end
143
143
 
144
- def validate_external_key
144
+ def validate_bundle_external_key
145
145
  json_response do
146
146
  external_key = params.require(:external_key)
147
147
 
@@ -155,6 +155,21 @@ class Kaui::SubscriptionsController < Kaui::EngineController
155
155
  end
156
156
  end
157
157
 
158
+
159
+ def validate_external_key
160
+ json_response do
161
+ external_key = params.require(:external_key)
162
+
163
+ begin
164
+ subscription = Kaui::Subscription.find_by_external_key(external_key, options_for_klient)
165
+ rescue KillBillClient::API::NotFound
166
+ subscription = nil
167
+ end
168
+
169
+ { :is_found => !subscription.nil? }
170
+ end
171
+ end
172
+
158
173
  def update_tags
159
174
  subscription_id = params.require(:id)
160
175
  subscription = Kaui::Subscription.find_by_id(subscription_id, options_for_klient)
@@ -18,7 +18,7 @@
18
18
  </tr>
19
19
  <% unless bundle.bundle_id == bundle.external_key %>
20
20
  <tr>
21
- <th>External key</th>
21
+ <th>Bundle key</th>
22
22
  <td><%= bundle.external_key %></td>
23
23
  </tr>
24
24
  <% end %>
@@ -2,9 +2,9 @@
2
2
  <%= f.hidden_field :invoice_id %>
3
3
 
4
4
  <div class="form-group">
5
- <%= f.label :credit_amount, 'Amount', :class => 'col-sm-2 control-label' %>
5
+ <%= f.label :amount, 'Amount', :class => 'col-sm-2 control-label' %>
6
6
  <div class="col-sm-10">
7
- <%= f.number_field :credit_amount, :step => :any, :id => 'credit_amount', :class => 'form-control' %>
7
+ <%= f.number_field :amount, :step => :any, :id => 'amount', :class => 'form-control' %>
8
8
  <% if @invoice.present? %>
9
9
  <p class="help-block">Currency: <%= @invoice.currency %></p>
10
10
  <% end %>
@@ -7,15 +7,27 @@
7
7
  <%= hidden_field_tag :base_product_name, @base_product_name %>
8
8
  <% elsif @subscription.product_category == 'BASE' %>
9
9
  <div class="form-group">
10
- <%= f.label :external_key, 'Key', :class => 'col-sm-2 control-label' %>
10
+ <%= f.label :bundle_external_key, 'Bundle Key', :class => 'col-sm-2 control-label' %>
11
11
  <div class="col-sm-10">
12
- <%= f.text_field :external_key, :class => 'form-control', :id => 'external_key' %>
13
- <div class="subscription_external_key_invalid_msg text-danger">
12
+ <%= f.text_field :bundle_external_key, :class => 'form-control', :id => 'bundle_external_key' %>
13
+ <div class="subscription_bundle_external_key_invalid_msg text-danger">
14
14
  Warning! External key already in use.
15
15
  </div>
16
16
  </div>
17
17
  </div>
18
18
  <% end %>
19
+
20
+ <div class="form-group">
21
+ <%= f.label :subscription_external_key, 'Subscription Key', :class => 'col-sm-2 control-label' %>
22
+ <div class="col-sm-10">
23
+ <%= f.text_field :external_key, :class => 'form-control', :id => 'subscription_external_key' %>
24
+ <div class="subscription_external_key_invalid_msg text-danger">
25
+ Warning! External key already in use.
26
+ </div>
27
+ </div>
28
+ </div>
29
+
30
+
19
31
  <div class="form-group">
20
32
  <%= label_tag :plan_name, 'Plan', :class => 'col-sm-2 control-label' %>
21
33
  <div class="col-sm-10">
@@ -128,6 +128,7 @@ Kaui::Engine.routes.draw do
128
128
  match '/:id/update_bcd' => 'subscriptions#update_bcd', :via => :put, :as => 'update_bcd'
129
129
  match '/:id/reinstate' => 'subscriptions#reinstate', :via => :put, :as => 'reinstate'
130
130
  match '/validate_external_key' => 'subscriptions#validate_external_key', :via => :get, :as => 'subscriptions_validate_external_key'
131
+ match '/validate_bundle_external_key' => 'subscriptions#validate_bundle_external_key', :via => :get, :as => 'subscriptions_validate_bundle_external_key'
131
132
  end
132
133
  resources :subscriptions, :only => [:new, :create, :show, :edit, :update, :destroy]
133
134
 
@@ -1,3 +1,3 @@
1
1
  module Kaui
2
- VERSION = '1.4.1'
2
+ VERSION = '2.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaui
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Killbill core team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-18 00:00:00.000000000 Z
11
+ date: 2019-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '2.0'
131
+ version: '3.0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '2.0'
138
+ version: '3.0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: devise
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -878,8 +878,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
878
878
  - !ruby/object:Gem::Version
879
879
  version: '0'
880
880
  requirements: []
881
- rubyforge_project:
882
- rubygems_version: 2.6.13
881
+ rubygems_version: 3.0.6
883
882
  signing_key:
884
883
  specification_version: 4
885
884
  summary: Killbill Admin UI mountable engine