@@ -174,6 +174,18 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
174174 $ baseTotalWeeeAmountInclTax += $ baseWeeeAmountInclTax ;
175175 }
176176
177+ // If FPT is configured to be included in the subtotal,
178+ // we need to subtract it from the subtotal and the grand total,
179+ // as Collect function from Catalog module knows nothing about FPT and that it is already included in Subtotal
180+ if ($ invoice ->isLast () && $ this ->_weeeData ->includeInSubtotal ($ store )) {
181+ $ invoice ->setSubtotal ($ invoice ->getSubtotal () - $ totalWeeeAmount );
182+ $ invoice ->setBaseSubtotal ($ invoice ->getBaseSubtotal () - $ baseTotalWeeeAmount );
183+ $ invoice ->setGrandTotal ($ invoice ->getGrandTotal () - $ totalWeeeAmountInclTax );
184+ $ invoice ->setBaseGrandTotal ($ invoice ->getBaseGrandTotal () - $ baseTotalWeeeAmountInclTax );
185+ $ invoice ->setTaxAmount ($ invoice ->getTaxAmount () - $ totalWeeeTaxAmount );
186+ $ invoice ->setBaseTaxAmount ($ invoice ->getBaseTaxAmount () - $ baseTotalWeeeTaxAmount );
187+ }
188+
177189 $ allowedTax = $ order ->getTaxAmount () - $ order ->getTaxInvoiced () - $ invoice ->getTaxAmount ();
178190 $ allowedBaseTax = $ order ->getBaseTaxAmount () - $ order ->getBaseTaxInvoiced () - $ invoice ->getBaseTaxAmount ();
179191 $ totalWeeeTaxAmount = min ($ totalWeeeTaxAmount , $ allowedTax );
@@ -200,7 +212,6 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
200212 // need to add the Weee amounts including all their taxes
201213 $ invoice ->setSubtotalInclTax ($ invoice ->getSubtotalInclTax () + $ totalWeeeAmountInclTax );
202214 $ invoice ->setBaseSubtotalInclTax ($ invoice ->getBaseSubtotalInclTax () + $ baseTotalWeeeAmountInclTax );
203- } else {
204215 // since the Subtotal Incl Tax line will already have the taxes on Weee, just add the non-taxable amounts
205216 $ invoice ->setSubtotalInclTax ($ invoice ->getSubtotalInclTax () + $ totalWeeeAmount );
206217 $ invoice ->setBaseSubtotalInclTax ($ invoice ->getBaseSubtotalInclTax () + $ baseTotalWeeeAmount );
0 commit comments