feat: add share linking enabled to current and savings accounts

This commit is contained in:
keshav898966
2026-06-26 11:12:00 +05:30
parent 8e55b6747c
commit db41c2b606
11 changed files with 121 additions and 1 deletions
@@ -304,6 +304,9 @@ public class CurrentAccount extends AbstractAuditableCustom {
@Column(name = "od_account_closed_zero_balance_in_day_closing")
private boolean odAccountClosedZeroBalanceInDayClosing = false;
@Column(name = "is_linking_enable", nullable = false)
private boolean shareLinkingEnabled = false;
// Relationships
@OneToMany(mappedBy = "currentAccount", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
@@ -406,4 +409,7 @@ public class CurrentAccount extends AbstractAuditableCustom {
public void setNominalAnnualInterestRateOverdraft(java.math.BigDecimal val) { this.nominalAnnualInterestRateOverdraft = val; }
public void setWithdrawalFeeForTransfer(boolean val) { this.withdrawalFeeForTransfer = val; }
public void setMinOverdraftForInterestCalculation(java.math.BigDecimal val) { this.minOverdraftForInterestCalculation = val; }
public boolean isShareLinkingEnabled() { return shareLinkingEnabled; }
public void setShareLinkingEnabled(boolean shareLinkingEnabled) { this.shareLinkingEnabled = shareLinkingEnabled; }
}
@@ -42,6 +42,8 @@ import static org.apache.fineract.portfolio.savings.SavingsApiConstants.specialC
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.weakerSectionParamName;
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.nominationFacilityParamName;
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.autoDebitFacilityParamName;
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.introducerRequiredParamName;
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.shareLinkingEnabledParamName;
import static org.apache.fineract.portfolio.savings.DepositsApiConstants.isSeniorCitizenParamName;
import static org.apache.fineract.portfolio.savings.DepositsApiConstants.seniorCitizenInterestRateParamName;
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.allowOverdraftParamName;
@@ -395,6 +397,16 @@ public class SavingsAccountAssembler {
if (command.parameterExists(autoDebitFacilityParamName)) {
account.setAutoDebitFacility(this.fromApiJsonHelper.extractBooleanNamed(autoDebitFacilityParamName, element));
}
if (command.parameterExists(introducerRequiredParamName)) {
account.setIntroducerRequired(this.fromApiJsonHelper.extractBooleanNamed(introducerRequiredParamName, element));
} else if (account.savingsProduct() != null) {
account.setIntroducerRequired(account.savingsProduct().isIntroducerRequired());
}
if (command.parameterExists(shareLinkingEnabledParamName)) {
account.setShareLinkingEnabled(this.fromApiJsonHelper.extractBooleanNamed(shareLinkingEnabledParamName, element));
} else if (account.savingsProduct() != null) {
account.setShareLinkingEnabled(account.savingsProduct().isShareLinkingEnabled());
}
// Senior citizen rate — runs after validateDomainRules so it is the final persisted value
if (command.parameterExists(isSeniorCitizenParamName)) {
@@ -443,6 +443,7 @@ public class CurrentAccountReadPlatformServiceImpl implements CurrentAccountRead
out.put("msme", row.get("msme"));
out.put("autoDebitFacility", row.get("auto_debit_facility"));
out.put("balanceSwapOption", row.get("balance_swap_option"));
out.put("shareLinkingEnabled", row.get("is_linking_enable"));
out.put("establishmentDate", row.get("establishment_date"));
out.put("startOperationDate", row.get("start_operation_date"));
out.put("nonIndividualClient", row.get("is_non_individual_client"));
@@ -140,6 +140,10 @@ public class CurrentAccountWritePlatformServiceImpl implements CurrentAccountWri
product.getInterestCalculateSelector(), product.getAveragePeriod(),
product.getAvgBalanceCalcPeriod());
boolean shareLinkingEnabled = json.has("shareLinkingEnabled") && !json.get("shareLinkingEnabled").isJsonNull()
? json.get("shareLinkingEnabled").getAsBoolean() : product.isShareLinkingEnabled();
account.setShareLinkingEnabled(shareLinkingEnabled);
// Save CBS account type (descriptive name: "Standard Account", "Basic Account", etc.)
if (cbsAccountType != null) account.setCbsAccountType(cbsAccountType);
@@ -422,6 +426,8 @@ public class CurrentAccountWritePlatformServiceImpl implements CurrentAccountWri
account.setBalanceSwapOption(json.get("balanceSwapOption").getAsBoolean());
if (json.has("autoDebitFacility") && !json.get("autoDebitFacility").isJsonNull())
account.setAutoDebitFacility(json.get("autoDebitFacility").getAsBoolean());
if (json.has("shareLinkingEnabled") && !json.get("shareLinkingEnabled").isJsonNull())
account.setShareLinkingEnabled(json.get("shareLinkingEnabled").getAsBoolean());
if (json.has("introducerClientId") && !json.get("introducerClientId").isJsonNull())
account.setIntroducerClientId(json.get("introducerClientId").getAsLong());
if (json.has("introducerName") && !json.get("introducerName").isJsonNull())
@@ -863,6 +863,8 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
sqlBuilder.append("sp.msme as msme, ");
sqlBuilder.append("COALESCE(sa.nomination_facility, sp.nomination_facility) as nominationFacility, ");
sqlBuilder.append("COALESCE(sa.auto_debit_facility, sp.auto_debit_facility) as autoDebitFacility, ");
sqlBuilder.append("COALESCE(sa.introducer_required, sp.introducer_required) as introducerRequired, ");
sqlBuilder.append("COALESCE(sa.share_linking_enabled, sp.share_linking_enabled) as shareLinkingEnabled, ");
// Facility config fields
sqlBuilder.append("safc.atm_facility as atmFacility, ");
sqlBuilder.append("safc.atm_withdrawal_facility as atmWithdrawalFacility, ");
@@ -1118,6 +1120,8 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
accountData.setMsme(rs.getObject("msme") != null ? rs.getBoolean("msme") : null);
accountData.setNominationFacility(rs.getObject("nominationFacility") != null ? rs.getBoolean("nominationFacility") : null);
accountData.setAutoDebitFacility(rs.getObject("autoDebitFacility") != null ? rs.getBoolean("autoDebitFacility") : null);
accountData.setIntroducerRequired(rs.getObject("introducerRequired") != null ? rs.getBoolean("introducerRequired") : null);
accountData.setShareLinkingEnabled(rs.getObject("shareLinkingEnabled") != null ? rs.getBoolean("shareLinkingEnabled") : null);
// Nominee as parsed map
final String nomineeDataStr = rs.getString("nomineeData");
@@ -366,4 +366,5 @@
<include file="parts/0336_add_request_type_to_clerk_disbursement.xml" relativeToChangelogFile="true"/>
<include file="parts/0337_create_election_module.xml" relativeToChangelogFile="true"/>
<include file="parts/0338_add_soft_delete_to_tellers.xml" relativeToChangelogFile="true"/>
<include file="parts/0339_add_share_linking_enabled_to_current_account.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
<changeSet id="0339_add_share_linking_enabled_to_current_account" author="CBS">
<preConditions onFail="MARK_RAN">
<tableExists tableName="m_current_account"/>
<not><columnExists tableName="m_current_account" columnName="is_linking_enable"/></not>
</preConditions>
<addColumn tableName="m_current_account">
<column name="is_linking_enable" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
</databaseChangeLog>
@@ -48,7 +48,7 @@ public class SavingsAccountConstant extends SavingsApiConstants {
introducerIdParamName, introducerNameParamName, introducerCifNumberParamName,
nomineeParamName, "nominees", linkedAccountIdParamName, linkedAccountTypeParamName, linkedAccountNoParamName,
accountFacilityConfigParamName, jointHoldersParamName,
balanceSwapOptionParamName, msmeParamName, autoDebitFacilityParamName));
balanceSwapOptionParamName, msmeParamName, autoDebitFacilityParamName, introducerRequiredParamName, shareLinkingEnabledParamName));
/**
* These parameters will match the class level parameters of {@link SavingsAccountData}. Where possible, we try to
@@ -34,6 +34,8 @@ import static org.apache.fineract.portfolio.savings.SavingsApiConstants.nominalA
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.overdraftLimitParamName;
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.withHoldTaxParamName;
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.withdrawalFeeForTransfersParamName;
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.introducerRequiredParamName;
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.shareLinkingEnabledParamName;
import com.google.gson.JsonArray;
import jakarta.persistence.CascadeType;
@@ -1852,6 +1854,18 @@ public class SavingsAccount extends AbstractAuditableWithUTCDateTimeCustom<Long>
baseDataValidator.reset().parameter(withHoldTaxParamName).failWithCode("not.supported.for.this.account");
}
}
if (command.isChangeInBooleanParameterNamed(introducerRequiredParamName, this.introducerRequired)) {
final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(introducerRequiredParamName);
actualChanges.put(introducerRequiredParamName, newValue);
this.introducerRequired = newValue;
}
if (command.isChangeInBooleanParameterNamed(shareLinkingEnabledParamName, this.shareLinkingEnabled)) {
final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(shareLinkingEnabledParamName);
actualChanges.put(shareLinkingEnabledParamName, newValue);
this.shareLinkingEnabled = newValue;
}
validateLockinDetails(baseDataValidator);
esnureOverdraftLimitsSetForOverdraftAccounts();
}
@@ -3972,6 +3986,12 @@ public class SavingsAccount extends AbstractAuditableWithUTCDateTimeCustom<Long>
@Column(name = "linked_account_no", length = 50)
private String linkedAccountNo;
@Column(name = "introducer_required", nullable = false, columnDefinition = "boolean default false")
private Boolean introducerRequired = false;
@Column(name = "share_linking_enabled", nullable = false, columnDefinition = "boolean default false")
private Boolean shareLinkingEnabled = false;
@Column(name = "nomination_facility", nullable = false, columnDefinition = "boolean default false")
private Boolean nominationFacility = false;
@@ -4057,6 +4077,12 @@ public class SavingsAccount extends AbstractAuditableWithUTCDateTimeCustom<Long>
public Boolean getAutoDebitFacility() { return autoDebitFacility; }
public void setAutoDebitFacility(Boolean v) { this.autoDebitFacility = v; }
public Boolean getIntroducerRequired() { return introducerRequired; }
public void setIntroducerRequired(Boolean v) { this.introducerRequired = v; }
public Boolean getShareLinkingEnabled() { return shareLinkingEnabled; }
public void setShareLinkingEnabled(Boolean v) { this.shareLinkingEnabled = v; }
public boolean isSeniorCitizen() { return isSeniorCitizen; }
public void setSeniorCitizen(boolean v) { this.isSeniorCitizen = v; }
@@ -38,4 +38,5 @@
<include file="parts/2013_add_missing_current_account_columns.xml" relativeToChangelogFile="true" />
<include file="parts/2014_add_is_mandatory_to_joint_holders.xml" relativeToChangelogFile="true" />
<include file="parts/2015_add_senior_citizen_to_savings_account.xml" relativeToChangelogFile="true" />
<include file="parts/2016_add_share_linking_enabled_to_savings_account.xml" relativeToChangelogFile="true" />
</databaseChangeLog>
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
<changeSet id="2016_add_share_linking_enabled_to_savings_account" author="CBS">
<preConditions onFail="MARK_RAN">
<tableExists tableName="m_savings_account"/>
<not><columnExists tableName="m_savings_account" columnName="share_linking_enabled"/></not>
</preConditions>
<addColumn tableName="m_savings_account">
<column name="introducer_required" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
<column name="share_linking_enabled" type="BOOLEAN" defaultValueBoolean="false">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
</databaseChangeLog>