diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml
index 0166d15e226c..5ed2bd5f75c0 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/SaveProductWithCustomOptionsSecondWebsiteTest.xml
@@ -34,6 +34,7 @@
+
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/ConfigSalesTaxClassActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/ConfigSalesTaxClassActionGroup.xml
new file mode 100644
index 000000000000..7bb2441a6a52
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/ConfigSalesTaxClassActionGroup.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml
index e517f6ef62c7..c24e578c9109 100644
--- a/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml
+++ b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigPage.xml
@@ -12,4 +12,7 @@
+
+
+
diff --git a/app/code/Magento/Config/Test/Mftf/Section/SalesConfigSection.xml b/app/code/Magento/Config/Test/Mftf/Section/SalesConfigSection.xml
new file mode 100644
index 000000000000..f1520f5813e6
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/Section/SalesConfigSection.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Discount.php b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Discount.php
index bb173f401031..0cc4143e569d 100644
--- a/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Discount.php
+++ b/app/code/Magento/Sales/Model/Order/Creditmemo/Total/Discount.php
@@ -25,7 +25,7 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
* Calculate how much shipping discount should be applied
* basing on how much shipping should be refunded.
*/
- $baseShippingAmount = (float)$creditmemo->getBaseShippingAmount();
+ $baseShippingAmount = $this->getBaseShippingAmount($creditmemo);
if ($baseShippingAmount) {
$baseShippingDiscount = $baseShippingAmount *
$order->getBaseShippingDiscountAmount() /
@@ -75,4 +75,21 @@ public function collect(\Magento\Sales\Model\Order\Creditmemo $creditmemo)
$creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() - $baseTotalDiscountAmount);
return $this;
}
+
+ /**
+ * Get base shipping amount
+ *
+ * @param \Magento\Sales\Model\Order\Creditmemo $creditmemo
+ * @return float
+ */
+ private function getBaseShippingAmount(\Magento\Sales\Model\Order\Creditmemo $creditmemo): float
+ {
+ $baseShippingAmount = (float)$creditmemo->getBaseShippingAmount();
+ if (!$baseShippingAmount) {
+ $baseShippingInclTax = (float)$creditmemo->getBaseShippingInclTax();
+ $baseShippingTaxAmount = (float)$creditmemo->getBaseShippingTaxAmount();
+ $baseShippingAmount = $baseShippingInclTax - $baseShippingTaxAmount;
+ }
+ return $baseShippingAmount;
+ }
}
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml
new file mode 100644
index 000000000000..26139f7182ba
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Mftf/Test/CreditMemoTotalAfterShippingDiscountTest.xml
@@ -0,0 +1,136 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php
index 2531a26321d6..18efef38b204 100644
--- a/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/DiscountTest.php
@@ -48,7 +48,7 @@ protected function setUp()
]);
$this->creditmemoMock = $this->createPartialMock(\Magento\Sales\Model\Order\Creditmemo::class, [
'setBaseCost', 'getAllItems', 'getOrder', 'getBaseShippingAmount', 'roundPrice',
- 'setDiscountAmount', 'setBaseDiscountAmount'
+ 'setDiscountAmount', 'setBaseDiscountAmount', 'getBaseShippingInclTax', 'getBaseShippingTaxAmount'
]);
$this->creditmemoItemMock = $this->createPartialMock(\Magento\Sales\Model\Order\Creditmemo\Item::class, [
'getHasChildren', 'getBaseCost', 'getQty', 'getOrderItem', 'setDiscountAmount',
@@ -127,6 +127,82 @@ public function testCollect()
$this->assertEquals($this->total, $this->total->collect($this->creditmemoMock));
}
+ public function testCollectNoBaseShippingAmount()
+ {
+ $this->creditmemoMock->expects($this->exactly(2))
+ ->method('setDiscountAmount')
+ ->willReturnSelf();
+ $this->creditmemoMock->expects($this->exactly(2))
+ ->method('setBaseDiscountAmount')
+ ->willReturnSelf();
+ $this->creditmemoMock->expects($this->once())
+ ->method('getOrder')
+ ->willReturn($this->orderMock);
+ $this->creditmemoMock->expects($this->once())
+ ->method('getBaseShippingAmount')
+ ->willReturn(0);
+ $this->creditmemoMock->expects($this->once())
+ ->method('getBaseShippingInclTax')
+ ->willReturn(1);
+ $this->creditmemoMock->expects($this->once())
+ ->method('getBaseShippingTaxAmount')
+ ->willReturn(0);
+ $this->orderMock->expects($this->once())
+ ->method('getBaseShippingDiscountAmount')
+ ->willReturn(1);
+ $this->orderMock->expects($this->exactly(2))
+ ->method('getBaseShippingAmount')
+ ->willReturn(1);
+ $this->orderMock->expects($this->once())
+ ->method('getShippingAmount')
+ ->willReturn(1);
+ $this->creditmemoMock->expects($this->once())
+ ->method('getAllItems')
+ ->willReturn([$this->creditmemoItemMock]);
+ $this->creditmemoItemMock->expects($this->atLeastOnce())
+ ->method('getOrderItem')
+ ->willReturn($this->orderItemMock);
+ $this->orderItemMock->expects($this->once())
+ ->method('isDummy')
+ ->willReturn(false);
+ $this->orderItemMock->expects($this->once())
+ ->method('getDiscountInvoiced')
+ ->willReturn(1);
+ $this->orderItemMock->expects($this->once())
+ ->method('getBaseDiscountInvoiced')
+ ->willReturn(1);
+ $this->orderItemMock->expects($this->once())
+ ->method('getQtyInvoiced')
+ ->willReturn(1);
+ $this->orderItemMock->expects($this->once())
+ ->method('getDiscountRefunded')
+ ->willReturn(1);
+ $this->orderItemMock->expects($this->once())
+ ->method('getQtyRefunded')
+ ->willReturn(0);
+ $this->creditmemoItemMock->expects($this->once())
+ ->method('isLast')
+ ->willReturn(false);
+ $this->creditmemoItemMock->expects($this->atLeastOnce())
+ ->method('getQty')
+ ->willReturn(1);
+ $this->creditmemoItemMock->expects($this->exactly(1))
+ ->method('setDiscountAmount')
+ ->willReturnSelf();
+ $this->creditmemoItemMock->expects($this->exactly(1))
+ ->method('setBaseDiscountAmount')
+ ->willReturnSelf();
+ $this->creditmemoMock->expects($this->exactly(2))
+ ->method('roundPrice')
+ ->willReturnMap(
+ [
+ [1, 'regular', true, 1],
+ [1, 'base', true, 1]
+ ]
+ );
+ $this->assertEquals($this->total, $this->total->collect($this->creditmemoMock));
+ }
+
public function testCollectZeroShipping()
{
$this->creditmemoMock->expects($this->exactly(2))
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml
index 87408aac2c0c..f31ff1a45689 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml
@@ -25,6 +25,8 @@
+
+