protected function calculateDiscountLine(Model\DocumentLineInterface $line, Amount $gross, Amount $final)
    {
        if ($line->getType() !== Model\DocumentLineTypes::TYPE_DISCOUNT) {
            throw new LogicException(sprintf(
                "Expected document line with type '%s'.",
                Model\DocumentLineTypes::TYPE_DISCOUNT
            ));
        }

        /** @var Common\SaleAdjustmentInterface $adjustment */
        if (null === $adjustment = $line->getSaleAdjustment()) {
            throw new LogicException("Document can't be recalculated.");
        }

        $result = $this->calculator->calculateSaleDiscount($adjustment, $gross, $final);

        $this->syncLineWithResult($line, $result);
    }
protected function calculateDiscountLine(Model\DocumentLineInterface $line, Amount $gross, Amount $final)
    {
        if ($line->getType() !== Model\DocumentLineTypes::TYPE_DISCOUNT) {
            throw new LogicException(sprintf(
                "Expected document line with type '%s'.",
                Model\DocumentLineTypes::TYPE_DISCOUNT
            ));
        }

        /** @var Common\SaleAdjustmentInterface $adjustment */
        if (null === $adjustment = $line->getSaleAdjustment()) {
            throw new LogicException("Document can't be recalculated.");
        }

        $result = $this->calculator->calculateSaleDiscount($adjustment, $gross, $final);

        $this->syncLineWithResult($line, $result);
    }
protected function calculateDiscountLine ( Model \ DocumentLineInterface $ line , Amount $ gross , Amount $ final ) { if ( $ line -> getType ( ) !== Model \ DocumentLineTypes :: TYPE_DISCOUNT ) { throw new LogicException ( sprintf ( "Expected document line with type '%s'." , Model \ DocumentLineTypes :: TYPE_DISCOUNT ) ) ; } /** @var Common\SaleAdjustmentInterface $adjustment */ if ( null === $ adjustment = $ line -> getSaleAdjustment ( ) ) { throw new LogicException ( "Document can't be recalculated." ) ; } $ result = $ this -> calculator -> calculateSaleDiscount ( $ adjustment , $ gross , $ final ) ; $ this -> syncLineWithResult ( $ line , $ result ) ; }
Calculate the discount line.

@param Model\DocumentLineInterface $line
@param Amount                      $gross
@param Amount                      $final

@throws LogicException
Calculate the discount line .