valvat 1.4.0 → 1.4.2

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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +2 -1
  3. data/lib/valvat/lookup/vies.rb +2 -2
  4. data/lib/valvat/version.rb +1 -1
  5. data.tar.gz.sig +0 -0
  6. metadata +35 -103
  7. metadata.gz.sig +0 -0
  8. data/.editorconfig +0 -15
  9. data/.github/workflows/rubocop.yml +0 -17
  10. data/.github/workflows/specs.yml +0 -45
  11. data/.gitignore +0 -9
  12. data/.rubocop.yml +0 -24
  13. data/CHANGES.md +0 -413
  14. data/Gemfile +0 -14
  15. data/Guardfile +0 -7
  16. data/MIT-LICENSE +0 -20
  17. data/README.md +0 -350
  18. data/Rakefile +0 -10
  19. data/certs/mite.pem +0 -26
  20. data/gemfiles/activemodel-5 +0 -8
  21. data/gemfiles/activemodel-6 +0 -8
  22. data/gemfiles/activemodel-7 +0 -8
  23. data/gemfiles/standalone +0 -7
  24. data/lib/valvat/locales/bg.yml +0 -34
  25. data/lib/valvat/locales/ca.yml +0 -34
  26. data/lib/valvat/locales/cs.yml +0 -34
  27. data/lib/valvat/locales/da.yml +0 -34
  28. data/lib/valvat/locales/de.yml +0 -35
  29. data/lib/valvat/locales/en.yml +0 -35
  30. data/lib/valvat/locales/es.yml +0 -35
  31. data/lib/valvat/locales/fi.yml +0 -34
  32. data/lib/valvat/locales/fr.yml +0 -34
  33. data/lib/valvat/locales/hu.yml +0 -35
  34. data/lib/valvat/locales/it.yml +0 -34
  35. data/lib/valvat/locales/lv.yml +0 -34
  36. data/lib/valvat/locales/nb.yml +0 -34
  37. data/lib/valvat/locales/nl.yml +0 -35
  38. data/lib/valvat/locales/pl.yml +0 -35
  39. data/lib/valvat/locales/pt.yml +0 -34
  40. data/lib/valvat/locales/ro.yml +0 -34
  41. data/lib/valvat/locales/sk.yml +0 -34
  42. data/lib/valvat/locales/sv.yml +0 -34
  43. data/lib/valvat/locales/tr.yml +0 -34
  44. data/spec/active_model/validations/valvat_validator_spec.rb +0 -274
  45. data/spec/spec_helper.rb +0 -37
  46. data/spec/valvat/checksum/at_spec.rb +0 -17
  47. data/spec/valvat/checksum/be_spec.rb +0 -17
  48. data/spec/valvat/checksum/bg_spec.rb +0 -18
  49. data/spec/valvat/checksum/cy_spec.rb +0 -17
  50. data/spec/valvat/checksum/de_spec.rb +0 -17
  51. data/spec/valvat/checksum/dk_spec.rb +0 -17
  52. data/spec/valvat/checksum/ee_spec.rb +0 -17
  53. data/spec/valvat/checksum/es_spec.rb +0 -65
  54. data/spec/valvat/checksum/fi_spec.rb +0 -17
  55. data/spec/valvat/checksum/fr_spec.rb +0 -17
  56. data/spec/valvat/checksum/gb_spec.rb +0 -34
  57. data/spec/valvat/checksum/gr_spec.rb +0 -17
  58. data/spec/valvat/checksum/hr_spec.rb +0 -17
  59. data/spec/valvat/checksum/hu_spec.rb +0 -17
  60. data/spec/valvat/checksum/ie_spec.rb +0 -24
  61. data/spec/valvat/checksum/it_spec.rb +0 -25
  62. data/spec/valvat/checksum/lt_spec.rb +0 -17
  63. data/spec/valvat/checksum/lu_spec.rb +0 -17
  64. data/spec/valvat/checksum/mt_spec.rb +0 -17
  65. data/spec/valvat/checksum/nl_spec.rb +0 -17
  66. data/spec/valvat/checksum/pl_spec.rb +0 -21
  67. data/spec/valvat/checksum/pt_spec.rb +0 -30
  68. data/spec/valvat/checksum/ro_spec.rb +0 -17
  69. data/spec/valvat/checksum/se_spec.rb +0 -21
  70. data/spec/valvat/checksum/si_spec.rb +0 -25
  71. data/spec/valvat/checksum_spec.rb +0 -40
  72. data/spec/valvat/lookup/hmrc_spec.rb +0 -58
  73. data/spec/valvat/lookup/vies_spec.rb +0 -25
  74. data/spec/valvat/lookup_spec.rb +0 -493
  75. data/spec/valvat/options_spec.rb +0 -23
  76. data/spec/valvat/syntax_spec.rb +0 -68
  77. data/spec/valvat/utils_spec.rb +0 -125
  78. data/spec/valvat_spec.rb +0 -276
  79. data/valvat.gemspec +0 -24
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Checksum::LT do
6
- %w[LT213179412 LT290061371314].each do |valid_vat|
7
- it "returns true on valid VAT #{valid_vat}" do
8
- expect(Valvat::Checksum.validate(valid_vat)).to be true
9
- end
10
-
11
- invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
12
-
13
- it "returns false on invalid VAT #{invalid_vat}" do
14
- expect(Valvat::Checksum.validate(invalid_vat)).to be false
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Checksum::LU do
6
- %w[LU13669580 LU25361352 LU23124018 LU17560609].each do |valid_vat|
7
- it "returns true on valid VAT #{valid_vat}" do
8
- expect(Valvat::Checksum.validate(valid_vat)).to be(true)
9
- end
10
-
11
- invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-2]}#{valid_vat[-3]}#{valid_vat[-1]}"
12
-
13
- it "returns false on invalid VAT #{invalid_vat}" do
14
- expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Checksum::MT do
6
- %w[MT11407334 MT10126313 MT11539237].each do |valid_vat|
7
- it "returns true on valid VAT #{valid_vat}" do
8
- expect(Valvat::Checksum.validate(valid_vat)).to be true
9
- end
10
-
11
- invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
12
-
13
- it "returns false on invalid VAT #{invalid_vat}" do
14
- expect(Valvat::Checksum.validate(invalid_vat)).to be false
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Checksum::NL do
6
- %w[NL123456782B12 NL802549391B01 NL808661863B01 NL820893559B01 NL000099998B57 NL123456789B13].each do |valid|
7
- it "returns true on valid VAT #{valid}" do
8
- expect(Valvat::Checksum.validate(valid)).to be(true)
9
- end
10
-
11
- invalid = "#{valid[0..-5]}#{valid[-2]}#{valid[-3]}#{valid[-4]}#{valid[-1]}#{valid[-2]}#{valid[-3]}"
12
-
13
- it "returns false on invalid VAT #{invalid}" do
14
- expect(Valvat::Checksum.validate(invalid)).to be(false)
15
- end
16
- end
17
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Checksum::PL do
6
- %w[PL8567346215 PL5260211587 PL9720575348 PL5272650022].each do |valid_vat|
7
- it "returns true on valid VAT #{valid_vat}" do
8
- expect(Valvat::Checksum.validate(valid_vat)).to be(true)
9
- end
10
-
11
- invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-3]}"
12
-
13
- it "returns false on invalid VAT #{invalid_vat}" do
14
- expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
15
- end
16
- end
17
-
18
- it 'returns false on special case invalid VAT PL8566445330' do
19
- expect(Valvat::Checksum.validate('PL8566445330')).to be(false)
20
- end
21
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Checksum::PT do
6
- %w[PT136695973 PT501413197 PT503037753 PT500243590 PT500100144 PT502921838].each do |valid_vat|
7
- it "returns true on valid VAT #{valid_vat}" do
8
- expect(Valvat::Checksum.validate(valid_vat)).to be(true)
9
- end
10
-
11
- invalid_vat = "#{valid_vat[0..-5]}#{valid_vat[-1]}#{valid_vat[-4]}#{valid_vat[-2]}#{valid_vat[-3]}"
12
-
13
- it "returns false on invalid VAT #{invalid_vat}" do
14
- expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
15
- end
16
- end
17
-
18
- # Portuguese business VAT should start with the following numbers
19
- # 1 or 2 (pessoa singular) - singular person
20
- # 5 (pessoa colectiva) - collective person
21
- # 6 (pessoa colectiva publica) - public collective person
22
- # 8 (empresario em nome individual) - individual enterpreneur
23
- # 9 (pessoa colectiva irregular ou numero provisorio) - provisional number
24
- # http://www.nif.pt/nif-das-empresas/
25
- %w[PT148166644 PT111623448 PT204874866 PT292261314 PT579104222 PT628910002 PT812627318 PT943935784].each do |number|
26
- it "returns true on a valid number - #{number}" do
27
- expect(Valvat::Checksum.validate(number)).to be(true)
28
- end
29
- end
30
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Checksum::RO do
6
- %w[RO123456789 RO99908 RO19 RO124 RO13182060].each do |valid_vat|
7
- it "returns true on valid VAT #{valid_vat}" do
8
- expect(Valvat::Checksum.validate(valid_vat)).to be true
9
- end
10
-
11
- invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
12
-
13
- it "returns false on invalid VAT #{invalid_vat}" do
14
- expect(Valvat::Checksum.validate(invalid_vat)).to be false
15
- end
16
- end
17
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Checksum::SE do
6
- %w[SE136695975501 SE556464687401 SE502052817901 SE556555952201 SE556084097601].each do |valid_vat|
7
- it "returns true on valid VAT #{valid_vat}" do
8
- expect(Valvat::Checksum.validate(valid_vat)).to be(true)
9
- end
10
-
11
- invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-3]}"
12
-
13
- it "returns false on invalid VAT #{invalid_vat}" do
14
- expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
15
- end
16
- end
17
-
18
- it 'returns false on special case invalid VAT SE556464687400' do
19
- expect(Valvat::Checksum.validate('SE556464687400')).to be(false)
20
- end
21
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Checksum::SI do
6
- %w[SI59082437 SI51049406 SI86154575 SI47431857 SI22511822 SI26833921].each do |valid_vat|
7
- it "returns true on valid VAT #{valid_vat}" do
8
- expect(Valvat::Checksum.validate(valid_vat)).to be(true)
9
- end
10
-
11
- invalid_vat = "#{valid_vat[0..-2]}#{valid_vat[-1].to_i + 1}"
12
-
13
- it "returns false on invalid VAT #{invalid_vat}" do
14
- expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
15
- end
16
- end
17
-
18
- it 'returns false on special case invalid VAT SI11111107' do
19
- expect(Valvat::Checksum.validate('SI11111107')).to be(false)
20
- end
21
-
22
- it 'returns false on special case invalid VAT SI01111108' do
23
- expect(Valvat::Checksum.validate('SI01111108')).to be(false)
24
- end
25
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- begin
6
- require "#{File.dirname(__FILE__)}/../../tmp/valid_vat_numbers.rb"
7
- rescue LoadError
8
- VALID_VAT_NUMBERS = [].freeze
9
- end
10
-
11
- # Syntax is correct, but checksum invalid
12
- INVALID_VAT_NUMBERS = %w[
13
- DE002768611 DE161216774 DE192970834 DE223361232 DE226095231
14
- DE227411313 DE230928917 DE232123248 DE267748405 DE275615509
15
- DE311927825 DE329214395 DE815842425 DE821530465 DE999999999
16
- ].freeze
17
-
18
- describe Valvat::Checksum do
19
- describe '#validate' do
20
- it 'returns true on VAT number with unknown checksum algorithm' do
21
- expect(described_class.validate('CZ699001237')).to be(true)
22
- end
23
-
24
- it 'returns false on corrupt number (e.g checks syntax)' do
25
- expect(described_class.validate('FI1234567891')).to be(false)
26
- end
27
-
28
- VALID_VAT_NUMBERS.each do |valid_vat|
29
- it "returns true on valid VAT number #{valid_vat}" do
30
- expect(described_class.validate(valid_vat)).to be(true)
31
- end
32
- end
33
-
34
- INVALID_VAT_NUMBERS.each do |invalid_vat|
35
- it "returns false on invalid VAT number #{invalid_vat}" do
36
- expect(described_class.validate(invalid_vat)).to be(false)
37
- end
38
- end
39
- end
40
- end
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Lookup::HMRC do
6
- before do
7
- stub_const('Valvat::Lookup::HMRC::ENDPOINT_URL', 'https://test-api.service.hmrc.gov.uk/organisations/vat/check-vat-number/lookup')
8
- end
9
-
10
- after do
11
- Valvat.configure(uk: false)
12
- end
13
-
14
- it 'returns hash with valid: true on success' do
15
- response = described_class.new('GB553557881', { uk: true }).perform
16
-
17
- expect(response).to match({
18
- valid: true,
19
- address: "131B Barton Hamlet\nSW97 5CK\nGB",
20
- country_code: 'GB',
21
- vat_number: '553557881',
22
- name: 'Credite Sberger Donal Inc.',
23
- request_date: kind_of(Time)
24
- })
25
- end
26
-
27
- it 'returns hash with valid: false on invalid input' do
28
- response = described_class.new('GB123456789', { uk: true }).perform
29
- expect(response).to match({ valid: false })
30
- end
31
-
32
- it 'returns hash with valid: false on valid input with :uk option not set' do
33
- response = described_class.new('GB553557881', {}).perform
34
- expect(response).to match({ valid: false })
35
- end
36
-
37
- it 'returns valid: false when uk option is set to false' do
38
- response = described_class.new('GB553557881', { uk: false }).perform
39
- expect(response).to match({ valid: false })
40
- end
41
-
42
- it 'returns valid: false when uk option is not set' do
43
- response = described_class.new('GB553557881').perform
44
- expect(response).to match({ valid: false })
45
- end
46
-
47
- it 'respects global :uk setting' do
48
- Valvat.configure(uk: true)
49
- response = described_class.new('GB553557881').perform
50
- expect(response).to include({ valid: true })
51
- end
52
-
53
- it 'overwrite global :uk setting' do
54
- Valvat.configure(uk: true)
55
- response = described_class.new('GB553557881', uk: false).perform
56
- expect(response).to include({ valid: false })
57
- end
58
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Valvat::Lookup::VIES do
6
- it 'returns hash with valid: true on success' do
7
- response = described_class.new('IE6388047V', {}).perform
8
-
9
- skip 'VIES is down' if response[:error].is_a?(Valvat::MemberStateUnavailable)
10
-
11
- expect(response).to match({
12
- valid: true,
13
- address: '3RD FLOOR, GORDON HOUSE, BARROW STREET, DUBLIN 4',
14
- country_code: 'IE',
15
- vat_number: '6388047V',
16
- name: 'GOOGLE IRELAND LIMITED',
17
- request_date: kind_of(Date)
18
- })
19
- end
20
-
21
- it 'returns hash with valid: false on invalid input' do
22
- response = described_class.new('XC123123', {}).perform
23
- expect(response.to_hash).to match({ valid: false, faultstring: 'INVALID_INPUT', faultcode: 'env:Server' })
24
- end
25
- end