super_good-solidus_taxjar 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76b48f5239948da1f17684991f5c22f66f2f4326
4
- data.tar.gz: 3ea032a3d4659ed75142bf9eb338da2985309164
3
+ metadata.gz: 4fabc8235afd3cc52046d35cf5d88ec0cd17d8e7
4
+ data.tar.gz: 52067151ebe53c704c9e9afb168919a2438f064c
5
5
  SHA512:
6
- metadata.gz: 554d571ac1eaf53f17cbb903ae3fd25efa2942dc23d77e9f6d07cdf18f637249732d73e0d5c859d614408eefd820a1d2f6bbd7aaebc4c4e99772ce612ce9ef8b
7
- data.tar.gz: 6b72b4a99f1c7f68955ff07c8c45f1061209dd11e0300e322bd8101162a5fa240074a0e0f292824c68ce665f51e39da664d43cdc2c9544ca60540bc6c34b1b43
6
+ metadata.gz: 9df52cfcec3b89302cf1b652172a7fa9f3545554d6ddb448f4a901dd681cdc0a15b8a710027e620078a9c2620ffe6bfee52b059a5cdb719b85e8a53579e3750d
7
+ data.tar.gz: 7d33b0dd569cde3c71e8b0bc390d406a6ba7c04200f206b45ab531f6ed5fae8a6e825c2cf0876887243197ca3b9b39589efa7d684721b9d5136f47362326c4ba
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.6.0
4
+
5
+ - Added `SuperGood::SolidusTaxJar.shipping_tax_label_maker` for customizing the labels on the tax adjustments on shipments.
6
+ - Added `SuperGood::SolidusTaxJar.line_item_tax_label_maker` for customizing the labels on the line iteme tax adjustments.
7
+
3
8
  ## v0.5.0
4
9
 
5
10
  - Moved exception handler configuration to `SuperGood::SolidusTaxJar.exception_handler` from `SuperGood::SolidusTaxJar::TaxCalculator.exception_handler`. Now all the configuration options are in the same place.
@@ -15,6 +15,8 @@ module SuperGood
15
15
  attr_accessor :test_mode
16
16
  attr_accessor :exception_handler
17
17
  attr_accessor :taxable_address_check
18
+ attr_accessor :shipping_tax_label_maker
19
+ attr_accessor :line_item_tax_label_maker
18
20
  end
19
21
 
20
22
  self.discount_calculator = ::SuperGood::SolidusTaxJar::DiscountCalculator
@@ -23,5 +25,7 @@ module SuperGood
23
25
  Rails.logger.error "An error occurred while fetching TaxJar tax rates - #{e}: #{e.message}"
24
26
  }
25
27
  self.taxable_address_check = ->(address) { true }
28
+ self.shipping_tax_label_maker = ->(shipment, shipping_tax) { "Sales Tax" }
29
+ self.line_item_tax_label_maker = ->(taxjar_line_item, spree_line_item) { "Sales Tax" }
26
30
  end
27
31
  end
@@ -35,12 +35,18 @@ module SuperGood
35
35
 
36
36
  def line_item_taxes
37
37
  @line_item_taxes ||=
38
- taxjar_breakdown.line_items.map do |line_item|
38
+ taxjar_breakdown.line_items.map do |taxjar_line_item|
39
+ spree_line_item_id = taxjar_line_item.id.to_i
40
+
41
+ # Searching in memory because this association is loaded and most
42
+ # orders aren't going to have a huge number of line items.
43
+ spree_line_item = order.line_items.find { |li| li.id == spree_line_item_id }
44
+
39
45
  Spree::Tax::ItemTax.new(
40
- item_id: line_item.id.to_i,
41
- label: "Sales Tax",
46
+ item_id: spree_line_item_id,
47
+ label: line_item_tax_label(taxjar_line_item, spree_line_item),
42
48
  tax_rate: tax_rate,
43
- amount: line_item.tax_collectable,
49
+ amount: taxjar_line_item.tax_collectable,
44
50
  included_in_price: false
45
51
  )
46
52
  end
@@ -67,7 +73,7 @@ module SuperGood
67
73
 
68
74
  tax_items << ::Spree::Tax::ItemTax.new(
69
75
  item_id: shipment.id,
70
- label: "Sales Tax",
76
+ label: shipping_tax_label(shipment, shipping_tax),
71
77
  tax_rate: tax_rate,
72
78
  amount: shipping_tax,
73
79
  included_in_price: false
@@ -76,7 +82,7 @@ module SuperGood
76
82
 
77
83
  tax_items << ::Spree::Tax::ItemTax.new(
78
84
  item_id: shipments.last.id,
79
- label: "Sales Tax",
85
+ label: shipping_tax_label(shipments.last, remaining_tax),
80
86
  tax_rate: tax_rate,
81
87
  amount: remaining_tax,
82
88
  included_in_price: false
@@ -133,6 +139,17 @@ module SuperGood
133
139
  def taxable_address?(address)
134
140
  SuperGood::SolidusTaxJar.taxable_address_check.(address)
135
141
  end
142
+
143
+ def shipping_tax_label(shipment, shipping_tax)
144
+ SuperGood::SolidusTaxJar.shipping_tax_label_maker.(
145
+ shipment,
146
+ shipping_tax
147
+ )
148
+ end
149
+
150
+ def line_item_tax_label(taxjar_line_item, spree_line_item)
151
+ SuperGood::SolidusTaxJar.line_item_tax_label_maker.(taxjar_line_item, spree_line_item)
152
+ end
136
153
  end
137
154
  end
138
155
  end
@@ -1,5 +1,5 @@
1
1
  module SuperGood
2
2
  module SolidusTaxJar
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_good-solidus_taxjar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared Norman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-05 00:00:00.000000000 Z
11
+ date: 2019-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core