Program: 59010
Project: 59010
Buggy source:
public Move createMoveUseExcessPayment(Invoice invoice) throws AxelorException {
  Move move=null;
  Company company=invoice.getCompany();
  AccountConfig accountConfig=accountConfigService.getAccountConfig(company);
  List<MoveLine> creditMoveLineList=paymentService.getExcessPayment(invoice,accountConfigService.getCustomerAccount(accountConfig));
  if (creditMoveLineList != null && creditMoveLineList.size() != 0) {
    Partner partner=invoice.getPartner();
    Account account=invoice.getPartnerAccount();
    MoveLine invoiceCustomerMoveLine=this.getCustomerMoveLineByLoop(invoice);
    Journal journal=accountConfigService.getMiscOperationJournal(accountConfig);
    if (this.isSameAccount(creditMoveLineList,account)) {
      List<MoveLine> debitMoveLineList=new ArrayList<MoveLine>();
      debitMoveLineList.add(invoiceCustomerMoveLine);
      paymentService.useExcessPaymentOnMoveLines(debitMoveLineList,creditMoveLineList);
    }
 else {
      LOG.debug("String_Node_Str",new Object[]{invoice.getInvoiceId(),company.getName(),journal.getCode()});
      move=this.createMove(journal,company,null,partner,invoice.getInvoiceDate(),null);
      if (move != null) {
        BigDecimal totalCreditAmount=this.getTotalCreditAmount(creditMoveLineList);
        BigDecimal amount=totalCreditAmount.min(invoiceCustomerMoveLine.getDebit());
        MoveLine creditMoveLine=moveLineService.createMoveLine(move,partner,account,amount,false,false,toDay,1,null);
        move.getMoveLineList().add(creditMoveLine);
        paymentService.useExcessPaymentWithAmountConsolidated(creditMoveLineList,amount,move,2,partner,company,account,invoice.getInvoiceDate(),invoice.getDueDate());
        this.validateMove(move);
        Reconcile reconcile=reconcileService.createReconcile(invoiceCustomerMoveLine,creditMoveLine,amount);
        reconcileService.confirmReconcile(reconcile);
      }
    }
    invoice.setInTaxTotalRemaining(this.getInTaxTotalRemaining(invoice));
  }
  return move;
}

Fixed version (ground truth):
public Move createMoveUseExcessPayment(Invoice invoice) throws AxelorException {
  Move move=null;
  Company company=invoice.getCompany();
  AccountConfig accountConfig=accountConfigService.getAccountConfig(company);
  List<MoveLine> creditMoveLineList=(List<MoveLine>)paymentService.getExcessPayment(invoice,accountConfigService.getCustomerAccount(accountConfig));
  if (creditMoveLineList != null && creditMoveLineList.size() != 0) {
    Partner partner=invoice.getPartner();
    Account account=invoice.getPartnerAccount();
    MoveLine invoiceCustomerMoveLine=this.getCustomerMoveLineByLoop(invoice);
    Journal journal=accountConfigService.getMiscOperationJournal(accountConfig);
    if (this.isSameAccount(creditMoveLineList,account)) {
      List<MoveLine> debitMoveLineList=new ArrayList<MoveLine>();
      debitMoveLineList.add(invoiceCustomerMoveLine);
      paymentService.useExcessPaymentOnMoveLines(debitMoveLineList,creditMoveLineList);
    }
 else {
      LOG.debug("String_Node_Str",new Object[]{invoice.getInvoiceId(),company.getName(),journal.getCode()});
      move=this.createMove(journal,company,null,partner,invoice.getInvoiceDate(),null);
      if (move != null) {
        BigDecimal totalCreditAmount=this.getTotalCreditAmount(creditMoveLineList);
        BigDecimal amount=totalCreditAmount.min(invoiceCustomerMoveLine.getDebit());
        MoveLine creditMoveLine=moveLineService.createMoveLine(move,partner,account,amount,false,false,toDay,1,null);
        move.getMoveLineList().add(creditMoveLine);
        paymentService.useExcessPaymentWithAmountConsolidated(creditMoveLineList,amount,move,2,partner,company,account,invoice.getInvoiceDate(),invoice.getDueDate());
        this.validateMove(move);
        Reconcile reconcile=reconcileService.createReconcile(invoiceCustomerMoveLine,creditMoveLine,amount);
        reconcileService.confirmReconcile(reconcile);
      }
    }
    invoice.setInTaxTotalRemaining(this.getInTaxTotalRemaining(invoice));
  }
  return move;
}