1212class Weee extends \Magento \Sales \Model \Order \Invoice \Total \AbstractTotal
1313{
1414 /**
15- * Weee data
15+ * Weee data object
1616 *
1717 * @var WeeeHelper
1818 */
@@ -177,7 +177,8 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
177177 // If FPT is configured to be included in the subtotal,
178178 // we need to subtract it from the subtotal and the grand total,
179179 // 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 )) {
180+ $ includeInSubtotal = $ this ->_weeeData ->includeInSubtotal ($ store );
181+ if ($ invoice ->isLast () && $ includeInSubtotal ) {
181182 $ invoice ->setSubtotal ($ invoice ->getSubtotal () - $ totalWeeeAmount );
182183 $ invoice ->setBaseSubtotal ($ invoice ->getBaseSubtotal () - $ baseTotalWeeeAmount );
183184 $ invoice ->setGrandTotal ($ invoice ->getGrandTotal () - $ totalWeeeAmountInclTax );
@@ -195,7 +196,7 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
195196 $ invoice ->setBaseTaxAmount ($ invoice ->getBaseTaxAmount () + $ baseTotalWeeeTaxAmount );
196197
197198 // Add FPT to subtotal and grand total
198- if ($ this -> _weeeData -> includeInSubtotal ( $ store ) ) {
199+ if ($ includeInSubtotal ) {
199200 $ order = $ invoice ->getOrder ();
200201 $ allowedSubtotal = $ order ->getSubtotal () - $ order ->getSubtotalInvoiced () - $ invoice ->getSubtotal ();
201202 $ allowedBaseSubtotal = $ order ->getBaseSubtotal () -
@@ -207,7 +208,7 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
207208 $ invoice ->setSubtotal ($ invoice ->getSubtotal () + $ totalWeeeAmount );
208209 $ invoice ->setBaseSubtotal ($ invoice ->getBaseSubtotal () + $ baseTotalWeeeAmount );
209210 }
210-
211+
211212 // need to add the Weee amounts including all their taxes
212213 $ invoice ->setSubtotalInclTax ($ invoice ->getSubtotalInclTax () + $ totalWeeeAmountInclTax );
213214 $ invoice ->setBaseSubtotalInclTax ($ invoice ->getBaseSubtotalInclTax () + $ baseTotalWeeeAmountInclTax );
0 commit comments