killbill-avatax 2.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -6
  3. data/Rakefile +3 -5
  4. data/app/assets/config/avatax_manifest.js +3 -0
  5. data/app/assets/javascripts/application.js +0 -1
  6. data/app/assets/stylesheets/application.css +0 -1
  7. data/app/assets/stylesheets/bootstrap_and_overrides.css +0 -4
  8. data/app/controllers/avatax/configuration_controller.rb +42 -34
  9. data/app/controllers/avatax/engine_controller.rb +2 -2
  10. data/app/helpers/avatax/application_helper.rb +2 -0
  11. data/app/views/avatax/configuration/_plugin_form.html.erb +2 -11
  12. data/config/routes.rb +3 -3
  13. data/lib/avatax/client.rb +14 -18
  14. data/lib/avatax/engine.rb +2 -2
  15. data/lib/avatax/version.rb +3 -1
  16. data/lib/avatax.rb +10 -10
  17. data/lib/tasks/avatax_tasks.rake +1 -0
  18. metadata +25 -147
  19. data/test/avatax_test.rb +0 -8
  20. data/test/dummy/README.rdoc +0 -28
  21. data/test/dummy/Rakefile +0 -6
  22. data/test/dummy/app/controllers/application_controller.rb +0 -5
  23. data/test/dummy/app/helpers/application_helper.rb +0 -2
  24. data/test/dummy/bin/bundle +0 -3
  25. data/test/dummy/bin/rails +0 -4
  26. data/test/dummy/bin/rake +0 -4
  27. data/test/dummy/bin/setup +0 -38
  28. data/test/dummy/bin/update +0 -29
  29. data/test/dummy/bin/yarn +0 -11
  30. data/test/dummy/config/application.rb +0 -26
  31. data/test/dummy/config/boot.rb +0 -3
  32. data/test/dummy/config/environment.rb +0 -5
  33. data/test/dummy/config/environments/development.rb +0 -54
  34. data/test/dummy/config/environments/production.rb +0 -91
  35. data/test/dummy/config/environments/test.rb +0 -42
  36. data/test/dummy/config/initializers/application_controller_renderer.rb +0 -6
  37. data/test/dummy/config/initializers/assets.rb +0 -14
  38. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  39. data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
  40. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  41. data/test/dummy/config/initializers/inflections.rb +0 -16
  42. data/test/dummy/config/initializers/killbill_client.rb +0 -3
  43. data/test/dummy/config/initializers/mime_types.rb +0 -4
  44. data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +0 -14
  45. data/test/dummy/config/initializers/session_store.rb +0 -3
  46. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  47. data/test/dummy/config/locales/en.yml +0 -33
  48. data/test/dummy/config/routes.rb +0 -4
  49. data/test/dummy/config/secrets.yml +0 -32
  50. data/test/dummy/config.ru +0 -4
  51. data/test/integration/navigation_test.rb +0 -17
  52. data/test/test_helper.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc98fda6ea7fcb6511fbf3dfe265135cc3bfbf2ca072b96f8f8898fdf28cecbd
4
- data.tar.gz: e1a8ed6b755519d48ca8bd73162ec6547b9801f4a9680cd10ae0292a9833f96d
3
+ metadata.gz: 356de25fb24a2c81634a2f55d4d204565a8d39a3960b4ff0abd32f0395e53d6c
4
+ data.tar.gz: ff63beed2d3c7987f764afd5549d29cdd91501af1975a07ac2a3363aab73a570
5
5
  SHA512:
6
- metadata.gz: 2f7200442606fc8a4dd30c853f08c0273dd361d6d3cda6ee480481694c0c47c4c3fca76fb49096a5539061208b2bda5a3a6db5efd83a6b438a973d117332ab84
7
- data.tar.gz: 6667f2f92bd71f9218d864e269febc1f67585ed594f13f378e528a60617fa644a637e2e6f070c549de042581c55229f72d34269a502b83800efe7fc59d3e042d
6
+ metadata.gz: cb5b083db696168a9c60c3e3d786818f07b78c4baa1aa6e02e3693b0c0cbe6c5c1aecc00e57f8f22e371fb07d508daf94330342dcf203d03c482e81bf6396099
7
+ data.tar.gz: eb19858c03d68f77397217b11adcba3dd85f3429783a54dce124c1f1f4a05e16ac36c8dea8eea49df2f6ad8fa469b2be369037b930478fdcb7a04008adbe866e
data/README.md CHANGED
@@ -11,12 +11,13 @@ Kill Bill compatibility
11
11
  -----------------------
12
12
 
13
13
  | Avatax UI version | Kill Bill version |
14
- | ----------------: | ----------------: |
15
- | 0.0.y | 0.16.z |
16
- | 0.1.y | 0.18.z (Rails 4) |
17
- | 0.2.y | 0.18.z (Rails 5) |
18
- | 1.x.y | 0.20.z |
19
- | 2.x.y | 0.22.z |
14
+ |------------------:|------------------:|
15
+ | 0.0.y | 0.16.z |
16
+ | 0.1.y | 0.18.z (Rails 4) |
17
+ | 0.2.y | 0.18.z (Rails 5) |
18
+ | 1.x.y | 0.20.z (Rails 5) |
19
+ | 2.x.y | 0.22.z (Rails 5) |
20
+ | 3.x.y | 0.24.z (Rails 7) |
20
21
 
21
22
  Functionality
22
23
  -------------
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/setup'
3
5
  rescue LoadError
@@ -14,14 +16,11 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
16
  rdoc.rdoc_files.include('lib/**/*.rb')
15
17
  end
16
18
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
19
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
18
20
  load 'rails/tasks/engine.rake'
19
21
 
20
-
21
22
  load 'rails/tasks/statistics.rake'
22
23
 
23
-
24
-
25
24
  Bundler::GemHelper.install_tasks
26
25
 
27
26
  require 'rake/testtask'
@@ -33,5 +32,4 @@ Rake::TestTask.new(:test) do |t|
33
32
  t.verbose = false
34
33
  end
35
34
 
36
-
37
35
  task default: :test
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -12,7 +12,6 @@
12
12
  //
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
- //= require twitter/bootstrap
16
15
  //= require dataTables/jquery.dataTables
17
16
  //= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
18
17
  //= require avatax/avatax
@@ -14,6 +14,5 @@
14
14
  *= require dataTables/jquery.dataTables
15
15
  *= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
16
16
  *= require font-awesome
17
- *= require bootstrap_and_overrides
18
17
  *= require avatax/avatax
19
18
  */
@@ -1,7 +1,3 @@
1
- /*
2
- *= require twitter-bootstrap-static/bootstrap
3
- */
4
-
5
1
  /* Override Bootstrap 3 font locations */
6
2
  @font-face {
7
3
  font-family: 'Glyphicons Halflings';
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'avatax/client'
2
4
 
3
5
  module Avatax
4
6
  class ConfigurationController < EngineController
5
-
6
7
  def index
7
8
  @tax_codes = ::Killbill::Avatax::AvataxClient.get_tax_codes(options_for_klient)
8
9
  @exemptions = exempt_accounts
@@ -25,7 +26,7 @@ module Avatax
25
26
  options_for_klient)
26
27
 
27
28
  flash[:notice] = 'Tax code successfully saved'
28
- redirect_to :action => :index
29
+ redirect_to action: :index
29
30
  end
30
31
 
31
32
  def remove_tax_code
@@ -36,15 +37,14 @@ module Avatax
36
37
  options_for_klient)
37
38
 
38
39
  flash[:notice] = 'Tax code successfully removed'
39
- redirect_to :action => :index
40
+ redirect_to action: :index
40
41
  end
41
42
 
42
43
  #
43
44
  # Exemptions
44
45
  #
45
46
 
46
- def set_exemption
47
- end
47
+ def set_exemption; end
48
48
 
49
49
  def do_set_exemption
50
50
  ::Killbill::Avatax::AvataxClient.set_exemption(params.require(:account_id),
@@ -55,7 +55,7 @@ module Avatax
55
55
  options_for_klient)
56
56
 
57
57
  flash[:notice] = 'Exemption successfully saved'
58
- redirect_to :action => :index
58
+ redirect_to action: :index
59
59
  end
60
60
 
61
61
  def remove_exemption
@@ -66,7 +66,7 @@ module Avatax
66
66
  options_for_klient)
67
67
 
68
68
  flash[:notice] = 'Exemption successfully removed'
69
- redirect_to :action => :index
69
+ redirect_to action: :index
70
70
  end
71
71
 
72
72
  #
@@ -82,26 +82,38 @@ module Avatax
82
82
  config.values.first.split.each do |property|
83
83
  k, v = property.split('=')
84
84
  case k
85
- when 'org.killbill.billing.plugin.avatax.url'
86
- @configuration[:test] = avatax_url(true) == v
87
- when 'org.killbill.billing.plugin.avatax.accountNumber'
88
- @configuration[:account_number] = v
89
- when 'org.killbill.billing.plugin.avatax.licenseKey'
90
- @configuration[:license_key] = v
91
- when 'org.killbill.billing.plugin.avatax.companyCode'
92
- @configuration[:company_code] = v
93
- when 'org.killbill.billing.plugin.avatax.commitDocuments'
94
- @configuration[:commit_documents] = v == 'true'
85
+ when 'org.killbill.billing.plugin.avatax.accountId'
86
+ @configuration[:account_id] = v
87
+ when 'org.killbill.billing.plugin.avatax.licenseKey'
88
+ @configuration[:license_key] = v
89
+ when 'org.killbill.billing.plugin.avatax.companyCode'
90
+ @configuration[:company_code] = v
91
+ when 'org.killbill.billing.plugin.avatax.commitDocuments'
92
+ @configuration[:commit_documents] = v == 'true'
95
93
  end
96
94
  end
97
95
  end
98
96
 
99
97
  def update_plugin_configuration
100
- plugin_config = "org.killbill.billing.plugin.avatax.url=#{avatax_url(params[:test] == '1')}
101
- org.killbill.billing.plugin.avatax.accountNumber=#{params.require(:account_number)}
102
- org.killbill.billing.plugin.avatax.licenseKey=#{params.require(:license_key)}
103
- org.killbill.billing.plugin.avatax.companyCode=#{params[:company_code]}
104
- org.killbill.billing.plugin.avatax.commitDocuments=#{params[:commit_documents] == '1'}"
98
+ plugin_config = "org.killbill.billing.plugin.avatax.accountId=#{params.require(:account_id)}
99
+ org.killbill.billing.plugin.avatax.licenseKey=#{params.require(:license_key)}\n"
100
+ plugin_config << "org.killbill.billing.plugin.avatax.commitDocuments=#{params[:commit_documents] == '1'}\n"
101
+ plugin_config << "org.killbill.billing.plugin.avatax.companyCode=#{params[:company_code]}\n" unless params[:company_code].blank?
102
+
103
+ # Merge the new values with the current config. The config will likely contain additional fields that we don't want to clobber.
104
+ # The user should really use the more powerful /admin_tenants screen - this plugin screen was just created
105
+ # to be able to pass the initial AvaTax certification.
106
+ current_config = KillBillClient::Model::Tenant.get_tenant_plugin_config('killbill-avatax', options_for_klient)
107
+
108
+ (current_config.values || ['']).first.split.each do |property|
109
+ k, v = property.split('=')
110
+ plugin_config << case k
111
+ when 'org.killbill.billing.plugin.avatax.accountId', 'org.killbill.billing.plugin.avatax.licenseKey', 'org.killbill.billing.plugin.avatax.companyCode', 'org.killbill.billing.plugin.avatax.commitDocuments'
112
+ next
113
+ else
114
+ "#{k}=#{v}\n"
115
+ end
116
+ end
105
117
 
106
118
  KillBillClient::Model::Tenant.upload_tenant_plugin_config('killbill-avatax',
107
119
  plugin_config,
@@ -111,31 +123,27 @@ org.killbill.billing.plugin.avatax.commitDocuments=#{params[:commit_documents] =
111
123
  options_for_klient)
112
124
 
113
125
  flash[:notice] = 'Configuration successfully saved'
114
- redirect_to :action => :index
126
+ redirect_to action: :index
115
127
  end
116
128
 
117
129
  private
118
130
 
119
- def avatax_url(test)
120
- "https://#{test ? 'development' : 'avatax'}.avalara.net"
121
- end
122
-
123
131
  def exempt_accounts(offset = 0, limit = 100)
124
132
  custom_field_value = 'customerUsageType'
125
133
 
126
134
  KillBillClient::Model::CustomField.find_in_batches_by_search_key(custom_field_value, offset, limit, options_for_klient)
127
- .select { |cf| cf.name == custom_field_value && cf.object_type == 'ACCOUNT' }
128
- .map { |cf| {:account_id => cf.object_id, :customer_usage_type => cf.value} }
135
+ .select { |cf| cf.name == custom_field_value && cf.object_type == 'ACCOUNT' }
136
+ .map { |cf| { account_id: cf.object_id, customer_usage_type: cf.value } }
129
137
  end
130
138
 
131
139
  def options_for_klient
132
140
  user = current_tenant_user
133
141
  {
134
- :username => user[:username],
135
- :password => user[:password],
136
- :session_id => user[:session_id],
137
- :api_key => user[:api_key],
138
- :api_secret => user[:api_secret]
142
+ username: user[:username],
143
+ password: user[:password],
144
+ session_id: user[:session_id],
145
+ api_key: user[:api_key],
146
+ api_secret: user[:api_secret]
139
147
  }
140
148
  end
141
149
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avatax
2
4
  class EngineController < ApplicationController
3
-
4
5
  layout :get_layout
5
6
 
6
7
  def get_layout
@@ -13,6 +14,5 @@ module Avatax
13
14
  user = current_user if respond_to?(:current_user)
14
15
  Avatax.current_tenant_user.call(session, user)
15
16
  end
16
-
17
17
  end
18
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avatax
2
4
  module ApplicationHelper
3
5
  end
@@ -1,8 +1,8 @@
1
1
  <%= form_tag update_plugin_configuration_path, :class => 'form-horizontal' do %>
2
2
  <div class="form-group">
3
- <%= label_tag :account_number, 'Account number', :class => 'col-sm-2 control-label' %>
3
+ <%= label_tag :account_id, 'Account ID', :class => 'col-sm-2 control-label' %>
4
4
  <div class="col-sm-10">
5
- <%= text_field_tag :account_number, @configuration[:account_number], :class => 'form-control' %>
5
+ <%= text_field_tag :account_id, @configuration[:account_id], :class => 'form-control' %>
6
6
  </div>
7
7
  </div>
8
8
  <div class="form-group">
@@ -26,15 +26,6 @@
26
26
  </div>
27
27
  </div>
28
28
  </div>
29
- <div class="form-group">
30
- <div class="col-sm-offset-2 col-sm-10">
31
- <div class="checkbox">
32
- <%= label_tag :test, 'Test mode', :class => 'control-label' do %>
33
- <%= check_box_tag :test, '1', @configuration[:test] %>Test mode?
34
- <% end %>
35
- </div>
36
- </div>
37
- </div>
38
29
  <div class="form-group">
39
30
  <div class="col-sm-offset-2 col-sm-10">
40
31
  <%= submit_tag 'Save', :class => 'btn btn-default' %>
data/config/routes.rb CHANGED
@@ -1,8 +1,9 @@
1
- Avatax::Engine.routes.draw do
1
+ # frozen_string_literal: true
2
2
 
3
+ Avatax::Engine.routes.draw do
3
4
  root to: 'configuration#index'
4
5
 
5
- resources :configuration, :only => [:index]
6
+ resources :configuration, only: [:index]
6
7
 
7
8
  scope '/configuration' do
8
9
  match '/tax_code' => 'configuration#set_tax_code', :via => :get, :as => 'set_tax_code_configuration'
@@ -16,5 +17,4 @@ Avatax::Engine.routes.draw do
16
17
  match '/plugin' => 'configuration#plugin_configuration', :via => :get, :as => 'plugin_configuration'
17
18
  match '/plugin' => 'configuration#update_plugin_configuration', :via => :post, :as => 'update_plugin_configuration'
18
19
  end
19
-
20
20
  end
data/lib/avatax/client.rb CHANGED
@@ -1,29 +1,28 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Killbill
2
4
  module Avatax
3
-
4
5
  class AvataxClient < KillBillClient::Model::Resource
5
-
6
6
  KILLBILL_AVATAX_PREFIX = '/plugins/killbill-avatax'
7
7
 
8
8
  class << self
9
-
10
9
  def set_exemption(account_id, customer_usage_type, user, reason, comment, options = {})
11
- exemptionCustomFieldName = 'customerUsageType'
10
+ exemption_cf_name = 'customerUsageType'
12
11
 
13
12
  account = KillBillClient::Model::Account.find_by_id(account_id, false, false, options)
14
13
 
15
14
  # Remove existing exemption(s) first
16
15
  account.custom_fields('NONE', options).each do |custom_field|
17
- account.remove_custom_field(custom_field.custom_field_id, user, reason, comment, options) if custom_field.name == exemptionCustomFieldName
16
+ account.remove_custom_field(custom_field.custom_field_id, user, reason, comment, options) if custom_field.name == exemption_cf_name
18
17
  end
19
18
 
20
- unless customer_usage_type.nil?
21
- # Set the exemption
22
- custom_field = KillBillClient::Model::CustomField.new
23
- custom_field.name = exemptionCustomFieldName
24
- custom_field.value = customer_usage_type
25
- account.add_custom_field(custom_field, user, reason, comment, options)
26
- end
19
+ return if customer_usage_type.nil?
20
+
21
+ # Set the exemption
22
+ custom_field = KillBillClient::Model::CustomField.new
23
+ custom_field.name = exemption_cf_name
24
+ custom_field.value = customer_usage_type
25
+ account.add_custom_field(custom_field, user, reason, comment, options)
27
26
  end
28
27
 
29
28
  def remove_exemption(account_id, user, reason, comment, options = {})
@@ -42,22 +41,19 @@ module Killbill
42
41
  JSON.parse(response.body).symbolize_keys
43
42
  end
44
43
 
45
- def set_tax_code(product_name, tax_code, user, reason, comment, options = {})
46
- body = {:productName => product_name, :taxCode => tax_code}.to_json
44
+ def set_tax_code(product_name, tax_code, _user, _reason, _comment, options = {})
45
+ body = { productName: product_name, taxCode: tax_code }.to_json
47
46
 
48
47
  path = "#{KILLBILL_AVATAX_PREFIX}/taxCodes"
49
48
  response = KillBillClient::API.post path, body, {}, options
50
49
  response.body
51
50
  end
52
51
 
53
- def remove_tax_code(product_name, user, reason, comment, options= {})
52
+ def remove_tax_code(product_name, _user, _reason, _comment, options = {})
54
53
  path = "#{KILLBILL_AVATAX_PREFIX}/taxCodes/#{product_name}"
55
54
  KillBillClient::API.delete path, nil, {}, options
56
55
  end
57
-
58
56
  end
59
-
60
57
  end
61
-
62
58
  end
63
59
  end
data/lib/avatax/engine.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Dependencies
2
4
  #
3
5
  # Sigh. Rails autoloads the gems specified in the Gemfile and nothing else.
@@ -7,12 +9,10 @@
7
9
  require 'jquery-rails'
8
10
  require 'jquery-datatables-rails'
9
11
  require 'font-awesome-rails'
10
- require 'twitter-bootstrap-rails'
11
12
  require 'killbill_client'
12
13
 
13
14
  module Avatax
14
15
  class Engine < ::Rails::Engine
15
-
16
16
  isolate_namespace Avatax
17
17
  end
18
18
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Avatax
2
- VERSION = '2.0.0'
4
+ VERSION = '3.0.1'
3
5
  end
data/lib/avatax.rb CHANGED
@@ -1,22 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'avatax/engine'
2
4
 
3
5
  module Avatax
4
-
5
6
  mattr_accessor :current_tenant_user
6
7
  mattr_accessor :layout
7
8
 
8
- self.current_tenant_user = lambda { |session, user|
9
- {:username => 'admin',
10
- :password => 'password',
11
- :session_id => nil,
12
- :api_key => KillBillClient.api_key,
13
- :api_secret => KillBillClient.api_secret}
9
+ self.current_tenant_user = lambda { |_session, _user|
10
+ { username: 'admin',
11
+ password: 'password',
12
+ session_id: nil,
13
+ api_key: KillBillClient.api_key,
14
+ api_secret: KillBillClient.api_secret }
14
15
  }
15
16
 
16
- def self.config(&block)
17
+ def self.config
17
18
  {
18
- :layout => layout || 'avatax/layouts/avatax_application',
19
+ layout: layout || 'avatax/layouts/avatax_application'
19
20
  }
20
21
  end
21
-
22
22
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # desc "Explaining what the task does"
2
3
  # task :avatax do
3
4
  # # Task goes here