Skip to content

Magento loading the wrong Tax info on admin Invoice and Creditmemo page #31197

Closed
@srenon

Description

@srenon

After upgrading from Magento 2.3.3 to 2.4.1, we are having random broken invoice pages. After further debugging, this seems to be core issue.

Preconditions (*)

  1. Magento 2.4-develop

Steps to reproduce (*)

  1. Install clear Magento!
  2. Set-up tax rule for CA region.
  3. Go to Store->Configuration->Sales->Tax->Orders, Invoices, Credit Memos Display Settings and set
    Include Tax In Order Total -> Yes;
    Display Full Tax Summary -> Yes;
  4. Create a simple product.
  5. Place order with this product chose State/Province -> California.
  6. Place one more order and choose any State/Province except for California (to avoid taxes).
  7. Open the second order on the admin panel and create an invoice for it.
  8. Open the second order again, go to the Invoices tab, and open the invoice.

Expected result (*)

  1. Invoice page loaded successfully

Actual result (*)

  1. Invoice page broken
    image

Additional information

file

https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Sales/Block/Adminhtml/Order/Totals/Tax.php#L98

app/code/Magento/Tax/Model/ResourceModel/Sales/Order/Tax/Collection.php

image

In the image above order->getId() is actually an instance of Magento\Sales\Model\Order\Creditmemo or Magento\Sales\Model\Order\Invoice therefore getId() will return the invoice or credit memo id instead of the order id which will send the wrong information to the SQL below.

SELECT 
  `main_table`.* 
FROM 
  `sales_order_tax` AS `main_table` 
WHERE 
  (main_table.order_id = 1) 
ORDER BY 
  `process` ASC

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

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Component: TaxFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S3Affects non-critical data or functionality and does not force users to employ a workaround.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions