This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,124 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['excluding_tax_apply_tax_after_discount'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS => SetupUtil::SHIPPING_TAX_CLASS,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 20,
],
SetupUtil::TAX_RULE_OVERRIDES => [
[
//tax rule for product
'code' => 'Product Tax Rule',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
],
[
//tax rule for shipping
'code' => 'Shipping Tax Rule',
'product_tax_class_ids' => [SetupUtil::SHIPPING_TAX_CLASS],
'tax_rate_ids' => [SetupUtil::TAX_RATE_SHIPPING],
],
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 10,
'qty' => 2,
],
],
'shipping_method' => 'flatrate_flatrate',
'shopping_cart_rules' => [
[
'discount_amount' => 50,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 20,
'base_subtotal' => 20,
'subtotal_incl_tax' => 24,
'base_subtotal_incl_tax' => 24,
'tax_amount' => 2.75,
'base_tax_amount' => 2.75,
'shipping_amount' => 10,
'base_shipping_amount' => 10,
'shipping_incl_tax' => 10.75,
'base_shipping_incl_tax' => 10.75,
'shipping_tax_amount' => 0.75,
'base_shipping_tax_amount' => 0.75,
'discount_amount' => -10,
'base_discount_amount' => -10,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 22.75,
'base_grand_total' => 22.75,
'applied_taxes' => [
SetupUtil::TAX_RATE_TX => [
'percent' => 20,
'amount' => 2,
'base_amount' => 2,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
'percent' => 20,
],
],
],
SetupUtil::TAX_RATE_SHIPPING => [
'percent' => 7.5,
'amount' => 0.75,
'base_amount' => 0.75,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_SHIPPING,
'title' => SetupUtil::TAX_RATE_SHIPPING,
'percent' => 7.5,
],
],
],
],
],
'items_data' => [
'simple1' => [
'row_total' => 20,
'base_row_total' => 20,
'tax_percent' => 20,
'price' => 10,
'base_price' => 10,
'price_incl_tax' => 12,
'base_price_incl_tax' => 12,
'row_total_incl_tax' => 24,
'base_row_total_incl_tax' => 24,
'tax_amount' => 2,
'base_tax_amount' => 2,
'discount_amount' => 10,
'base_discount_amount' => 10,
'discount_percent' => 50,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,125 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['excluding_tax_apply_tax_after_discount_discount_tax'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS => SetupUtil::SHIPPING_TAX_CLASS,
Config::CONFIG_XML_PATH_DISCOUNT_TAX => 1,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 20,
],
SetupUtil::TAX_RULE_OVERRIDES => [
[
//tax rule for product
'code' => 'Product Tax Rule',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
],
[
//tax rule for shipping
'code' => 'Shipping Tax Rule',
'product_tax_class_ids' => [SetupUtil::SHIPPING_TAX_CLASS],
'tax_rate_ids' => [SetupUtil::TAX_RATE_SHIPPING],
],
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 10,
'qty' => 2,
],
],
'shipping_method' => 'flatrate_flatrate',
'shopping_cart_rules' => [
[
'discount_amount' => 50,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 20,
'base_subtotal' => 20,
'subtotal_incl_tax' => 24,
'base_subtotal_incl_tax' => 24,
'tax_amount' => 2.35,
'base_tax_amount' => 2.35,
'shipping_amount' => 10,
'base_shipping_amount' => 10,
'shipping_incl_tax' => 10.75,
'base_shipping_incl_tax' => 10.75,
'shipping_tax_amount' => 0.75,
'base_shipping_tax_amount' => 0.75,
'discount_amount' => -12,
'base_discount_amount' => -12,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 20.35,
'base_grand_total' => 20.35,
'applied_taxes' => [
SetupUtil::TAX_RATE_TX => [
'percent' => 20,
'amount' => 1.6,
'base_amount' => 1.6,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
'percent' => 20,
],
],
],
SetupUtil::TAX_RATE_SHIPPING => [
'percent' => 7.5,
'amount' => 0.75,
'base_amount' => 0.75,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_SHIPPING,
'title' => SetupUtil::TAX_RATE_SHIPPING,
'percent' => 7.5,
],
],
],
],
],
'items_data' => [
'simple1' => [
'row_total' => 20,
'base_row_total' => 20,
'tax_percent' => 20,
'price' => 10,
'base_price' => 10,
'price_incl_tax' => 12,
'base_price_incl_tax' => 12,
'row_total_incl_tax' => 24,
'base_row_total_incl_tax' => 24,
'tax_amount' => 1.6,
'base_tax_amount' => 1.6,
'discount_amount' => 12,
'base_discount_amount' => 12,
'discount_percent' => 50,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,87 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['excluding_tax_apply_tax_before_discount'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 0,
Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS => SetupUtil::PRODUCT_TAX_CLASS_1,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 20,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 10,
'qty' => 2,
],
],
'shipping_method' => 'flatrate_flatrate',
'shopping_cart_rules' => [
[
'discount_amount' => 50,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 20,
'base_subtotal' => 20,
'subtotal_incl_tax' => 24,
'base_subtotal_incl_tax' => 24,
'tax_amount' => 6,
'base_tax_amount' => 6,
'shipping_amount' => 10,
'base_shipping_amount' => 10,
'shipping_incl_tax' => 12,
'base_shipping_incl_tax' => 12,
'shipping_tax_amount' => 2,
'base_shipping_tax_amount' => 2,
'discount_amount' => -10,
'base_discount_amount' => -10,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 26,
'base_grand_total' => 26,
],
'items_data' => [
'simple1' => [
'row_total' => 20,
'base_row_total' => 20,
'tax_percent' => 20,
'price' => 10,
'base_price' => 10,
'price_incl_tax' => 12,
'base_price_incl_tax' => 12,
'row_total_incl_tax' => 24,
'base_row_total_incl_tax' => 24,
'tax_amount' => 4,
'base_tax_amount' => 4,
'discount_amount' => 10,
'base_discount_amount' => 10,
'discount_percent' => 50,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,109 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['excluding_tax__multi_item_row'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 0,
Config::XML_PATH_ALGORITHM => Calculation::CALC_ROW_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 8.25,
SetupUtil::TAX_STORE_RATE => 8.25,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 10.00,
'qty' => 1,
],
[
'sku' => 'simple2',
'price' => 11.00,
'qty' => 1,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 21,
'base_subtotal' => 21,
'subtotal_incl_tax' => 22.74,
'base_subtotal_incl_tax' => 22.74,
'tax_amount' => 1.74,
'base_tax_amount' => 1.74,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 22.74,
'base_grand_total' => 22.74,
],
'items_data' => [
'simple1' => [
'row_total' => 10,
'base_row_total' => 10,
'tax_percent' => 8.25,
'price' => 10,
'base_price' => 10,
'price_incl_tax' => 10.83,
'base_price_incl_tax' => 10.83,
'row_total_incl_tax' => 10.83,
'base_row_total_incl_tax' => 10.83,
'tax_amount' => 0.83,
'base_tax_amount' => 0.83,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
'simple2' => [
'row_total' => 11,
'base_row_total' => 11,
'tax_percent' => 8.25,
'price' => 11,
'base_price' => 11,
'price_incl_tax' => 11.91,
'base_price_incl_tax' => 11.91,
'row_total_incl_tax' => 11.91,
'base_row_total_incl_tax' => 11.91,
'tax_amount' => 0.91,
'base_tax_amount' => 0.91,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,109 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['excluding_tax__multi_item_total'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 0,
Config::XML_PATH_ALGORITHM => Calculation::CALC_TOTAL_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 8.25,
SetupUtil::TAX_STORE_RATE => 8.25,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 10.00,
'qty' => 1,
],
[
'sku' => 'simple2',
'price' => 11.00,
'qty' => 1,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 21,
'base_subtotal' => 21,
'subtotal_incl_tax' => 22.73,
'base_subtotal_incl_tax' => 22.73,
'tax_amount' => 1.73,
'base_tax_amount' => 1.73,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 22.73,
'base_grand_total' => 22.73,
],
'items_data' => [
'simple1' => [
'row_total' => 10,
'base_row_total' => 10,
'tax_percent' => 8.25,
'price' => 10,
'base_price' => 10,
'price_incl_tax' => 10.83,
'base_price_incl_tax' => 10.83,
'row_total_incl_tax' => 10.83,
'base_row_total_incl_tax' => 10.83,
'tax_amount' => 0.83,
'base_tax_amount' => 0.83,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
'simple2' => [
'row_total' => 11,
'base_row_total' => 11,
'tax_percent' => 8.25,
'price' => 11,
'base_price' => 11,
'price_incl_tax' => 11.90,
'base_price_incl_tax' => 11.90,
'row_total_incl_tax' => 11.90,
'base_row_total_incl_tax' => 11.90,
'tax_amount' => 0.90,
'base_tax_amount' => 0.90,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,109 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['excluding_tax__multi_item_unit'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 0,
Config::XML_PATH_ALGORITHM => Calculation::CALC_UNIT_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 8.25,
SetupUtil::TAX_STORE_RATE => 8.25,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 10.00,
'qty' => 1,
],
[
'sku' => 'simple2',
'price' => 11.00,
'qty' => 1,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 21,
'base_subtotal' => 21,
'subtotal_incl_tax' => 22.74,
'base_subtotal_incl_tax' => 22.74,
'tax_amount' => 1.74,
'base_tax_amount' => 1.74,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 22.74,
'base_grand_total' => 22.74,
],
'items_data' => [
'simple1' => [
'row_total' => 10,
'base_row_total' => 10,
'tax_percent' => 8.25,
'price' => 10,
'base_price' => 10,
'price_incl_tax' => 10.83,
'base_price_incl_tax' => 10.83,
'row_total_incl_tax' => 10.83,
'base_row_total_incl_tax' => 10.83,
'tax_amount' => 0.83,
'base_tax_amount' => 0.83,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
'simple2' => [
'row_total' => 11,
'base_row_total' => 11,
'tax_percent' => 8.25,
'price' => 11,
'base_price' => 11,
'price_incl_tax' => 11.91,
'base_price_incl_tax' => 11.91,
'row_total_incl_tax' => 11.91,
'base_row_total_incl_tax' => 11.91,
'tax_amount' => 0.91,
'base_tax_amount' => 0.91,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,84 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['excluding_tax_row'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_ROW_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 8.25,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 10,
'qty' => 2,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 20,
'base_subtotal' => 20,
'subtotal_incl_tax' => 21.65,
'base_subtotal_incl_tax' => 21.65,
'tax_amount' => 1.65,
'base_tax_amount' => 1.65,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 21.65,
'base_grand_total' => 21.65,
],
'items_data' => [
'simple1' => [
'row_total' => 20,
'base_row_total' => 20,
'tax_percent' => 8.25,
'price' => 10,
'base_price' => 10,
'price_incl_tax' => 10.83,
'base_price_incl_tax' => 10.83,
'row_total_incl_tax' => 21.65,
'base_row_total_incl_tax' => 21.65,
'tax_amount' => 1.65,
'base_tax_amount' => 1.65,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,84 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['excluding_tax_total'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_TOTAL_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 8.25,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 10,
'qty' => 2,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 20,
'base_subtotal' => 20,
'subtotal_incl_tax' => 21.65,
'base_subtotal_incl_tax' => 21.65,
'tax_amount' => 1.65,
'base_tax_amount' => 1.65,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 21.65,
'base_grand_total' => 21.65,
],
'items_data' => [
'simple1' => [
'row_total' => 20,
'base_row_total' => 20,
'tax_percent' => 8.25,
'price' => 10,
'base_price' => 10,
'price_incl_tax' => 10.83,
'base_price_incl_tax' => 10.83,
'row_total_incl_tax' => 21.65,
'base_row_total_incl_tax' => 21.65,
'tax_amount' => 1.65,
'base_tax_amount' => 1.65,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,84 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['excluding_tax_unit'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_UNIT_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 8.25,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 10,
'qty' => 2,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 20,
'base_subtotal' => 20,
'subtotal_incl_tax' => 21.66,
'base_subtotal_incl_tax' => 21.66,
'tax_amount' => 1.66,
'base_tax_amount' => 1.66,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 21.66,
'base_grand_total' => 21.66,
],
'items_data' => [
'simple1' => [
'row_total' => 20,
'base_row_total' => 20,
'tax_percent' => 8.25,
'price' => 10,
'base_price' => 10,
'price_incl_tax' => 10.83,
'base_price_incl_tax' => 10.83,
'row_total_incl_tax' => 21.66,
'base_row_total_incl_tax' => 21.66,
'tax_amount' => 1.66,
'base_tax_amount' => 1.66,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,132 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['including_tax_apply_tax_after_discount'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 1,
Config::CONFIG_XML_PATH_SHIPPING_INCLUDES_TAX => 1,
Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS => SetupUtil::SHIPPING_TAX_CLASS,
Config::XML_PATH_ALGORITHM => Calculation::CALC_ROW_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 10,
SetupUtil::TAX_STORE_RATE => 10,
SetupUtil::TAX_RATE_SHIPPING => 10,
],
SetupUtil::TAX_RULE_OVERRIDES => [
[
//tax rule for product
'code' => 'Product Tax Rule',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
],
[
//tax rule for shipping
'code' => 'Shipping Tax Rule',
'product_tax_class_ids' => [SetupUtil::SHIPPING_TAX_CLASS],
'tax_rate_ids' => [SetupUtil::TAX_RATE_SHIPPING],
],
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 29,
'qty' => 1,
],
],
'shipping_method' => 'flatrate_flatrate',
'shopping_cart_rules' => [
[
'discount_amount' => 50,
'apply_to_shipping' => 1,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 26.36,
'base_subtotal' => 26.36,
'subtotal_incl_tax' => 29,
'base_subtotal_incl_tax' => 29,
'tax_amount' => 1.69,
'base_tax_amount' => 1.69,
'shipping_amount' => 4.55,
'base_shipping_amount' => 4.55,
'shipping_incl_tax' => 5,
'base_shipping_incl_tax' => 5,
'shipping_tax_amount' => 0.25,
'base_shipping_tax_amount' => 0.25,
'discount_amount' => -15.46,
'base_discount_amount' => -15.46,
'discount_tax_compensation_amount' => 1.2,
'base_discount_tax_compensation_amount' => 1.2,
'shipping_discount_tax_compensation_amount' => 0.2,
'base_shipping_discount_tax_compensation_amount' => 0.2,
'grand_total' => 18.54,
'base_grand_total' => 18.54,
'applied_taxes' => [
SetupUtil::TAX_RATE_TX => [
'percent' => 10,
'amount' => 1.44,
'base_amount' => 1.44,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
'percent' => 10,
],
],
],
SetupUtil::TAX_RATE_SHIPPING => [
'percent' => 10,
'amount' => 0.25,
'base_amount' => 0.25,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_SHIPPING,
'title' => SetupUtil::TAX_RATE_SHIPPING,
'percent' => 10,
],
],
],
],
],
'items_data' => [
'simple1' => [
'row_total' => 26.36,
'base_row_total' => 26.36,
'tax_percent' => 10,
'price' => 26.36,
'base_price' => 26.36,
'price_incl_tax' => 29,
'base_price_incl_tax' => 29,
'row_total_incl_tax' => 29,
'base_row_total_incl_tax' => 29,
'tax_amount' => 1.44,
'base_tax_amount' => 1.44,
'discount_amount' => 13.18,
'base_discount_amount' => 13.18,
'discount_percent' => 50,
'discount_tax_compensation_amount' => 1.2,
'base_discount_tax_compensation_amount' => 1.2,
],
],
],
];
@@ -0,0 +1,87 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['including_tax_cross_border_trade_disabled'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 1,
Config::CONFIG_XML_PATH_CROSS_BORDER_TRADE_ENABLED => 0,
Config::XML_PATH_ALGORITHM => Calculation::CALC_UNIT_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 20,
SetupUtil::TAX_STORE_RATE => 10,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 9.99,
'qty' => 2,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 18.16,
'base_subtotal' => 18.16,
'subtotal_incl_tax' => 21.80,
'base_subtotal_incl_tax' => 21.80,
'tax_amount' => 3.64,
'base_tax_amount' => 3.64,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 21.80,
'base_grand_total' => 21.80,
],
'items_data' => [
'simple1' => [
'row_total' => 18.16,
'base_row_total' => 18.16,
'tax_percent' => 20,
'price' => 9.08,
'base_price' => 9.08,
'price_incl_tax' => 10.90,
'base_price_incl_tax' => 10.90,
'row_total_incl_tax' => 21.80,
'base_row_total_incl_tax' => 21.80,
'tax_amount' => 3.64,
'base_tax_amount' => 3.64,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,87 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['including_tax_cross_border_trade_enabled'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 1,
Config::CONFIG_XML_PATH_CROSS_BORDER_TRADE_ENABLED => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_UNIT_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 20,
SetupUtil::TAX_STORE_RATE => 10,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 9.99,
'qty' => 2,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 16.64,
'base_subtotal' => 16.64,
'subtotal_incl_tax' => 19.98,
'base_subtotal_incl_tax' => 19.98,
'tax_amount' => 3.34,
'base_tax_amount' => 3.34,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 19.98,
'base_grand_total' => 19.98,
],
'items_data' => [
'simple1' => [
'row_total' => 16.64,
'base_row_total' => 16.64,
'tax_percent' => 20,
'price' => 8.32,
'base_price' => 8.32,
'price_incl_tax' => 9.99,
'base_price_incl_tax' => 9.99,
'row_total_incl_tax' => 19.98,
'base_row_total_incl_tax' => 19.98,
'tax_amount' => 3.34,
'base_tax_amount' => 3.34,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,86 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['including_tax_row'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_ROW_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 20,
SetupUtil::TAX_STORE_RATE => 20,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 9.99,
'qty' => 2,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 16.65,
'base_subtotal' => 16.65,
'subtotal_incl_tax' => 19.98,
'base_subtotal_incl_tax' => 19.98,
'tax_amount' => 3.33,
'base_tax_amount' => 3.33,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 19.98,
'base_grand_total' => 19.98,
],
'items_data' => [
'simple1' => [
'row_total' => 16.65,
'base_row_total' => 16.65,
'tax_percent' => 20,
'price' => 8.33,
'base_price' => 8.33,
'price_incl_tax' => 9.99,
'base_price_incl_tax' => 9.99,
'row_total_incl_tax' => 19.98,
'base_row_total_incl_tax' => 19.98,
'tax_amount' => 3.33,
'base_tax_amount' => 3.33,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,86 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['including_tax_total'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_TOTAL_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 20,
SetupUtil::TAX_STORE_RATE => 20,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 9.99,
'qty' => 2,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 16.65,
'base_subtotal' => 16.65,
'subtotal_incl_tax' => 19.98,
'base_subtotal_incl_tax' => 19.98,
'tax_amount' => 3.33,
'base_tax_amount' => 3.33,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 19.98,
'base_grand_total' => 19.98,
],
'items_data' => [
'simple1' => [
'row_total' => 16.65,
'base_row_total' => 16.65,
'tax_percent' => 20,
'price' => 8.33,
'base_price' => 8.33,
'price_incl_tax' => 9.99,
'base_price_incl_tax' => 9.99,
'row_total_incl_tax' => 19.98,
'base_row_total_incl_tax' => 19.98,
'tax_amount' => 3.33,
'base_tax_amount' => 3.33,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,86 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['including_tax_unit'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_UNIT_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 20,
SetupUtil::TAX_STORE_RATE => 20,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 9.99,
'qty' => 2,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 16.64,
'base_subtotal' => 16.64,
'subtotal_incl_tax' => 19.98,
'base_subtotal_incl_tax' => 19.98,
'tax_amount' => 3.34,
'base_tax_amount' => 3.34,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 19.98,
'base_grand_total' => 19.98,
],
'items_data' => [
'simple1' => [
'row_total' => 16.64,
'base_row_total' => 16.64,
'tax_percent' => 20,
'price' => 8.32,
'base_price' => 8.32,
'price_incl_tax' => 9.99,
'base_price_incl_tax' => 9.99,
'row_total_incl_tax' => 19.98,
'base_row_total_incl_tax' => 19.98,
'tax_amount' => 3.34,
'base_tax_amount' => 3.34,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,93 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
$taxCalculationData['including_tax_with_custom_price'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 1,
Config::CONFIG_XML_PATH_APPLY_ON => 0,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 8.25,
SetupUtil::TAX_STORE_RATE => 8.25,
],
SetupUtil::TAX_RULE_OVERRIDES => [
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'items' => [
[
'sku' => 'simple1',
'price' => 16.24,
'qty' => 1,
],
],
'update_items' => [
'simple1' => [
'custom_price' => 14,
'qty' => 1,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 12.93,
'base_subtotal' => 12.93,
'subtotal_incl_tax' => 14,
'base_subtotal_incl_tax' => 14,
'tax_amount' => 1.07,
'base_tax_amount' => 1.07,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 14,
'base_grand_total' => 14,
],
'items_data' => [
'simple1' => [
'row_total' => 12.93,
'base_row_total' => 12.93,
'tax_percent' => 8.25,
'price' => 12.93,
'custom_price' => 12.93,
'original_custom_price' => 14,
'base_price' => 12.93,
'price_incl_tax' => 14,
'base_price_incl_tax' => 14,
'row_total_incl_tax' => 14,
'base_row_total_incl_tax' => 14,
'tax_amount' => 1.07,
'base_tax_amount' => 1.07,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,132 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
/**
* This test case test the scenario where there are two tax rules with different priority
* The calculate_subtotal field is off, the second tax rate will be applied on top of first
* tax rate. This testcases uses total based calculation.
*/
$taxCalculationData['multi_tax_rule_total_calculate_subtotal_no'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_TOTAL_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 7.5,
SetupUtil::TAX_RATE_AUSTIN => 5.5,
],
SetupUtil::TAX_RULE_OVERRIDES => [
[
//tax rule 1 for product
'code' => 'Product Tax Rule TX',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_TX],
'priority' => 1,
],
[
//tax rule 2 for product
'code' => 'Product Tax Rule AUSTIN',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_AUSTIN],
'priority' => 2,
'calculate_subtotal' => 0,
],
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
'tax_postcode' => SetupUtil::AUSTIN_POST_CODE,
],
'items' => [
[
'sku' => 'simple1',
'price' => 1,
'qty' => 10,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 10,
'base_subtotal' => 10,
'subtotal_incl_tax' => 11.34,
'base_subtotal_incl_tax' => 11.34,
'tax_amount' => 1.34,
'base_tax_amount' => 1.34,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 11.34,
'base_grand_total' => 11.34,
'applied_taxes' => [
SetupUtil::TAX_RATE_TX => [
'percent' => 7.5,
'amount' => 0.75,
'base_amount' => 0.75,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
'percent' => 7.5,
],
],
],
SetupUtil::TAX_RATE_AUSTIN => [
'percent' => 5.9125,
'amount' => 0.59,
'base_amount' => 0.59,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_AUSTIN,
'title' => SetupUtil::TAX_RATE_AUSTIN,
'percent' => 5.5,
],
],
],
],
],
'items_data' => [
'simple1' => [
'row_total' => 10,
'base_row_total' => 10,
'tax_percent' => 13.4125,
'price' => 1,
'base_price' => 1,
'price_incl_tax' => 1.13,
'base_price_incl_tax' => 1.13,
'row_total_incl_tax' => 11.34,
'base_row_total_incl_tax' => 11.34,
'tax_amount' => 1.34,
'base_tax_amount' => 1.34,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,132 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
/**
* This test case test the scenario where there are two tax rules with different priority
* The calculate_subtotal field is on, the second tax rate will be applied on subtotal only.
* This testcase uses total based calculation.
*/
$taxCalculationData['multi_tax_rule_total_calculate_subtotal_yes'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_TOTAL_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 7.5,
SetupUtil::TAX_RATE_AUSTIN => 5.5,
],
SetupUtil::TAX_RULE_OVERRIDES => [
[
//tax rule 1 for product
'code' => 'Product Tax Rule TX',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_TX],
'priority' => 1,
],
[
//tax rule 2 for product
'code' => 'Product Tax Rule AUSTIN',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_AUSTIN],
'priority' => 2,
'calculate_subtotal' => 1,
],
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
'tax_postcode' => SetupUtil::AUSTIN_POST_CODE,
],
'items' => [
[
'sku' => 'simple1',
'price' => 1,
'qty' => 10,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 10,
'base_subtotal' => 10,
'subtotal_incl_tax' => 11.3,
'base_subtotal_incl_tax' => 11.3,
'tax_amount' => 1.3,
'base_tax_amount' => 1.3,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 11.3,
'base_grand_total' => 11.3,
'applied_taxes' => [
SetupUtil::TAX_RATE_TX => [
'percent' => 7.5,
'amount' => 0.75,
'base_amount' => 0.75,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
'percent' => 7.5,
],
],
],
SetupUtil::TAX_RATE_AUSTIN => [
'percent' => 5.5,
'amount' => 0.55,
'base_amount' => 0.55,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_AUSTIN,
'title' => SetupUtil::TAX_RATE_AUSTIN,
'percent' => 5.5,
],
],
],
],
],
'items_data' => [
'simple1' => [
'row_total' => 10,
'base_row_total' => 10,
'tax_percent' => 13,
'price' => 1,
'base_price' => 1,
'price_incl_tax' => 1.13,
'base_price_incl_tax' => 1.13,
'row_total_incl_tax' => 11.3,
'base_row_total_incl_tax' => 11.3,
'tax_amount' => 1.3,
'base_tax_amount' => 1.3,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,223 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
/**
* This test case test the scenario where there are two tax rules with different priority
* The calculate_subtotal field is on, the second tax rate will be applied on subtotal only.
* This testcase uses total based calculation.
*/
$taxCalculationData['multi_tax_rule_two_row_calculate_subtotal_yes_row'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_ROW_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 9,
SetupUtil::TAX_RATE_AUSTIN => 5,
],
SetupUtil::TAX_RULE_OVERRIDES => [
[
//tax rule 1 for product
'code' => 'Product Tax Rule TX',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_TX],
'priority' => 1,
],
[
//tax rule 2 for product
'code' => 'Product Tax Rule AUSTIN',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_AUSTIN],
'priority' => 2,
'calculate_subtotal' => 1,
],
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
'tax_postcode' => SetupUtil::AUSTIN_POST_CODE,
],
'items' => [
[
'sku' => 'simple1',
'price' => 10.05,
'qty' => 1,
],
[
'sku' => 'simple2',
'price' => 10.45,
'qty' => 1,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 20.5,
'base_subtotal' => 20.5,
'subtotal_incl_tax' => 23.36,
'base_subtotal_incl_tax' => 23.36,
'tax_amount' => 2.86,
'base_tax_amount' => 2.86,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 23.36,
'base_grand_total' => 23.36,
'applied_taxes' => [
SetupUtil::TAX_RATE_TX => [
'percent' => 9,
'amount' => 1.84,
'base_amount' => 1.84,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
'percent' => 9,
],
],
],
SetupUtil::TAX_RATE_AUSTIN => [
'percent' => 5,
'amount' => 1.02,
'base_amount' => 1.02,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_AUSTIN,
'title' => SetupUtil::TAX_RATE_AUSTIN,
'percent' => 5,
],
],
],
],
],
'items_data' => [
'simple1' => [
'row_total' => 10.05,
'base_row_total' => 10.05,
'tax_percent' => 14,
'price' => 10.05,
'base_price' => 10.05,
'price_incl_tax' => 11.45,
'base_price_incl_tax' => 11.45,
'row_total_incl_tax' => 11.45,
'base_row_total_incl_tax' => 11.45,
'tax_amount' => 1.4,
'base_tax_amount' => 1.4,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'applied_taxes' => [
[
'amount' => 0.9,
'base_amount' => 0.9,
'percent' => 9,
'id' => SetupUtil::TAX_RATE_TX,
'rates' => [
[
'percent' => 9,
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
],
],
'item_id' => null,
'item_type' => 'product',
'associated_item_id' => null,
],
[
'amount' => 0.5,
'base_amount' => 0.5,
'percent' => 5,
'id' => SetupUtil::TAX_RATE_AUSTIN,
'rates' => [
[
'percent' => 5,
'code' => SetupUtil::TAX_RATE_AUSTIN,
'title' => SetupUtil::TAX_RATE_AUSTIN,
],
],
'item_id' => null,
'item_type' => 'product',
'associated_item_id' => null,
],
],
],
'simple2' => [
'row_total' => 10.45,
'base_row_total' => 10.45,
'tax_percent' => 14,
'price' => 10.45,
'base_price' => 10.45,
'price_incl_tax' => 11.91,
'base_price_incl_tax' => 11.91,
'row_total_incl_tax' => 11.91,
'base_row_total_incl_tax' => 11.91,
'tax_amount' => 1.46,
'base_tax_amount' => 1.46,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'applied_taxes' => [
[
'amount' => 0.94,
'base_amount' => 0.94,
'percent' => 9,
'id' => SetupUtil::TAX_RATE_TX,
'rates' => [
[
'percent' => 9,
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
],
],
'item_id' => null,
'item_type' => 'product',
'associated_item_id' => null,
],
[
'amount' => 0.52,
'base_amount' => 0.52,
'percent' => 5,
'id' => SetupUtil::TAX_RATE_AUSTIN,
'rates' => [
[
'percent' => 5,
'code' => SetupUtil::TAX_RATE_AUSTIN,
'title' => SetupUtil::TAX_RATE_AUSTIN,
],
],
'item_id' => null,
'item_type' => 'product',
'associated_item_id' => null,
],
],
],
],
],
];
@@ -0,0 +1,223 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
/**
* This test case test the scenario where there are two tax rules with different priority
* The calculate_subtotal field is on, the second tax rate will be applied on subtotal only.
* This testcase uses total based calculation.
*/
$taxCalculationData['multi_tax_rule_two_row_calculate_subtotal_yes_total'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_TOTAL_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 9,
SetupUtil::TAX_RATE_AUSTIN => 5,
],
SetupUtil::TAX_RULE_OVERRIDES => [
[
//tax rule 1 for product
'code' => 'Product Tax Rule TX',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_TX],
'priority' => 1,
],
[
//tax rule 2 for product
'code' => 'Product Tax Rule AUSTIN',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_AUSTIN],
'priority' => 2,
'calculate_subtotal' => 1,
],
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
'tax_postcode' => SetupUtil::AUSTIN_POST_CODE,
],
'items' => [
[
'sku' => 'simple1',
'price' => 10.05,
'qty' => 1,
],
[
'sku' => 'simple2',
'price' => 10.45,
'qty' => 1,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 20.5,
'base_subtotal' => 20.5,
'subtotal_incl_tax' => 23.38,
'base_subtotal_incl_tax' => 23.38,
'tax_amount' => 2.88,
'base_tax_amount' => 2.88,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 23.38,
'base_grand_total' => 23.38,
'applied_taxes' => [
SetupUtil::TAX_RATE_TX => [
'percent' => 9,
'amount' => 1.85,
'base_amount' => 1.85,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
'percent' => 9,
],
],
],
SetupUtil::TAX_RATE_AUSTIN => [
'percent' => 5,
'amount' => 1.03,
'base_amount' => 1.03,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_AUSTIN,
'title' => SetupUtil::TAX_RATE_AUSTIN,
'percent' => 5,
],
],
],
],
],
'items_data' => [
'simple1' => [
'row_total' => 10.05,
'base_row_total' => 10.05,
'tax_percent' => 14,
'price' => 10.05,
'base_price' => 10.05,
'price_incl_tax' => 11.45,
'base_price_incl_tax' => 11.45,
'row_total_incl_tax' => 11.45,
'base_row_total_incl_tax' => 11.45,
'tax_amount' => 1.40,
'base_tax_amount' => 1.40,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'applied_taxes' => [
[
'amount' => 0.9,
'base_amount' => 0.9,
'percent' => 9,
'id' => SetupUtil::TAX_RATE_TX,
'rates' => [
[
'percent' => 9,
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
],
],
'item_id' => null,
'item_type' => 'product',
'associated_item_id' => null,
],
[
'amount' => 0.5,
'base_amount' => 0.5,
'percent' => 5,
'id' => SetupUtil::TAX_RATE_AUSTIN,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_AUSTIN,
'title' => SetupUtil::TAX_RATE_AUSTIN,
'percent' => 5,
],
],
'item_id' => null,
'item_type' => 'product',
'associated_item_id' => null,
],
],
],
'simple2' => [
'row_total' => 10.45,
'base_row_total' => 10.45,
'tax_percent' => 14,
'price' => 10.45,
'base_price' => 10.45,
'price_incl_tax' => 11.93,
'base_price_incl_tax' => 11.93,
'row_total_incl_tax' => 11.93,
'base_row_total_incl_tax' => 11.93,
'tax_amount' => 1.48,
'base_tax_amount' => 1.48,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'applied_taxes' => [
[
'amount' => 0.95,
'base_amount' => 0.95,
'percent' => 9,
'id' => SetupUtil::TAX_RATE_TX,
'rates' => [
[
'percent' => 9,
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
],
],
'item_id' => null,
'item_type' => 'product',
'associated_item_id' => null,
],
[
'amount' => 0.53,
'base_amount' => 0.53,
'percent' => 5,
'id' => SetupUtil::TAX_RATE_AUSTIN,
'rates' => [
[
'percent' => 5,
'code' => SetupUtil::TAX_RATE_AUSTIN,
'title' => SetupUtil::TAX_RATE_AUSTIN,
],
],
'item_id' => null,
'item_type' => 'product',
'associated_item_id' => null,
],
],
],
],
],
];
@@ -0,0 +1,132 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
/**
* This test case test the scenario where there are two tax rules with different priority
* The calculate_subtotal field is off, the second tax rate will be applied on top of first
* tax rate. This testcase uses unit based calculation.
*/
$taxCalculationData['multi_tax_rule_unit_calculate_subtotal_no'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_UNIT_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 7.5,
SetupUtil::TAX_RATE_AUSTIN => 5.5,
],
SetupUtil::TAX_RULE_OVERRIDES => [
[
//tax rule 1 for product
'code' => 'Product Tax Rule TX',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_TX],
'priority' => 1,
],
[
//tax rule 2 for product
'code' => 'Product Tax Rule AUSTIN',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_AUSTIN],
'priority' => 2,
'calculate_subtotal' => 0,
],
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
'tax_postcode' => SetupUtil::AUSTIN_POST_CODE,
],
'items' => [
[
'sku' => 'simple1',
'price' => 1,
'qty' => 10,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 10,
'base_subtotal' => 10,
'subtotal_incl_tax' => 11.4,
'base_subtotal_incl_tax' => 11.4,
'tax_amount' => 1.4,
'base_tax_amount' => 1.4,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 11.4,
'base_grand_total' => 11.4,
'applied_taxes' => [
SetupUtil::TAX_RATE_TX => [
'percent' => 7.5,
'amount' => 0.8,
'base_amount' => 0.8,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
'percent' => 7.5,
],
],
],
SetupUtil::TAX_RATE_AUSTIN => [
'percent' => 5.9125,
'amount' => 0.6,
'base_amount' => 0.6,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_AUSTIN,
'title' => SetupUtil::TAX_RATE_AUSTIN,
'percent' => 5.5,
],
],
],
],
],
'items_data' => [
'simple1' => [
'row_total' => 10,
'base_row_total' => 10,
'tax_percent' => 13.4125,
'price' => 1,
'base_price' => 1,
'price_incl_tax' => 1.14,
'base_price_incl_tax' => 1.14,
'row_total_incl_tax' => 11.4,
'base_row_total_incl_tax' => 11.4,
'tax_amount' => 1.4,
'base_tax_amount' => 1.4,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];
@@ -0,0 +1,132 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Tax\Model\Calculation;
use Magento\Tax\Model\Config;
use Magento\Tax\Model\Sales\Total\Quote\SetupUtil;
/**
* This test case test the scenario where there are two tax rules with different priority
* The calculate_subtotal field is on, the second tax rate will be applied on subtotal only.
* This testcase uses unit based calculation.
*/
$taxCalculationData['multi_tax_rule_unit_calculate_subtotal_yes'] = [
'config_data' => [
SetupUtil::CONFIG_OVERRIDES => [
Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
Config::XML_PATH_ALGORITHM => Calculation::CALC_UNIT_BASE,
],
SetupUtil::TAX_RATE_OVERRIDES => [
SetupUtil::TAX_RATE_TX => 7.5,
SetupUtil::TAX_RATE_AUSTIN => 5.5,
],
SetupUtil::TAX_RULE_OVERRIDES => [
[
//tax rule 1 for product
'code' => 'Product Tax Rule TX',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_TX],
'priority' => 1,
],
[
//tax rule 2 for product
'code' => 'Product Tax Rule AUSTIN',
'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
'tax_rate_ids' => [SetupUtil::TAX_RATE_AUSTIN],
'priority' => 2,
'calculate_subtotal' => 1,
],
],
],
'quote_data' => [
'billing_address' => [
'region_id' => SetupUtil::REGION_TX,
],
'shipping_address' => [
'region_id' => SetupUtil::REGION_TX,
'tax_postcode' => SetupUtil::AUSTIN_POST_CODE,
],
'items' => [
[
'sku' => 'simple1',
'price' => 1,
'qty' => 10,
],
],
],
'expected_results' => [
'address_data' => [
'subtotal' => 10,
'base_subtotal' => 10,
'subtotal_incl_tax' => 11.4,
'base_subtotal_incl_tax' => 11.4,
'tax_amount' => 1.4,
'base_tax_amount' => 1.4,
'shipping_amount' => 0,
'base_shipping_amount' => 0,
'shipping_incl_tax' => 0,
'base_shipping_incl_tax' => 0,
'shipping_taxable' => 0,
'base_shipping_taxable' => 0,
'shipping_tax_amount' => 0,
'base_shipping_tax_amount' => 0,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
'shipping_discount_tax_compensation_amount' => 0,
'base_shipping_discount_tax_compensation_amount' => 0,
'grand_total' => 11.4,
'base_grand_total' => 11.4,
'applied_taxes' => [
SetupUtil::TAX_RATE_TX => [
'percent' => 7.5,
'amount' => 0.8,
'base_amount' => 0.8,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_TX,
'title' => SetupUtil::TAX_RATE_TX,
'percent' => 7.5,
],
],
],
SetupUtil::TAX_RATE_AUSTIN => [
'percent' => 5.5,
'amount' => 0.6,
'base_amount' => 0.6,
'rates' => [
[
'code' => SetupUtil::TAX_RATE_AUSTIN,
'title' => SetupUtil::TAX_RATE_AUSTIN,
'percent' => 5.5,
],
],
],
],
],
'items_data' => [
'simple1' => [
'row_total' => 10,
'base_row_total' => 10,
'tax_percent' => 13,
'price' => 1,
'base_price' => 1,
'price_incl_tax' => 1.14,
'base_price_incl_tax' => 1.14,
'row_total_incl_tax' => 11.4,
'base_row_total_incl_tax' => 11.4,
'tax_amount' => 1.4,
'base_tax_amount' => 1.4,
'discount_amount' => 0,
'base_discount_amount' => 0,
'discount_percent' => 0,
'discount_tax_compensation_amount' => 0,
'base_discount_tax_compensation_amount' => 0,
],
],
],
];