Common/Calculator/AmountCalculator.php
protected function convert(Model\SaleInterface $sale, float $amount, string $currency, bool $round)
    {
        if ($currency === $this->converter->getDefaultCurrency()) {
            return $round ? Money::round($amount, $currency) : $amount;
        }

        if (null !== $rate = $sale->getExchangeRate()) {
            return $this
                ->converter
                ->convertWithRate($amount, $rate, $currency, $round);
        }

        $date = $this->contextProvider->getContext($sale)->getDate();

        return $this
            ->converter
            ->convert($amount, $this->converter->getDefaultCurrency(), $currency, $date, $round);
    }
protected function convert(Model\SaleInterface $sale, float $amount, string $currency, bool $round)
    {
        if ($currency === $this->converter->getDefaultCurrency()) {
            return $round ? Money::round($amount, $currency) : $amount;
        }

        if (null !== $rate = $sale->getExchangeRate()) {
            return $this
                ->converter
                ->convertWithRate($amount, $rate, $currency, $round);
        }

        $date = $this->contextProvider->getContext($sale)->getDate();

        return $this
            ->converter
            ->convert($amount, $this->converter->getDefaultCurrency(), $currency, $date, $round);
    }
protected function convert ( Model \ SaleInterface $ sale , float $ amount , string $ currency , bool $ round ) { if ( $ currency === $ this -> converter -> getDefaultCurrency ( ) ) { return $ round ? Money :: round ( $ amount , $ currency ) : $ amount ; } if ( null !== $ rate = $ sale -> getExchangeRate ( ) ) { return $ this -> converter -> convertWithRate ( $ amount , $ rate , $ currency , $ round ) ; } $ date = $ this -> contextProvider -> getContext ( $ sale ) -> getDate ( ) ; return $ this -> converter -> convert ( $ amount , $ this -> converter -> getDefaultCurrency ( ) , $ currency , $ date , $ round ) ; }
Converts the given amount.

@param Model\SaleInterface $sale
@param float               $amount
@param string              $currency
@param bool                $round

@return float
@throws \Exception
Converts the given amount .