Skip to content

Commit

Permalink
Merge pull request #1101 from buckaroo-it/BP-3899-Payment-fee-tax-is-…
Browse files Browse the repository at this point in the history
…not-correct

BP-3899-Payment-fee-tax-is-not-correct
  • Loading branch information
vegimcarkaxhija authored Dec 2, 2024
2 parents bdddf0b + 310c8be commit 6b04d54
Show file tree
Hide file tree
Showing 67 changed files with 1,033 additions and 1,134 deletions.
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

0 comments on commit 6b04d54

Please sign in to comment.