Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BP-3899-Payment-fee-tax-is-not-correct #1101

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions Block/Adminhtml/Sales/Totals.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,9 @@ public function __construct(
public function initTotals()
{
$parent = $this->getParentBlock();
/**
* @noinspection PhpUndefinedMethodInspection
*/
$source = $parent->getSource();
$totals = $this->getTotalsForCreditmemo($source);
foreach ($totals as $total) {
/**
* @noinspection PhpUndefinedMethodInspection
*/
$this->getParentBlock()->addTotalBefore(new \Magento\Framework\DataObject($total), 'grand_total');
}
return $this;
Expand All @@ -72,12 +66,9 @@ public function initTotals()
public function getTotals()
{
$parent = $this->getParentBlock();
/**
* @noinspection PhpUndefinedMethodInspection
*/
$source = $parent->getSource();


return $this->getTotalsForCreditmemo($source);
}

Expand All @@ -92,7 +83,7 @@ public function getCurrentCurrencySymbol()
}

/**
* For credit memo display the fees from invoice/order,
* For credit memo display the fees from invoice/order,
* check if invoice has that fee and set selected
*
* @param mixed $source
Expand All @@ -107,7 +98,7 @@ protected function getTotalsForCreditmemo($source)
$invoice = $source->getInvoice();
$salesModel = ($invoice != null? $invoice : $order);
$saleTotals = $this->helper->getTotals($salesModel);

$saleTotals = array_map(function($saleTotal) use($creditTotals) {
if (in_array($saleTotal['code'],['buckaroo_fee', 'buckaroo_fee_excl'] )) {
$saleTotal['block_name'] = "buckaroo_fee";
Expand All @@ -116,12 +107,12 @@ protected function getTotalsForCreditmemo($source)
return $saleTotal;
}, $saleTotals);


return array_merge(
$this->getTotalsByCode($creditTotals, 'buckaroo_already_paid'),
$this->getTotalsExceptCode($saleTotals, 'buckaroo_already_paid')
);

}
return $this->helper->getTotals($source);
}
Expand Down
50 changes: 36 additions & 14 deletions Block/Cart/BuckarooConfig.php
Original file line number Diff line number Diff line change
@@ -1,37 +1,58 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* https://tldrlegal.com/license/mit-license
* If you are unable to obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact [email protected] for more information.
*
* @copyright Copyright (c) Buckaroo B.V.
* @license https://tldrlegal.com/license/mit-license
*/

namespace Buckaroo\Magento2\Block\Cart;

class BuckarooConfig extends \Magento\Backend\Block\Template
use Buckaroo\Magento2\Exception;
use Buckaroo\Magento2\Model\ConfigProvider\Factory;
use Magento\Backend\Block\Template;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Serialize\Serializer\Json;

class BuckarooConfig extends Template
{
/**
* @var bool
*/
protected $_isScopePrivate = false;

/**
* @var \Buckaroo\Magento2\Model\ConfigProvider\Factory
* @var Factory
*/
protected $configProviderFactory;

/**
* @var \Magento\Framework\Json\Encoder
* @var Json
*/
protected $jsonEncoder;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Json\Encoder $jsonEncoder
* @param \Buckaroo\Magento2\Model\ConfigProvider\Factory $configProviderFactory
* @param array $data
* @param Context $context
* @param Json $jsonEncoder
* @param Factory $configProviderFactory
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Json\Encoder $jsonEncoder,
\Buckaroo\Magento2\Model\ConfigProvider\Factory $configProviderFactory,
Context $context,
Json $jsonEncoder,
Factory $configProviderFactory,
array $data = []
) {
parent::__construct($context, $data);
Expand All @@ -42,11 +63,12 @@ public function __construct(
/**
* Retrieve buckaroo configuration
*
* @return array
* @return string
* @throws Exception
*/
public function getBuckarooConfigJson()
{
$configProvider = $this->configProviderFactory->get('buckaroo_fee');
return $this->jsonEncoder->encode($configProvider->getConfig());
return $this->jsonEncoder->serialize($configProvider->getConfig());
}
}
5 changes: 5 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ public function getOriginalTransactionKey($orderId)
return $this->groupTransaction->getGroupTransactionOriginalTransactionKey($orderId);
}

public function getAlreadyPaid()
{
return $this->groupTransaction->getAlreadyPaid($this->getOrderId());
}

public function getOrderId()
{
$orderId = $this->_checkoutSession->getQuote()->getReservedOrderId();
Expand Down
Loading
Loading