Skip to content
This repository has been archived by the owner on Aug 1, 2018. It is now read-only.

Commit

Permalink
Fix invoice issue
Browse files Browse the repository at this point in the history
  • Loading branch information
giacmir committed Aug 4, 2017
1 parent 3f02a82 commit fe2d0b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion Block/Sales/Cashondelivery.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

use Magento\Framework\View\Element\Template;
use Magento\Framework\DataObject;
use Magento\Sales\Api\Data\InvoiceInterface;
use Magento\Sales\Api\Data\OrderInterface;
use MSP\CashOnDelivery\Model\Payment;

class Cashondelivery extends Template
Expand All @@ -46,7 +48,8 @@ public function initTotals()
$this->_source = $parent->getSource();
$source = $this->getSource();

if ($source->getPayment()->getMethod() == Payment::CODE) {

if ($this->getPayment($source)->getMethod() == Payment::CODE) {
$fee = new DataObject(
[
'code' => 'msp_cashondelivery',
Expand All @@ -61,4 +64,17 @@ public function initTotals()

return $this;
}

protected function getPayment($source)
{
if($source instanceof InvoiceInterface) {
return $source->getOrder()->getPayment();
}

if($source instanceof OrderInterface) {
return $source;
}


}
}
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="MSP_CashOnDelivery" setup_version="1.1.6">
<module name="MSP_CashOnDelivery" setup_version="1.1.7">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit fe2d0b9

Please sign in to comment.