From 8ba0420398af82f15c2ad77dbc9d50e735832894 Mon Sep 17 00:00:00 2001 From: Nitesh Yadav Date: Fri, 16 Oct 2026 12:30:44 +0530 Subject: [PATCH] feat(deposits): allow several FD/RD accounts on the same product for one client A client may now open any number of Fixed Deposit and Recurring Deposit accounts on the same product, even while an earlier one is still active. The one-active-account- per-product check is removed from submitFDApplication and submitRDApplication only; the same rule on plain Savings and Current accounts is unchanged. Co-Authored-By: Claude Opus 5.5 --- ...WritePlatformServiceJpaRepositoryImpl.java | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl.java index 2f1d19d5b..025d86582 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl.java @@ -48,7 +48,6 @@ import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.exception.ErrorHandler; import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; -import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.event.business.domain.deposit.FixedDepositAccountCreateBusinessEvent; import org.apache.fineract.infrastructure.event.business.domain.deposit.RecurringDepositAccountCreateBusinessEvent; @@ -184,16 +183,8 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl final FixedDepositAccount account = (FixedDepositAccount) this.depositAccountAssembler.assembleFrom(command, submittedBy, DepositAccountType.FIXED_DEPOSIT); - if (account.getClient() != null && account.productId() != null) { - long existingCount = this.savingAccountRepository.countActiveAccountsByClientAndProduct( - account.getClient().getId(), account.productId()); - if (existingCount > 0) { - throw new PlatformDataIntegrityException( - "error.msg.savings.account.duplicate.product.for.client", - "Client already has an active Fixed Deposit account with the same product.", - "productId", account.productId()); - } - } + // A client may hold any number of Fixed Deposits on the same product, even while an earlier one is + // still active, so there is deliberately no one-active-account-per-product check here. final MathContext mc = MathContext.DECIMAL64; final boolean isPreMatureClosure = false; @@ -269,16 +260,8 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(command, submittedBy, DepositAccountType.RECURRING_DEPOSIT); - if (account.getClient() != null && account.productId() != null) { - long existingCount = this.savingAccountRepository.countActiveAccountsByClientAndProduct( - account.getClient().getId(), account.productId()); - if (existingCount > 0) { - throw new PlatformDataIntegrityException( - "error.msg.savings.account.duplicate.product.for.client", - "Client already has an active Recurring Deposit account with the same product.", - "productId", account.productId()); - } - } + // A client may hold any number of Recurring Deposits on the same product, even while an earlier one + // is still active, so there is deliberately no one-active-account-per-product check here. this.savingsAccountAssembler.applyCbsFields(command, command.parsedJson(), account);