Program: 58734
Project: 58734
Buggy source:
public List<InvoiceLine> createInvoiceLine(Invoice invoice,Product product,User user,String date,BigDecimal durationStored,int priority) throws AxelorException {
  Employee employee=user.getEmployee();
  int discountTypeSelect=1;
  if (product == null) {
    throw new AxelorException(String.format(I18n.get(IExceptionMessage.TIMESHEET_PRODUCT)),IException.CONFIGURATION_ERROR);
  }
  BigDecimal price=product.getSalePrice();
  BigDecimal discountAmount=product.getCostPrice();
  BigDecimal qtyConverted=durationStored;
  qtyConverted=Beans.get(UnitConversionService.class).convert(generalService.getGeneral().getUnitHours(),product.getUnit(),durationStored);
  if (employee != null) {
    if (employee.getTimeLoggingPreferenceSelect().equals(EmployeeRepository.TIME_PREFERENCE_DAYS)) {
      qtyConverted=Beans.get(UnitConversionService.class).convert(generalService.getGeneral().getUnitDays(),product.getUnit(),durationStored);
    }
 else     if (employee.getTimeLoggingPreferenceSelect().equals(EmployeeRepository.TIME_PREFERENCE_MINUTES)) {
      qtyConverted=Beans.get(UnitConversionService.class).convert(generalService.getGeneral().getUnitMinutes(),product.getUnit(),durationStored);
    }
  }
  PriceList priceList=invoice.getPartner().getSalePriceList();
  if (priceList != null) {
    PriceListLine priceListLine=priceListService.getPriceListLine(product,qtyConverted,priceList);
    if (priceListLine != null) {
      discountTypeSelect=priceListLine.getTypeSelect();
    }
    if ((generalService.getGeneral().getComputeMethodDiscountSelect() == GeneralRepository.INCLUDE_DISCOUNT_REPLACE_ONLY && discountTypeSelect == IPriceListLine.TYPE_REPLACE) || generalService.getGeneral().getComputeMethodDiscountSelect() == GeneralRepository.INCLUDE_DISCOUNT) {
      Map<String,Object> discounts=priceListService.getDiscounts(priceList,priceListLine,price);
      if (discounts != null) {
        discountAmount=(BigDecimal)discounts.get("String_Node_Str");
        price=priceListService.computeDiscount(price,(int)discounts.get("String_Node_Str"),discountAmount);
      }
    }
 else {
      Map<String,Object> discounts=priceListService.getDiscounts(priceList,priceListLine,price);
      if (discounts != null) {
        discountAmount=(BigDecimal)discounts.get("String_Node_Str");
        if (discounts.get("String_Node_Str") != null) {
          price=(BigDecimal)discounts.get("String_Node_Str");
        }
      }
    }
  }
  String description=user.getFullName(), productName=product.getName() + "String_Node_Str" + "String_Node_Str"+ date+ "String_Node_Str";
  InvoiceLineGenerator invoiceLineGenerator=new InvoiceLineGenerator(invoice,product,productName,price,price,description,qtyConverted,product.getUnit(),null,priority,discountAmount,discountTypeSelect,price.multiply(qtyConverted),null,false){
    @Override public List<InvoiceLine> creates() throws AxelorException {
      InvoiceLine invoiceLine=this.createInvoiceLine();
      List<InvoiceLine> invoiceLines=new ArrayList<InvoiceLine>();
      invoiceLines.add(invoiceLine);
      return invoiceLines;
    }
  }
;
  return invoiceLineGenerator.creates();
}

Fixed version (ground truth):
public List<InvoiceLine> createInvoiceLine(Invoice invoice,Product product,User user,String date,BigDecimal durationStored,int priority) throws AxelorException {
  Employee employee=user.getEmployee();
  int discountTypeSelect=1;
  if (product == null) {
    throw new AxelorException(String.format(I18n.get(IExceptionMessage.TIMESHEET_PRODUCT)),IException.CONFIGURATION_ERROR);
  }
  BigDecimal price=product.getSalePrice();
  BigDecimal discountAmount=product.getCostPrice();
  BigDecimal qtyConverted=durationStored;
  qtyConverted=Beans.get(UnitConversionService.class).convert(generalService.getGeneral().getUnitHours(),product.getUnit(),durationStored);
  PriceList priceList=invoice.getPartner().getSalePriceList();
  if (priceList != null) {
    PriceListLine priceListLine=priceListService.getPriceListLine(product,qtyConverted,priceList);
    if (priceListLine != null) {
      discountTypeSelect=priceListLine.getTypeSelect();
    }
    if ((generalService.getGeneral().getComputeMethodDiscountSelect() == GeneralRepository.INCLUDE_DISCOUNT_REPLACE_ONLY && discountTypeSelect == IPriceListLine.TYPE_REPLACE) || generalService.getGeneral().getComputeMethodDiscountSelect() == GeneralRepository.INCLUDE_DISCOUNT) {
      Map<String,Object> discounts=priceListService.getDiscounts(priceList,priceListLine,price);
      if (discounts != null) {
        discountAmount=(BigDecimal)discounts.get("String_Node_Str");
        price=priceListService.computeDiscount(price,(int)discounts.get("String_Node_Str"),discountAmount);
      }
    }
 else {
      Map<String,Object> discounts=priceListService.getDiscounts(priceList,priceListLine,price);
      if (discounts != null) {
        discountAmount=(BigDecimal)discounts.get("String_Node_Str");
        if (discounts.get("String_Node_Str") != null) {
          price=(BigDecimal)discounts.get("String_Node_Str");
        }
      }
    }
  }
  String description=user.getFullName(), productName=product.getName() + "String_Node_Str" + "String_Node_Str"+ date+ "String_Node_Str";
  InvoiceLineGenerator invoiceLineGenerator=new InvoiceLineGenerator(invoice,product,productName,price,price,description,qtyConverted,product.getUnit(),null,priority,discountAmount,discountTypeSelect,price.multiply(qtyConverted),null,false){
    @Override public List<InvoiceLine> creates() throws AxelorException {
      InvoiceLine invoiceLine=this.createInvoiceLine();
      List<InvoiceLine> invoiceLines=new ArrayList<InvoiceLine>();
      invoiceLines.add(invoiceLine);
      return invoiceLines;
    }
  }
;
  return invoiceLineGenerator.creates();
}