FINERACT-2182: Group creation fails due to NullPointerException when random-account-number=enabled

This commit is contained in:
a7med3del1973
2025-07-18 17:51:10 +02:00
committed by Arnold Gálovics
parent a30a34bea8
commit c0859f4fda
2 changed files with 110 additions and 18 deletions
@@ -193,28 +193,42 @@ public class AccountNumberGenerator {
return accountNumber;
}
private Boolean checkAccountNumberConflict(Map<String, String> propertyMap, AccountNumberFormat accountNumberFormat,
public Boolean checkAccountNumberConflict(Map<String, String> propertyMap, AccountNumberFormat accountNumberFormat,
String accountNumber) {
String entityType = propertyMap.get(ENTITY_TYPE);
Boolean randomNumberConflict = false;
if (entityType.equals("client")) { // avoid duplication it will loop until it finds new random account no.
Client client = this.clientRepository.getClientByAccountNumber(accountNumber);
if (client != null) {
randomNumberConflict = true;
}
} else if (entityType.equals("loan")) {
Loan loan = this.loanRepository.findLoanAccountByAccountNumber(accountNumber);
if (loan != null) {
randomNumberConflict = true;
}
} else if (entityType.equals("savingsAccount")) {
SavingsAccount savingsAccount = this.savingsAccountRepository.findSavingsAccountByAccountNumber(accountNumber);
if (savingsAccount != null) {
randomNumberConflict = true;
}
if (entityType == null) { // No entityType in map -> cannot check for conflicts.
return false;
}
boolean randomNumberConflict = false;
switch (entityType) {
case "client": // avoid duplication it will loop until it finds new random account no.
Client client = this.clientRepository.getClientByAccountNumber(accountNumber);
if (client != null) {
randomNumberConflict = true;
}
break;
case "loan":
Loan loan = this.loanRepository.findLoanAccountByAccountNumber(accountNumber);
if (loan != null) {
randomNumberConflict = true;
}
break;
case "savingsAccount":
SavingsAccount savingsAccount = this.savingsAccountRepository.findSavingsAccountByAccountNumber(accountNumber);
if (savingsAccount != null) {
randomNumberConflict = true;
}
break;
default:
break;
}
return randomNumberConflict;
}