Program: 58958
Project: 58958
Buggy source:
/** 
 * @return
 * @throws AxelorException 
 */
protected InvoiceLine createInvoiceLine() throws AxelorException {
  InvoiceLine invoiceLine=new InvoiceLine();
  invoiceLine.setInvoice(invoice);
  invoiceLine.setProduct(product);
  invoiceLine.setProductName(productName);
  invoiceLine.setDescription(description);
  invoiceLine.setPrice(price);
  invoiceLine.setQty(qty);
  if (exTaxTotal == null) {
    exTaxTotal=computeAmount(qty,price);
  }
  invoiceLine.setExTaxTotal(exTaxTotal);
  Partner partner=invoice.getPartner();
  Currency partnerCurrency=partner.getCurrency();
  if (partnerCurrency == null) {
    throw new AxelorException(String.format(I18n.get(IExceptionMessage.INVOICE_LINE_GENERATOR_1),partner.getFullName(),partner.getPartnerSeq()),IException.CONFIGURATION_ERROR);
  }
  invoiceLine.setAccountingExTaxTotal(currencyService.getAmountCurrencyConverted(invoice.getCurrency(),partnerCurrency,exTaxTotal,invoice.getInvoiceDate()));
  Company company=invoice.getCompany();
  Currency companyCurrency=company.getCurrency();
  if (companyCurrency == null) {
    throw new AxelorException(String.format(I18n.get(IExceptionMessage.INVOICE_LINE_GENERATOR_2),company.getName()),IException.CONFIGURATION_ERROR);
  }
  invoiceLine.setCompanyExTaxTotal(currencyService.getAmountCurrencyConverted(invoice.getCurrency(),companyCurrency,exTaxTotal,invoice.getInvoiceDate()));
  invoiceLine.setPricingListUnit(unit);
  if (taxLine == null) {
    boolean isPurchase=false;
    if (invoice.getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE || invoice.getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_REFUND) {
      isPurchase=true;
    }
    taxLine=accountManagementServiceImpl.getTaxLine(invoice.getInvoiceDate(),product,invoice.getCompany(),partner.getFiscalPosition(),isPurchase);
  }
  invoiceLine.setTaxLine(taxLine);
  invoiceLine.setInvoiceLineType(invoiceLineType);
  invoiceLine.setSequence(sequence);
  invoiceLine.setDiscountTypeSelect(discountTypeSelect);
  invoiceLine.setDiscountAmount(discountAmount);
  return invoiceLine;
}

Fixed version (ground truth):
/** 
 * @return
 * @throws AxelorException 
 */
protected InvoiceLine createInvoiceLine() throws AxelorException {
  InvoiceLine invoiceLine=new InvoiceLine();
  invoiceLine.setInvoice(invoice);
  invoiceLine.setProduct(product);
  invoiceLine.setProductName(productName);
  invoiceLine.setDescription(description);
  invoiceLine.setPrice(price);
  invoiceLine.setQty(qty);
  invoiceLine.setUnit(unit);
  if (exTaxTotal == null) {
    exTaxTotal=computeAmount(qty,price);
  }
  invoiceLine.setExTaxTotal(exTaxTotal);
  Partner partner=invoice.getPartner();
  Currency partnerCurrency=partner.getCurrency();
  if (partnerCurrency == null) {
    throw new AxelorException(String.format(I18n.get(IExceptionMessage.INVOICE_LINE_GENERATOR_1),partner.getFullName(),partner.getPartnerSeq()),IException.CONFIGURATION_ERROR);
  }
  invoiceLine.setAccountingExTaxTotal(currencyService.getAmountCurrencyConverted(invoice.getCurrency(),partnerCurrency,exTaxTotal,today));
  Company company=invoice.getCompany();
  Currency companyCurrency=company.getCurrency();
  if (companyCurrency == null) {
    throw new AxelorException(String.format(I18n.get(IExceptionMessage.INVOICE_LINE_GENERATOR_2),company.getName()),IException.CONFIGURATION_ERROR);
  }
  invoiceLine.setCompanyExTaxTotal(currencyService.getAmountCurrencyConverted(invoice.getCurrency(),companyCurrency,exTaxTotal,today));
  if (taxLine == null) {
    boolean isPurchase=false;
    if (invoice.getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_PURCHASE || invoice.getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_SUPPLIER_REFUND) {
      isPurchase=true;
    }
    taxLine=accountManagementServiceImpl.getTaxLine(today,product,invoice.getCompany(),partner.getFiscalPosition(),isPurchase);
  }
  invoiceLine.setTaxLine(taxLine);
  invoiceLine.setInvoiceLineType(invoiceLineType);
  invoiceLine.setSequence(sequence);
  invoiceLine.setDiscountTypeSelect(discountTypeSelect);
  invoiceLine.setDiscountAmount(discountAmount);
  return invoiceLine;
}