Skip to content

Commit

Permalink
update buckaroofee
Browse files Browse the repository at this point in the history
  • Loading branch information
vegimcarkaxhija committed Dec 12, 2024
1 parent 4292048 commit becb314
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Model/Method/AbstractMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -2773,8 +2773,8 @@ public function checkTotalGrossAmount($requestData, $payment)
}

return $requestData;

}

public function canUseForCountry($country)
{
if ($this->getConfigData('allowspecific') != 1) {
Expand Down
8 changes: 2 additions & 6 deletions Model/Method/Afterpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,11 +778,8 @@ protected function getTaxCategory($order)
if (!$taxClassId) {
return $taxCategory;
}
/**
* @var \Buckaroo\Magento2\Model\ConfigProvider\Method\Afterpay $afterPayConfig
*/
$afterPayConfig = $this->configProviderMethodFactory
->get($this->_code);

$afterPayConfig = $this->configProviderMethodFactory->get($this->_code);

$highClasses = explode(',', (string)$afterPayConfig->getHighTaxClasses($storeId));
$middleClasses = explode(',', (string)$afterPayConfig->getMiddleTaxClasses($storeId));
Expand All @@ -798,7 +795,6 @@ protected function getTaxCategory($order)
} elseif (in_array($taxClassId, $zeroClasses)) {
$taxCategory = 3;
} else {
// No classes == 4
$taxCategory = 4;
}

Expand Down
22 changes: 2 additions & 20 deletions Model/Total/Quote/Tax/BuckarooFee.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ public function collect(
Total $total
) {
if (!$shippingAssignment->getItems()) {
parent::collect($quote, $shippingAssignment, $total);
return $this;
}

$orderId = $quote->getReservedOrderId();

// Check if already paid amount is affecting the calculation
Expand All @@ -170,30 +170,13 @@ public function collect(
}

$result = $this->calculate->calculatePaymentFee($quote, $total);

if ($result === null){
return $this;
}
$amount = $this->priceCurrency->convert($result->getRoundedAmount());

$this->addAssociatedTaxable($shippingAssignment, $result, $quote);

$feeDataObject = $this->quoteDetailsItemDataObjectFactory->create()
->setType('buckaroo_fee')
->setCode('buckaroo_fee')
->setQuantity(1);

$feeDataObject->setUnitPrice($result->getRoundedAmount());
$feeDataObject->setTaxClassKey(
$this->taxClassKeyDataObjectFactory->create()
->setType(TaxClassKeyInterface::TYPE_ID)
->setValue(4)
);
$feeDataObject->setIsTaxIncluded(true);

$quoteDetails = $this->prepareQuoteDetails($shippingAssignment, [$feeDataObject]);

$this->taxCalculationService->calculateTax($quoteDetails, $quote->getStoreId());

parent::collect($quote, $shippingAssignment, $total);

return $this;
Expand Down Expand Up @@ -225,7 +208,6 @@ private function addAssociatedTaxable(ShippingAssignmentInterface $shippingAssig

// Retrieve the Buckaroo fee tax class ID from BuckarooFeeConfigProvider using the store
$taxClassId = $this->configProviderBuckarooFee->getBuckarooFeeTaxClass($store);

$associatedTaxables[] = [
CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_TYPE => self::QUOTE_TYPE,
CommonTaxCollector::KEY_ASSOCIATED_TAXABLE_CODE => self::CODE_QUOTE_GW,
Expand Down
2 changes: 2 additions & 0 deletions Model/Total/Quote/Tax/BuckarooFeeAfterTax.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ public function collect(
if (empty($extraTaxableDetails[BuckarooFee::QUOTE_TYPE])) {
return $this;
}

$itemTaxDetails = $extraTaxableDetails[BuckarooFee::QUOTE_TYPE];

if (empty($itemTaxDetails[CommonTaxCollector::ASSOCIATION_ITEM_CODE_FOR_QUOTE][0])) {
return $this;
}

$buckarooFeeTaxDetails = $itemTaxDetails[CommonTaxCollector::ASSOCIATION_ITEM_CODE_FOR_QUOTE][0];

$buckarooFeeBaseTaxAmount = $buckarooFeeTaxDetails['base_row_tax'];
Expand Down

0 comments on commit becb314

Please sign in to comment.