Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.accounting.accrual.handler;

import lombok.RequiredArgsConstructor;
import org.apache.fineract.accounting.accrual.service.AccrualAccountingWritePlatformService;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@CommandType(entity = "PERIODICACCRUALACCOUNTINGFORSAVINGS", action = "EXECUTE")
@RequiredArgsConstructor
public class ExecutePeriodicAccrualForSavingsCommandHandler implements NewCommandSourceHandler {

private final AccrualAccountingWritePlatformService writePlatformService;

@Transactional
@Override
public CommandProcessingResult processCommand(final JsonCommand command) {
return this.writePlatformService.executeLoansPeriodicAccrual(command);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ public void validateForSavingsProductCreate(final String json, DepositAccountTyp
Locale.getDefault());
baseDataValidator.reset().parameter(accountingRuleParamName).value(accountingRuleType).notNull().inMinMaxRange(1, 3);

if (AccountingValidations.isCashBasedAccounting(accountingRuleType)) {
if (AccountingValidations.isCashBasedAccounting(accountingRuleType)
|| AccountingValidations.isAccrualBasedAccounting(accountingRuleType)) {

final Long savingsControlAccountId = this.fromApiJsonHelper
.extractLongNamed(SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), element);
Expand Down Expand Up @@ -225,7 +226,6 @@ public void validateForSavingsProductCreate(final String json, DepositAccountTyp
baseDataValidator.reset().parameter(SavingProductAccountingParams.LOSSES_WRITTEN_OFF.getValue()).value(writtenOff).notNull()
.integerGreaterThanZero();
}

}

// Periodic Accrual Accounting aditional GL Accounts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void mergeProductToAccountMappingChanges(final JsonElement element, final
optionalProductToGLAccountMappingEntries.add("incomeFromGoodwillCreditInterestAccountId");
optionalProductToGLAccountMappingEntries.add("incomeFromGoodwillCreditFeesAccountId");
optionalProductToGLAccountMappingEntries.add("incomeFromGoodwillCreditPenaltyAccountId");
optionalProductToGLAccountMappingEntries.add("interestReceivableAccountId");
optionalProductToGLAccountMappingEntries.add(LoanProductAccountingParams.DEFERRED_INCOME_LIABILITY.getValue());
optionalProductToGLAccountMappingEntries.add(LoanProductAccountingParams.INCOME_FROM_CAPITALIZATION.getValue());
optionalProductToGLAccountMappingEntries.add(LoanProductAccountingParams.BUY_DOWN_EXPENSE.getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ private Map<String, Object> setAccrualPeriodicSavingsProductToGLAccountMaps(fina
// Assets
if (glAccountForSavings.equals(AccrualAccountsForSavings.SAVINGS_REFERENCE)) {
accountMappingDetails.put(SavingProductAccountingDataParams.SAVINGS_REFERENCE.getValue(), glAccountData);
} else if (glAccountForSavings.equals(AccrualAccountsForSavings.INTEREST_RECEIVABLE)) {
accountMappingDetails.put(SavingProductAccountingDataParams.INTEREST_RECEIVABLE.getValue(), glAccountData);
} else if (glAccountForSavings.equals(AccrualAccountsForSavings.OVERDRAFT_PORTFOLIO_CONTROL)) {
accountMappingDetails.put(SavingProductAccountingDataParams.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), glAccountData);
} else if (glAccountForSavings.equals(AccrualAccountsForSavings.FEES_RECEIVABLE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ public void handleChangesToSavingsProductToGLAccountMappings(final Long savingsP
savingsProductId, AccrualAccountsForSavings.FEES_RECEIVABLE.getValue(),
AccrualAccountsForSavings.FEES_RECEIVABLE.toString(), changes);

mergeSavingsToAssetAccountMappingChanges(element, SavingProductAccountingParams.PENALTIES_RECEIVABLE.getValue(),
savingsProductId, AccrualAccountsForSavings.PENALTIES_RECEIVABLE.getValue(),
AccrualAccountsForSavings.PENALTIES_RECEIVABLE.toString(), changes);
mergeSavingsToAssetAccountMappingChanges(element, SavingProductAccountingParams.INTEREST_RECEIVABLE.getValue(),
savingsProductId, AccrualAccountsForSavings.INTEREST_RECEIVABLE.getValue(),
AccrualAccountsForSavings.INTEREST_RECEIVABLE.toString(), changes);

// income
mergeSavingsToIncomeAccountMappingChanges(element, SavingProductAccountingParams.INCOME_FROM_FEES.getValue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.fineract.portfolio.charge.service;

import java.util.Collection;
import java.util.List;
import org.apache.fineract.portfolio.charge.data.ChargeData;
import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
Expand Down Expand Up @@ -112,6 +113,8 @@ public interface ChargeReadPlatformService {
*/
List<ChargeData> retrieveSavingsProductCharges(Long savingsProductId);

Collection<ChargeData> retrieveSavingsProductAccrualCharges(Long savingsProductId);

/** Retrieve savings account charges **/
List<ChargeData> retrieveSavingsAccountApplicableCharges(Long savingsId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ public enum AccrualAccountsForSavings {
ESCHEAT_LIABILITY(14), //
FEES_RECEIVABLE(15), //
PENALTIES_RECEIVABLE(16), //
INTEREST_PAYABLE(17);
INTEREST_PAYABLE(17), //
INTEREST_RECEIVABLE(18);

private final Integer value;

Expand Down Expand Up @@ -366,6 +367,7 @@ public enum SavingProductAccountingParams {
LOSSES_WRITTEN_OFF("writeOffAccountId"), //
ESCHEAT_LIABILITY("escheatLiabilityId"), //
PENALTIES_RECEIVABLE("penaltiesReceivableAccountId"), //
INTEREST_RECEIVABLE("interestReceivableAccountId"), //
FEES_RECEIVABLE("feesReceivableAccountId"), //
INTEREST_PAYABLE("interestPayableAccountId");

Expand Down Expand Up @@ -404,7 +406,8 @@ public enum SavingProductAccountingDataParams {
ESCHEAT_LIABILITY("escheatLiabilityAccount"), //
FEES_RECEIVABLE("feeReceivableAccount"), //
PENALTIES_RECEIVABLE("penaltyReceivableAccount"), //
INTEREST_PAYABLE("interestPayableAccount"); //
INTEREST_PAYABLE("interestPayableAccount"), //
INTEREST_RECEIVABLE("interestReceivableAccount"); //

private final String value;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.accounting.common;

public class AccountingValidations {

protected AccountingValidations() {}

public static boolean isCashBasedAccounting(final Integer accountingRuleType) {
return AccountingRuleType.CASH_BASED.getValue().equals(accountingRuleType);
}

public static boolean isAccrualPeriodicBasedAccounting(final Integer accountingRuleType) {
return AccountingRuleType.ACCRUAL_PERIODIC.getValue().equals(accountingRuleType);
}

public static boolean isUpfrontAccrualAccounting(final Integer accountingRuleType) {
return AccountingRuleType.ACCRUAL_UPFRONT.getValue().equals(accountingRuleType);
}

public static boolean isAccrualBasedAccounting(final Integer accountingRuleType) {
return AccountingRuleType.ACCRUAL_PERIODIC.getValue().equals(accountingRuleType)
|| AccountingRuleType.ACCRUAL_UPFRONT.getValue().equals(accountingRuleType);
}

public static boolean isCashOrAccrualBasedAccounting(final Integer accountingRuleType) {
return isCashBasedAccounting(accountingRuleType) || isAccrualBasedAccounting(accountingRuleType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.exception.MultiException;

public interface NewCommandSourceHandler {

CommandProcessingResult processCommand(JsonCommand command);
CommandProcessingResult processCommand(JsonCommand command) throws MultiException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.fineract.infrastructure.core.exception.ErrorHandler;
import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException;
import org.apache.fineract.infrastructure.core.exception.IdempotentCommandProcessUnderProcessingException;
import org.apache.fineract.infrastructure.core.exception.MultiException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.useradministration.domain.AppUser;
import org.springframework.lang.NonNull;
Expand Down Expand Up @@ -131,7 +132,7 @@ public CommandSource getInitialCommandSource(CommandWrapper wrapper, JsonCommand

@Transactional
public CommandProcessingResult processCommand(NewCommandSourceHandler handler, JsonCommand command, CommandSource commandSource,
AppUser user, boolean isApprovedByChecker) {
AppUser user, boolean isApprovedByChecker) throws MultiException {
final CommandProcessingResult result = handler.processCommand(command);

String permission = commandSource.getPermissionCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3416,6 +3416,15 @@ public CommandWrapperBuilder unblockSavingsAccount(final Long accountId) {
return this;
}

public CommandWrapperBuilder addAccrualsToSavingsAccount(final Long accountId) {
this.actionName = "ADD_ACCRUALS";
this.entityName = "SAVINGSACCOUNT";
this.savingsId = accountId;
this.entityId = null;
this.href = "/savingsaccounts/" + accountId + "?command=addAccrualTransactions";
return this;
}

public CommandWrapperBuilder disableAdHoc(Long adHocId) {
this.actionName = "DISABLE";
this.entityName = "ADHOC";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public enum JobName {
PURGE_EXTERNAL_EVENTS("Purge External Events"), //
PURGE_PROCESSED_COMMANDS("Purge Processed Commands"), //
ACCRUAL_ACTIVITY_POSTING("Accrual Activity Posting"), //
;
ADD_PERIODIC_ACCRUAL_ENTRIES_FOR_SAVINGS_WITH_INCOME_POSTED_AS_TRANSACTIONS("Add Accrual Transactions For Savings"); //

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private DepositsApiConstants() {
interestPostingPeriodTypeParamName, interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName,
lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName, accountingRuleParamName, chargesParamName,
SavingProductAccountingParams.INCOME_FROM_FEES.getValue(), SavingProductAccountingParams.INCOME_FROM_PENALTIES.getValue(),
SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(),
SavingProductAccountingParams.INTEREST_ON_SAVINGS.getValue(), SavingProductAccountingParams.FEES_RECEIVABLE.getValue(),
SavingProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
SavingProductAccountingParams.SAVINGS_CONTROL.getValue(), SavingProductAccountingParams.TRANSFERS_SUSPENSE.getValue(),
SavingProductAccountingParams.SAVINGS_REFERENCE.getValue(), SavingProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue(),
Expand Down Expand Up @@ -304,14 +304,14 @@ private static Set<String> recurringDepositProductResponseData() {
* Depost Account parameters
*/

private static final Set<String> DEPOSIT_ACCOUNT_REQUEST_DATA_PARAMETERS = new HashSet<>(
Arrays.asList(localeParamName, dateFormatParamName, monthDayFormatParamName, accountNoParamName, externalIdParamName,
clientIdParamName, groupIdParamName, productIdParamName, fieldOfficerIdParamName, submittedOnDateParamName,
nominalAnnualInterestRateParamName, interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName,
interestCalculationTypeParamName, interestCalculationDaysInYearTypeParamName, lockinPeriodFrequencyParamName,
lockinPeriodFrequencyTypeParamName, chargesParamName, chartsParamName, depositAmountParamName, depositPeriodParamName,
depositPeriodFrequencyIdParamName, savingsAccounts, expectedFirstDepositOnDateParamName,
SavingsApiConstants.withHoldTaxParamName, maturityInstructionIdParamName, transferToSavingsIdParamName));
private static final Set<String> DEPOSIT_ACCOUNT_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
dateFormatParamName, monthDayFormatParamName, accountNoParamName, externalIdParamName, clientIdParamName, groupIdParamName,
productIdParamName, fieldOfficerIdParamName, submittedOnDateParamName, nominalAnnualInterestRateParamName,
interestCompoundingPeriodTypeParamName, interestPostingPeriodTypeParamName, interestCalculationTypeParamName,
interestCalculationDaysInYearTypeParamName, lockinPeriodFrequencyParamName, lockinPeriodFrequencyTypeParamName,
chargesParamName, chartsParamName, depositAmountParamName, depositPeriodParamName, depositPeriodFrequencyIdParamName,
savingsAccounts, expectedFirstDepositOnDateParamName, SavingsApiConstants.withHoldTaxParamName, maturityInstructionIdParamName,
transferToSavingsIdParamName, linkedAccountParamName, transferInterestToSavingsParamName));

public static final Set<String> FIXED_DEPOSIT_ACCOUNT_REQUEST_DATA_PARAMETERS = fixedDepositAccountRequestData();
public static final Set<String> FIXED_DEPOSIT_ACCOUNT_RESPONSE_DATA_PARAMETERS = fixedDepositAccountResponseData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class SavingsApiConstants {
public static final String withdrawnByApplicantAction = ".withdrawnByApplicant";
public static final String activateAction = ".activate";
public static final String modifyApplicationAction = ".modify";
public static final String undoActivateAction = ".undoactivate";
public static final String deleteApplicationAction = ".delete";
public static final String undoTransactionAction = ".undotransaction";
public static final String applyAnnualFeeTransactionAction = ".applyannualfee";
Expand Down Expand Up @@ -65,6 +66,7 @@ public class SavingsApiConstants {
public static final String COMMAND_BLOCK_DEBIT = "blockDebit";
public static final String COMMAND_UNBLOCK_DEBIT = "unblockDebit";
public static final String COMMAND_UNBLOCK_CREDIT = "unblockCredit";
public static final String COMMAND_ADD_ACCRUAL_TRANSACTION = "addAccrualTransactions";

// general
public static final String localeParamName = "locale";
Expand Down Expand Up @@ -104,6 +106,7 @@ public class SavingsApiConstants {
public static final String activeParamName = "active";
public static final String nameParamName = "name";
public static final String shortNameParamName = "shortName";
public static final String interestReceivableAccount = "interestReceivableAccountId";
public static final String descriptionParamName = "description";
public static final String currencyCodeParamName = "currencyCode";
public static final String digitsAfterDecimalParamName = "digitsAfterDecimal";
Expand Down Expand Up @@ -156,6 +159,7 @@ public class SavingsApiConstants {
// charges parameters
public static final String chargeIdParamName = "chargeId";
public static final String chargesParamName = "charges";
public static final String accrualChargesParamName = "accrualCharges";
public static final String savingsAccountChargeIdParamName = "savingsAccountChargeId";
public static final String chargeNameParamName = "name";
public static final String penaltyParamName = "penalty";
Expand Down
Loading