FINERACT-1971
- validation added for the case when advanced repayment strategy is used with empty or missing allocation rules.
This commit is contained in:
+4
-4
@@ -39,8 +39,9 @@ public class AdvancedPaymentAllocationsJsonParser {
|
||||
public List<LoanProductPaymentAllocationRule> assembleLoanProductPaymentAllocationRules(final JsonCommand command,
|
||||
String loanTransactionProcessingStrategyCode) {
|
||||
JsonArray paymentAllocations = command.arrayOfParameterNamed("paymentAllocation");
|
||||
List<LoanProductPaymentAllocationRule> productPaymentAllocationRules = null;
|
||||
if (paymentAllocations != null) {
|
||||
List<LoanProductPaymentAllocationRule> productPaymentAllocationRules = paymentAllocations.asList().stream().map(json -> {
|
||||
productPaymentAllocationRules = paymentAllocations.asList().stream().map(json -> {
|
||||
Map<String, JsonElement> map = json.getAsJsonObject().asMap();
|
||||
LoanProductPaymentAllocationRule loanProductPaymentAllocationRule = new LoanProductPaymentAllocationRule();
|
||||
populatePaymentAllocationRules(map, loanProductPaymentAllocationRule);
|
||||
@@ -48,10 +49,9 @@ public class AdvancedPaymentAllocationsJsonParser {
|
||||
populateTransactionType(map, loanProductPaymentAllocationRule);
|
||||
return loanProductPaymentAllocationRule;
|
||||
}).toList();
|
||||
advancedPaymentAllocationsValidator.validate(productPaymentAllocationRules, loanTransactionProcessingStrategyCode);
|
||||
return productPaymentAllocationRules;
|
||||
}
|
||||
return null;
|
||||
advancedPaymentAllocationsValidator.validate(productPaymentAllocationRules, loanTransactionProcessingStrategyCode);
|
||||
return productPaymentAllocationRules;
|
||||
}
|
||||
|
||||
private void populatePaymentAllocationRules(Map<String, JsonElement> map,
|
||||
|
||||
+4
-3
@@ -73,7 +73,8 @@ public class AdvancedPaymentAllocationsValidator {
|
||||
}
|
||||
|
||||
private boolean hasDuplicateTransactionTypes(List<LoanProductPaymentAllocationRule> rules) {
|
||||
return rules.stream().map(LoanProductPaymentAllocationRule::getTransactionType).distinct().toList().size() != rules.size();
|
||||
return rules != null
|
||||
&& rules.stream().map(LoanProductPaymentAllocationRule::getTransactionType).distinct().toList().size() != rules.size();
|
||||
}
|
||||
|
||||
private void validateAllocationRule(LoanProductPaymentAllocationRule rule) {
|
||||
@@ -92,14 +93,14 @@ public class AdvancedPaymentAllocationsValidator {
|
||||
}
|
||||
|
||||
private boolean hasAtLeastOneDefaultPaymentAllocation(List<LoanProductPaymentAllocationRule> rules) {
|
||||
return rules.stream() //
|
||||
return rules != null && rules.stream() //
|
||||
.filter(r -> PaymentAllocationTransactionType.DEFAULT.equals(r.getTransactionType())) //
|
||||
.toList() //
|
||||
.size() > 0;
|
||||
}
|
||||
|
||||
private boolean hasLoanProductPaymentAllocationRule(List<LoanProductPaymentAllocationRule> rules) {
|
||||
return rules.size() > 0;
|
||||
return rules != null && rules.size() > 0;
|
||||
}
|
||||
|
||||
private void raiseValidationError(String globalisationMessageCode, String msg) {
|
||||
|
||||
Reference in New Issue
Block a user