solidus_avatax_certified 1.0.0 → 1.1.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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +28 -0
  3. data/Gemfile +3 -0
  4. data/README.md +4 -0
  5. data/app/assets/javascripts/spree/backend/address_validator.js +1 -1
  6. data/app/assets/javascripts/spree/frontend/address_validator.js +1 -1
  7. data/app/controllers/spree/admin/avatax_settings_controller.rb +5 -13
  8. data/app/models/solidus_avatax_certified/address.rb +2 -8
  9. data/app/models/solidus_avatax_certified/avatax_log.rb +10 -20
  10. data/app/models/solidus_avatax_certified/line.rb +0 -6
  11. data/app/models/solidus_avatax_certified/preference_updater.rb +11 -28
  12. data/app/models/solidus_avatax_certified/request/base.rb +64 -0
  13. data/app/models/solidus_avatax_certified/request/cancel_tax.rb +14 -0
  14. data/app/models/solidus_avatax_certified/request/get_tax.rb +27 -0
  15. data/app/models/solidus_avatax_certified/request/return_tax.rb +50 -0
  16. data/app/models/solidus_avatax_certified/response/address_validation.rb +11 -0
  17. data/app/models/solidus_avatax_certified/response/base.rb +25 -0
  18. data/app/models/solidus_avatax_certified/response/cancel_tax.rb +15 -0
  19. data/app/models/solidus_avatax_certified/response/get_tax.rb +11 -0
  20. data/app/models/spree/address_decorator.rb +2 -2
  21. data/app/models/spree/adjustment_decorator.rb +0 -2
  22. data/app/models/spree/avalara_transaction.rb +20 -108
  23. data/app/models/spree/avatax_configuration.rb +25 -0
  24. data/app/models/spree/calculator/avalara_transaction.rb +18 -10
  25. data/app/models/spree/order_decorator.rb +7 -15
  26. data/app/models/spree/payment_decorator.rb +2 -7
  27. data/app/models/spree/refund_decorator.rb +6 -10
  28. data/app/models/spree/shipping_rate_decorator.rb +1 -1
  29. data/app/models/tax_svc.rb +71 -61
  30. data/app/views/spree/admin/avatax_settings/edit.html.erb +34 -54
  31. data/app/views/spree/admin/avatax_settings/show.html.erb +28 -35
  32. data/app/views/spree/checkout/_address_validator_button.html.erb +1 -1
  33. data/config/initializers/avatax.rb +11 -2
  34. data/config/locales/en.yml +9 -3
  35. data/config/routes.rb +1 -1
  36. data/db/migrate/20170509201056_drop_spree_avalara_preferences.rb +6 -0
  37. data/lib/solidus_avatax_certified/exceptions.rb +4 -0
  38. data/lib/solidus_avatax_certified/preference_seeder.rb +9 -27
  39. data/lib/solidus_avatax_certified/version.rb +3 -0
  40. data/lib/solidus_avatax_certified.rb +2 -0
  41. data/solidus_avatax_certified.gemspec +6 -3
  42. data/spec/controllers/spree/admin/avatax_settings_controller_spec.rb +8 -8
  43. data/spec/factories/response_hash_factories.rb +88 -0
  44. data/spec/features/checkout_spec.rb +1 -1
  45. data/spec/features/vat_spec.rb +1 -1
  46. data/spec/models/solidus_avatax_certified/address_spec.rb +22 -7
  47. data/spec/models/solidus_avatax_certified/avatax_log_spec.rb +17 -24
  48. data/spec/models/solidus_avatax_certified/line_spec.rb +8 -4
  49. data/spec/models/solidus_avatax_certified/request/base_spec.rb +13 -0
  50. data/spec/models/solidus_avatax_certified/request/cancel_tax_spec.rb +13 -0
  51. data/spec/models/solidus_avatax_certified/request/get_tax_spec.rb +31 -0
  52. data/spec/models/solidus_avatax_certified/request/return_tax_spec.rb +31 -0
  53. data/spec/models/solidus_avatax_certified/response/base_spec.rb +21 -0
  54. data/spec/models/spree/address_decorator_spec.rb +5 -5
  55. data/spec/models/spree/adjustment_decorator_spec.rb +0 -10
  56. data/spec/models/spree/avalara_transaction_spec.rb +12 -12
  57. data/spec/models/spree/calculator/avalara_transaction_spec.rb +4 -3
  58. data/spec/models/spree/order_decorator_spec.rb +38 -12
  59. data/spec/models/spree/payment_decorator_spec.rb +7 -9
  60. data/spec/models/spree/refund_decorator_spec.rb +1 -1
  61. data/spec/models/tax_svc_spec.rb +65 -0
  62. data/spec/spec_helper.rb +3 -2
  63. data/spec/support/avatax_config_preferences.rb +1 -3
  64. data/spec/support/vcr.rb +1 -1
  65. data/spec/vcr/Spree_Order/_cancel_avalara/error/should_raise_exception_if_preference_is_enabled.yml +191 -0
  66. data/spec/vcr/Spree_Order/_cancel_avalara/error/should_receive_ResultCode_of_Error.yml +191 -0
  67. data/spec/vcr/{SolidusAvataxCertified_Address/_validate/fails_when_information_is_incorrect.yml → Spree_Order/_validate_ship_address/validation_failed/raise_exceptions_if_raise_exceptions_preference_is_enabled.yml} +8 -8
  68. data/spec/vcr/Spree_Order/_validate_ship_address/validation_failed/should_return_false.yml +54 -0
  69. data/spec/vcr/Spree_Payment/_avalara_finalize/should_receive_avalara_finalize.yml +205 -0
  70. data/spec/vcr/TaxSvc/_cancel_tax/respond_with_success.yml +121 -0
  71. data/spec/vcr/TaxSvc/_cancel_tax/should_raise_error.yml +58 -0
  72. data/spec/vcr/TaxSvc/_get_tax/fails/fails_when_no_lines_are_given.yml +60 -0
  73. data/spec/vcr/TaxSvc/_get_tax/fails/fails_when_no_params_are_given.yml +68 -0
  74. data/spec/vcr/TaxSvc/_get_tax/fails/responds_with_error_when_result_code_is_not_a_success.yml +61 -0
  75. data/spec/vcr/TaxSvc/_get_tax/gets_tax_when_all_credentials_are_there.yml +68 -0
  76. data/spec/vcr/TaxSvc/_ping/should_return_estimate.yml +81 -0
  77. data/spec/vcr/address_validation_failure.yml +54 -0
  78. data/spec/vcr/address_validation_success.yml +16 -16
  79. data/spec/vcr/order_capture.yml +21 -21
  80. data/spec/vcr/order_capture_finalize.yml +22 -91
  81. metadata +56 -13
  82. data/GEM_VERSION +0 -1
  83. data/app/models/spree/avalara_preference.rb +0 -72
  84. data/spec/factories/avalara_preference_factory.rb +0 -7
  85. data/spec/models/spree/avalara_preference_spec.rb +0 -173
  86. data/spec/vcr/Spree_Payment/_avalara_finalize/should_update_the_amount_to_be_the_order_total.yml +0 -136
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a887c27e84dad711cddf9d4fb3aeae1f8f218cd
4
- data.tar.gz: c0b14deafc45577a96fb16d4245b82e2e986679d
3
+ metadata.gz: 88d7c785ac3c5a75d216e1ceb29f7a541579be6c
4
+ data.tar.gz: 6d5b6363588951eeef89cbe13a747ee4c4ae29c2
5
5
  SHA512:
6
- metadata.gz: 0d006929267b836849d0b4a8f552ad79ba1da794045d9b78fcd261051a53b659591374725b3f859930d9228f162c2a4b3fd45cf8273a66ae56fbdbeaccf78f65
7
- data.tar.gz: b3f43090df24a9545a291b13e5f5bcce024cc70f74805430fd4f3bd73fc94b68c40acc9a7f528c64bb1796642655c05a979b4fa62e587bd58036dd821a1ec6fa
6
+ metadata.gz: 4831e98ede6e7d067b7d889184553261726f04faeac142133c7b53cddd19f46d1179b2ee680baf93dafbcbfd633c5edab8bcca6fc25104c96480d8d12b90067d
7
+ data.tar.gz: f4a2e6f51878e652053d1c2bc4f951e592a441cdf7f85cff13409a4d28403154b395304d3625991396509bf57410db61e6249612893b538bf4f5085eb7fa5308
data/.travis.yml ADDED
@@ -0,0 +1,28 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install:
6
+ - rvm @default,@global do gem uninstall bundler -x
7
+ - gem install bundler --version '~> 1.13.0'
8
+ - bundle --version
9
+ before_script:
10
+ - sh -e /etc/init.d/xvfb start
11
+ - export DISPLAY=:99.0
12
+ - bundle exec rake test_app
13
+ script:
14
+ - bundle exec rspec
15
+ env:
16
+ matrix:
17
+ - SOLIDUS_BRANCH=v1.0 DB=postgres
18
+ - SOLIDUS_BRANCH=v1.1 DB=postgres
19
+ - SOLIDUS_BRANCH=v1.2 DB=postgres
20
+ - SOLIDUS_BRANCH=v1.3 DB=postgres
21
+ - SOLIDUS_BRANCH=v1.4 DB=postgres
22
+ - SOLIDUS_BRANCH=v2.0 DB=postgres
23
+ - SOLIDUS_BRANCH=v1.0 DB=mysql
24
+ - SOLIDUS_BRANCH=v1.1 DB=mysql
25
+ - SOLIDUS_BRANCH=v1.2 DB=mysql
26
+ - SOLIDUS_BRANCH=v1.3 DB=mysql
27
+ - SOLIDUS_BRANCH=v1.4 DB=mysql
28
+ - SOLIDUS_BRANCH=v2.0 DB=mysql
data/Gemfile CHANGED
@@ -15,4 +15,7 @@ else
15
15
  gem "rails_test_params_backport", group: :test
16
16
  end
17
17
 
18
+ gem 'pg'
19
+ gem 'mysql2'
20
+
18
21
  gemspec
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/boomerdigital/solidus_avatax_certified.svg?branch=master)](https://travis-ci.org/boomerdigital/solidus_avatax_certified)
2
+
1
3
  SolidusAvataxCertified
2
4
  ===========
3
5
 
@@ -12,6 +14,8 @@ From Avalara's own explanation of the certification program:
12
14
  > Avalara’s partners who have created certified integrations for AvaTax have demonstrated that those integrations contain elements which are essential to providing customers with easy-to-use software that gives accurate sales tax calculations. The certification criteria used to demonstrate these elements are based on Avalara’s years of experience integrating into ERP, ecommerce and point-of-sale applications.
13
15
 
14
16
 
17
+ **For Solidus versions v2.1 and up, please use branch v2.1**
18
+
15
19
  **[For Installation and Setup instructions, please visit our wiki.](https://github.com/boomerdigital/solidus_avatax_certified/wiki)**
16
20
 
17
21
  Testing
@@ -37,7 +37,7 @@ AddressValidator.prototype = {
37
37
 
38
38
  $.each(["Line1", "Line2", "City", "PostalCode"], function(index, value){
39
39
  var keyVal = controller.getKeyByValue(value);
40
- $(wrapper + " input[id*='" + keyVal + "']").val(data.Address[value]);
40
+ $(wrapper + " input[id*='" + keyVal + "']").val(data.result.Address[value]);
41
41
  }.bind(address));
42
42
 
43
43
  this.showFlash(data);
@@ -39,7 +39,7 @@ AddressValidator.prototype = {
39
39
 
40
40
  $.each(["Line1", "Line2", "City", "PostalCode"], function(index, value){
41
41
  var keyVal = controller.getKeyByValue(value);
42
- $(wrapper + " input[id*='" + keyVal + "']").val(data.Address[value]);
42
+ $(wrapper + " input[id*='" + keyVal + "']").val(data.result.Address[value]);
43
43
  }.bind(address));
44
44
 
45
45
  this.showFlash(data);
@@ -7,20 +7,12 @@ module Spree
7
7
  def show
8
8
  end
9
9
 
10
- def get_file_txt_tax_svc
11
- send_file "#{Rails.root}/log/tax_svc.log"
12
- end
13
-
14
- def get_file_post_order_to_avalara
15
- send_file "#{Rails.root}/log/post_order_to_avalara.log"
16
- end
17
-
18
- def get_file_avalara_order
19
- send_file "#{Rails.root}/log/avalara_order.log"
10
+ def download_avatax_log
11
+ send_file "#{Rails.root}/log/avatax.log"
20
12
  end
21
13
 
22
14
  def erase_data
23
- File.open("log/#{params['log_name']}.log", 'w') {}
15
+ File.open("log/avatax.log", 'w') {}
24
16
 
25
17
  head :ok
26
18
  end
@@ -67,10 +59,10 @@ module Spree
67
59
  private
68
60
 
69
61
  def load_avatax_origin
70
- if Spree::AvalaraPreference.origin_address.value.blank?
62
+ if Spree::Avatax::Config.origin.blank?
71
63
  @avatax_origin = {}
72
64
  else
73
- @avatax_origin = JSON.parse(Spree::AvalaraPreference.origin_address.value)
65
+ @avatax_origin = JSON.parse(Spree::Avatax::Config.origin)
74
66
  end
75
67
  end
76
68
 
@@ -10,7 +10,7 @@ module SolidusAvataxCertified
10
10
  def initialize(order)
11
11
  @order = order
12
12
  @ship_address = order.ship_address
13
- @origin_address = JSON.parse(Spree::AvalaraPreference.origin_address.value)
13
+ @origin_address = JSON.parse(Spree::Avatax::Config.origin)
14
14
  @addresses = []
15
15
 
16
16
  build_addresses
@@ -20,8 +20,6 @@ module SolidusAvataxCertified
20
20
  origin_address
21
21
  order_ship_address unless @ship_address.nil?
22
22
  origin_ship_addresses
23
-
24
- logger.debug @addresses
25
23
  end
26
24
 
27
25
  def origin_address
@@ -81,15 +79,11 @@ module SolidusAvataxCertified
81
79
 
82
80
  def validation_response(address)
83
81
  validator = TaxSvc.new
84
- validator.validate_address(address)
82
+ validator.validate_address(address).validation_result
85
83
  end
86
84
 
87
85
  def stock_loc_ids
88
86
  order.shipments.pluck(:stock_location_id).uniq
89
87
  end
90
-
91
- def logger
92
- @logger ||= SolidusAvataxCertified::AvataxLog.new('avalara_order_addresses', 'SolidusAvataxCertified::Address', "Building Addresses for Order#: #{order.number}")
93
- end
94
88
  end
95
89
  end
@@ -1,9 +1,9 @@
1
1
  module SolidusAvataxCertified
2
2
  class AvataxLog
3
- def initialize(path_name, file_name, log_info = nil, schedule = nil)
4
- if !Spree::AvalaraPreference.log_to_stdout.is_true?
3
+ def initialize(file_name, log_info = nil, schedule = nil)
4
+ if !Spree::Avatax::Config.log_to_stdout
5
5
  schedule = 'weekly' unless schedule != nil
6
- @logger ||= Logger.new("#{Rails.root}/log/#{path_name}.log", schedule)
6
+ @logger ||= Logger.new("#{Rails.root}/log/avatax.log", schedule)
7
7
  progname(file_name.split('/').last.chomp('.rb'))
8
8
  info(log_info) unless log_info.nil?
9
9
  else
@@ -17,7 +17,7 @@ module SolidusAvataxCertified
17
17
  end
18
18
 
19
19
  def enabled?
20
- Spree::AvalaraPreference.log.is_true? || Spree::AvalaraPreference.log_to_stdout.is_true?
20
+ Spree::Avatax::Config.log || Spree::Avatax::Config.log_to_stdout
21
21
  end
22
22
 
23
23
  def progname(progname = nil)
@@ -26,11 +26,9 @@ module SolidusAvataxCertified
26
26
  end
27
27
  end
28
28
 
29
- def info(log_info = nil)
29
+ def info(message, obj = nil)
30
30
  if enabled?
31
- unless log_info.nil?
32
- logger.info "[AVATAX] #{log_info}"
33
- end
31
+ logger.info "[AVATAX] #{message} #{obj}"
34
32
  end
35
33
  end
36
34
 
@@ -46,23 +44,15 @@ module SolidusAvataxCertified
46
44
  end
47
45
 
48
46
 
49
- def debug(obj, text = nil)
47
+ def debug(obj, message='')
50
48
  if enabled?
51
- logger.debug "[AVATAX] #{obj.inspect}"
52
- if text.nil?
53
- obj
54
- else
55
- logger.debug "[AVATAX] text"
56
- text
57
- end
49
+ logger.debug "[AVATAX] #{message} #{obj.inspect}"
58
50
  end
59
51
  end
60
52
 
61
- def error(log_info = nil)
53
+ def error(obj, message='')
62
54
  if enabled?
63
- unless log_info.nil?
64
- logger.error "[AVATAX] #{log_info}"
65
- end
55
+ logger.error "[AVATAX] #{message} #{obj}"
66
56
  end
67
57
  end
68
58
  end
@@ -18,8 +18,6 @@ module SolidusAvataxCertified
18
18
  item_lines_array
19
19
  shipment_lines_array
20
20
  end
21
-
22
- logger.debug @lines
23
21
  end
24
22
 
25
23
  def item_line(line_item)
@@ -133,10 +131,6 @@ module SolidusAvataxCertified
133
131
  line_item.adjustments.promotion.eligible.any? || order.adjustments.promotion.eligible.any?
134
132
  end
135
133
 
136
- def logger
137
- @logger ||= SolidusAvataxCertified::AvataxLog.new('avalara_order_lines', 'SolidusAvataxCertified::Line', "Building Lines for Order#: #{order.number}")
138
- end
139
-
140
134
  def tax_included_in_price?(item)
141
135
  # Need better error handling
142
136
  # if no tax rates, raise error tax rates needs to be set up
@@ -7,56 +7,39 @@ module SolidusAvataxCertified
7
7
  end
8
8
 
9
9
  def update
10
+ update_storable_settings
11
+ update_boolean_settings
10
12
  update_validation_enabled_countries
11
13
  update_origin_address
12
- update_stored_preferences
13
- update_boolean_preferences
14
14
  end
15
15
 
16
16
  private
17
17
 
18
- def update_stored_preferences
19
- Spree::AvalaraPreference.storable_envs.each do |preference|
20
- if !ENV["AVATAX_#{preference.name.upcase}"].blank?
21
- update_value(preference, ENV["AVATAX_#{preference.name.upcase}"])
22
- else
23
- update_value(preference, @avatax_preferences[preference.name.downcase])
24
- end
18
+ def update_boolean_settings
19
+ Spree::AvataxConfiguration.boolean_preferences.each do |key|
20
+ Spree::Avatax::Config[key.to_sym] = @avatax_preferences[key] || false
25
21
  end
26
22
  end
27
23
 
28
- def update_boolean_preferences
29
- Spree::AvalaraPreference.booleans.each do |boolean|
30
- if !@avatax_preferences[boolean.name].nil?
31
- update_value(boolean, 'true')
32
- else
33
- update_value(boolean, 'false')
34
- end
24
+ def update_storable_settings
25
+ Spree::AvataxConfiguration.storable_env_preferences.each do |key|
26
+ Spree::Avatax::Config[key.to_sym] = @avatax_preferences[key] || ENV["AVATAX_#{key.upcase}"]
35
27
  end
36
28
  end
37
29
 
30
+
38
31
  def update_origin_address
39
32
  set_region
40
33
  set_country
41
- update_value(Spree::AvalaraPreference.origin_address, @avatax_origin.to_json)
34
+ Spree::Avatax::Config.origin = @avatax_origin.to_json
42
35
  end
43
36
 
44
37
  def update_validation_enabled_countries
45
38
  if @avatax_preferences['address_validation_enabled_countries'].present?
46
- update_value(Spree::AvalaraPreference.validation_enabled_countries, @avatax_preferences['address_validation_enabled_countries'].join(','))
47
- end
48
- end
49
-
50
- def update_value(preference, param)
51
- if value_changed?(preference, param)
52
- preference.update_attributes(value: param)
39
+ Spree::Avatax::Config.address_validation_enabled_countries = @avatax_preferences['address_validation_enabled_countries']
53
40
  end
54
41
  end
55
42
 
56
- def value_changed?(preference, param)
57
- preference.value != param
58
- end
59
-
60
43
  def set_region
61
44
  region = @avatax_origin['Region']
62
45
  unless region.blank?
@@ -0,0 +1,64 @@
1
+ module SolidusAvataxCertified
2
+ module Request
3
+ class Base
4
+ attr_reader :order, :request
5
+
6
+ def initialize(order, opts={})
7
+ @order = order
8
+ @doc_type = opts[:doc_type]
9
+ @commit = opts[:commit]
10
+ @request = {}
11
+ end
12
+
13
+ def generate
14
+ raise 'Method needs to be implemented in subclass.'
15
+ end
16
+
17
+ protected
18
+
19
+ def base_tax_hash
20
+ {
21
+ CustomerCode: customer_code,
22
+ CompanyCode: company_code,
23
+ CustomerUsageType: order.customer_usage_type,
24
+ ExemptionNo: order.user.try(:exemption_number),
25
+ Client: avatax_client_version,
26
+ ReferenceCode: order.number,
27
+ DetailLevel: 'Tax',
28
+ CurrencyCode: order.currency
29
+ }
30
+ end
31
+
32
+ # If there is a vat id, set BusinessIdentificationNo
33
+ def check_vat_id
34
+ if !business_id_no.blank?
35
+ @request[:BusinessIdentificationNo] = business_id_no
36
+ end
37
+ end
38
+
39
+ def address_lines
40
+ @address_lines ||= SolidusAvataxCertified::Address.new(order).addresses
41
+ end
42
+
43
+ def sales_lines
44
+ @sales_lines ||= SolidusAvataxCertified::Line.new(order, @doc_type).lines
45
+ end
46
+
47
+ def company_code
48
+ @company_code ||= Spree::Avatax::Config.company_code
49
+ end
50
+
51
+ def business_id_no
52
+ order.user.try(:vat_id)
53
+ end
54
+
55
+ def customer_code
56
+ order.user ? order.user.id : order.email
57
+ end
58
+
59
+ def avatax_client_version
60
+ AVATAX_CLIENT_VERSION || 'a0o33000004FH8l'
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,14 @@
1
+ module SolidusAvataxCertified
2
+ module Request
3
+ class CancelTax < SolidusAvataxCertified::Request::Base
4
+ def generate
5
+ @request = {
6
+ CompanyCode: company_code,
7
+ DocType: @doc_type,
8
+ DocCode: order.number,
9
+ CancelCode: 'DocVoided'
10
+ }
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ module SolidusAvataxCertified
2
+ module Request
3
+ class GetTax < SolidusAvataxCertified::Request::Base
4
+ def generate
5
+ @request = {
6
+ DocCode: order.number,
7
+ DocDate: doc_date,
8
+ Discount: order.all_adjustments.promotion.eligible.sum(:amount).abs.to_s,
9
+ Commit: @commit,
10
+ DocType: @doc_type ? @doc_type : 'SalesOrder',
11
+ Addresses: address_lines,
12
+ Lines: sales_lines
13
+ }.merge(base_tax_hash)
14
+
15
+ check_vat_id
16
+
17
+ @request
18
+ end
19
+
20
+ protected
21
+
22
+ def doc_date
23
+ order.completed? ? order.completed_at.strftime('%F') : Date.today.strftime('%F')
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,50 @@
1
+ module SolidusAvataxCertified
2
+ module Request
3
+ class ReturnTax < SolidusAvataxCertified::Request::Base
4
+
5
+ def initialize(order, opts={})
6
+ super
7
+ @refund = opts[:refund]
8
+ end
9
+
10
+ def generate
11
+ @request = {
12
+ DocCode: order.number.to_s + '.' + @refund.id.to_s,
13
+ DocDate: Date.today.strftime('%F'),
14
+ Commit: @commit,
15
+ DocType: @doc_type ? @doc_type : 'ReturnOrder',
16
+ Addresses: address_lines,
17
+ Lines: sales_lines
18
+ }.merge(base_tax_hash)
19
+
20
+ check_vat_id
21
+
22
+ @request
23
+ end
24
+
25
+ protected
26
+
27
+ def doc_date
28
+ Date.today.strftime('%F')
29
+ end
30
+
31
+ def base_tax_hash
32
+ super.merge(tax_override)
33
+ end
34
+
35
+ def tax_override
36
+ {
37
+ TaxOverride: {
38
+ TaxOverrideType: 'TaxDate',
39
+ Reason: @refund.try(:reason).try(:name).limit(255) || 'Return',
40
+ TaxDate: order.completed_at.strftime('%F')
41
+ }
42
+ }
43
+ end
44
+
45
+ def sales_lines
46
+ @sales_lines ||= SolidusAvataxCertified::Line.new(order, @doc_type, @refund).lines
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,11 @@
1
+ module SolidusAvataxCertified
2
+ module Response
3
+ class AddressValidation < SolidusAvataxCertified::Response::Base
4
+ alias :validation_result :result
5
+
6
+ def description
7
+ 'Address Validation'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ module SolidusAvataxCertified
2
+ module Response
3
+ class Base
4
+ attr_accessor :result
5
+ # To Do
6
+ # 1. Create way to display errors cleanly
7
+
8
+ def initialize(result)
9
+ @result = result
10
+ end
11
+
12
+ def success?
13
+ result['ResultCode'] == 'Success'
14
+ end
15
+
16
+ def error?
17
+ !success? rescue true
18
+ end
19
+
20
+ def description
21
+ raise 'Method needs to be implemented in subclass.'
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ module SolidusAvataxCertified
2
+ module Response
3
+ class CancelTax < SolidusAvataxCertified::Response::Base
4
+ alias :tax_result :result
5
+
6
+ def initialize(result)
7
+ @result = result['CancelTaxResult']
8
+ end
9
+
10
+ def description
11
+ 'Cancel Tax'
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module SolidusAvataxCertified
2
+ module Response
3
+ class GetTax < SolidusAvataxCertified::Response::Base
4
+ alias :tax_result :result
5
+
6
+ def description
7
+ 'Get Tax'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,6 +1,6 @@
1
1
  Spree::Address.class_eval do
2
2
  def validation_enabled?
3
- Spree::AvalaraPreference.address_validation.is_true? && country_validation_enabled?
3
+ Spree::Avatax::Config.address_validation && country_validation_enabled?
4
4
  end
5
5
 
6
6
  def country_validation_enabled?
@@ -8,6 +8,6 @@ Spree::Address.class_eval do
8
8
  end
9
9
 
10
10
  def self.validation_enabled_countries
11
- Spree::AvalaraPreference.validation_enabled_countries_array
11
+ Spree::Avatax::Config.address_validation_enabled_countries
12
12
  end
13
13
  end
@@ -1,6 +1,4 @@
1
1
  Spree::Adjustment.class_eval do
2
- scope :not_tax, -> { where.not(source_type: 'Spree::TaxRate') }
3
-
4
2
  def avatax_cache_key
5
3
  key = ['Spree::Adjustment']
6
4
  key << self.id