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(
|
||||
"incomeFromFeeAccountId"), INCOME_FROM_PENALTIES("incomeFromPenaltyAccountId"), LOSSES_WRITTEN_OFF("writeOffAccountId"), INTEREST_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");
|
||||
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper;
|
||||
|
||||
public interface ProductToGLAccountMappingReadPlatformService {
|
||||
|
||||
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.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
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.CASH_ACCOUNTS_FOR_LOAN;
|
||||
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.portfolio.loanproduct.domain.AccountingRuleType;
|
||||
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 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 });
|
||||
|
||||
@@ -128,8 +130,8 @@ public class ProductToGLAccountMappingReadPlatformServiceImpl implements Product
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, Long> fetchPaymentTypeToFundSourceMappingsForLoanProduct(Long loanProductId) {
|
||||
Map<Long, Long> paymentTypeToFundSourceMappingDetails = null;
|
||||
public List<PaymentTypeToGLAccountMapper> fetchPaymentTypeToFundSourceMappingsForLoanProduct(Long loanProductId) {
|
||||
List<PaymentTypeToGLAccountMapper> paymentTypeToGLAccountMappers = null;
|
||||
|
||||
final LoanProductToGLAccountMappingMapper rm = new LoanProductToGLAccountMappingMapper();
|
||||
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 });
|
||||
|
||||
for (final Map<String, Object> productToGLAccountMap : paymentTypeToFundSourceMappingsList) {
|
||||
if (paymentTypeToFundSourceMappingDetails == null) {
|
||||
paymentTypeToFundSourceMappingDetails = new LinkedHashMap<Long, Long>();
|
||||
if (paymentTypeToGLAccountMappers == null) {
|
||||
paymentTypeToGLAccountMappers = new ArrayList<PaymentTypeToGLAccountMapper>();
|
||||
}
|
||||
final Long glAccountId = (Long) productToGLAccountMap.get("glAccountId");
|
||||
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 element
|
||||
@@ -239,11 +239,11 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
**/
|
||||
else {
|
||||
for (ProductToGLAccountMapping existingPaymentChannelToFundSourceMapping : existingPaymentChannelToFundSourceMappings) {
|
||||
Long currentPaymentChannelId = existingPaymentChannelToFundSourceMapping.getId();
|
||||
Long currentPaymentChannelId = existingPaymentChannelToFundSourceMapping.getPaymentType().getId();
|
||||
existingPaymentTypes.add(currentPaymentChannelId);
|
||||
// update existing mappings (if required)
|
||||
if (inputPaymentChannelFundSourceMap.containsKey(existingPaymentChannelToFundSourceMapping.getId())) {
|
||||
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(existingPaymentChannelToFundSourceMapping.getId());
|
||||
if (inputPaymentChannelFundSourceMap.containsKey(currentPaymentChannelId)) {
|
||||
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(currentPaymentChannelId);
|
||||
if (newGLAccountId != existingPaymentChannelToFundSourceMapping.getGlAccount().getId()) {
|
||||
final GLAccount glAccount = getAccountByIdAndType(LOAN_PRODUCT_ACCOUNTING_PARAMS.FUND_SOURCE.getValue(),
|
||||
GLAccountType.ASSET, newGLAccountId);
|
||||
@@ -257,12 +257,12 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
||||
}
|
||||
// create new mappings
|
||||
Set<Long> incomingPaymentTypes = inputPaymentChannelFundSourceMap.keySet();
|
||||
boolean newPaymentTypesAdded = incomingPaymentTypes.removeAll(existingPaymentTypes);
|
||||
if (newPaymentTypesAdded) {
|
||||
for (Long newPaymentType : incomingPaymentTypes) {
|
||||
Long newGLAccountId = inputPaymentChannelFundSourceMap.get(newPaymentType);
|
||||
savePaymentChannelToFundSourceMapping(productId, newPaymentType, newGLAccountId);
|
||||
}
|
||||
incomingPaymentTypes.removeAll(existingPaymentTypes);
|
||||
// incomingPaymentTypes now only contains the newly added
|
||||
// payment Type mappings
|
||||
for (Long newPaymentType : incomingPaymentTypes) {
|
||||
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.domain.GLAccountType;
|
||||
import org.mifosplatform.accounting.glaccount.service.GLAccountReadPlatformService;
|
||||
import org.mifosplatform.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper;
|
||||
import org.mifosplatform.accounting.producttoaccountmapping.service.ProductToGLAccountMappingReadPlatformService;
|
||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||
@@ -161,7 +162,7 @@ public class LoanProductsApiResource {
|
||||
LoanProductData loanProduct = this.loanProductReadPlatformService.retrieveLoanProduct(productId);
|
||||
|
||||
Map<String, Object> accountingMappings = null;
|
||||
Map<Long, Long> paymentChannelToFundSourceMappings = null;
|
||||
Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings = null;
|
||||
if (loanProduct.hasAccountingEnabled()) {
|
||||
accountingMappings = accountMappingReadPlatformService.fetchAccountMappingDetailsForLoanProduct(productId, loanProduct
|
||||
.accountingRuleType().getId().intValue());
|
||||
@@ -191,7 +192,7 @@ public class LoanProductsApiResource {
|
||||
}
|
||||
|
||||
private LoanProductData handleTemplate(final LoanProductData productData, final Map<String, Object> accountingMappings,
|
||||
final Map<Long, Long> paymentChannelToFundSourceMappings) {
|
||||
final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings) {
|
||||
|
||||
final boolean feeChargesOnly = true;
|
||||
Collection<ChargeData> chargeOptions = this.chargeReadPlatformService.retrieveLoanApplicableCharges(feeChargesOnly);
|
||||
|
||||
+4
-3
@@ -12,6 +12,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.core.data.EnumOptionData;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
@@ -67,7 +68,7 @@ public class LoanProductData {
|
||||
@SuppressWarnings("unused")
|
||||
private final Map<String, Object> accountingMappings;
|
||||
@SuppressWarnings("unused")
|
||||
private final Map<Long, Long> paymentChannelToFundSourceMappings;
|
||||
private final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings;
|
||||
|
||||
// template related
|
||||
private final Collection<FundData> fundOptions;
|
||||
@@ -191,7 +192,7 @@ public class LoanProductData {
|
||||
}
|
||||
|
||||
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,
|
||||
productData.amortizationTypeOptions, productData.interestTypeOptions, productData.interestCalculationPeriodTypeOptions,
|
||||
@@ -270,7 +271,7 @@ public class LoanProductData {
|
||||
final List<EnumOptionData> interestRateFrequencyTypeOptions, final Collection<FundData> fundOptions,
|
||||
final Collection<TransactionProcessingStrategyData> transactionStrategyOptions,
|
||||
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.name = productData.name;
|
||||
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)) {
|
||||
JsonArray paymentChannelMappingArray = fromApiJsonHelper.extractJsonArrayNamed(
|
||||
LOAN_PRODUCT_ACCOUNTING_PARAMS.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), element);
|
||||
if (paymentChannelMappingArray != null) {
|
||||
if (paymentChannelMappingArray != null && paymentChannelMappingArray.size() > 0) {
|
||||
int i = 0;
|
||||
do {
|
||||
final JsonObject jsonObject = paymentChannelMappingArray.get(i).getAsJsonObject();
|
||||
|
||||
Reference in New Issue
Block a user