Skip to content

Commit 3ff27c2

Browse files
author
Mike Weis
committed
MAGETWO-31118: Subtotal Including Tax on invoice is discounted
- fixed
1 parent 1be6ca1 commit 3ff27c2

File tree

1 file changed

+2
-33
lines changed
  • app/code/Magento/Sales/Model/Order/Invoice/Total

1 file changed

+2
-33
lines changed

app/code/Magento/Sales/Model/Order/Invoice/Total/Subtotal.php

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,46 +36,15 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
3636

3737
$allowedSubtotal = $order->getSubtotal() - $order->getSubtotalInvoiced();
3838
$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.
6841

6942
if ($invoice->isLast()) {
7043
$subtotal = $allowedSubtotal;
7144
$baseSubtotal = $baseAllowedSubtotal;
72-
$subtotalInclTax = $allowedSubtotalInclTax;
73-
$baseSubtotalInclTax = $baseAllowedSubtotalInclTax;
7445
} else {
7546
$subtotal = min($allowedSubtotal, $subtotal);
7647
$baseSubtotal = min($baseAllowedSubtotal, $baseSubtotal);
77-
$subtotalInclTax = min($allowedSubtotalInclTax, $subtotalInclTax);
78-
$baseSubtotalInclTax = min($baseAllowedSubtotalInclTax, $baseSubtotalInclTax);
7948
}
8049

8150
$invoice->setSubtotal($subtotal);

0 commit comments

Comments
 (0)