Skip to content

Customer Tax Group not applied on order creation #10412

Closed
@er453r

Description

@er453r

Preconditions

  1. Magento 2.1.7

Steps to reproduce

  1. Crated different Customer Tax Classes (Retail/Company)
  2. Created different Tax Rates (21%/0%) and applied them with Tax Rule
  3. In Store Config enabled Enable Automatic Assignment to Customer Group and selected correct Customer Tax Classes based on Billing Address and Validate on each transaction

Expected result

In the store front everything works as expected. The prices during checkout are calculated with different Tax Rates based on the billing address with and without VAT ID.

BUT the Order is saved with the Retail tax values, even though the Company tax group is saved properly.

So both the admin Sales -> Orders and API show that order correctly with the Company customer tax group, but the tax rates are applied from the Retail class.

Actual result

  1. Wrong Tax Class is applied

Workaround

Fixed this by modifing app/code/Magento/Quote/Model/QuoteManagement.php by adding 3 lines after the first one in the following method:

 public function placeOrder($cartId, PaymentInterface $paymentMethod = null){
    $quote = $this->quoteRepository->getActive($cartId);

    $quote->setTotalsCollectedFlag(false); // add this lines
    $quote->collectTotals(); // add this lines
    $quote->save(); // add this lines

This forces Magento to recollect prices according to the billing address before saving it to the database.

Also this link for reference: https://magento.stackexchange.com/questions/187479/customer-tax-group-not-applied-on-order-creation/187587#187587

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions