From e1010b86dd5b5b8bd5290f8c4963fc2efa3fc17f Mon Sep 17 00:00:00 2001 From: Eduardo Iriarte Date: Fri, 7 Sep 2018 20:50:36 +0200 Subject: [PATCH 1/2] [SHPWR-347] fix rounded price discrepancies - use `money_format` instead of `round` - fix missing parameters for customer wrapper --- Component/Mapper/ModelFactory.php | 2 +- Component/Service/PaymentProcessor.php | 2 ++ Controller/frontend/RpayRatepay.php | 2 +- .../responsive/frontend/installment/php/PiRatepayRateCalc.php | 3 +-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Component/Mapper/ModelFactory.php b/Component/Mapper/ModelFactory.php index d9a8e912..4432761c 100755 --- a/Component/Mapper/ModelFactory.php +++ b/Component/Mapper/ModelFactory.php @@ -826,7 +826,7 @@ private function getShippingItemData(PaymentRequestData $shippingData, $useFallb Math::netToGross($shippingData->getShippingCost(), $shippingData->getShippingTax()) : $shippingData->getShippingCost(); - $priceGross = round($priceGross, 2); + $priceGross = money_format('%.2n', $priceGross); $item = [ 'Description' => 'Shipping costs', diff --git a/Component/Service/PaymentProcessor.php b/Component/Service/PaymentProcessor.php index 8e317fb6..f4bf93db 100644 --- a/Component/Service/PaymentProcessor.php +++ b/Component/Service/PaymentProcessor.php @@ -106,6 +106,8 @@ public function setPaymentStatusPaid($order) /** * @param $transactionId * @param \Shopware\Models\Order\Order $order + * @param bool $backend + * @throws \Exception */ public function sendPaymentConfirm($transactionId, $order, $backend = false) { diff --git a/Controller/frontend/RpayRatepay.php b/Controller/frontend/RpayRatepay.php index 86bd6931..f529408b 100755 --- a/Controller/frontend/RpayRatepay.php +++ b/Controller/frontend/RpayRatepay.php @@ -123,7 +123,7 @@ public function saveUserDataAction() /** @var Shopware\Models\Customer\Customer $userModel */ $userModel = $customerModel->findOneBy(array('id' => Shopware()->Session()->sUserId)); - $userWrapped = new ShopwareCustomerWrapper($userModel); + $userWrapped = new ShopwareCustomerWrapper($userModel, Shopware()->Models()); if (isset($Parameter['checkoutBillingAddressId']) && !is_null($Parameter['checkoutBillingAddressId'])) { // From Shopware 5.2 current billing address is sent by parameter $addressModel = Shopware()->Models()->getRepository('Shopware\Models\Customer\Address'); diff --git a/Views/responsive/frontend/installment/php/PiRatepayRateCalc.php b/Views/responsive/frontend/installment/php/PiRatepayRateCalc.php index 1f07ea34..4628a024 100755 --- a/Views/responsive/frontend/installment/php/PiRatepayRateCalc.php +++ b/Views/responsive/frontend/installment/php/PiRatepayRateCalc.php @@ -111,8 +111,7 @@ public function createFormattedResult() $currency = '€'; $decimalSeperator = ','; $thousandSepeartor = '.'; - } - else { + } else { $currency = '€'; $decimalSeperator = '.'; $thousandSepeartor = ','; From 38265b4d7679debcbdf871b3e54adbcf78d1d548 Mon Sep 17 00:00:00 2001 From: Eduardo Iriarte Date: Mon, 10 Sep 2018 16:18:45 +0200 Subject: [PATCH 2/2] [SHPWR-347] round item prices for b2b shops - uses round to keep number instead of strings --- .../Request/SubModel/Content/ShoppingBasket.php | 2 +- Component/Library/src/Service/Math.php | 16 ++++++---------- Component/Mapper/ModelFactory.php | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Component/Library/src/Model/Request/SubModel/Content/ShoppingBasket.php b/Component/Library/src/Model/Request/SubModel/Content/ShoppingBasket.php index b330b431..b6a91c4a 100755 --- a/Component/Library/src/Model/Request/SubModel/Content/ShoppingBasket.php +++ b/Component/Library/src/Model/Request/SubModel/Content/ShoppingBasket.php @@ -96,7 +96,7 @@ public function toArray() $amount += floatval($unitPrice); } - $this->admittedFields['Amount']['value'] = $amount; + $this->admittedFields['Amount']['value'] = round($amount, 2); } return parent::toArray(); diff --git a/Component/Library/src/Service/Math.php b/Component/Library/src/Service/Math.php index 33554f88..da7c7c2d 100644 --- a/Component/Library/src/Service/Math.php +++ b/Component/Library/src/Service/Math.php @@ -1,6 +1,7 @@ getShippingCost(), $shippingData->getShippingTax()) : $shippingData->getShippingCost(); - $priceGross = money_format('%.2n', $priceGross); + $priceGross = round($priceGross, 3); $item = [ 'Description' => 'Shipping costs',