workarea-avatax 4.2.0 → 4.2.1

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
2
  SHA256:
3
- metadata.gz: 154de54ee351747a48c10892cc8ae997fea1584ccc63388295ad304ff35e195e
4
- data.tar.gz: 3a06052d7b64aebabc4648482c553ce0b4012a2db1533ec19bf691425477c377
3
+ metadata.gz: 713fe2f7c3c7676ee8e2ecf1c8ef1eafd6febd8b138b09ab72998ab70aad9300
4
+ data.tar.gz: 2f0523ea4a27aa522c05db4b5a55b329e9c55596039ab1ba7b6e3e7934c4ac30
5
5
  SHA512:
6
- metadata.gz: 6b4e6f1e88d2d040c60b3f0b30b020bb31918fa02ad956ca80b58a9a663e30eaac0ab594f6a60a256ccce531e1710b63818b2d0b1696ce852eae16bde60e7dfb
7
- data.tar.gz: 59a9e7d21976bd0b47e5b3c2d2345c89a793e780981a1ee548715bf173145dbf68d9cabc0775630b47b0cf910f3fb278fb2950144225d9ad202c41684b45adfa
6
+ metadata.gz: 1e6c9ca74441bb3d82772de4bffc30d65b1891e59bb28d6bd3f3a81165c601a6a57b68a207165ed391310b39306f73322b4551f6b50beebc6949674e4db801a0
7
+ data.tar.gz: 7bcbad121322c508dffbc5fd24c690d9d0f9b3d16bc1ce5368e343015bc19ed71632981dd06769f2c30cd2fbc8e25251e12169f3b74985803709bac9ca264171
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ Gemfile.lock
16
16
  coverage
17
17
  .DS_Store
18
18
  .byebug_history
19
+ .rubocop-http*
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ Workarea Avatax 4.2.1 (2020-03-05)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Respect the tax exempt flag on b2b account
5
+
6
+ Checks for the installation for b2b plugin and creates zero dollar
7
+ price adjustments for tax exempt organizations
8
+
9
+ AVATAX-2
10
+ Jeff Yucis
11
+
12
+
13
+
1
14
  Workarea Avatax 4.2.0 (2019-11-26)
2
15
  --------------------------------------------------------------------------------
3
16
 
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'workarea', git: 'https://github.com/workarea-commerce/workarea.git'
5
+ gem 'workarea', git: 'https://github.com/workarea-commerce/workarea.git', branch: 'v3.5-stable'
6
6
  gem 'workarea-oms', git: "https://x-access-token:#{ENV['GITHUB_ACCESS_TOKEN']}@github.com/workarea-commerce/workarea-oms.git"
7
7
 
8
8
  group :test do
data/Rakefile CHANGED
@@ -38,10 +38,9 @@ task :release do
38
38
  Rake::Task["workarea:changelog"].execute
39
39
  system "git add CHANGELOG.md"
40
40
  system 'git commit -m "Update CHANGELOG"'
41
- system "git push origin HEAD"
42
41
 
43
42
  system "git tag -a v#{Workarea::Avatax::VERSION} -m 'Tagging #{Workarea::Avatax::VERSION}'"
44
- system "git push --tags"
43
+ system "git push origin HEAD --follow-tags"
45
44
 
46
45
  system "gem build workarea-avatax.gemspec"
47
46
  system "gem push workarea-avatax-#{Workarea::Avatax::VERSION}.gem"
@@ -7,6 +7,29 @@ module Workarea
7
7
  include Calculator
8
8
 
9
9
  def adjust
10
+ if organization_tax_exempt?
11
+ shippings.each do |tmp_shipping|
12
+ next unless tmp_shipping.address.present?
13
+
14
+ price_adjustments_for(tmp_shipping).each do |adjustment|
15
+ tmp_shipping.adjust_pricing(
16
+ price: 'tax',
17
+ calculator: self.class.name,
18
+ description: 'Item Tax',
19
+ amount: 0.to_m,
20
+ data: {
21
+ 'adjustment' => adjustment.id,
22
+ 'order_item_id' => adjustment._parent.id,
23
+ 'tax_code' => adjustment.data['tax_code'],
24
+ 'tax_exempt' => true
25
+ }
26
+ )
27
+ end
28
+ end
29
+
30
+ return
31
+ end
32
+
10
33
  response = Avatax::TaxRequest.new(
11
34
  order: order,
12
35
  shippings: shippings,
@@ -62,6 +85,16 @@ module Workarea
62
85
 
63
86
  private
64
87
 
88
+ def organization_tax_exempt?
89
+ return false unless Workarea::Plugin.installed?(:b2b)
90
+
91
+ account = Organization::Account.find(order.account_id) rescue nil
92
+
93
+ return unless account.present?
94
+
95
+ account.tax_exempt?
96
+ end
97
+
65
98
  def request_options
66
99
  { timeout: 2 }
67
100
  end
@@ -1,5 +1,5 @@
1
1
  module Workarea
2
2
  module Avatax
3
- VERSION = '4.2.0'
3
+ VERSION = '4.2.1'
4
4
  end
5
5
  end
@@ -0,0 +1,56 @@
1
+ require "test_helper"
2
+
3
+ module Workarea
4
+ module Pricing
5
+ module Calculators
6
+ class ExemptTaxCalculatorTest < Workarea::TestCase
7
+ if Workarea::Plugin.installed?(:b2b)
8
+ def test_adjust
9
+ account = create_account(tax_exempt: true)
10
+
11
+ create_pricing_sku(
12
+ id: 'SKU',
13
+ tax_code: '001',
14
+ prices: [{ regular: 5.to_m }]
15
+ )
16
+
17
+ create_tax_category(
18
+ code: '001',
19
+ rates: [{ percentage: 0.06, region: 'PA', country: 'US' }]
20
+ )
21
+
22
+ order = Order.new(
23
+ account_id: account.id,
24
+ items: [
25
+ {
26
+ price_adjustments: [
27
+ {
28
+ price: 'item',
29
+ amount: 5.to_m,
30
+ data: { 'tax_code' => '001' }
31
+ }
32
+ ]
33
+ }
34
+ ]
35
+ )
36
+
37
+ shipping = Shipping.new
38
+
39
+ shipping.set_address(
40
+ postal_code: '19106',
41
+ region: 'PA',
42
+ country: 'US'
43
+ )
44
+
45
+ AvalaraTaxCalculator.test_adjust(order, shipping)
46
+
47
+ assert_equal(1, shipping.price_adjustments.length)
48
+ assert_equal('tax', shipping.price_adjustments.last.price)
49
+ assert_equal(0.to_m, shipping.price_adjustments.first.amount)
50
+ assert(shipping.price_adjustments.first.data["tax_exempt"])
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-avatax
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Pigeon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-26 00:00:00.000000000 Z
11
+ date: 2020-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea
@@ -144,6 +144,7 @@ files:
144
144
  - test/lib/workarea/avatax_test.rb
145
145
  - test/models/workarea/avatax/usage_type_test.rb
146
146
  - test/models/workarea/pricing/calculators/avalara_tax_calculator_test.rb
147
+ - test/models/workarea/pricing/calculators/exempt_tax_calculator_test.rb
147
148
  - test/support/avatax_test_settings.rb
148
149
  - test/system/workarea/storefront/avatax_system_test.rb
149
150
  - test/test_helper.rb