europe 0.0.22 → 0.0.24

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: 74ac3245cc45575b18122cc8373d545d3f303cf0d0e5664e8e629c6d99bd1411
4
- data.tar.gz: 81ac5481c954e26268c4c240f4b38b97221795061274a757a7ddf9fbae564fa9
3
+ metadata.gz: e64d994e1bcde40d5299ac2f99a1709a57e6fb44af2577ee88a22f12dbafaac8
4
+ data.tar.gz: 2035eec388fb5c6e975465c46e0cab5767e82064dbcfdffbfa46969ab1a7d2be
5
5
  SHA512:
6
- metadata.gz: 0fd626a93c2978c7a42f6525a9660225c4e964c68465d3f48c8652c7e7ef83c33b2442fa3c5176c279276569627a92cb48579863ee5ace1966efd92005554b74
7
- data.tar.gz: be952232e6468c93da55da187798316e6aab704cd4375dddced8719c6ee1af898f91ebafe87d5c9092cabf85ad101312248b777f54a44153126d86255ddf24e6
6
+ metadata.gz: 50ef66cb98eefbde1b30e0178a326b398f43b88cf56e6d187f58a26b755bb29ae37398a60b3cb3f541b0e5002059504453965208352f376fef008ba037c10b49
7
+ data.tar.gz: bf540b38bda311c563456826a56e835cf30f2aac6a2db9ef204bd124379c96fac4c811e209f0f190dc067155b4e4d48f1dd943e528442fc74a6a2cecb5f804af
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
+ ## 0.0.24
5
+ - Changed source for retrieving VAT rates. (https://europa.eu/youreurope/business/taxation/vat/vat-rules-rates/index_en.htm)
6
+ - Removed UK from VAT rate fallbacks
7
+ - Updated VAT rates for Slovakia (SK) and Finland (FI)
8
+ - [Full Changelog](https://github.com/gem-shards/europe.rb/compare/v0.0.23...v0.0.24)
9
+ ## 0.0.23
10
+ - Added support for new Belgium VAT numbers, thank you tim-vandecasteele
11
+ - [Full Changelog](https://github.com/gem-shards/europe.rb/compare/v0.0.22...v0.0.23)
4
12
  ## 0.0.22
5
13
  - Updated Estonia's tax rate to 22%
6
14
  - [Full Changelog](https://github.com/gem-shards/europe.rb/compare/v0.0.21...v0.0.22)
@@ -8,7 +8,7 @@ module Europe
8
8
  module Format
9
9
  VAT_REGEX = {
10
10
  AT: /^ATU\d{8}$/,
11
- BE: /^BE0\d{9}$/,
11
+ BE: /^BE[0-1]\d{9}$/,
12
12
  BG: /^BG(\d{10}|\d{9})$/,
13
13
  CY: /^CY\d{8}[A-Z]$/,
14
14
  CZ: /^CZ(\d{8}|\d{9}|\d{10})$/,
@@ -8,13 +8,12 @@ module Europe
8
8
  module Rates
9
9
  FALLBACK_RATES = {
10
10
  AT: 20.0, BE: 21.0, BG: 20.0, CY: 19.0, CZ: 21.0, DE: 19.0, DK: 25.0, EE: 22.0,
11
- EL: 24.0, ES: 21.0, FI: 24.0, FR: 20.0, UK: 20.0, HR: 25.0, HU: 27.0, IE: 23.0,
11
+ EL: 24.0, ES: 21.0, FI: 25.5, FR: 20.0, HR: 25.0, HU: 27.0, IE: 23.0,
12
12
  IT: 22.0, LT: 21.0, LU: 17.0, LV: 21.0, MT: 18.0, NL: 21.0, PL: 23.0, PT: 23.0,
13
- RO: 19.0, SE: 25.0, SI: 22.0, SK: 20.0
13
+ RO: 19.0, SE: 25.0, SI: 22.0, SK: 23.0
14
14
  }.freeze
15
- RATES_URL = 'https://ec.europa.eu/taxation_customs/' \
16
- 'business/vat/telecommunications-broadcasting' \
17
- '-electronic-services/vat-rates_en'
15
+ RATES_URL = 'https://europa.eu/youreurope/business/taxation/vat' \
16
+ '/vat-rules-rates/index_en.htm'
18
17
 
19
18
  def self.retrieve
20
19
  resp = fetch_rates
@@ -37,17 +36,18 @@ module Europe
37
36
  xml.first.elements.each('tr') do |result|
38
37
  next if result[3].nil?
39
38
 
40
- rates = filter_rate(result, rates)
39
+ rates = filter_rate(result, rates || {})
41
40
  end
42
41
  rates
43
42
  end
44
43
  # rubocop:enable Metrics/MethodLength
45
44
 
46
45
  def self.filter_rate(result, rates)
47
- country = result[0].text
48
- rate = result[3].text
49
- country_code = Europe::Countries::Reversed.generate(:name)[country]
50
- rates[country_code] = rate.to_f if country_code
46
+ return unless result[1].text.size == 2
47
+
48
+ country = result[1].text
49
+ rate = result[5].text
50
+ rates[country.to_sym] = rate.to_f if country && rate
51
51
  rates
52
52
  end
53
53
 
@@ -38,6 +38,8 @@ module Europe
38
38
  response = send_request(number[0..1], number[2..-1])
39
39
  return :failed unless response.is_a? Net::HTTPSuccess
40
40
  return :failed if response.body.include?('soap:Fault')
41
+ return :timeout if response.body.include?('TIMEOUT')
42
+ return :timeout if response.body.include?('MS_MAX_CONCURRENT_REQ')
41
43
 
42
44
  setup_response(response)
43
45
  rescue Net::OpenTimeout
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Europe version
4
4
  module Europe
5
- VERSION = '0.0.22'
5
+ VERSION = '0.0.24'
6
6
  end
@@ -15,7 +15,8 @@ module Europe
15
15
  def test_retrieval_of_vat_rates
16
16
  rates = Europe::Vat::Rates.retrieve
17
17
 
18
- assert_equal rates.count, Europe::Countries::COUNTRIES.count
18
+ # Remove UK from VAT rates
19
+ assert_equal rates.count, (Europe::Countries::COUNTRIES.keys - [:UK]).count
19
20
 
20
21
  assert rates[:NL]
21
22
  assert rates[:DE]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: europe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gem shards
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-20 00:00:00.000000000 Z
11
+ date: 2025-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  - !ruby/object:Gem::Version
200
200
  version: '0'
201
201
  requirements: []
202
- rubygems_version: 3.3.7
202
+ rubygems_version: 3.5.23
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Europe is a gem for retrieving and validating EU government data.