Skip to content

Commit d32646f

Browse files
committed
AC-7901: Can't create credit memo - free shipping related
1 parent a047c76 commit d32646f

File tree

2 files changed

+63
-2
lines changed
  • app/code/Magento/Sales

2 files changed

+63
-2
lines changed

app/code/Magento/Sales/Model/Order/Creditmemo/Total/Tax.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ public function collect(Creditmemo $creditmemo)
134134
$baseShippingDiscountTaxCompensationAmount = 0;
135135
$shippingDelta = $baseOrderShippingAmount - $baseOrderShippingRefundedAmount;
136136

137-
if ($shippingDelta > $creditmemo->getBaseShippingAmount() ||
138-
$this->isShippingIncludeTaxWithTaxAfterDiscount($order->getStoreId())) {
137+
if ($orderShippingAmount > 0 && ($shippingDelta > $creditmemo->getBaseShippingAmount() ||
138+
$this->isShippingIncludeTaxWithTaxAfterDiscount($order->getStoreId()))) {
139139
$part = $creditmemo->getShippingAmount() / $orderShippingAmount;
140140
$basePart = $creditmemo->getBaseShippingAmount() / $baseOrderShippingAmount;
141141
$shippingTaxAmount = $order->getShippingTaxAmount() * $part;

app/code/Magento/Sales/Test/Unit/Model/Order/Creditmemo/Total/TaxTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,67 @@ public function collectDataProvider()
806806
],
807807
];
808808

809+
// scenario 8: 1 items, 1 invoiced, shipping covered by cart rule
810+
// shipping amount is 0 i.e., free shipping
811+
$result['creditmemo_with_discount_for_entire_shipping_all_prices_including_tax_free_shipping'] = [
812+
'order_data' => [
813+
'data_fields' => [
814+
'shipping_tax_amount' => 0,
815+
'base_shipping_tax_amount' => 0,
816+
'shipping_discount_tax_compensation_amount' => 1.36,
817+
'base_shipping_discount_tax_compensation_amount' => 1.36,
818+
'tax_amount' => 1.22,
819+
'base_tax_amount' => 1.22,
820+
'tax_invoiced' => 1.22,
821+
'base_tax_invoiced' => 1.22,
822+
'shipping_amount' => 0,
823+
'shipping_discount_amount' => 15,
824+
'base_shipping_amount' => 13.64,
825+
'discount_tax_compensation_invoiced' => 1.73,
826+
'base_discount_tax_compensation_invoiced' => 1.73
827+
],
828+
],
829+
'creditmemo_data' => [
830+
'items' => [
831+
'item_1' => [
832+
'order_item' => [
833+
'qty_invoiced' => 1,
834+
'tax_invoiced' => 1.22,
835+
'base_tax_invoiced' => 1.22,
836+
'discount_tax_compensation_amount' => 1.73,
837+
'base_discount_tax_compensation_amount' => 1.73,
838+
'discount_tax_compensation_invoiced' => 1.73,
839+
'base_discount_tax_compensation_invoiced' => 1.73
840+
],
841+
'is_last' => true,
842+
'qty' => 1,
843+
],
844+
],
845+
'is_last' => true,
846+
'data_fields' => [
847+
'shipping_amount' => 0,
848+
'base_shipping_amount' => 0,
849+
'grand_total' => 10.45,
850+
'base_grand_total' => 10.45,
851+
'tax_amount' => 0,
852+
'base_tax_amount' => 0
853+
],
854+
],
855+
'expected_results' => [
856+
'creditmemo_items' => [
857+
'item_1' => [
858+
'tax_amount' => 1.22,
859+
'base_tax_amount' => 1.22,
860+
],
861+
],
862+
'creditmemo_data' => [
863+
'grand_total' => 14.76,
864+
'base_grand_total' => 13.4,
865+
'tax_amount' => 1.22,
866+
'base_tax_amount' => 1.22,
867+
],
868+
],
869+
];
809870
return $result;
810871
}
811872

0 commit comments

Comments
 (0)