File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -988,6 +988,11 @@ public function getFilteredCollectionItems($filter = null)
988
988
public function isLast ()
989
989
{
990
990
foreach ($ this ->getAllItems () as $ item ) {
991
+ $ orderItem = $ item ->getOrderItem ();
992
+ if ($ orderItem ->isDummy ()) {
993
+ continue ;
994
+ }
995
+
991
996
if (!$ item ->isLast ()) {
992
997
return false ;
993
998
}
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
32
32
$ subtotalInclTax = 0 ;
33
33
$ baseSubtotalInclTax = 0 ;
34
34
35
+ $ order = $ creditmemo ->getOrder ();
36
+
35
37
foreach ($ creditmemo ->getAllItems () as $ item ) {
36
38
if ($ item ->getOrderItem ()->isDummy ()) {
37
39
continue ;
@@ -41,8 +43,19 @@ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
41
43
42
44
$ subtotal += $ item ->getRowTotal ();
43
45
$ 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 );
46
59
}
47
60
48
61
$ creditmemo ->setSubtotal ($ subtotal );
Original file line number Diff line number Diff line change 785
785
</row_weight >
786
786
<row_total >
787
787
<to_quote_item >*</to_quote_item >
788
+ <to_invoice_item >*</to_invoice_item >
789
+ <to_cm_item >*</to_cm_item >
788
790
</row_total >
789
791
<applied_rule_ids >
790
792
<to_quote_item >*</to_quote_item >
797
799
</base_tax_amount >
798
800
<base_row_total >
799
801
<to_quote_item >*</to_quote_item >
802
+ <to_invoice_item >*</to_invoice_item >
803
+ <to_cm_item >*</to_cm_item >
800
804
</base_row_total >
801
805
<base_price >
802
806
<to_invoice_item >base_price</to_invoice_item >
You can’t perform that action at this time.
0 commit comments