bug fixes for mapping paymet channel to ledger accounts
This commit is contained in:
+1
-1
@@ -84,7 +84,7 @@ public class AccountingConstants {
|
|||||||
FUND_SOURCE("fundSourceAccountId"), LOAN_PORTFOLIO("loanPortfolioAccountId"), INTEREST_ON_LOANS("interestOnLoanAccountId"), INCOME_FROM_FEES(
|
FUND_SOURCE("fundSourceAccountId"), LOAN_PORTFOLIO("loanPortfolioAccountId"), INTEREST_ON_LOANS("interestOnLoanAccountId"), INCOME_FROM_FEES(
|
||||||
"incomeFromFeeAccountId"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccountId"), LOSSES_WRITTEN_OFF("writeOffAccountId"), INTEREST_RECEIVABLE(
|
"incomeFromFeeAccountId"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccountId"), LOSSES_WRITTEN_OFF("writeOffAccountId"), INTEREST_RECEIVABLE(
|
||||||
"receivableInterestAccountId"), FEES_RECEIVABLE("receivableFeeAccountId"), PENALTIES_RECEIVABLE(
|
"receivableInterestAccountId"), FEES_RECEIVABLE("receivableFeeAccountId"), PENALTIES_RECEIVABLE(
|
||||||
"receivablePenaltyAccountId"), PAYMENT_CHANNEL_FUND_SOURCE_MAPPING("paymentChannelFundSourceMappings"), PAYMENT_TYPE(
|
"receivablePenaltyAccountId"), PAYMENT_CHANNEL_FUND_SOURCE_MAPPING("paymentChannelToFundSourceMappings"), PAYMENT_TYPE(
|
||||||
"paymentTypeId");
|
"paymentTypeId");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package org.mifosplatform.accounting.producttoaccountmapping.data;
|
||||||
|
|
||||||
|
public class PaymentTypeToGLAccountMapper {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final long paymentTypeId;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private final long fundSourceAccountId;
|
||||||
|
|
||||||
|
public PaymentTypeToGLAccountMapper(long paymentTypeId, long fundSourceAccountId) {
|
||||||
|
this.paymentTypeId = paymentTypeId;
|
||||||
|
this.fundSourceAccountId = fundSourceAccountId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+4
-1
@@ -5,11 +5,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.producttoaccountmapping.service;
|
package org.mifosplatform.accounting.producttoaccountmapping.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper;
|
||||||
|
|
||||||
public interface ProductToGLAccountMappingReadPlatformService {
|
public interface ProductToGLAccountMappingReadPlatformService {
|
||||||
|
|
||||||
Map<String, Object> fetchAccountMappingDetailsForLoanProduct(final Long loanProductId, final Integer accountingType);
|
Map<String, Object> fetchAccountMappingDetailsForLoanProduct(final Long loanProductId, final Integer accountingType);
|
||||||
|
|
||||||
Map<Long, Long> fetchPaymentTypeToFundSourceMappingsForLoanProduct(final Long loanProductId);
|
List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForLoanProduct(final Long loanProductId);
|
||||||
}
|
}
|
||||||
+10
-7
@@ -7,6 +7,7 @@ package org.mifosplatform.accounting.producttoaccountmapping.service;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -14,6 +15,7 @@ import java.util.Map;
|
|||||||
import org.mifosplatform.accounting.common.AccountingConstants.ACCRUAL_ACCOUNTS_FOR_LOAN;
|
import org.mifosplatform.accounting.common.AccountingConstants.ACCRUAL_ACCOUNTS_FOR_LOAN;
|
||||||
import org.mifosplatform.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_LOAN;
|
import org.mifosplatform.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_LOAN;
|
||||||
import org.mifosplatform.accounting.common.AccountingConstants.LOAN_PRODUCT_ACCOUNTING_PARAMS;
|
import org.mifosplatform.accounting.common.AccountingConstants.LOAN_PRODUCT_ACCOUNTING_PARAMS;
|
||||||
|
import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper;
|
||||||
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource;
|
||||||
import org.mifosplatform.portfolio.loanproduct.domain.AccountingRuleType;
|
import org.mifosplatform.portfolio.loanproduct.domain.AccountingRuleType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -66,7 +68,7 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
|||||||
final Map<String, Object> accountMappingDetails = new LinkedHashMap<String, Object>(8);
|
final Map<String, Object> accountMappingDetails = new LinkedHashMap<String, Object>(8);
|
||||||
|
|
||||||
final LoanProductToGLAccountMappingMapper rm = new LoanProductToGLAccountMappingMapper();
|
final LoanProductToGLAccountMappingMapper rm = new LoanProductToGLAccountMappingMapper();
|
||||||
final String sql = "select " + rm.schema() + " and product_id = ?";
|
final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is null ";
|
||||||
|
|
||||||
final List<Map<String, Object>> listOfProductToGLAccountMaps = this.jdbcTemplate.query(sql, rm, new Object[] { loanProductId });
|
final List<Map<String, Object>> listOfProductToGLAccountMaps = this.jdbcTemplate.query(sql, rm, new Object[] { loanProductId });
|
||||||
|
|
||||||
@@ -128,8 +130,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Long, Long> fetchPaymentTypeToFundSourceMappingsForLoanProduct(Long loanProductId) {
|
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForLoanProduct(Long loanProductId) {
|
||||||
Map<Long, Long> paymentTypeToFundSourceMappingDetails = null;
|
List<PaymentTypeToGLAccountMapper> paymentTypeToGLAccountMappers = null;
|
||||||
|
|
||||||
final LoanProductToGLAccountMappingMapper rm = new LoanProductToGLAccountMappingMapper();
|
final LoanProductToGLAccountMappingMapper rm = new LoanProductToGLAccountMappingMapper();
|
||||||
final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is not null";
|
final String sql = "select " + rm.schema() + " and product_id = ? and payment_type is not null";
|
||||||
@@ -138,13 +140,14 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
|||||||
new Object[] { loanProductId });
|
new Object[] { loanProductId });
|
||||||
|
|
||||||
for (final Map<String, Object> productToGLAccountMap : paymentTypeToFundSourceMappingsList) {
|
for (final Map<String, Object> productToGLAccountMap : paymentTypeToFundSourceMappingsList) {
|
||||||
if (paymentTypeToFundSourceMappingDetails == null) {
|
if (paymentTypeToGLAccountMappers == null) {
|
||||||
paymentTypeToFundSourceMappingDetails = new LinkedHashMap<Long, Long>();
|
paymentTypeToGLAccountMappers = new ArrayList<PaymentTypeToGLAccountMapper>();
|
||||||
}
|
}
|
||||||
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
|
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
|
||||||
final Long paymentTypeId = (Long) productToGLAccountMap.get("paymentTypeId");
|
final Long paymentTypeId = (Long) productToGLAccountMap.get("paymentTypeId");
|
||||||
paymentTypeToFundSourceMappingDetails.put(paymentTypeId, glAccountId);
|
PaymentTypeToGLAccountMapper paymentTypeToGLAccountMapper = new PaymentTypeToGLAccountMapper(paymentTypeId, glAccountId);
|
||||||
|
paymentTypeToGLAccountMappers.add(paymentTypeToGLAccountMapper);
|
||||||
}
|
}
|
||||||
return paymentTypeToFundSourceMappingDetails;
|
return paymentTypeToGLAccountMappers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+10
-10
@@ -188,7 +188,7 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds
|
*
|
||||||
*
|
*
|
||||||
* @param command
|
* @param command
|
||||||
* @param element
|
* @param element
|
||||||
@@ -239,11 +239,11 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
|||||||
**/
|
**/
|
||||||
else {
|
else {
|
||||||
for (ProductToGLAccountMapping existingPaymentChannelToFundSourceMapping : existingPaymentChannelToFundSourceMappings) {
|
for (ProductToGLAccountMapping existingPaymentChannelToFundSourceMapping : existingPaymentChannelToFundSourceMappings) {
|
||||||
Long currentPaymentChannelId = existingPaymentChannelToFundSourceMapping.getId();
|
Long currentPaymentChannelId = existingPaymentChannelToFundSourceMapping.getPaymentType().getId();
|
||||||
existingPaymentTypes.add(currentPaymentChannelId);
|
existingPaymentTypes.add(currentPaymentChannelId);
|
||||||
// update existing mappings (if required)
|
// update existing mappings (if required)
|
||||||
if (inputPaymentChannelFundSourceMap.containsKey(existingPaymentChannelToFundSourceMapping.getId())) {
|
if (inputPaymentChannelFundSourceMap.containsKey(currentPaymentChannelId)) {
|
||||||
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(existingPaymentChannelToFundSourceMapping.getId());
|
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId);
|
||||||
if (newGLAccountId != existingPaymentChannelToFundSourceMapping.getGlAccount().getId()) {
|
if (newGLAccountId != existingPaymentChannelToFundSourceMapping.getGlAccount().getId()) {
|
||||||
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(),
|
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(),
|
||||||
GLAccountType.ASSET, newGLAccountId);
|
GLAccountType.ASSET, newGLAccountId);
|
||||||
@@ -257,12 +257,12 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
|||||||
}
|
}
|
||||||
// create new mappings
|
// create new mappings
|
||||||
Set<Long> incomingPaymentTypes = inputPaymentChannelFundSourceMap.keySet();
|
Set<Long> incomingPaymentTypes = inputPaymentChannelFundSourceMap.keySet();
|
||||||
boolean newPaymentTypesAdded = incomingPaymentTypes.removeAll(existingPaymentTypes);
|
incomingPaymentTypes.removeAll(existingPaymentTypes);
|
||||||
if (newPaymentTypesAdded) {
|
// incomingPaymentTypes now only contains the newly added
|
||||||
for (Long newPaymentType : incomingPaymentTypes) {
|
// payment Type mappings
|
||||||
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(newPaymentType);
|
for (Long newPaymentType : incomingPaymentTypes) {
|
||||||
savePaymentChannelToFundSourceMapping(productId, newPaymentType, newGLAccountId);
|
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(newPaymentType);
|
||||||
}
|
savePaymentChannelToFundSourceMapping(productId, newPaymentType, newGLAccountId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -27,6 +27,7 @@ import javax.ws.rs.core.UriInfo;
|
|||||||
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
|
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
|
||||||
import org.mifosplatform.accounting.glaccount.domain.GLAccountType;
|
import org.mifosplatform.accounting.glaccount.domain.GLAccountType;
|
||||||
import org.mifosplatform.accounting.glaccount.service.GLAccountReadPlatformService;
|
import org.mifosplatform.accounting.glaccount.service.GLAccountReadPlatformService;
|
||||||
|
import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper;
|
||||||
import org.mifosplatform.accounting.producttoaccountmapping.service.ProductToGLAccountMappingReadPlatformService;
|
import org.mifosplatform.accounting.producttoaccountmapping.service.ProductToGLAccountMappingReadPlatformService;
|
||||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||||
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||||
@@ -161,7 +162,7 @@ public class LoanProductsApiResource {
|
|||||||
LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
||||||
|
|
||||||
Map<String, Object> accountingMappings = null;
|
Map<String, Object> accountingMappings = null;
|
||||||
Map<Long, Long> paymentChannelToFundSourceMappings = null;
|
Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings = null;
|
||||||
if (loanProduct.hasAccountingEnabled()) {
|
if (loanProduct.hasAccountingEnabled()) {
|
||||||
accountingMappings = accountMappingReadPlatformService.fetchAccountMappingDetailsForLoanProduct(productId, loanProduct
|
accountingMappings = accountMappingReadPlatformService.fetchAccountMappingDetailsForLoanProduct(productId, loanProduct
|
||||||
.accountingRuleType().getId().intValue());
|
.accountingRuleType().getId().intValue());
|
||||||
@@ -191,7 +192,7 @@ public class LoanProductsApiResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LoanProductData handleTemplate(final LoanProductData productData, final Map<String, Object> accountingMappings,
|
private LoanProductData handleTemplate(final LoanProductData productData, final Map<String, Object> accountingMappings,
|
||||||
final Map<Long, Long> paymentChannelToFundSourceMappings) {
|
final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings) {
|
||||||
|
|
||||||
final boolean feeChargesOnly = true;
|
final boolean feeChargesOnly = true;
|
||||||
Collection<ChargeData> chargeOptions = this.chargeReadPlatformService.retrieveLoanApplicableCharges(feeChargesOnly);
|
Collection<ChargeData> chargeOptions = this.chargeReadPlatformService.retrieveLoanApplicableCharges(feeChargesOnly);
|
||||||
|
|||||||
+4
-3
@@ -12,6 +12,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
|
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
|
||||||
|
import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper;
|
||||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||||
@@ -67,7 +68,7 @@ public class LoanProductData {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final Map<String, Object> accountingMappings;
|
private final Map<String, Object> accountingMappings;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final Map<Long, Long> paymentChannelToFundSourceMappings;
|
private final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings;
|
||||||
|
|
||||||
// template related
|
// template related
|
||||||
private final Collection<FundData> fundOptions;
|
private final Collection<FundData> fundOptions;
|
||||||
@@ -191,7 +192,7 @@ public class LoanProductData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LoanProductData withAccountingDetails(final LoanProductData productData, final Map<String, Object> accountingMappings,
|
public static LoanProductData withAccountingDetails(final LoanProductData productData, final Map<String, Object> accountingMappings,
|
||||||
final Map<Long, Long> paymentChannelToFundSourceMappings) {
|
final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings) {
|
||||||
|
|
||||||
return new LoanProductData(productData, productData.chargeOptions, productData.paymentTypeOptions, productData.currencyOptions,
|
return new LoanProductData(productData, productData.chargeOptions, productData.paymentTypeOptions, productData.currencyOptions,
|
||||||
productData.amortizationTypeOptions, productData.interestTypeOptions, productData.interestCalculationPeriodTypeOptions,
|
productData.amortizationTypeOptions, productData.interestTypeOptions, productData.interestCalculationPeriodTypeOptions,
|
||||||
@@ -270,7 +271,7 @@ public class LoanProductData {
|
|||||||
final List<EnumOptionData> interestRateFrequencyTypeOptions, final Collection<FundData> fundOptions,
|
final List<EnumOptionData> interestRateFrequencyTypeOptions, final Collection<FundData> fundOptions,
|
||||||
final Collection<TransactionProcessingStrategyData> transactionStrategyOptions,
|
final Collection<TransactionProcessingStrategyData> transactionStrategyOptions,
|
||||||
final Map<String, List<GLAccountData>> accountingMappingOptions, final List<EnumOptionData> accountingRuleOptions,
|
final Map<String, List<GLAccountData>> accountingMappingOptions, final List<EnumOptionData> accountingRuleOptions,
|
||||||
final Map<String, Object> accountingMappings, final Map<Long, Long> paymentChannelToFundSourceMappings) {
|
final Map<String, Object> accountingMappings, final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings) {
|
||||||
this.id = productData.id;
|
this.id = productData.id;
|
||||||
this.name = productData.name;
|
this.name = productData.name;
|
||||||
this.description = productData.description;
|
this.description = productData.description;
|
||||||
|
|||||||
+1
-1
@@ -483,7 +483,7 @@ public final class LoanProductCommandFromApiJsonDeserializer {
|
|||||||
if (fromApiJsonHelper.parameterExists(LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element)) {
|
if (fromApiJsonHelper.parameterExists(LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element)) {
|
||||||
JsonArray paymentChannelMappingArray = fromApiJsonHelper.extractJsonArrayNamed(
|
JsonArray paymentChannelMappingArray = fromApiJsonHelper.extractJsonArrayNamed(
|
||||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
|
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
|
||||||
if (paymentChannelMappingArray != null) {
|
if (paymentChannelMappingArray != null && paymentChannelMappingArray.size() > 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do {
|
do {
|
||||||
final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject();
|
final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject();
|
||||||
|
|||||||
Reference in New Issue
Block a user