From 887ac83f83bad53c318f138d0167b372e33ae1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Wed, 8 Apr 2020 16:06:32 +0200 Subject: [PATCH] Fixed an exception when a pricedetail has a currency without exchange rate. Fixes issue #37 --- src/Services/PricedetailHelper.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Services/PricedetailHelper.php b/src/Services/PricedetailHelper.php index d36ce4d7..c4a24a6b 100644 --- a/src/Services/PricedetailHelper.php +++ b/src/Services/PricedetailHelper.php @@ -174,8 +174,12 @@ class PricedetailHelper continue; } - $avg = bcadd($avg, $this->convertMoneyToCurrency($pricedetail->getPricePerUnit(), $pricedetail->getCurrency(), $currency), Pricedetail::PRICE_PRECISION); - ++$count; + $converted = $this->convertMoneyToCurrency($pricedetail->getPricePerUnit(), $pricedetail->getCurrency(), $currency); + //Ignore price informations that can not be converted to base currency. + if ($converted !== null) { + $avg = bcadd($avg, $converted, Pricedetail::PRICE_PRECISION); + ++$count; + } } if (0 === $count) {