valvat 0.9.1 → 1.1.0
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.tar.gz.sig +0 -0
- data/.github/workflows/ruby.yml +35 -0
- data/.gitignore +3 -1
- data/.rubocop.yml +15 -0
- data/CHANGES.md +30 -1
- data/Gemfile +4 -3
- data/Guardfile +6 -4
- data/README.md +99 -47
- data/Rakefile +3 -1
- data/certs/yolk.pem +21 -21
- data/gemfiles/activemodel-5 +4 -5
- data/gemfiles/activemodel-6 +7 -0
- data/gemfiles/standalone +3 -5
- data/lib/active_model/validations/valvat_validator.rb +70 -22
- data/lib/valvat.rb +7 -3
- data/lib/valvat/checksum.rb +14 -13
- data/lib/valvat/checksum/at.rb +3 -1
- data/lib/valvat/checksum/be.rb +3 -1
- data/lib/valvat/checksum/bg.rb +17 -17
- data/lib/valvat/checksum/cy.rb +2 -0
- data/lib/valvat/checksum/de.rb +5 -3
- data/lib/valvat/checksum/dk.rb +3 -1
- data/lib/valvat/checksum/ee.rb +2 -0
- data/lib/valvat/checksum/es.rb +14 -16
- data/lib/valvat/checksum/fi.rb +3 -1
- data/lib/valvat/checksum/fr.rb +4 -2
- data/lib/valvat/checksum/gb.rb +53 -21
- data/lib/valvat/checksum/gr.rb +4 -2
- data/lib/valvat/checksum/hr.rb +2 -0
- data/lib/valvat/checksum/hu.rb +2 -0
- data/lib/valvat/checksum/ie.rb +5 -6
- data/lib/valvat/checksum/it.rb +6 -4
- data/lib/valvat/checksum/lt.rb +2 -0
- data/lib/valvat/checksum/lu.rb +3 -1
- data/lib/valvat/checksum/mt.rb +2 -0
- data/lib/valvat/checksum/nl.rb +5 -3
- data/lib/valvat/checksum/pl.rb +3 -1
- data/lib/valvat/checksum/pt.rb +3 -1
- data/lib/valvat/checksum/ro.rb +2 -0
- data/lib/valvat/checksum/se.rb +5 -3
- data/lib/valvat/checksum/si.rb +4 -2
- data/lib/valvat/error.rb +31 -0
- data/lib/valvat/local.rb +8 -5
- data/lib/valvat/locales/de.yml +2 -1
- data/lib/valvat/locales/en.yml +2 -1
- data/lib/valvat/locales/es.yml +1 -0
- data/lib/valvat/locales/fr.yml +1 -0
- data/lib/valvat/locales/hu.yml +1 -0
- data/lib/valvat/locales/nl.yml +1 -0
- data/lib/valvat/locales/pl.yml +1 -0
- data/lib/valvat/locales/pt.yml +28 -28
- data/lib/valvat/lookup.rb +14 -45
- data/lib/valvat/lookup/fault.rb +31 -0
- data/lib/valvat/lookup/request.rb +37 -11
- data/lib/valvat/lookup/response.rb +37 -0
- data/lib/valvat/syntax.rb +31 -30
- data/lib/valvat/utils.rb +20 -9
- data/lib/valvat/version.rb +3 -1
- data/spec/active_model/validations/valvat_validator_spec.rb +132 -100
- data/spec/spec_helper.rb +8 -8
- data/spec/valvat/checksum/at_spec.rb +8 -6
- data/spec/valvat/checksum/be_spec.rb +8 -6
- data/spec/valvat/checksum/bg_spec.rb +9 -6
- data/spec/valvat/checksum/cy_spec.rb +5 -3
- data/spec/valvat/checksum/de_spec.rb +8 -6
- data/spec/valvat/checksum/dk_spec.rb +8 -6
- data/spec/valvat/checksum/ee_spec.rb +5 -3
- data/spec/valvat/checksum/es_spec.rb +9 -6
- data/spec/valvat/checksum/fi_spec.rb +8 -6
- data/spec/valvat/checksum/fr_spec.rb +8 -6
- data/spec/valvat/checksum/gb_spec.rb +9 -5
- data/spec/valvat/checksum/gr_spec.rb +8 -6
- data/spec/valvat/checksum/hr_spec.rb +5 -3
- data/spec/valvat/checksum/hu_spec.rb +5 -3
- data/spec/valvat/checksum/ie_spec.rb +13 -5
- data/spec/valvat/checksum/it_spec.rb +12 -10
- data/spec/valvat/checksum/lt_spec.rb +5 -3
- data/spec/valvat/checksum/lu_spec.rb +8 -6
- data/spec/valvat/checksum/mt_spec.rb +5 -3
- data/spec/valvat/checksum/nl_spec.rb +9 -7
- data/spec/valvat/checksum/pl_spec.rb +10 -8
- data/spec/valvat/checksum/pt_spec.rb +12 -13
- data/spec/valvat/checksum/ro_spec.rb +5 -3
- data/spec/valvat/checksum/se_spec.rb +10 -8
- data/spec/valvat/checksum/si_spec.rb +12 -10
- data/spec/valvat/checksum_spec.rb +12 -10
- data/spec/valvat/lookup/fault_spec.rb +34 -0
- data/spec/valvat/lookup/request_spec.rb +19 -0
- data/spec/valvat/lookup/response_spec.rb +29 -0
- data/spec/valvat/lookup_spec.rb +202 -84
- data/spec/valvat/syntax_spec.rb +59 -280
- data/spec/valvat/utils_spec.rb +76 -43
- data/spec/valvat_spec.rb +140 -152
- data/valvat.gemspec +18 -17
- metadata +61 -41
- metadata.gz.sig +3 -3
- data/.travis.yml +0 -33
- data/gemfiles/activemodel-3-2 +0 -8
- data/gemfiles/activemodel-4 +0 -8
- data/gemfiles/before-ruby21/activemodel-3-2 +0 -9
- data/gemfiles/before-ruby21/activemodel-4 +0 -9
- data/gemfiles/before-ruby21/standalone +0 -8
- data/lib/valvat/lookup/request_with_id.rb +0 -31
data/spec/spec_helper.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rspec'
|
2
4
|
begin
|
3
5
|
require 'active_model'
|
4
|
-
rescue LoadError
|
5
|
-
puts
|
6
|
+
rescue LoadError
|
7
|
+
puts 'Running specs without active_model extension'
|
6
8
|
end
|
7
9
|
|
8
|
-
require File.dirname(__FILE__)
|
10
|
+
require "#{File.dirname(__FILE__)}/../lib/valvat.rb"
|
9
11
|
|
10
12
|
RSpec.configure do |config|
|
11
13
|
config.mock_with :rspec
|
12
|
-
config.filter_run :
|
14
|
+
config.filter_run focus: true
|
13
15
|
config.run_all_when_everything_filtered = true
|
14
|
-
config.backtrace_exclusion_patterns = [/
|
16
|
+
config.backtrace_exclusion_patterns = [%r{rspec/(core|expectations)}]
|
15
17
|
end
|
16
18
|
|
17
|
-
if defined?(I18n)
|
18
|
-
I18n.enforce_available_locales = false
|
19
|
-
end
|
19
|
+
I18n.enforce_available_locales = false if defined?(I18n)
|
20
20
|
|
21
21
|
if defined?(ActiveModel)
|
22
22
|
class ModelBase
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::AT do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
-
expect(Valvat::Checksum.validate(valid_vat)).to
|
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)
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-3]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
12
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
14
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::BE do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
-
expect(Valvat::Checksum.validate(valid_vat)).to
|
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)
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
12
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
14
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
@@ -1,15 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::BG do
|
4
|
-
%w
|
5
|
-
|
6
|
-
|
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)
|
7
10
|
end
|
8
11
|
|
9
12
|
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-4]}"
|
10
13
|
|
11
|
-
it "returns false on invalid
|
12
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to
|
14
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
15
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
13
16
|
end
|
14
17
|
end
|
15
|
-
end
|
18
|
+
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::CY do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
+
%w[CY01234567U CY00532445O].each do |valid_vat|
|
7
|
+
it "returns true on valid VAT #{valid_vat}" do
|
6
8
|
expect(Valvat::Checksum.validate(valid_vat)).to be true
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-2]}#{valid_vat[-3]}#{valid_vat[-1]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
12
14
|
expect(Valvat::Checksum.validate(invalid_vat)).to be false
|
13
15
|
end
|
14
16
|
end
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::DE do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
-
expect(Valvat::Checksum.validate(valid_vat)).to
|
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)
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
12
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
14
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::DK do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
-
expect(Valvat::Checksum.validate(valid_vat)).to
|
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)
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
12
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
14
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::EE do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
+
%w[EE101234568 EE100207415].each do |valid_vat|
|
7
|
+
it "returns true on valid VAT #{valid_vat}" do
|
6
8
|
expect(Valvat::Checksum.validate(valid_vat)).to be true
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
12
14
|
expect(Valvat::Checksum.validate(invalid_vat)).to be false
|
13
15
|
end
|
14
16
|
end
|
@@ -1,15 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::ES do
|
4
|
-
%w
|
5
|
-
|
6
|
-
|
6
|
+
%w[ESA13585625 ESB83871236 ESE54507058 ES25139013J ESQ1518001A ESQ5018001G ESX4942978W ESX7676464F ESB10317980
|
7
|
+
ESY3860557K ESY2207765D].each do |valid_vat|
|
8
|
+
it "returns true on valid VAT #{valid_vat}" do
|
9
|
+
expect(Valvat::Checksum.validate(valid_vat)).to be(true)
|
7
10
|
end
|
8
11
|
|
9
12
|
invalid_vat = "#{valid_vat[0..-6]}#{valid_vat[-2]}#{valid_vat[-5]}#{valid_vat[-4]}#{valid_vat[-3]}#{valid_vat[-1]}"
|
10
13
|
|
11
|
-
it "returns false on invalid
|
12
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to
|
14
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
15
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
13
16
|
end
|
14
17
|
end
|
15
|
-
end
|
18
|
+
end
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::FI do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
-
expect(Valvat::Checksum.validate(valid_vat)).to
|
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)
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-1]}#{valid_vat[-2]}#{valid_vat[-3]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
12
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
14
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::FR do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
-
expect(Valvat::Checksum.validate(valid_vat)).to
|
6
|
+
%w[FR60528551658 FR43820567501].each do |valid_vat|
|
7
|
+
it "returns true on valid VAT #{valid_vat}" do
|
8
|
+
expect(Valvat::Checksum.validate(valid_vat)).to be(true)
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
12
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
14
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
@@ -1,11 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
1
5
|
describe Valvat::Checksum::GB do
|
2
|
-
%w
|
3
|
-
it "returns true on valid
|
6
|
+
%w[GBGD100 GBHA600].each do |gov_agency_vat|
|
7
|
+
it "returns true on valid VAT for government agency #{gov_agency_vat}" do
|
4
8
|
expect(Valvat::Checksum.validate(gov_agency_vat)).to be true
|
5
9
|
end
|
6
10
|
end
|
7
11
|
|
8
|
-
%w
|
12
|
+
%w[GB000000000 GB000000000000].each do |invalid_vat|
|
9
13
|
it 'is false for all zero number' do
|
10
14
|
expect(Valvat::Checksum.validate(invalid_vat)).to be false
|
11
15
|
end
|
@@ -19,11 +23,11 @@ describe Valvat::Checksum::GB do
|
|
19
23
|
expect(Valvat::Checksum.validate('GB434031439')).to be true
|
20
24
|
end
|
21
25
|
|
22
|
-
it 'is false for an old format
|
26
|
+
it 'is false for an old format VAT in forbidden group' do
|
23
27
|
expect(Valvat::Checksum.validate('GB999999973')).to be false
|
24
28
|
end
|
25
29
|
|
26
|
-
it 'is false for a new format
|
30
|
+
it 'is false for a new format VAT in forbidden group' do
|
27
31
|
expect(Valvat::Checksum.validate('GB100000034')).to be false
|
28
32
|
end
|
29
33
|
end
|
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::GR do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
-
expect(Valvat::Checksum.validate(valid_vat)).to
|
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)
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
12
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
14
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
13
15
|
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::HR do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
+
%w[HR06282943396 HR17099025134].each do |valid_vat|
|
7
|
+
it "returns true on valid VAT #{valid_vat}" do
|
6
8
|
expect(Valvat::Checksum.validate(valid_vat)).to be true
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
12
14
|
expect(Valvat::Checksum.validate(invalid_vat)).to be false
|
13
15
|
end
|
14
16
|
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::HU do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
+
%w[HU10672101 HU13460370 HU10747759].each do |valid_vat|
|
7
|
+
it "returns true on valid VAT #{valid_vat}" do
|
6
8
|
expect(Valvat::Checksum.validate(valid_vat)).to be true
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
12
14
|
expect(Valvat::Checksum.validate(invalid_vat)).to be false
|
13
15
|
end
|
14
16
|
end
|
@@ -1,16 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::IE do
|
4
|
-
%w
|
5
|
-
|
6
|
-
it "returns true on valid
|
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
|
7
9
|
expect(Valvat::Checksum.validate(valid_vat)).to eql(true), valid_vat
|
8
10
|
end
|
9
11
|
|
10
12
|
invalid_vat = "#{valid_vat[0..-4]}#{valid_vat[-2]}#{valid_vat[-3]}#{valid_vat[-1]}"
|
11
13
|
|
12
|
-
it "returns false on invalid
|
13
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to
|
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)
|
14
22
|
end
|
15
23
|
end
|
16
24
|
end
|
@@ -1,23 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::IT do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
-
expect(Valvat::Checksum.validate(valid_vat)).to
|
6
|
+
%w[IT12345670785 IT01897810162 IT00197200132 IT02762750210].each do |valid_vat|
|
7
|
+
it "returns true on valid VAT #{valid_vat}" do
|
8
|
+
expect(Valvat::Checksum.validate(valid_vat)).to be(true)
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
12
|
-
expect(Valvat::Checksum.validate(invalid_vat)).to
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
14
|
+
expect(Valvat::Checksum.validate(invalid_vat)).to be(false)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
it
|
17
|
-
expect(Valvat::Checksum.validate(
|
18
|
+
it 'returns false on invalid special case VAT IT12345671783' do
|
19
|
+
expect(Valvat::Checksum.validate('IT12345671783')).to be(false)
|
18
20
|
end
|
19
21
|
|
20
|
-
it
|
21
|
-
expect(Valvat::Checksum.validate(
|
22
|
+
it 'returns false on invalid special case VAT IT00000000133' do
|
23
|
+
expect(Valvat::Checksum.validate('IT00000000133')).to be(false)
|
22
24
|
end
|
23
|
-
end
|
25
|
+
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Valvat::Checksum::LT do
|
4
|
-
%w
|
5
|
-
it "returns true on valid
|
6
|
+
%w[LT213179412 LT290061371314].each do |valid_vat|
|
7
|
+
it "returns true on valid VAT #{valid_vat}" do
|
6
8
|
expect(Valvat::Checksum.validate(valid_vat)).to be true
|
7
9
|
end
|
8
10
|
|
9
11
|
invalid_vat = "#{valid_vat[0..-3]}#{valid_vat[-1]}#{valid_vat[-2]}"
|
10
12
|
|
11
|
-
it "returns false on invalid
|
13
|
+
it "returns false on invalid VAT #{invalid_vat}" do
|
12
14
|
expect(Valvat::Checksum.validate(invalid_vat)).to be false
|
13
15
|
end
|
14
16
|
end
|