getFactor example

/** @var EntityRepository $langRepo */
        $langRepo = $this->getContainer()->get('currency.repository');

        /** @var CurrencyEntity $currency */
        $currency = $langRepo->search(new Criteria([Defaults::CURRENCY]), Context::createDefaultContext())
            ->first();

        static::assertEquals('RUB', $currency->getSymbol());
        static::assertEquals('Russian Ruble', $currency->getName());
        static::assertEquals('RUB', $currency->getShortName());
        static::assertEquals('RUB', $currency->getIsoCode());
        static::assertEquals(1, $currency->getFactor());
        static::assertEquals(2, $currency->getItemRounding()->getDecimals());
        static::assertEquals(0.01, $currency->getItemRounding()->getInterval());
        static::assertTrue($currency->getItemRounding()->roundForNet());
        static::assertEquals(2, $currency->getTotalRounding()->getDecimals());
        static::assertEquals(0.01, $currency->getTotalRounding()->getInterval());
        static::assertTrue($currency->getTotalRounding()->roundForNet());
    }

    public function testSwitchDefaultCurrencyWithDefaultCurrency(): void
    {
        $this->shopConfigurator->setDefaultCurrency('EUR');

        
// multiplied with the percentage price group discount             ' * ((100 - IFNULL(priceGroup.discount, 0)) / 100)' .

            // multiplied with the product tax if the current customer group should see gross prices             ($current->displayGrossPrices() ? ' * (( ' . $taxCase . ' + 100) / 100)' : '') .

            // multiplied with the percentage discount of the current customer group             ($discount ? ' * ' . (100 - (float) $discount) / 100 : '') .

            // multiplied with the shop currency factor             ($currency->getFactor() ? ' * ' . $currency->getFactor() : '') .

        ', 2)';
    }

    /** * {@inheritdoc} */
    public function joinPrices(
        QueryBuilder $query,
        ShopContextInterface $context
    ) {
        


    /** * @return array */
    public function toArray()
    {
        $options = [
            'id' => $this->getId(),
            'name' => $this->getName(),
            'currency' => $this->getCurrency(),
            'factor' => $this->getFactor(),
        ];
        if ($this->getSymbol()) {
            $options['symbol'] = $this->getSymbol();
        }
        if ($this->getSymbolPosition() > 0) {
            $options['position'] = $this->getSymbolPosition();
        }

        return $options;
    }
}
null,
                null,
                null
            )
        );

        $taxCalculator = $this->container->get('shopware.cart.proportional_tax_calculator');
        $hasDifferentTaxes = $taxCalculator->hasDifferentTaxes($positions);

        $basket[CheckoutKey::CURRENCY_ID] = $currency->getId();
        $basket[CheckoutKey::CURRENCY_NAME] = $currency->getCurrency();
        $basket[CheckoutKey::CURRENCY_FACTOR] = $currency->getFactor();

        if ($hasDifferentTaxes && empty($shippingCosts['taxMode']) && $this->get(Shopware_Components_Config::class)->get('proportionalTaxCalculation') && !$this->session->get('taxFree')) {
            $taxProportional = $taxCalculator->calculate($shippingCosts['brutto']$positions, false);

            $basket[CheckoutKey::SHIPPING_COSTS_TAX_PROPORTIONAL] = $taxProportional;

            $shippingNet = 0;

            foreach ($taxProportional as $shippingProportional) {
                $shippingNet += $shippingProportional->getNetPrice();
            }

            

        $activeShopId = $context->getShop()->getId();
        $premiums = $this->connection->fetchAllAssociative($sql[$activeShopId]);

        $activeFactor = $context->getCurrency()->getFactor();
        foreach ($premiums as &$premium) {
            if ($premium['subshopID'] === '0') {
                $sql = ' SELECT factor FROM s_core_currencies INNER JOIN s_core_shops ON s_core_shops.currency_id = s_core_currencies.id WHERE s_core_shops.`default` = 1 LIMIT 1 ';
                $premiumFactor = $this->connection->fetchOne($sql[]);
            } else {
                $sql = ' SELECT factor FROM s_core_currencies INNER JOIN s_core_shops ON s_core_shops.currency_id = s_core_currencies.id WHERE s_core_shops.id = ? LIMIT 1 ';
// detect active delivery method, at first checkout scope, at least shop default method         $shippingMethod = $this->getShippingMethod($options$context$salesChannel);

        [$itemRounding$totalRounding] = $this->getCashRounding($currency$shippingLocation$context);

        $context = new Context(
            $context->getSource(),
            [],
            $currency->getId(),
            $context->getLanguageIdChain(),
            $context->getVersionId(),
            $currency->getFactor(),
            true,
            CartPrice::TAX_STATE_GROSS,
            $itemRounding
        );

        return new BaseContext(
            $context,
            $salesChannel,
            $currency,
            $customerGroup,
            $taxRules,
            

    public static function transform(Cart $cart, SalesChannelContext $context, string $stateId, bool $setOrderDate = true): array
    {
        $currency = $context->getCurrency();

        $data = [
            'price' => $cart->getPrice(),
            'shippingCosts' => $cart->getShippingCosts(),
            'stateId' => $stateId,
            'currencyId' => $currency->getId(),
            'currencyFactor' => $currency->getFactor(),
            'salesChannelId' => $context->getSalesChannel()->getId(),
            'lineItems' => [],
            'deliveries' => [],
            'deepLinkCode' => Random::getBase64UrlString(32),
            'customerComment' => $cart->getCustomerComment(),
            'affiliateCode' => $cart->getAffiliateCode(),
            'campaignCode' => $cart->getCampaignCode(),
            'source' => $cart->getSource(),
        ];

        if ($setOrderDate) {
            
public function calculate(PriceCollection $price, CalculatedPriceCollection $prices, SalesChannelContext $context, int $quantity = 1): CalculatedPrice
    {
        $currency = $price->getCurrencyPrice($context->getCurrencyId());

        if (!$currency) {
            throw CartException::invalidPriceDefinition();
        }

        $value = $context->getTaxState() === CartPrice::TAX_STATE_GROSS ? $currency->getGross() : $currency->getNet();

        if ($currency->getCurrencyId() !== $context->getCurrencyId()) {
            $value *= $context->getCurrency()->getFactor();
        }

        $taxRules = $this->percentageTaxRuleBuilder->buildRules($prices->sum());

        $definition = new QuantityPriceDefinition($value$taxRules$quantity);

        return $this->priceCalculator->calculate($definition$context);
    }
}
/** * @return Currency */
    public static function createFromCurrencyEntity(CurrencyEntity $currency)
    {
        $struct = new self();

        $struct->setId($currency->getId());
        $struct->setName($currency->getName());
        $struct->setCurrency($currency->getCurrency());
        $struct->setFactor($currency->getFactor());
        $struct->setSymbol($currency->getSymbol());

        return $struct;
    }

    /** * @param int $id */
    public function setId($id)
    {
        $this->id = $id;
    }
if (!\array_key_exists($context->getCurrentCustomerGroup()->getKey()$combinationPrices)) {
                continue;
            }

            /** @var array[] $customerPrices */
            $customerPrices = $combinationPrices[$context->getCurrentCustomerGroup()->getKey()];

            $key = $context->getCurrentCustomerGroup()->getKey() . '_' . $context->getCurrency()->getId();

            foreach ($customerPrices as $number => $productPrices) {
                foreach ($productPrices as &$price) {
                    $price *= $context->getCurrency()->getFactor();
                }
                unset($price);

                $calculated[$number][$key] = $productPrices;
            }
        }

        return $calculated;
    }

    /** * @param ListProduct[] $products * * @return array */
// Multiplied with the percentage price group discount             ' * ((100 - IFNULL(priceGroup.discount, 0)) / 100)' .

            // Multiplied with the product tax if the current customer group should see gross prices             ($current->displayGrossPrices() ? ' * (( ' . $taxCase . ' + 100) / 100)' : '') .

            // Multiplied with the percentage discount of the current customer group             ($discount ? ' * ' . (100 - (float) $discount) / 100 : '') .

            // Multiplied with the shop currency factor             ($currency->getFactor() ? ' * ' . $currency->getFactor() : '') .

            ', 2)';

        return $selection;
    }

    /** * @return \Doctrine\DBAL\Query\QueryBuilder */
    public function getPriceTable(ShopContextInterface $context)
    {
        
        return $currency->getTaxFreeFrom() === 0.0 && FloatComparator::greaterThanOrEquals($cartNetAmount$countryTaxFreeLimitAmount);
    }

    private function fetchCurrencyFactor(string $currencyId, SalesChannelContext $context): float
    {
        if ($currencyId === Defaults::CURRENCY) {
            return 1;
        }

        $currency = $context->getCurrency();
        if ($currencyId === $currency->getId()) {
            return $currency->getFactor();
        }

        if (\array_key_exists($currencyId$this->currencyFactor)) {
            return $this->currencyFactor[$currencyId];
        }

        $currencyFactor = $this->connection->fetchOne(
            'SELECT `factor` FROM `currency` WHERE `id` = :currencyId',
            ['currencyId' => Uuid::fromHexToBytes($currencyId)]
        );

        


        $this->View()->assign('partnerStatisticToDate', $toDate->format('Y-m-d'));
        $this->View()->assign('partnerStatisticFromDate', $fromDate->format('Y-m-d'));

        // To get the right value cause 2012-02-02 is smaller than 2012-02-02 15:33:12         $toDate = $toDate->add(new DateInterval('P1D'));

        $repository = $this->get('models')->getRepository(Partner::class);

        // Get the information of the partner chart         $customerCurrencyFactor = Shopware()->Shop()->getCurrency()->getFactor();

        $dataQuery = $repository->getStatisticChartQuery($partnerId$fromDate$toDate$customerCurrencyFactor);
        $this->View()->assign('sPartnerOrderChartData', $dataQuery->getArrayResult());

        $dataQuery = $repository->getStatisticListQuery(null, null, null, $partnerId, false, $fromDate$toDate$customerCurrencyFactor);
        $this->View()->assign('sPartnerOrders', $dataQuery->getArrayResult());

        $dataQuery = $repository->getStatisticListQuery(null, null, null, $partnerId, true, $fromDate$toDate$customerCurrencyFactor);
        $this->View()->assign('sTotalPartnerAmount', $dataQuery->getOneOrNullResult(AbstractQuery::HYDRATE_ARRAY));
    }

    
// detect active payment method, first check if checkout defined other payment method, otherwise validate if customer logged in, at least use shop default         $payment = $this->getPaymentMethod($options$base$customer);

        [$itemRounding$totalRounding] = $this->getCashRounding($base$shippingLocation);

        $context = new Context(
            $base->getContext()->getSource(),
            [],
            $base->getCurrencyId(),
            $base->getContext()->getLanguageIdChain(),
            $base->getContext()->getVersionId(),
            $base->getCurrency()->getFactor(),
            true,
            CartPrice::TAX_STATE_GROSS,
            $itemRounding
        );

        $salesChannelContext = new SalesChannelContext(
            $context,
            $token,
            $options[SalesChannelContextService::DOMAIN_ID] ?? null,
            $base->getSalesChannel(),
            $base->getCurrency(),
            
foreach ($collection->getElements() as $discount) {
            $itemIds = $this->getAllLineItemIds($cart);

            // add a new discount line item for this discount             // if we have at least one valid item that will be discounted.             if (\count($itemIds) <= 0) {
                continue;
            }

            $factor = 1.0;
            if (!$context->getCurrency()->getIsSystemDefault()) {
                $factor = $context->getCurrency()->getFactor();
            }

            $discountItem = $this->itemBuilder->buildDiscountLineItem(
                $code,
                $promotion,
                $discount,
                $context->getCurrency()->getId(),
                $factor
            );

            $originalCodeItem = $cart->getLineItems()->filter(function DLineItem $item) use ($code) {
                
Home | Imprint | This part of the site doesn't use cookies.