code: protected function calculateGoodLine(Model\DocumentLineInterface $line): ?Amount
      {
          if ($line->getType() !== Model\DocumentLineTypes::TYPE_GOOD) {
              throw new LogicException(sprintf(
                  "Expected document line with type '%s'.",
                  Model\DocumentLineTypes::TYPE_GOOD
              ));
          }
  
          if (null === $item = $line->getSaleItem()) {
              throw new LogicException("Document can't be recalculated.");
          }
  
          $result = $this->calculator->calculateSaleItem($item, $line->getQuantity());
  
          $this->syncLineWithResult($line, $result);
  
          if ($item->isPrivate()) {
              return null;
          }
  
          return $result;
      }
docs: Calculate the good line.
  
  @param Model\DocumentLineInterface $line
  
  @return Amount
  
  @throws LogicException