Giter VIP home page Giter VIP logo

Comments (4)

DragonBe avatar DragonBe commented on August 18, 2024

Thank you @johanwilfer for mentioning this. We have noticed the difference in the VAT prefix and the international country code, but as all things from the European Commission, exceptions on the rule must exist.

I agree that this exception should be documented in the code to make it clear for developers and integrators why this exception exists, maybe even add this as a separate remark in the README.md to emphasise the difference that it's not a bug, but a feature 😸 So, just updated the README.

Just for my understanding: this VIES library processes the Greece VAT IDN's correctly, right? It's just that the prefix EL is different from the international ISO code for Greece, being GR. Correct?

Just to verify, I've added the Greece railway company Train OSE SA in my example, returning valid information after validation:

Valid
Identifier: WAPIAAAAWcNVzowR
Date and time: 13/11/2018 01:00
Company name: ΤΡΑΙΝΟΣΕ ΜΕΤΑΦΟΡΕΣ ΜΕΤΑΦΟΡΙΚΕΣ ΥΠΗΡΕΣΙΕΣ ΕΠΙΒΑΤΩΝ ΚΑΙ ΦΟΡΤΙΟΥ ΑΝΩΝΥΜΗ ΣΙΔΗΡΟΔΡΟΜΙΚΗ ΕΤΑΙΡΕΙΑ ||ΤΡΑΙΝΟΣΕ  ΑΕ
Company address: ΚΑΡΟΛΟΥ 1-3       10437 - ΑΘΗΝΑ

from vies.

johanwilfer avatar johanwilfer commented on August 18, 2024

Yes, the validation works great. I just tested this also.
The problem for us was that we use the list in the mentioned method to show/hide the VAT inputs, so we didn't even ask for it for Greek customers as there was no country "EL" selected...

Thanks for updating the README about this. :-)

from vies.

DragonBe avatar DragonBe commented on August 18, 2024

@johanwilfer You're very welcome. Only with this kind of feedback I can make the information more meaningful for users, especially when you're not engaging with VAT related things on a regular basis. The more I receive this type of not expected behaviour, the better use cases I can come up with and more accurate we can make our pre-validation before we fire things of to the EC VIES service.

from vies.

cottton avatar cottton commented on August 18, 2024

Old but still

GR <-> EL

As i read: GR is a country iso,
and EL is a VAT prefix.

VIES_EU_COUNTRY_LIST contains country iso as keys.
So 'EL' => ['name' => 'Greece', 'validator' => Validator\ValidatorEL::class], is actually a bad choice.

We may should change that in next major release to GR
(may add additional row with GR inthe current lastest version),
to keep the keys as country iso only,
and add an additional value 'vat_prefix' => 'EL' (optionally).

Every method should look up the vat prefix in the array instead using the country iso.

Example:
https://github.com/DragonBe/vies/blob/master/src/Vies/Vies.php#L491

    $requestParams = [
        'countryCode' => $countryCode,
        'vatNumber' => $testVatNumber,
    ];

Should then look like

$requestParams = [
    'countryCode' => $this->getVatPrefix($countryIso),
    'vatNumber' => $testVatNumber,
];

// ...
public function getVatPrefix($countryIso)
{
    if (!isset(self::VIES_EU_COUNTRY_LIST[$countryIso])) {
        // todo throw exception "invalid ..."
    }
    if (!isset(self::VIES_EU_COUNTRY_LIST[$countryIso]['var_prefix'])) {
        // VAT has a vat prefix that is NOT the same as the country iso.
        return self::VIES_EU_COUNTRY_LIST[$countryIso]['var_prefix'];
    }
    // VAT has a vat prefix that is the same as the country iso.
    return $countryIso;
}

TODO: does VIES expect the VAT prefix, or the real country iso?
Should we name it "vat prefix" or "country code"? Perhaps country code since this is already the case in lots of code already.

from vies.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.