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

Fixes incorrect country code being used for Greek VAT numbers, should… #20548

Merged
merged 1 commit into from
Feb 12, 2019

Conversation

hostep
Copy link
Contributor

@hostep hostep commented Jan 23, 2019

… be 'EL' instead of 'GR'.

Description (*)

Greek VAT numbers use the prefix 'EL' and not the normal country code 'GR'.
This VAT number is send to the VIES VAT number validation and currently in Magento, the validation of Greek VAT numbers just never works. This PR fixes this.

Quoting from wikipedia:

The full identifier starts with an ISO 3166-1 alpha-2 (2 letters) country code (except for Greece, which uses the ISO 639-1 language code EL for the Greek language, instead of its ISO 3166-1 alpha-2 country code GR)

Fixed Issues (if relevant)

  1. Greek vat numbers cannot be validated #6960: Greek vat numbers cannot be validated

Manual testing scenarios (*)

In admin:

  1. In admin, go to Stores > Configuration > General > General > Store Information
  2. Make sure you select Greece as country and enter some dummy number "1234"
  3. It is expected that the string EL1234 is send to VIES, right now GR1234 is getting send

In frontend:

  1. First in admin, make sure these configurations are setup in Stores > Configuration > Customers > Customer Configuration > Create New Account Options:
    • Enable Automatic Assignment to Customer Group => Yes
    • Tax Calculation Based On => Yes
    • Group for Valid VAT ID - Domestic => General (doesn't really matter in this case)
    • Group for Valid VAT ID - Intra-Union => General (doesn't really matter in this case)
    • Group for Invalid VAT ID => General (doesn't really matter in this case)
    • Validation Error Group => General (doesn't really matter in this case)
    • Validate on Each Transaction => Yes
    • Show VAT Number on Storefront => Yes
  2. Flush caches
  3. On frontend, create a new account
  4. While logged in, create a new address and select Greece as a country, and enter some dummy VAT number "1234"
  5. It is expected that the string EL1234 is send to VIES, right now GR1234 is getting send

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @hostep. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@@ -179,18 +179,21 @@ public function checkVatNumber($countryCode, $vatNumber, $requesterCountryCode =
return $gatewayResponse;
}

$countryCodeForVatNumber = $this->getCountryCodeForVatNumber($countryCode);
$requesterCountryCodeForVatNumber = $this->getCountryCodeForVatNumber($requesterCountryCode);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Codacity blames about variable name length, you can try renaming them into $ctryVatCode and $requesterCtryVatCode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @aleron75, thanks for the review!

I don't agree with this check on length of variable names by Codacy, I like to keep them readable and understandable, we aren't living in the 1990's anymore where disk space was limited and code was supposed to be as small as possible :)

If Magento code standards really wants me to change these to a shorter name, please let me know, and I will change them, but I've send in PR's in the past where the same check failed, and then it wasn't a problem and was just approved as is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @hostep I will check, if this is not a real issue, your PR will proceed.

Copy link
Contributor

@aleron75 aleron75 Feb 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @hostep, I confirm you can ignore Codacity blaming about variable name length.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thanks! :)

@magento-engcom-team
Copy link
Contributor

Hi @aleron75, thank you for the review.
ENGCOM-4108 has been created to process this Pull Request

@ghost
Copy link

ghost commented Feb 12, 2019

Hi @hostep, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@hostep
Copy link
Contributor Author

hostep commented Feb 12, 2019

Thanks for reviewing and merging!
However, I won't be filling in the survey because it wants way too many permissions to my liking of my github account (This application will be able to read and write all public repository data.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants