-
Notifications
You must be signed in to change notification settings - Fork 168
VAT Id Number validators for all EU countries #271
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
Open
homebeaver
wants to merge
184
commits into
apache:master
Choose a base branch
from
homebeaver:master+vatin
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 183 commits
Commits
Show all changes
184 commits
Select commit
Hold shift + click to select a range
af28a53
add SIRENE Validator: SIREN and SIRET
homebeaver afeec88
Merge remote-tracking branch 'apache/master' into sirene
homebeaver a9e2341
Merge remote-tracking branch 'homebeaver/sirene' into master+vatin
homebeaver 6b70394
Merge commit 'ca4db8dca6829bce1b1701a74a115c6e2e39f2f0' into master+v…
homebeaver 423aff9
Merge commit '5335159022d750558c4e5a46028cc8467586b05b' into master+v…
homebeaver 8fa5dcd
Merge commit '4a87127ac38047a70aaf522ae105701ff5343237' into master+v…
homebeaver 441df92
Merge commit '682acf26359eabcac1b942ef8ec807a3e4033fb8' into master+v…
homebeaver 8a99de6
Merge commit 'd3c9cf0457c1bbb6256d3b0e7cbbc8203d4de419' into master+v…
homebeaver 1ae4e90
Merge commit '5b3bc4bdb674490419a62559cd222819b93750eb' into master+v…
homebeaver de831aa
Merge commit '77951ab6ba08753488e88385209663573fc00ea9' into master+v…
homebeaver ba34206
Merge commit 'c05298e773b1bb570d545d85fd10d8f203b25309' into master+v…
homebeaver 33dbb83
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver a4dc104
add Austrian VAT identification number (VATIN)
homebeaver b213e03
reported by Checkstyle
homebeaver 62c5f75
Re-run Maven using the -X (--debug) switch to get info for ...
homebeaver 06858ed
Revert "Re-run Maven using the -X (--debug) switch to get info for ..."
homebeaver 26c7dc6
checkstyle
homebeaver 1d8143a
comment
homebeaver d3cf001
add common message texts to CheckDigitException
homebeaver b8eff81
checkstyle
homebeaver 9f09912
add Belgian VAT identification number (VATIN) - first shot
homebeaver 9876fb9
minor change in VATidATCheckDigit
homebeaver 967a436
VATidBECheckDigit extends Modulus97CheckDigit
homebeaver c40d772
AbstractCheckDigitTest.createInvalidCodes for two char check digits
homebeaver 080de6c
checkstyle
homebeaver 6b83b78
error occurred in Javadoc report
homebeaver ac12f00
add Bulgarian VAT identification number (VATIN)
homebeaver 473a741
refine code for Bulgarian VATIN - TODO remove java.logging
homebeaver 2a9dcd3
add testdata from from https://de.wikipedia.org/wiki/Leitweg-ID
homebeaver 5710ad7
Bulgarian VATIN for physical persons (civil number)
homebeaver 825ecd0
use apache.commons.logging
homebeaver 79b694d
add Cypriot VATIN check digit validator and test (first shot)
homebeaver 5468214
code housekeeping for Cypriot VAT identification number (VATIN)
homebeaver 2eb4df4
add Czech VATIN check digit validator and test (first shot)
homebeaver 9720d43
common method for Czech: Rodné číslo (RČ)
homebeaver 4dedb63
Housekeeping Czech VATIN
homebeaver 1afc7b1
use apache.commons.logging
homebeaver dcde8bf
PMD check UselessParentheses
homebeaver e538bd0
add German VAT identification number (VATIN)
homebeaver 7fb2129
Housekeeping DE VATIN Check Digit
homebeaver 79d67f7
Remove Modulus11TenCheckDigit
homebeaver 34e4807
VATidDECheckDigitTest more Tests
homebeaver 6dadac8
improve MOD 11,10 module (Modulus11TenCheckDigit),
homebeaver 6b80416
housekeeping
homebeaver 368ab9b
add Danish VATIN check digit validator and test
homebeaver 189fe8b
housekeeping
homebeaver efc5b8a
add Estonian VATIN check digit validator and test
homebeaver d626d4a
housekeeping
homebeaver fc49240
add Greek VATIN check digit validator and test
homebeaver 7991096
housekeeping EL VATIN
homebeaver 1d88bf2
add Spanish VATIN check digit validator and test
homebeaver e048f2b
Spanish VATIN housekeeping, use apache.commons.logging
homebeaver 34d4e10
add Finnish VATIN check digit validator and test
homebeaver 0aef22f
add a commented test
homebeaver 6bc52ff
add French VATIN check digit validator and test (first shot)
homebeaver fd0b357
check SIREN in French VAT identification number
homebeaver f96fc17
PMD rule="UselessParentheses" ruleset="Code Style"
homebeaver f524998
add HU VATIN check digit validator and test
homebeaver 35c0953
add Irish VATIN check digit validator and test
homebeaver 409d4a4
add Italian VATIN check digit validator and test
homebeaver b77b9b0
remove informational empty class VATidITCheckDigit because
homebeaver 27e1398
Irish VATIN housekeeping
homebeaver 15d2934
add Lithuanian VATIN check digit validator and test
homebeaver 30731e2
Lithuanian VATIN housekeeping
homebeaver a26bfec
add Luxemburg VATIN check digit validator and test
homebeaver d1681ea
add Latvian VATIN check digit validator and test
homebeaver 1a5c76b
calculate NMIN (TIN) check digit for natural persons
homebeaver 3b9b8d3
Latvian VATIN housekeeping
homebeaver d5c8676
checkstyle
homebeaver b336a82
add Malta VATIN check digit validator and test
homebeaver 7f1812d
method Modulus97CheckDigit.toCheckDigit : change visibility
homebeaver 5e8b44f
Malta VATIN housekeeping
homebeaver c04bb09
add Netherlands VATIN check digit validator and test
homebeaver 7880eae
Netherlands VATIN housekeeping
homebeaver 1ddaadc
add Polish VATIN check digit validator and test (first shot)
homebeaver 6c72249
SireneValidatorTest : add testcase from overseas department
homebeaver be48ff1
Polish VAT identification number (VATIN) housekeeping
homebeaver 753d161
add Netherlands VATIN check digit validator and test
homebeaver d4af518
Portugal VATIN housekeeping
homebeaver f30c445
add Romanian VATIN check digit validator and test
homebeaver c4503ff
Romanian VATIN housekeeping
homebeaver 6636af4
add Swedish VATIN check digit validator and test
homebeaver c9933db
housekeeping for Swedish VATIN
homebeaver 5bd2f70
add Slovenian VATIN check digit validator and test
homebeaver 44e819c
housekeeping Slovenian VAT
homebeaver 47f577a
add Slovakia VATIN check digit validator and test
homebeaver d38f33b
add UK VATIN check digit validator and test (first shot)
homebeaver 3857a35
VATINCheckDigit check digit validator class: a mapping for all ...
homebeaver 9a2dd03
VATINCheckDigit comment and housekeeping
homebeaver b57a08c
Swedish VATIN : CheckDigit LUHN_CD_INSTANCE
homebeaver 9393a5b
VAT identification number (VATIN) Validator / main routine (first shot)
homebeaver 14a31fb
TidDECheckDigit use apache.commons.logging
homebeaver fdef6e7
test spaces in SIRET overseas department
homebeaver 0b44466
work in progress for FR-VATIN
homebeaver e973a30
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 2954d1e
work in progress : VATIN Validator
homebeaver 108ecca
comments and tests
homebeaver bde0f65
remove the prefix "EU" Foreign (non EU) companies
homebeaver ab64726
remove otherCountryCodes from VATINValidator.Validator
homebeaver fb2434d
AbstractCheckDigitTest.createInvalidCodes provide to create codes with
homebeaver cabd326
simplify VATINValidator with formats and check routines for EU countries
homebeaver 44c3698
forgot to checkin VATINValidatorTest
homebeaver ca2c19f
VATidGBCheckDigit for Northern Ireland - work in progress
homebeaver a4da03c
VATidXICheckDigitTest new style 9755 tests
homebeaver 9159c4f
style check
homebeaver b18e83d
Revert "style check"
homebeaver 2105ae0
wrong check in revert + commit VATidXICheckDigitTest
homebeaver d687936
finish GB+XI VATINS validating also codes with branch ids
homebeaver 2114e2e
finish VATidFRCheckDigit
homebeaver 33d54e3
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 8460226
IT VAT Id Check Digit Tests against LUHN
homebeaver 547c10e
Speling
homebeaver c4c2401
SireneValidator minor changes tkx to https://github.com/garydgregory
homebeaver 79709d3
more small chenges in SireneValidator
homebeaver 7a319c2
resolved files VATINValidator, Modulus11TenCheckDigit,
homebeaver 0a89437
implement Serializable, restore previous version
homebeaver a2a0ff3
Can use ABANumberCheckDigit for Estonian VATIN
homebeaver 1283f49
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 8add96b
Do not implement Serializable
homebeaver 8fa98a1
Revert "Do not implement Serializable"
homebeaver 416ce3f
close HTML tag, final in method param
homebeaver 2eef971
use Lists validFormat, invalidFormat and forEach() in test
homebeaver 76cc208
checkstyle and error has occurred in Javadoc report generatio
homebeaver 1d098d6
HTML in comment
homebeaver 54c4829
HTML blocks
homebeaver 7401b59
remove hamcrest, use List and forEach(...)
homebeaver ff57128
comment special FR test cases
homebeaver 1075609
Merge comments in tests LV RO SK
homebeaver 6bcd970
XI VAT Id Check Digit Tests. Merge comments. Explain "new style"
homebeaver b11ed72
update to the package-info.java in org.apache.commons.validator.routines
homebeaver da7aed4
HTML tag
homebeaver e086d42
Test, Comment and Simplify Estonian + Hungarien VATIN
homebeaver 9959b89
Merge comments in tests
homebeaver 7a17bb2
HTML Tags in comment
homebeaver 8eec607
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 251d8e0
Greek VATIN Testcase wich results to checkdigit 10 == 'X'
homebeaver 56697d9
test Slovenian VATIN
homebeaver 4df70d6
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver e60169e
NL VATIN Testcase which results to checkdigit 10 == 'X'
homebeaver 18741c6
Method AbstractCheckDigitTest.createInvalidCodes should return empty
homebeaver 98a94dd
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver fdb620a
Revert "Method AbstractCheckDigitTest.createInvalidCodes should retur…
homebeaver 5b01ccb
Uups - commit reverted + merge master branch + correct commit ...
homebeaver 147277c
Modulus 11-X module simplifies a group of VATIN calculations
homebeaver 47a93bf
Simplify VATIN for BG , LT , LV
homebeaver 3ce28a3
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 3d529b7
Luxemburg VATIN - accept "00" check digit
homebeaver e2e04d4
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 6d43ff2
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver ed2b3b6
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 5aa9654
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 9d93556
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 850433a
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver a2e0117
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 9df5404
resolve errors reported by Checkstyle 10.18.2
homebeaver e74b3c9
resolve remaining errors reported by checkstyle
homebeaver 0e8de9c
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 87b1907
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver e35ee04
NL VATIN with MOD 97 used additionally since 2020
homebeaver ef199a7
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 89d1519
VATidNLCheckDigit : Line has trailing spaces + simplify
homebeaver e20cb8a
checkstyle : whitespace
homebeaver 5e1c022
VATidLUCheckDigit class comment - tkx to https://github.com/sebbASF
homebeaver dc6e9c1
VATidLUCheckDigit : to be consistent with `VATidBECheckDigit`
homebeaver fcfec10
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 95d6a2b
avoid Javadoc Warnings: use of default constructor,
homebeaver f371965
remove logging - not really needed.
homebeaver 0ddb8f8
resolve pdm Code Style problem
homebeaver 8779990
removed class TidDECheckDigit
homebeaver 9ecd6c9
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 0f003e1
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver ca3896a
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 9bb900b
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 7e771f0
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 5fc3dd6
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 0a9a607
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 4b4c7f1
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver b78a2b1
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver cf660a0
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver a39e2ef
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 5f09b7e
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver f1d1ad9
Merge remote-tracking branch 'apache/master' into master+vatin
homebeaver 3b500c4
cvc-elt.1.a error in pom.xml
homebeaver 4b7df5b
Revert "cvc-elt.1.a error in pom.xml"
homebeaver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
src/main/java/org/apache/commons/validator/routines/SireneValidator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| /* | ||
| * 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.validator.GenericValidator; | ||
| import org.apache.commons.validator.routines.checkdigit.LuhnCheckDigit; | ||
|
|
||
| /** | ||
| * SIRENE (French System Information et Repertoire des Entreprise et des Etablissements) Validator. | ||
| * | ||
| * <p> | ||
| * International Code Designator, ICD : 0002 for SIRENE | ||
| * </p> | ||
| * <p> | ||
| * 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 : | ||
| * </p> | ||
| * <p> | ||
| * 1) Number of characters: 9 characters ("SIREN") 14 " 9+5 ("SIRET"), | ||
| * </p> | ||
| * <p> | ||
| * The 9 character number designates an organization, | ||
| * the 14 character number designates a specific establishment of the organization designated by the first 9 characters. | ||
| * </p> | ||
| * <p> | ||
| * 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> | ||
| * @since 1.10.0 | ||
| */ | ||
homebeaver marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| public class SireneValidator { | ||
|
|
||
| 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 format validation class contains regex for SIREN and SIRET. | ||
| */ | ||
| public static class Validator { | ||
| final RegexValidator validator; | ||
|
|
||
| /** | ||
| * Creates the format validator | ||
| * | ||
| * @param formats the regex to use to check the format | ||
| */ | ||
| public Validator(final String[] formats) { | ||
| this.validator = new RegexValidator(formats); | ||
| } | ||
| } | ||
|
|
||
| /** The singleton instance which uses the default formats */ | ||
| private static final SireneValidator DEFAULT_SIRENE_VALIDATOR = new SireneValidator(); | ||
|
|
||
| /** | ||
| * Gets the singleton instance of the SIRENE validator using the default formats | ||
| * | ||
| * @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; | ||
| } | ||
| final 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; | ||
| } | ||
| 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))) { | ||
| return false; | ||
| } | ||
| // check SIRET: | ||
| return LuhnCheckDigit.LUHN_CHECK_DIGIT.isValid(id); | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert these changes. They are not valid.
Although the values look like URLs, they are not; they are unique identifiers so must be left as is