code: protected function syncLineWithResult(Model\DocumentLineInterface $line, Amount $result)
      {
          // TODO Currency conversions
  
          // Unit
          if ($line->getUnit() !== $result->getUnit()) {
              $line->setUnit($result->getUnit());
              $this->changed = true;
          }
          // Gross
          if ($line->getGross() !== $result->getGross()) {
              $line->setGross($result->getGross());
              $this->changed = true;
          }
          // Discount
          if ($line->getDiscount() !== $result->getDiscount()) {
              $line->setDiscount($result->getDiscount());
              $this->changed = true;
          }
          // Discount rates
          $discountRates = [];
          if (!empty($adjustments = $result->getDiscountAdjustments())) {
              foreach ($adjustments as $adjustment) {
                  $discountRates[] = $adjustment->getRate();
              }
          }
          if ($discountRates !== $line->getDiscountRates()) {
              $line->setDiscountRates($discountRates);
              $this->changed = true;
          }
          // Base
          if ($line->getBase() !== $result->getBase()) {
              $line->setBase($result->getBase());
              $this->changed = true;
          }
          // Tax
          if ($line->getTax() !== $result->getTax()) {
              $line->setTax($result->getTax());
              $this->changed = true;
          }
          // Tax rates
          $taxRates = [];
          if (!empty($adjustments = $result->getTaxAdjustments())) {
              foreach ($adjustments as $adjustment) {
                  $taxRates[] = $adjustment->getRate();
              }
          }
          if ($taxRates !== $line->getTaxRates()) {
              $line->setTaxRates($taxRates);
              $this->changed = true;
          }
          // Total
          if ($line->getTotal() !== $result->getTotal()) {
              $line->setTotal($result->getTotal());
              $this->changed = true;
          }
      }
docs: Synchronizes the line amounts with the given result.
  
  @param Model\DocumentLineInterface $line
  @param Amount                      $result