Skip to content

Commit 1b0bbe3

Browse files
authoredNov 7, 2024··
Merge pull request #300 from Shopify/df.add_tax_type
Add Region#tax_type accessor, cut v1.14.0
2 parents 7bcc93a + 9755b45 commit 1b0bbe3

File tree

6 files changed

+27
-3
lines changed

6 files changed

+27
-3
lines changed
 

‎CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2626
- Security in case of vulnerabilities.
2727

2828
## [Unreleased]
29-
- Add example_city_zip and priority accessors to Regions [#298](https://github.com/Shopify/worldwide/pull/298)
29+
- Nil.
3030

3131
---
3232

33+
## [1.14.0] - 2024-11-07
34+
- Add example_city_zip and priority accessors to Regions [#298](https://github.com/Shopify/worldwide/pull/298)
35+
- Add tax_type accessor to Regions [#299](https://github.com/Shopify/worldwide/pull/299)
36+
3337
## [1.13.0] - 2024-11-06
3438
- Add `zip_prefixes` for Spain. [#295](https://github.com/Shopify/worldwide/pull/295)
3539
- Move expensive resource initialization into an explicit `eager_load!` namespace method

‎Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ GIT
1313
PATH
1414
remote: .
1515
specs:
16-
worldwide (1.13.0)
16+
worldwide (1.14.0)
1717
activesupport (>= 7.0)
1818
i18n
1919
phonelib (~> 0.8)

‎lib/worldwide/region.rb

+3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ class Region
166166
# "generic" VAT tax rate on "most" goods
167167
attr_reader :tax_rate
168168

169+
# The type of tax for this region, e.g. "harmonized"
170+
attr_accessor :tax_type
171+
169172
# tags that help us group the region, e.g. "EU-member"
170173
attr_accessor :tags
171174

‎lib/worldwide/regions_loader.rb

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def apply_zone_attributes(region, zone)
134134
region.example_city = zone["example_city"]
135135
region.example_city_zip = zone["example_city_zip"]
136136
region.priority = zone["priority"]
137+
region.tax_type = zone["tax_type"] || nil
137138
region.neighbours = zone["neighboring_zones"]
138139
region.zip_prefixes = zone["zip_prefixes"] || []
139140
end

‎lib/worldwide/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Worldwide
4-
VERSION = "1.13.0"
4+
VERSION = "1.14.0"
55
end

‎test/worldwide/region_test.rb

+16
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ class RegionTest < ActiveSupport::TestCase
8686
assert_empty region.zip_prefixes
8787
assert_nil region.zip_regex
8888
assert_nil region.example_address
89+
assert_nil region.example_city
90+
assert_nil region.example_city_zip
8991
assert_empty region.parents
9092
assert_empty region.zones
93+
assert_nil region.tax_name
94+
assert_equal 0, (region.tax_rate * 100).floor
9195
end
9296

9397
test "#short_name returns values as expected" do
@@ -508,5 +512,17 @@ class RegionTest < ActiveSupport::TestCase
508512
test "#priority returns values as expected" do
509513
assert_equal 47, Worldwide.region(code: "JP").zone(code: "JP-01").priority
510514
end
515+
516+
test "#tax_type returns values as expected" do
517+
assert_equal "harmonized", Worldwide.region(code: "CA").zone(code: "ON").tax_type
518+
end
519+
520+
test "#tax_name returns values as expected" do
521+
assert_equal "HST", Worldwide.region(code: "CA").zone(code: "ON").tax_name
522+
end
523+
524+
test "#tax_rate returns values as expected" do
525+
assert_in_delta(0.13, Worldwide.region(code: "CA").zone(code: "ON").tax_rate)
526+
end
511527
end
512528
end

0 commit comments

Comments
 (0)
Please sign in to comment.