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.55k stars 9.32k forks source link

Validating VAT Number on Admin Order Creation screen wipes shipping address when customer group changes. #30994

Closed gwharton closed 3 months ago

gwharton commented 3 years ago

Preconditions (*)

2.4-develop

Steps to reproduce (*)

- BACKEND

-- Customers
--- All Customers
---- Add New Customer
----- First Name = Test
----- Last Name = Test
----- Email = test@test.com
----- Save Customer

-- Catalog -> Products -> Add Product
--- Name = Test
--- Sku = TEST
--- Price = 100
--- Tax Class = Taxable Goods
--- Qty = 100
--- Save & Close

-- Stores -> Tax Zones and Rates -> Add New Tax Rate
--- Tax Identifier = Ireland Zero Rate
--- Zip Postcode = *
--- Country = Ireland 
--- Rate = 0
--- Save Rate

-- Stores -> Tax Rules -> Add New Tax Rule
--- Name = Ireland Zero Rate
--- Tax Rate = Ireland Zero Rate
--- Additional Settings
---- Add New Tax Class
----- Domestic
---- Add New Tax Class
----- VAT Error
---- Add New Tax Class
----- Invalid VAT
---- Add New Tax Class
----- Intra EU
--- Customer TAX Class = Intra EU (Deselect all others)
--- Save

-- Customers -> Customer Group -> Add New Customer Group
--- Group Name = Domestic
--- Tax Class = Domestic
--- Save Customer Group

-- Customers -> Customer Group -> Add New Customer Group
--- Group Name = Invalid VAT
--- Tax Class = Invalid VAT
--- Save Customer Group

-- Customers -> Customer Group -> Add New Customer Group
--- Group Name = VAT Error
--- Tax Class = VAT Error
--- Save Customer Group

-- Customers -> Customer Group -> Add New Customer Group
--- Group Name = Intra EU
--- Tax Class = Intra EU
--- Save Customer Group

-- Store -> Configuration -> Customers -> Customer Configuration -> Create new account options
--- Enable Automatic Assignment to Customer Group = Yes
--- Tax Calculation Based On = Shipping Address
--- Group for Valid VAT ID - Domestic = Domestic
--- Group for Valid VAT ID - Intra-Union = Intra EU
--- Group for Invalid VAT ID = Invalid VAT
--- Validation Error Group = VAT Error
--- Validate on Each Transaction = Yes
--- Show VAT Number on Storefront = Yes
--- Save Config

-- Store -> Configuration -> Customers -> Customer Configuration -> Name and Address Options
--- Show Tax/VAT Number = Optional
--- Save Config

-- Store -> Configuration -> General -> General -> Store Information
--- Country = United Kingdom
--- VAT Number = GB782325424 (This is ebay UK's vat number)
--- Save Config

--- Sales -> Orders -> Create New Order
---- Select "Test Test"
---- Click Add Products
---- Select Test and hit "Add Selected Products to Order"
---- First Name = "Billing"
---- Last Name = "Address"
---- Street Address = "Street"
---- Country = "Ireland"
---- City = "City"
---- Phone Number = "1234"
---- VAT Number = "IE3206488LH" (Stripes VAT Number)
---- Click "Validate VAT Number"
---- Click "OK" on the warning displayed asking you to change Customer Group to Intra EU

Expected result (*)

  1. Group should be changed to Intra-EU
  2. Rest of fields on form should be unchanged

Actual result (*)

  1. The whole shipping address is wiped.

Peek 2020-11-20 11-52


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 @gwharton. 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

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:

magento-engcom-team commented 3 years ago

:white_check_mark: Confirmed by @engcom-Alfa Thank you for verifying the issue. Based on the provided information internal tickets MC-39285 were created

Issue Available: @engcom-Alfa, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

gwharton commented 3 years ago

I think whats going on is that when either the "Validate VAT Number" link is clicked, or the "Customer Group" dropdown is changed, the forms content is refreshed and redrawn using the contents of the $quote object which will probably have empty address objects. However when either of these two events are triggers, the current contents of the form are not saved in the quote and are lost when it is refreshed.

gwharton commented 3 years ago

Is this the bug

reset_shipping is set true when the address field being modified is a billing address field, and Shipping is the same as Billing, or if the field being edited is a shipping address field. That makes sense. https://github.com/magento/magento2/blob/2cf043303b61423eaaadc5a095b83bdcf6443a6b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js#L264-L271

But here, Whenever a field on the form is edited, the form data is only ever sent to the backend and updated in the quote object when reset_shipping is false..... Huh? https://github.com/magento/magento2/blob/2cf043303b61423eaaadc5a095b83bdcf6443a6b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js#L291-L299

chiranjeevi-cj commented 3 years ago

@magento I am working on this.

chiranjeevi-cj commented 3 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 3 years ago

Hi @chiranjeevi-cj. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 3 years ago

Hi @chiranjeevi-cj, here is your Magento Instance: https://ac48f9bb74a6d77ca9c089ac4da5ab6e-2-4-develop.instances.magento-community.engineering Admin access: https://ac48f9bb74a6d77ca9c089ac4da5ab6e-2-4-develop.instances.magento-community.engineering/admin_a25c Login: c05f95c7 Password: 775251c78d18

kanevbg commented 1 year ago

up