From 74721ffffac092f5013d95be1165f9d40b5b86c3 Mon Sep 17 00:00:00 2001 From: Ugur Ozkan Date: Wed, 13 Jan 2021 11:59:32 +0300 Subject: [PATCH] Normalize TCMB rates --- src/Service/CentralBankOfRepublicTurkey.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Service/CentralBankOfRepublicTurkey.php b/src/Service/CentralBankOfRepublicTurkey.php index d498756..1da8371 100755 --- a/src/Service/CentralBankOfRepublicTurkey.php +++ b/src/Service/CentralBankOfRepublicTurkey.php @@ -78,10 +78,13 @@ private function doCreateRate(ExchangeRateQuery $exchangeQuery, DateTimeInterfac $element = StringUtil::xmlToElement($content); $date = new \DateTime((string) $element->xpath('//Tarih_Date/@Date')[0]); - $elements = $element->xpath('//Currency[@CurrencyCode="'.$currencyPair->getBaseCurrency().'"]/ForexSelling'); + $elements = $element->xpath('//Currency[@CurrencyCode="'.$currencyPair->getBaseCurrency().'"]'); if (!empty($elements) || !$date) { - return $this->createRate($currencyPair, (float) ($elements[0]), $date); + $rate = (float) $elements[0]->ForexSelling; + $unit = (int) $elements[0]->Unit ?? 1; + + return $this->createRate($currencyPair, (float) ($rate / $unit), $date); } throw new UnsupportedCurrencyPairException($currencyPair, $this);