324 , 325
This commit is contained in:
+14
-2
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.apache.fineract.portfolio.savings.api;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@@ -175,16 +176,27 @@ public class FixedDepositAccountsApiResource {
|
||||
|
||||
final FixedDepositAccountData account = (FixedDepositAccountData) this.depositAccountReadPlatformService.retrieveOneWithChartSlabs(
|
||||
DepositAccountType.FIXED_DEPOSIT, accountId);
|
||||
|
||||
|
||||
final Set<String> mandatoryResponseParameters = new HashSet<>();
|
||||
final FixedDepositAccountData accountTemplate = populateTemplateAndAssociations(accountId, account, staffInSelectedOfficeOnly,
|
||||
chargeStatus, uriInfo, mandatoryResponseParameters);
|
||||
|
||||
accountTemplate.setActivationCharge(getActivationCharge(accountId));
|
||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters(),
|
||||
mandatoryResponseParameters);
|
||||
return this.toApiJsonSerializer.serialize(settings, accountTemplate,
|
||||
DepositsApiConstants.FIXED_DEPOSIT_ACCOUNT_RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
private BigDecimal getActivationCharge(Long accountId){
|
||||
BigDecimal activationCharge = BigDecimal.ZERO;
|
||||
Collection<SavingsAccountChargeData> savingCharges = this.savingsAccountChargeReadPlatformService.retrieveSavingsAccountCharges(accountId, "active");
|
||||
for (SavingsAccountChargeData savingsAccountChargeData : savingCharges) {
|
||||
if(savingsAccountChargeData.isSavingsActivation()){
|
||||
activationCharge = activationCharge.add(savingsAccountChargeData.getAmountOutstanding());
|
||||
}
|
||||
}
|
||||
return activationCharge;
|
||||
}
|
||||
|
||||
private FixedDepositAccountData populateTemplateAndAssociations(final Long accountId, final FixedDepositAccountData savingsAccount,
|
||||
final boolean staffInSelectedOfficeOnly, final String chargeStatus, final UriInfo uriInfo,
|
||||
|
||||
+10
@@ -53,6 +53,7 @@ public class FixedDepositAccountData extends DepositAccountData {
|
||||
private LocalDate maturityDate;
|
||||
private Integer depositPeriod;
|
||||
private EnumOptionData depositPeriodFrequency;
|
||||
private BigDecimal activationCharge;
|
||||
|
||||
// used for account close
|
||||
private EnumOptionData onAccountClosure;
|
||||
@@ -449,4 +450,13 @@ public class FixedDepositAccountData extends DepositAccountData {
|
||||
return new HashCodeBuilder(17, 37).append(this.id).append(this.accountNo).toHashCode();
|
||||
}
|
||||
|
||||
|
||||
public BigDecimal getActivationCharge() {
|
||||
return this.activationCharge;
|
||||
}
|
||||
|
||||
|
||||
public void setActivationCharge(BigDecimal activationCharge) {
|
||||
this.activationCharge = activationCharge;
|
||||
}
|
||||
}
|
||||
+10
@@ -158,4 +158,14 @@ public class SavingsAccountChargeData {
|
||||
public boolean isAnnualFee() {
|
||||
return ChargeTimeType.fromInt(this.chargeTimeType.getId().intValue()).isAnnualFee();
|
||||
}
|
||||
|
||||
public boolean isSavingsActivation() {
|
||||
return ChargeTimeType.fromInt(this.chargeTimeType.getId().intValue()).isSavingsActivation();
|
||||
}
|
||||
|
||||
public BigDecimal getAmountOutstanding() {
|
||||
return this.amountOutstanding;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+26
-6
@@ -208,13 +208,12 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
|
||||
|
||||
final Map<String, Object> changes = account.activate(user, command, DateUtils.getLocalDateOfTenant());
|
||||
|
||||
Money activationChargeAmount = getActivationCharge(account);
|
||||
if (!changes.isEmpty()) {
|
||||
final Locale locale = command.extractLocale();
|
||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
||||
Money amountForDeposit = account.activateWithBalance();
|
||||
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
|
||||
Money amountForDeposit = account.activateWithBalance().plus(activationChargeAmount);
|
||||
if (amountForDeposit.isGreaterThanZero()) {
|
||||
|
||||
final PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService
|
||||
.retriveSavingsLinkedAssociation(savingsId);
|
||||
|
||||
@@ -235,6 +234,9 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
}
|
||||
final boolean isInterestTransfer = false;
|
||||
final LocalDate postInterestOnDate = null;
|
||||
if(activationChargeAmount.isGreaterThanZero()){
|
||||
payActivationCharge(account, user);
|
||||
}
|
||||
if (account.isBeforeLastPostingPeriod(account.getActivationLocalDate())) {
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
|
||||
@@ -259,8 +261,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name(),
|
||||
depositAccountOnHoldTransactions);
|
||||
this.savingAccountRepositoryWrapper.saveAndFlush(account);
|
||||
}
|
||||
|
||||
}
|
||||
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
|
||||
|
||||
return new CommandProcessingResultBuilder() //
|
||||
@@ -273,6 +274,25 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
.build();
|
||||
}
|
||||
|
||||
private Money getActivationCharge(final FixedDepositAccount account) {
|
||||
Money activationChargeAmount = Money.zero(account.getCurrency());
|
||||
for (SavingsAccountCharge savingsAccountCharge : account.charges()) {
|
||||
if (savingsAccountCharge.isSavingsActivation()) {
|
||||
activationChargeAmount = activationChargeAmount.plus(savingsAccountCharge.getAmount(account.getCurrency()));
|
||||
}
|
||||
}
|
||||
return activationChargeAmount;
|
||||
}
|
||||
|
||||
private void payActivationCharge(final FixedDepositAccount account, AppUser user){
|
||||
for (SavingsAccountCharge savingsAccountCharge : account.charges()) {
|
||||
if (savingsAccountCharge.isSavingsActivation()) {
|
||||
account.payCharge(savingsAccountCharge, savingsAccountCharge.getAmount(account.getCurrency()),
|
||||
account.getActivationLocalDate(), user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public CommandProcessingResult activateRDAccount(final Long savingsId, final JsonCommand command) {
|
||||
|
||||
Reference in New Issue
Block a user