magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

Customer VAT ID not validated when an address is saved / updated in customer dashboard #30720

Closed qsolutions-pl closed 3 years ago

qsolutions-pl commented 3 years ago

Preconditions (*)

  1. Any Magento 2 version
  2. Setup proper customer groups for EU VAT ID validation
  3. Make sure TAX / VAT field is visible in front so customer can edit it
  4. Configure Shipping Origin and store owner data as a valid EU entity with valid VATEU number

Steps to reproduce (*)

  1. Create an account Go to customer dashboard
  2. Add new address and fill TAX FIELD
  3. save new address

Expected result (*)

  1. Customer is assigned to customer group (for example B2B customer which are not charged with VAT)

Actual result (*)

  1. Vat ID validation error: Your Tax ID cannot be validated. You will be charged tax. If you believe this is an error, please contact us at
  2. Customer group is not changed

Class \Magento\Customer\Observer\AfterAddressSaveObserver is bugged, vat validation does not use requester ID when it validates customer address VAT ID

$result = $this->_customerVat->checkVatNumber(
                    $customerAddress->getCountryId(),
                    $customerAddress->getVatId()
                );

however in this class \Magento\Quote\Observer\Frontend\Quote\Address\VatValidator , Tax Validation looks like this:

$validationResult = $this->customerVat->checkVatNumber(
                $customerCountryCode,
                $customerVatNumber,
                $merchantVatNumber !== '' ? $merchantCountryCode : '',
                $merchantVatNumber
            );

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

m2-assistant[bot] commented 3 years ago

Hi @qsolutions-pl. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

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

Please, add a comment to assign the issue: @magento I am working on this


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

peterjaap commented 3 years ago

Magento 2 uses the VIES validation service, which requires a Requester Member State & number (in Magento's terms a merchant VAT number and merchant country code). See https://ec.europa.eu/taxation_customs/vies/vatRequest.html.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Thank you for your contributions.

qsolutions-pl commented 3 years ago

has anyone confirmed the issue?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

dverkade commented 3 years ago

Posting a comment. Issues should not be automatically closed.

m2-assistant[bot] commented 3 years ago

Hi @engcom-Alfa. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Alfa commented 3 years ago

Hi @qsolutions-pl Need more info , in fact Tried to reproduce it on Magento ver. dev-2.4-develop but i could not get the error provided for EU. Hence request to provide more test data used for this scenario like Zip code, Country and TAX VAT Number.

m2-assistant[bot] commented 3 years ago

Hi @engcom-Lima. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Lima commented 3 years ago

Hi @qsolutions-pl ,

Waited since 2 week about the updates, Hence closing this ticket as of now. If you have any issue or query then you can raise the new ticket or reopen.

Thanks for understanding!

hostep commented 3 years ago

This issue seems to be closed for the incorrect reasons.

The offending code referred to in the opening comment is still not passing on the merchant VAT data on the 2.4-develop branch: https://github.com/magento/magento2/blob/ed2ffad8f227e253c0aa50393f40478b02310b65/app/code/Magento/Customer/Observer/AfterAddressSaveObserver.php#L152-L155

I'll try to provide more info about how to reproduce this later when I find some time.

hostep commented 3 years ago

Hmm, I just tried to reproduce and it turns out that VIES validation does work without passing the requester member state country and number. Even on their own form those last two fields can remain empty and it still works.

So the issue is not valid (or at least not until VIES makes this a hard requirement one day in the future).

@qsolutions-pl: do you still have this problem or has it gone away?