mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-05-24 20:31:32 +00:00
Upgraded brick/math to latest version
This commit is contained in:
parent
506d5f8173
commit
527c42c227
11 changed files with 58 additions and 56 deletions
|
|
@ -44,15 +44,15 @@ class ExchangeRateUpdater
|
|||
try {
|
||||
//Try it in the direction QUOTE/BASE first, as most providers provide rates in this direction
|
||||
$rate = $this->swap->latest($currency->getIsoCode().'/'.$this->localizationSettings->baseCurrency);
|
||||
$effective_rate = BigDecimal::of($rate->getValue());
|
||||
$effective_rate = BigDecimal::fromFloatShortest($rate->getValue());
|
||||
} catch (UnsupportedCurrencyPairException|UnsupportedExchangeQueryException $exception) {
|
||||
//Otherwise try to get it inverse and calculate it ourselfes, from the format "BASE/QUOTE"
|
||||
$rate = $this->swap->latest($this->localizationSettings->baseCurrency.'/'.$currency->getIsoCode());
|
||||
//The rate says how many quote units are worth one base unit
|
||||
//So we need to invert it to get the exchange rate
|
||||
|
||||
$rate_bd = BigDecimal::of($rate->getValue());
|
||||
$effective_rate = BigDecimal::one()->dividedBy($rate_bd, Currency::PRICE_SCALE, RoundingMode::HALF_UP);
|
||||
$rate_bd = BigDecimal::fromFloatShortest($rate->getValue());
|
||||
$effective_rate = BigDecimal::one()->dividedBy($rate_bd, Currency::PRICE_SCALE, RoundingMode::HalfUp);
|
||||
}
|
||||
|
||||
$currency->setExchangeRate($effective_rate);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue