Program: 58749
Project: 58749
Buggy source:
/** 
 * Method to create a payment move for an invoice Payment Create a move and reconcile it with the invoice move
 * @param invoicePayment An invoice payment
 * @throws AxelorException
 */
@Transactional(rollbackOn={AxelorException.class,Exception.class}) public Move createMoveForInvoicePayment(InvoicePayment invoicePayment) throws AxelorException {
  Invoice invoice=invoicePayment.getInvoice();
  Company company=invoice.getCompany();
  PaymentMode paymentMode=invoicePayment.getPaymentMode();
  Partner partner=invoice.getPartner();
  LocalDate paymentDate=invoicePayment.getPaymentDate();
  Journal journal=paymentModeService.getPaymentModeJournal(paymentMode,company);
  boolean isDebitInvoice=moveService.getMoveToolService().isDebitCustomer(invoice);
  MoveLine invoiceMoveLine=moveService.getMoveToolService().getInvoiceCustomerMoveLineByLoop(invoice);
  Move move=moveService.getMoveCreateService().createMove(journal,company,null,partner,paymentDate,paymentMode);
  BigDecimal amountConverted=currencyService.getAmountCurrencyConverted(invoicePayment.getCurrency(),invoice.getCurrency(),invoicePayment.getAmount(),paymentDate);
  move.addMoveLineListItem(moveLineService.createMoveLine(move,partner,paymentModeService.getPaymentModeAccount(paymentMode,company),amountConverted,isDebitInvoice,paymentDate,null,1,"String_Node_Str"));
  MoveLine customerMoveLine=moveLineService.createMoveLine(move,partner,invoiceMoveLine.getAccount(),amountConverted,!isDebitInvoice,paymentDate,null,2,"String_Node_Str");
  move.addMoveLineListItem(customerMoveLine);
  moveService.getMoveValidateService().validate(move);
  Reconcile reconcile=reconcileService.reconcile(invoiceMoveLine,customerMoveLine,true);
  invoicePayment.setReconcile(reconcile);
  invoicePayment.setMove(move);
  invoicePaymentRepository.save(invoicePayment);
  return move;
}

Fixed version (ground truth):
/** 
 * Method to create a payment move for an invoice Payment Create a move and reconcile it with the invoice move
 * @param invoicePayment An invoice payment
 * @throws AxelorException
 */
@Transactional(rollbackOn={AxelorException.class,Exception.class}) public Move createMoveForInvoicePayment(InvoicePayment invoicePayment) throws AxelorException {
  Invoice invoice=invoicePayment.getInvoice();
  Company company=invoice.getCompany();
  PaymentMode paymentMode=invoicePayment.getPaymentMode();
  Partner partner=invoice.getPartner();
  LocalDate paymentDate=invoicePayment.getPaymentDate();
  Journal journal=paymentModeService.getPaymentModeJournal(paymentMode,company);
  boolean isDebitInvoice=moveService.getMoveToolService().isDebitCustomer(invoice,true);
  MoveLine invoiceMoveLine=moveService.getMoveToolService().getInvoiceCustomerMoveLineByLoop(invoice);
  Move move=moveService.getMoveCreateService().createMove(journal,company,null,partner,paymentDate,paymentMode);
  BigDecimal amountConverted=currencyService.getAmountCurrencyConverted(invoicePayment.getCurrency(),invoice.getCurrency(),invoicePayment.getAmount(),paymentDate);
  move.addMoveLineListItem(moveLineService.createMoveLine(move,partner,paymentModeService.getPaymentModeAccount(paymentMode,company),amountConverted,isDebitInvoice,paymentDate,null,1,"String_Node_Str"));
  MoveLine customerMoveLine=moveLineService.createMoveLine(move,partner,invoiceMoveLine.getAccount(),amountConverted,!isDebitInvoice,paymentDate,null,2,"String_Node_Str");
  move.addMoveLineListItem(customerMoveLine);
  moveService.getMoveValidateService().validate(move);
  Reconcile reconcile=reconcileService.reconcile(invoiceMoveLine,customerMoveLine,true);
  invoicePayment.setReconcile(reconcile);
  invoicePayment.setMove(move);
  invoicePaymentRepository.save(invoicePayment);
  return move;
}