homebeaver commented on code in PR #271: URL: https://github.com/apache/commons-validator/pull/271#discussion_r1797409952
########## src/test/java/org/apache/commons/validator/routines/checkdigit/VATidXICheckDigitTest.java: ########## @@ -0,0 +1,173 @@ +/* + * 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.checkdigit; + +import static org.junit.jupiter.api.Assertions.assertFalse; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +/** + * XI VAT Id Check Digit Tests. + */ +/* + + XI 110305878 : gültig bullseyecountrysport + XI 366303068 : gültig donnellygroup.co.uk Company Info Reg. Company Number: NI 643, + GB 366303013 ist HUITAIHK TECHNOLOGY LIMITED, ABERDEEN + XI 174918964 : valide, aber ungültig da nicht in Nordirland + GB 174918964 : gültig, valid UK VAT number: RESPOND HEALTHCARE LIMITED, CARDIFF + GB 613451470 : gültig, UNIVERSITY OF LEEDS. Aus adresslabor.de + GB 107328000 : gültig, IBM UNITED KINGDOM LIMITED + // VAT with branch test in VATINValidatorTest + GB 107328000001 Nr mit Niederlassung : gültig, IBM UK RENTALS LTD + GB 107328000002 Nr mit Niederlassung : gültig, IBM UNITED KINGDOM HOLDINGS LTD + GB 766800804 : gültig, IDOX SOFTWARE LTD + GB 980780684 : ungültig. Aus formvalidation.io und koblas/stdnum-js + GB 340804329 : gültig, SUNS LIFESTYLE LIMITED + GB 888801276 : == GD012 gültig, CENTRE FOR MANAGEMENT & POLICY STUDIES CIVIL SERVICE COLLEGE + GB 888850259 : == HA502 gültig, DEFENCE ELECTRONICS AND COMPONENTS AGENCY + GB 888851256 : == HA512 gültig, HIGH SPEED TWO (HS2) LIMITED + XI/GB 434031494 : valide, aber nicht gültig (aus AT-Doku) +VAT Mod 97 : GB 562235945 nicht gültig +VAT Mod 9755 : GB 562235987 nicht gültig + */ +public class VATidXICheckDigitTest extends AbstractCheckDigitTest { + + /** + * Sets up routine & valid codes. + */ + @BeforeEach + protected void setUp() { + checkDigitLth = VATidGBCheckDigit.CHECKDIGIT_LEN; + routine = VATidGBCheckDigit.getInstance(); + +// 366303068 (old style) 366303013 sind zwei verschiedene Unternehmen, die verschiedene PZ haben + valid = new String[] {"366303068" // old style XI + , "434031494" + , "110305836" // 1103058 36 old style for testing +// , "110305878", "174918964" // new style XI 9755 => test in VATINValidatorTest + , "613451470" + , "107328000" + , "766800804" + , "980780684" + , "888801276" + , "888850259" + , "888851256" + , "816137833" + , "562235945" + /* new style 9755 cannot be tested here Review Comment: I`ve explained "new style" in the file. Here in short: - each VAT code in GB and Nothern Ireland (XI) has two check digits - both are valid - one calculated with MOD97 algorithm - this is called "old style" (this is the result of calculate method) - the second calculated with MOD9755 - this is called "new style" -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
