super_good-solidus_taxjar 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/super_good/solidus_taxjar/api.rb +9 -5
- data/lib/super_good/solidus_taxjar/discount_calculator.rb +17 -0
- data/lib/super_good/solidus_taxjar/tax_calculator.rb +8 -21
- data/lib/super_good/solidus_taxjar/version.rb +1 -1
- data/lib/super_good/solidus_taxjar.rb +12 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 802c6668a1ea106f680f6c0fcffa87ae3ab118c4
|
4
|
+
data.tar.gz: 46c432958f8131ea6625187a645ce8e3bcf3fb5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b06a684114911d7c4b166cd62790e7bc4bb0af0778252453367e90210aa9c7c84b4306c358a7fa530af88601de9ccb3a335f4502b26e16060fb26960cfe0314f
|
7
|
+
data.tar.gz: 4a88564733603bc1d7d8d7e8be69f77c80bbb27e57f33ea8dca476862d3c4203020d6c24c30acae443756cbf5dc0ec6d8f95bb4d01a6d4daeae27598c16b8143
|
@@ -26,10 +26,6 @@ module SuperGood
|
|
26
26
|
)
|
27
27
|
end
|
28
28
|
|
29
|
-
private
|
30
|
-
|
31
|
-
attr_reader :taxjar_client
|
32
|
-
|
33
29
|
def order_params(order)
|
34
30
|
tax_address = order.tax_address
|
35
31
|
|
@@ -47,12 +43,20 @@ module SuperGood
|
|
47
43
|
id: line_item.id,
|
48
44
|
quantity: line_item.quantity,
|
49
45
|
unit_price: line_item.price,
|
50
|
-
discount:
|
46
|
+
discount: discount(line_item),
|
51
47
|
product_tax_code: line_item.tax_category&.tax_code
|
52
48
|
}
|
53
49
|
end
|
54
50
|
}
|
55
51
|
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
attr_reader :taxjar_client
|
56
|
+
|
57
|
+
def discount(line_item)
|
58
|
+
::SuperGood::SolidusTaxJar.discount_calculator.new(line_item).discount
|
59
|
+
end
|
56
60
|
end
|
57
61
|
end
|
58
62
|
end
|
@@ -16,6 +16,7 @@ module SuperGood
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def calculate
|
19
|
+
return no_tax if SuperGood::SolidusTaxJar.test_mode
|
19
20
|
return no_tax if order.tax_address.empty? || order.line_items.none?
|
20
21
|
|
21
22
|
cache do
|
@@ -120,27 +121,13 @@ module SuperGood
|
|
120
121
|
end
|
121
122
|
|
122
123
|
def cache_key
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
to_street: tax_address.address1,
|
131
|
-
|
132
|
-
shipping: order.shipment_total,
|
133
|
-
|
134
|
-
line_items: order.line_items.map do |line_item|
|
135
|
-
{
|
136
|
-
id: line_item.id,
|
137
|
-
quantity: line_item.quantity,
|
138
|
-
unit_price: line_item.price,
|
139
|
-
discount: -line_item.adjustment_total,
|
140
|
-
product_tax_code: line_item.tax_category&.tax_code
|
141
|
-
}
|
142
|
-
end.hash
|
143
|
-
}
|
124
|
+
api.order_params(order).transform_values do |value|
|
125
|
+
case value
|
126
|
+
when Array, Hash then value.hash
|
127
|
+
else
|
128
|
+
value
|
129
|
+
end
|
130
|
+
end
|
144
131
|
end
|
145
132
|
end
|
146
133
|
end
|
@@ -2,11 +2,19 @@ require 'solidus_core'
|
|
2
2
|
require 'solidus_support'
|
3
3
|
require 'taxjar'
|
4
4
|
|
5
|
+
require "super_good/solidus_taxjar/version"
|
6
|
+
require "super_good/solidus_taxjar/api"
|
7
|
+
require "super_good/solidus_taxjar/tax_calculator"
|
8
|
+
require "super_good/solidus_taxjar/discount_calculator"
|
9
|
+
|
5
10
|
module SuperGood
|
6
11
|
module SolidusTaxJar
|
12
|
+
class << self
|
13
|
+
attr_accessor :discount_calculator
|
14
|
+
attr_accessor :test_mode
|
15
|
+
end
|
16
|
+
|
17
|
+
self.discount_calculator = ::SuperGood::SolidusTaxJar::DiscountCalculator
|
18
|
+
self.test_mode = false
|
7
19
|
end
|
8
20
|
end
|
9
|
-
|
10
|
-
require "super_good/solidus_taxjar/version"
|
11
|
-
require "super_good/solidus_taxjar/api"
|
12
|
-
require "super_good/solidus_taxjar/tax_calculator"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: super_good-solidus_taxjar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Norman
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- bin/setup
|
170
170
|
- lib/super_good/solidus_taxjar.rb
|
171
171
|
- lib/super_good/solidus_taxjar/api.rb
|
172
|
+
- lib/super_good/solidus_taxjar/discount_calculator.rb
|
172
173
|
- lib/super_good/solidus_taxjar/tax_calculator.rb
|
173
174
|
- lib/super_good/solidus_taxjar/version.rb
|
174
175
|
- super_good-solidus_taxjar.gemspec
|