1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
|
test_eu_vat.doctest - more detailed doctests for the stdnum.eu.vat module
Copyright (C) 2012-2017 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
This file contains more detailed doctests for the stdnum.eu.vat module. It
tries to validate a number of VAT numbers that have been found online.
>>> from stdnum.eu import vat
>>> from stdnum.exceptions import *
These have been found online and should all be valid numbers.
>>> numbers = '''
...
... ATU 142 43 102
... ATU 15159209
... ATU 28560205
... ATU 34172105
... ATU 40698107
... ATU 46276408
... ATU 49362201
... ATU 54299806
... ATU 54300000
... ATU 56377717
... ATU 57194903
... ATU 64487479
... ATU 64762368
... ATU 64938009
... ATU 65020906
... ATU 65033803
... ATU 65034704
... ATU 65480455
... ATU13585627
... ATU46080404
... ATU61195628
...
... BE (0)468.561.072
... BE 0202.239.951
... BE 0220.764.971
... BE 0248.015.142
... BE 0402 918 402
... BE 0407.139.583
... BE 0408 299 922
... BE 0441.928.931
... BE 0450 118 996
... BE 0462423150
... BE 0474 621 394
... BE 0795 013 186
... BE 0897290877
... BE 444.503.092
... BE 456.973.433
... BE 464 401 356
... BE0428759497
... BE413562567
... BE697449992
...
... BG 103873594
... BG 124 551 319
... BG 130 358 310
... BG 131 272 009
... BG 131202360
... BG 147137471
... BG 175074752
... BG 175186242
... BG 200182590
... BG 200950556
... BG130544585
... BG175074752
... BG7111042925
... BG7523169263
... BG7542011030
... BG8032056031
... Bg 200442771
...
... CY 10246672X
... CY 10263870R
... CY 10274231F
... CY 10285193Z
... CY- 10277198H
... CY-10008489 A
... CY-10189098G
... CY-10258074Y
... CY-10259033P
... CY00632993 F
...
... CZ 25123891
... CZ 25577581
... CZ 26852357
... CZ 60 72 77 72
... CZ 61467839
... CZ 640229/4448
... CZ 640903926
... CZ 64628060
... CZ 654123789
... CZ 682127228
... CZ 6956220612
... CZ 736028/5163
... CZ 8058012314
... CZ00023205
... CZ24158313
... CZ26780259
... CZ450 33 145
... CZ48207926
... CZ49620819
... CZ6011270177
... CZ6109220348
... CZ61989100
... CZ6306150004
... CZ7205151536
... CZ7652046248
...
... DE - 113866163
... DE - 231969187
... DE - 265265318
... DE - 267297673
... DE 118619592
... DE 125014955
... DE 129304291
... DE 168347747
... DE 181 207 708
... DE 195131068
... DE 204 760 908
... DE 213 806 597
... DE 221.304.969
... DE 246 595 415
... DE 811 363 057
... DE 811125440
... DE 811305931
... DE 813 11 38 75
... DE 813 184868
... DE119263782
... DE129390950
... DE136308783
... DE812847601
...
... DK 10 50 32 80
... DK 11 97 56 58
... DK 12 14 48 22
... DK 13 20 24 35
... DK 13 31 04 59
... DK 16 89 50 16
... DK 25 18 63 11
... DK 25 76 63 69
... DK 25 86 35 26
... DK 2566 2202
... DK 26 09 77 89
... DK 26 57 61 64
... DK 28 01 76 34
... DK 28107773
... DK 29523215
... DK 30 06 09 46
... DK 32 27 15 02
... DK 32329853
... DK 65 07 04 13
... DK 90 30 16 59
... DK-20 04 52 72
... DK-20 64 64 46
... DK-27630308
... DK-27926592
... DK-28840926
... DK-31882095
... DK-33053266
... DK10150817
... DK10290813
... DK26210895
... DK36149213
... DK: 21599336
...
... EE 100 931 558
... EE 100523487
... EE 100572933
... EE 100578209
... EE 100594102
... EE 100594403
... EE 100832107
... EE 100834066
... EE 101031389
... EE 101286639
... EE 101288941
... EE101256753
...
... ES - Q0818001J
... ES 54362315K
... ES A-28184661
... ES A-60631835
... ES A-60997582
... ES A08370314
... ES A17028366
... ES B-58378431
... ES B64240914
... ES B64717838
... ES B79110482
... ES B80975063
... ES F13005293
... ES J99216582
... ES Q-2818015-F
... ES R9600075G
... ES U99216426
... ES U99216632
... ES V99218067
... ES W4003922D
... ES X-5253868-R
... ES X5277343Q
... ES Y5277343F
... ES Z5277343K
... ES- A84409408
... ES-A08074908
... ES-B 60432291
... ES-B18889204
... ES-B55015432
... ES-B64995111
... ES-B96902531
... ES-x-2482300w
... ESA78109592
... Es-a58951310
...
... EL 039868210
... EL 044824428
... EL 072130053
... EL 082499478
... EL 094012834
... EL 094064321
... EL 094068633
... EL 094237076
... EL 094263543
... EL 095217179
... EL 095304080
... EL 099548630
... EL 94051189
... EL 998386804
... EL 998408192
... EL 998722134
... EL 999038150
... EL 999107669
... EL 999533911
... EL 999698730
... EL 999715835
... EL-082857563
... EL094501040
... EL098099809
... EL: 094279805
... El 800 179 925
...
... FI 02459042
... FI 0982651-1
... FI 10320534
... FI 18949388
... FI 20194885
... FI 20774740
... FI 2094606-3
... FI 24416318
... FI- 01968312
... FI- 22291259
... FI-214 95 540
... FI-22291240
... FI-24163066
... FI18261444
...
... FR 04409414364
... FR 09434086930
... FR 114 248 728 36
... FR 13 393 892 815
... FR 163 041 877 01
... FR 18 349 685 099
... FR 19 552 008 443
... FR 19552143273
... FR 20 329 450 738
... FR 21 448 834 911
... FR 2143 2146 546
... FR 22 326 565 603
... FR 22 379 160 070
... FR 26 495 205 213
... FR 28337893168
... FR 355 92065536
... FR 36 380 610 451
... FR 36502095094
... FR 38 353427495
... FR 41-343848552
... FR 53418304010
... FR 60391548955
... FR 61 954 506 077
... FR 63 334 214 293
... FR 65 444 243 075
... FR 68 378 838 692
... FR 70492082151
... FR 72 483 995 197
... FR 734 836 491 66
... FR 736 220 50 318
... FR 74 397 888 330
... FR 77 055 501 902
... FR 77 384 627 170
... FR 78528824428
... FR 79 410 964 837
... FR 83 404 833 048
... FR 84 323 140 392
... FR 86 394 303 796
... FR 86 542 103 569
... FR 88775649726
... FR 94016950842
... FR K 7399859412
... FR01712030113
... FR64333266765
... FR82542065479
... FR83404833048
... FR86451397608
... FR95483929956
... Fr 40 303 265 045
... Fr 96 631 620 572
... fr 71383076817
...
... FR16000063601
... FR23000047372
... FR26000040583
... FR28000113851
... FR30000017854
... FR32000000330
... FR36000006022
... FR40000066034
... FR43000020445
... FR48000052489
... FR54000065101
... FR64000063908
... FR65000100833
... FR79000030642
... FR83000065143
... FR83000113158
... FR84000082668
... FR87000018746
... FR88000008820
... FR88000053537
... FR96000110899
...
... GB 002 4257 28
... GB 003232345
... GB 100 1950 75
... GB 100190874
... GB 102675046
... GB 232177091
... GB 242338087388
... GB 311 405 025
... GB 362 5866 29
... GB 417 2280 71
... GB 436 0630 72
... GB 495 2781 05
... GB 507 5768 25
... GB 521 6763 52
... GB 586 367 295
... GB 591 9373 01
... GB 605 8678 15
... GB 662 8564 06
... GB 698 550 577
... GB 733 4428 41
... GB 770 381 235
... GB 784 9117 89
... GB 808 6365 12
... GB 812 8333 44
... GB 818243334
... GB 823 531 352
... GB 829 9594 59
... GB 845788960
... GB 879 7056 62
... GB 881 3758 91
... GB 913 3041 68
... GB 933210951
... GB 975 8664 50
... GB 977 4872 51
... GB 980780684
... GB 997 7094 44
... GB260311213
... GB653599494
... GB974053902
...
... HU -12509403
... HU 10672101
... HU 10766172
... HU 11444923
... HU 12723650
... HU 12840937
... HU 13851909
... HU 18206373
... HU 23157653
... HU 64241281
... HU-10402434
... HU-12892312
... HU-14528114
... HU11377304
... HU12078503
... HU13852467
...
... IE 0005306C
... IE 4550159S
... IE 4693875V
... IE 4731823J
... IE 632 3420 C
... IE 6324720T
... IE 6339273F
... IE 635 430 5C
... IE 6388047V
... IE 6397893P
... IE 6433435F
... IE 6436390B
... IE 6791517I
... IE 8223200u
... IE 9502346O
... IE 9574173P
... IE 9679477V
... IE 9719156S
... IE 9741812E
... IE 9742129V
... IE-9696131F
... IE6433435IH
... IE6433435OA
... IE6599001W
... IE8D79739I
... IE9Y71814N
...
... IT - 01404480202
... IT 0 0 6 1 8 2 8 0 4 9 9
... IT 00 595 000 217
... IT 00118439991
... IT 00193180932
... IT 00520800319
... IT 00571320076
... IT 00687120980
... IT 01189820689
... IT 01413270396
... IT 01465210449
... IT 01501180333
... IT 01606120226
... IT 01687870137
... IT 01720020344
... IT 01822890388
... IT 02100550264
... IT 02109480976
... IT 02153481201
... IT 02359210354
... IT 02408660211
... IT 02829410980
... IT 03274440241
... IT 03367280363
... IT 04894530635
... IT 05366960010
... IT 05460820961
... IT 05617370969
... IT 06075960010
... IT 06729900966
... IT 06863340961
... IT 09596821000
... IT 12920760159
... IT-01626160210
... IT-03700020104
... IT-03827740402
... IT-09159800011
... IT00743110157
... IT02087050155
... IT: 02331250163
...
... LT 100001354118
... LT 100001509912
... LT 100001799517
... LT 100001890913
... LT 100001906711
... LT 100001919017
... LT 100002645517
... LT 100002922012
... LT 100003619917
... LT 100005066013
... LT 100005929611
... LT 119511515
... LT 235449811
... LT 250266219
... LT 258596610
... LT 354991917
... LT 616414610
... LT 757118413
... LT-100000979812
... LT100001251914
... LT100002894215
... LT100004801610
... LT290068995116
...
... LU 10059929
... LU 10590281
... LU 109 676 28
... LU 11082217
... LU 13178262
... LU 150 274 42
... LU 1871 0830
... LU 19184853
... LU 19406747
... LU 19979983
... LU 20981643
... LU 21989666
... LU 22 22 12 68
... LU 22690342
... LU 22991225
... LU.248.70.640
... LU: 20993674
... LU: 2294 4200
... Lu 19980500
...
... LV 4000 3521 600
... LV 40003189718
... LV 40003282138
... LV 40003449366
... LV 40003655379
... LV 40003718068
... LV 40003754957
... LV 40003777428
... LV 40003939038
... LV 40008000102
... LV 40103077610
... LV 40103157009
... LV 40103179665
... LV 40103264016
... LV 43603009384
... LV 44103040262
... LV 5000 399 3021
... LV 50003087101
... LV 90000528023
... LV-40003241337
... LV-40003467376
... LV-42103016370
... LV-42103048183
...
... MT 1039-6417
... MT 1167-9112
... MT 1465 8213
... MT 1613-4207
... MT 17025737
... MT 18740407
... MT 1894 0705
... MT 1966 1023
... MT 19784818
... MT 2029 1423
... MT 20630321
...
... NL 001241 643 B01
... NL 009122746 B01
... NL 806753742B01
... NL 820605876B01
... NL 8225.69.759 b01
... NL-812421267 B01
... NL-8197.38.116.B.01
... NL.0094.10.806.B.01
... NL.8143.26.584.B.01
... NL.8186.43.778.B.01
... NL001309675B01
... NL001545668B01
... NL003376734B77
... NL00449544B01
... NL006375054B01
... NL006866049B01
... NL007394913B01
... NL009093503B01
... NL019077312B01
... NL066593931B01
... NL068357370B01
... NL117621729B01
... NL167647672B01
... NL4495445B01
... NL68357370B01
... NL802003217B01
... NL808373894B01
... NL811705262B01
... NL813411786B01
...
... PL 5211355116
... PL 5211754253
... PL 5220205853
... PL 5342152448
... PL 5423074698
... PL 584-030-44-72
... PL 5840154038
... PL 5840304472
... PL 5860224115
... PL 6330005110
... PL 645-000-67-50
... PL 6651344956
... PL 6661913137
... PL 6772320831
... PL 6792831859
... PL 6831810615
... PL 6842599822
... PL 687-16-26-585
... PL 7010098470
... PL 7271676569
... PL 764-23-05-489
... PL 764-23-05-495
... PL 764-23-05-503
... PL 764-23-05-526
... PL 764-23-05-549
... PL 764-23-05-555
... PL 764-23-05-578
... PL 767-000-06-78
... PL 767-13-25-342
... PL 767-14-25-718
... PL 767-14-47-329
... PL 768-000-24-66
... PL 7711598811
... PL 777 26 68 285
... PL 7780104605
... PL 7881154591
... PL 7961373674
... PL 8393173893
... PL 851-020-66-96
... PL 867-16-19-297
... PL 8722342429
... PL 8771130532
... PL 8971772896
... PL 8992708633
... PL 9241826918
... PL 9452174677
... PL 9462485048
... PL 9542705026
... PL 9562197426
... PL-7532365958
... PL-951-157-77-68
... PL5261025421
... PL6772135826
...
... PT 500 019 720
... PT 500135.495
... PT 501 507 930
... PT 501 519 246
... PT 501 964 843
... PT 502448911
... PT 502971142
... PT 504141066
... PT 506 030 636
... PT 506835669
... PT 507 223 730
... PT 507 757 505
... PT 507 859 146
... PT 507297687
... PT 508 081 327
... PT 509 250 505
... PT 509284930
... PT-505 856 468
... PT503038083
...
... RO 11358544
... RO 13837330
... RO 14840784
... RO 1630615123457
... RO 16621241
... RO 17832344
... RO 1822964
... RO 18341035
... RO 185 472 90
... RO 18779508
... RO 20950021
... RO 21356044
... RO 21996566
... RO 241 30 20
... RO 24736200
... RO 3087444
... RO 4003786
... RO 4019740
... RO 4257679
... RO 573768
... RO 6010151
... RO 6322498
... RO 6655328
... RO-23867797
... RO-27849238
... RO16241790
... Ro 15071875
...
... SE 202 100-5000 01
... SE 390 806 051 401
... SE 55 62 00-0777 01
... SE 55 67 59 32 48 01
... SE 556.383.740.901
... SE 556058115801
... SE 556126249301
... SE 556433592401
... SE 556700 3552 01
... SE 556708202801
... SE 556728341001
... SE 556848115301
... SE 720 522 241 201
... SE-502053602401
... SE-556 644 662 001
... SE-556 792 355 101
... SE-5562245190-01
... SE-556271210801
... SE-556666-4438-01
... SE556043606401
... Se 556250398601
...
... SI 26808498
... SI 29664373
... SI 3609 7152
... SI 48673820
... SI 50223054
... SI 56633360
... SI 56951442
... SI 68297530
... SI 70310815
... SI 73567906
... SI 85390518
... SI 92351069
... SI-83815201
... SI-89036999
...
... SK 1078449064
... SK 202 274 96 19
... SK 2020 237 945
... SK 2020257679
... SK 2021 6858 20
... SK 2021853504
... SK 2021998528
... SK 2022193459
... SK2022193459
...
... '''
>>> [x for x in numbers.splitlines() if x and not vat.is_valid(x)]
[]
The following numbers are wrong in one way or another. First we need a
function to be able to determine the kind of error.
>>> def caught(number, exception):
... try:
... vat.validate(number)
... return False
... except exception:
... return True
...
These numbers should be mostly valid except that they have been mangled
so their check digit is wrong.
>>> numbers = '''
...
... ATU 143 43 102
... ATU 15169209
... ATU46080904
... ATU61191628
...
... BE 0406.139.583
... BE 0793 013 186
... BE 456.973.432
... BE697449982
...
... BG 1037735942
... BG 131 172 009
... BG 147147471
... BG 200940556
...
... CY 10246672F
... CY-10009489 A
... CY-10257074Y
... CY00632893 F
...
... CZ 25557481
... CZ 48207726
... CZ 640913926
... CZ 8058018314
...
... DE 125014855
... DE 246 495 415
... DE 813 91 38 75
... DE - 266297673
...
... DK 11 96 56 58
... DK 2565 2202
... DK-27996592
... DK10159817
...
... EE 100 941 558
... EE 100525487
... EE 101586639
... EE101256754
...
... ES 54362415K
... ES K-2814015-F
... ES-x-2322300w
... Es-a48951310
...
... EL 094013834
... EL 094068733
... EL094501140
... EL: 094269805
...
... FR 04409414264
... FR 21 326 565 603
... FR K 7399859312
... FR L 7399859412
...
... IE 4731823H
... IE 632 3421 C
... IE 5339273F
... IE8D79729I
...
... LV 40003189715
... LV 90000528022
... LV-10103241337
... LV-42103048181
...
... SK 1078449164
... SK 302 274 96 19
... SK 2030 237 945
... SK 2020457679
...
... '''
>>> [x for x in numbers.splitlines() if x and not caught(x, InvalidChecksum)]
[]
These numbers should be mostly valid except that they have some formatting
flaws.
>>> numbers = '''
...
... AT1 142 43 102
... ATU 1515B209
...
... BE 02A2.239.951
... BE 0220,764.971
...
... BG 10X8735941
...
... CY-102590Z3P
...
... DE 246X595 415
... DE 011125440
...
... IE 4550C59S
... IE 069385V8
...
... NL 001241643801
... NL 009122746B00
... NL B06753742B01
... NL 82X569759b01
...
... SK A078449064
... SK 012 274 96 19
... SK 2010 237 945
...
... '''
>>> [x for x in numbers.splitlines() if x and not caught(x, InvalidFormat)]
[]
These numbers should be mostly valid except that they have some component
that contains an invalid or unknown value.
>>> numbers = '''
...
... CY-12259033P
...
... CZ 95123891
...
... IT 00687129980
...
... LT 100001354
... LT 100001509922
...
... QQ 124567
...
... '''
>>> [x for x in numbers.splitlines() if x and not caught(x, InvalidComponent)]
[]
>>> vat.compact('QQ 124567')
Traceback (most recent call last):
...
InvalidComponent: ...
These numbers should be mostly valid except that they have the wrong length.
>>> numbers = '''
...
... ATU 151592092
...
... CY-1225903322
...
... ES B-583784312
...
... FR000076090
...
... NL006866304B021
...
... SE 55643359201
... SE 5567003255201
...
... '''
>>> [x for x in numbers.splitlines() if x and not caught(x, InvalidLength)]
[]
|