-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from magmodules/release/1.20.0
Release/1.20.0
- Loading branch information
Showing
16 changed files
with
580 additions
and
453 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* Copyright © Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magmodules\Channable\Plugin; | ||
|
||
use Magento\Sales\Model\Order\Invoice; | ||
|
||
class AddDiscountToInvoice | ||
{ | ||
/** | ||
* Add channable discount total to the invoice. | ||
* | ||
* @param Invoice $invoice | ||
* @param callable $proceed | ||
* @return void | ||
*/ | ||
public function aroundCollectTotals(Invoice $invoice, callable $proceed) | ||
{ | ||
$invoice = $proceed(); | ||
|
||
$order = $invoice->getOrder(); | ||
if ($order->getPayment()->getMethod() == 'channable') { | ||
$discountAmount = abs((float)$order->getDiscountAmount()); | ||
if ($discountAmount > 0) { | ||
$invoice->setDiscountAmount(-$discountAmount); | ||
$invoice->setBaseDiscountAmount(-$discountAmount); | ||
$invoice->setGrandTotal($invoice->getGrandTotal() - $discountAmount); | ||
$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() - $discountAmount); | ||
} | ||
} | ||
|
||
return $invoice; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,7 +174,6 @@ public function getTestData(array $params): array | |
"middle_name" => "From", | ||
"last_name" => "Channable", | ||
"company" => "Do Not Ship", | ||
"vat_id" => 'NL0001', | ||
"email" => "[email protected]", | ||
"address_line_1" => "Billing Line 1", | ||
"address_line_2" => "Billing Line 2", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.