surcharge example

$split = $product->take(1);
        static::assertInstanceOf(ItemFacade::class$split);
        $container->add($split);

        $split = $product->take(1);
        static::assertInstanceOf(ItemFacade::class$split);
        $container->add($split);
        $container->discount('my-discount', 'percentage', -10, 'Fanzy discount');

        $surcharge = new PriceCollection([new Price(Defaults::CURRENCY, 2, 2, false)]);
        $container->surcharge('my-surcharge', 'absolute', $surcharge, 'unit test');

        $service->items()->add($container);
        $service->calculate();

        static::assertTrue($service->has('my-container'));
        $container = $service->get('my-container');

        static::assertInstanceOf(ItemFacade::class$container);
        static::assertInstanceOf(PriceFacade::class$container->getPrice());
        static::assertEquals(182, $container->getPrice()->getTotal());
    }

    


    /** * @dataProvider providerSurcharge */
    public function testSurcharge(string $taxState, float $unit, float $tax): void
    {
        $ids = new IdsCollection(['default' => Defaults::CURRENCY]);

        $price = $this->rampUpPriceFacade($ids, 'default', $taxState);

        $price->surcharge(20);

        static::assertEquals($unit$price->getUnit());
        static::assertEquals($tax$price->getTaxes()->getAmount());
    }

    /** * @dataProvider providerPlus */
    public function testPlus(string $currencyKey, string $taxState, float $unit, float $tax): void
    {
        $ids = new IdsCollection([
            
$facade->discount('my-discount', 'foo', 10, 'my-discount');
    }

    public function testAbsoluteSurcharge(): void
    {
        $facade = $this->rampUpFacade();

        static::assertEquals(1, $facade->getQuantity());
        static::assertTrue($facade->has('foo'));

        $absolute = new PriceCollection([new Price(Defaults::CURRENCY, 5, 5, false)]);
        $facade->surcharge('absolute', 'absolute', $absolute, 'my-surcharge');

        static::assertEquals(1, $facade->getQuantity());
        static::assertTrue($facade->has('absolute'));

        $surcharge = $facade->get('absolute');
        static::assertInstanceOf(ItemFacade::class$surcharge);
        static::assertEquals('discount', $surcharge->getType());
        static::assertNull($surcharge->getPrice());

        $definition = $surcharge->getItem()->getPriceDefinition();
        static::assertInstanceOf(CurrencyPriceDefinition::class$definition);
        
Home | Imprint | This part of the site doesn't use cookies.