Program: 59118
Project: 59118
Buggy source:
public PurchaseOrderLine createPurchaseOrderLine(PurchaseOrder purchaseOrder,Product product,String description,ProductVariant productVariant,BigDecimal qty,Unit unit,Task task) throws AxelorException {
  PurchaseOrderLine purchaseOrderLine=new PurchaseOrderLine();
  purchaseOrderLine.setAmountInvoiced(BigDecimal.ZERO);
  purchaseOrderLine.setDeliveryDate(purchaseOrder.getDeliveryDate());
  purchaseOrderLine.setDescription(description);
  purchaseOrderLine.setIsInvoiced(false);
  purchaseOrderLine.setIsOrdered(false);
  BigDecimal price=this.getUnitPrice(purchaseOrder,purchaseOrderLine);
  PriceList priceList=purchaseOrder.getPriceList();
  if (priceList != null) {
    PriceListLine priceListLine=this.getPriceListLine(purchaseOrderLine,priceList);
    Map<String,Object> discounts=priceListService.getDiscounts(priceList,priceListLine,price);
    purchaseOrderLine.setDiscountAmount((BigDecimal)discounts.get("String_Node_Str"));
    purchaseOrderLine.setDiscountTypeSelect((Integer)discounts.get("String_Node_Str"));
    if (discounts.get("String_Node_Str") != null) {
      price=(BigDecimal)discounts.get("String_Node_Str");
    }
  }
  purchaseOrderLine.setPrice(price);
  purchaseOrderLine.setProduct(product);
  purchaseOrderLine.setProductName(product.getName());
  purchaseOrderLine.setProductVariant(productVariant);
  purchaseOrderLine.setPurchaseOrder(purchaseOrder);
  purchaseOrderLine.setQty(qty);
  purchaseOrderLine.setSequence(sequence);
  sequence++;
  purchaseOrderLine.setTask(task);
  purchaseOrderLine.setUnit(unit);
  purchaseOrderLine.setTaxLine(this.getTaxLine(purchaseOrder,purchaseOrderLine));
  BigDecimal exTaxTotal=PurchaseOrderLineService.computeAmount(purchaseOrderLine.getQty(),this.computeDiscount(purchaseOrderLine));
  BigDecimal companyExTaxTotal=this.getCompanyExTaxTotal(exTaxTotal,purchaseOrder);
  purchaseOrderLine.setExTaxTotal(exTaxTotal);
  purchaseOrderLine.setCompanyExTaxTotal(companyExTaxTotal);
  purchaseOrderLine.setAmountRemainingToBeInvoiced(exTaxTotal);
  return purchaseOrderLine;
}

Fixed version (ground truth):
public PurchaseOrderLine createPurchaseOrderLine(PurchaseOrder purchaseOrder,Product product,String description,ProductVariant productVariant,BigDecimal qty,Unit unit,Task task) throws AxelorException {
  PurchaseOrderLine purchaseOrderLine=new PurchaseOrderLine();
  purchaseOrderLine.setPurchaseOrder(purchaseOrder);
  purchaseOrderLine.setAmountInvoiced(BigDecimal.ZERO);
  purchaseOrderLine.setDeliveryDate(purchaseOrder.getDeliveryDate());
  purchaseOrderLine.setDescription(description);
  purchaseOrderLine.setIsInvoiced(false);
  purchaseOrderLine.setIsOrdered(false);
  purchaseOrderLine.setProduct(product);
  purchaseOrderLine.setProductName(product.getName());
  purchaseOrderLine.setProductVariant(productVariant);
  purchaseOrderLine.setQty(qty);
  purchaseOrderLine.setSequence(sequence);
  sequence++;
  purchaseOrderLine.setTask(task);
  purchaseOrderLine.setUnit(unit);
  purchaseOrderLine.setTaxLine(this.getTaxLine(purchaseOrder,purchaseOrderLine));
  BigDecimal price=this.getUnitPrice(purchaseOrder,purchaseOrderLine);
  PriceList priceList=purchaseOrder.getPriceList();
  if (priceList != null) {
    PriceListLine priceListLine=this.getPriceListLine(purchaseOrderLine,priceList);
    Map<String,Object> discounts=priceListService.getDiscounts(priceList,priceListLine,price);
    purchaseOrderLine.setDiscountAmount((BigDecimal)discounts.get("String_Node_Str"));
    purchaseOrderLine.setDiscountTypeSelect((Integer)discounts.get("String_Node_Str"));
    if (discounts.get("String_Node_Str") != null) {
      price=(BigDecimal)discounts.get("String_Node_Str");
    }
  }
  purchaseOrderLine.setPrice(price);
  BigDecimal exTaxTotal=PurchaseOrderLineService.computeAmount(purchaseOrderLine.getQty(),this.computeDiscount(purchaseOrderLine));
  BigDecimal companyExTaxTotal=this.getCompanyExTaxTotal(exTaxTotal,purchaseOrder);
  purchaseOrderLine.setExTaxTotal(exTaxTotal);
  purchaseOrderLine.setCompanyExTaxTotal(companyExTaxTotal);
  purchaseOrderLine.setAmountRemainingToBeInvoiced(exTaxTotal);
  return purchaseOrderLine;
}