FINERACT-1411 Allow charges type saving to map to all types of Ledgers (#1935)

This commit is contained in:
ankita10r
2021-10-29 16:35:02 +05:30
committed by GitHub
parent 32d2b2fbb9
commit e942527efe
19 changed files with 100 additions and 32 deletions
@@ -43,4 +43,8 @@ public interface AccountingDropdownReadPlatformService {
Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForShareProducts(); Map<String, List<GLAccountData>> retrieveAccountMappingOptionsForShareProducts();
List<GLAccountData> retrieveExpenseAccountOptions();
List<GLAccountData> retrieveAssetAccountOptions();
} }
@@ -95,6 +95,16 @@ public class AccountingDropdownReadPlatformServiceImpl implements AccountingDrop
includeEquityAccounts); includeEquityAccounts);
} }
@Override
public List<GLAccountData> retrieveExpenseAccountOptions() {
return accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.EXPENSE);
}
@Override
public List<GLAccountData> retrieveAssetAccountOptions() {
return accountReadPlatformService.retrieveAllEnabledDetailGLAccounts(GLAccountType.ASSET);
}
private Map<String, List<GLAccountData>> retrieveAccountMappingOptions(boolean includeAssetAccounts, boolean includeIncomeAccounts, private Map<String, List<GLAccountData>> retrieveAccountMappingOptions(boolean includeAssetAccounts, boolean includeIncomeAccounts,
boolean includeExpenseAccounts, boolean includeLiabilityAccounts, boolean includeEquityAccounts) { boolean includeExpenseAccounts, boolean includeLiabilityAccounts, boolean includeEquityAccounts) {
final Map<String, List<GLAccountData>> accountOptions = new HashMap<>(); final Map<String, List<GLAccountData>> accountOptions = new HashMap<>();
@@ -30,6 +30,7 @@ public class ChargePaymentDTO {
this.chargeId = chargeId; this.chargeId = chargeId;
this.amount = amount; this.amount = amount;
this.loanChargeId = loanChargeId; this.loanChargeId = loanChargeId;
} }
public Long getChargeId() { public Long getChargeId() {
@@ -64,6 +64,7 @@ import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper; import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
import org.apache.fineract.portfolio.account.PortfolioAccountType; import org.apache.fineract.portfolio.account.PortfolioAccountType;
import org.apache.fineract.portfolio.account.service.AccountTransfersReadPlatformService; import org.apache.fineract.portfolio.account.service.AccountTransfersReadPlatformService;
import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper;
import org.apache.fineract.portfolio.client.domain.ClientTransaction; import org.apache.fineract.portfolio.client.domain.ClientTransaction;
import org.apache.fineract.portfolio.client.domain.ClientTransactionRepositoryWrapper; import org.apache.fineract.portfolio.client.domain.ClientTransactionRepositoryWrapper;
import org.apache.fineract.portfolio.loanaccount.data.LoanTransactionEnumData; import org.apache.fineract.portfolio.loanaccount.data.LoanTransactionEnumData;
@@ -95,6 +96,7 @@ public class AccountingProcessorHelper {
private final ClientTransactionRepositoryWrapper clientTransactionRepository; private final ClientTransactionRepositoryWrapper clientTransactionRepository;
private final SavingsAccountTransactionRepository savingsAccountTransactionRepository; private final SavingsAccountTransactionRepository savingsAccountTransactionRepository;
private final AccountTransfersReadPlatformService accountTransfersReadPlatformService; private final AccountTransfersReadPlatformService accountTransfersReadPlatformService;
private final ChargeRepositoryWrapper chargeRepositoryWrapper;
@Autowired @Autowired
public AccountingProcessorHelper(final JournalEntryRepository glJournalEntryRepository, public AccountingProcessorHelper(final JournalEntryRepository glJournalEntryRepository,
@@ -104,7 +106,8 @@ public class AccountingProcessorHelper {
final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepository, final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepository,
final AccountTransfersReadPlatformService accountTransfersReadPlatformService, final AccountTransfersReadPlatformService accountTransfersReadPlatformService,
final GLAccountRepositoryWrapper accountRepositoryWrapper, final GLAccountRepositoryWrapper accountRepositoryWrapper,
final ClientTransactionRepositoryWrapper clientTransactionRepositoryWrapper) { final ClientTransactionRepositoryWrapper clientTransactionRepositoryWrapper,
final ChargeRepositoryWrapper chargeRepositoryWrapper) {
this.glJournalEntryRepository = glJournalEntryRepository; this.glJournalEntryRepository = glJournalEntryRepository;
this.accountMappingRepository = accountMappingRepository; this.accountMappingRepository = accountMappingRepository;
this.closureRepository = closureRepository; this.closureRepository = closureRepository;
@@ -115,6 +118,7 @@ public class AccountingProcessorHelper {
this.accountTransfersReadPlatformService = accountTransfersReadPlatformService; this.accountTransfersReadPlatformService = accountTransfersReadPlatformService;
this.accountRepositoryWrapper = accountRepositoryWrapper; this.accountRepositoryWrapper = accountRepositoryWrapper;
this.clientTransactionRepository = clientTransactionRepositoryWrapper; this.clientTransactionRepository = clientTransactionRepositoryWrapper;
this.chargeRepositoryWrapper = chargeRepositoryWrapper;
} }
public LoanDTO populateLoanDtoFromMap(final Map<String, Object> accountingBridgeData, final boolean cashBasedAccountingEnabled, public LoanDTO populateLoanDtoFromMap(final Map<String, Object> accountingBridgeData, final boolean cashBasedAccountingEnabled,
@@ -758,7 +762,7 @@ public class AccountingProcessorHelper {
* chargePaymentDTOs * chargePaymentDTOs
*/ */
public void createCashBasedJournalEntriesAndReversalsForSavingsCharges(final Office office, final String currencyCode, public void createCashBasedJournalEntriesAndReversalsForSavingsCharges(final Office office, final String currencyCode,
final CashAccountsForSavings accountTypeToBeDebited, final CashAccountsForSavings accountTypeToBeCredited, final CashAccountsForSavings accountTypeToBeDebited, CashAccountsForSavings accountTypeToBeCredited,
final Long savingsProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Long savingsProductId, final Long paymentTypeId, final Long loanId, final String transactionId,
final Date transactionDate, final BigDecimal totalAmount, final Boolean isReversal, final Date transactionDate, final BigDecimal totalAmount, final Boolean isReversal,
final List<ChargePaymentDTO> chargePaymentDTOs) { final List<ChargePaymentDTO> chargePaymentDTOs) {
@@ -774,9 +778,9 @@ public class AccountingProcessorHelper {
"Recent Portfolio changes w.r.t Charges for Savings have Broken the accounting code"); "Recent Portfolio changes w.r.t Charges for Savings have Broken the accounting code");
} }
ChargePaymentDTO chargePaymentDTO = chargePaymentDTOs.get(0); ChargePaymentDTO chargePaymentDTO = chargePaymentDTOs.get(0);
GLAccount chargeSpecificAccount = getLinkedGLAccountForSavingsCharges(savingsProductId, accountTypeToBeCredited.getValue(),
final GLAccount chargeSpecificAccount = getLinkedGLAccountForSavingsCharges(savingsProductId, accountTypeToBeCredited.getValue(),
chargePaymentDTO.getChargeId()); chargePaymentDTO.getChargeId());
final GLAccount savingsControlAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToBeDebited.getValue(), final GLAccount savingsControlAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToBeDebited.getValue(),
paymentTypeId); paymentTypeId);
if (isReversal) { if (isReversal) {
@@ -1158,6 +1162,7 @@ public class AccountingProcessorHelper {
private GLAccount getLinkedGLAccountForSavingsCharges(final Long savingsProductId, final int accountMappingTypeId, private GLAccount getLinkedGLAccountForSavingsCharges(final Long savingsProductId, final int accountMappingTypeId,
final Long chargeId) { final Long chargeId) {
ProductToGLAccountMapping accountMapping = this.accountMappingRepository.findCoreProductToFinAccountMapping(savingsProductId, ProductToGLAccountMapping accountMapping = this.accountMappingRepository.findCoreProductToFinAccountMapping(savingsProductId,
PortfolioProductType.SAVING.getValue(), accountMappingTypeId); PortfolioProductType.SAVING.getValue(), accountMappingTypeId);
/***** /*****
@@ -1167,15 +1172,22 @@ public class AccountingProcessorHelper {
*****/ *****/
// Vishwas TODO: remove this condition as it should always be true // Vishwas TODO: remove this condition as it should always be true
if (accountMappingTypeId == CashAccountsForSavings.INCOME_FROM_FEES.getValue() if (accountMappingTypeId == CashAccountsForSavings.INCOME_FROM_FEES.getValue()
|| accountMappingTypeId == CashAccountsForLoan.INCOME_FROM_PENALTIES.getValue()) { || accountMappingTypeId == CashAccountsForLoan.INCOME_FROM_PENALTIES.getValue()) {
GLAccount glAccount = chargeRepositoryWrapper.findOneWithNotFoundDetection(chargeId).getAccount();
if (glAccount != null) {
return glAccount;
}
final ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository final ProductToGLAccountMapping chargeSpecificIncomeAccountMapping = this.accountMappingRepository
.findProductIdAndProductTypeAndFinancialAccountTypeAndChargeId(savingsProductId, PortfolioProductType.SAVING.getValue(), .findProductIdAndProductTypeAndFinancialAccountTypeAndChargeId(savingsProductId, PortfolioProductType.SAVING.getValue(),
accountMappingTypeId, chargeId); accountMappingTypeId, chargeId);
if (chargeSpecificIncomeAccountMapping != null) { if (chargeSpecificIncomeAccountMapping != null) {
accountMapping = chargeSpecificIncomeAccountMapping; accountMapping = chargeSpecificIncomeAccountMapping;
} }
} }
return accountMapping.getGlAccount(); return accountMapping.getGlAccount();
} }
@@ -115,8 +115,8 @@ public class LoanProductToGLAccountMappingHelper extends ProductToGLAccountMappi
public void saveChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId, public void saveChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
final Map<String, Object> changes) { final Map<String, Object> changes) {
// save both fee and penalty charges // save both fee and penalty charges
saveChargesToIncomeOrLiabilityAccountMappings(command, element, productId, changes, PortfolioProductType.LOAN, true); saveChargesToGLAccountMappings(command, element, productId, changes, PortfolioProductType.LOAN, true);
saveChargesToIncomeOrLiabilityAccountMappings(command, element, productId, changes, PortfolioProductType.LOAN, false); saveChargesToGLAccountMappings(command, element, productId, changes, PortfolioProductType.LOAN, false);
} }
public void updateChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId, public void updateChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
@@ -162,7 +162,7 @@ public class ProductToGLAccountMappingHelper {
* @param productId * @param productId
* @param changes * @param changes
*/ */
public void saveChargesToIncomeOrLiabilityAccountMappings(final JsonCommand command, final JsonElement element, final Long productId, public void saveChargesToGLAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
final Map<String, Object> changes, final PortfolioProductType portfolioProductType, final boolean isPenalty) { final Map<String, Object> changes, final PortfolioProductType portfolioProductType, final boolean isPenalty) {
String arrayName; String arrayName;
if (isPenalty) { if (isPenalty) {
@@ -332,8 +332,7 @@ public class ProductToGLAccountMappingHelper {
if (inputPaymentChannelFundSourceMap.containsKey(currentPaymentChannelId)) { if (inputPaymentChannelFundSourceMap.containsKey(currentPaymentChannelId)) {
final Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId); final Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId);
if (!newGLAccountId.equals(existingPaymentChannelToFundSourceMapping.getGlAccount().getId())) { if (!newGLAccountId.equals(existingPaymentChannelToFundSourceMapping.getGlAccount().getId())) {
final GLAccount glAccount = getAccountByIdAndType(LoanProductAccountingParams.FUND_SOURCE.getValue(), final GLAccount glAccount = getAccountById(LoanProductAccountingParams.FUND_SOURCE.getValue(), newGLAccountId);
GLAccountType.ASSET, newGLAccountId);
existingPaymentChannelToFundSourceMapping.setGlAccount(glAccount); existingPaymentChannelToFundSourceMapping.setGlAccount(glAccount);
this.accountMappingRepository.save(existingPaymentChannelToFundSourceMapping); this.accountMappingRepository.save(existingPaymentChannelToFundSourceMapping);
} }
@@ -29,7 +29,7 @@ public interface ProductToGLAccountMappingReadPlatformService {
List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForLoanProduct(Long loanProductId); List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForLoanProduct(Long loanProductId);
List<ChargeToGLAccountMapper> fetchFeeToIncomeOrLiabilityAccountMappingsForLoanProduct(Long loanProductId); List<ChargeToGLAccountMapper> fetchFeeToGLAccountMappingsForLoanProduct(Long loanProductId);
List<ChargeToGLAccountMapper> fetchPenaltyToIncomeAccountMappingsForLoanProduct(Long loanProductId); List<ChargeToGLAccountMapper> fetchPenaltyToIncomeAccountMappingsForLoanProduct(Long loanProductId);
@@ -279,7 +279,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
} }
@Override @Override
public List<ChargeToGLAccountMapper> fetchFeeToIncomeOrLiabilityAccountMappingsForLoanProduct(final Long loanProductId) { public List<ChargeToGLAccountMapper> fetchFeeToGLAccountMappingsForLoanProduct(final Long loanProductId) {
return fetchChargeToIncomeAccountMappings(PortfolioProductType.LOAN, loanProductId, false); return fetchChargeToIncomeAccountMappings(PortfolioProductType.LOAN, loanProductId, false);
} }
@@ -121,8 +121,8 @@ public class SavingsProductToGLAccountMappingHelper extends ProductToGLAccountMa
public void saveChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId, public void saveChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
final Map<String, Object> changes) { final Map<String, Object> changes) {
// save both fee and penalty charges // save both fee and penalty charges
saveChargesToIncomeOrLiabilityAccountMappings(command, element, productId, changes, PortfolioProductType.SAVING, true); saveChargesToGLAccountMappings(command, element, productId, changes, PortfolioProductType.SAVING, true);
saveChargesToIncomeOrLiabilityAccountMappings(command, element, productId, changes, PortfolioProductType.SAVING, false); saveChargesToGLAccountMappings(command, element, productId, changes, PortfolioProductType.SAVING, false);
} }
public void updateChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId, public void updateChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
@@ -114,8 +114,8 @@ public class ShareProductToGLAccountMappingHelper extends ProductToGLAccountMapp
public void saveChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId, public void saveChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
final Map<String, Object> changes) { final Map<String, Object> changes) {
saveChargesToIncomeOrLiabilityAccountMappings(command, element, productId, changes, PortfolioProductType.SHARES, true); saveChargesToGLAccountMappings(command, element, productId, changes, PortfolioProductType.SHARES, true);
saveChargesToIncomeOrLiabilityAccountMappings(command, element, productId, changes, PortfolioProductType.SHARES, false); saveChargesToGLAccountMappings(command, element, productId, changes, PortfolioProductType.SHARES, false);
} }
public void updateChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId, public void updateChargesToIncomeAccountMappings(final JsonCommand command, final JsonElement element, final Long productId,
@@ -370,7 +370,7 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName);
if (property.isEnabled()) { if (property.isEnabled()) {
String value = property.getStringValue(); String value = property.getStringValue();
if (value == null) { if (StringUtils.isBlank(value)) {
return defaultValue; return defaultValue;
} }
return value; return value;
@@ -384,8 +384,8 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
String defaultValue = "Income"; // 1 Stands for Account mapped from income only String defaultValue = "Income"; // 1 Stands for Account mapped from income only
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName);
if (property.isEnabled()) { if (property.isEnabled()) {
String value = property.getValue().toString(); String value = property.getStringValue();
if (value == null) { if (StringUtils.isBlank(value)) {
return defaultValue; return defaultValue;
} }
return value; return value;
@@ -184,7 +184,6 @@ public class ChargesApiResource {
@DELETE @DELETE
@Path("{chargeId}") @Path("{chargeId}")
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Delete a Charge", description = "Deletes a Charge.") @Operation(summary = "Delete a Charge", description = "Deletes a Charge.")
@ApiResponses({ @ApiResponses({
@@ -77,6 +77,10 @@ public final class ChargeData implements Comparable<ChargeData>, Serializable {
private final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions; private final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions;
private final Collection<TaxGroupData> taxGroupOptions; private final Collection<TaxGroupData> taxGroupOptions;
private final String accountMappingForChargeConfig;
private final List<GLAccountData> expenseAccountOptions;
private final List<GLAccountData> assetAccountOptions;
public static ChargeData template(final Collection<CurrencyData> currencyOptions, public static ChargeData template(final Collection<CurrencyData> currencyOptions,
final List<EnumOptionData> chargeCalculationTypeOptions, final List<EnumOptionData> chargeAppliesToOptions, final List<EnumOptionData> chargeCalculationTypeOptions, final List<EnumOptionData> chargeAppliesToOptions,
final List<EnumOptionData> chargeTimeTypeOptions, final List<EnumOptionData> chargePaymentModeOptions, final List<EnumOptionData> chargeTimeTypeOptions, final List<EnumOptionData> chargePaymentModeOptions,
@@ -85,7 +89,8 @@ public final class ChargeData implements Comparable<ChargeData>, Serializable {
final List<EnumOptionData> clientChargeCalculationTypeOptions, final List<EnumOptionData> clientChargeTimeTypeOptions, final List<EnumOptionData> clientChargeCalculationTypeOptions, final List<EnumOptionData> clientChargeTimeTypeOptions,
final List<EnumOptionData> feeFrequencyOptions, final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions, final List<EnumOptionData> feeFrequencyOptions, final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions,
final Collection<TaxGroupData> taxGroupOptions, final List<EnumOptionData> shareChargeCalculationTypeOptions, final Collection<TaxGroupData> taxGroupOptions, final List<EnumOptionData> shareChargeCalculationTypeOptions,
final List<EnumOptionData> shareChargeTimeTypeOptions) { final List<EnumOptionData> shareChargeTimeTypeOptions, String accountMappingForChargeConfig,
List<GLAccountData> expenseAccountOptions, List<GLAccountData> assetAccountOptions) {
final GLAccountData account = null; final GLAccountData account = null;
final TaxGroupData taxGroupData = null; final TaxGroupData taxGroupData = null;
@@ -94,7 +99,7 @@ public final class ChargeData implements Comparable<ChargeData>, Serializable {
loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, savingsChargeCalculationTypeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, savingsChargeCalculationTypeOptions,
savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions, clientChargeTimeTypeOptions, null, null, null, null, null, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions, clientChargeTimeTypeOptions, null, null, null, null, null,
feeFrequencyOptions, account, incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, feeFrequencyOptions, account, incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions,
shareChargeTimeTypeOptions); shareChargeTimeTypeOptions, accountMappingForChargeConfig, expenseAccountOptions, assetAccountOptions);
} }
public static ChargeData withTemplate(final ChargeData charge, final ChargeData template) { public static ChargeData withTemplate(final ChargeData charge, final ChargeData template) {
@@ -106,7 +111,8 @@ public final class ChargeData implements Comparable<ChargeData>, Serializable {
template.clientChargeCalculationTypeOptions, template.clientChargeTimeTypeOptions, charge.feeOnMonthDay, charge.feeInterval, template.clientChargeCalculationTypeOptions, template.clientChargeTimeTypeOptions, charge.feeOnMonthDay, charge.feeInterval,
charge.minCap, charge.maxCap, charge.feeFrequency, template.feeFrequencyOptions, charge.incomeOrLiabilityAccount, charge.minCap, charge.maxCap, charge.feeFrequency, template.feeFrequencyOptions, charge.incomeOrLiabilityAccount,
template.incomeOrLiabilityAccountOptions, template.taxGroupOptions, template.shareChargeCalculationTypeOptions, template.incomeOrLiabilityAccountOptions, template.taxGroupOptions, template.shareChargeCalculationTypeOptions,
template.shareChargeTimeTypeOptions); template.shareChargeTimeTypeOptions, template.accountMappingForChargeConfig, template.expenseAccountOptions,
template.assetAccountOptions);
} }
public static ChargeData instance(final Long id, final String name, final BigDecimal amount, final CurrencyData currency, public static ChargeData instance(final Long id, final String name, final BigDecimal amount, final CurrencyData currency,
@@ -131,12 +137,16 @@ public final class ChargeData implements Comparable<ChargeData>, Serializable {
final List<EnumOptionData> shareChargeCalculationTypeOptions = null; final List<EnumOptionData> shareChargeCalculationTypeOptions = null;
final List<EnumOptionData> shareChargeTimeTypeOptions = null; final List<EnumOptionData> shareChargeTimeTypeOptions = null;
final Collection<TaxGroupData> taxGroupOptions = null; final Collection<TaxGroupData> taxGroupOptions = null;
final String accountMappingForChargeConfig = null;
final List<GLAccountData> expenseAccountOptions = null;
final List<GLAccountData> assetAccountOptions = null;
return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, chargePaymentMode, return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, chargePaymentMode,
penalty, active, taxGroupData, currencyOptions, chargeCalculationTypeOptions, chargeAppliesToOptions, chargeTimeTypeOptions, penalty, active, taxGroupData, currencyOptions, chargeCalculationTypeOptions, chargeAppliesToOptions, chargeTimeTypeOptions,
chargePaymentModeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, chargePaymentModeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions,
savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions, savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions,
clientChargeTimeTypeOptions, feeOnMonthDay, feeInterval, minCap, maxCap, feeFrequency, feeFrequencyOptions, accountData, clientChargeTimeTypeOptions, feeOnMonthDay, feeInterval, minCap, maxCap, feeFrequency, feeFrequencyOptions, accountData,
incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions); incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions,
accountMappingForChargeConfig, expenseAccountOptions, assetAccountOptions);
} }
public static ChargeData lookup(final Long id, final String name, final boolean isPenalty) { public static ChargeData lookup(final Long id, final String name, final boolean isPenalty) {
@@ -171,12 +181,17 @@ public final class ChargeData implements Comparable<ChargeData>, Serializable {
final List<EnumOptionData> shareChargeTimeTypeOptions = null; final List<EnumOptionData> shareChargeTimeTypeOptions = null;
final TaxGroupData taxGroupData = null; final TaxGroupData taxGroupData = null;
final Collection<TaxGroupData> taxGroupOptions = null; final Collection<TaxGroupData> taxGroupOptions = null;
final String accountMappingForChargeConfig = null;
final List<GLAccountData> expenseAccountOptions = null;
final List<GLAccountData> assetAccountOptions = null;
return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, chargePaymentMode, return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, chargePaymentMode,
penalty, active, taxGroupData, currencyOptions, chargeCalculationTypeOptions, chargeAppliesToOptions, chargeTimeTypeOptions, penalty, active, taxGroupData, currencyOptions, chargeCalculationTypeOptions, chargeAppliesToOptions, chargeTimeTypeOptions,
chargePaymentModeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, chargePaymentModeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions,
savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions, savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions,
clientChargeTimeTypeOptions, feeOnMonthDay, feeInterval, minCap, maxCap, feeFrequency, feeFrequencyOptions, account, clientChargeTimeTypeOptions, feeOnMonthDay, feeInterval, minCap, maxCap, feeFrequency, feeFrequencyOptions, account,
incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions); incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions,
accountMappingForChargeConfig, expenseAccountOptions, assetAccountOptions);
} }
private ChargeData(final Long id, final String name, final BigDecimal amount, final CurrencyData currency, private ChargeData(final Long id, final String name, final BigDecimal amount, final CurrencyData currency,
@@ -191,7 +206,9 @@ public final class ChargeData implements Comparable<ChargeData>, Serializable {
final BigDecimal minCap, final BigDecimal maxCap, final EnumOptionData feeFrequency, final BigDecimal minCap, final BigDecimal maxCap, final EnumOptionData feeFrequency,
final List<EnumOptionData> feeFrequencyOptions, final GLAccountData account, final List<EnumOptionData> feeFrequencyOptions, final GLAccountData account,
final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions, final Collection<TaxGroupData> taxGroupOptions, final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions, final Collection<TaxGroupData> taxGroupOptions,
final List<EnumOptionData> shareChargeCalculationTypeOptions, final List<EnumOptionData> shareChargeTimeTypeOptions) { final List<EnumOptionData> shareChargeCalculationTypeOptions, final List<EnumOptionData> shareChargeTimeTypeOptions,
final String accountMappingForChargeConfig, final List<GLAccountData> expenseAccountOptions,
final List<GLAccountData> assetAccountOptions) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.amount = amount; this.amount = amount;
@@ -225,6 +242,9 @@ public final class ChargeData implements Comparable<ChargeData>, Serializable {
this.taxGroupOptions = taxGroupOptions; this.taxGroupOptions = taxGroupOptions;
this.shareChargeCalculationTypeOptions = shareChargeCalculationTypeOptions; this.shareChargeCalculationTypeOptions = shareChargeCalculationTypeOptions;
this.shareChargeTimeTypeOptions = shareChargeTimeTypeOptions; this.shareChargeTimeTypeOptions = shareChargeTimeTypeOptions;
this.accountMappingForChargeConfig = accountMappingForChargeConfig;
this.assetAccountOptions = assetAccountOptions;
this.expenseAccountOptions = expenseAccountOptions;
} }
@Override @Override
@@ -579,7 +579,7 @@ public class Charge extends AbstractPersistableCustom {
this.account = account; this.account = account;
} }
private Long getIncomeAccountId() { public Long getIncomeAccountId() {
Long incomeAccountId = null; Long incomeAccountId = null;
if (this.account != null) { if (this.account != null) {
incomeAccountId = this.account.getId(); incomeAccountId = this.account.getId();
@@ -28,6 +28,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService; import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService;
import org.apache.fineract.accounting.glaccount.data.GLAccountData; import org.apache.fineract.accounting.glaccount.data.GLAccountData;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainServiceJpa;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.core.service.DateUtils;
@@ -67,13 +68,14 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
private final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService; private final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService;
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate; private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
private final TaxReadPlatformService taxReadPlatformService; private final TaxReadPlatformService taxReadPlatformService;
private final ConfigurationDomainServiceJpa configurationDomainServiceJpa;
@Autowired @Autowired
public ChargeReadPlatformServiceImpl(final CurrencyReadPlatformService currencyReadPlatformService, public ChargeReadPlatformServiceImpl(final CurrencyReadPlatformService currencyReadPlatformService,
final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService, final RoutingDataSource dataSource, final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService, final RoutingDataSource dataSource,
final DropdownReadPlatformService dropdownReadPlatformService, final FineractEntityAccessUtil fineractEntityAccessUtil, final DropdownReadPlatformService dropdownReadPlatformService, final FineractEntityAccessUtil fineractEntityAccessUtil,
final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService, final AccountingDropdownReadPlatformService accountingDropdownReadPlatformService,
final TaxReadPlatformService taxReadPlatformService) { final TaxReadPlatformService taxReadPlatformService, final ConfigurationDomainServiceJpa configurationDomainServiceJpa) {
this.chargeDropdownReadPlatformService = chargeDropdownReadPlatformService; this.chargeDropdownReadPlatformService = chargeDropdownReadPlatformService;
this.jdbcTemplate = new JdbcTemplate(dataSource); this.jdbcTemplate = new JdbcTemplate(dataSource);
this.currencyReadPlatformService = currencyReadPlatformService; this.currencyReadPlatformService = currencyReadPlatformService;
@@ -82,6 +84,7 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
this.accountingDropdownReadPlatformService = accountingDropdownReadPlatformService; this.accountingDropdownReadPlatformService = accountingDropdownReadPlatformService;
this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
this.taxReadPlatformService = taxReadPlatformService; this.taxReadPlatformService = taxReadPlatformService;
this.configurationDomainServiceJpa = configurationDomainServiceJpa;
} }
@Override @Override
@@ -152,11 +155,16 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
.retrieveSharesCalculationTypes(); .retrieveSharesCalculationTypes();
final List<EnumOptionData> shareChargeTimeTypeOptions = this.chargeDropdownReadPlatformService.retrieveSharesCollectionTimeTypes(); final List<EnumOptionData> shareChargeTimeTypeOptions = this.chargeDropdownReadPlatformService.retrieveSharesCollectionTimeTypes();
final Collection<TaxGroupData> taxGroupOptions = this.taxReadPlatformService.retrieveTaxGroupsForLookUp(); final Collection<TaxGroupData> taxGroupOptions = this.taxReadPlatformService.retrieveTaxGroupsForLookUp();
final String accountMappingForChargeConfig = this.configurationDomainServiceJpa.getAccountMappingForCharge();
final List<GLAccountData> expenseAccountOptions = this.accountingDropdownReadPlatformService.retrieveExpenseAccountOptions();
final List<GLAccountData> assetAccountOptions = this.accountingDropdownReadPlatformService.retrieveAssetAccountOptions();
return ChargeData.template(currencyOptions, allowedChargeCalculationTypeOptions, allowedChargeAppliesToOptions, return ChargeData.template(currencyOptions, allowedChargeCalculationTypeOptions, allowedChargeAppliesToOptions,
allowedChargeTimeOptions, chargePaymentOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, allowedChargeTimeOptions, chargePaymentOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions,
savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions, savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions,
clientChargeTimeTypeOptions, feeFrequencyOptions, incomeOrLiabilityAccountOptions, taxGroupOptions, clientChargeTimeTypeOptions, feeFrequencyOptions, incomeOrLiabilityAccountOptions, taxGroupOptions,
shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions); shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions, accountMappingForChargeConfig, expenseAccountOptions,
assetAccountOptions);
} }
@Override @Override
@@ -159,10 +159,16 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
final List<EnumOptionData> shareChargeCalculationTypeOptions = null; final List<EnumOptionData> shareChargeCalculationTypeOptions = null;
final List<EnumOptionData> shareChargeTimeTypeOptions = null; final List<EnumOptionData> shareChargeTimeTypeOptions = null;
final Collection<TaxGroupData> taxGroupOptions = null; final Collection<TaxGroupData> taxGroupOptions = null;
final String accountMappingForChargeConfig = null;
final List<GLAccountData> expenseAccountOptions = null;
final List<GLAccountData> assetAccountOptions = null;
return ChargeData.template(null, allowedChargeCalculationTypeOptions, null, allowedChargeTimeOptions, null, return ChargeData.template(null, allowedChargeCalculationTypeOptions, null, allowedChargeTimeOptions, null,
loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, savingsChargeCalculationTypeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, savingsChargeCalculationTypeOptions,
savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions, clientChargeTimeTypeOptions, feeFrequencyOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions, clientChargeTimeTypeOptions, feeFrequencyOptions,
incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions); incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions,
accountMappingForChargeConfig, expenseAccountOptions, assetAccountOptions);
} }
@Override @Override
@@ -275,8 +275,7 @@ public class LoanProductsApiResource {
loanProduct.accountingRuleType().getId().intValue()); loanProduct.accountingRuleType().getId().intValue());
paymentChannelToFundSourceMappings = this.accountMappingReadPlatformService paymentChannelToFundSourceMappings = this.accountMappingReadPlatformService
.fetchPaymentTypeToFundSourceMappingsForLoanProduct(productId); .fetchPaymentTypeToFundSourceMappingsForLoanProduct(productId);
feeToGLAccountMappings = this.accountMappingReadPlatformService feeToGLAccountMappings = this.accountMappingReadPlatformService.fetchFeeToGLAccountMappingsForLoanProduct(productId);
.fetchFeeToIncomeOrLiabilityAccountMappingsForLoanProduct(productId);
penaltyToGLAccountMappings = this.accountMappingReadPlatformService penaltyToGLAccountMappings = this.accountMappingReadPlatformService
.fetchPenaltyToIncomeAccountMappingsForLoanProduct(productId); .fetchPenaltyToIncomeAccountMappingsForLoanProduct(productId);
loanProduct = LoanProductData.withAccountingDetails(loanProduct, accountingMappings, paymentChannelToFundSourceMappings, loanProduct = LoanProductData.withAccountingDetails(loanProduct, accountingMappings, paymentChannelToFundSourceMappings,
@@ -192,4 +192,8 @@ public class SavingsAccountChargeData implements Serializable {
return this.amountOutstanding; return this.amountOutstanding;
} }
public long getAccountId() {
return this.accountId;
}
} }
@@ -163,11 +163,17 @@ public class SavingsAccountChargeReadPlatformServiceImpl implements SavingsAccou
final List<EnumOptionData> shareChargeCalculationTypeOptions = null; final List<EnumOptionData> shareChargeCalculationTypeOptions = null;
final List<EnumOptionData> shareChargeTimeTypeOptions = null; final List<EnumOptionData> shareChargeTimeTypeOptions = null;
final Collection<TaxGroupData> taxGroupOptions = null; final Collection<TaxGroupData> taxGroupOptions = null;
final String accountMappingForChargeConfig = null;
final List<GLAccountData> expenseAccountOptions = null;
final List<GLAccountData> assetAccountOptions = null;
// TODO AA : revisit for merge conflict - Not sure method signature // TODO AA : revisit for merge conflict - Not sure method signature
return ChargeData.template(null, allowedChargeCalculationTypeOptions, null, allowedChargeTimeOptions, null, return ChargeData.template(null, allowedChargeCalculationTypeOptions, null, allowedChargeTimeOptions, null,
loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, savingsChargeCalculationTypeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, savingsChargeCalculationTypeOptions,
savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions, clientChargeTimeTypeOptions, feeFrequencyOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions, clientChargeTimeTypeOptions, feeFrequencyOptions,
incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions); incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions,
accountMappingForChargeConfig, expenseAccountOptions, assetAccountOptions);
} }
@Override @Override