PercentageCalculation example

$priceDefinition = new QuantityPriceDefinition(10.40, new TaxRuleCollection([new TaxRule(21, 100)]), 1);
        $price = $calculator->calculate($priceDefinition, Generator::createSalesChannelContext());
        static::assertSame(10.40, $price->getTotalPrice());
        static::assertSame(1.80, $price->getCalculatedTaxes()->getAmount());

        $priceDefinition = new QuantityPriceDefinition(104.00, new TaxRuleCollection([new TaxRule(21, 100)]), 1);
        $price = $calculator->calculate($priceDefinition, Generator::createSalesChannelContext());
        static::assertSame(104.00, $price->getTotalPrice());
        static::assertSame(18.05, $price->getCalculatedTaxes()->getAmount());

        return new PercentageCalculation(
            -10,
            new CalculatedPrice(
                -10.4,
                -10.4,
                new CalculatedTaxCollection([
                    new CalculatedTax(-1.80, 21, -10.4),
                ]),
                new TaxRuleCollection([new TaxRule(21)])
            ),
            new PriceCollection([$price])
        );
    }
Home | Imprint | This part of the site doesn't use cookies.