public function discount(float
$value): void
{ $definition =
new QuantityPriceDefinition($this->price->
getUnitPrice(),
$this->price->
getTaxRules());
$definition->
setIsCalculated(true
);
$unit =
$this->priceStubs->
calculateQuantity($definition,
$this->context
);
$discount =
$this->priceStubs->
calculatePercentage(\
abs($value),
new CalculatedPriceCollection([$unit]),
$this->context
);
$definition =
new QuantityPriceDefinition( $this->price->
getUnitPrice() -
$discount->
getUnitPrice(),
$this->price->
getTaxRules(),
$this->
getQuantity() );
$this->
overwrite($definition);
} /**
* `surcharge()` allows a percentage surcharge calculation of the current price scope. The provided value will be ensured to be negative via `abs(value)`.
* The provided surcharge is interpreted as a percentage value and will be applied to the unit price and the total price as well.
*
* @example pricing-cases/product-pricing.twig 34 1 Adds a 10% surcharge to the existing calculated price
*
* @param float $value The percentage value of the surcharge. The value will be ensured to be negative via `abs(value)`.
*/