Program: 59183
Project: 59183
Buggy source:
@SuppressWarnings("String_Node_Str") public int useExcessPaymentWithAmountConsolidated(List<MoveLine> creditMoveLines,BigDecimal remainingPaidAmount,Move move,int moveLineNo,Partner partner,Company company,Account account,LocalDate date,LocalDate dueDate) throws AxelorException {
  LOG.debug("String_Node_Str");
  int moveLineNo2=moveLineNo;
  BigDecimal remainingPaidAmount2=remainingPaidAmount;
  List<Reconcile> reconcileList=new ArrayList<Reconcile>();
  int i=creditMoveLines.size();
  if (i != 0) {
    Query q=JPA.em().createQuery("String_Node_Str" + "String_Node_Str");
    q.setParameter(1,creditMoveLines);
    List<Map<Account,BigDecimal>> allMap=new ArrayList<Map<Account,BigDecimal>>();
    allMap=q.getResultList();
    for (    Map<Account,BigDecimal> map : allMap) {
      Account accountMap=(Account)map.values().toArray()[1];
      BigDecimal amountMap=(BigDecimal)map.values().toArray()[0];
      BigDecimal amountDebit=amountMap.min(remainingPaidAmount2);
      if (amountDebit.compareTo(BigDecimal.ZERO) > 0) {
        MoveLine debitMoveLine=mls.createMoveLine(move,partner,accountMap,amountDebit,true,false,date,dueDate,moveLineNo2,false,false,false,null);
        move.getMoveLineList().add(debitMoveLine);
        moveLineNo2++;
        for (        MoveLine creditMoveLine : creditMoveLines) {
          if (creditMoveLine.getAccount().equals(accountMap)) {
            Reconcile reconcile=null;
            i--;
            if (amountDebit.compareTo(BigDecimal.ZERO) < 0) {
              break;
            }
            BigDecimal amountToPay=amountDebit.min(creditMoveLine.getAmountRemaining());
            if (i == 0) {
              reconcile=rcs.createGenericReconcile(debitMoveLine,creditMoveLine,amountToPay,true,false,false);
            }
 else {
              reconcile=rcs.createGenericReconcile(debitMoveLine,creditMoveLine,amountToPay,false,false,false);
            }
            remainingPaidAmount2=remainingPaidAmount2.subtract(amountToPay);
            amountDebit=amountDebit.subtract(amountToPay);
            reconcileList.add(reconcile);
          }
        }
      }
    }
    for (    Reconcile reconcile : reconcileList) {
      rs.confirmReconcile(reconcile);
    }
  }
  if (remainingPaidAmount2.compareTo(BigDecimal.ZERO) > 0) {
    MoveLine debitmoveLine=mls.createMoveLine(move,partner,account,remainingPaidAmount2,true,false,date,dueDate,moveLineNo2,false,false,false,null);
    move.getMoveLineList().add(debitmoveLine);
    moveLineNo2++;
  }
  LOG.debug("String_Node_Str");
  return moveLineNo2;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public int useExcessPaymentWithAmountConsolidated(List<MoveLine> creditMoveLines,BigDecimal remainingPaidAmount,Move move,int moveLineNo,Partner partner,Company company,Account account,LocalDate date,LocalDate dueDate) throws AxelorException {
  LOG.debug("String_Node_Str");
  int moveLineNo2=moveLineNo;
  BigDecimal remainingPaidAmount2=remainingPaidAmount;
  List<Reconcile> reconcileList=new ArrayList<Reconcile>();
  int i=creditMoveLines.size();
  if (i != 0) {
    Query q=JPA.em().createQuery("String_Node_Str" + "String_Node_Str");
    q.setParameter(1,creditMoveLines);
    List<Map<Account,BigDecimal>> allMap=new ArrayList<Map<Account,BigDecimal>>();
    allMap=q.getResultList();
    for (    Map<Account,BigDecimal> map : allMap) {
      Account accountMap=(Account)map.values().toArray()[1];
      BigDecimal amountMap=(BigDecimal)map.values().toArray()[0];
      BigDecimal amountDebit=amountMap.min(remainingPaidAmount2);
      if (amountDebit.compareTo(BigDecimal.ZERO) > 0) {
        MoveLine debitMoveLine=mls.createMoveLine(move,partner,accountMap,amountDebit,true,false,date,dueDate,moveLineNo2,false,false,false,null);
        move.getMoveLineList().add(debitMoveLine);
        moveLineNo2++;
        for (        MoveLine creditMoveLine : creditMoveLines) {
          if (creditMoveLine.getAccount().equals(accountMap)) {
            Reconcile reconcile=null;
            i--;
            if (amountDebit.compareTo(BigDecimal.ZERO) <= 0) {
              break;
            }
            BigDecimal amountToPay=amountDebit.min(creditMoveLine.getAmountRemaining());
            if (i == 0) {
              reconcile=rcs.createGenericReconcile(debitMoveLine,creditMoveLine,amountToPay,true,false,false);
            }
 else {
              reconcile=rcs.createGenericReconcile(debitMoveLine,creditMoveLine,amountToPay,false,false,false);
            }
            remainingPaidAmount2=remainingPaidAmount2.subtract(amountToPay);
            amountDebit=amountDebit.subtract(amountToPay);
            reconcileList.add(reconcile);
          }
        }
      }
    }
    for (    Reconcile reconcile : reconcileList) {
      rs.confirmReconcile(reconcile);
    }
  }
  if (remainingPaidAmount2.compareTo(BigDecimal.ZERO) > 0) {
    MoveLine debitmoveLine=mls.createMoveLine(move,partner,account,remainingPaidAmount2,true,false,date,dueDate,moveLineNo2,false,false,false,null);
    move.getMoveLineList().add(debitmoveLine);
    moveLineNo2++;
  }
  LOG.debug("String_Node_Str");
  return moveLineNo2;
}