/**
* @throws InvalidPriceDefinitionException
* @throws CartException
*/
public function calculate(DiscountLineItem
$discount, DiscountPackageCollection
$packages, SalesChannelContext
$context): DiscountCalculatorResult
{ /** @var AbsolutePriceDefinition|null $priceDefinition */
$priceDefinition =
$discount->
getPriceDefinition();
if (!
$priceDefinition instanceof AbsolutePriceDefinition
) { throw new InvalidPriceDefinitionException($discount->
getLabel(),
$discount->
getCode());
} $fixedTotalPrice =
abs($priceDefinition->
getPrice());
$affectedPrices =
$packages->
getAffectedPrices();
$discountDiff =
$this->
getTotalDiscountDiffSum($fixedTotalPrice,
$packages,
$affectedPrices);
// now calculate the correct price
// from our collected total discount price
$discountPrice =
$this->absolutePriceCalculator->
calculate( -