AbsolutePriceCalculator example

class AbsolutePriceCalculatorTest extends TestCase
{
    /** * @dataProvider provider */
    public function testCalculateAbsolutePriceOfGrossPrices(AbsoluteCalculation $calculation): void
    {
        $rounding = new CashRounding();

        $taxCalculator = new TaxCalculator();

        $calculator = new AbsolutePriceCalculator(
            new QuantityPriceCalculator(
                new GrossPriceCalculator($taxCalculator$rounding),
                new NetPriceCalculator($taxCalculator$rounding),
            ),
            new PercentageTaxRuleBuilder()
        );

        $calculatedPrice = $calculator->calculate(
            $calculation->getDiscount(),
            $calculation->getPrices(),
            Generator::createSalesChannelContext()
        );
protected function setUp(): void
    {
        $cashRounding = new CashRounding();
        $percentageTaxRuleBuilder = new PercentageTaxRuleBuilder();
        $quantityPriceCalculator = new QuantityPriceCalculator(
            new GrossPriceCalculator(new TaxCalculator()$cashRounding),
            new NetPriceCalculator(new TaxCalculator()$cashRounding),
        );
        $this->calculator = new Calculator(
            $quantityPriceCalculator,
            new PercentagePriceCalculator($cashRounding$quantityPriceCalculator$percentageTaxRuleBuilder),
            new AbsolutePriceCalculator($quantityPriceCalculator$percentageTaxRuleBuilder)
        );

        $this->context = $this->createMock(SalesChannelContext::class);
        $this->context->method('getItemRounding')->willReturn(new CashRoundingConfig(2, 0.01, true));
    }

    public function testCalculateSimplePrice(): void
    {
        $cart = new Cart('test');

        $lineItem = (new LineItem('A', 'test'))
            
/** * @dataProvider priceProvider */
    public function testCalculate(float $discountIn, float $packageSum, float $discountOut): void
    {
        $context = Generator::createSalesChannelContext();

        $rounding = new CashRounding();

        $taxCalculator = new TaxCalculator();

        $calculator = new AbsolutePriceCalculator(
            new QuantityPriceCalculator(
                new GrossPriceCalculator($taxCalculator$rounding),
                new NetPriceCalculator($taxCalculator$rounding),
            ),
            new PercentageTaxRuleBuilder()
        );

        $discountCalculator = new DiscountAbsoluteCalculator($calculator);

        $priceDefinition = new AbsolutePriceDefinition($discountIn);
        $discount = new DiscountLineItem('foo', $priceDefinition['discountScope' => 'foo', 'discountType' => 'bar'], null);

        
Home | Imprint | This part of the site doesn't use cookies.