valvat 1.4.1 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/valvat/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +34 -82
- metadata.gz.sig +0 -0
- data/.editorconfig +0 -15
- data/.github/workflows/rubocop.yml +0 -17
- data/.github/workflows/specs.yml +0 -47
- data/.gitignore +0 -9
- data/.rubocop.yml +0 -24
- data/CHANGES.md +0 -419
- data/Gemfile +0 -14
- data/Guardfile +0 -7
- data/MIT-LICENSE +0 -20
- data/README.md +0 -350
- data/Rakefile +0 -10
- data/certs/mite.pem +0 -26
- data/gemfiles/activemodel-5 +0 -8
- data/gemfiles/activemodel-6 +0 -8
- data/gemfiles/activemodel-7 +0 -8
- data/gemfiles/standalone +0 -7
- data/spec/active_model/validations/valvat_validator_spec.rb +0 -274
- data/spec/spec_helper.rb +0 -37
- data/spec/valvat/checksum/at_spec.rb +0 -17
- data/spec/valvat/checksum/be_spec.rb +0 -17
- data/spec/valvat/checksum/bg_spec.rb +0 -18
- data/spec/valvat/checksum/cy_spec.rb +0 -17
- data/spec/valvat/checksum/de_spec.rb +0 -17
- data/spec/valvat/checksum/dk_spec.rb +0 -17
- data/spec/valvat/checksum/ee_spec.rb +0 -17
- data/spec/valvat/checksum/es_spec.rb +0 -65
- data/spec/valvat/checksum/fi_spec.rb +0 -17
- data/spec/valvat/checksum/fr_spec.rb +0 -17
- data/spec/valvat/checksum/gb_spec.rb +0 -34
- data/spec/valvat/checksum/gr_spec.rb +0 -17
- data/spec/valvat/checksum/hr_spec.rb +0 -17
- data/spec/valvat/checksum/hu_spec.rb +0 -17
- data/spec/valvat/checksum/ie_spec.rb +0 -24
- data/spec/valvat/checksum/it_spec.rb +0 -25
- data/spec/valvat/checksum/lt_spec.rb +0 -17
- data/spec/valvat/checksum/lu_spec.rb +0 -17
- data/spec/valvat/checksum/mt_spec.rb +0 -17
- data/spec/valvat/checksum/nl_spec.rb +0 -17
- data/spec/valvat/checksum/pl_spec.rb +0 -21
- data/spec/valvat/checksum/pt_spec.rb +0 -30
- data/spec/valvat/checksum/ro_spec.rb +0 -17
- data/spec/valvat/checksum/se_spec.rb +0 -21
- data/spec/valvat/checksum/si_spec.rb +0 -25
- data/spec/valvat/checksum_spec.rb +0 -40
- data/spec/valvat/lookup/hmrc_spec.rb +0 -58
- data/spec/valvat/lookup/vies_spec.rb +0 -25
- data/spec/valvat/lookup_spec.rb +0 -493
- data/spec/valvat/options_spec.rb +0 -23
- data/spec/valvat/syntax_spec.rb +0 -68
- data/spec/valvat/utils_spec.rb +0 -125
- data/spec/valvat_spec.rb +0 -276
- data/valvat.gemspec +0 -24
data/spec/spec_helper.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rspec'
|
4
|
-
begin
|
5
|
-
require 'active_model'
|
6
|
-
rescue LoadError
|
7
|
-
puts 'Running specs without active_model extension'
|
8
|
-
end
|
9
|
-
|
10
|
-
require "#{File.dirname(__FILE__)}/../lib/valvat.rb"
|
11
|
-
require 'webmock/rspec'
|
12
|
-
WebMock.allow_net_connect!
|
13
|
-
|
14
|
-
RSpec.configure do |config|
|
15
|
-
config.mock_with :rspec
|
16
|
-
config.filter_run focus: true
|
17
|
-
config.run_all_when_everything_filtered = true
|
18
|
-
end
|
19
|
-
|
20
|
-
I18n.enforce_available_locales = false if defined?(I18n)
|
21
|
-
|
22
|
-
if defined?(ActiveModel)
|
23
|
-
class ModelBase
|
24
|
-
include ActiveModel::Serialization
|
25
|
-
include ActiveModel::Validations
|
26
|
-
|
27
|
-
attr_accessor :attributes
|
28
|
-
|
29
|
-
def initialize(attributes = {})
|
30
|
-
@attributes = attributes
|
31
|
-
end
|
32
|
-
|
33
|
-
def read_attribute_for_validation(key)
|
34
|
-
@attributes[key]
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Valvat::Checksum::AT do
|
6
|
-
%w[ATU13585627 ATU66059506 ATU42403001].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
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Valvat::Checksum::BE do
|
6
|
-
%w[BE0123456749 BE0136695962 BE0817331995].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,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Valvat::Checksum::BG do
|
6
|
-
%w[BG123456786 BG926067143 BG926067770 BG0101011739 BG0121013021 BG5041019992 BG1521687837
|
7
|
-
BG1431889037].each do |valid_vat|
|
8
|
-
it "returns true on valid VAT #{valid_vat}" do
|
9
|
-
expect(Valvat::Checksum.validate(valid_vat)).to be(true)
|
10
|
-
end
|
11
|
-
|
12
|
-
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-4]}"
|
13
|
-
|
14
|
-
it "returns false on invalid VAT #{invalid_vat}" do
|
15
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Valvat::Checksum::CY do
|
6
|
-
%w[CY01234567U CY00532445O].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::DE do
|
6
|
-
%w[DE280857971 DE281381706 DE283108332 DE813622378 DE813628528 DE814178359 DE811907980].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::DK do
|
6
|
-
%w[DK13585628 DK61126228].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::EE do
|
6
|
-
%w[EE101234568 EE100207415].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,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Valvat::Checksum::ES do
|
6
|
-
%w[ESA13585625 ESB83871236 ESE54507058 ES25139013J ESQ1518001A ESQ5018001G ESX4942978W ESX7676464F ESB10317980
|
7
|
-
ESY3860557K ESY2207765D ES28350472M ES41961720Z ESM1171170X ESK0928769Y ES50095545G].each do |valid_vat|
|
8
|
-
it "returns true on valid VAT #{valid_vat}" do
|
9
|
-
expect(Valvat::Checksum.validate(valid_vat)).to be(true)
|
10
|
-
end
|
11
|
-
|
12
|
-
invalid_vat = "#{valid_vat[0..-6]}#{valid_vat[-2]}#{valid_vat[-5]}#{valid_vat[-4]}#{valid_vat[-3]}#{valid_vat[-1]}"
|
13
|
-
|
14
|
-
it "returns false on invalid VAT #{invalid_vat}" do
|
15
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe 'if starts with [KLMXYZ\\d], is always a natural person' do
|
20
|
-
invalid_vat = 'ESX65474207'
|
21
|
-
it "returns false on invalid VAT #{invalid_vat}" do
|
22
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe 'some CIF categories (NPQRSW) require control-digit to be a letter' do
|
27
|
-
invalid_vat = 'ESP65474207'
|
28
|
-
valid_vat = 'ESP6547420G'
|
29
|
-
|
30
|
-
it "returns false on invalid VAT #{invalid_vat}" do
|
31
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "returns true on valid VAT #{valid_vat}" do
|
35
|
-
expect(Valvat::Checksum.validate(valid_vat)).to be(true)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'some CIF categories (CDFGJNUV) allow both a numeric check digit and a letter' do
|
40
|
-
%w[ESC65474207 ESC6547420G].each do |valid_vat|
|
41
|
-
it "returns true on valid VAT #{valid_vat}" do
|
42
|
-
expect(Valvat::Checksum.validate(valid_vat)).to be(true)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'applies special rules to validation' do
|
48
|
-
describe 'special NIF categories (KLM) require CD to be a letter and first two digits ' \
|
49
|
-
'to be between 01 and 56 (inclusive)' do
|
50
|
-
%w[ESK8201230M ESK0001230B].each do |invalid_vat|
|
51
|
-
it "returns false on invalid VAT #{invalid_vat}" do
|
52
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe 'arbitrarily invalid VATs' do
|
58
|
-
%w[ESX0000000T ES00000001R ES00000000T ES99999999R].each do |invalid_vat|
|
59
|
-
it "returns false on invalid VAT #{invalid_vat}" do
|
60
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Valvat::Checksum::FI do
|
6
|
-
%w[FI13669598 FI20584306 FI01080233].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
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Valvat::Checksum::FR do
|
6
|
-
%w[FR60528551658 FR43820567501 FR0H384498879].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,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Valvat::Checksum::GB do
|
6
|
-
%w[GBGD100 GBHA600].each do |gov_agency_vat|
|
7
|
-
it "returns true on valid VAT for government agency #{gov_agency_vat}" do
|
8
|
-
expect(Valvat::Checksum.validate(gov_agency_vat)).to be true
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
%w[GB000000000 GB000000000000].each do |invalid_vat|
|
13
|
-
it 'is false for all zero number' do
|
14
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to be false
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'is true for an old format valid vat' do
|
19
|
-
expect(Valvat::Checksum.validate('GB434031494')).to be true
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'is true for a new format valid vat' do
|
23
|
-
expect(Valvat::Checksum.validate('GB434031439')).to be true
|
24
|
-
expect(Valvat::Checksum.validate('GB727255821')).to be true
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'is false for an old format VAT in forbidden group' do
|
28
|
-
expect(Valvat::Checksum.validate('GB999999973')).to be false
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'is false for a new format VAT in forbidden group' do
|
32
|
-
expect(Valvat::Checksum.validate('GB100000034')).to be false
|
33
|
-
end
|
34
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Valvat::Checksum::GR do
|
6
|
-
%w[EL123456783 EL094543092 EL998219694].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::HR do
|
6
|
-
%w[HR06282943396 HR17099025134].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::HU do
|
6
|
-
%w[HU10672101 HU13460370 HU10747759].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,24 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Valvat::Checksum::IE do
|
6
|
-
%w[IE8473625E IE0123459N IE9B12345N IE1113571MH IE2973912UH IE2974611LH
|
7
|
-
IE2974901UH IE3200115LH IE3206791MH IE3208913KH IE3214048CH].each do |valid_vat|
|
8
|
-
it "returns true on valid VAT #{valid_vat}" do
|
9
|
-
expect(Valvat::Checksum.validate(valid_vat)).to eql(true), valid_vat
|
10
|
-
end
|
11
|
-
|
12
|
-
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-2]}#{valid_vat[-3]}#{valid_vat[-1]}"
|
13
|
-
|
14
|
-
it "returns false on invalid VAT #{invalid_vat}" do
|
15
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
%w[IE0000000XX IE0000000AZ].each do |invalid|
|
20
|
-
it "returns false on invalid VAT #{invalid}" do
|
21
|
-
expect(Valvat::Checksum.validate(invalid)).to be(false)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Valvat::Checksum::IT do
|
6
|
-
%w[IT12345670785 IT01897810162 IT00197200132 IT02762750210 IT00146089990].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
|
-
|
18
|
-
it 'returns false on invalid special case VAT IT12345671783' do
|
19
|
-
expect(Valvat::Checksum.validate('IT12345671783')).to be(false)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns false on invalid special case VAT IT00000000133' do
|
23
|
-
expect(Valvat::Checksum.validate('IT00000000133')).to be(false)
|
24
|
-
end
|
25
|
-
end
|
@@ -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
|