Program: 58916
Project: 58916
Buggy source:
public void compute(ActionRequest request,ActionResponse response) throws AxelorException {
  PurchaseOrderLine purchaseOrderLine=request.getContext().asType(PurchaseOrderLine.class);
  BigDecimal exTaxTotal=BigDecimal.ZERO;
  BigDecimal companyExTaxTotal=BigDecimal.ZERO;
  BigDecimal inTaxTotal=BigDecimal.ZERO;
  BigDecimal companyInTaxTotal=BigDecimal.ZERO;
  BigDecimal priceDiscounted=BigDecimal.ZERO;
  if (purchaseOrderLine.getTaxLine() == null) {
    throw new AxelorException(String.format(I18n.get(IExceptionMessage.PURCHASE_ORDER_LINE_TAX_LINE)),IException.CONFIGURATION_ERROR);
  }
  try {
    if (!request.getContext().getParentContext().asType(PurchaseOrder.class).getInAti()) {
      if (purchaseOrderLine.getPrice() != null && purchaseOrderLine.getQty() != null) {
        exTaxTotal=PurchaseOrderLineServiceImpl.computeAmount(purchaseOrderLine.getQty(),purchaseOrderLineService.computeDiscount(purchaseOrderLine));
        inTaxTotal=exTaxTotal.add(exTaxTotal.multiply(purchaseOrderLine.getTaxLine().getValue()));
        priceDiscounted=purchaseOrderLineService.computeDiscount(purchaseOrderLine);
      }
      if (exTaxTotal != null) {
        PurchaseOrder purchaseOrder=purchaseOrderLine.getPurchaseOrder();
        if (purchaseOrder == null) {
          purchaseOrder=request.getContext().getParentContext().asType(PurchaseOrder.class);
        }
        if (purchaseOrder != null) {
          companyExTaxTotal=purchaseOrderLineService.getCompanyExTaxTotal(exTaxTotal,purchaseOrder);
          companyInTaxTotal=companyExTaxTotal.add(companyExTaxTotal.multiply(purchaseOrderLine.getTaxLine().getValue()));
          response.setValue("String_Node_Str",purchaseOrderLineService.getMinSalePrice(purchaseOrder,purchaseOrderLine));
          response.setValue("String_Node_Str",purchaseOrderLineService.getSalePrice(purchaseOrder,purchaseOrderLine.getPrice()));
        }
      }
      response.setValue("String_Node_Str",exTaxTotal);
      response.setValue("String_Node_Str",inTaxTotal);
      response.setValue("String_Node_Str",companyExTaxTotal);
      response.setValue("String_Node_Str",companyInTaxTotal);
      response.setValue("String_Node_Str",priceDiscounted);
    }
 else {
      if (purchaseOrderLine.getPrice() != null && purchaseOrderLine.getQty() != null) {
        inTaxTotal=PurchaseOrderLineServiceImpl.computeAmount(purchaseOrderLine.getQty(),purchaseOrderLineService.computeDiscount(purchaseOrderLine));
        exTaxTotal=inTaxTotal.divide(purchaseOrderLine.getTaxLine().getValue().add(new BigDecimal(1)),2,BigDecimal.ROUND_HALF_UP);
        priceDiscounted=purchaseOrderLineService.computeDiscount(purchaseOrderLine);
      }
      if (inTaxTotal != null) {
        PurchaseOrder purchaseOrder=purchaseOrderLine.getPurchaseOrder();
        if (purchaseOrder == null) {
          purchaseOrder=request.getContext().getParentContext().asType(PurchaseOrder.class);
        }
        if (purchaseOrder != null) {
          companyInTaxTotal=purchaseOrderLineService.getCompanyExTaxTotal(inTaxTotal,purchaseOrder);
          companyExTaxTotal=companyInTaxTotal.divide(purchaseOrderLine.getTaxLine().getValue().add(new BigDecimal(1)),2,BigDecimal.ROUND_HALF_UP);
          response.setValue("String_Node_Str",purchaseOrderLineService.getMinSalePrice(purchaseOrder,purchaseOrderLine));
          response.setValue("String_Node_Str",purchaseOrderLineService.getSalePrice(purchaseOrder,purchaseOrderLine.getPrice()));
        }
      }
      response.setValue("String_Node_Str",exTaxTotal);
      response.setValue("String_Node_Str",inTaxTotal);
      response.setValue("String_Node_Str",companyInTaxTotal);
      response.setValue("String_Node_Str",companyExTaxTotal);
      response.setValue("String_Node_Str",priceDiscounted);
    }
  }
 catch (  Exception e) {
    response.setFlash(e.getMessage());
  }
}

Fixed version (ground truth):
public void compute(ActionRequest request,ActionResponse response) throws AxelorException {
  PurchaseOrderLine purchaseOrderLine=request.getContext().asType(PurchaseOrderLine.class);
  BigDecimal exTaxTotal=BigDecimal.ZERO;
  BigDecimal companyExTaxTotal=BigDecimal.ZERO;
  BigDecimal inTaxTotal=BigDecimal.ZERO;
  BigDecimal companyInTaxTotal=BigDecimal.ZERO;
  BigDecimal priceDiscounted=BigDecimal.ZERO;
  if (purchaseOrderLine.getTaxLine() == null) {
    throw new AxelorException(String.format(I18n.get(IExceptionMessage.PURCHASE_ORDER_LINE_TAX_LINE)),IException.CONFIGURATION_ERROR);
  }
  try {
    if (!request.getContext().getParentContext().asType(PurchaseOrder.class).getInAti()) {
      if (purchaseOrderLine.getPrice() != null && purchaseOrderLine.getQty() != null) {
        exTaxTotal=PurchaseOrderLineServiceImpl.computeAmount(purchaseOrderLine.getQty(),purchaseOrderLineService.computeDiscount(purchaseOrderLine));
        inTaxTotal=exTaxTotal.add(exTaxTotal.multiply(purchaseOrderLine.getTaxLine().getValue()));
        priceDiscounted=purchaseOrderLineService.computeDiscount(purchaseOrderLine).setScale(GeneralService.getNbDecimalDigitForUnitPrice(),RoundingMode.HALF_UP);
      }
      if (exTaxTotal != null) {
        PurchaseOrder purchaseOrder=purchaseOrderLine.getPurchaseOrder();
        if (purchaseOrder == null) {
          purchaseOrder=request.getContext().getParentContext().asType(PurchaseOrder.class);
        }
        if (purchaseOrder != null) {
          companyExTaxTotal=purchaseOrderLineService.getCompanyExTaxTotal(exTaxTotal,purchaseOrder);
          companyInTaxTotal=companyExTaxTotal.add(companyExTaxTotal.multiply(purchaseOrderLine.getTaxLine().getValue()));
          response.setValue("String_Node_Str",purchaseOrderLineService.getMinSalePrice(purchaseOrder,purchaseOrderLine));
          response.setValue("String_Node_Str",purchaseOrderLineService.getSalePrice(purchaseOrder,purchaseOrderLine.getPrice()));
        }
      }
      response.setValue("String_Node_Str",exTaxTotal);
      response.setValue("String_Node_Str",inTaxTotal);
      response.setValue("String_Node_Str",companyExTaxTotal);
      response.setValue("String_Node_Str",companyInTaxTotal);
      response.setValue("String_Node_Str",priceDiscounted);
    }
 else {
      if (purchaseOrderLine.getPrice() != null && purchaseOrderLine.getQty() != null) {
        inTaxTotal=PurchaseOrderLineServiceImpl.computeAmount(purchaseOrderLine.getQty(),purchaseOrderLineService.computeDiscount(purchaseOrderLine));
        exTaxTotal=inTaxTotal.divide(purchaseOrderLine.getTaxLine().getValue().add(new BigDecimal(1)),2,BigDecimal.ROUND_HALF_UP);
        priceDiscounted=purchaseOrderLineService.computeDiscount(purchaseOrderLine);
      }
      if (inTaxTotal != null) {
        PurchaseOrder purchaseOrder=purchaseOrderLine.getPurchaseOrder();
        if (purchaseOrder == null) {
          purchaseOrder=request.getContext().getParentContext().asType(PurchaseOrder.class);
        }
        if (purchaseOrder != null) {
          companyInTaxTotal=purchaseOrderLineService.getCompanyExTaxTotal(inTaxTotal,purchaseOrder);
          companyExTaxTotal=companyInTaxTotal.divide(purchaseOrderLine.getTaxLine().getValue().add(new BigDecimal(1)),2,BigDecimal.ROUND_HALF_UP);
          response.setValue("String_Node_Str",purchaseOrderLineService.getMinSalePrice(purchaseOrder,purchaseOrderLine));
          response.setValue("String_Node_Str",purchaseOrderLineService.getSalePrice(purchaseOrder,purchaseOrderLine.getPrice()));
        }
      }
      response.setValue("String_Node_Str",exTaxTotal);
      response.setValue("String_Node_Str",inTaxTotal);
      response.setValue("String_Node_Str",companyInTaxTotal);
      response.setValue("String_Node_Str",companyExTaxTotal);
      response.setValue("String_Node_Str",priceDiscounted);
    }
  }
 catch (  Exception e) {
    response.setFlash(e.getMessage());
  }
}