12
12
class Weee extends \Magento \Sales \Model \Order \Invoice \Total \AbstractTotal
13
13
{
14
14
/**
15
- * Weee data
15
+ * Weee data object
16
16
*
17
17
* @var WeeeHelper
18
18
*/
@@ -177,7 +177,8 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
177
177
// If FPT is configured to be included in the subtotal,
178
178
// we need to subtract it from the subtotal and the grand total,
179
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 )) {
180
+ $ includeInSubtotal = $ this ->_weeeData ->includeInSubtotal ($ store );
181
+ if ($ invoice ->isLast () && $ includeInSubtotal ) {
181
182
$ invoice ->setSubtotal ($ invoice ->getSubtotal () - $ totalWeeeAmount );
182
183
$ invoice ->setBaseSubtotal ($ invoice ->getBaseSubtotal () - $ baseTotalWeeeAmount );
183
184
$ invoice ->setGrandTotal ($ invoice ->getGrandTotal () - $ totalWeeeAmountInclTax );
@@ -195,7 +196,7 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
195
196
$ invoice ->setBaseTaxAmount ($ invoice ->getBaseTaxAmount () + $ baseTotalWeeeTaxAmount );
196
197
197
198
// Add FPT to subtotal and grand total
198
- if ($ this -> _weeeData -> includeInSubtotal ( $ store ) ) {
199
+ if ($ includeInSubtotal ) {
199
200
$ order = $ invoice ->getOrder ();
200
201
$ allowedSubtotal = $ order ->getSubtotal () - $ order ->getSubtotalInvoiced () - $ invoice ->getSubtotal ();
201
202
$ allowedBaseSubtotal = $ order ->getBaseSubtotal () -
@@ -207,7 +208,7 @@ public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
207
208
$ invoice ->setSubtotal ($ invoice ->getSubtotal () + $ totalWeeeAmount );
208
209
$ invoice ->setBaseSubtotal ($ invoice ->getBaseSubtotal () + $ baseTotalWeeeAmount );
209
210
}
210
-
211
+
211
212
// need to add the Weee amounts including all their taxes
212
213
$ invoice ->setSubtotalInclTax ($ invoice ->getSubtotalInclTax () + $ totalWeeeAmountInclTax );
213
214
$ invoice ->setBaseSubtotalInclTax ($ invoice ->getBaseSubtotalInclTax () + $ baseTotalWeeeAmountInclTax );
0 commit comments