valvat 1.4.1 → 1.4.3

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 (78) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/valvat/version.rb +1 -1
  4. data.tar.gz.sig +0 -0
  5. metadata +34 -102
  6. metadata.gz.sig +0 -0
  7. data/.editorconfig +0 -15
  8. data/.github/workflows/rubocop.yml +0 -17
  9. data/.github/workflows/specs.yml +0 -47
  10. data/.gitignore +0 -9
  11. data/.rubocop.yml +0 -24
  12. data/CHANGES.md +0 -419
  13. data/Gemfile +0 -14
  14. data/Guardfile +0 -7
  15. data/MIT-LICENSE +0 -20
  16. data/README.md +0 -350
  17. data/Rakefile +0 -10
  18. data/certs/mite.pem +0 -26
  19. data/gemfiles/activemodel-5 +0 -8
  20. data/gemfiles/activemodel-6 +0 -8
  21. data/gemfiles/activemodel-7 +0 -8
  22. data/gemfiles/standalone +0 -7
  23. data/lib/valvat/locales/bg.yml +0 -34
  24. data/lib/valvat/locales/ca.yml +0 -34
  25. data/lib/valvat/locales/cs.yml +0 -34
  26. data/lib/valvat/locales/da.yml +0 -34
  27. data/lib/valvat/locales/de.yml +0 -35
  28. data/lib/valvat/locales/en.yml +0 -35
  29. data/lib/valvat/locales/es.yml +0 -35
  30. data/lib/valvat/locales/fi.yml +0 -34
  31. data/lib/valvat/locales/fr.yml +0 -34
  32. data/lib/valvat/locales/hu.yml +0 -35
  33. data/lib/valvat/locales/it.yml +0 -34
  34. data/lib/valvat/locales/lv.yml +0 -34
  35. data/lib/valvat/locales/nb.yml +0 -34
  36. data/lib/valvat/locales/nl.yml +0 -35
  37. data/lib/valvat/locales/pl.yml +0 -35
  38. data/lib/valvat/locales/pt.yml +0 -34
  39. data/lib/valvat/locales/ro.yml +0 -34
  40. data/lib/valvat/locales/sk.yml +0 -34
  41. data/lib/valvat/locales/sv.yml +0 -34
  42. data/lib/valvat/locales/tr.yml +0 -34
  43. data/spec/active_model/validations/valvat_validator_spec.rb +0 -274
  44. data/spec/spec_helper.rb +0 -37
  45. data/spec/valvat/checksum/at_spec.rb +0 -17
  46. data/spec/valvat/checksum/be_spec.rb +0 -17
  47. data/spec/valvat/checksum/bg_spec.rb +0 -18
  48. data/spec/valvat/checksum/cy_spec.rb +0 -17
  49. data/spec/valvat/checksum/de_spec.rb +0 -17
  50. data/spec/valvat/checksum/dk_spec.rb +0 -17
  51. data/spec/valvat/checksum/ee_spec.rb +0 -17
  52. data/spec/valvat/checksum/es_spec.rb +0 -65
  53. data/spec/valvat/checksum/fi_spec.rb +0 -17
  54. data/spec/valvat/checksum/fr_spec.rb +0 -17
  55. data/spec/valvat/checksum/gb_spec.rb +0 -34
  56. data/spec/valvat/checksum/gr_spec.rb +0 -17
  57. data/spec/valvat/checksum/hr_spec.rb +0 -17
  58. data/spec/valvat/checksum/hu_spec.rb +0 -17
  59. data/spec/valvat/checksum/ie_spec.rb +0 -24
  60. data/spec/valvat/checksum/it_spec.rb +0 -25
  61. data/spec/valvat/checksum/lt_spec.rb +0 -17
  62. data/spec/valvat/checksum/lu_spec.rb +0 -17
  63. data/spec/valvat/checksum/mt_spec.rb +0 -17
  64. data/spec/valvat/checksum/nl_spec.rb +0 -17
  65. data/spec/valvat/checksum/pl_spec.rb +0 -21
  66. data/spec/valvat/checksum/pt_spec.rb +0 -30
  67. data/spec/valvat/checksum/ro_spec.rb +0 -17
  68. data/spec/valvat/checksum/se_spec.rb +0 -21
  69. data/spec/valvat/checksum/si_spec.rb +0 -25
  70. data/spec/valvat/checksum_spec.rb +0 -40
  71. data/spec/valvat/lookup/hmrc_spec.rb +0 -58
  72. data/spec/valvat/lookup/vies_spec.rb +0 -25
  73. data/spec/valvat/lookup_spec.rb +0 -493
  74. data/spec/valvat/options_spec.rb +0 -23
  75. data/spec/valvat/syntax_spec.rb +0 -68
  76. data/spec/valvat/utils_spec.rb +0 -125
  77. data/spec/valvat_spec.rb +0 -276
  78. data/valvat.gemspec +0 -24
@@ -1,274 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- if defined?(ActiveModel)
6
- class Invoice < ModelBase
7
- validates :vat_number, valvat: true
8
- end
9
-
10
- class InvoiceWithLookup < ModelBase
11
- validates :vat_number, valvat: { lookup: true }
12
- end
13
-
14
- class InvoiceWithLookupAndFailIfDown < ModelBase
15
- validates :vat_number, valvat: { lookup: :fail_if_down }
16
- end
17
-
18
- class InvoiceAllowBlank < ModelBase
19
- validates :vat_number, valvat: { allow_blank: true }
20
- end
21
-
22
- class InvoiceAllowBlankOnAll < ModelBase
23
- validates :vat_number, valvat: true, allow_blank: true
24
- end
25
-
26
- class InvoiceCheckCountry < ModelBase
27
- validates :vat_number, valvat: { match_country: :country }
28
-
29
- def country
30
- @attributes[:country]
31
- end
32
- end
33
-
34
- class InvoiceCheckCountryWithLookup < ModelBase
35
- validates :vat_number, valvat: { match_country: :country, lookup: true }
36
-
37
- def country
38
- @attributes[:country]
39
- end
40
- end
41
-
42
- class InvoiceWithChecksum < ModelBase
43
- validates :vat_number, valvat: { checksum: true }
44
- end
45
-
46
- describe Invoice do
47
- before do
48
- I18n.locale = :en
49
- end
50
-
51
- context 'with valid VAT number' do
52
- it 'is valid' do
53
- expect(described_class.new(vat_number: 'DE259597697')).to be_valid
54
- end
55
- end
56
-
57
- context 'with invalid VAT number' do
58
- let(:invoice) { described_class.new(vat_number: 'DE259597697123') }
59
-
60
- it 'is not valid' do
61
- expect(invoice).not_to be_valid
62
- end
63
-
64
- it 'adds default (country specific) error message' do
65
- invoice.valid?
66
- expect(invoice.errors[:vat_number]).to eql(['is not a valid German VAT number'])
67
- end
68
-
69
- context 'with DE locale' do
70
- before do
71
- I18n.locale = :de
72
- end
73
-
74
- it 'adds translated error message' do
75
- invoice.valid?
76
- expect(invoice.errors[:vat_number]).to eql(['ist keine gültige deutsche USt-IdNr.'])
77
- end
78
- end
79
-
80
- context 'with PT locale' do
81
- before do
82
- I18n.locale = :pt
83
- end
84
-
85
- it 'adds translated error message' do
86
- invoice.valid?
87
- expect(invoice.errors[:vat_number]).to eql(['O NIF alemão não é válido.'])
88
- end
89
- end
90
-
91
- context 'with i18n translation in place' do
92
- before do
93
- I18n.backend.store_translations(:en, activemodel: {
94
- errors: { models: { invoice: { invalid_vat: 'is ugly.' } } }
95
- })
96
- end
97
-
98
- after { I18n.reload! }
99
-
100
- it 'uses translation' do
101
- invoice.valid?
102
- expect(invoice.errors[:vat_number]).to eql(['is ugly.'])
103
- end
104
- end
105
-
106
- context 'with i18n translation with country_adjective placeholder in place' do
107
- before do
108
- msg = 'is not a %{country_adjective} vat' # rubocop:disable Style/FormatStringToken
109
- translation = { activemodel: { errors: { models: { invoice: { invalid_vat: msg } } } } }
110
- I18n.backend.store_translations(:en, translation)
111
- end
112
-
113
- after { I18n.reload! }
114
-
115
- it 'replaces country_adjective placeholder' do
116
- invoice = described_class.new(vat_number: 'IE123')
117
- invoice.valid?
118
- expect(invoice.errors[:vat_number]).to eql(['is not a Irish vat'])
119
- end
120
-
121
- it "falls back to 'European' if country is missing" do
122
- invoice = described_class.new(vat_number: 'XX123')
123
- invoice.valid?
124
- expect(invoice.errors[:vat_number]).to eql(['is not a European vat'])
125
- end
126
- end
127
- end
128
-
129
- context 'with blank VAT number' do
130
- it 'is not valid' do
131
- expect(described_class.new(vat_number: '')).not_to be_valid
132
- expect(described_class.new(vat_number: nil)).not_to be_valid
133
- end
134
- end
135
- end
136
-
137
- describe InvoiceWithLookup do
138
- context 'with valid but not existing VAT number' do
139
- before do
140
- allow(Valvat::Syntax).to receive_messages(validate: true)
141
- allow(Valvat::Lookup).to receive_messages(validate: false)
142
- end
143
-
144
- it 'is not valid' do
145
- expect(described_class.new(vat_number: 'DE123')).not_to be_valid
146
- end
147
- end
148
-
149
- context 'with valid and existing VAT number' do
150
- before do
151
- allow(Valvat::Syntax).to receive_messages(validate: true)
152
- allow(Valvat::Lookup).to receive_messages(validate: true)
153
- end
154
-
155
- it 'is valid' do
156
- expect(described_class.new(vat_number: 'DE123')).to be_valid
157
- end
158
- end
159
-
160
- context 'with valid VAT number and VIES country service down' do
161
- before do
162
- allow(Valvat::Syntax).to receive_messages(validate: true)
163
- allow(Valvat::Lookup).to receive_messages(validate: nil)
164
- end
165
-
166
- it 'is valid' do
167
- expect(described_class.new(vat_number: 'DE123')).to be_valid
168
- end
169
- end
170
- end
171
-
172
- describe InvoiceWithLookupAndFailIfDown do
173
- let(:record) { described_class.new }
174
-
175
- context 'with valid VAT number and VIES country service down' do
176
- before do
177
- allow(Valvat::Syntax).to receive_messages(validate: true)
178
- allow(Valvat::Lookup).to receive_messages(validate: nil)
179
- end
180
-
181
- it 'is not valid' do
182
- expect(record).not_to be_valid
183
- msg = 'Unable to validate your VAT number: the VIES service is down. Please try again later.'
184
- expect(record.errors[:vat_number]).to eql([msg])
185
- end
186
- end
187
- end
188
-
189
- describe InvoiceAllowBlank do
190
- context 'with blank VAT number' do
191
- it 'is valid' do
192
- expect(described_class.new(vat_number: '')).to be_valid
193
- expect(described_class.new(vat_number: nil)).to be_valid
194
- end
195
- end
196
- end
197
-
198
- describe InvoiceAllowBlankOnAll do
199
- context 'with blank VAT number' do
200
- it 'is valid' do
201
- expect(described_class.new(vat_number: '')).to be_valid
202
- expect(described_class.new(vat_number: nil)).to be_valid
203
- end
204
- end
205
- end
206
-
207
- describe InvoiceCheckCountry do
208
- it 'is not valid on blank country' do
209
- expect(described_class.new(country: nil, vat_number: 'DE259597697')).not_to be_valid
210
- expect(described_class.new(country: '', vat_number: 'DE259597697')).not_to be_valid
211
- end
212
-
213
- it 'is not valid on wired country' do
214
- expect(described_class.new(country: 'XAXXX', vat_number: 'DE259597697')).not_to be_valid
215
- expect(described_class.new(country: 'ZO', vat_number: 'DE259597697')).not_to be_valid
216
- end
217
-
218
- it 'is not valid on mismatching (eu) country' do
219
- expect(described_class.new(country: 'FR', vat_number: 'DE259597697')).not_to be_valid
220
- expect(described_class.new(country: 'AT', vat_number: 'DE259597697')).not_to be_valid
221
- expect(described_class.new(country: 'DE', vat_number: 'ATU65931334')).not_to be_valid
222
- end
223
-
224
- it 'is valid on matching country' do
225
- expect(described_class.new(country: 'DE', vat_number: 'DE259597697')).to be_valid
226
- expect(described_class.new(country: 'AT', vat_number: 'ATU65931334')).to be_valid
227
- end
228
-
229
- it 'gives back error message with country from :country_match' do
230
- invoice = described_class.new(country: 'FR', vat_number: 'DE259597697')
231
- invoice.valid?
232
- expect(invoice.errors[:vat_number]).to eql(['is not a valid French VAT number'])
233
- end
234
-
235
- it 'gives back error message with country from :country_match even on invalid VAT number' do
236
- invoice = described_class.new(country: 'FR', vat_number: 'DE259597697123')
237
- invoice.valid?
238
- expect(invoice.errors[:vat_number]).to eql(['is not a valid French VAT number'])
239
- end
240
- end
241
-
242
- describe InvoiceCheckCountryWithLookup do
243
- before do
244
- allow(Valvat::Syntax).to receive_messages(validate: true)
245
- allow(Valvat::Lookup).to receive_messages(validate: true)
246
- end
247
-
248
- it 'avoids lookup or syntax check on failed because of mismatching country' do
249
- described_class.new(country: 'FR', vat_number: 'DE259597697').valid?
250
- expect(Valvat::Syntax).not_to have_received(:validate)
251
- expect(Valvat::Lookup).not_to have_received(:validate)
252
- end
253
-
254
- it 'check syntax and looup on matching country' do
255
- described_class.new(country: 'DE', vat_number: 'DE259597697').valid?
256
- expect(Valvat::Syntax).to have_received(:validate)
257
- expect(Valvat::Lookup).to have_received(:validate)
258
- end
259
- end
260
-
261
- describe InvoiceWithChecksum do
262
- context 'with valid VAT number' do
263
- it 'is valid' do
264
- expect(described_class.new(vat_number: 'DE259597697')).to be_valid
265
- end
266
- end
267
-
268
- context 'with invalid VAT number' do
269
- it 'is not valid' do
270
- expect(described_class.new(vat_number: 'DE259597687')).not_to be_valid
271
- end
272
- end
273
- end
274
- end
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