Returns price by currency id. If found, the ProductPrice entity is removed
from the prices array.

@param ProductPrice[] $prices
@param $currencyId

@return null|ProductPrice
770335
private function retrievePriceByCurrency(array &$prices, $currencyId)
    {
        /** @var ProductPrice $price */
        foreach ($prices as $index => $price) {
            if ($currencyId === $price->getCurrency()->getId()) {
                unset($prices[$index]);

                return $price;
            }
        }

        return null;
    }
976133
public function getFor(Currency $currency): float
    {
        if ($currency->equals($this->baseCurrency)) {
            // no need to make an api call for same currencies.
            $this->exchangeRates[$currency->getCode()] = (float) 1;
        } else {
            $this->retrieveExchangeRateFor($currency);
        }

        return $this->exchangeRates[$currency->getCode()];
    }
835731
private function getCurrencies($language)
    {
        /** @var Currency[] $currencies */
        $currencies = $this->get('sulu_product.currency_manager')->findAll($language);

        $currencyValues = array();

        foreach ($currencies as $currency) {
            $currencyValues[] = array(
                'id' => $currency->getId(),
                'name' => $currency->getName(),
                'code' => $currency->getCode()
            );
        }

        return $currencyValues;
    }
1141325
public static function compareAmounts($price1, $price2)
    {
        //====================================================================//
        // Compare Price
        if ($price1["base"]) {
            if (abs($price1["ttc"] - $price2["ttc"]) > 1E-6) {
                return false;
            }
        } else {
            if (abs($price1["ht"] - $price2["ht"]) > 1E-6) {
                return false;
            }
        }
        //====================================================================//
        // Compare VAT
        if (abs($price1["vat"] - $price2["vat"]) > 1E-6) {
            return false;
        }
        //====================================================================//
        // Compare Currency If Set on Both Sides
        if (empty($price1["code"]) || empty($price2["code"])) {
            return true;
        }
        if ($price1["code"] !== $price2["code"]) {
            return false;
        }
        //====================================================================//
        // Prices Are Identical
        return true;
    }
323600
@Override
	public List<CommercePriceList> findByCommerceCurrencyId(
		long commerceCurrencyId) {
		return findByCommerceCurrencyId(commerceCurrencyId, QueryUtil.ALL_POS,
			QueryUtil.ALL_POS, null);
	}
888863
@Override
	public List<CommerceCurrency> getCommerceCurrenciesByUuidAndCompanyId(
		String uuid, long companyId) {
		return commerceCurrencyPersistence.findByUuid_C(uuid, companyId);
	}
615823
public function calculateItemNetPrice($item, $currency = null, $useProductsPrice = null, $isGrossPrice = false)
    {
        $currency = $this->getCurrency($currency);

        if ($useProductsPrice === null) {
            $useProductsPrice = $item->getUseProductsPrice();
        }

        // Validate item
        $this->validateItem($item);

        $priceValue = $item->getPrice();

        if ($useProductsPrice && ($item->getCalcProduct() || $item->getAddon())) {
            $priceValue = $this->getValidProductNetPriceForItem($item, $currency);
        } elseif ($isGrossPrice) {
            // Handle gross prices.
            $tax = $item->getTax();
            if ($tax > 0) {
                $priceValue = ($priceValue / (100 + $tax)) * 100;
            }
        }

        return $priceValue;
    }
879206
private function addAllCurrencies(ProductInterface $product)
    {
        $currencies = $this->currencyRepository->findAll();

        foreach ($product->getPrices() as $price) {
            if (($key = array_search($price->getCurrency(), $currencies)) !== false) {
                unset($currencies[$key]);
            }
        }

        foreach ($currencies as $currency) {
            $price = new ProductPriceEntity();
            $price->setCurrency($currency);

            $product->addPrice($price);
            $price->setProduct($product);
        }
    }
829045
public function getProductValueModel($productId)
    {
        $dataType = ucfirst(strtolower($this->data_type));

        $method = 'productProperty' . $dataType . 'Value';

        $productPropertyModel = $this
                                        ->$method()
                                        ->whereProductId($productId)
                                        ->get();

        if ($productPropertyModel->count() == 0) {
            $valueClass = __NAMESPACE__ . '\\' . ucfirst($method);

            $valueModel = new $valueClass([
                'property_id' => $this->id,
                'product_id' => $productId
            ]);
        } else {
            $valueModel = $this->$method()->whereProductId($productId)->first();
        }

        return $valueModel;
    }
1301994
public function getCurrency($currencyCode) : Currency
    {
        if (isset($this->currencies[$currencyCode])) {
            return $this->currencies[$currencyCode];
        }

        if (! isset($this->currencyData[$currencyCode])) {
            if ($this->numericToCurrency === null) {
                $this->numericToCurrency = require __DIR__ . '/../data/numeric-to-currency.php';
            }

            if (isset($this->numericToCurrency[$currencyCode])) {
                return $this->getCurrency($this->numericToCurrency[$currencyCode]);
            }

            throw UnknownCurrencyException::unknownCurrency($currencyCode);
        }

        $currency = new Currency(... $this->currencyData[$currencyCode]);

        return $this->currencies[$currencyCode] = $currency;
    }
435007
public function getPriceObject($iPriceTypeID = null)
    {
        if (empty($iPriceTypeID)) {
            $obPriceModel = $this->main_price;
        } else {
            $obPriceModel = $this->price_link->where('price_type_id', $iPriceTypeID)->first();
        }

        return $obPriceModel;
    }
869913
public function getBulkPriceForCurrency($quantity, $currency = 'EUR')
    {
        $bulkPrice = null;
        $prices = $this->entity->getPrices();
        if ($prices) {
            $bestDifference = PHP_INT_MAX;
            foreach ($prices as $price) {
                if ($price->getCurrency()->getCode() == $currency &&
                    $price->getMinimumQuantity() <= $quantity &&
                    ($quantity - $price->getMinimumQuantity()) < $bestDifference
                ) {
                    $bestDifference = $quantity - $price->getMinimumQuantity();
                    $bulkPrice = $price;
                }
            }
        }

        return $bulkPrice;
    }
786286
public function loadPriceIds($dPriceFrom, $dPriceTo)
    {
        $sSelect = $this->_getPriceSelect($dPriceFrom, $dPriceTo);
        $this->_createIdListFromSql($sSelect);
    }
1363761
public function retrieveItemPrices($itemsData, $currency, $locale)
    {
        $items = [];
        $previousItem = null;

        // Prepare item data.
        foreach ($itemsData as $itemData) {
            $useProductsPrice = false;
            if (isset($itemData['useProductsPrice']) && $itemData['useProductsPrice'] == true) {
                $useProductsPrice = $itemData['useProductsPrice'];
            }

            // Add and remove necessary data for calculation.
            $itemData = $this->setDefaultData($itemData);
            $itemData = $this->unsetUneccesaryData($itemData);

            // Generate item.
            /** @var ItemInterface $item */
            $item = $this->getItemManager()->save($itemData, $locale, null, null, null, null, $previousItem);
            $item->setUseProductsPrice($useProductsPrice);

            // Calculate total net price of item.
            $itemPrice = $this->itemPriceCalculator->calculateItemNetPrice(
                $item,
                $currency,
                $useProductsPrice,
                $this->isItemGrossPrice($itemData)
            );
            $itemTotalNetPrice = $this->itemPriceCalculator->calculateItemTotalNetPrice(
                $item,
                $currency,
                $useProductsPrice,
                $this->isItemGrossPrice($itemData)
            );
            $item->setPrice($itemPrice);
            $item->setTotalNetPrice($itemTotalNetPrice);

            // Save the last processed product item to calculate addon prices.
            if (Item::TYPE_ADDON !== $item->getType()) {
                $previousItem = $item->getEntity();
            }

            $items[] = $item;
        }

        return [
            'items' => $items,
        ];
    }
1140849
public function findProductPrice(PriceProduct $product)
    {
        $priceConfigurationFilter = new PriceConfigurationFilter();
        $priceConfigurationFilter->addProduct($product);

        $result = $this->findPrice($priceConfigurationFilter);
        if (isset($result[0])) {
            return $result[0];
        }

        return null;
    }
537640
public function getFProductsPrice()
    {
        return \OxidEsales\Eshop\Core\Registry::getLang()->formatCurrency($this->getBruttoSum(), $this->getBasketCurrency());
    }
741964
public function formatPrice($price) {
    // Fetch the config.
    $config = $this->configFactory->get('acm.currency');

    // Get currency with the correct locale.
    $locale = \Drupal::languageManager()->getCurrentLanguage()->getId();
    $currency = \Drupal::service('repository.currency');
    $numberFormat = \Drupal::service('repository.number_format');
    $currencyFormatter = new CurrencyFormatter($numberFormat, $currency, ['locale' => $locale]);

    $currencyCode = $currency->get($config->get('currency_code'))->getCurrencyCode();

    return $currencyFormatter->format($price, $currencyCode);
  }