FINERACT-1960: Fix savings product validation
This commit is contained in:
+1
-1
@@ -302,7 +302,7 @@ public class DepositProductDataValidator {
|
|||||||
if (AccountingValidations.isCashBasedAccounting(accountingRuleType)
|
if (AccountingValidations.isCashBasedAccounting(accountingRuleType)
|
||||||
|| AccountingValidations.isAccrualPeriodicBasedAccounting(accountingRuleType)) {
|
|| AccountingValidations.isAccrualPeriodicBasedAccounting(accountingRuleType)) {
|
||||||
savingsProductAccountingDataValidator.evaluateProductAccountingData(accountingRuleType, isDormancyActive, element,
|
savingsProductAccountingDataValidator.evaluateProductAccountingData(accountingRuleType, isDormancyActive, element,
|
||||||
baseDataValidator, accountType);
|
baseDataValidator, accountType, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
validateTaxWithHoldingParams(baseDataValidator, element, true);
|
validateTaxWithHoldingParams(baseDataValidator, element, true);
|
||||||
|
|||||||
+91
-61
@@ -36,82 +36,112 @@ public class SavingsProductAccountingDataValidator {
|
|||||||
private final FromJsonHelper fromApiJsonHelper;
|
private final FromJsonHelper fromApiJsonHelper;
|
||||||
|
|
||||||
public void evaluateProductAccountingData(final Integer accountingRuleType, final boolean isDormancyActive, final JsonElement element,
|
public void evaluateProductAccountingData(final Integer accountingRuleType, final boolean isDormancyActive, final JsonElement element,
|
||||||
DataValidatorBuilder baseDataValidator, final DepositAccountType accountType) {
|
DataValidatorBuilder baseDataValidator, final DepositAccountType accountType, boolean ignoreExistenceValidation) {
|
||||||
// GL Accounts for Cash or Accrual Periodic
|
// GL Accounts for Cash or Accrual Periodic
|
||||||
if (AccountingValidations.isCashBasedAccounting(accountingRuleType)
|
if (AccountingValidations.isCashBasedAccounting(accountingRuleType)
|
||||||
|| AccountingValidations.isAccrualPeriodicBasedAccounting(accountingRuleType)) {
|
|| AccountingValidations.isAccrualPeriodicBasedAccounting(accountingRuleType)) {
|
||||||
|
|
||||||
final Long savingsControlAccountId = fromApiJsonHelper
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), element)
|
||||||
.extractLongNamed(SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), element);
|
|| ignoreExistenceValidation) {
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_CONTROL.getValue()).value(savingsControlAccountId)
|
final Long savingsControlAccountId = fromApiJsonHelper
|
||||||
.notNull().integerGreaterThanZero();
|
.extractLongNamed(SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_CONTROL.getValue()).value(savingsControlAccountId)
|
||||||
final Long savingsReferenceAccountId = fromApiJsonHelper
|
|
||||||
.extractLongNamed(SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), element);
|
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_REFERENCE.getValue()).value(savingsReferenceAccountId)
|
|
||||||
.notNull().integerGreaterThanZero();
|
|
||||||
|
|
||||||
final Long transfersInSuspenseAccountId = fromApiJsonHelper
|
|
||||||
.extractLongNamed(SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
|
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue())
|
|
||||||
.value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero();
|
|
||||||
|
|
||||||
final Long interestOnSavingsAccountId = fromApiJsonHelper
|
|
||||||
.extractLongNamed(SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), element);
|
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue())
|
|
||||||
.value(interestOnSavingsAccountId).notNull().integerGreaterThanZero();
|
|
||||||
|
|
||||||
final Long incomeFromFeeId = fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.INCOME_FROM_FEES.getValue(),
|
|
||||||
element);
|
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId).notNull()
|
|
||||||
.integerGreaterThanZero();
|
|
||||||
|
|
||||||
final Long incomeFromPenaltyId = fromApiJsonHelper
|
|
||||||
.extractLongNamed(SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
|
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue()).value(incomeFromPenaltyId)
|
|
||||||
.notNull().integerGreaterThanZero();
|
|
||||||
|
|
||||||
if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) {
|
|
||||||
final Long overdraftControlAccountId = fromApiJsonHelper
|
|
||||||
.extractLongNamed(SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element);
|
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue())
|
|
||||||
.value(overdraftControlAccountId).notNull().integerGreaterThanZero();
|
|
||||||
|
|
||||||
final Long incomeFromInterest = fromApiJsonHelper
|
|
||||||
.extractLongNamed(SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue(), element);
|
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue()).value(incomeFromInterest)
|
|
||||||
.notNull().integerGreaterThanZero();
|
.notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
|
||||||
final Long writtenoff = fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(),
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), element)
|
||||||
|
|| ignoreExistenceValidation) {
|
||||||
|
final Long savingsReferenceAccountId = fromApiJsonHelper
|
||||||
|
.extractLongNamed(SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.SAVINGS_REFERENCE.getValue())
|
||||||
|
.value(savingsReferenceAccountId).notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element)
|
||||||
|
|| ignoreExistenceValidation) {
|
||||||
|
final Long transfersInSuspenseAccountId = fromApiJsonHelper
|
||||||
|
.extractLongNamed(SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue())
|
||||||
|
.value(transfersInSuspenseAccountId).notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), element)
|
||||||
|
|| ignoreExistenceValidation) {
|
||||||
|
final Long interestOnSavingsAccountId = fromApiJsonHelper
|
||||||
|
.extractLongNamed(SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue())
|
||||||
|
.value(interestOnSavingsAccountId).notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.INCOME_FROM_FEES.getValue(), element)
|
||||||
|
|| ignoreExistenceValidation) {
|
||||||
|
final Long incomeFromFeeId = fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.INCOME_FROM_FEES.getValue(),
|
||||||
element);
|
element);
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue()).value(writtenoff).notNull()
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_FEES.getValue()).value(incomeFromFeeId)
|
||||||
.integerGreaterThanZero();
|
.notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element)
|
||||||
|
|| ignoreExistenceValidation) {
|
||||||
|
final Long incomeFromPenaltyId = fromApiJsonHelper
|
||||||
|
.extractLongNamed(SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue())
|
||||||
|
.value(incomeFromPenaltyId).notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) {
|
||||||
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element)
|
||||||
|
|| ignoreExistenceValidation) {
|
||||||
|
final Long overdraftControlAccountId = fromApiJsonHelper
|
||||||
|
.extractLongNamed(SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue())
|
||||||
|
.value(overdraftControlAccountId).notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue(), element)
|
||||||
|
|| ignoreExistenceValidation) {
|
||||||
|
final Long incomeFromInterest = fromApiJsonHelper
|
||||||
|
.extractLongNamed(SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.INCOME_FROM_INTEREST.getValue())
|
||||||
|
.value(incomeFromInterest).notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(), element)
|
||||||
|
|| ignoreExistenceValidation) {
|
||||||
|
final Long writtenoff = fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue(),
|
||||||
|
element);
|
||||||
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue()).value(writtenoff)
|
||||||
|
.notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDormancyActive) {
|
if (isDormancyActive) {
|
||||||
final Long escheatLiabilityAccountId = fromApiJsonHelper
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue(), element)
|
||||||
.extractLongNamed(SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue(), element);
|
|| ignoreExistenceValidation) {
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue())
|
final Long escheatLiabilityAccountId = fromApiJsonHelper
|
||||||
.value(escheatLiabilityAccountId).notNull().integerGreaterThanZero();
|
.extractLongNamed(SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.ESCHEAT_LIABILITY.getValue())
|
||||||
|
.value(escheatLiabilityAccountId).notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GL Accounts for Accrual Period only
|
// GL Accounts for Accrual Period only
|
||||||
if (AccountingValidations.isAccrualPeriodicBasedAccounting(accountingRuleType)) {
|
if (AccountingValidations.isAccrualPeriodicBasedAccounting(accountingRuleType)) {
|
||||||
final Long feeReceivableAccountId = fromApiJsonHelper.extractLongNamed(SavingProductAccountingParams.FEES_RECEIVABLE.getValue(),
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.FEES_RECEIVABLE.getValue(), element)
|
||||||
element);
|
|| ignoreExistenceValidation) {
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.FEES_RECEIVABLE.getValue()).value(feeReceivableAccountId)
|
final Long feeReceivableAccountId = fromApiJsonHelper
|
||||||
.notNull().integerGreaterThanZero();
|
.extractLongNamed(SavingProductAccountingParams.FEES_RECEIVABLE.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.FEES_RECEIVABLE.getValue()).value(feeReceivableAccountId)
|
||||||
final Long penaltyReceivableAccountId = fromApiJsonHelper
|
.notNull().integerGreaterThanZero();
|
||||||
.extractLongNamed(SavingProductAccountingParams.PENALTIES_RECEIVABLE.getValue(), element);
|
}
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.PENALTIES_RECEIVABLE.getValue())
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.PENALTIES_RECEIVABLE.getValue(), element)
|
||||||
.value(penaltyReceivableAccountId).notNull().integerGreaterThanZero();
|
|| ignoreExistenceValidation) {
|
||||||
|
final Long penaltyReceivableAccountId = fromApiJsonHelper
|
||||||
final Long interestPayableAccountId = fromApiJsonHelper
|
.extractLongNamed(SavingProductAccountingParams.PENALTIES_RECEIVABLE.getValue(), element);
|
||||||
.extractLongNamed(SavingProductAccountingParams.INTEREST_PAYABLE.getValue(), element);
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.PENALTIES_RECEIVABLE.getValue())
|
||||||
baseDataValidator.reset().parameter(SavingProductAccountingParams.INTEREST_PAYABLE.getValue()).value(interestPayableAccountId)
|
.value(penaltyReceivableAccountId).notNull().integerGreaterThanZero();
|
||||||
.notNull().integerGreaterThanZero();
|
}
|
||||||
|
if (fromApiJsonHelper.parameterExists(SavingProductAccountingParams.INTEREST_PAYABLE.getValue(), element)
|
||||||
|
|| ignoreExistenceValidation) {
|
||||||
|
final Long interestPayableAccountId = fromApiJsonHelper
|
||||||
|
.extractLongNamed(SavingProductAccountingParams.INTEREST_PAYABLE.getValue(), element);
|
||||||
|
baseDataValidator.reset().parameter(SavingProductAccountingParams.INTEREST_PAYABLE.getValue())
|
||||||
|
.value(interestPayableAccountId).notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
validatePaymentChannelFundSourceMappings(baseDataValidator, element);
|
validatePaymentChannelFundSourceMappings(baseDataValidator, element);
|
||||||
|
|||||||
+7
-4
@@ -259,7 +259,7 @@ public class SavingsProductDataValidator {
|
|||||||
if (AccountingValidations.isCashBasedAccounting(accountingRuleType)
|
if (AccountingValidations.isCashBasedAccounting(accountingRuleType)
|
||||||
|| AccountingValidations.isAccrualPeriodicBasedAccounting(accountingRuleType)) {
|
|| AccountingValidations.isAccrualPeriodicBasedAccounting(accountingRuleType)) {
|
||||||
savingsProductAccountingDataValidator.evaluateProductAccountingData(accountingRuleType, isDormancyActive, element,
|
savingsProductAccountingDataValidator.evaluateProductAccountingData(accountingRuleType, isDormancyActive, element,
|
||||||
baseDataValidator, DepositAccountType.SAVINGS_DEPOSIT);
|
baseDataValidator, DepositAccountType.SAVINGS_DEPOSIT, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
validateOverdraftParams(baseDataValidator, element);
|
validateOverdraftParams(baseDataValidator, element);
|
||||||
@@ -384,8 +384,11 @@ public class SavingsProductDataValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// accounting related data validation
|
// accounting related data validation
|
||||||
final Integer accountingRuleType = this.fromApiJsonHelper.extractIntegerNamed("accountingRule", element, Locale.getDefault());
|
Integer accountingRuleType = product.getAccountingType();
|
||||||
baseDataValidator.reset().parameter("accountingRule").value(accountingRuleType).notNull().inMinMaxRange(1, 3);
|
if (this.fromApiJsonHelper.parameterExists("accountingRule", element)) {
|
||||||
|
accountingRuleType = this.fromApiJsonHelper.extractIntegerNamed("accountingRule", element, Locale.getDefault());
|
||||||
|
baseDataValidator.reset().parameter("accountingRule").value(accountingRuleType).notNull().inMinMaxRange(1, 3);
|
||||||
|
}
|
||||||
|
|
||||||
// dormancy
|
// dormancy
|
||||||
final Boolean isDormancyActive = this.fromApiJsonHelper.parameterExists(isDormancyTrackingActiveParamName, element)
|
final Boolean isDormancyActive = this.fromApiJsonHelper.parameterExists(isDormancyTrackingActiveParamName, element)
|
||||||
@@ -395,7 +398,7 @@ public class SavingsProductDataValidator {
|
|||||||
if (AccountingValidations.isCashBasedAccounting(accountingRuleType)
|
if (AccountingValidations.isCashBasedAccounting(accountingRuleType)
|
||||||
|| AccountingValidations.isAccrualPeriodicBasedAccounting(accountingRuleType)) {
|
|| AccountingValidations.isAccrualPeriodicBasedAccounting(accountingRuleType)) {
|
||||||
savingsProductAccountingDataValidator.evaluateProductAccountingData(accountingRuleType, isDormancyActive, element,
|
savingsProductAccountingDataValidator.evaluateProductAccountingData(accountingRuleType, isDormancyActive, element,
|
||||||
baseDataValidator, DepositAccountType.SAVINGS_DEPOSIT);
|
baseDataValidator, DepositAccountType.SAVINGS_DEPOSIT, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null != isDormancyActive && isDormancyActive) {
|
if (null != isDormancyActive && isDormancyActive) {
|
||||||
|
|||||||
Reference in New Issue
Block a user