Populates the exchange rates.

@return $this Self object
555515
public function populate()
    {
        $currenciesCodes = [];
        $currencies = $this
            ->currencyRepository
            ->findAll();

        /**
         * Create an array of all active currency codes.
         *
         * @var CurrencyInterface $currency
         */
        foreach ($currencies as $currency) {
            if ($currency->getIso() != $this->defaultCurrency) {
                $currenciesCodes[] = $currency->getIso();
            }
        }

        /**
         * Get rates for all of the enabled and active currencies.
         */
        $rates = $this
            ->currencyExchangeRatesAdapter
            ->getExchangeRates(
                $this->defaultCurrency,
                $currenciesCodes
            );

        /**
         * @var CurrencyInterface $sourceCurrency
         */
        $sourceCurrency = $this
            ->currencyRepository
            ->findOneBy([
                'iso' => $this->defaultCurrency,
            ]);

        /**
         * [
         *      "EUR" => "1,378278",
         *      "YEN" => "0,784937",
         * ].
         */
        foreach ($rates as $code => $rate) {

            /**
             * @var CurrencyInterface $targetCurrency
             */
            $targetCurrency = $this
                ->currencyRepository
                ->findOneBy([
                    'iso' => $code,
                ]);

            if (!($targetCurrency instanceof CurrencyInterface)) {
                continue;
            }

            /**
             * check if this is a new exchange rate, or if we have to
             * create a new one.
             */
            $exchangeRate = $this
                ->currencyExchangeRateObjectDirector
                ->findOneBy([
                    'sourceCurrency' => $sourceCurrency,
                    'targetCurrency' => $targetCurrency,
                ]);

            if (!($exchangeRate instanceof CurrencyExchangeRateInterface)) {
                $exchangeRate = $this
                    ->currencyExchangeRateObjectDirector
                    ->create();
            }

            $exchangeRate
                ->setExchangeRate($rate)
                ->setSourceCurrency($sourceCurrency)
                ->setTargetCurrency($targetCurrency);

            $this
                ->currencyExchangeRateObjectDirector
                ->save($exchangeRate);
        }

        return $this;
    }
527371
protected function loadExchangeRates($targetCurrency)
    {
        if (!isset($this->exchangeRates[$targetCurrency])) {
            $currencyRates = $this->currencyRateRepository->findBy(['currencyTo' => $targetCurrency]);
            if (count($currencyRates) === 0) {
                throw new MissingCurrencyRatesException($targetCurrency);
            }
            foreach ($currencyRates as $rate) {
                $this->setExchangeRate($rate, $targetCurrency);
            }
        }
    }
1172442
public function getCurrency()
    {
        $currency = Currency::getCurrencyInstance($this->getOrder()->source->id_currency);
        $result = array (
            Meta::Currency => $currency->iso_code,
            Meta::CurrencyRate => (float) $this->source->conversion_rate,
            Meta::CurrencyDoConvert => true,
        );
        return $result;
    }
134930
public function getCurrency()
    {
        $options = [ 'EUR' => __('Euro'),
                    'GBP' => __('Sterling'),
                    'USD' => __('US Dollar'),
                    'CAD' => __('Canadian Dollar'),
                    'AUD' => __('Australian Dollar'),
                    'DKK' => __('Danish Krone'),
                    'SEK' => __('Swedish Krona'),
                    'NOK' => __('Norwegian Krone')
                ];
        return $options;
    }
1078301
protected function fillCarbonValues()
    {
        foreach ($this->formats as $format)
        {
            $this->values[$format] = $this->date->format($format);
        }

        return $this;
    }
721499
public function load(ObjectManager $manager)
    {
        /**
         * @var ObjectDirector    $currencyExchangeRateDirector
         * @var CurrencyInterface $currencyEuro
         * @var CurrencyInterface $currencyDollar
         * @var CurrencyInterface $currencyPound
         * @var CurrencyInterface $currencyIen
         */
        $currencyExchangeRateDirector = $this->getDirector('currency_exchange_rate');
        $currencyEuro = $this->getReference('currency-euro');
        $currencyDollar = $this->getReference('currency-dollar');
        $currencyPound = $this->getReference('currency-pound');
        $currencyIen = $this->getReference('currency-ien');

        /**
         * Dollar to Euro.
         */
        $dollarToEuroRate = $currencyExchangeRateDirector
            ->create()
            ->setSourceCurrency($currencyDollar)
            ->setTargetCurrency($currencyEuro)
            ->setExchangeRate(0.736596);

        $currencyExchangeRateDirector->save($dollarToEuroRate);

        /**
         * Dollar to Pound.
         */
        $dollarToPoundRate = $currencyExchangeRateDirector
            ->create()
            ->setSourceCurrency($currencyDollar)
            ->setTargetCurrency($currencyPound)
            ->setExchangeRate(0.588765);

        $currencyExchangeRateDirector->save($dollarToPoundRate);

        /**
         * Dollar to Yen.
         */
        $dollarToIenRate = $currencyExchangeRateDirector
            ->create()
            ->setSourceCurrency($currencyDollar)
            ->setTargetCurrency($currencyIen)
            ->setExchangeRate(101.822625);

        $currencyExchangeRateDirector->save($dollarToIenRate);
    }
51250
public function refresh() : self {
      $newCode = $this->collection->assemble();
      $tokens = Helper::getTokensFromString($newCode);

      $this->collection->setItems($tokens);
      return $this;
    }
1224184
public function populate($data = array())
    {
        if (isset($data['prizeContent']) && $data['prizeContent'] !== null) {
            $this->prizeContent = $data['prizeContent'];
        }

        if (isset($data['title']) && $data['title'] !== null) {
            $this->title = $data['title'];
        }

        if (isset($data['qty']) && $data['qty'] !== null) {
            $this->qty = $data['qty'];
        }

        if (isset($data['identifier']) && $data['identifier'] !== null) {
            $this->identifier = $data['identifier'];
        }

        if (isset($data['unitPrice']) && $data['unitPrice'] !== null) {
            $this->unitPrice = $data['unitPrice'];
        }

        if (isset($data['currency']) && $data['currency'] !== null) {
            $this->currency = $data['currency'];
        }

        if (isset($data['picture']) && $data['picture'] !== null) {
            $this->picture = $data['picture'];
        }
    }
928590
public function getCurrency()
    {
        // @todo
        $result = array (
            Meta::Currency => $this->source->currency_code,
            Meta::CurrencyRate => (float) $this->source->conversion_rate,
            Meta::CurrencyDoConvert => true,
        );
        return $result;
    }
859133
private function translate(): self
    {
        if (empty($this->translations)) {
            return $this;
        }

        $lang = $this->get('lang');

        foreach ($this->attributes as $key => $attribute) {
            if (in_array($key, $this->translations, true)) {
                $this->set($key, __($attribute, [], $lang));
            }
        }

        return $this;
    }
976797
public function flip(): self
    {
        $collection = Factory::create();
        foreach ($this->items as $key => $value) {
            $collection->set($value, $key);
        }

        return $collection;
    }
1354324
protected function synchronize()
    {
        if (!empty($this->currencies)) {
            // Map keys to currency code.
            $this->currencies = array_reduce($this->currencies, function ($currencies, Currency $currency) {
                $currencies[$currency->getIso()] = $currency;

                return $currencies;
            }, []);
        }
    }
827863
public static function fromArray(array $currencies)
    {
        foreach ($currencies as $key => $iso) {
            $currencies[$key] = new Currency($iso);
        }

        return new self($currencies);
    }
826953
public function convertBaseRatesToUSD() : Rates
    {
        if (!empty($this->rates)) {
            if ($this->base !== 'USD') {
                if (!empty($this->rates['USD'])) {
                    $usdrate = $this->rates['USD'];
                    foreach ($this->rates as $key => $rate) {
                        $newrates[$key] = $rate * (1 / $usdrate);
                    }
                }
            }
        }
        if (!empty($newrates)) {
            $this->rates = $newrates;
            $this->base = 'USD';
        }

        return $this;
    }
655225
public function attachAll()
    {
        // Get other currencies
        $data = @file_get_contents($this->getUrl());
		$data = @json_decode($data, true);

		if($data && is_array($data) && isset($data['rates']))
		{
			$data = $data['rates'];
			foreach($this->managedCurrencies as $code)
			{
				if(isset($data[$code]))
				{
                    $currency = new $this->currencyClass;
                    $currency->setCode($code);
                    $currency->setRate($data[$code]);

                    $this[$code] = $currency;
				}
			}

            if (isset($this[$this->defaultCurrency])) {
                $defaultRate = $this[$this->defaultCurrency]->getRate();
            }
			else
				throw new CurrencyNotFoundException("Your default currency is not supported by Oer provider");

            $this->convertAll($defaultRate);
        }
    }
21476
public function loadCurrency()
    {
        if ($this->_blLoadCurrency == null) {
            $this->_blLoadCurrency = false;
            if ($loadCurrency = \OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('bl_perfLoadCurrency')) {
                $this->_blLoadCurrency = $loadCurrency;
            }
        }

        return $this->_blLoadCurrency;
    }
1093529
protected function initialize()
    {
        $this->data = new stdClass();
        $this->data->ownId = null;
        $this->data->amount = new stdClass();
        $this->data->amount->currency = self::AMOUNT_CURRENCY;
        $this->data->amount->subtotals = new stdClass();
        $this->data->items = [];
        $this->data->receivers = [];
        $this->data->checkoutPreferences = new stdClass();
        $this->data->checkoutPreferences->redirectUrls = new stdClass();
        $this->data->checkoutPreferences->installments = [];
    }