MifosX-1466-Flexible Savings Interest Posting
This commit is contained in:
@@ -13145,6 +13145,8 @@ Request Body:
|
|||||||
<li><b>allow-transactions-on-non_workingday</b> - defaults to false - if true allows transactions on non-working days</li>
|
<li><b>allow-transactions-on-non_workingday</b> - defaults to false - if true allows transactions on non-working days</li>
|
||||||
<li><b>reschedule-repayments-on-holidays</b> - defaults to false - if true reschedules repayemnts which falls on a non-working day to defined <a href="#holidays">reschedule date</a></li>
|
<li><b>reschedule-repayments-on-holidays</b> - defaults to false - if true reschedules repayemnts which falls on a non-working day to defined <a href="#holidays">reschedule date</a></li>
|
||||||
<li><b>allow-transactions-on-holiday</b> - defaults to false - if true allows transactions on <a href="#holidays">holidays</a></li>
|
<li><b>allow-transactions-on-holiday</b> - defaults to false - if true allows transactions on <a href="#holidays">holidays</a></li>
|
||||||
|
<li><b>savings-interest-posting-current-period-end</b> - Set it at the database level before any savings interest is posted. When set as false(default), interest will be posted on the first date of next period. If set as true, interest will be posted on last date of current period. There is no difference in the interest amount posted.</li>
|
||||||
|
<li><b>financial-year-beginning-month</b> - Set it at the database level before any savings interest is posted. Allowed values 1 - 12 (January - December). Interest posting periods are evaluated based on this configuration.</li>
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+148
@@ -0,0 +1,148 @@
|
|||||||
|
/**
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
package org.mifosplatform.integrationtests;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||||
|
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||||
|
import org.mifosplatform.integrationtests.common.GlobalConfigurationHelper;
|
||||||
|
import org.mifosplatform.integrationtests.common.Utils;
|
||||||
|
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
|
||||||
|
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
|
||||||
|
import org.mifosplatform.integrationtests.common.savings.SavingsStatusChecker;
|
||||||
|
|
||||||
|
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||||
|
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||||
|
import com.jayway.restassured.http.ContentType;
|
||||||
|
import com.jayway.restassured.specification.RequestSpecification;
|
||||||
|
import com.jayway.restassured.specification.ResponseSpecification;
|
||||||
|
|
||||||
|
@SuppressWarnings({ "rawtypes", "unused", "unchecked" })
|
||||||
|
public class FlexibleSavingsInterestPostingIntegrationTest {
|
||||||
|
|
||||||
|
public static final String ACCOUNT_TYPE_INDIVIDUAL = "INDIVIDUAL";
|
||||||
|
|
||||||
|
private ResponseSpecification responseSpec;
|
||||||
|
private RequestSpecification requestSpec;
|
||||||
|
private SavingsProductHelper savingsProductHelper;
|
||||||
|
private SavingsAccountHelper savingsAccountHelper;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
Utils.initializeRESTAssured();
|
||||||
|
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
|
||||||
|
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||||
|
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
|
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||||
|
this.savingsProductHelper = new SavingsProductHelper();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSavingsInterestPostingAtPeriodEnd() {
|
||||||
|
//client activation, savings activation and 1st transaction date
|
||||||
|
final String startDate = "01 December 2013";
|
||||||
|
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, startDate);
|
||||||
|
Assert.assertNotNull(clientID);
|
||||||
|
|
||||||
|
// Configuring global config flags
|
||||||
|
configureInterestPosting(true, 4);
|
||||||
|
|
||||||
|
final Integer savingsId = createSavingsAccount(clientID, startDate);
|
||||||
|
|
||||||
|
Integer depositTransactionId = (Integer) this.savingsAccountHelper.depositToSavingsAccount(savingsId, "1000",
|
||||||
|
startDate, CommonConstants.RESPONSE_RESOURCE_ID);
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Perform Post interest transaction and verify the posted transaction date
|
||||||
|
*/
|
||||||
|
this.savingsAccountHelper.postInterestForSavings(savingsId);
|
||||||
|
HashMap accountDetails = this.savingsAccountHelper.getSavingsDetails(savingsId);
|
||||||
|
ArrayList<HashMap<String, Object>> transactions = (ArrayList<HashMap<String, Object>>)
|
||||||
|
accountDetails.get("transactions");
|
||||||
|
HashMap<String, Object> interestPostingTransaction = transactions.get(0);
|
||||||
|
for(Entry<String, Object> entry : interestPostingTransaction.entrySet())
|
||||||
|
System.out.println(entry.getKey() + "-" + entry.getValue().toString());
|
||||||
|
//1st Dec 13 to 31st March 14 - 365 days, daily compounding using daily balance
|
||||||
|
//33.7016 obtained from formula in excel provided by Subramanya
|
||||||
|
assertEquals("Equality check for interest posted amount",
|
||||||
|
"33.7016", interestPostingTransaction.get("amount").toString());
|
||||||
|
assertEquals("Date check for Interest Posting transaction",
|
||||||
|
"[2014, 3, 31]", interestPostingTransaction.get("date").toString());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer createSavingsAccount(final Integer clientID, final String startDate) {
|
||||||
|
final Integer savingsProductID = createSavingsProduct();
|
||||||
|
Assert.assertNotNull(savingsProductID);
|
||||||
|
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplicationOnDate(clientID,
|
||||||
|
savingsProductID, ACCOUNT_TYPE_INDIVIDUAL, startDate);
|
||||||
|
Assert.assertNotNull(savingsId);
|
||||||
|
HashMap savingsStatusHashMap = this.savingsAccountHelper.approveSavingsOnDate(savingsId, startDate);
|
||||||
|
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
|
||||||
|
savingsStatusHashMap = this.savingsAccountHelper.activateSavingsAccount(savingsId, startDate);
|
||||||
|
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||||
|
return savingsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void configureInterestPosting(final Boolean periodEndEnable,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
final ArrayList<HashMap> globalConfig = GlobalConfigurationHelper.getAllGlobalConfigurations(this.requestSpec,
|
||||||
|
this.responseSpec);
|
||||||
|
Assert.assertNotNull(globalConfig);
|
||||||
|
|
||||||
|
// Updating flag for interest posting at period end
|
||||||
|
Integer periodEndConfigId = (Integer) globalConfig.get(10).get("id");
|
||||||
|
Assert.assertNotNull(periodEndConfigId);
|
||||||
|
|
||||||
|
HashMap periodEndConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
|
||||||
|
periodEndConfigId.toString());
|
||||||
|
Assert.assertNotNull(periodEndConfigData);
|
||||||
|
|
||||||
|
Boolean enabled = (Boolean) globalConfig.get(10).get("enabled");
|
||||||
|
|
||||||
|
if (enabled != periodEndEnable)
|
||||||
|
periodEndConfigId = GlobalConfigurationHelper.updateEnabledFlagForGlobalConfiguration(this.requestSpec, this.responseSpec,
|
||||||
|
periodEndConfigId.toString(), periodEndEnable);
|
||||||
|
|
||||||
|
|
||||||
|
//Updating value for financial year beginning month
|
||||||
|
Integer financialYearBeginningConfigId = (Integer) globalConfig.get(11).get("id");
|
||||||
|
Assert.assertNotNull(financialYearBeginningConfigId);
|
||||||
|
|
||||||
|
HashMap financialYearBeginningConfigData = GlobalConfigurationHelper.getGlobalConfigurationById(this.requestSpec, this.responseSpec,
|
||||||
|
financialYearBeginningConfigId.toString());
|
||||||
|
Assert.assertNotNull(financialYearBeginningConfigData);
|
||||||
|
|
||||||
|
financialYearBeginningConfigId = GlobalConfigurationHelper.updateValueForGlobalConfiguration(this.requestSpec, this.responseSpec,
|
||||||
|
financialYearBeginningConfigId.toString(), financialYearBeginningMonth.toString());
|
||||||
|
Assert.assertNotNull(financialYearBeginningConfigId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer createSavingsProduct() {
|
||||||
|
final String savingsProductJSON = this.savingsProductHelper
|
||||||
|
.withInterestCompoundingPeriodTypeAsDaily()
|
||||||
|
.withInterestPostingPeriodTypeAsAnnual()
|
||||||
|
.withInterestCalculationPeriodTypeAsDailyBalance()
|
||||||
|
.build();
|
||||||
|
return SavingsProductHelper.createSavingsProduct(savingsProductJSON, requestSpec, responseSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Reset configuration fields
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
configureInterestPosting(false, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+22
-6
@@ -59,9 +59,14 @@ public class SavingsAccountHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Integer applyForSavingsApplication(final Integer ID, final Integer savingsProductID, final String accountType) {
|
public Integer applyForSavingsApplication(final Integer ID, final Integer savingsProductID, final String accountType) {
|
||||||
System.out.println("--------------------------------APPLYING FOR SAVINGS APPLICATION--------------------------------");
|
return applyForSavingsApplicationOnDate(ID, savingsProductID, accountType, CREATED_DATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer applyForSavingsApplicationOnDate(final Integer ID, final Integer savingsProductID, final String accountType,
|
||||||
|
final String submittedOnDate) {
|
||||||
|
System.out.println("--------------------------------APPLYING FOR SAVINGS APPLICATION--------------------------------");
|
||||||
final String savingsApplicationJSON = new SavingsApplicationTestBuilder() //
|
final String savingsApplicationJSON = new SavingsApplicationTestBuilder() //
|
||||||
.withSubmittedOnDate(CREATED_DATE) //
|
.withSubmittedOnDate(submittedOnDate) //
|
||||||
.build(ID.toString(), savingsProductID.toString(), accountType);
|
.build(ID.toString(), savingsProductID.toString(), accountType);
|
||||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER,
|
return Utils.performServerPost(this.requestSpec, this.responseSpec, SAVINGS_ACCOUNT_URL + "?" + Utils.TENANT_IDENTIFIER,
|
||||||
savingsApplicationJSON, "savingsId");
|
savingsApplicationJSON, "savingsId");
|
||||||
@@ -77,8 +82,15 @@ public class SavingsAccountHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HashMap approveSavings(final Integer savingsID) {
|
public HashMap approveSavings(final Integer savingsID) {
|
||||||
System.out.println("--------------------------------- APPROVING SAVINGS APPLICATION ------------------------------------");
|
return approveSavingsOnDate(savingsID, null);
|
||||||
return performSavingApplicationActions(createSavingsOperationURL(APPROVE_SAVINGS_COMMAND, savingsID), getApproveSavingsAsJSON());
|
}
|
||||||
|
|
||||||
|
public HashMap approveSavingsOnDate(final Integer savingsID, final String approvalDate) {
|
||||||
|
System.out.println("--------------------------------- APPROVING SAVINGS APPLICATION ------------------------------------");
|
||||||
|
final String savingsOperationURL = createSavingsOperationURL(APPROVE_SAVINGS_COMMAND, savingsID);
|
||||||
|
if(approvalDate == null || approvalDate == "")
|
||||||
|
return performSavingApplicationActions(savingsOperationURL, getApproveSavingsAsJSON());
|
||||||
|
return performSavingApplicationActions(savingsOperationURL, getApproveSavingsAsJsonOnDate(approvalDate));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap undoApproval(final Integer savingsID) {
|
public HashMap undoApproval(final Integer savingsID) {
|
||||||
@@ -185,10 +197,14 @@ public class SavingsAccountHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getApproveSavingsAsJSON() {
|
private String getApproveSavingsAsJSON() {
|
||||||
final HashMap<String, String> map = new HashMap<>();
|
return getApproveSavingsAsJsonOnDate(CREATED_DATE_PLUS_ONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getApproveSavingsAsJsonOnDate(final String approvalDate) {
|
||||||
|
final HashMap<String, String> map = new HashMap<>();
|
||||||
map.put("locale", CommonConstants.locale);
|
map.put("locale", CommonConstants.locale);
|
||||||
map.put("dateFormat", CommonConstants.dateFormat);
|
map.put("dateFormat", CommonConstants.dateFormat);
|
||||||
map.put("approvedOnDate", CREATED_DATE_PLUS_ONE);
|
map.put("approvedOnDate", approvalDate);
|
||||||
map.put("note", "Approval NOTE");
|
map.put("note", "Approval NOTE");
|
||||||
String savingsAccountApproveJson = new Gson().toJson(map);
|
String savingsAccountApproveJson = new Gson().toJson(map);
|
||||||
System.out.println(savingsAccountApproveJson);
|
System.out.println(savingsAccountApproveJson);
|
||||||
|
|||||||
+8
-2
@@ -18,18 +18,24 @@ public class GlobalConfigurationPropertyData {
|
|||||||
private final Long value;
|
private final Long value;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final Long id;
|
private final Long id;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final String description;
|
||||||
|
|
||||||
public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value) {
|
public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value,
|
||||||
|
final String description) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.id = null;
|
this.id = null;
|
||||||
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value, final Long id) {
|
public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value,
|
||||||
|
final Long id, final String description) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.description = description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -35,4 +35,8 @@ public interface ConfigurationDomainService {
|
|||||||
|
|
||||||
Long retrieveGraceOnPenaltyPostingPeriod();
|
Long retrieveGraceOnPenaltyPostingPeriod();
|
||||||
|
|
||||||
|
boolean isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
|
||||||
|
Integer retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
}
|
}
|
||||||
+16
@@ -136,4 +136,20 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
|||||||
return property.getValue();
|
return property.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSavingsInterestPostingAtCurrentPeriodEnd() {
|
||||||
|
final String propertyName = "savings-interest-posting-current-period-end";
|
||||||
|
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByNameWithNotFoundDetection(propertyName);
|
||||||
|
return property.isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer retrieveFinancialYearBeginningMonth() {
|
||||||
|
final String propertyName = "financial-year-beginning-month";
|
||||||
|
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByNameWithNotFoundDetection(propertyName);
|
||||||
|
if(property.isEnabled())
|
||||||
|
return property.getValue().intValue();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+8
-2
@@ -28,16 +28,22 @@ public class GlobalConfigurationProperty extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "value", nullable = true)
|
@Column(name = "value", nullable = true)
|
||||||
private Long value;
|
private Long value;
|
||||||
|
|
||||||
|
@Column(name = "description", nullable = true)
|
||||||
|
private final String description;
|
||||||
|
|
||||||
protected GlobalConfigurationProperty() {
|
protected GlobalConfigurationProperty() {
|
||||||
this.name = null;
|
this.name = null;
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
this.value = null;
|
this.value = null;
|
||||||
|
this.description = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlobalConfigurationProperty(final String name, final boolean enabled, final Long value) {
|
public GlobalConfigurationProperty(final String name, final boolean enabled, final Long value,
|
||||||
|
final String description) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
@@ -78,7 +84,7 @@ public class GlobalConfigurationProperty extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
public static GlobalConfigurationProperty newSurveyConfiguration(final String name)
|
public static GlobalConfigurationProperty newSurveyConfiguration(final String name)
|
||||||
{
|
{
|
||||||
return new GlobalConfigurationProperty(name,false,null);
|
return new GlobalConfigurationProperty(name, false, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+5
-3
@@ -39,7 +39,7 @@ public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPl
|
|||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
String sql = "SELECT c.id, c.name, c.enabled, c.value FROM c_configuration c ";
|
String sql = "SELECT c.id, c.name, c.enabled, c.value, c.description FROM c_configuration c ";
|
||||||
|
|
||||||
if(survey)
|
if(survey)
|
||||||
{
|
{
|
||||||
@@ -59,7 +59,8 @@ public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPl
|
|||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
final String sql = "SELECT c.id, c.name, c.enabled, c.value FROM c_configuration c where c.id=? order by c.id";
|
final String sql = "SELECT c.id, c.name, c.enabled, c.value, c.description FROM "
|
||||||
|
+ "c_configuration c where c.id=? order by c.id";
|
||||||
final GlobalConfigurationPropertyData globalConfiguration = this.jdbcTemplate.queryForObject(sql, this.rm, new Object[] {configId});
|
final GlobalConfigurationPropertyData globalConfiguration = this.jdbcTemplate.queryForObject(sql, this.rm, new Object[] {configId});
|
||||||
|
|
||||||
return globalConfiguration;
|
return globalConfiguration;
|
||||||
@@ -76,9 +77,10 @@ public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPl
|
|||||||
final String name = rs.getString("name");
|
final String name = rs.getString("name");
|
||||||
final boolean enabled = rs.getBoolean("enabled");
|
final boolean enabled = rs.getBoolean("enabled");
|
||||||
final Long value = rs.getLong("value");
|
final Long value = rs.getLong("value");
|
||||||
|
final String description = rs.getString("description");
|
||||||
final Long id = rs.getLong("id");
|
final Long id = rs.getLong("id");
|
||||||
|
|
||||||
return new GlobalConfigurationPropertyData(name, enabled, value, id);
|
return new GlobalConfigurationPropertyData(name, enabled, value, id, description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-1
@@ -66,7 +66,6 @@ public class GlobalConfigurationWritePlatformServiceJpaRepositoryImpl implements
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void addSurveyConfig(final String name)
|
public void addSurveyConfig(final String name)
|
||||||
|
|||||||
+54
-11
@@ -20,6 +20,7 @@ import org.joda.time.LocalDate;
|
|||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService;
|
import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||||
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrency;
|
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrency;
|
||||||
@@ -53,6 +54,7 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
private final DepositAccountAssembler depositAccountAssembler;
|
private final DepositAccountAssembler depositAccountAssembler;
|
||||||
private final SavingsAccountDomainService savingsAccountDomainService;
|
private final SavingsAccountDomainService savingsAccountDomainService;
|
||||||
private final AccountTransfersWritePlatformService accountTransfersWritePlatformService;
|
private final AccountTransfersWritePlatformService accountTransfersWritePlatformService;
|
||||||
|
private final ConfigurationDomainService configurationDomainService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DepositAccountDomainServiceJpa(final SavingsAccountRepositoryWrapper savingsAccountRepository,
|
public DepositAccountDomainServiceJpa(final SavingsAccountRepositoryWrapper savingsAccountRepository,
|
||||||
@@ -60,7 +62,8 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
final JournalEntryWritePlatformService journalEntryWritePlatformService,
|
final JournalEntryWritePlatformService journalEntryWritePlatformService,
|
||||||
final AccountNumberGeneratorFactory accountIdentifierGeneratorFactory, final DepositAccountAssembler depositAccountAssembler,
|
final AccountNumberGeneratorFactory accountIdentifierGeneratorFactory, final DepositAccountAssembler depositAccountAssembler,
|
||||||
final SavingsAccountDomainService savingsAccountDomainService,
|
final SavingsAccountDomainService savingsAccountDomainService,
|
||||||
final AccountTransfersWritePlatformService accountTransfersWritePlatformService) {
|
final AccountTransfersWritePlatformService accountTransfersWritePlatformService,
|
||||||
|
final ConfigurationDomainService configurationDomainService) {
|
||||||
this.savingsAccountRepository = savingsAccountRepository;
|
this.savingsAccountRepository = savingsAccountRepository;
|
||||||
this.applicationCurrencyRepositoryWrapper = applicationCurrencyRepositoryWrapper;
|
this.applicationCurrencyRepositoryWrapper = applicationCurrencyRepositoryWrapper;
|
||||||
this.journalEntryWritePlatformService = journalEntryWritePlatformService;
|
this.journalEntryWritePlatformService = journalEntryWritePlatformService;
|
||||||
@@ -68,6 +71,7 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
this.depositAccountAssembler = depositAccountAssembler;
|
this.depositAccountAssembler = depositAccountAssembler;
|
||||||
this.savingsAccountDomainService = savingsAccountDomainService;
|
this.savingsAccountDomainService = savingsAccountDomainService;
|
||||||
this.accountTransfersWritePlatformService = accountTransfersWritePlatformService;
|
this.accountTransfersWritePlatformService = accountTransfersWritePlatformService;
|
||||||
|
this.configurationDomainService = configurationDomainService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -100,6 +104,12 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
public SavingsAccountTransaction handleRDDeposit(final RecurringDepositAccount account, final DateTimeFormatter fmt,
|
public SavingsAccountTransaction handleRDDeposit(final RecurringDepositAccount account, final DateTimeFormatter fmt,
|
||||||
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail,
|
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail,
|
||||||
final boolean isRegularTransaction) {
|
final boolean isRegularTransaction) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
boolean isAccountTransfer = false;
|
boolean isAccountTransfer = false;
|
||||||
final boolean isPreMatureClosure = false;
|
final boolean isPreMatureClosure = false;
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
@@ -107,7 +117,8 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
transactionAmount, paymentDetail, isAccountTransfer, isRegularTransaction);
|
transactionAmount, paymentDetail, isAccountTransfer, isRegularTransaction);
|
||||||
|
|
||||||
account.handleScheduleInstallments(deposit);
|
account.handleScheduleInstallments(deposit);
|
||||||
account.updateMaturityDateAndAmount(mc, isPreMatureClosure);
|
account.updateMaturityDateAndAmount(mc, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
account.updateOverduePayments(DateUtils.getLocalDateOfTenant());
|
account.updateOverduePayments(DateUtils.getLocalDateOfTenant());
|
||||||
return deposit;
|
return deposit;
|
||||||
}
|
}
|
||||||
@@ -116,6 +127,12 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
@Override
|
@Override
|
||||||
public Long handleFDAccountClosure(final FixedDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
|
public Long handleFDAccountClosure(final FixedDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
|
||||||
final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
|
final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
boolean isRegularTransaction = false;
|
boolean isRegularTransaction = false;
|
||||||
boolean isAccountTransfer = false;
|
boolean isAccountTransfer = false;
|
||||||
final boolean isPreMatureClosure = false;
|
final boolean isPreMatureClosure = false;
|
||||||
@@ -140,13 +157,15 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
||||||
final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
|
final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
|
||||||
Long savingsTransactionId = null;
|
Long savingsTransactionId = null;
|
||||||
account.postMaturityInterest();
|
account.postMaturityInterest(isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
final Integer onAccountClosureId = command.integerValueOfParameterNamed(onAccountClosureIdParamName);
|
final Integer onAccountClosureId = command.integerValueOfParameterNamed(onAccountClosureIdParamName);
|
||||||
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
|
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
|
||||||
if (onClosureType.isReinvest()) {
|
if (onClosureType.isReinvest()) {
|
||||||
FixedDepositAccount reinvestedDeposit = account.reInvest(account.getAccountBalance());
|
FixedDepositAccount reinvestedDeposit = account.reInvest(account.getAccountBalance());
|
||||||
this.depositAccountAssembler.assignSavingAccountHelpers(reinvestedDeposit);
|
this.depositAccountAssembler.assignSavingAccountHelpers(reinvestedDeposit);
|
||||||
reinvestedDeposit.updateMaturityDateAndAmountBeforeAccountActivation(mc, isPreMatureClosure);
|
reinvestedDeposit.updateMaturityDateAndAmountBeforeAccountActivation(mc, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
this.savingsAccountRepository.save(reinvestedDeposit);
|
this.savingsAccountRepository.save(reinvestedDeposit);
|
||||||
autoGenerateAccountNumber(reinvestedDeposit);
|
autoGenerateAccountNumber(reinvestedDeposit);
|
||||||
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
|
final SavingsAccountTransaction withdrawal = this.handleWithdrawal(account, fmt, closedDate, account.getAccountBalance(),
|
||||||
@@ -185,6 +204,12 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
@Override
|
@Override
|
||||||
public Long handleRDAccountClosure(final RecurringDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
|
public Long handleRDAccountClosure(final RecurringDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
|
||||||
final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
|
final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
boolean isRegularTransaction = false;
|
boolean isRegularTransaction = false;
|
||||||
boolean isAccountTransfer = false;
|
boolean isAccountTransfer = false;
|
||||||
final boolean isPreMatureClosure = false;
|
final boolean isPreMatureClosure = false;
|
||||||
@@ -197,16 +222,19 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
||||||
final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
|
final LocalDate closedDate = command.localDateValueOfParameterNamed(SavingsApiConstants.closedOnDateParamName);
|
||||||
Long savingsTransactionId = null;
|
Long savingsTransactionId = null;
|
||||||
account.postMaturityInterest();
|
account.postMaturityInterest(isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
final BigDecimal transactionAmount = account.getAccountBalance();
|
final BigDecimal transactionAmount = account.getAccountBalance();
|
||||||
final Integer onAccountClosureId = command.integerValueOfParameterNamed(onAccountClosureIdParamName);
|
final Integer onAccountClosureId = command.integerValueOfParameterNamed(onAccountClosureIdParamName);
|
||||||
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
|
final DepositAccountOnClosureType onClosureType = DepositAccountOnClosureType.fromInt(onAccountClosureId);
|
||||||
if (onClosureType.isReinvest()) {
|
if (onClosureType.isReinvest()) {
|
||||||
RecurringDepositAccount reinvestedDeposit = account.reInvest(transactionAmount);
|
RecurringDepositAccount reinvestedDeposit = account.reInvest(transactionAmount);
|
||||||
depositAccountAssembler.assignSavingAccountHelpers(reinvestedDeposit);
|
depositAccountAssembler.assignSavingAccountHelpers(reinvestedDeposit);
|
||||||
reinvestedDeposit.updateMaturityDateAndAmount(mc, isPreMatureClosure);
|
reinvestedDeposit.updateMaturityDateAndAmount(mc, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
reinvestedDeposit.processAccountUponActivation(fmt);
|
reinvestedDeposit.processAccountUponActivation(fmt);
|
||||||
reinvestedDeposit.updateMaturityDateAndAmount(mc, isPreMatureClosure);
|
reinvestedDeposit.updateMaturityDateAndAmount(mc, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
this.savingsAccountRepository.save(reinvestedDeposit);
|
this.savingsAccountRepository.save(reinvestedDeposit);
|
||||||
|
|
||||||
Money amountForDeposit = reinvestedDeposit.activateWithBalance();
|
Money amountForDeposit = reinvestedDeposit.activateWithBalance();
|
||||||
@@ -214,7 +242,8 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
handleRDDeposit(reinvestedDeposit, fmt, reinvestedDeposit.getActivationLocalDate(), amountForDeposit.getAmount(),
|
handleRDDeposit(reinvestedDeposit, fmt, reinvestedDeposit.getActivationLocalDate(), amountForDeposit.getAmount(),
|
||||||
paymentDetail, isRegularTransaction);
|
paymentDetail, isRegularTransaction);
|
||||||
}
|
}
|
||||||
reinvestedDeposit.updateMaturityDateAndAmount(mc, isPreMatureClosure);
|
reinvestedDeposit.updateMaturityDateAndAmount(mc, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
this.savingsAccountRepository.save(reinvestedDeposit);
|
this.savingsAccountRepository.save(reinvestedDeposit);
|
||||||
autoGenerateAccountNumber(reinvestedDeposit);
|
autoGenerateAccountNumber(reinvestedDeposit);
|
||||||
|
|
||||||
@@ -265,6 +294,12 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
@Override
|
@Override
|
||||||
public Long handleFDAccountPreMatureClosure(final FixedDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
|
public Long handleFDAccountPreMatureClosure(final FixedDepositAccount account, final PaymentDetail paymentDetail, final AppUser user,
|
||||||
final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
|
final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
boolean isAccountTransfer = false;
|
boolean isAccountTransfer = false;
|
||||||
boolean isRegularTransaction = false;
|
boolean isRegularTransaction = false;
|
||||||
final boolean isPreMatureClosure = true;
|
final boolean isPreMatureClosure = true;
|
||||||
@@ -277,7 +312,8 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
||||||
Long savingsTransactionId = null;
|
Long savingsTransactionId = null;
|
||||||
// post interest
|
// post interest
|
||||||
account.postPreMaturityInterest(closedDate, isPreMatureClosure);
|
account.postPreMaturityInterest(closedDate, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
|
|
||||||
final Integer closureTypeValue = command.integerValueOfParameterNamed(DepositsApiConstants.onAccountClosureIdParamName);
|
final Integer closureTypeValue = command.integerValueOfParameterNamed(DepositsApiConstants.onAccountClosureIdParamName);
|
||||||
DepositAccountOnClosureType closureType = DepositAccountOnClosureType.fromInt(closureTypeValue);
|
DepositAccountOnClosureType closureType = DepositAccountOnClosureType.fromInt(closureTypeValue);
|
||||||
@@ -315,7 +351,13 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
@Override
|
@Override
|
||||||
public Long handleRDAccountPreMatureClosure(final RecurringDepositAccount account, final PaymentDetail paymentDetail,
|
public Long handleRDAccountPreMatureClosure(final RecurringDepositAccount account, final PaymentDetail paymentDetail,
|
||||||
final AppUser user, final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
|
final AppUser user, final JsonCommand command, final LocalDate tenantsTodayDate, final Map<String, Object> changes) {
|
||||||
boolean isAccountTransfer = false;
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
|
boolean isAccountTransfer = false;
|
||||||
final boolean isPreMatureClosure = true;
|
final boolean isPreMatureClosure = true;
|
||||||
boolean isRegularTransaction = false;
|
boolean isRegularTransaction = false;
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
@@ -327,7 +369,8 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
||||||
Long savingsTransactionId = null;
|
Long savingsTransactionId = null;
|
||||||
// post interest
|
// post interest
|
||||||
account.postPreMaturityInterest(closedDate, isPreMatureClosure);
|
account.postPreMaturityInterest(closedDate, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
|
|
||||||
final Integer closureTypeValue = command.integerValueOfParameterNamed(DepositsApiConstants.onAccountClosureIdParamName);
|
final Integer closureTypeValue = command.integerValueOfParameterNamed(DepositsApiConstants.onAccountClosureIdParamName);
|
||||||
DepositAccountOnClosureType closureType = DepositAccountOnClosureType.fromInt(closureTypeValue);
|
DepositAccountOnClosureType closureType = DepositAccountOnClosureType.fromInt(closureTypeValue);
|
||||||
|
|||||||
+60
-24
@@ -174,7 +174,9 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc);
|
return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMaturityDateAndAmountBeforeAccountActivation(final MathContext mc, final boolean isPreMatureClosure) {
|
public void updateMaturityDateAndAmountBeforeAccountActivation(final MathContext mc,
|
||||||
|
final boolean isPreMatureClosure, final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
List<SavingsAccountTransaction> allTransactions = new ArrayList<>();
|
List<SavingsAccountTransaction> allTransactions = new ArrayList<>();
|
||||||
final Money transactionAmountMoney = Money.of(getCurrency(), this.accountTermAndPreClosure.depositAmount());
|
final Money transactionAmountMoney = Money.of(getCurrency(), this.accountTermAndPreClosure.depositAmount());
|
||||||
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null,
|
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null,
|
||||||
@@ -182,15 +184,20 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
transaction.updateRunningBalance(transactionAmountMoney);
|
transaction.updateRunningBalance(transactionAmountMoney);
|
||||||
transaction.updateCumulativeBalanceAndDates(this.getCurrency(), interestCalculatedUpto());
|
transaction.updateCumulativeBalanceAndDates(this.getCurrency(), interestCalculatedUpto());
|
||||||
allTransactions.add(transaction);
|
allTransactions.add(transaction);
|
||||||
updateMaturityDateAndAmount(mc, allTransactions, isPreMatureClosure);
|
updateMaturityDateAndAmount(mc, allTransactions, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMaturityDateAndAmount(final MathContext mc, final boolean isPreMatureClosure) {
|
public void updateMaturityDateAndAmount(final MathContext mc, final boolean isPreMatureClosure,
|
||||||
updateMaturityDateAndAmount(mc, retreiveOrderedNonInterestPostingTransactions(), isPreMatureClosure);
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
updateMaturityDateAndAmount(mc, retreiveOrderedNonInterestPostingTransactions(), isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMaturityDateAndAmount(final MathContext mc, final List<SavingsAccountTransaction> transactions,
|
public void updateMaturityDateAndAmount(final MathContext mc, final List<SavingsAccountTransaction> transactions,
|
||||||
final boolean isPreMatureClosure) {
|
final boolean isPreMatureClosure, final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
final LocalDate maturityDate = calculateMaturityDate();
|
final LocalDate maturityDate = calculateMaturityDate();
|
||||||
final LocalDate interestCalculationUpto = maturityDate.minusDays(1);
|
final LocalDate interestCalculationUpto = maturityDate.minusDays(1);
|
||||||
|
|
||||||
@@ -198,7 +205,9 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
// calculation
|
// calculation
|
||||||
this.resetAccountTransactionsEndOfDayBalances(transactions, maturityDate);
|
this.resetAccountTransactionsEndOfDayBalances(transactions, maturityDate);
|
||||||
|
|
||||||
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, interestCalculationUpto, transactions, isPreMatureClosure);
|
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, interestCalculationUpto,
|
||||||
|
transactions, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
// reset end of day balance back to today's date
|
// reset end of day balance back to today's date
|
||||||
this.resetAccountTransactionsEndOfDayBalances(transactions, DateUtils.getLocalDateOfTenant());
|
this.resetAccountTransactionsEndOfDayBalances(transactions, DateUtils.getLocalDateOfTenant());
|
||||||
@@ -213,7 +222,8 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
this.accountTermAndPreClosure.updateMaturityDetails(maturityAmount.getAmount(), maturityDate);
|
this.accountTermAndPreClosure.updateMaturityDetails(maturityAmount.getAmount(), maturityDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMaturityStatus() {
|
public void updateMaturityStatus(final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||||
.resource(FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.updateMaturityDetailsAction);
|
.resource(FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.updateMaturityDetailsAction);
|
||||||
@@ -228,7 +238,8 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
if (!this.maturityDate().isAfter(todayDate)) {
|
if (!this.maturityDate().isAfter(todayDate)) {
|
||||||
// update account status
|
// update account status
|
||||||
this.status = SavingsAccountStatusType.MATURED.getValue();
|
this.status = SavingsAccountStatusType.MATURED.getValue();
|
||||||
postMaturityInterest();
|
postMaturityInterest(isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +269,9 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<PostingPeriod> calculateInterestPayable(final MathContext mc, final LocalDate maturityDate,
|
private List<PostingPeriod> calculateInterestPayable(final MathContext mc, final LocalDate maturityDate,
|
||||||
final List<SavingsAccountTransaction> transactions, final boolean isPreMatureClosure) {
|
final List<SavingsAccountTransaction> transactions, final boolean isPreMatureClosure,
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
|
||||||
final SavingsPostingInterestPeriodType postingPeriodType = SavingsPostingInterestPeriodType.fromInt(this.interestPostingPeriodType);
|
final SavingsPostingInterestPeriodType postingPeriodType = SavingsPostingInterestPeriodType.fromInt(this.interestPostingPeriodType);
|
||||||
|
|
||||||
@@ -269,7 +282,8 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
.fromInt(this.interestCalculationDaysInYearType);
|
.fromInt(this.interestCalculationDaysInYearType);
|
||||||
|
|
||||||
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
|
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
|
||||||
accountSubmittedOrActivationDate(), maturityDate, postingPeriodType);
|
accountSubmittedOrActivationDate(), maturityDate, postingPeriodType,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
|
final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
|
||||||
|
|
||||||
@@ -284,7 +298,8 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
|
|
||||||
final PostingPeriod postingPeriod = PostingPeriod.createFrom(periodInterval, periodStartingBalance, transactions,
|
final PostingPeriod postingPeriod = PostingPeriod.createFrom(periodInterval, periodStartingBalance, transactions,
|
||||||
this.currency, compoundingPeriodType, interestCalculationType, interestRateAsFraction, daysInYearType.getValue(),
|
this.currency, compoundingPeriodType, interestCalculationType, interestRateAsFraction, daysInYearType.getValue(),
|
||||||
maturityDate, interestPostTransactions, isInterestTransfer, minBalanceForInterestCalculation);
|
maturityDate, interestPostTransactions, isInterestTransfer, minBalanceForInterestCalculation,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd);
|
||||||
|
|
||||||
periodStartingBalance = postingPeriod.closingBalance();
|
periodStartingBalance = postingPeriod.closingBalance();
|
||||||
|
|
||||||
@@ -455,11 +470,14 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
// this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
// this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postMaturityInterest() {
|
public void postMaturityInterest(final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
final LocalDate interestPostingUpToDate = maturityDate();
|
final LocalDate interestPostingUpToDate = maturityDate();
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
final boolean isInterestTransfer = false;
|
final boolean isInterestTransfer = false;
|
||||||
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer);
|
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate,
|
||||||
|
isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
Money interestPostedToDate = Money.zero(this.currency);
|
Money interestPostedToDate = Money.zero(this.currency);
|
||||||
|
|
||||||
@@ -503,13 +521,17 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postPreMaturityInterest(final LocalDate accountCloseDate, final boolean isPreMatureClosure) {
|
public void postPreMaturityInterest(final LocalDate accountCloseDate, final boolean isPreMatureClosure,
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
|
||||||
Money interestPostedToDate = totalInterestPosted();
|
Money interestPostedToDate = totalInterestPosted();
|
||||||
// calculate interest before one day of closure date
|
// calculate interest before one day of closure date
|
||||||
final LocalDate interestCalculatedToDate = accountCloseDate.minusDays(1);
|
final LocalDate interestCalculatedToDate = accountCloseDate.minusDays(1);
|
||||||
final Money interestOnMaturity = calculatePreMatureInterest(interestCalculatedToDate,
|
final Money interestOnMaturity = calculatePreMatureInterest(interestCalculatedToDate,
|
||||||
retreiveOrderedNonInterestPostingTransactions(), isPreMatureClosure);
|
retreiveOrderedNonInterestPostingTransactions(), isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
boolean recalucateDailyBalance = false;
|
boolean recalucateDailyBalance = false;
|
||||||
|
|
||||||
// post remaining interest
|
// post remaining interest
|
||||||
@@ -531,12 +553,15 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculatePreMatureAmount(final LocalDate preMatureDate, final boolean isPreMatureClosure) {
|
public BigDecimal calculatePreMatureAmount(final LocalDate preMatureDate, final boolean isPreMatureClosure,
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
|
||||||
final Money interestPostedToDate = totalInterestPosted().copy();
|
final Money interestPostedToDate = totalInterestPosted().copy();
|
||||||
|
|
||||||
final Money interestEarnedTillDate = calculatePreMatureInterest(preMatureDate, retreiveOrderedNonInterestPostingTransactions(),
|
final Money interestEarnedTillDate = calculatePreMatureInterest(preMatureDate, retreiveOrderedNonInterestPostingTransactions(),
|
||||||
isPreMatureClosure);
|
isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
final Money accountBalance = Money.of(getCurrency(), getAccountBalance());
|
final Money accountBalance = Money.of(getCurrency(), getAccountBalance());
|
||||||
final Money maturityAmount = accountBalance.minus(interestPostedToDate).plus(interestEarnedTillDate);
|
final Money maturityAmount = accountBalance.minus(interestPostedToDate).plus(interestEarnedTillDate);
|
||||||
@@ -545,9 +570,12 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Money calculatePreMatureInterest(final LocalDate preMatureDate, final List<SavingsAccountTransaction> transactions,
|
private Money calculatePreMatureInterest(final LocalDate preMatureDate, final List<SavingsAccountTransaction> transactions,
|
||||||
final boolean isPreMatureClosure) {
|
final boolean isPreMatureClosure, final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, preMatureDate, transactions, isPreMatureClosure);
|
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, preMatureDate, transactions,
|
||||||
|
isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
Money interestOnMaturity = Money.zero(this.currency);
|
Money interestOnMaturity = Money.zero(this.currency);
|
||||||
|
|
||||||
@@ -560,15 +588,23 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postInterest(final MathContext mc, final LocalDate postingDate, boolean isInterestTransfer) {
|
public void postInterest(final MathContext mc, final LocalDate postingDate, boolean isInterestTransfer,
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
||||||
super.postInterest(mc, interestPostingUpToDate, isInterestTransfer);
|
super.postInterest(mc, interestPostingUpToDate, isInterestTransfer,
|
||||||
}
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate postingDate, boolean isInterestTransfer) {
|
public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate postingDate,
|
||||||
|
boolean isInterestTransfer, final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
||||||
return super.calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer);
|
return super.calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalDate interestPostingUpToDate(final LocalDate interestPostingDate) {
|
private LocalDate interestPostingUpToDate(final LocalDate interestPostingDate) {
|
||||||
|
|||||||
+45
-19
@@ -206,13 +206,16 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc);
|
return applicableInterestRate.divide(BigDecimal.valueOf(100l), mc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMaturityDateAndAmount(final MathContext mc, final boolean isPreMatureClosure) {
|
public void updateMaturityDateAndAmount(final MathContext mc, final boolean isPreMatureClosure,
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
final LocalDate maturityDate = calculateMaturityDate();
|
final LocalDate maturityDate = calculateMaturityDate();
|
||||||
final LocalDate interestCalculationUpto = maturityDate.minusDays(1);
|
final LocalDate interestCalculationUpto = maturityDate.minusDays(1);
|
||||||
final List<SavingsAccountTransaction> allTransactions = generateIncludingFutureTransactions(interestCalculationUpto);
|
final List<SavingsAccountTransaction> allTransactions = generateIncludingFutureTransactions(interestCalculationUpto);
|
||||||
|
|
||||||
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, interestCalculationUpto, allTransactions,
|
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, interestCalculationUpto, allTransactions,
|
||||||
isPreMatureClosure);
|
isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
Money totalInterestPayable = Money.zero(getCurrency());
|
Money totalInterestPayable = Money.zero(getCurrency());
|
||||||
Money totalDepositAmount = Money.zero(getCurrency());
|
Money totalDepositAmount = Money.zero(getCurrency());
|
||||||
for (PostingPeriod postingPeriod : postingPeriods) {
|
for (PostingPeriod postingPeriod : postingPeriods) {
|
||||||
@@ -223,7 +226,8 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
this.accountTermAndPreClosure.updateMaturityDetails(totalDepositAmount.getAmount(), totalInterestPayable.getAmount(), maturityDate);
|
this.accountTermAndPreClosure.updateMaturityDetails(totalDepositAmount.getAmount(), totalInterestPayable.getAmount(), maturityDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateMaturityStatus() {
|
public void updateMaturityStatus(final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||||
.resource(RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.updateMaturityDetailsAction);
|
.resource(RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME + SavingsApiConstants.updateMaturityDetailsAction);
|
||||||
@@ -238,7 +242,8 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
if (!this.maturityDate().isAfter(todayDate)) {
|
if (!this.maturityDate().isAfter(todayDate)) {
|
||||||
// update account status
|
// update account status
|
||||||
this.status = SavingsAccountStatusType.MATURED.getValue();
|
this.status = SavingsAccountStatusType.MATURED.getValue();
|
||||||
postMaturityInterest();
|
postMaturityInterest(isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +273,9 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<PostingPeriod> calculateInterestPayable(final MathContext mc, final LocalDate maturityDate,
|
private List<PostingPeriod> calculateInterestPayable(final MathContext mc, final LocalDate maturityDate,
|
||||||
final List<SavingsAccountTransaction> transactions, final boolean isPreMatureClosure) {
|
final List<SavingsAccountTransaction> transactions, final boolean isPreMatureClosure,
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
|
||||||
// 1. default to calculate interest based on entire history OR
|
// 1. default to calculate interest based on entire history OR
|
||||||
// 2. determine latest 'posting period' and find interest credited to
|
// 2. determine latest 'posting period' and find interest credited to
|
||||||
@@ -284,7 +291,7 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
.fromInt(this.interestCalculationDaysInYearType);
|
.fromInt(this.interestCalculationDaysInYearType);
|
||||||
|
|
||||||
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(depositStartDate(),
|
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(depositStartDate(),
|
||||||
maturityDate, postingPeriodType);
|
maturityDate, postingPeriodType, financialYearBeginningMonth);
|
||||||
|
|
||||||
final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
|
final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
|
||||||
|
|
||||||
@@ -298,7 +305,8 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
for (final LocalDateInterval periodInterval : postingPeriodIntervals) {
|
for (final LocalDateInterval periodInterval : postingPeriodIntervals) {
|
||||||
final PostingPeriod postingPeriod = PostingPeriod.createFrom(periodInterval, periodStartingBalance, transactions,
|
final PostingPeriod postingPeriod = PostingPeriod.createFrom(periodInterval, periodStartingBalance, transactions,
|
||||||
this.currency, compoundingPeriodType, interestCalculationType, interestRateAsFraction, daysInYearType.getValue(),
|
this.currency, compoundingPeriodType, interestCalculationType, interestRateAsFraction, daysInYearType.getValue(),
|
||||||
maturityDate, interestPostTransactions, isInterestTransfer, minBalanceForInterestCalculation);
|
maturityDate, interestPostTransactions, isInterestTransfer, minBalanceForInterestCalculation,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd);
|
||||||
|
|
||||||
periodStartingBalance = postingPeriod.closingBalance();
|
periodStartingBalance = postingPeriod.closingBalance();
|
||||||
|
|
||||||
@@ -560,11 +568,14 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postMaturityInterest() {
|
public void postMaturityInterest(final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
final LocalDate interestPostingUpToDate = maturityDate();
|
final LocalDate interestPostingUpToDate = maturityDate();
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer);
|
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate,
|
||||||
|
isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
Money interestPostedToDate = Money.zero(this.currency);
|
Money interestPostedToDate = Money.zero(this.currency);
|
||||||
|
|
||||||
@@ -606,13 +617,17 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postPreMaturityInterest(final LocalDate accountCloseDate, final boolean isPreMatureClosure) {
|
public void postPreMaturityInterest(final LocalDate accountCloseDate, final boolean isPreMatureClosure,
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
|
||||||
final Money interestPostedToDate = totalInterestPosted();
|
final Money interestPostedToDate = totalInterestPosted();
|
||||||
// calculate interest before one day of closure date
|
// calculate interest before one day of closure date
|
||||||
final LocalDate interestCalculatedToDate = accountCloseDate.minusDays(1);
|
final LocalDate interestCalculatedToDate = accountCloseDate.minusDays(1);
|
||||||
final Money interestOnMaturity = calculatePreMatureInterest(interestCalculatedToDate,
|
final Money interestOnMaturity = calculatePreMatureInterest(interestCalculatedToDate,
|
||||||
retreiveOrderedNonInterestPostingTransactions(), isPreMatureClosure);
|
retreiveOrderedNonInterestPostingTransactions(), isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
boolean recalucateDailyBalance = false;
|
boolean recalucateDailyBalance = false;
|
||||||
|
|
||||||
@@ -635,12 +650,15 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
this.accountTermAndPreClosure.updateMaturityDetails(this.getAccountBalance(), accountCloseDate);
|
this.accountTermAndPreClosure.updateMaturityDetails(this.getAccountBalance(), accountCloseDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculatePreMatureAmount(final LocalDate preMatureDate, final boolean isPreMatureClosure) {
|
public BigDecimal calculatePreMatureAmount(final LocalDate preMatureDate, final boolean isPreMatureClosure,
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
|
||||||
final Money interestPostedToDate = totalInterestPosted().copy();
|
final Money interestPostedToDate = totalInterestPosted().copy();
|
||||||
|
|
||||||
final Money interestEarnedTillDate = calculatePreMatureInterest(preMatureDate, retreiveOrderedNonInterestPostingTransactions(),
|
final Money interestEarnedTillDate = calculatePreMatureInterest(preMatureDate, retreiveOrderedNonInterestPostingTransactions(),
|
||||||
isPreMatureClosure);
|
isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
final Money accountBalance = Money.of(getCurrency(), getAccountBalance());
|
final Money accountBalance = Money.of(getCurrency(), getAccountBalance());
|
||||||
final Money maturityAmount = accountBalance.minus(interestPostedToDate).plus(interestEarnedTillDate);
|
final Money maturityAmount = accountBalance.minus(interestPostedToDate).plus(interestEarnedTillDate);
|
||||||
@@ -649,9 +667,12 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Money calculatePreMatureInterest(final LocalDate preMatureDate, final List<SavingsAccountTransaction> transactions,
|
private Money calculatePreMatureInterest(final LocalDate preMatureDate, final List<SavingsAccountTransaction> transactions,
|
||||||
final boolean isPreMatureClosure) {
|
final boolean isPreMatureClosure, final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, preMatureDate, transactions, isPreMatureClosure);
|
final List<PostingPeriod> postingPeriods = calculateInterestPayable(mc, preMatureDate, transactions,
|
||||||
|
isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
Money interestOnMaturity = Money.zero(this.currency);
|
Money interestOnMaturity = Money.zero(this.currency);
|
||||||
|
|
||||||
@@ -664,15 +685,20 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postInterest(final MathContext mc, final LocalDate postingDate, final boolean isInterestTransfer) {
|
public void postInterest(final MathContext mc, final LocalDate postingDate, final boolean isInterestTransfer,
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd, final Integer financialYearBeginningMonth) {
|
||||||
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
||||||
super.postInterest(mc, interestPostingUpToDate, isInterestTransfer);
|
super.postInterest(mc, interestPostingUpToDate, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate postingDate, boolean isInterestTransfer) {
|
public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate postingDate,
|
||||||
|
boolean isInterestTransfer, final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
final LocalDate interestPostingUpToDate = interestPostingUpToDate(postingDate);
|
||||||
return super.calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer);
|
return super.calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalDate interestPostingUpToDate(final LocalDate interestPostingDate) {
|
private LocalDate interestPostingUpToDate(final LocalDate interestPostingDate) {
|
||||||
|
|||||||
+23
-10
@@ -417,9 +417,14 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
return SavingsAccountStatusType.fromInt(this.status).isClosed();
|
return SavingsAccountStatusType.fromInt(this.status).isClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postInterest(final MathContext mc, final LocalDate interestPostingUpToDate, final boolean isInterestTransfer) {
|
public void postInterest(final MathContext mc,
|
||||||
|
final LocalDate interestPostingUpToDate,
|
||||||
|
final boolean isInterestTransfer,
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
|
||||||
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer);
|
final List<PostingPeriod> postingPeriods = calculateInterestUsing(mc, interestPostingUpToDate, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
|
|
||||||
Money interestPostedToDate = Money.zero(this.currency);
|
Money interestPostedToDate = Money.zero(this.currency);
|
||||||
|
|
||||||
@@ -514,7 +519,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate upToInterestCalculationDate,
|
public List<PostingPeriod> calculateInterestUsing(final MathContext mc, final LocalDate upToInterestCalculationDate,
|
||||||
boolean isInterestTransfer) {
|
boolean isInterestTransfer, final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
|
||||||
// no openingBalance concept supported yet but probably will to allow
|
// no openingBalance concept supported yet but probably will to allow
|
||||||
// for migrations.
|
// for migrations.
|
||||||
@@ -538,7 +544,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
.fromInt(this.interestCalculationDaysInYearType);
|
.fromInt(this.interestCalculationDaysInYearType);
|
||||||
|
|
||||||
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
|
final List<LocalDateInterval> postingPeriodIntervals = this.savingsHelper.determineInterestPostingPeriods(
|
||||||
getStartInterestCalculationDate(), upToInterestCalculationDate, postingPeriodType);
|
getStartInterestCalculationDate(), upToInterestCalculationDate, postingPeriodType,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
|
final List<PostingPeriod> allPostingPeriods = new ArrayList<>();
|
||||||
|
|
||||||
@@ -576,7 +583,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
final PostingPeriod postingPeriod = PostingPeriod.createFrom(periodInterval, periodStartingBalance,
|
final PostingPeriod postingPeriod = PostingPeriod.createFrom(periodInterval, periodStartingBalance,
|
||||||
retreiveOrderedNonInterestPostingTransactions(), this.currency, compoundingPeriodType, interestCalculationType,
|
retreiveOrderedNonInterestPostingTransactions(), this.currency, compoundingPeriodType, interestCalculationType,
|
||||||
interestRateAsFraction, daysInYearType.getValue(), upToInterestCalculationDate, interestPostTransactions,
|
interestRateAsFraction, daysInYearType.getValue(), upToInterestCalculationDate, interestPostTransactions,
|
||||||
isInterestTransfer, minBalanceForInterestCalculation);
|
isInterestTransfer, minBalanceForInterestCalculation, isSavingsInterestPostingAtCurrentPeriodEnd);
|
||||||
|
|
||||||
periodStartingBalance = postingPeriod.closingBalance();
|
periodStartingBalance = postingPeriod.closingBalance();
|
||||||
|
|
||||||
@@ -1825,7 +1832,9 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
return actualChanges;
|
return actualChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processAccountUponActivation() {
|
public void processAccountUponActivation(
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
|
||||||
// update annual fee due date
|
// update annual fee due date
|
||||||
for (SavingsAccountCharge charge : this.charges()) {
|
for (SavingsAccountCharge charge : this.charges()) {
|
||||||
@@ -1833,7 +1842,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// auto pay the activation time charges
|
// auto pay the activation time charges
|
||||||
this.payActivationCharges();
|
this.payActivationCharges(isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
// TODO : AA add activation charges to actual changes list
|
// TODO : AA add activation charges to actual changes list
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1856,7 +1866,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
this.lockedInUntilDate = calculateDateAccountIsLockedUntil(getActivationLocalDate());
|
this.lockedInUntilDate = calculateDateAccountIsLockedUntil(getActivationLocalDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void payActivationCharges() {
|
private void payActivationCharges(final boolean isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
boolean isSavingsChargeApplied = false;
|
boolean isSavingsChargeApplied = false;
|
||||||
for (SavingsAccountCharge savingsAccountCharge : this.charges()) {
|
for (SavingsAccountCharge savingsAccountCharge : this.charges()) {
|
||||||
if (savingsAccountCharge.isSavingsActivation()) {
|
if (savingsAccountCharge.isSavingsActivation()) {
|
||||||
@@ -1870,10 +1881,12 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
if (this.isBeforeLastPostingPeriod(getActivationLocalDate())) {
|
if (this.isBeforeLastPostingPeriod(getActivationLocalDate())) {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
this.postInterest(mc, today, isInterestTransfer);
|
this.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
this.calculateInterestUsing(mc, today, isInterestTransfer);
|
this.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-5
@@ -15,6 +15,7 @@ import java.util.Set;
|
|||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService;
|
import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||||
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||||
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrency;
|
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrency;
|
||||||
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrencyRepositoryWrapper;
|
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrencyRepositoryWrapper;
|
||||||
@@ -34,16 +35,19 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
|
|||||||
private final SavingsAccountTransactionRepository savingsAccountTransactionRepository;
|
private final SavingsAccountTransactionRepository savingsAccountTransactionRepository;
|
||||||
private final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper;
|
private final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper;
|
||||||
private final JournalEntryWritePlatformService journalEntryWritePlatformService;
|
private final JournalEntryWritePlatformService journalEntryWritePlatformService;
|
||||||
|
private final ConfigurationDomainService configurationDomainService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public SavingsAccountDomainServiceJpa(final SavingsAccountRepositoryWrapper savingsAccountRepository,
|
public SavingsAccountDomainServiceJpa(final SavingsAccountRepositoryWrapper savingsAccountRepository,
|
||||||
final SavingsAccountTransactionRepository savingsAccountTransactionRepository,
|
final SavingsAccountTransactionRepository savingsAccountTransactionRepository,
|
||||||
final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper,
|
final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper,
|
||||||
final JournalEntryWritePlatformService journalEntryWritePlatformService) {
|
final JournalEntryWritePlatformService journalEntryWritePlatformService,
|
||||||
|
final ConfigurationDomainService configurationDomainService) {
|
||||||
this.savingsAccountRepository = savingsAccountRepository;
|
this.savingsAccountRepository = savingsAccountRepository;
|
||||||
this.savingsAccountTransactionRepository = savingsAccountTransactionRepository;
|
this.savingsAccountTransactionRepository = savingsAccountTransactionRepository;
|
||||||
this.applicationCurrencyRepositoryWrapper = applicationCurrencyRepositoryWrapper;
|
this.applicationCurrencyRepositoryWrapper = applicationCurrencyRepositoryWrapper;
|
||||||
this.journalEntryWritePlatformService = journalEntryWritePlatformService;
|
this.journalEntryWritePlatformService = journalEntryWritePlatformService;
|
||||||
|
this.configurationDomainService = configurationDomainService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -52,6 +56,11 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
|
|||||||
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail,
|
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail,
|
||||||
final SavingsTransactionBooleanValues transactionBooleanValues) {
|
final SavingsTransactionBooleanValues transactionBooleanValues) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
if (transactionBooleanValues.isRegularTransaction() && !account.allowWithdrawal()) { throw new DepositAccountTransactionNotAllowedException(
|
if (transactionBooleanValues.isRegularTransaction() && !account.allowWithdrawal()) { throw new DepositAccountTransactionNotAllowedException(
|
||||||
account.getId(), "withdraw", account.depositAccountType()); }
|
account.getId(), "withdraw", account.depositAccountType()); }
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
@@ -64,10 +73,14 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
|
|||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
if (account.isBeforeLastPostingPeriod(transactionDate)) {
|
if (account.isBeforeLastPostingPeriod(transactionDate)) {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.postInterest(mc, today, transactionBooleanValues.isInterestTransfer());
|
account.postInterest(mc, today, transactionBooleanValues.isInterestTransfer(),
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.calculateInterestUsing(mc, today, transactionBooleanValues.isInterestTransfer());
|
account.calculateInterestUsing(mc, today, transactionBooleanValues.isInterestTransfer(),
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative(transactionAmount, transactionBooleanValues.isWithdrawBalance());
|
account.validateAccountBalanceDoesNotBecomeNegative(transactionAmount, transactionBooleanValues.isWithdrawBalance());
|
||||||
saveTransactionToGenerateTransactionId(withdrawal);
|
saveTransactionToGenerateTransactionId(withdrawal);
|
||||||
@@ -84,6 +97,11 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
|
|||||||
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail,
|
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail,
|
||||||
final boolean isAccountTransfer, final boolean isRegularTransaction) {
|
final boolean isAccountTransfer, final boolean isRegularTransaction) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
if (isRegularTransaction && !account.allowDeposit()) { throw new DepositAccountTransactionNotAllowedException(account.getId(),
|
if (isRegularTransaction && !account.allowDeposit()) { throw new DepositAccountTransactionNotAllowedException(account.getId(),
|
||||||
"deposit", account.depositAccountType()); }
|
"deposit", account.depositAccountType()); }
|
||||||
|
|
||||||
@@ -98,10 +116,13 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
|
|||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
if (account.isBeforeLastPostingPeriod(transactionDate)) {
|
if (account.isBeforeLastPostingPeriod(transactionDate)) {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveTransactionToGenerateTransactionId(deposit);
|
saveTransactionToGenerateTransactionId(deposit);
|
||||||
|
|||||||
+72
-45
@@ -7,9 +7,9 @@ package org.mifosplatform.portfolio.savings.domain;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.mifosplatform.infrastructure.core.domain.LocalDateInterval;
|
import org.mifosplatform.infrastructure.core.domain.LocalDateInterval;
|
||||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||||
@@ -30,7 +30,8 @@ public final class SavingsHelper {
|
|||||||
private final CompoundInterestHelper compoundInterestHelper = new CompoundInterestHelper();
|
private final CompoundInterestHelper compoundInterestHelper = new CompoundInterestHelper();
|
||||||
|
|
||||||
public List<LocalDateInterval> determineInterestPostingPeriods(final LocalDate startInterestCalculationLocalDate,
|
public List<LocalDateInterval> determineInterestPostingPeriods(final LocalDate startInterestCalculationLocalDate,
|
||||||
final LocalDate interestPostingUpToDate, final SavingsPostingInterestPeriodType postingPeriodType) {
|
final LocalDate interestPostingUpToDate, final SavingsPostingInterestPeriodType postingPeriodType,
|
||||||
|
final Integer financialYearBeginningMonth) {
|
||||||
|
|
||||||
final List<LocalDateInterval> postingPeriods = new ArrayList<>();
|
final List<LocalDateInterval> postingPeriods = new ArrayList<>();
|
||||||
|
|
||||||
@@ -40,14 +41,10 @@ public final class SavingsHelper {
|
|||||||
while (!periodStartDate.isAfter(interestPostingUpToDate) && !periodEndDate.isAfter(interestPostingUpToDate)) {
|
while (!periodStartDate.isAfter(interestPostingUpToDate) && !periodEndDate.isAfter(interestPostingUpToDate)) {
|
||||||
|
|
||||||
final LocalDate interestPostingLocalDate = determineInterestPostingPeriodEndDateFrom(periodStartDate, postingPeriodType,
|
final LocalDate interestPostingLocalDate = determineInterestPostingPeriodEndDateFrom(periodStartDate, postingPeriodType,
|
||||||
interestPostingUpToDate);
|
interestPostingUpToDate, financialYearBeginningMonth);
|
||||||
periodEndDate = interestPostingLocalDate.minusDays(1);
|
periodEndDate = interestPostingLocalDate.minusDays(1);
|
||||||
|
|
||||||
if (!interestPostingLocalDate.isAfter(interestPostingUpToDate)) {
|
postingPeriods.add(LocalDateInterval.create(periodStartDate, periodEndDate));
|
||||||
postingPeriods.add(LocalDateInterval.create(periodStartDate, periodEndDate));
|
|
||||||
} else {
|
|
||||||
postingPeriods.add(LocalDateInterval.create(periodStartDate, periodEndDate));
|
|
||||||
}
|
|
||||||
|
|
||||||
periodEndDate = interestPostingLocalDate;
|
periodEndDate = interestPostingLocalDate;
|
||||||
periodStartDate = interestPostingLocalDate;
|
periodStartDate = interestPostingLocalDate;
|
||||||
@@ -57,46 +54,76 @@ public final class SavingsHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LocalDate determineInterestPostingPeriodEndDateFrom(final LocalDate periodStartDate,
|
private LocalDate determineInterestPostingPeriodEndDateFrom(final LocalDate periodStartDate,
|
||||||
final SavingsPostingInterestPeriodType interestPostingPeriodType, final LocalDate interestPostingUpToDate) {
|
final SavingsPostingInterestPeriodType interestPostingPeriodType, final LocalDate interestPostingUpToDate,
|
||||||
|
Integer financialYearBeginningMonth) {
|
||||||
|
|
||||||
LocalDate periodEndDate = interestPostingUpToDate;
|
LocalDate periodEndDate = interestPostingUpToDate;
|
||||||
|
final Integer monthOfYear = periodStartDate.getMonthOfYear();
|
||||||
|
financialYearBeginningMonth--;
|
||||||
|
if(financialYearBeginningMonth == 0)
|
||||||
|
financialYearBeginningMonth = 12;
|
||||||
|
|
||||||
switch (interestPostingPeriodType) {
|
final ArrayList<LocalDate> quarterlyDates = new ArrayList<>();
|
||||||
case INVALID:
|
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).dayOfMonth().withMaximumValue());
|
||||||
break;
|
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth)
|
||||||
case MONTHLY:
|
.plusMonths(3).withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue());
|
||||||
// produce period end date on last day of current month
|
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth)
|
||||||
periodEndDate = periodStartDate.dayOfMonth().withMaximumValue();
|
.plusMonths(6).withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue());
|
||||||
break;
|
quarterlyDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth)
|
||||||
case QUATERLY:
|
.plusMonths(9).withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue());
|
||||||
// jan 1st to mar 31st, 1st apr to jun 30, jul 1st to sept 30,
|
Collections.sort(quarterlyDates);
|
||||||
// oct 1st to dec 31
|
|
||||||
final int year = periodStartDate.getYearOfEra();
|
final ArrayList<LocalDate> biannualDates = new ArrayList<>();
|
||||||
final int monthofYear = periodStartDate.getMonthOfYear();
|
biannualDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).dayOfMonth().withMaximumValue());
|
||||||
if (monthofYear <= 3) {
|
biannualDates.add(periodStartDate.withMonthOfYear(financialYearBeginningMonth).plusMonths(6)
|
||||||
periodEndDate = new DateTime().withDate(year, 3, 31).toLocalDate();
|
.withYear(periodStartDate.getYear()).dayOfMonth().withMaximumValue());
|
||||||
} else if (monthofYear <= 6) {
|
Collections.sort(biannualDates);
|
||||||
periodEndDate = new DateTime().withDate(year, 6, 30).toLocalDate();
|
|
||||||
} else if (monthofYear <= 9) {
|
boolean isEndDateSet = false;
|
||||||
periodEndDate = new DateTime().withDate(year, 9, 30).toLocalDate();
|
|
||||||
} else if (monthofYear <= 12) {
|
switch (interestPostingPeriodType) {
|
||||||
periodEndDate = new DateTime().withDate(year, 12, 31).toLocalDate();
|
case INVALID:
|
||||||
}
|
break;
|
||||||
break;
|
case MONTHLY:
|
||||||
case BIANNUAL:
|
// produce period end date on last day of current month
|
||||||
final int byear = periodStartDate.getYearOfEra();
|
periodEndDate = periodStartDate.dayOfMonth().withMaximumValue();
|
||||||
final int bmonthofYear = periodStartDate.getMonthOfYear();
|
break;
|
||||||
if (bmonthofYear <= 6) {
|
case QUATERLY:
|
||||||
periodEndDate = new DateTime().withDate(byear, 6, 30).toLocalDate();
|
for(LocalDate quarterlyDate : quarterlyDates) {
|
||||||
} else if (bmonthofYear <= 12) {
|
if(quarterlyDate.isAfter(periodStartDate)) {
|
||||||
periodEndDate = new DateTime().withDate(byear, 12, 31).toLocalDate();
|
periodEndDate = quarterlyDate;
|
||||||
}
|
isEndDateSet = true;
|
||||||
break;
|
break;
|
||||||
case ANNUAL:
|
}
|
||||||
periodEndDate = periodStartDate.monthOfYear().withMaximumValue();
|
}
|
||||||
periodEndDate = periodEndDate.dayOfMonth().withMaximumValue();
|
|
||||||
break;
|
if(!isEndDateSet)
|
||||||
}
|
periodEndDate = quarterlyDates.get(0).plusYears(1).dayOfMonth().withMaximumValue();
|
||||||
|
break;
|
||||||
|
case BIANNUAL:
|
||||||
|
for(LocalDate biannualDate : biannualDates) {
|
||||||
|
if(biannualDate.isAfter(periodStartDate)) {
|
||||||
|
periodEndDate = biannualDate;
|
||||||
|
isEndDateSet = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isEndDateSet)
|
||||||
|
periodEndDate = biannualDates.get(0).plusYears(1).dayOfMonth().withMaximumValue();
|
||||||
|
break;
|
||||||
|
case ANNUAL:
|
||||||
|
if (financialYearBeginningMonth < monthOfYear) {
|
||||||
|
periodEndDate = periodStartDate
|
||||||
|
.withMonthOfYear(financialYearBeginningMonth);
|
||||||
|
periodEndDate = periodEndDate.plusYears(1);
|
||||||
|
} else {
|
||||||
|
periodEndDate = periodStartDate
|
||||||
|
.withMonthOfYear(financialYearBeginningMonth);
|
||||||
|
}
|
||||||
|
periodEndDate = periodEndDate.dayOfMonth().withMaximumValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// interest posting always occurs on next day after the period end date.
|
// interest posting always occurs on next day after the period end date.
|
||||||
periodEndDate = periodEndDate.plusDays(1);
|
periodEndDate = periodEndDate.plusDays(1);
|
||||||
|
|||||||
+8
-4
@@ -52,7 +52,7 @@ public class PostingPeriod {
|
|||||||
final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType,
|
final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType,
|
||||||
final SavingsInterestCalculationType interestCalculationType, final BigDecimal interestRateAsFraction, final long daysInYear,
|
final SavingsInterestCalculationType interestCalculationType, final BigDecimal interestRateAsFraction, final long daysInYear,
|
||||||
final LocalDate upToInterestCalculationDate, Collection<Long> interestPostTransactions, boolean isInterestTransfer,
|
final LocalDate upToInterestCalculationDate, Collection<Long> interestPostTransactions, boolean isInterestTransfer,
|
||||||
final Money minBalanceForInterestCalculation) {
|
final Money minBalanceForInterestCalculation, final boolean isSavingsInterestPostingAtCurrentPeriodEnd) {
|
||||||
|
|
||||||
final List<EndOfDayBalance> accountEndOfDayBalances = new ArrayList<>();
|
final List<EndOfDayBalance> accountEndOfDayBalances = new ArrayList<>();
|
||||||
boolean interestTransfered = false;
|
boolean interestTransfered = false;
|
||||||
@@ -113,13 +113,14 @@ public class PostingPeriod {
|
|||||||
|
|
||||||
return new PostingPeriod(periodInterval, currency, periodStartingBalance, openingDayBalance, interestCompoundingPeriodType,
|
return new PostingPeriod(periodInterval, currency, periodStartingBalance, openingDayBalance, interestCompoundingPeriodType,
|
||||||
interestCalculationType, interestRateAsFraction, daysInYear, compoundingPeriods, interestTransfered,
|
interestCalculationType, interestRateAsFraction, daysInYear, compoundingPeriods, interestTransfered,
|
||||||
minBalanceForInterestCalculation);
|
minBalanceForInterestCalculation, isSavingsInterestPostingAtCurrentPeriodEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
private PostingPeriod(final LocalDateInterval periodInterval, final MonetaryCurrency currency, final Money openingBalance,
|
private PostingPeriod(final LocalDateInterval periodInterval, final MonetaryCurrency currency, final Money openingBalance,
|
||||||
final Money closingBalance, final SavingsCompoundingInterestPeriodType interestCompoundingType,
|
final Money closingBalance, final SavingsCompoundingInterestPeriodType interestCompoundingType,
|
||||||
final SavingsInterestCalculationType interestCalculationType, final BigDecimal interestRateAsFraction, final long daysInYear,
|
final SavingsInterestCalculationType interestCalculationType, final BigDecimal interestRateAsFraction, final long daysInYear,
|
||||||
final List<CompoundingPeriod> compoundingPeriods, boolean interestTransfered, final Money minBalanceForInterestCalculation) {
|
final List<CompoundingPeriod> compoundingPeriods, boolean interestTransfered, final Money minBalanceForInterestCalculation,
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd) {
|
||||||
this.periodInterval = periodInterval;
|
this.periodInterval = periodInterval;
|
||||||
this.currency = currency;
|
this.currency = currency;
|
||||||
this.openingBalance = openingBalance;
|
this.openingBalance = openingBalance;
|
||||||
@@ -130,7 +131,10 @@ public class PostingPeriod {
|
|||||||
this.daysInYear = daysInYear;
|
this.daysInYear = daysInYear;
|
||||||
this.compoundingPeriods = compoundingPeriods;
|
this.compoundingPeriods = compoundingPeriods;
|
||||||
|
|
||||||
this.dateOfPostingTransaction = periodInterval.endDate().plusDays(1);
|
if(isSavingsInterestPostingAtCurrentPeriodEnd)
|
||||||
|
this.dateOfPostingTransaction = periodInterval.endDate();
|
||||||
|
else
|
||||||
|
this.dateOfPostingTransaction = periodInterval.endDate().plusDays(1);
|
||||||
this.interestTransfered = interestTransfered;
|
this.interestTransfered = interestTransfered;
|
||||||
this.minBalanceForInterestCalculation = minBalanceForInterestCalculation;
|
this.minBalanceForInterestCalculation = minBalanceForInterestCalculation;
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-5
@@ -12,6 +12,7 @@ import java.util.Collection;
|
|||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||||
import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService;
|
import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonQuery;
|
import org.mifosplatform.infrastructure.core.api.JsonQuery;
|
||||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||||
@@ -41,17 +42,20 @@ public class DepositAccountPreMatureCalculationPlatformServiceImpl implements De
|
|||||||
private final DepositAccountAssembler depositAccountAssembler;
|
private final DepositAccountAssembler depositAccountAssembler;
|
||||||
private final CodeValueReadPlatformService codeValueReadPlatformService;
|
private final CodeValueReadPlatformService codeValueReadPlatformService;
|
||||||
private final SavingsAccountReadPlatformService savingsAccountReadPlatformService;
|
private final SavingsAccountReadPlatformService savingsAccountReadPlatformService;
|
||||||
|
private final ConfigurationDomainService configurationDomainService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DepositAccountPreMatureCalculationPlatformServiceImpl(final FromJsonHelper fromJsonHelper,
|
public DepositAccountPreMatureCalculationPlatformServiceImpl(final FromJsonHelper fromJsonHelper,
|
||||||
final DepositAccountTransactionDataValidator depositAccountTransactionDataValidator,
|
final DepositAccountTransactionDataValidator depositAccountTransactionDataValidator,
|
||||||
final DepositAccountAssembler depositAccountAssembler, final CodeValueReadPlatformService codeValueReadPlatformService,
|
final DepositAccountAssembler depositAccountAssembler, final CodeValueReadPlatformService codeValueReadPlatformService,
|
||||||
final SavingsAccountReadPlatformService savingsAccountReadPlatformService) {
|
final SavingsAccountReadPlatformService savingsAccountReadPlatformService,
|
||||||
|
final ConfigurationDomainService configurationDomainService) {
|
||||||
this.fromJsonHelper = fromJsonHelper;
|
this.fromJsonHelper = fromJsonHelper;
|
||||||
this.depositAccountTransactionDataValidator = depositAccountTransactionDataValidator;
|
this.depositAccountTransactionDataValidator = depositAccountTransactionDataValidator;
|
||||||
this.depositAccountAssembler = depositAccountAssembler;
|
this.depositAccountAssembler = depositAccountAssembler;
|
||||||
this.codeValueReadPlatformService = codeValueReadPlatformService;
|
this.codeValueReadPlatformService = codeValueReadPlatformService;
|
||||||
this.savingsAccountReadPlatformService = savingsAccountReadPlatformService;
|
this.savingsAccountReadPlatformService = savingsAccountReadPlatformService;
|
||||||
|
this.configurationDomainService = configurationDomainService;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +63,12 @@ public class DepositAccountPreMatureCalculationPlatformServiceImpl implements De
|
|||||||
@Override
|
@Override
|
||||||
public DepositAccountData calculatePreMatureAmount(final Long accountId, final JsonQuery query,
|
public DepositAccountData calculatePreMatureAmount(final Long accountId, final JsonQuery query,
|
||||||
final DepositAccountType depositAccountType) {
|
final DepositAccountType depositAccountType) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
this.depositAccountTransactionDataValidator.validatePreMatureAmountCalculation(query.json(), depositAccountType);
|
this.depositAccountTransactionDataValidator.validatePreMatureAmountCalculation(query.json(), depositAccountType);
|
||||||
final SavingsAccount account = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
|
final SavingsAccount account = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
|
||||||
|
|
||||||
@@ -79,13 +89,15 @@ public class DepositAccountPreMatureCalculationPlatformServiceImpl implements De
|
|||||||
if (depositAccountType.isFixedDeposit()) {
|
if (depositAccountType.isFixedDeposit()) {
|
||||||
final FixedDepositAccount fd = (FixedDepositAccount) account;
|
final FixedDepositAccount fd = (FixedDepositAccount) account;
|
||||||
accountData = FixedDepositAccountData.preClosureDetails(account.getId(),
|
accountData = FixedDepositAccountData.preClosureDetails(account.getId(),
|
||||||
fd.calculatePreMatureAmount(interestCalculatedToDate, isPreMatureClosure), onAccountClosureOptions, paymentTypeOptions,
|
fd.calculatePreMatureAmount(interestCalculatedToDate, isPreMatureClosure,
|
||||||
savingsAccountDatas);
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth),
|
||||||
|
onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas);
|
||||||
} else if (depositAccountType.isRecurringDeposit()) {
|
} else if (depositAccountType.isRecurringDeposit()) {
|
||||||
final RecurringDepositAccount rd = (RecurringDepositAccount) account;
|
final RecurringDepositAccount rd = (RecurringDepositAccount) account;
|
||||||
accountData = RecurringDepositAccountData.preClosureDetails(account.getId(),
|
accountData = RecurringDepositAccountData.preClosureDetails(account.getId(),
|
||||||
rd.calculatePreMatureAmount(interestCalculatedToDate, isPreMatureClosure), onAccountClosureOptions, paymentTypeOptions,
|
rd.calculatePreMatureAmount(interestCalculatedToDate, isPreMatureClosure,
|
||||||
savingsAccountDatas);
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth),
|
||||||
|
onAccountClosureOptions, paymentTypeOptions, savingsAccountDatas);
|
||||||
}
|
}
|
||||||
|
|
||||||
return accountData;
|
return accountData;
|
||||||
|
|||||||
+133
-24
@@ -27,6 +27,7 @@ import org.joda.time.LocalDate;
|
|||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService;
|
import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
@@ -121,6 +122,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
private final AccountTransfersWritePlatformService accountTransfersWritePlatformService;
|
private final AccountTransfersWritePlatformService accountTransfersWritePlatformService;
|
||||||
private final DepositAccountReadPlatformService depositAccountReadPlatformService;
|
private final DepositAccountReadPlatformService depositAccountReadPlatformService;
|
||||||
private final CalendarInstanceRepository calendarInstanceRepository;
|
private final CalendarInstanceRepository calendarInstanceRepository;
|
||||||
|
private final ConfigurationDomainService configurationDomainService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DepositAccountWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
public DepositAccountWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||||
@@ -140,7 +142,8 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
final AccountAssociationsReadPlatformService accountAssociationsReadPlatformService,
|
final AccountAssociationsReadPlatformService accountAssociationsReadPlatformService,
|
||||||
final AccountTransfersWritePlatformService accountTransfersWritePlatformService,
|
final AccountTransfersWritePlatformService accountTransfersWritePlatformService,
|
||||||
final DepositAccountReadPlatformService depositAccountReadPlatformService,
|
final DepositAccountReadPlatformService depositAccountReadPlatformService,
|
||||||
final CalendarInstanceRepository calendarInstanceRepository) {
|
final CalendarInstanceRepository calendarInstanceRepository,
|
||||||
|
final ConfigurationDomainService configurationDomainService) {
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.savingAccountRepository = savingAccountRepository;
|
this.savingAccountRepository = savingAccountRepository;
|
||||||
@@ -162,6 +165,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
this.accountTransfersWritePlatformService = accountTransfersWritePlatformService;
|
this.accountTransfersWritePlatformService = accountTransfersWritePlatformService;
|
||||||
this.depositAccountReadPlatformService = depositAccountReadPlatformService;
|
this.depositAccountReadPlatformService = depositAccountReadPlatformService;
|
||||||
this.calendarInstanceRepository = calendarInstanceRepository;
|
this.calendarInstanceRepository = calendarInstanceRepository;
|
||||||
|
this.configurationDomainService = configurationDomainService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -170,6 +174,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
|
|
||||||
final AppUser user = this.context.authenticatedUser();
|
final AppUser user = this.context.authenticatedUser();
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
this.depositAccountTransactionDataValidator.validateActivation(command);
|
this.depositAccountTransactionDataValidator.validateActivation(command);
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
final FixedDepositAccount account = (FixedDepositAccount) this.depositAccountAssembler.assembleFrom(savingsId,
|
final FixedDepositAccount account = (FixedDepositAccount) this.depositAccountAssembler.assembleFrom(savingsId,
|
||||||
@@ -208,17 +217,20 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
final boolean isInterestTransfer = false;
|
final boolean isInterestTransfer = false;
|
||||||
if (account.isBeforeLastPostingPeriod(account.getActivationLocalDate())) {
|
if (account.isBeforeLastPostingPeriod(account.getActivationLocalDate())) {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean isPreMatureClosure = false;
|
final boolean isPreMatureClosure = false;
|
||||||
account.updateMaturityDateAndAmount(mc, isPreMatureClosure);
|
account.updateMaturityDateAndAmount(mc, isPreMatureClosure, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name());
|
account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name());
|
||||||
this.savingAccountRepository.save(account);
|
this.savingAccountRepository.save(account);
|
||||||
}
|
}
|
||||||
@@ -242,6 +254,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
|
|
||||||
final AppUser user = this.context.authenticatedUser();
|
final AppUser user = this.context.authenticatedUser();
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
this.depositAccountTransactionDataValidator.validateActivation(command);
|
this.depositAccountTransactionDataValidator.validateActivation(command);
|
||||||
|
|
||||||
final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(savingsId,
|
final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(savingsId,
|
||||||
@@ -290,7 +307,9 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
Integer frequency = CalendarUtils.getInterval(calendar.getRecurrence());
|
Integer frequency = CalendarUtils.getInterval(calendar.getRecurrence());
|
||||||
frequency = frequency == -1 ? 1 : frequency;
|
frequency = frequency == -1 ? 1 : frequency;
|
||||||
account.generateSchedule(frequencyType, frequency, calendar);
|
account.generateSchedule(frequencyType, frequency, calendar);
|
||||||
account.updateMaturityDateAndAmount(mc, isPreMatureClosure);
|
account.updateMaturityDateAndAmount(mc, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
final LocalDate overdueUptoDate = account.maturityDate().isAfter(DateUtils.getLocalDateOfTenant()) ? DateUtils
|
final LocalDate overdueUptoDate = account.maturityDate().isAfter(DateUtils.getLocalDateOfTenant()) ? DateUtils
|
||||||
@@ -299,10 +318,14 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
final boolean isInterestTransfer = false;
|
final boolean isInterestTransfer = false;
|
||||||
if (account.isBeforeLastPostingPeriod(account.getActivationLocalDate())) {
|
if (account.isBeforeLastPostingPeriod(account.getActivationLocalDate())) {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name());
|
account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name());
|
||||||
@@ -407,6 +430,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult calculateInterest(final Long savingsId, final DepositAccountType depositAccountType) {
|
public CommandProcessingResult calculateInterest(final Long savingsId, final DepositAccountType depositAccountType) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccount account = this.depositAccountAssembler.assembleFrom(savingsId, depositAccountType);
|
final SavingsAccount account = this.depositAccountAssembler.assembleFrom(savingsId, depositAccountType);
|
||||||
checkClientOrGroupActive(account);
|
checkClientOrGroupActive(account);
|
||||||
|
|
||||||
@@ -414,7 +442,9 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
final MathContext mc = new MathContext(15, RoundingMode.HALF_EVEN);
|
final MathContext mc = new MathContext(15, RoundingMode.HALF_EVEN);
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
|
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
this.savingAccountRepository.save(account);
|
this.savingAccountRepository.save(account);
|
||||||
|
|
||||||
@@ -445,13 +475,21 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
private void postInterest(final SavingsAccount account) {
|
private void postInterest(final SavingsAccount account) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
||||||
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
final MathContext mc = new MathContext(10, RoundingMode.HALF_EVEN);
|
final MathContext mc = new MathContext(10, RoundingMode.HALF_EVEN);
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
this.savingAccountRepository.save(account);
|
this.savingAccountRepository.save(account);
|
||||||
|
|
||||||
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
|
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
|
||||||
@@ -488,6 +526,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
public CommandProcessingResult undoRDTransaction(final Long savingsId, final Long transactionId,
|
public CommandProcessingResult undoRDTransaction(final Long savingsId, final Long transactionId,
|
||||||
final boolean allowAccountTransferModification) {
|
final boolean allowAccountTransferModification) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(savingsId,
|
final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(savingsId,
|
||||||
DepositAccountType.RECURRING_DEPOSIT);
|
DepositAccountType.RECURRING_DEPOSIT);
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
@@ -514,14 +557,20 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
checkClientOrGroupActive(account);
|
checkClientOrGroupActive(account);
|
||||||
if (savingsAccountTransaction.isPostInterestCalculationRequired()
|
if (savingsAccountTransaction.isPostInterestCalculationRequired()
|
||||||
&& account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
|
&& account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.undoTransactionAction);
|
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.undoTransactionAction);
|
||||||
// account.activateAccountBasedOnBalance();
|
// account.activateAccountBasedOnBalance();
|
||||||
final boolean isPreMatureClosure = false;
|
final boolean isPreMatureClosure = false;
|
||||||
account.updateMaturityDateAndAmount(mc, isPreMatureClosure);
|
account.updateMaturityDateAndAmount(mc, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
final LocalDate overdueUptoDate = account.maturityDate().isAfter(DateUtils.getLocalDateOfTenant()) ? DateUtils
|
final LocalDate overdueUptoDate = account.maturityDate().isAfter(DateUtils.getLocalDateOfTenant()) ? DateUtils
|
||||||
.getLocalDateOfTenant() : account.maturityDate();
|
.getLocalDateOfTenant() : account.maturityDate();
|
||||||
@@ -553,6 +602,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult adjustRDTransaction(final Long savingsId, final Long transactionId, final JsonCommand command) {
|
public CommandProcessingResult adjustRDTransaction(final Long savingsId, final Long transactionId, final JsonCommand command) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
this.depositAccountTransactionDataValidator.validate(command, DepositAccountType.RECURRING_DEPOSIT);
|
this.depositAccountTransactionDataValidator.validate(command, DepositAccountType.RECURRING_DEPOSIT);
|
||||||
|
|
||||||
final SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountTransactionRepository
|
final SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountTransactionRepository
|
||||||
@@ -601,9 +655,13 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
if (account.isBeforeLastPostingPeriod(transactionDate)
|
if (account.isBeforeLastPostingPeriod(transactionDate)
|
||||||
|| account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
|
|| account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.adjustTransactionAction);
|
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.adjustTransactionAction);
|
||||||
@@ -788,6 +846,12 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
@Override
|
@Override
|
||||||
public SavingsAccountTransaction initiateSavingsTransfer(final Long accountId, final LocalDate transferDate,
|
public SavingsAccountTransaction initiateSavingsTransfer(final Long accountId, final LocalDate transferDate,
|
||||||
final DepositAccountType depositAccountType) {
|
final DepositAccountType depositAccountType) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
|
final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
|
||||||
|
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
@@ -800,7 +864,9 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
savingsAccount.setStatus(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue());
|
savingsAccount.setStatus(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue());
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer);
|
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
this.savingsAccountTransactionRepository.save(newTransferTransaction);
|
this.savingsAccountTransactionRepository.save(newTransferTransaction);
|
||||||
this.savingAccountRepository.save(savingsAccount);
|
this.savingAccountRepository.save(savingsAccount);
|
||||||
@@ -813,6 +879,12 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
@Override
|
@Override
|
||||||
public SavingsAccountTransaction withdrawSavingsTransfer(final Long accountId, final LocalDate transferDate,
|
public SavingsAccountTransaction withdrawSavingsTransfer(final Long accountId, final LocalDate transferDate,
|
||||||
final DepositAccountType depositAccountType) {
|
final DepositAccountType depositAccountType) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
|
final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
|
||||||
|
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
@@ -825,7 +897,9 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer);
|
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
this.savingsAccountTransactionRepository.save(withdrawtransferTransaction);
|
this.savingsAccountTransactionRepository.save(withdrawtransferTransaction);
|
||||||
this.savingAccountRepository.save(savingsAccount);
|
this.savingAccountRepository.save(savingsAccount);
|
||||||
@@ -845,7 +919,13 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
@Override
|
@Override
|
||||||
public SavingsAccountTransaction acceptSavingsTransfer(final Long accountId, final LocalDate transferDate,
|
public SavingsAccountTransaction acceptSavingsTransfer(final Long accountId, final LocalDate transferDate,
|
||||||
final Office acceptedInOffice, final Staff fieldOfficer, final DepositAccountType depositAccountType) {
|
final Office acceptedInOffice, final Staff fieldOfficer, final DepositAccountType depositAccountType) {
|
||||||
final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
|
final SavingsAccount savingsAccount = this.depositAccountAssembler.assembleFrom(accountId, depositAccountType);
|
||||||
|
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
||||||
@@ -860,7 +940,9 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
}
|
}
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer);
|
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
this.savingsAccountTransactionRepository.save(acceptTransferTransaction);
|
this.savingsAccountTransactionRepository.save(acceptTransferTransaction);
|
||||||
this.savingAccountRepository.save(savingsAccount);
|
this.savingAccountRepository.save(savingsAccount);
|
||||||
@@ -986,6 +1068,11 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(
|
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(
|
||||||
savingsAccountChargeId, savingsAccountId);
|
savingsAccountChargeId, savingsAccountId);
|
||||||
|
|
||||||
@@ -1002,10 +1089,14 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
if (account.isBeforeLastPostingPeriod(savingsAccountCharge.getDueLocalDate())) {
|
if (account.isBeforeLastPostingPeriod(savingsAccountCharge.getDueLocalDate())) {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.waiveChargeTransactionAction);
|
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.waiveChargeTransactionAction);
|
||||||
@@ -1109,6 +1200,12 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
@Transactional
|
@Transactional
|
||||||
private void payCharge(final SavingsAccountCharge savingsAccountCharge, final LocalDate transactionDate, final BigDecimal amountPaid,
|
private void payCharge(final SavingsAccountCharge savingsAccountCharge, final LocalDate transactionDate, final BigDecimal amountPaid,
|
||||||
final DateTimeFormatter formatter) {
|
final DateTimeFormatter formatter) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
// Get Savings account from savings charge
|
// Get Savings account from savings charge
|
||||||
final SavingsAccount account = savingsAccountCharge.savingsAccount();
|
final SavingsAccount account = savingsAccountCharge.savingsAccount();
|
||||||
this.depositAccountAssembler.assignSavingAccountHelpers(account);
|
this.depositAccountAssembler.assignSavingAccountHelpers(account);
|
||||||
@@ -1120,10 +1217,14 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
if (account.isBeforeLastPostingPeriod(transactionDate)) {
|
if (account.isBeforeLastPostingPeriod(transactionDate)) {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative("." + SavingsAccountTransactionType.PAY_CHARGE.getCode());
|
account.validateAccountBalanceDoesNotBecomeNegative("." + SavingsAccountTransactionType.PAY_CHARGE.getCode());
|
||||||
@@ -1136,15 +1237,23 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void updateMaturityDetails(Long depositAccountId, DepositAccountType depositAccountType) {
|
public void updateMaturityDetails(Long depositAccountId, DepositAccountType depositAccountType) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccount account = this.depositAccountAssembler.assembleFrom(depositAccountId, depositAccountType);
|
final SavingsAccount account = this.depositAccountAssembler.assembleFrom(depositAccountId, depositAccountType);
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
||||||
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
||||||
|
|
||||||
if (depositAccountType.isFixedDeposit()) {
|
if (depositAccountType.isFixedDeposit()) {
|
||||||
((FixedDepositAccount) account).updateMaturityStatus();
|
((FixedDepositAccount) account).updateMaturityStatus(isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else if (depositAccountType.isRecurringDeposit()) {
|
} else if (depositAccountType.isRecurringDeposit()) {
|
||||||
((RecurringDepositAccount) account).updateMaturityStatus();
|
((RecurringDepositAccount) account).updateMaturityStatus(isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
|
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
|
||||||
|
|||||||
+34
-5
@@ -19,6 +19,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
@@ -100,6 +101,7 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
private final AccountAssociationsRepository accountAssociationsRepository;
|
private final AccountAssociationsRepository accountAssociationsRepository;
|
||||||
private final FromJsonHelper fromJsonHelper;
|
private final FromJsonHelper fromJsonHelper;
|
||||||
private final CalendarInstanceRepository calendarInstanceRepository;
|
private final CalendarInstanceRepository calendarInstanceRepository;
|
||||||
|
private final ConfigurationDomainService configurationDomainService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
public DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||||
@@ -113,7 +115,8 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
final FixedDepositAccountRepository fixedDepositAccountRepository,
|
final FixedDepositAccountRepository fixedDepositAccountRepository,
|
||||||
final RecurringDepositAccountRepository recurringDepositAccountRepository,
|
final RecurringDepositAccountRepository recurringDepositAccountRepository,
|
||||||
final AccountAssociationsRepository accountAssociationsRepository, final FromJsonHelper fromJsonHelper,
|
final AccountAssociationsRepository accountAssociationsRepository, final FromJsonHelper fromJsonHelper,
|
||||||
final CalendarInstanceRepository calendarInstanceRepository) {
|
final CalendarInstanceRepository calendarInstanceRepository,
|
||||||
|
final ConfigurationDomainService configurationDomainService) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.savingAccountRepository = savingAccountRepository;
|
this.savingAccountRepository = savingAccountRepository;
|
||||||
this.depositAccountAssembler = depositAccountAssembler;
|
this.depositAccountAssembler = depositAccountAssembler;
|
||||||
@@ -131,6 +134,7 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
this.accountAssociationsRepository = accountAssociationsRepository;
|
this.accountAssociationsRepository = accountAssociationsRepository;
|
||||||
this.fromJsonHelper = fromJsonHelper;
|
this.fromJsonHelper = fromJsonHelper;
|
||||||
this.calendarInstanceRepository = calendarInstanceRepository;
|
this.calendarInstanceRepository = calendarInstanceRepository;
|
||||||
|
this.configurationDomainService = configurationDomainService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -168,13 +172,19 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
this.depositAccountDataValidator.validateFixedDepositForSubmit(command.json());
|
this.depositAccountDataValidator.validateFixedDepositForSubmit(command.json());
|
||||||
final AppUser submittedBy = this.context.authenticatedUser();
|
final AppUser submittedBy = this.context.authenticatedUser();
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final FixedDepositAccount account = (FixedDepositAccount) this.depositAccountAssembler.assembleFrom(command, submittedBy,
|
final FixedDepositAccount account = (FixedDepositAccount) this.depositAccountAssembler.assembleFrom(command, submittedBy,
|
||||||
DepositAccountType.FIXED_DEPOSIT);
|
DepositAccountType.FIXED_DEPOSIT);
|
||||||
|
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
final boolean isPreMatureClosure = false;
|
final boolean isPreMatureClosure = false;
|
||||||
|
|
||||||
account.updateMaturityDateAndAmountBeforeAccountActivation(mc, isPreMatureClosure);
|
account.updateMaturityDateAndAmountBeforeAccountActivation(mc, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
this.fixedDepositAccountRepository.save(account);
|
this.fixedDepositAccountRepository.save(account);
|
||||||
|
|
||||||
if (account.isAccountNumberRequiresAutoGeneration()) {
|
if (account.isAccountNumberRequiresAutoGeneration()) {
|
||||||
@@ -218,6 +228,11 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
this.depositAccountDataValidator.validateRecurringDepositForSubmit(command.json());
|
this.depositAccountDataValidator.validateRecurringDepositForSubmit(command.json());
|
||||||
final AppUser submittedBy = this.context.authenticatedUser();
|
final AppUser submittedBy = this.context.authenticatedUser();
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(command,
|
final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(command,
|
||||||
submittedBy, DepositAccountType.RECURRING_DEPOSIT);
|
submittedBy, DepositAccountType.RECURRING_DEPOSIT);
|
||||||
|
|
||||||
@@ -242,7 +257,8 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
frequency = frequency == -1 ? 1 : frequency;
|
frequency = frequency == -1 ? 1 : frequency;
|
||||||
account.generateSchedule(frequencyType, frequency, calendar);
|
account.generateSchedule(frequencyType, frequency, calendar);
|
||||||
final boolean isPreMatureClosure = false;
|
final boolean isPreMatureClosure = false;
|
||||||
account.updateMaturityDateAndAmount(mc, isPreMatureClosure);
|
account.updateMaturityDateAndAmount(mc, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
account.validateApplicableInterestRate();
|
account.validateApplicableInterestRate();
|
||||||
this.savingAccountRepository.save(account);
|
this.savingAccountRepository.save(account);
|
||||||
|
|
||||||
@@ -319,6 +335,11 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
try {
|
try {
|
||||||
this.depositAccountDataValidator.validateFixedDepositForUpdate(command.json());
|
this.depositAccountDataValidator.validateFixedDepositForUpdate(command.json());
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final Map<String, Object> changes = new LinkedHashMap<>(20);
|
final Map<String, Object> changes = new LinkedHashMap<>(20);
|
||||||
|
|
||||||
final FixedDepositAccount account = (FixedDepositAccount) this.depositAccountAssembler.assembleFrom(accountId,
|
final FixedDepositAccount account = (FixedDepositAccount) this.depositAccountAssembler.assembleFrom(accountId,
|
||||||
@@ -331,7 +352,8 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
updateFDAndRDCommonChanges(changes, command, account);
|
updateFDAndRDCommonChanges(changes, command, account);
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
final boolean isPreMatureClosure = false;
|
final boolean isPreMatureClosure = false;
|
||||||
account.updateMaturityDateAndAmountBeforeAccountActivation(mc, isPreMatureClosure);
|
account.updateMaturityDateAndAmountBeforeAccountActivation(mc, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd, financialYearBeginningMonth);
|
||||||
this.savingAccountRepository.save(account);
|
this.savingAccountRepository.save(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,6 +378,11 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
try {
|
try {
|
||||||
this.depositAccountDataValidator.validateRecurringDepositForUpdate(command.json());
|
this.depositAccountDataValidator.validateRecurringDepositForUpdate(command.json());
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final Map<String, Object> changes = new LinkedHashMap<>(20);
|
final Map<String, Object> changes = new LinkedHashMap<>(20);
|
||||||
|
|
||||||
final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(accountId,
|
final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(accountId,
|
||||||
@@ -375,7 +402,9 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
frequency = frequency == -1 ? 1 : frequency;
|
frequency = frequency == -1 ? 1 : frequency;
|
||||||
account.generateSchedule(frequencyType, frequency, calendar);
|
account.generateSchedule(frequencyType, frequency, calendar);
|
||||||
final boolean isPreMatureClosure = false;
|
final boolean isPreMatureClosure = false;
|
||||||
account.updateMaturityDateAndAmount(mc, isPreMatureClosure);
|
account.updateMaturityDateAndAmount(mc, isPreMatureClosure,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
account.validateApplicableInterestRate();
|
account.validateApplicableInterestRate();
|
||||||
this.savingAccountRepository.save(account);
|
this.savingAccountRepository.save(account);
|
||||||
|
|
||||||
|
|||||||
+97
-15
@@ -28,6 +28,7 @@ import org.joda.time.LocalDate;
|
|||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService;
|
import org.mifosplatform.accounting.journalentry.service.JournalEntryWritePlatformService;
|
||||||
|
import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
@@ -113,6 +114,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
private final SavingsAccountChargeRepositoryWrapper savingsAccountChargeRepository;
|
private final SavingsAccountChargeRepositoryWrapper savingsAccountChargeRepository;
|
||||||
private final HolidayWritePlatformService holidayWritePlatformService;
|
private final HolidayWritePlatformService holidayWritePlatformService;
|
||||||
private final WorkingDaysWritePlatformService workingDaysWritePlatformService;
|
private final WorkingDaysWritePlatformService workingDaysWritePlatformService;
|
||||||
|
private final ConfigurationDomainService configurationDomainService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public SavingsAccountWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
public SavingsAccountWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||||
@@ -131,7 +133,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
final HolidayWritePlatformService holidayWritePlatformService,
|
final HolidayWritePlatformService holidayWritePlatformService,
|
||||||
final WorkingDaysWritePlatformService workingDaysWritePlatformService,
|
final WorkingDaysWritePlatformService workingDaysWritePlatformService,
|
||||||
final SavingsAccountDataValidator fromApiJsonDeserializer, final SavingsAccountRepositoryWrapper savingsRepository,
|
final SavingsAccountDataValidator fromApiJsonDeserializer, final SavingsAccountRepositoryWrapper savingsRepository,
|
||||||
final StaffRepositoryWrapper staffRepository) {
|
final StaffRepositoryWrapper staffRepository,
|
||||||
|
final ConfigurationDomainService configurationDomainService) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.savingAccountRepository = savingAccountRepository;
|
this.savingAccountRepository = savingAccountRepository;
|
||||||
this.savingsAccountTransactionRepository = savingsAccountTransactionRepository;
|
this.savingsAccountTransactionRepository = savingsAccountTransactionRepository;
|
||||||
@@ -152,6 +155,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||||
this.savingsRepository = savingsRepository;
|
this.savingsRepository = savingsRepository;
|
||||||
this.staffRepository = staffRepository;
|
this.staffRepository = staffRepository;
|
||||||
|
this.configurationDomainService = configurationDomainService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@@ -192,6 +196,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
@Override
|
@Override
|
||||||
public void processPostActiveActions(final SavingsAccount account, final DateTimeFormatter fmt, final Set<Long> existingTransactionIds,
|
public void processPostActiveActions(final SavingsAccount account, final DateTimeFormatter fmt, final Set<Long> existingTransactionIds,
|
||||||
final Set<Long> existingReversedTransactionIds) {
|
final Set<Long> existingReversedTransactionIds) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
Money amountForDeposit = account.activateWithBalance();
|
Money amountForDeposit = account.activateWithBalance();
|
||||||
boolean isRegularTransaction = false;
|
boolean isRegularTransaction = false;
|
||||||
if (amountForDeposit.isGreaterThanZero()) {
|
if (amountForDeposit.isGreaterThanZero()) {
|
||||||
@@ -200,7 +210,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
null, isAccountTransfer, isRegularTransaction);
|
null, isAccountTransfer, isRegularTransaction);
|
||||||
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
||||||
}
|
}
|
||||||
account.processAccountUponActivation();
|
account.processAccountUponActivation(isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name());
|
account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,13 +316,20 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult calculateInterest(final Long savingsId) {
|
public CommandProcessingResult calculateInterest(final Long savingsId) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
|
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
|
||||||
checkClientOrGroupActive(account);
|
checkClientOrGroupActive(account);
|
||||||
|
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
final MathContext mc = new MathContext(15, RoundingMode.HALF_EVEN);
|
final MathContext mc = new MathContext(15, RoundingMode.HALF_EVEN);
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
this.savingAccountRepository.save(account);
|
this.savingAccountRepository.save(account);
|
||||||
|
|
||||||
@@ -342,6 +360,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
private void postInterest(final SavingsAccount account) {
|
private void postInterest(final SavingsAccount account) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
if (account.getNominalAnnualInterestRate().compareTo(BigDecimal.ZERO) == 1) {
|
if (account.getNominalAnnualInterestRate().compareTo(BigDecimal.ZERO) == 1) {
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
||||||
@@ -349,7 +373,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
final MathContext mc = new MathContext(10, RoundingMode.HALF_EVEN);
|
final MathContext mc = new MathContext(10, RoundingMode.HALF_EVEN);
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
// for generating transaction id's
|
// for generating transaction id's
|
||||||
List<SavingsAccountTransaction> transactions = account.getTransactions();
|
List<SavingsAccountTransaction> transactions = account.getTransactions();
|
||||||
@@ -380,6 +405,11 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
public CommandProcessingResult undoTransaction(final Long savingsId, final Long transactionId,
|
public CommandProcessingResult undoTransaction(final Long savingsId, final Long transactionId,
|
||||||
final boolean allowAccountTransferModification) {
|
final boolean allowAccountTransferModification) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
|
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
final Set<Long> existingReversedTransactionIds = new HashSet<>();
|
||||||
@@ -419,9 +449,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
checkClientOrGroupActive(account);
|
checkClientOrGroupActive(account);
|
||||||
if (savingsAccountTransaction.isPostInterestCalculationRequired()
|
if (savingsAccountTransaction.isPostInterestCalculationRequired()
|
||||||
&& account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
|
&& account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.undoTransactionAction);
|
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.undoTransactionAction);
|
||||||
account.activateAccountBasedOnBalance();
|
account.activateAccountBasedOnBalance();
|
||||||
@@ -439,6 +472,11 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult adjustSavingsTransaction(final Long savingsId, final Long transactionId, final JsonCommand command) {
|
public CommandProcessingResult adjustSavingsTransaction(final Long savingsId, final Long transactionId, final JsonCommand command) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountTransactionRepository
|
final SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountTransactionRepository
|
||||||
.findOneByIdAndSavingsAccountId(transactionId, savingsId);
|
.findOneByIdAndSavingsAccountId(transactionId, savingsId);
|
||||||
if (savingsAccountTransaction == null) { throw new SavingsAccountTransactionNotFoundException(savingsId, transactionId); }
|
if (savingsAccountTransaction == null) { throw new SavingsAccountTransactionNotFoundException(savingsId, transactionId); }
|
||||||
@@ -495,9 +533,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
if (account.isBeforeLastPostingPeriod(transactionDate)
|
if (account.isBeforeLastPostingPeriod(transactionDate)
|
||||||
|| account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
|
|| account.isBeforeLastPostingPeriod(savingsAccountTransaction.transactionLocalDate())) {
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.adjustTransactionAction);
|
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.adjustTransactionAction);
|
||||||
account.activateAccountBasedOnBalance();
|
account.activateAccountBasedOnBalance();
|
||||||
@@ -597,6 +638,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SavingsAccountTransaction initiateSavingsTransfer(final Long accountId, final LocalDate transferDate) {
|
public SavingsAccountTransaction initiateSavingsTransfer(final Long accountId, final LocalDate transferDate) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(accountId);
|
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(accountId);
|
||||||
|
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
@@ -609,7 +656,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
savingsAccount.setStatus(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue());
|
savingsAccount.setStatus(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue());
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer);
|
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
this.savingsAccountTransactionRepository.save(newTransferTransaction);
|
this.savingsAccountTransactionRepository.save(newTransferTransaction);
|
||||||
this.savingAccountRepository.save(savingsAccount);
|
this.savingAccountRepository.save(savingsAccount);
|
||||||
@@ -621,6 +670,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SavingsAccountTransaction withdrawSavingsTransfer(final Long accountId, final LocalDate transferDate) {
|
public SavingsAccountTransaction withdrawSavingsTransfer(final Long accountId, final LocalDate transferDate) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(accountId);
|
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(accountId);
|
||||||
|
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
@@ -633,7 +688,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer);
|
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
this.savingsAccountTransactionRepository.save(withdrawtransferTransaction);
|
this.savingsAccountTransactionRepository.save(withdrawtransferTransaction);
|
||||||
this.savingAccountRepository.save(savingsAccount);
|
this.savingAccountRepository.save(savingsAccount);
|
||||||
@@ -653,6 +710,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
@Override
|
@Override
|
||||||
public SavingsAccountTransaction acceptSavingsTransfer(final Long accountId, final LocalDate transferDate,
|
public SavingsAccountTransaction acceptSavingsTransfer(final Long accountId, final LocalDate transferDate,
|
||||||
final Office acceptedInOffice, final Staff fieldOfficer) {
|
final Office acceptedInOffice, final Staff fieldOfficer) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(accountId);
|
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(accountId);
|
||||||
|
|
||||||
final Set<Long> existingTransactionIds = new HashSet<>();
|
final Set<Long> existingTransactionIds = new HashSet<>();
|
||||||
@@ -668,7 +731,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
}
|
}
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer);
|
savingsAccount.calculateInterestUsing(mc, transferDate, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
|
|
||||||
this.savingsAccountTransactionRepository.save(acceptTransferTransaction);
|
this.savingsAccountTransactionRepository.save(acceptTransferTransaction);
|
||||||
this.savingAccountRepository.save(savingsAccount);
|
this.savingAccountRepository.save(savingsAccount);
|
||||||
@@ -793,6 +858,11 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(
|
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(
|
||||||
savingsAccountChargeId, savingsAccountId);
|
savingsAccountChargeId, savingsAccountId);
|
||||||
|
|
||||||
@@ -809,10 +879,13 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
if (account.isBeforeLastPostingPeriod(savingsAccountCharge.getDueLocalDate())) {
|
if (account.isBeforeLastPostingPeriod(savingsAccountCharge.getDueLocalDate())) {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.waiveChargeTransactionAction);
|
account.validateAccountBalanceDoesNotBecomeNegative(SavingsApiConstants.waiveChargeTransactionAction);
|
||||||
@@ -914,6 +987,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
@Transactional
|
@Transactional
|
||||||
private void payCharge(final SavingsAccountCharge savingsAccountCharge, final LocalDate transactionDate, final BigDecimal amountPaid,
|
private void payCharge(final SavingsAccountCharge savingsAccountCharge, final LocalDate transactionDate, final BigDecimal amountPaid,
|
||||||
final DateTimeFormatter formatter) {
|
final DateTimeFormatter formatter) {
|
||||||
|
|
||||||
|
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||||
|
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||||
|
final Integer financialYearBeginningMonth = this.configurationDomainService
|
||||||
|
.retrieveFinancialYearBeginningMonth();
|
||||||
|
|
||||||
// Get Savings account from savings charge
|
// Get Savings account from savings charge
|
||||||
final SavingsAccount account = savingsAccountCharge.savingsAccount();
|
final SavingsAccount account = savingsAccountCharge.savingsAccount();
|
||||||
this.savingAccountAssembler.assignSavingAccountHelpers(account);
|
this.savingAccountAssembler.assignSavingAccountHelpers(account);
|
||||||
@@ -925,10 +1004,13 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
if (account.isBeforeLastPostingPeriod(transactionDate)) {
|
if (account.isBeforeLastPostingPeriod(transactionDate)) {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.postInterest(mc, today, isInterestTransfer);
|
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
} else {
|
} else {
|
||||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||||
account.calculateInterestUsing(mc, today, isInterestTransfer);
|
account.calculateInterestUsing(mc, today, isInterestTransfer,
|
||||||
|
isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||||
|
financialYearBeginningMonth);
|
||||||
}
|
}
|
||||||
|
|
||||||
account.validateAccountBalanceDoesNotBecomeNegative("." + SavingsAccountTransactionType.PAY_CHARGE.getCode());
|
account.validateAccountBalanceDoesNotBecomeNegative("." + SavingsAccountTransactionType.PAY_CHARGE.getCode());
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
ALTER TABLE c_configuration ADD `description` varchar(300) DEFAULT NULL;
|
||||||
|
|
||||||
|
INSERT INTO `c_configuration` (`id`, `name`, `enabled`, `description`)
|
||||||
|
VALUES (NULL, 'savings-interest-posting-current-period-end', '0', "Recommended to be changed only once during start of production. When set as false(default), interest will be posted on the first date of next period. If set as true, interest will be posted on last date of current period. There is no difference in the interest amount posted.");
|
||||||
|
|
||||||
|
INSERT INTO `c_configuration` (`id`, `name`, `value`, `enabled`, `description`)
|
||||||
|
VALUES (NULL, 'financial-year-beginning-month', '1', '1', "Recommended to be changed only once during start of production. Allowed values 1 - 12 (January - December). Interest posting periods are evaluated based on this configuration.");
|
||||||
Reference in New Issue
Block a user