Skip to content

Commit a165720

Browse files
committed
FINERACT-2312: Savings Accounts Improvements
1 parent 9c87276 commit a165720

File tree

94 files changed

+2571
-489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+2571
-489
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.fineract.accounting.accrual.handler;
20+
21+
import lombok.RequiredArgsConstructor;
22+
import org.apache.fineract.accounting.accrual.service.AccrualAccountingWritePlatformService;
23+
import org.apache.fineract.commands.annotation.CommandType;
24+
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
25+
import org.apache.fineract.infrastructure.core.api.JsonCommand;
26+
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
27+
import org.springframework.stereotype.Service;
28+
import org.springframework.transaction.annotation.Transactional;
29+
30+
@Service
31+
@CommandType(entity = "PERIODICACCRUALACCOUNTINGFORSAVINGS", action = "EXECUTE")
32+
@RequiredArgsConstructor
33+
public class ExecutePeriodicAccrualForSavingsCommandHandler implements NewCommandSourceHandler {
34+
35+
private final AccrualAccountingWritePlatformService writePlatformService;
36+
37+
@Transactional
38+
@Override
39+
public CommandProcessingResult processCommand(final JsonCommand command) {
40+
return this.writePlatformService.executeLoansPeriodicAccrual(command);
41+
}
42+
}

fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/serialization/ProductToGLAccountMappingFromApiJsonDeserializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ public void validateForSavingsProductCreate(final String json, DepositAccountTyp
169169
Locale.getDefault());
170170
baseDataValidator.reset().parameter(accountingRuleParamName).value(accountingRuleType).notNull().inMinMaxRange(1, 3);
171171

172-
if (AccountingValidations.isCashBasedAccounting(accountingRuleType)) {
172+
if (AccountingValidations.isCashBasedAccounting(accountingRuleType)
173+
|| AccountingValidations.isAccrualBasedAccounting(accountingRuleType)) {
173174

174175
final Long savingsControlAccountId = this.fromApiJsonHelper
175176
.extractLongNamed(SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), element);
@@ -225,7 +226,6 @@ public void validateForSavingsProductCreate(final String json, DepositAccountTyp
225226
baseDataValidator.reset().parameter(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue()).value(writtenOff).notNull()
226227
.integerGreaterThanZero();
227228
}
228-
229229
}
230230

231231
// Periodic Accrual Accounting aditional GL Accounts

fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public void mergeProductToAccountMappingChanges(final JsonElement element, final
100100
optionalProductToGLAccountMappingEntries.add("incomeFromGoodwillCreditInterestAccountId");
101101
optionalProductToGLAccountMappingEntries.add("incomeFromGoodwillCreditFeesAccountId");
102102
optionalProductToGLAccountMappingEntries.add("incomeFromGoodwillCreditPenaltyAccountId");
103+
optionalProductToGLAccountMappingEntries.add("interestReceivableAccountId");
103104
optionalProductToGLAccountMappingEntries.add(LoanProductAccountingParams.DEFERRED_INCOME_LIABILITY.getValue());
104105
optionalProductToGLAccountMappingEntries.add(LoanProductAccountingParams.INCOME_FROM_CAPITALIZATION.getValue());
105106

fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/ProductToGLAccountMappingReadPlatformServiceImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ private Map<String, Object> setAccrualPeriodicSavingsProductToGLAccountMaps(fina
354354
// Assets
355355
if (glAccountForSavings.equals(AccrualAccountsForSavings.SAVINGS_REFERENCE)) {
356356
accountMappingDetails.put(SavingProductAccountingDataParams.SAVINGS_REFERENCE.getValue(), glAccountData);
357+
} else if (glAccountForSavings.equals(AccrualAccountsForSavings.INTEREST_RECEIVABLE)) {
358+
accountMappingDetails.put(SavingProductAccountingDataParams.INTEREST_RECEIVABLE.getValue(), glAccountData);
357359
} else if (glAccountForSavings.equals(AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL)) {
358360
accountMappingDetails.put(SavingProductAccountingDataParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), glAccountData);
359361
} else if (glAccountForSavings.equals(AccrualAccountsForSavings.FEES_RECEIVABLE)) {

fineract-accounting/src/main/java/org/apache/fineract/accounting/producttoaccountmapping/service/SavingsProductToGLAccountMappingHelper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ public void handleChangesToSavingsProductToGLAccountMappings(final Long savingsP
263263
savingsProductId, AccrualAccountsForSavings.FEES_RECEIVABLE.getValue(),
264264
AccrualAccountsForSavings.FEES_RECEIVABLE.toString(), changes);
265265

266-
mergeSavingsToAssetAccountMappingChanges(element, SavingProductAccountingParams.PENALTIES_RECEIVABLE.getValue(),
267-
savingsProductId, AccrualAccountsForSavings.PENALTIES_RECEIVABLE.getValue(),
268-
AccrualAccountsForSavings.PENALTIES_RECEIVABLE.toString(), changes);
266+
mergeSavingsToAssetAccountMappingChanges(element, SavingProductAccountingParams.INTEREST_RECEIVABLE.getValue(),
267+
savingsProductId, AccrualAccountsForSavings.INTEREST_RECEIVABLE.getValue(),
268+
AccrualAccountsForSavings.INTEREST_RECEIVABLE.toString(), changes);
269269

270270
// income
271271
mergeSavingsToIncomeAccountMappingChanges(element, SavingProductAccountingParams.INCOME_FROM_FEES.getValue(),

fineract-charge/src/main/java/org/apache/fineract/portfolio/charge/service/ChargeReadPlatformService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.apache.fineract.portfolio.charge.service;
2020

21+
import java.util.Collection;
2122
import java.util.List;
2223
import org.apache.fineract.portfolio.charge.data.ChargeData;
2324
import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
@@ -112,6 +113,8 @@ public interface ChargeReadPlatformService {
112113
*/
113114
List<ChargeData> retrieveSavingsProductCharges(Long savingsProductId);
114115

116+
Collection<ChargeData> retrieveSavingsProductAccrualCharges(Long savingsProductId);
117+
115118
/** Retrieve savings account charges **/
116119
List<ChargeData> retrieveSavingsAccountApplicableCharges(Long savingsId);
117120

fineract-core/src/main/java/org/apache/fineract/accounting/common/AccountingConstants.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ public enum AccrualAccountsForSavings {
303303
ESCHEAT_LIABILITY(14), //
304304
FEES_RECEIVABLE(15), //
305305
PENALTIES_RECEIVABLE(16), //
306-
INTEREST_PAYABLE(17);
306+
INTEREST_PAYABLE(17), //
307+
INTEREST_RECEIVABLE(18);
307308

308309
private final Integer value;
309310

@@ -357,6 +358,7 @@ public enum SavingProductAccountingParams {
357358
LOSSES_WRITTEN_OFF("writeOffAccountId"), //
358359
ESCHEAT_LIABILITY("escheatLiabilityId"), //
359360
PENALTIES_RECEIVABLE("penaltiesReceivableAccountId"), //
361+
INTEREST_RECEIVABLE("interestReceivableAccountId"), //
360362
FEES_RECEIVABLE("feesReceivableAccountId"), //
361363
INTEREST_PAYABLE("interestPayableAccountId");
362364

@@ -395,7 +397,8 @@ public enum SavingProductAccountingDataParams {
395397
ESCHEAT_LIABILITY("escheatLiabilityAccount"), //
396398
FEES_RECEIVABLE("feeReceivableAccount"), //
397399
PENALTIES_RECEIVABLE("penaltyReceivableAccount"), //
398-
INTEREST_PAYABLE("interestPayableAccount"); //
400+
INTEREST_PAYABLE("interestPayableAccount"), //
401+
INTEREST_RECEIVABLE("interestReceivableAccount"); //
399402

400403
private final String value;
401404

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.fineract.accounting.common;
20+
21+
public class AccountingValidations {
22+
23+
protected AccountingValidations() {}
24+
25+
public static boolean isCashBasedAccounting(final Integer accountingRuleType) {
26+
return AccountingRuleType.CASH_BASED.getValue().equals(accountingRuleType);
27+
}
28+
29+
public static boolean isAccrualPeriodicBasedAccounting(final Integer accountingRuleType) {
30+
return AccountingRuleType.ACCRUAL_PERIODIC.getValue().equals(accountingRuleType);
31+
}
32+
33+
public static boolean isUpfrontAccrualAccounting(final Integer accountingRuleType) {
34+
return AccountingRuleType.ACCRUAL_UPFRONT.getValue().equals(accountingRuleType);
35+
}
36+
37+
public static boolean isAccrualBasedAccounting(final Integer accountingRuleType) {
38+
return AccountingRuleType.ACCRUAL_PERIODIC.getValue().equals(accountingRuleType)
39+
|| AccountingRuleType.ACCRUAL_UPFRONT.getValue().equals(accountingRuleType);
40+
}
41+
42+
public static boolean isCashOrAccrualBasedAccounting(final Integer accountingRuleType) {
43+
return isCashBasedAccounting(accountingRuleType) || isAccrualBasedAccounting(accountingRuleType);
44+
}
45+
}

fineract-core/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,14 @@ public CommandWrapperBuilder createAccountTransfer() {
15431543
return this;
15441544
}
15451545

1546+
public CommandWrapperBuilder adjustAccountTransfer(final Long accountTransferId) {
1547+
this.actionName = "ADJUST";
1548+
this.entityName = "ACCOUNTTRANSFER";
1549+
this.entityId = accountTransferId;
1550+
this.href = "/accounttransfers";
1551+
return this;
1552+
}
1553+
15461554
public CommandWrapperBuilder createStandingInstruction() {
15471555
this.actionName = "CREATE";
15481556
this.entityName = "STANDINGINSTRUCTION";
@@ -3416,6 +3424,15 @@ public CommandWrapperBuilder unblockSavingsAccount(final Long accountId) {
34163424
return this;
34173425
}
34183426

3427+
public CommandWrapperBuilder addAccrualsToSavingsAccount(final Long accountId) {
3428+
this.actionName = "ADD_ACCRUALS";
3429+
this.entityName = "SAVINGSACCOUNT";
3430+
this.savingsId = accountId;
3431+
this.entityId = null;
3432+
this.href = "/savingsaccounts/" + accountId + "?command=addAccrualTransactions";
3433+
return this;
3434+
}
3435+
34193436
public CommandWrapperBuilder disableAdHoc(Long adHocId) {
34203437
this.actionName = "DISABLE";
34213438
this.entityName = "ADHOC";

fineract-core/src/main/java/org/apache/fineract/infrastructure/jobs/service/JobName.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public enum JobName {
5858
PURGE_EXTERNAL_EVENTS("Purge External Events"), //
5959
PURGE_PROCESSED_COMMANDS("Purge Processed Commands"), //
6060
ACCRUAL_ACTIVITY_POSTING("Accrual Activity Posting"), //
61-
;
61+
ADD_PERIODIC_ACCRUAL_ENTRIES_FOR_SAVINGS_WITH_INCOME_POSTED_AS_TRANSACTIONS("Add Accrual Transactions For Savings"); //
6262

6363
private final String name;
6464

0 commit comments

Comments
 (0)