@@ -36,46 +36,15 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
36
36
37
37
$ allowedSubtotal = $ order ->getSubtotal () - $ order ->getSubtotalInvoiced ();
38
38
$ baseAllowedSubtotal = $ order ->getBaseSubtotal () - $ order ->getBaseSubtotalInvoiced ();
39
- $ allowedSubtotalInclTax = $ allowedSubtotal +
40
- $ order ->getHiddenTaxAmount () +
41
- $ order ->getTaxAmount () -
42
- $ order ->getTaxInvoiced () -
43
- $ order ->getHiddenTaxInvoiced ();
44
- $ baseAllowedSubtotalInclTax = $ baseAllowedSubtotal +
45
- $ order ->getBaseHiddenTaxAmount () +
46
- $ order ->getBaseTaxAmount () -
47
- $ order ->getBaseTaxInvoiced () -
48
- $ order ->getBaseHiddenTaxInvoiced ();
49
-
50
- /**
51
- * Check if shipping tax calculation is included to current invoice.
52
- */
53
- $ includeShippingTax = true ;
54
- foreach ($ invoice ->getOrder ()->getInvoiceCollection () as $ previousInvoice ) {
55
- if ($ previousInvoice ->getShippingAmount () && !$ previousInvoice ->isCanceled ()) {
56
- $ includeShippingTax = false ;
57
- break ;
58
- }
59
- }
60
-
61
- if ($ includeShippingTax ) {
62
- $ allowedSubtotalInclTax -= $ order ->getShippingTaxAmount ();
63
- $ baseAllowedSubtotalInclTax -= $ order ->getBaseShippingTaxAmount ();
64
- } else {
65
- $ allowedSubtotalInclTax += $ order ->getShippingHiddenTaxAmount ();
66
- $ baseAllowedSubtotalInclTax += $ order ->getBaseShippingHiddenTaxAmount ();
67
- }
39
+ //Note: The $subtotalInclTax and $baseSubtotalInclTax are not adjusted from those provide by the line items
40
+ //because the "InclTax" is displayed before any tax adjustments based on discounts, shipping, etc.
68
41
69
42
if ($ invoice ->isLast ()) {
70
43
$ subtotal = $ allowedSubtotal ;
71
44
$ baseSubtotal = $ baseAllowedSubtotal ;
72
- $ subtotalInclTax = $ allowedSubtotalInclTax ;
73
- $ baseSubtotalInclTax = $ baseAllowedSubtotalInclTax ;
74
45
} else {
75
46
$ subtotal = min ($ allowedSubtotal , $ subtotal );
76
47
$ baseSubtotal = min ($ baseAllowedSubtotal , $ baseSubtotal );
77
- $ subtotalInclTax = min ($ allowedSubtotalInclTax , $ subtotalInclTax );
78
- $ baseSubtotalInclTax = min ($ baseAllowedSubtotalInclTax , $ baseSubtotalInclTax );
79
48
}
80
49
81
50
$ invoice ->setSubtotal ($ subtotal );
0 commit comments