Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VAT Id Number validators for all EU countries #271

Open
wants to merge 152 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 110 commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
af28a53
add SIRENE Validator: SIREN and SIRET
homebeaver Jul 14, 2021
afeec88
Merge remote-tracking branch 'apache/master' into sirene
homebeaver Oct 8, 2022
a9e2341
Merge remote-tracking branch 'homebeaver/sirene' into master+vatin
homebeaver Jun 17, 2024
6b70394
Merge commit 'ca4db8dca6829bce1b1701a74a115c6e2e39f2f0' into master+v…
homebeaver Sep 14, 2024
423aff9
Merge commit '5335159022d750558c4e5a46028cc8467586b05b' into master+v…
homebeaver Sep 14, 2024
8fa5dcd
Merge commit '4a87127ac38047a70aaf522ae105701ff5343237' into master+v…
homebeaver Sep 14, 2024
441df92
Merge commit '682acf26359eabcac1b942ef8ec807a3e4033fb8' into master+v…
homebeaver Sep 14, 2024
8a99de6
Merge commit 'd3c9cf0457c1bbb6256d3b0e7cbbc8203d4de419' into master+v…
homebeaver Sep 14, 2024
1ae4e90
Merge commit '5b3bc4bdb674490419a62559cd222819b93750eb' into master+v…
homebeaver Sep 14, 2024
de831aa
Merge commit '77951ab6ba08753488e88385209663573fc00ea9' into master+v…
homebeaver Sep 14, 2024
ba34206
Merge commit 'c05298e773b1bb570d545d85fd10d8f203b25309' into master+v…
homebeaver Sep 14, 2024
33dbb83
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Sep 14, 2024
a4dc104
add Austrian VAT identification number (VATIN)
homebeaver Sep 14, 2024
b213e03
reported by Checkstyle
homebeaver Sep 14, 2024
62c5f75
Re-run Maven using the -X (--debug) switch to get info for ...
homebeaver Sep 14, 2024
06858ed
Revert "Re-run Maven using the -X (--debug) switch to get info for ..."
homebeaver Sep 14, 2024
26c7dc6
checkstyle
homebeaver Sep 14, 2024
1d8143a
comment
homebeaver Sep 14, 2024
d3cf001
add common message texts to CheckDigitException
homebeaver Sep 15, 2024
b8eff81
checkstyle
homebeaver Sep 15, 2024
9f09912
add Belgian VAT identification number (VATIN) - first shot
homebeaver Sep 15, 2024
9876fb9
minor change in VATidATCheckDigit
homebeaver Sep 16, 2024
967a436
VATidBECheckDigit extends Modulus97CheckDigit
homebeaver Sep 16, 2024
c40d772
AbstractCheckDigitTest.createInvalidCodes for two char check digits
homebeaver Sep 16, 2024
080de6c
checkstyle
homebeaver Sep 16, 2024
6b83b78
error occurred in Javadoc report
homebeaver Sep 16, 2024
ac12f00
add Bulgarian VAT identification number (VATIN)
homebeaver Sep 16, 2024
473a741
refine code for Bulgarian VATIN - TODO remove java.logging
homebeaver Sep 16, 2024
2a9dcd3
add testdata from from https://de.wikipedia.org/wiki/Leitweg-ID
homebeaver Sep 17, 2024
5710ad7
Bulgarian VATIN for physical persons (civil number)
homebeaver Sep 17, 2024
825ecd0
use apache.commons.logging
homebeaver Sep 17, 2024
79b694d
add Cypriot VATIN check digit validator and test (first shot)
homebeaver Sep 17, 2024
5468214
code housekeeping for Cypriot VAT identification number (VATIN)
homebeaver Sep 18, 2024
2eb4df4
add Czech VATIN check digit validator and test (first shot)
homebeaver Sep 18, 2024
9720d43
common method for Czech: Rodné číslo (RČ)
homebeaver Sep 22, 2024
4dedb63
Housekeeping Czech VATIN
homebeaver Sep 23, 2024
1afc7b1
use apache.commons.logging
homebeaver Sep 23, 2024
dcde8bf
PMD check UselessParentheses
homebeaver Sep 23, 2024
e538bd0
add German VAT identification number (VATIN)
homebeaver Sep 23, 2024
7fb2129
Housekeeping DE VATIN Check Digit
homebeaver Sep 23, 2024
79d67f7
Remove Modulus11TenCheckDigit
homebeaver Sep 23, 2024
34e4807
VATidDECheckDigitTest more Tests
homebeaver Sep 23, 2024
6dadac8
improve MOD 11,10 module (Modulus11TenCheckDigit),
homebeaver Sep 24, 2024
6b80416
housekeeping
homebeaver Sep 24, 2024
368ab9b
add Danish VATIN check digit validator and test
homebeaver Sep 24, 2024
189fe8b
housekeeping
homebeaver Sep 24, 2024
efc5b8a
add Estonian VATIN check digit validator and test
homebeaver Sep 24, 2024
d626d4a
housekeeping
homebeaver Sep 24, 2024
fc49240
add Greek VATIN check digit validator and test
homebeaver Sep 24, 2024
7991096
housekeeping EL VATIN
homebeaver Sep 24, 2024
1d88bf2
add Spanish VATIN check digit validator and test
homebeaver Sep 24, 2024
e048f2b
Spanish VATIN housekeeping, use apache.commons.logging
homebeaver Sep 25, 2024
34d4e10
add Finnish VATIN check digit validator and test
homebeaver Sep 25, 2024
0aef22f
add a commented test
homebeaver Sep 27, 2024
6bc52ff
add French VATIN check digit validator and test (first shot)
homebeaver Sep 29, 2024
fd0b357
check SIREN in French VAT identification number
homebeaver Sep 29, 2024
f96fc17
PMD rule="UselessParentheses" ruleset="Code Style"
homebeaver Sep 29, 2024
f524998
add HU VATIN check digit validator and test
homebeaver Sep 29, 2024
35c0953
add Irish VATIN check digit validator and test
homebeaver Sep 29, 2024
409d4a4
add Italian VATIN check digit validator and test
homebeaver Sep 29, 2024
b77b9b0
remove informational empty class VATidITCheckDigit because
homebeaver Sep 29, 2024
27e1398
Irish VATIN housekeeping
homebeaver Sep 29, 2024
15d2934
add Lithuanian VATIN check digit validator and test
homebeaver Sep 29, 2024
30731e2
Lithuanian VATIN housekeeping
homebeaver Sep 29, 2024
a26bfec
add Luxemburg VATIN check digit validator and test
homebeaver Sep 29, 2024
d1681ea
add Latvian VATIN check digit validator and test
homebeaver Sep 30, 2024
1a5c76b
calculate NMIN (TIN) check digit for natural persons
homebeaver Oct 1, 2024
3b9b8d3
Latvian VATIN housekeeping
homebeaver Oct 1, 2024
d5c8676
checkstyle
homebeaver Oct 1, 2024
b336a82
add Malta VATIN check digit validator and test
homebeaver Oct 1, 2024
7f1812d
method Modulus97CheckDigit.toCheckDigit : change visibility
homebeaver Oct 1, 2024
5e8b44f
Malta VATIN housekeeping
homebeaver Oct 1, 2024
c04bb09
add Netherlands VATIN check digit validator and test
homebeaver Oct 1, 2024
7880eae
Netherlands VATIN housekeeping
homebeaver Oct 1, 2024
1ddaadc
add Polish VATIN check digit validator and test (first shot)
homebeaver Oct 1, 2024
6c72249
SireneValidatorTest : add testcase from overseas department
homebeaver Oct 2, 2024
be48ff1
Polish VAT identification number (VATIN) housekeeping
homebeaver Oct 2, 2024
753d161
add Netherlands VATIN check digit validator and test
homebeaver Oct 2, 2024
d4af518
Portugal VATIN housekeeping
homebeaver Oct 2, 2024
f30c445
add Romanian VATIN check digit validator and test
homebeaver Oct 2, 2024
c4503ff
Romanian VATIN housekeeping
homebeaver Oct 2, 2024
6636af4
add Swedish VATIN check digit validator and test
homebeaver Oct 2, 2024
c9933db
housekeeping for Swedish VATIN
homebeaver Oct 3, 2024
5bd2f70
add Slovenian VATIN check digit validator and test
homebeaver Oct 3, 2024
44e819c
housekeeping Slovenian VAT
homebeaver Oct 3, 2024
47f577a
add Slovakia VATIN check digit validator and test
homebeaver Oct 3, 2024
d38f33b
add UK VATIN check digit validator and test (first shot)
homebeaver Oct 3, 2024
3857a35
VATINCheckDigit check digit validator class: a mapping for all ...
homebeaver Oct 3, 2024
9a2dd03
VATINCheckDigit comment and housekeeping
homebeaver Oct 3, 2024
b57a08c
Swedish VATIN : CheckDigit LUHN_CD_INSTANCE
homebeaver Oct 3, 2024
9393a5b
VAT identification number (VATIN) Validator / main routine (first shot)
homebeaver Oct 3, 2024
14a31fb
TidDECheckDigit use apache.commons.logging
homebeaver Oct 3, 2024
fdef6e7
test spaces in SIRET overseas department
homebeaver Oct 3, 2024
0b44466
work in progress for FR-VATIN
homebeaver Oct 3, 2024
e973a30
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Oct 3, 2024
2954d1e
work in progress : VATIN Validator
homebeaver Oct 3, 2024
108ecca
comments and tests
homebeaver Oct 3, 2024
bde0f65
remove the prefix "EU" Foreign (non EU) companies
homebeaver Oct 3, 2024
ab64726
remove otherCountryCodes from VATINValidator.Validator
homebeaver Oct 4, 2024
fb2434d
AbstractCheckDigitTest.createInvalidCodes provide to create codes with
homebeaver Oct 4, 2024
cabd326
simplify VATINValidator with formats and check routines for EU countries
homebeaver Oct 4, 2024
44c3698
forgot to checkin VATINValidatorTest
homebeaver Oct 4, 2024
ca2c19f
VATidGBCheckDigit for Northern Ireland - work in progress
homebeaver Oct 7, 2024
a4da03c
VATidXICheckDigitTest new style 9755 tests
homebeaver Oct 7, 2024
9159c4f
style check
homebeaver Oct 7, 2024
b18e83d
Revert "style check"
homebeaver Oct 7, 2024
2105ae0
wrong check in revert + commit VATidXICheckDigitTest
homebeaver Oct 7, 2024
d687936
finish GB+XI VATINS validating also codes with branch ids
homebeaver Oct 8, 2024
2114e2e
finish VATidFRCheckDigit
homebeaver Oct 8, 2024
33d54e3
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Oct 8, 2024
8460226
IT VAT Id Check Digit Tests against LUHN
homebeaver Oct 9, 2024
547c10e
Speling
homebeaver Oct 9, 2024
c4c2401
SireneValidator minor changes tkx to https://github.com/garydgregory
homebeaver Oct 10, 2024
79709d3
more small chenges in SireneValidator
homebeaver Oct 10, 2024
7a319c2
resolved files VATINValidator, Modulus11TenCheckDigit,
homebeaver Oct 10, 2024
0a89437
implement Serializable, restore previous version
homebeaver Oct 10, 2024
a2a0ff3
Can use ABANumberCheckDigit for Estonian VATIN
homebeaver Oct 10, 2024
1283f49
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Oct 10, 2024
8add96b
Do not implement Serializable
homebeaver Oct 10, 2024
8fa98a1
Revert "Do not implement Serializable"
homebeaver Oct 11, 2024
416ce3f
close HTML tag, final in method param
homebeaver Oct 11, 2024
2eef971
use Lists validFormat, invalidFormat and forEach() in test
homebeaver Oct 11, 2024
76cc208
checkstyle and error has occurred in Javadoc report generatio
homebeaver Oct 11, 2024
1d098d6
HTML in comment
homebeaver Oct 11, 2024
54c4829
HTML blocks
homebeaver Oct 11, 2024
7401b59
remove hamcrest, use List and forEach(...)
homebeaver Oct 11, 2024
ff57128
comment special FR test cases
homebeaver Oct 11, 2024
1075609
Merge comments in tests LV RO SK
homebeaver Oct 11, 2024
6bcd970
XI VAT Id Check Digit Tests. Merge comments. Explain "new style"
homebeaver Oct 11, 2024
b11ed72
update to the package-info.java in org.apache.commons.validator.routines
homebeaver Oct 11, 2024
da7aed4
HTML tag
homebeaver Oct 11, 2024
e086d42
Test, Comment and Simplify Estonian + Hungarien VATIN
homebeaver Oct 12, 2024
9959b89
Merge comments in tests
homebeaver Oct 12, 2024
7a17bb2
HTML Tags in comment
homebeaver Oct 12, 2024
8eec607
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Oct 13, 2024
251d8e0
Greek VATIN Testcase wich results to checkdigit 10 == 'X'
homebeaver Oct 19, 2024
56697d9
test Slovenian VATIN
homebeaver Oct 21, 2024
4df70d6
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Oct 21, 2024
e60169e
NL VATIN Testcase which results to checkdigit 10 == 'X'
homebeaver Oct 21, 2024
18741c6
Method AbstractCheckDigitTest.createInvalidCodes should return empty
homebeaver Oct 22, 2024
98a94dd
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Oct 22, 2024
fdb620a
Revert "Method AbstractCheckDigitTest.createInvalidCodes should retur…
homebeaver Oct 22, 2024
5b01ccb
Uups - commit reverted + merge master branch + correct commit ...
homebeaver Oct 22, 2024
147277c
Modulus 11-X module simplifies a group of VATIN calculations
homebeaver Oct 23, 2024
47a93bf
Simplify VATIN for BG , LT , LV
homebeaver Oct 23, 2024
3ce28a3
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Oct 28, 2024
3d529b7
Luxemburg VATIN - accept "00" check digit
homebeaver Oct 31, 2024
e2e04d4
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Nov 24, 2024
6d43ff2
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Dec 6, 2024
ed2b3b6
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Dec 7, 2024
5aa9654
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Dec 17, 2024
9d93556
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.validator.routines;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.validator.GenericValidator;
import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit;

/**
* SIRENE (FR System Information et Repertoire des Entreprise et des Etablissements) Validator.
homebeaver marked this conversation as resolved.
Show resolved Hide resolved
*
* <p>
* International Code Designator, ICD : 0002 for SIRENE
* <br>
* Issuing Organization :
* Institut National de la Statistique et des Etudes Economiques, (I.N.S.E.E.),
* Departement des Repertoires, 18, Bd Adolphe Pinard, 75675 PARIS Cedex 14
* </p>
* <p>
* Structure of Code :
* <br>
* 1) Number of characters: 9 characters ("SIREN") 14 " 9+5 ("SIRET"),
* <br>
* The 9 character number designates an organization,
* the 14 character number designates a specific establishment of the organization designated by the first 9 characters.
* <br>
* 2) Check digits: 9th and 14th character respectively
* </p>
* <p>
* See <a href="https://en.wikipedia.org/wiki/SIRET_code">Wikipedia - SIRET</a> for more details.
* </p>
*/
homebeaver marked this conversation as resolved.
Show resolved Hide resolved
public class SireneValidator {

private static final Log LOG = LogFactory.getLog(SireneValidator.class);

final Validator formatValidator;

private static final Validator DEFAULT_FORMAT =
new Validator( new String[]
{ "^(\\d{9})$" // SIREN
, "^(\\d{14})$" // SIRET
});

private static final int SIREN_CODE_LEN = 9;
private static final int SIRET_CODE_LEN = 14;

/**
* The validation class
homebeaver marked this conversation as resolved.
Show resolved Hide resolved
*/
public static class Validator {
final RegexValidator validator;

/**
* Creates the format validator
*
* @param formats the regex's to use to check the format
homebeaver marked this conversation as resolved.
Show resolved Hide resolved
*/
public Validator(String[] formats) {
homebeaver marked this conversation as resolved.
Show resolved Hide resolved
this.validator = new RegexValidator(formats);
}
}

/** The singleton instance which uses the default formats */
public static final SireneValidator DEFAULT_SIRENE_VALIDATOR = new SireneValidator();

/**
* Return a singleton instance of the SIRENE validator using the default formats
homebeaver marked this conversation as resolved.
Show resolved Hide resolved
*
* @return A singleton instance of the validator
homebeaver marked this conversation as resolved.
Show resolved Hide resolved
*/
public static SireneValidator getInstance() {
return DEFAULT_SIRENE_VALIDATOR;
}

/**
* Create a default format validator.
*/
public SireneValidator() {
this.formatValidator = DEFAULT_FORMAT;
}

/**
* Validate a SIRENE-ID (SIREN or SIRET)
*
* @param code The value validation is being performed on
* @return <code>true</code> if the value is valid
*/
public boolean isValid(final String code) {
if (GenericValidator.isBlankOrNull(code)) {
return false;
}

homebeaver marked this conversation as resolved.
Show resolved Hide resolved
String id = code.trim();
if (id.length() != SIREN_CODE_LEN && id.length() != SIRET_CODE_LEN) {
return false;
}

// format check:
if (!formatValidator.validator.isValid(id)) return false;
homebeaver marked this conversation as resolved.
Show resolved Hide resolved

if (id.length() == SIREN_CODE_LEN) {
return LuhnCheckDigit.LUHN_CHECK_DIGIT.isValid(id);
}
if (!LuhnCheckDigit.LUHN_CHECK_DIGIT.isValid(id.substring(0, SIREN_CODE_LEN))) {
if (LOG.isDebugEnabled()) {
LOG.debug(id + " is SIRET, SIREN check digit at 9 is NOT valid.");
}
return false;
}

return LuhnCheckDigit.LUHN_CHECK_DIGIT.isValid(id);
}

}
Loading