Skip to content

Commit 592bd66

Browse files
committed
Bugfix for refund bundle items
1 parent 620f078 commit 592bd66

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

app/code/core/Mage/Sales/Model/Order/Creditmemo.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,11 @@ public function getFilteredCollectionItems($filter = null)
988988
public function isLast()
989989
{
990990
foreach ($this->getAllItems() as $item) {
991+
$orderItem = $item->getOrderItem();
992+
if ($orderItem->isDummy()) {
993+
continue;
994+
}
995+
991996
if (!$item->isLast()) {
992997
return false;
993998
}

app/code/core/Mage/Sales/Model/Order/Creditmemo/Total/Subtotal.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
3232
$subtotalInclTax = 0;
3333
$baseSubtotalInclTax = 0;
3434

35+
$order = $creditmemo->getOrder();
36+
3537
foreach ($creditmemo->getAllItems() as $item) {
3638
if ($item->getOrderItem()->isDummy()) {
3739
continue;
@@ -41,8 +43,19 @@ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
4143

4244
$subtotal += $item->getRowTotal();
4345
$baseSubtotal += $item->getBaseRowTotal();
44-
$subtotalInclTax += $item->getRowTotalInclTax();
45-
$baseSubtotalInclTax += $item->getBaseRowTotalInclTax();
46+
$subtotalInclTax += $item->getRowTotalInclTax() + $item->getWeeeTaxAppliedRowAmount();
47+
$baseSubtotalInclTax += $item->getBaseRowTotalInclTax() + $item->getBaseWeeeTaxAppliedRowAmount();
48+
}
49+
50+
$allowedSubtotal = $order->getSubtotal() - $order->getSubtotalRefunded();
51+
$baseAllowedSubtotal = $order->getBaseSubtotal() - $order->getBaseSubtotalRefunded();
52+
53+
if ($creditmemo->isLast()) {
54+
$subtotal = $allowedSubtotal;
55+
$baseSubtotal = $baseAllowedSubtotal;
56+
} else {
57+
$subtotal = min($allowedSubtotal, $subtotal);
58+
$baseSubtotal = min($baseAllowedSubtotal, $baseSubtotal);
4659
}
4760

4861
$creditmemo->setSubtotal($subtotal);

app/code/core/Mage/Sales/etc/config.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,8 @@
785785
</row_weight>
786786
<row_total>
787787
<to_quote_item>*</to_quote_item>
788+
<to_invoice_item>*</to_invoice_item>
789+
<to_cm_item>*</to_cm_item>
788790
</row_total>
789791
<applied_rule_ids>
790792
<to_quote_item>*</to_quote_item>
@@ -797,6 +799,8 @@
797799
</base_tax_amount>
798800
<base_row_total>
799801
<to_quote_item>*</to_quote_item>
802+
<to_invoice_item>*</to_invoice_item>
803+
<to_cm_item>*</to_cm_item>
800804
</base_row_total>
801805
<base_price>
802806
<to_invoice_item>base_price</to_invoice_item>

0 commit comments

Comments
 (0)