public function collect(\Magento\Sales\Model\Order\Invoice $invoice)
 {
     parent::collect($invoice);
     $orderId = $invoice->getOrderId();
     $found = $this->repoPartialSale->getById($orderId);
     if ($found) {
         $partial = $found->getPartialAmount();
         $partialBase = $found->getBasePartialAmount();
         $grand = $invoice->getGrandTotal();
         $grandBase = $invoice->getBaseGrandTotal();
         $grandFixed = $grand - $partial;
         $grandFixedBase = $grandBase - $partialBase;
         $invoice->setGrandTotal($grandFixed);
         $invoice->setBaseGrandTotal($grandFixedBase);
         $invoice->setData(Cfg::CODE_TOTAL_PARTIAL_AMOUNT, $partial);
         $invoice->setData(Cfg::CODE_TOTAL_PARTIAL_AMOUNT_BASE, $partialBase);
     }
     return $this;
 }
Example #2
0
 /**
  * Constructor
  *
  * By default is looking for first argument as array and assigns it as object
  * attributes This behavior may change in child classes
  *
  * @param \Magento\Weee\Helper\Data $weeeData
  * @param array                     $data
  */
 public function __construct(\Magento\Weee\Helper\Data $weeeData, array $data = [])
 {
     $this->_weeeData = $weeeData;
     parent::__construct($data);
 }