FINERACT-1971: Loan transaction processing strategy validation fix

This commit is contained in:
taskain7
2023-12-15 14:02:50 +01:00
committed by Adam Saghy
parent b9314d0b1e
commit f981ffe519
2 changed files with 53 additions and 12 deletions
@@ -396,6 +396,14 @@ public final class LoanApplicationCommandFromApiJsonHelper {
.extractStringNamed(LoanApiConstants.transactionProcessingStrategyCodeParameterName, element);
baseDataValidator.reset().parameter(LoanApiConstants.transactionProcessingStrategyCodeParameterName)
.value(transactionProcessingStrategy).notNull();
if (!AdvancedPaymentScheduleTransactionProcessor.ADVANCED_PAYMENT_ALLOCATION_STRATEGY
.equals(loanProduct.getTransactionProcessingStrategyCode())
&& AdvancedPaymentScheduleTransactionProcessor.ADVANCED_PAYMENT_ALLOCATION_STRATEGY.equals(transactionProcessingStrategy)) {
baseDataValidator.reset().parameter(LoanApiConstants.transactionProcessingStrategyCodeParameterName).failWithCode(
"strategy.cannot.be.advanced.payment.allocation.if.not.configured",
"Loan transaction processing strategy cannot be Advanced Payment Allocation Strategy if it's not configured on loan product");
}
// Validating whether the processor is existing
loanRepaymentScheduleTransactionProcessorFactory.determineProcessor(transactionProcessingStrategy);
@@ -670,6 +678,14 @@ public final class LoanApplicationCommandFromApiJsonHelper {
loanRepaymentScheduleTransactionProcessorFactory.determineProcessor(transactionProcessingStrategy);
}
if (!AdvancedPaymentScheduleTransactionProcessor.ADVANCED_PAYMENT_ALLOCATION_STRATEGY
.equals(loanProduct.getTransactionProcessingStrategyCode())
&& AdvancedPaymentScheduleTransactionProcessor.ADVANCED_PAYMENT_ALLOCATION_STRATEGY.equals(transactionProcessingStrategy)) {
baseDataValidator.reset().parameter(LoanApiConstants.transactionProcessingStrategyCodeParameterName).failWithCode(
"strategy.cannot.be.advanced.payment.allocation.if.not.configured",
"Loan transaction processing strategy cannot be Advanced Payment Allocation Strategy if it's not configured on loan product");
}
BigDecimal principal = null;
if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.principalParameterName, element)) {
atLeastOneParameterPassedForUpdate = true;