Program: 59184
Project: 59184
Buggy source:
@Deprecated public int useExcessPaymentWithAmount(List<MoveLine> creditMoveLines,BigDecimal remainingPaidAmount,Move move,int moveLineNo,Partner partner,Company company,Account account) throws AxelorException {
  LOG.debug("String_Node_Str");
  int moveLineNo2=moveLineNo;
  BigDecimal remainingPaidAmount2=remainingPaidAmount;
  List<Reconcile> reconcileList=new ArrayList<Reconcile>();
  int i=creditMoveLines.size();
  for (  MoveLine creditMoveLine : creditMoveLines) {
    i--;
    BigDecimal amountRemaining=creditMoveLine.getAmountRemaining();
    if (remainingPaidAmount2.compareTo(BigDecimal.ZERO) < 0) {
      break;
    }
    BigDecimal amountToPay=remainingPaidAmount2.min(amountRemaining);
    MoveLine debitMoveLine=mls.createMoveLine(move,creditMoveLine.getPartner(),creditMoveLine.getAccount(),amountToPay,true,false,this.date,moveLineNo2,false,false,false,creditMoveLine.getName());
    move.getMoveLineList().add(debitMoveLine);
    moveLineNo2++;
    Reconcile reconcile=null;
    if (i == 0) {
      reconcile=rcs.createGenericReconcile(debitMoveLine,creditMoveLine,amountToPay,true,false,false);
    }
 else {
      reconcile=rcs.createGenericReconcile(debitMoveLine,creditMoveLine,amountToPay,false,false,false);
    }
    reconcileList.add(reconcile);
    remainingPaidAmount2=remainingPaidAmount2.subtract(amountToPay);
  }
  for (  Reconcile reconcile : reconcileList) {
    rs.confirmReconcile(reconcile);
  }
  if (remainingPaidAmount2.compareTo(BigDecimal.ZERO) > 0) {
    MoveLine debitmoveLine=mls.createMoveLine(move,partner,account,remainingPaidAmount2,true,false,this.date,moveLineNo2,false,false,false,null);
    move.getMoveLineList().add(debitmoveLine);
    moveLineNo2++;
    rs.balanceCredit(debitmoveLine,company,true);
  }
  LOG.debug("String_Node_Str");
  return moveLineNo2;
}

Fixed version (ground truth):
@Deprecated public int useExcessPaymentWithAmount(List<MoveLine> creditMoveLines,BigDecimal remainingPaidAmount,Move move,int moveLineNo,Partner partner,Company company,Account account) throws AxelorException {
  LOG.debug("String_Node_Str");
  int moveLineNo2=moveLineNo;
  BigDecimal remainingPaidAmount2=remainingPaidAmount;
  List<Reconcile> reconcileList=new ArrayList<Reconcile>();
  int i=creditMoveLines.size();
  for (  MoveLine creditMoveLine : creditMoveLines) {
    i--;
    BigDecimal amountRemaining=creditMoveLine.getAmountRemaining();
    if (remainingPaidAmount2.compareTo(BigDecimal.ZERO) <= 0) {
      break;
    }
    BigDecimal amountToPay=remainingPaidAmount2.min(amountRemaining);
    MoveLine debitMoveLine=mls.createMoveLine(move,creditMoveLine.getPartner(),creditMoveLine.getAccount(),amountToPay,true,false,this.date,moveLineNo2,false,false,false,creditMoveLine.getName());
    move.getMoveLineList().add(debitMoveLine);
    moveLineNo2++;
    Reconcile reconcile=null;
    if (i == 0) {
      reconcile=rcs.createGenericReconcile(debitMoveLine,creditMoveLine,amountToPay,true,false,false);
    }
 else {
      reconcile=rcs.createGenericReconcile(debitMoveLine,creditMoveLine,amountToPay,false,false,false);
    }
    reconcileList.add(reconcile);
    remainingPaidAmount2=remainingPaidAmount2.subtract(amountToPay);
  }
  for (  Reconcile reconcile : reconcileList) {
    rs.confirmReconcile(reconcile);
  }
  if (remainingPaidAmount2.compareTo(BigDecimal.ZERO) > 0) {
    MoveLine debitmoveLine=mls.createMoveLine(move,partner,account,remainingPaidAmount2,true,false,this.date,moveLineNo2,false,false,false,null);
    move.getMoveLineList().add(debitmoveLine);
    moveLineNo2++;
    rs.balanceCredit(debitmoveLine,company,true);
  }
  LOG.debug("String_Node_Str");
  return moveLineNo2;
}