Skip to content

Commit

Permalink
PIPREs-269: Tax rounding issue improvements (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
mandan2 authored Jul 18, 2023
1 parent 968c174 commit 9b14253
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
8 changes: 4 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Changelog #

## Changes in release 5.4.1 ##
+ Fixed order state duplication on install when single shop instance/ multishop instances were switched during module usage.
+ Added environment based settings support for iframe, single click payment and mollie issuers settings.
+ Improved payment fee handling. Added support to select tax rule for payment fee. Improved logic to append fee taxes to the order totals.
+ Improved auto-shipping functionality with better error/message handling.
+ Fixed payment fee tax problems and improved fee set-up process.
+ Sync Mollie components and Single click flag to the environment selected.
+ Overall improvements and bug fixes.
+ Fixed order state duplication on install when single shop instance/multishop instances were switched during module usage. Reset your module to remove any duplicates.

## Changes in release 5.4.0 ##
+ Fixed issue where saving wrong API key would reset settings page.
Expand Down
4 changes: 2 additions & 2 deletions controllers/admin/AdminMollieAjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ private function updateFixedPaymentFeePrice()
'error' => false,
'paymentFeeTaxIncl' => NumberUtility::toPrecision(
$paymentFeeTaxIncl,
$context->getComputingPrecision()
NumberUtility::FLOAT_PRECISION
),
'paymentFeeTaxExcl' => NumberUtility::toPrecision(
$paymentFeeTaxExcl,
$context->getComputingPrecision()
NumberUtility::FLOAT_PRECISION
),
])
);
Expand Down
13 changes: 12 additions & 1 deletion mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ public function hookPaymentOptions($params)
if (version_compare(_PS_VERSION_, '1.7.0.0', '<')) {
return [];
}

$paymentOptions = [];

/** @var PaymentMethodRepositoryInterface $paymentMethodRepository */
Expand All @@ -584,6 +585,9 @@ public function hookPaymentOptions($params)
/** @var \Mollie\Service\PaymentMethodService $paymentMethodService */
$paymentMethodService = $this->getMollieContainer(\Mollie\Service\PaymentMethodService::class);

/** @var PrestaLoggerInterface $logger */
$logger = $this->getMollieContainer(PrestaLoggerInterface::class);

$methods = $paymentMethodService->getMethodsForCheckout();

foreach ($methods as $method) {
Expand All @@ -594,7 +598,14 @@ public function hookPaymentOptions($params)
continue;
}
$paymentMethod->method_name = $method['method_name'];
$paymentOptions[] = $paymentOptionsHandler->handle($paymentMethod);

try {
$paymentOptions[] = $paymentOptionsHandler->handle($paymentMethod);
} catch (Exception $exception) {
// TODO handle payment fee exception and other exceptions with custom exception throw

$logger->error($exception->getMessage());
}
}

return $paymentOptions;
Expand Down
18 changes: 9 additions & 9 deletions src/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ public function getMethodsForConfig(MollieApiClient $api)
'minimumAmount' => $apiMethod->minimumAmount ? [
'value' => NumberUtility::toPrecision(
$apiMethod->minimumAmount->value,
$this->context->getComputingPrecision()
NumberUtility::FLOAT_PRECISION
),
'currency' => $apiMethod->minimumAmount->currency,
] : false,
'maximumAmount' => $apiMethod->maximumAmount ? [
'value' => NumberUtility::toPrecision(
$apiMethod->maximumAmount->value,
$this->context->getComputingPrecision()
NumberUtility::FLOAT_PRECISION
),
'currency' => $apiMethod->maximumAmount->currency,
] : false,
Expand Down Expand Up @@ -213,12 +213,12 @@ private function getMethodsObjForConfig($apiMethods)

$paymentMethod->surcharge_fixed_amount_tax_excl = NumberUtility::toPrecision(
$paymentMethod->surcharge_fixed_amount_tax_excl,
$this->context->getComputingPrecision()
NumberUtility::FLOAT_PRECISION
);

$apiMethod['surcharge_fixed_amount_tax_incl'] = NumberUtility::toPrecision(
$apiMethod['surcharge_fixed_amount_tax_incl'],
$this->context->getComputingPrecision()
NumberUtility::FLOAT_PRECISION
);
}

Expand Down Expand Up @@ -425,30 +425,30 @@ private function getSurchargeFixedAmountTaxInclPrice(float $priceTaxExcl, int $t

return NumberUtility::toPrecision(
$taxCalculator->addTaxes($priceTaxExcl),
$this->context->getComputingPrecision()
NumberUtility::FLOAT_PRECISION
);
}

private function toPrecisionForDecimalNumbers(MolPaymentMethod $paymentMethod): MolPaymentMethod
{
$paymentMethod->surcharge_percentage = (string) NumberUtility::toPrecision(
(float) $paymentMethod->surcharge_percentage,
$this->context->getComputingPrecision()
NumberUtility::FLOAT_PRECISION
);

$paymentMethod->surcharge_limit = (string) NumberUtility::toPrecision(
(float) $paymentMethod->surcharge_limit,
$this->context->getComputingPrecision()
NumberUtility::FLOAT_PRECISION
);

$paymentMethod->min_amount = NumberUtility::toPrecision(
$paymentMethod->min_amount,
$this->context->getComputingPrecision()
NumberUtility::FLOAT_PRECISION
);

$paymentMethod->max_amount = NumberUtility::toPrecision(
$paymentMethod->max_amount,
$this->context->getComputingPrecision()
NumberUtility::FLOAT_PRECISION
);

return $paymentMethod;
Expand Down

0 comments on commit 9b14253

Please sign in to comment.