DragonBe / vies

Component using the European Commission (EC) VAT Information Exchange System (VIES) to verify and validate VAT registration numbers in the EU, using PHP and Composer.
http://ec.europa.eu/taxation_customs/vies/faqvies.do#item16
MIT License
266 stars 59 forks source link

Validation of Irish VAT ID failed for valid VAT ID #108

Closed DragonBe closed 4 years ago

DragonBe commented 4 years ago

I was validating supplier VAT ID's and noticed that for Slack Technologies LTD (IE3336483DH) the validation failed while the VIES service confirms it's a valid VAT ID.

image

Looks like there's a failure in validating Irish VAT ID's

DragonBe commented 4 years ago

@peter279k and @krzaczek any ideas before I dig into this issue?

krzaczek commented 4 years ago

Ill take a look at in later today.

P.

Wiadomość napisana przez Michelangelo van Dam notifications@github.com w dniu 16.04.2020, o godz. 11:45:

@peter279k https://github.com/peter279k and @krzaczek https://github.com/krzaczek any ideas before I dig into this issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DragonBe/vies/issues/108#issuecomment-614538674, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMBTBOGCKSMD7UBKGWOXMDRM3HSBANCNFSM4MJNL2KA.

peter279k commented 4 years ago

I add this test case on ValidatorIETest::vatNumberProvider().

These code snippets are as follows:

<?php

declare (strict_types=1);

namespace DragonBe\Test\Vies\Validator;

class ValidatorIETest extends AbstractValidatorTest
{
    /**
     * @covers \DragonBe\Vies\Validator\ValidatorIE
     * @dataProvider vatNumberProvider
     */
    public function testValidator(string $vatNumber, bool $state)
    {
        $this->validateVatNumber('IE', $vatNumber, $state);
    }

    public function vatNumberProvider()
    {
        return [
            ['8Z49289F', true],
            ['3628739L', true],
            ['5343381W', true],
            ['6433435OA', true],
            ['8Z49389F', false],
            ['1234567', false],
            ['6433435OB', false],
            ['IE3336483DH', false], // the problematic test case
        ];
    }
}

It will be passed on PHPUnit test.

krzaczek commented 4 years ago

@peter279k @DragonBe what version of library are You using. ?

I did try the number on the latest master branch and it seems to work ok.

return [
            ['8Z49289F', true],
            ['3628739L', true],
            ['5343381W', true],
            ['6433435OA', true],
            ['3336483DH', true], //<- You should skip country prefix here `IE`
            ['8Z49389F', false],
            ['1234567', false],
            ['6433435OB', false]
        ];
→ ./vendor/bin/phpunit
PHPUnit 7.5.18 by Sebastian Bergmann and contributors.

...............................................................  63 / 221 ( 28%)
............................................................... 126 / 221 ( 57%)
............................................................... 189 / 221 ( 85%)
................................                                221 / 221 (100%)

Time: 1.24 seconds, Memory: 14.00 MB

OK (221 tests, 417 assertions)
krzaczek commented 4 years ago

I did tests back to 2.1.0 versions and 2.0.4 and it always passes as valid.

peter279k commented 4 years ago

@krzaczek, thanks for your reply and report.

It looks weird.

I remove vendor folder and composer.lock and run composer install.

Running php vendor/bin/phpunit again, and it's worked successfully now.

BTW, I run this on master branch.

DragonBe commented 4 years ago

Sorry for the wait, but seem to hit a brick wall here.

I've done a clean checkout from "git@github.com:DragonBe/vies.git", added the VAT ID "3336483DH" to the tests for ValidatorIETest and ran PHPUnit. Now all tests seem to pass.

in2it-mbp:vies-clean (master) % cat tests/Vies/Validator/ValidatorIETest.php
<?php

declare (strict_types=1);

namespace DragonBe\Test\Vies\Validator;

class ValidatorIETest extends AbstractValidatorTest
{
    /**
     * @covers \DragonBe\Vies\Validator\ValidatorIE
     * @dataProvider vatNumberProvider
     */
    public function testValidator(string $vatNumber, bool $state)
    {
        $this->validateVatNumber('IE', $vatNumber, $state);
    }

    public function vatNumberProvider()
    {
        return [
            ['8Z49289F', true],
            ['3628739L', true],
            ['5343381W', true],
            ['6433435OA', true],
            ['8Z49389F', false],
            ['1234567', false],
            ['6433435OB', false],
            ['3336483DH', true],  // <-- questionable VAT ID
        ];
    }
}
in2it-mbp:vies-clean (master) % ./vendor/bin/phpunit
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

...............................................................  63 / 221 ( 28%)
............................................................... 126 / 221 ( 57%)
............................................................... 189 / 221 ( 85%)
................................                                221 / 221 (100%)

Time: 3.57 seconds, Memory: 12.00 MB

OK (221 tests, 417 assertions)

Generating code coverage report in Clover XML format ... done

Generating code coverage report in HTML format ... done

Guess I've got some giberish in my codebase 🤦