Merge pull request #949 from vishwasbabu/develop
Rewriting Financial Activity Account Mapping
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
update m_permission set entity_name="FINANCIALACTIVITYACCOUNT" where entity_name="OFFICEGLACCOUNT";
|
||||||
|
update m_permission set code="READ_FINANCIALACTIVITYACCOUNT" where code="READ_OFFICEGLACCOUNT";
|
||||||
|
update m_permission set code="CREATE_FINANCIALACTIVITYACCOUNT" where code="CREATE_OFFICEGLACCOUNT";
|
||||||
|
update m_permission set code="DELETE_FINANCIALACTIVITYACCOUNT" where code="DELETE_OFFICEGLACCOUNT";
|
||||||
|
update m_permission set code="UPDATE_FINANCIALACTIVITYACCOUNT" where code="UPDATE_OFFICEGLACCOUNT";
|
||||||
+4
-32
@@ -2,25 +2,19 @@ package org.mifosplatform.integrationtests;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
|
||||||
import org.mifosplatform.integrationtests.common.OfficeHelper;
|
import org.mifosplatform.integrationtests.common.OfficeHelper;
|
||||||
import org.mifosplatform.integrationtests.common.Utils;
|
import org.mifosplatform.integrationtests.common.Utils;
|
||||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||||
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
||||||
|
import org.mifosplatform.integrationtests.common.accounting.FinancialActivityAccountsHelper;
|
||||||
import org.mifosplatform.integrationtests.common.accounting.JournalEntry;
|
import org.mifosplatform.integrationtests.common.accounting.JournalEntry;
|
||||||
import org.mifosplatform.integrationtests.common.accounting.JournalEntryHelper;
|
import org.mifosplatform.integrationtests.common.accounting.JournalEntryHelper;
|
||||||
import org.mifosplatform.integrationtests.common.accounting.OfficeAccountMappingHelper;
|
|
||||||
import org.mifosplatform.integrationtests.common.charges.ChargesHelper;
|
|
||||||
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
|
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
|
||||||
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
||||||
import org.mifosplatform.integrationtests.common.loans.LoanStatusChecker;
|
import org.mifosplatform.integrationtests.common.loans.LoanStatusChecker;
|
||||||
@@ -98,11 +92,8 @@ public class AccountTransferTest {
|
|||||||
Account toTransferAccount = accountHelper.createLiabilityAccount();
|
Account toTransferAccount = accountHelper.createLiabilityAccount();
|
||||||
Assert.assertNotNull(toTransferAccount);
|
Assert.assertNotNull(toTransferAccount);
|
||||||
|
|
||||||
OfficeAccountMappingHelper accountMappingHelper = new OfficeAccountMappingHelper(this.requestSpec,
|
FinancialActivityAccountsHelper accountMappingHelper = new FinancialActivityAccountsHelper(this.requestSpec,
|
||||||
new ResponseSpecBuilder().build());
|
new ResponseSpecBuilder().build());
|
||||||
Integer toTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(toOfficeId,
|
|
||||||
toTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
|
||||||
Assert.assertNotNull(toTransferAccountMappingId);
|
|
||||||
|
|
||||||
final Integer toSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, assetAccount,
|
final Integer toSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, assetAccount,
|
||||||
incomeAccount, expenseAccount, liabilityAccount);
|
incomeAccount, expenseAccount, liabilityAccount);
|
||||||
@@ -134,10 +125,6 @@ public class AccountTransferTest {
|
|||||||
Account fromTransferAccount = accountHelper.createLiabilityAccount();
|
Account fromTransferAccount = accountHelper.createLiabilityAccount();
|
||||||
Assert.assertNotNull(fromTransferAccount);
|
Assert.assertNotNull(fromTransferAccount);
|
||||||
|
|
||||||
Integer fromTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(fromOfficeId,
|
|
||||||
fromTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
|
||||||
Assert.assertNotNull(fromTransferAccountMappingId);
|
|
||||||
|
|
||||||
final Integer fromSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
final Integer fromSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||||
assetAccount, incomeAccount, expenseAccount, liabilityAccount);
|
assetAccount, incomeAccount, expenseAccount, liabilityAccount);
|
||||||
Assert.assertNotNull(fromSavingsProductID);
|
Assert.assertNotNull(fromSavingsProductID);
|
||||||
@@ -213,11 +200,8 @@ public class AccountTransferTest {
|
|||||||
Account toTransferAccount = accountHelper.createLiabilityAccount();
|
Account toTransferAccount = accountHelper.createLiabilityAccount();
|
||||||
Assert.assertNotNull(toTransferAccount);
|
Assert.assertNotNull(toTransferAccount);
|
||||||
|
|
||||||
OfficeAccountMappingHelper accountMappingHelper = new OfficeAccountMappingHelper(this.requestSpec,
|
FinancialActivityAccountsHelper accountMappingHelper = new FinancialActivityAccountsHelper(this.requestSpec,
|
||||||
new ResponseSpecBuilder().build());
|
new ResponseSpecBuilder().build());
|
||||||
Integer toTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(toOfficeId,
|
|
||||||
toTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
|
||||||
Assert.assertNotNull(toTransferAccountMappingId);
|
|
||||||
|
|
||||||
final Integer toLoanProductID = createLoanProduct(loanAssetAccount, loanIncomeAccount, loanExpenseAccount, overpaymentAccount);
|
final Integer toLoanProductID = createLoanProduct(loanAssetAccount, loanIncomeAccount, loanExpenseAccount, overpaymentAccount);
|
||||||
Assert.assertNotNull(toLoanProductID);
|
Assert.assertNotNull(toLoanProductID);
|
||||||
@@ -245,10 +229,6 @@ public class AccountTransferTest {
|
|||||||
Account fromTransferAccount = accountHelper.createLiabilityAccount();
|
Account fromTransferAccount = accountHelper.createLiabilityAccount();
|
||||||
Assert.assertNotNull(fromTransferAccount);
|
Assert.assertNotNull(fromTransferAccount);
|
||||||
|
|
||||||
Integer fromTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(fromOfficeId,
|
|
||||||
fromTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
|
||||||
Assert.assertNotNull(fromTransferAccountMappingId);
|
|
||||||
|
|
||||||
final Integer fromSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
final Integer fromSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||||
assetAccount, incomeAccount, expenseAccount, liabilityAccount);
|
assetAccount, incomeAccount, expenseAccount, liabilityAccount);
|
||||||
Assert.assertNotNull(fromSavingsProductID);
|
Assert.assertNotNull(fromSavingsProductID);
|
||||||
@@ -322,11 +302,8 @@ public class AccountTransferTest {
|
|||||||
Account toTransferAccount = accountHelper.createLiabilityAccount();
|
Account toTransferAccount = accountHelper.createLiabilityAccount();
|
||||||
Assert.assertNotNull(toTransferAccount);
|
Assert.assertNotNull(toTransferAccount);
|
||||||
|
|
||||||
OfficeAccountMappingHelper accountMappingHelper = new OfficeAccountMappingHelper(this.requestSpec,
|
FinancialActivityAccountsHelper accountMappingHelper = new FinancialActivityAccountsHelper(this.requestSpec,
|
||||||
new ResponseSpecBuilder().build());
|
new ResponseSpecBuilder().build());
|
||||||
Integer toTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(toOfficeId,
|
|
||||||
toTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
|
||||||
Assert.assertNotNull(toTransferAccountMappingId);
|
|
||||||
|
|
||||||
final Integer toSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, assetAccount,
|
final Integer toSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE, assetAccount,
|
||||||
incomeAccount, expenseAccount, liabilityAccount);
|
incomeAccount, expenseAccount, liabilityAccount);
|
||||||
@@ -356,10 +333,6 @@ public class AccountTransferTest {
|
|||||||
Account fromTransferAccount = accountHelper.createLiabilityAccount();
|
Account fromTransferAccount = accountHelper.createLiabilityAccount();
|
||||||
Assert.assertNotNull(fromTransferAccount);
|
Assert.assertNotNull(fromTransferAccount);
|
||||||
|
|
||||||
Integer fromTransferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(fromOfficeId,
|
|
||||||
fromTransferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
|
||||||
Assert.assertNotNull(fromTransferAccountMappingId);
|
|
||||||
|
|
||||||
final Integer loanProductID = createLoanProduct(loanAssetAccount, loanIncomeAccount, loanExpenseAccount, overpaymentAccount);
|
final Integer loanProductID = createLoanProduct(loanAssetAccount, loanIncomeAccount, loanExpenseAccount, overpaymentAccount);
|
||||||
Assert.assertNotNull(loanProductID);
|
Assert.assertNotNull(loanProductID);
|
||||||
|
|
||||||
@@ -375,7 +348,6 @@ public class AccountTransferTest {
|
|||||||
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSAL_DATE, loanID);
|
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSAL_DATE, loanID);
|
||||||
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
|
||||||
|
|
||||||
|
|
||||||
final Integer fromSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
final Integer fromSavingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
|
||||||
assetAccount, incomeAccount, expenseAccount, liabilityAccount);
|
assetAccount, incomeAccount, expenseAccount, liabilityAccount);
|
||||||
Assert.assertNotNull(fromSavingsProductID);
|
Assert.assertNotNull(fromSavingsProductID);
|
||||||
|
|||||||
+7
-13
@@ -10,11 +10,10 @@ import junit.framework.Assert;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mifosplatform.integrationtests.common.CommonConstants;
|
import org.mifosplatform.integrationtests.common.CommonConstants;
|
||||||
import org.mifosplatform.integrationtests.common.OfficeHelper;
|
|
||||||
import org.mifosplatform.integrationtests.common.Utils;
|
import org.mifosplatform.integrationtests.common.Utils;
|
||||||
import org.mifosplatform.integrationtests.common.accounting.Account;
|
import org.mifosplatform.integrationtests.common.accounting.Account;
|
||||||
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
import org.mifosplatform.integrationtests.common.accounting.AccountHelper;
|
||||||
import org.mifosplatform.integrationtests.common.accounting.OfficeAccountMappingHelper;
|
import org.mifosplatform.integrationtests.common.accounting.FinancialActivityAccountsHelper;
|
||||||
|
|
||||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||||
@@ -36,22 +35,16 @@ public class OfficeAccountingMappingsTest {
|
|||||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Test
|
@Test
|
||||||
public void testOfficeAccountingMappings() {
|
public void testFinancialActivityAccounts() {
|
||||||
|
|
||||||
OfficeHelper officeHelper = new OfficeHelper(this.requestSpec, this.responseSpec);
|
|
||||||
Integer officeId = officeHelper.createOffice("01 January 2014");
|
|
||||||
Assert.assertNotNull(officeId);
|
|
||||||
|
|
||||||
Integer officeId2 = officeHelper.createOffice("01 January 2014");
|
|
||||||
Assert.assertNotNull(officeId2);
|
|
||||||
|
|
||||||
AccountHelper accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
AccountHelper accountHelper = new AccountHelper(this.requestSpec, this.responseSpec);
|
||||||
Account transferAccount = accountHelper.createLiabilityAccount();
|
Account transferAccount = accountHelper.createLiabilityAccount();
|
||||||
Assert.assertNotNull(transferAccount);
|
Assert.assertNotNull(transferAccount);
|
||||||
|
|
||||||
OfficeAccountMappingHelper accountMappingHelper = new OfficeAccountMappingHelper(this.requestSpec,
|
FinancialActivityAccountsHelper accountMappingHelper = new FinancialActivityAccountsHelper(this.requestSpec,
|
||||||
new ResponseSpecBuilder().build());
|
new ResponseSpecBuilder().build());
|
||||||
Integer transferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(officeId,
|
Integer transferAccountMappingId = (Integer) accountMappingHelper.createOfficeAccountMapping(officeId,
|
||||||
transferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
transferAccount.getAccountID(), CommonConstants.RESPONSE_RESOURCE_ID);
|
||||||
@@ -86,8 +79,9 @@ public class OfficeAccountingMappingsTest {
|
|||||||
|
|
||||||
List<HashMap> error3 = (List<HashMap>) accountMappingHelper.createOfficeAccountMapping(officeId2, fundAccount.getAccountID(),
|
List<HashMap> error3 = (List<HashMap>) accountMappingHelper.createOfficeAccountMapping(officeId2, fundAccount.getAccountID(),
|
||||||
CommonConstants.RESPONSE_ERROR);
|
CommonConstants.RESPONSE_ERROR);
|
||||||
assertEquals("error.msg.liabilityTransferInSuspenseAccountId.invalid.account.type", error3.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
assertEquals("error.msg.liabilityTransferInSuspenseAccountId.invalid.account.type",
|
||||||
|
error3.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||||
|
|
||||||
}
|
}**/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -8,30 +8,30 @@ import com.jayway.restassured.specification.RequestSpecification;
|
|||||||
import com.jayway.restassured.specification.ResponseSpecification;
|
import com.jayway.restassured.specification.ResponseSpecification;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class OfficeAccountMappingHelper {
|
public class FinancialActivityAccountsHelper {
|
||||||
|
|
||||||
private static final String ACCOUNT_MAPPING_URL = "/mifosng-provider/api/v1/officeglaccounts";
|
private static final String ACCOUNT_MAPPING_URL = "/mifosng-provider/api/v1/financialactivityaccounts";
|
||||||
private final RequestSpecification requestSpec;
|
private final RequestSpecification requestSpec;
|
||||||
private final ResponseSpecification responseSpec;
|
private final ResponseSpecification responseSpec;
|
||||||
|
|
||||||
public OfficeAccountMappingHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
public FinancialActivityAccountsHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||||
this.requestSpec = requestSpec;
|
this.requestSpec = requestSpec;
|
||||||
this.responseSpec = responseSpec;
|
this.responseSpec = responseSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object createOfficeAccountMapping(Integer officeId, Integer glAccountId, String jsonBack) {
|
public Object createFinancialactivityaccounts(Integer officeId, Integer glAccountId, String jsonBack) {
|
||||||
String json = OfficeAccountMappingBuilder.build(officeId, glAccountId);
|
String json = OfficeAccountMappingBuilder.build(officeId, glAccountId);
|
||||||
return Utils.performServerPost(this.requestSpec, this.responseSpec, ACCOUNT_MAPPING_URL + "?" + Utils.TENANT_IDENTIFIER, json,
|
return Utils.performServerPost(this.requestSpec, this.responseSpec, ACCOUNT_MAPPING_URL + "?" + Utils.TENANT_IDENTIFIER, json,
|
||||||
jsonBack);
|
jsonBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object updateOfficeAccountMapping(Integer mappingId, Integer officeId, Integer glAccountId, String jsonBack) {
|
public Object updateFinancialactivityaccounts(Integer mappingId, Integer officeId, Integer glAccountId, String jsonBack) {
|
||||||
String json = OfficeAccountMappingBuilder.build(officeId, glAccountId);
|
String json = OfficeAccountMappingBuilder.build(officeId, glAccountId);
|
||||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, ACCOUNT_MAPPING_URL + "/" + mappingId + "?"
|
return Utils.performServerPut(this.requestSpec, this.responseSpec, ACCOUNT_MAPPING_URL + "/" + mappingId + "?"
|
||||||
+ Utils.TENANT_IDENTIFIER, json, jsonBack);
|
+ Utils.TENANT_IDENTIFIER, json, jsonBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap getOfficeAccountMapping(final Integer mappingId) {
|
public HashMap getFinancialactivityaccount(final Integer mappingId) {
|
||||||
final String URL = ACCOUNT_MAPPING_URL + "/" + mappingId + "?" + Utils.TENANT_IDENTIFIER;
|
final String URL = ACCOUNT_MAPPING_URL + "/" + mappingId + "?" + Utils.TENANT_IDENTIFIER;
|
||||||
return Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
return Utils.performServerGet(requestSpec, responseSpec, URL, "");
|
||||||
}
|
}
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
package org.mifosplatform.accounting.accountmapping.data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
|
|
||||||
|
|
||||||
public class FinancialActivityAccountData {
|
|
||||||
|
|
||||||
private final Long id;
|
|
||||||
private final GLAccountData glAccountData;
|
|
||||||
private final Map<String, List<GLAccountData>> accountingMappingOptions;
|
|
||||||
|
|
||||||
public static FinancialActivityAccountData instance(final Long id, final GLAccountData glAccountData) {
|
|
||||||
final Map<String, List<GLAccountData>> accountingMappingOptions = null;
|
|
||||||
return new FinancialActivityAccountData(id, glAccountData, accountingMappingOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FinancialActivityAccountData template(final Map<String, List<GLAccountData>> accountingMappingOptions) {
|
|
||||||
final Long id = null;
|
|
||||||
final GLAccountData glAccountData = null;
|
|
||||||
return new FinancialActivityAccountData(id, glAccountData, accountingMappingOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FinancialActivityAccountData associateTemplateData(final FinancialActivityAccountData templateData,
|
|
||||||
final FinancialActivityAccountData accountMappingData) {
|
|
||||||
return new FinancialActivityAccountData(accountMappingData.id, accountMappingData.glAccountData,
|
|
||||||
templateData.accountingMappingOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
private FinancialActivityAccountData(final Long id, final GLAccountData glAccountData,
|
|
||||||
final Map<String, List<GLAccountData>> accountingMappingOptions) {
|
|
||||||
this.id = id;
|
|
||||||
this.glAccountData = glAccountData;
|
|
||||||
this.accountingMappingOptions = accountingMappingOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
package org.mifosplatform.accounting.accountmapping.exception;
|
|
||||||
|
|
||||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@link RuntimeException} thrown when Calendar resources are not found.
|
|
||||||
*/
|
|
||||||
public class MappingUpdateNotSupportedException extends AbstractPlatformDomainRuleException {
|
|
||||||
|
|
||||||
public MappingUpdateNotSupportedException(final String postFix, final String defaultUserMessage,
|
|
||||||
final Object... defaultUserMessageArgs) {
|
|
||||||
super("error.msg.officeToAccountMapping.update.of." + postFix + ".is.not.supported", defaultUserMessage, defaultUserMessageArgs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-90
@@ -1,90 +0,0 @@
|
|||||||
/**
|
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
package org.mifosplatform.accounting.accountmapping.serialization;
|
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.mifosplatform.accounting.common.AccountingConstants.ORGANIZATION_ACCOUNTING_PARAMS;
|
|
||||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
|
||||||
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
|
||||||
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
|
||||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
|
||||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public final class FinancialActivityAccountDataValidator {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The parameters supported for this command.
|
|
||||||
*/
|
|
||||||
private final Set<String> supportedParameters = new HashSet<String>(Arrays.asList("locale",
|
|
||||||
ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue()));
|
|
||||||
|
|
||||||
private final FromJsonHelper fromApiJsonHelper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public FinancialActivityAccountDataValidator(final FromJsonHelper fromApiJsonHelper) {
|
|
||||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void validateForCreate(final String json) {
|
|
||||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
|
||||||
|
|
||||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
|
||||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
|
||||||
|
|
||||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
|
||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loanproduct");
|
|
||||||
|
|
||||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
|
||||||
|
|
||||||
final Long liabilityTransferInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
|
|
||||||
ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue(), element);
|
|
||||||
baseDataValidator.reset().parameter(ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue())
|
|
||||||
.value(liabilityTransferInSuspenseAccountId).notNull().integerGreaterThanZero();
|
|
||||||
|
|
||||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void validateForUpdate(final String json) {
|
|
||||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
|
||||||
|
|
||||||
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
|
||||||
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
|
||||||
|
|
||||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
|
||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loanproduct");
|
|
||||||
|
|
||||||
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
|
||||||
|
|
||||||
if (this.fromApiJsonHelper.parameterExists(ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue(), element)) {
|
|
||||||
final Long liabilityTransferInSuspenseAccountId = this.fromApiJsonHelper.extractLongNamed(
|
|
||||||
ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue(), element);
|
|
||||||
baseDataValidator.reset().parameter(ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue())
|
|
||||||
.value(liabilityTransferInSuspenseAccountId).notNull().integerGreaterThanZero();
|
|
||||||
}
|
|
||||||
|
|
||||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
|
||||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
|
||||||
"Validation errors exist.", dataValidationErrors); }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-141
@@ -1,141 +0,0 @@
|
|||||||
package org.mifosplatform.accounting.accountmapping.service;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.mifosplatform.accounting.accountmapping.domain.FinancialActivityAccount;
|
|
||||||
import org.mifosplatform.accounting.accountmapping.domain.FinancialActivityAccountRepositoryWrapper;
|
|
||||||
import org.mifosplatform.accounting.accountmapping.exception.DuplicateFinancialActivityAccountFoundException;
|
|
||||||
import org.mifosplatform.accounting.accountmapping.serialization.FinancialActivityAccountDataValidator;
|
|
||||||
import org.mifosplatform.accounting.common.AccountingConstants.ORGANIZATION_ACCOUNTING_PARAMS;
|
|
||||||
import org.mifosplatform.accounting.common.AccountingConstants.ORGANIZATION_ACCOUNTS;
|
|
||||||
import org.mifosplatform.accounting.glaccount.domain.GLAccount;
|
|
||||||
import org.mifosplatform.accounting.glaccount.domain.GLAccountRepositoryWrapper;
|
|
||||||
import org.mifosplatform.accounting.glaccount.domain.GLAccountType;
|
|
||||||
import org.mifosplatform.accounting.producttoaccountmapping.exception.ProductToGLAccountMappingInvalidException;
|
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
|
||||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class FinancialActivityAccountWritePlatformServiceImpl implements FinancialActivityAccountWritePlatformService {
|
|
||||||
|
|
||||||
private final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepository;
|
|
||||||
private final FinancialActivityAccountDataValidator fromApiJsonDeserializer;
|
|
||||||
private final FromJsonHelper fromApiJsonHelper;
|
|
||||||
private final GLAccountRepositoryWrapper glAccountRepositoryWrapper;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public FinancialActivityAccountWritePlatformServiceImpl(
|
|
||||||
final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepository,
|
|
||||||
final FinancialActivityAccountDataValidator fromApiJsonDeserializer, final FromJsonHelper fromApiJsonHelper,
|
|
||||||
final GLAccountRepositoryWrapper glAccountRepositoryWrapper) {
|
|
||||||
this.financialActivityAccountRepository = financialActivityAccountRepository;
|
|
||||||
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
|
||||||
this.fromApiJsonHelper = fromApiJsonHelper;
|
|
||||||
this.glAccountRepositoryWrapper = glAccountRepositoryWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandProcessingResult createGLAccountActivityMapping(JsonCommand command) {
|
|
||||||
|
|
||||||
this.fromApiJsonDeserializer.validateForCreate(command.json());
|
|
||||||
final JsonElement element = this.fromApiJsonHelper.parse(command.json());
|
|
||||||
FinancialActivityAccount financialActivityAccount = createLiabilityTrasferSuspenceMapping(element);
|
|
||||||
checkForExistingMapping(financialActivityAccount);
|
|
||||||
this.financialActivityAccountRepository.save(financialActivityAccount);
|
|
||||||
return new CommandProcessingResultBuilder() //
|
|
||||||
.withCommandId(command.commandId()) //
|
|
||||||
.withEntityId(financialActivityAccount.getId()) //
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkForExistingMapping(final FinancialActivityAccount financialActivityAccount) {
|
|
||||||
FinancialActivityAccount existingMapping = this.financialActivityAccountRepository
|
|
||||||
.findByFinancialActivityType(financialActivityAccount.getFinancialActivityType());
|
|
||||||
if (existingMapping != null) { throw new DuplicateFinancialActivityAccountFoundException(
|
|
||||||
financialActivityAccount.getFinancialActivityType()); }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandProcessingResult updateGLAccountActivityMapping(Long mappingId, JsonCommand command) {
|
|
||||||
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
|
||||||
final FinancialActivityAccount financialActivityAccount = this.financialActivityAccountRepository
|
|
||||||
.findOneWithNotFoundDetection(mappingId);
|
|
||||||
Map<String, Object> changes = findChanges(command, financialActivityAccount);
|
|
||||||
final JsonElement element = this.fromApiJsonHelper.parse(command.json());
|
|
||||||
|
|
||||||
if (changes.containsKey(ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue())) {
|
|
||||||
final GLAccount glAccount = fetchGLAccount(element, ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue(),
|
|
||||||
GLAccountType.LIABILITY);
|
|
||||||
financialActivityAccount.updateGlAccount(glAccount);
|
|
||||||
this.financialActivityAccountRepository.save(financialActivityAccount);
|
|
||||||
}
|
|
||||||
return new CommandProcessingResultBuilder() //
|
|
||||||
.withCommandId(command.commandId()) //
|
|
||||||
.withEntityId(mappingId) //
|
|
||||||
.with(changes) //
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandProcessingResult deleteGLAccountActivityMapping(Long mappingId, JsonCommand command) {
|
|
||||||
final FinancialActivityAccount officeToGLAccountMapping = this.financialActivityAccountRepository
|
|
||||||
.findOneWithNotFoundDetection(mappingId);
|
|
||||||
this.financialActivityAccountRepository.delete(officeToGLAccountMapping);
|
|
||||||
return new CommandProcessingResultBuilder() //
|
|
||||||
.withCommandId(command.commandId()) //
|
|
||||||
.withEntityId(mappingId) //
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private FinancialActivityAccount createLiabilityTrasferSuspenceMapping(final JsonElement element) {
|
|
||||||
final GLAccount glAccount = fetchGLAccount(element, ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue(),
|
|
||||||
GLAccountType.LIABILITY);
|
|
||||||
final Integer financialAccountType = ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue();
|
|
||||||
return FinancialActivityAccount.createNew(glAccount, financialAccountType);
|
|
||||||
}
|
|
||||||
|
|
||||||
private GLAccount fetchGLAccount(final JsonElement element, final String paramName, final GLAccountType expectedAccountType) {
|
|
||||||
final Long accountId = this.fromApiJsonHelper.extractLongNamed(paramName, element);
|
|
||||||
final GLAccount glAccount = getAccountByIdAndType(paramName, expectedAccountType, accountId);
|
|
||||||
return glAccount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches account with a particular Id and throws and Exception it is not
|
|
||||||
* of the expected Account Category ('ASSET','liability' etc)
|
|
||||||
*
|
|
||||||
* @param paramName
|
|
||||||
* @param expectedAccountType
|
|
||||||
* @param accountId
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public GLAccount getAccountByIdAndType(final String paramName, final GLAccountType expectedAccountType, final Long accountId) {
|
|
||||||
final GLAccount glAccount = this.glAccountRepositoryWrapper.findOneWithNotFoundDetection(accountId);
|
|
||||||
// validate account is of the expected Type
|
|
||||||
if (glAccount.getType().intValue() != expectedAccountType.getValue()) { throw new ProductToGLAccountMappingInvalidException(
|
|
||||||
paramName, glAccount.getName(), accountId, GLAccountType.fromInt(glAccount.getType()).toString(),
|
|
||||||
expectedAccountType.toString()); }
|
|
||||||
return glAccount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Object> findChanges(JsonCommand command, FinancialActivityAccount financialActivityAccount) {
|
|
||||||
|
|
||||||
Map<String, Object> changes = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
Long existingGLAccountId = financialActivityAccount.glAccount().getId();
|
|
||||||
if (command
|
|
||||||
.isChangeInLongParameterNamed(ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue(), existingGLAccountId)) {
|
|
||||||
final Long newValue = command.longValueOfParameterNamed(ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue());
|
|
||||||
changes.put(ORGANIZATION_ACCOUNTING_PARAMS.LIABILITY_TRANSFER_SUSPENSE.getValue(), newValue);
|
|
||||||
}
|
|
||||||
return changes;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+44
-47
@@ -5,9 +5,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.common;
|
package org.mifosplatform.accounting.common;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.data.FinancialActivityData;
|
||||||
|
import org.mifosplatform.accounting.glaccount.domain.GLAccountType;
|
||||||
|
|
||||||
public class AccountingConstants {
|
public class AccountingConstants {
|
||||||
|
|
||||||
/*** Accounting placeholders for cash based accounting for loan products ***/
|
/*** Accounting placeholders for cash based accounting for loan products ***/
|
||||||
@@ -215,13 +220,18 @@ public class AccountingConstants {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum ORGANIZATION_ACCOUNTS {
|
public static enum FINANCIAL_ACTIVITY {
|
||||||
LIABILITY_TRANSFER_SUSPENSE(100);
|
ASSET_TRANSFER(100, "assetTransfer", GLAccountType.ASSET), LIABILITY_TRANSFER(200, "liabilityTransfer", GLAccountType.LIABILITY);
|
||||||
|
|
||||||
private final Integer value;
|
private final Integer value;
|
||||||
|
private final String code;
|
||||||
|
private final GLAccountType mappedGLAccountType;
|
||||||
|
private static List<FinancialActivityData> financialActivities;
|
||||||
|
|
||||||
private ORGANIZATION_ACCOUNTS(final Integer value) {
|
private FINANCIAL_ACTIVITY(final Integer value, final String code, final GLAccountType mappedGLAccountType) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
this.code = code;
|
||||||
|
this.mappedGLAccountType = mappedGLAccountType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -233,62 +243,49 @@ public class AccountingConstants {
|
|||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<Integer, ORGANIZATION_ACCOUNTS> intToEnumMap = new HashMap<Integer, ORGANIZATION_ACCOUNTS>();
|
public String getCode() {
|
||||||
|
return this.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GLAccountType getMappedGLAccountType() {
|
||||||
|
return mappedGLAccountType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValueAsString() {
|
||||||
|
return this.value.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Map<Integer, FINANCIAL_ACTIVITY> intToEnumMap = new HashMap<Integer, FINANCIAL_ACTIVITY>();
|
||||||
static {
|
static {
|
||||||
for (final ORGANIZATION_ACCOUNTS type : ORGANIZATION_ACCOUNTS.values()) {
|
for (final FINANCIAL_ACTIVITY type : FINANCIAL_ACTIVITY.values()) {
|
||||||
intToEnumMap.put(type.value, type);
|
intToEnumMap.put(type.value, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ORGANIZATION_ACCOUNTS fromInt(final int i) {
|
public static FINANCIAL_ACTIVITY fromInt(final int financialActivityId) {
|
||||||
final ORGANIZATION_ACCOUNTS type = intToEnumMap.get(Integer.valueOf(i));
|
final FINANCIAL_ACTIVITY type = intToEnumMap.get(Integer.valueOf(financialActivityId));
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
public static FinancialActivityData toFinancialActivityData(final int financialActivityId) {
|
||||||
* Enum of all accounting related input parameter names used while
|
final FINANCIAL_ACTIVITY type = fromInt(financialActivityId);
|
||||||
* creating/updating a loan product
|
return convertToFinancialActivityData(type);
|
||||||
***/
|
|
||||||
public static enum ORGANIZATION_ACCOUNTING_PARAMS {
|
|
||||||
LIABILITY_TRANSFER_SUSPENSE("liabilityTransferInSuspenseAccountId");
|
|
||||||
|
|
||||||
private final String value;
|
|
||||||
|
|
||||||
private ORGANIZATION_ACCOUNTING_PARAMS(final String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static List<FinancialActivityData> getAllFinancialActivities() {
|
||||||
public String toString() {
|
if (financialActivities == null) {
|
||||||
return name().toString().replaceAll("_", " ");
|
financialActivities = new ArrayList<FinancialActivityData>();
|
||||||
|
for (final FINANCIAL_ACTIVITY type : FINANCIAL_ACTIVITY.values()) {
|
||||||
|
FinancialActivityData financialActivityData = convertToFinancialActivityData(type);
|
||||||
|
financialActivities.add(financialActivityData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return financialActivities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
private static FinancialActivityData convertToFinancialActivityData(final FINANCIAL_ACTIVITY type) {
|
||||||
return this.value;
|
FinancialActivityData financialActivityData = new FinancialActivityData(type.value, type.code, type.getMappedGLAccountType());
|
||||||
}
|
return financialActivityData;
|
||||||
}
|
|
||||||
|
|
||||||
/***
|
|
||||||
* Enum of all accounting related input parameter names used while
|
|
||||||
* creating/updating a loan product
|
|
||||||
***/
|
|
||||||
public static enum ORGANIZATION_ACCOUNTING_DATA_PARAMS {
|
|
||||||
LIABILITY_TRANSFER_SUSPENSE("liabilityTransferInSuspenseAccount");
|
|
||||||
|
|
||||||
private final String value;
|
|
||||||
|
|
||||||
private ORGANIZATION_ACCOUNTING_DATA_PARAMS(final String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return name().toString().replaceAll("_", " ");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return this.value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
-22
@@ -3,12 +3,9 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.accountmapping.api;
|
package org.mifosplatform.accounting.financialactivityaccount.api;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.ws.rs.Consumes;
|
import javax.ws.rs.Consumes;
|
||||||
import javax.ws.rs.DELETE;
|
import javax.ws.rs.DELETE;
|
||||||
@@ -22,8 +19,8 @@ import javax.ws.rs.core.Context;
|
|||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.UriInfo;
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
|
||||||
import org.mifosplatform.accounting.accountmapping.data.FinancialActivityAccountData;
|
import org.mifosplatform.accounting.financialactivityaccount.data.FinancialActivityAccountData;
|
||||||
import org.mifosplatform.accounting.accountmapping.service.FinancialActivityAccountReadPlatformService;
|
import org.mifosplatform.accounting.financialactivityaccount.service.FinancialActivityAccountReadPlatformService;
|
||||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||||
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||||
@@ -41,11 +38,6 @@ import org.springframework.stereotype.Component;
|
|||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
public class FinancialActivityAccountsApiResource {
|
public class FinancialActivityAccountsApiResource {
|
||||||
|
|
||||||
private static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "glAccountData",
|
|
||||||
"accountingMappingOptions"));
|
|
||||||
|
|
||||||
private final String resourceNameForPermission = "OFFICEGLACCOUNT";
|
|
||||||
|
|
||||||
private final FinancialActivityAccountReadPlatformService financialActivityAccountReadPlatformService;
|
private final FinancialActivityAccountReadPlatformService financialActivityAccountReadPlatformService;
|
||||||
private final DefaultToApiJsonSerializer<FinancialActivityAccountData> apiJsonSerializerService;
|
private final DefaultToApiJsonSerializer<FinancialActivityAccountData> apiJsonSerializerService;
|
||||||
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
private final ApiRequestParameterHelper apiRequestParameterHelper;
|
||||||
@@ -71,12 +63,14 @@ public class FinancialActivityAccountsApiResource {
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveTemplate(@Context final UriInfo uriInfo) {
|
public String retrieveTemplate(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission);
|
this.context.authenticatedUser().validateHasReadPermission(FinancialActivityAccountsConstants.resourceNameForPermission);
|
||||||
|
|
||||||
FinancialActivityAccountData officeToGLAccountMappingData = this.financialActivityAccountReadPlatformService.retrieveTemplate();
|
FinancialActivityAccountData financialActivityAccountData = this.financialActivityAccountReadPlatformService
|
||||||
|
.getFinancialActivityAccountTemplate();
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
return this.apiJsonSerializerService.serialize(settings, officeToGLAccountMappingData, RESPONSE_DATA_PARAMETERS);
|
return this.apiJsonSerializerService.serialize(settings, financialActivityAccountData,
|
||||||
|
FinancialActivityAccountsConstants.RESPONSE_DATA_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@@ -84,29 +78,31 @@ public class FinancialActivityAccountsApiResource {
|
|||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveAll(@Context final UriInfo uriInfo) {
|
public String retrieveAll(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission);
|
this.context.authenticatedUser().validateHasReadPermission(FinancialActivityAccountsConstants.resourceNameForPermission);
|
||||||
final List<FinancialActivityAccountData> financialActivityAccounts = this.financialActivityAccountReadPlatformService.retrieveAll();
|
final List<FinancialActivityAccountData> financialActivityAccounts = this.financialActivityAccountReadPlatformService.retrieveAll();
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
return this.apiJsonSerializerService.serialize(settings, financialActivityAccounts, RESPONSE_DATA_PARAMETERS);
|
return this.apiJsonSerializerService.serialize(settings, financialActivityAccounts,
|
||||||
|
FinancialActivityAccountsConstants.RESPONSE_DATA_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{mappingId}")
|
@Path("{mappingId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retreiveAccountMapping(@PathParam("mappingId") final Long mappingId, @Context final UriInfo uriInfo) {
|
public String retreive(@PathParam("mappingId") final Long mappingId, @Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission);
|
this.context.authenticatedUser().validateHasReadPermission(FinancialActivityAccountsConstants.resourceNameForPermission);
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
FinancialActivityAccountData officeToGLAccountMappingData = this.financialActivityAccountReadPlatformService.retrieve(mappingId);
|
FinancialActivityAccountData financialActivityAccountData = this.financialActivityAccountReadPlatformService.retrieve(mappingId);
|
||||||
if (settings.isTemplate()) {
|
if (settings.isTemplate()) {
|
||||||
FinancialActivityAccountData templateData = this.financialActivityAccountReadPlatformService.retrieveTemplate();
|
financialActivityAccountData = this.financialActivityAccountReadPlatformService
|
||||||
officeToGLAccountMappingData = FinancialActivityAccountData.associateTemplateData(templateData, officeToGLAccountMappingData);
|
.addTemplateDetails(financialActivityAccountData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.apiJsonSerializerService.serialize(settings, officeToGLAccountMappingData, RESPONSE_DATA_PARAMETERS);
|
return this.apiJsonSerializerService.serialize(settings, financialActivityAccountData,
|
||||||
|
FinancialActivityAccountsConstants.RESPONSE_DATA_PARAMETERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package org.mifosplatform.accounting.financialactivityaccount.api;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class FinancialActivityAccountsConstants {
|
||||||
|
|
||||||
|
public static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("id", "financialActivityData",
|
||||||
|
"glAccountData", "glAccountOptions", "financialActivityOptions"));
|
||||||
|
|
||||||
|
public static final String resourceNameForPermission = "FINANCIALACTIVITYACCOUNT";
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
package org.mifosplatform.accounting.financialactivityaccount.api;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Enum of all parameters passed in while creating/updating a GL Account
|
||||||
|
***/
|
||||||
|
public enum FinancialActivityAccountsJsonInputParams {
|
||||||
|
FINANCIAL_ACTIVITY_ID("financialActivityId"), GL_ACCOUNT_ID("glAccountId");
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
private FinancialActivityAccountsJsonInputParams(final String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Set<String> values = new HashSet<String>();
|
||||||
|
static {
|
||||||
|
for (final FinancialActivityAccountsJsonInputParams type : FinancialActivityAccountsJsonInputParams.values()) {
|
||||||
|
values.add(type.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Set<String> getAllValues() {
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name().toString().replaceAll("_", " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
package org.mifosplatform.accounting.financialactivityaccount.data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
|
||||||
|
|
||||||
|
public class FinancialActivityAccountData {
|
||||||
|
|
||||||
|
private final Long id;
|
||||||
|
private final FinancialActivityData financialActivityData;
|
||||||
|
private final GLAccountData glAccountData;
|
||||||
|
private Map<String, List<GLAccountData>> glAccountOptions;
|
||||||
|
private List<FinancialActivityData> financialActivityOptions;
|
||||||
|
|
||||||
|
public FinancialActivityAccountData() {
|
||||||
|
this.id = null;
|
||||||
|
this.glAccountData = null;
|
||||||
|
this.financialActivityData = null;
|
||||||
|
this.glAccountOptions = null;
|
||||||
|
this.financialActivityOptions = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FinancialActivityAccountData(final Long id, final FinancialActivityData financialActivityData, final GLAccountData glAccountData) {
|
||||||
|
this.id = id;
|
||||||
|
this.glAccountData = glAccountData;
|
||||||
|
this.financialActivityData = financialActivityData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FinancialActivityAccountData(Map<String, List<GLAccountData>> glAccountOptions,
|
||||||
|
List<FinancialActivityData> financialActivityOptions) {
|
||||||
|
this.id = null;
|
||||||
|
this.glAccountData = null;
|
||||||
|
this.financialActivityData = null;
|
||||||
|
this.glAccountOptions = glAccountOptions;
|
||||||
|
this.financialActivityOptions = financialActivityOptions;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FinancialActivityData> getFinancialActivityOptions() {
|
||||||
|
return financialActivityOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinancialActivityOptions(List<FinancialActivityData> financialActivityOptions) {
|
||||||
|
this.financialActivityOptions = financialActivityOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<GLAccountData>> getAccountingMappingOptions() {
|
||||||
|
return this.glAccountOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountingMappingOptions(Map<String, List<GLAccountData>> accountingMappingOptions) {
|
||||||
|
this.glAccountOptions = accountingMappingOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GLAccountData getGlAccountData() {
|
||||||
|
return glAccountData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FinancialActivityData getFinancialActivityData() {
|
||||||
|
return financialActivityData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package org.mifosplatform.accounting.financialactivityaccount.data;
|
||||||
|
|
||||||
|
import org.mifosplatform.accounting.glaccount.domain.GLAccountType;
|
||||||
|
|
||||||
|
public class FinancialActivityData {
|
||||||
|
|
||||||
|
private final Integer id;
|
||||||
|
private final String name;
|
||||||
|
private final GLAccountType mappedGLAccountType;
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GLAccountType getMappedGLAccountType() {
|
||||||
|
return this.mappedGLAccountType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FinancialActivityData(Integer id, String name, GLAccountType mappedGLAccountType) {
|
||||||
|
super();
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.mappedGLAccountType = mappedGLAccountType;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+10
-7
@@ -3,7 +3,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.accountmapping.domain;
|
package org.mifosplatform.accounting.financialactivityaccount.domain;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
@@ -24,9 +24,9 @@ public class FinancialActivityAccount extends AbstractPersistable<Long> {
|
|||||||
private GLAccount glAccount;
|
private GLAccount glAccount;
|
||||||
|
|
||||||
@Column(name = "financial_activity_type", nullable = false)
|
@Column(name = "financial_activity_type", nullable = false)
|
||||||
private int financialActivityType;
|
private Integer financialActivityType;
|
||||||
|
|
||||||
public static FinancialActivityAccount createNew(final GLAccount glAccount, final int financialAccountType) {
|
public static FinancialActivityAccount createNew(final GLAccount glAccount, final Integer financialAccountType) {
|
||||||
return new FinancialActivityAccount(glAccount, financialAccountType);
|
return new FinancialActivityAccount(glAccount, financialAccountType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,16 +39,19 @@ public class FinancialActivityAccount extends AbstractPersistable<Long> {
|
|||||||
this.financialActivityType = financialAccountType;
|
this.financialActivityType = financialAccountType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GLAccount glAccount() {
|
public GLAccount getGlAccount() {
|
||||||
return this.glAccount;
|
return this.glAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getFinancialActivityType() {
|
||||||
|
return this.financialActivityType;
|
||||||
|
}
|
||||||
|
|
||||||
public void updateGlAccount(final GLAccount glAccount) {
|
public void updateGlAccount(final GLAccount glAccount) {
|
||||||
this.glAccount = glAccount;
|
this.glAccount = glAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFinancialActivityType() {
|
public void updateFinancialActivityType(final Integer financialActivityType) {
|
||||||
return this.financialActivityType;
|
this.financialActivityType = financialActivityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.accountmapping.domain;
|
package org.mifosplatform.accounting.financialactivityaccount.domain;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
+6
-4
@@ -3,11 +3,11 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.accountmapping.domain;
|
package org.mifosplatform.accounting.financialactivityaccount.domain;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.mifosplatform.accounting.accountmapping.exception.FinancialActivityAccountNotFoundException;
|
import org.mifosplatform.accounting.financialactivityaccount.exception.FinancialActivityAccountNotFoundException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -33,8 +33,10 @@ public class FinancialActivityAccountRepositoryWrapper {
|
|||||||
return financialActivityAccount;
|
return financialActivityAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FinancialActivityAccount findByFinancialActivityType(final int financialActivityType) {
|
public FinancialActivityAccount findByFinancialActivityTypeWithNotFoundDetection(final int financialActivityType) {
|
||||||
return this.repository.findByFinancialActivityType(financialActivityType);
|
FinancialActivityAccount financialActivityAccount = this.repository.findByFinancialActivityType(financialActivityType);
|
||||||
|
if (financialActivityAccount == null) { throw new FinancialActivityAccountNotFoundException(financialActivityType); }
|
||||||
|
return financialActivityAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FinancialActivityAccount> findAll() {
|
public List<FinancialActivityAccount> findAll() {
|
||||||
+2
-2
@@ -3,7 +3,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.accountmapping.exception;
|
package org.mifosplatform.accounting.financialactivityaccount.exception;
|
||||||
|
|
||||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRul
|
|||||||
public class DuplicateFinancialActivityAccountFoundException extends AbstractPlatformDomainRuleException {
|
public class DuplicateFinancialActivityAccountFoundException extends AbstractPlatformDomainRuleException {
|
||||||
|
|
||||||
public DuplicateFinancialActivityAccountFoundException(final Integer financialActivityType) {
|
public DuplicateFinancialActivityAccountFoundException(final Integer financialActivityType) {
|
||||||
super("error.msg.officeToAccountMapping.exists.for.office", "Mapping for activity already exists " + financialActivityType,
|
super("error.msg.financialActivityAccount.exists.for.office", "Mapping for activity already exists " + financialActivityType,
|
||||||
financialActivityType);
|
financialActivityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
package org.mifosplatform.accounting.financialactivityaccount.exception;
|
||||||
|
|
||||||
|
import org.mifosplatform.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY;
|
||||||
|
import org.mifosplatform.accounting.glaccount.domain.GLAccount;
|
||||||
|
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link RuntimeException} thrown when product to GL account mapping are not
|
||||||
|
* found.
|
||||||
|
*/
|
||||||
|
public class FinancialActivityAccountInvalidException extends AbstractPlatformDomainRuleException {
|
||||||
|
|
||||||
|
public FinancialActivityAccountInvalidException(final FINANCIAL_ACTIVITY financialActivity, final GLAccount glAccount) {
|
||||||
|
super("error.msg.financialActivityAccount.invalid", "Financial Activity '" + financialActivity.getCode() + "' with Id :"
|
||||||
|
+ financialActivity.getValue() + "' can only be associated with a Ledger Account of Type "
|
||||||
|
+ financialActivity.getMappedGLAccountType().getCode() + " the provided Ledger Account '" + glAccount.getName() + "("
|
||||||
|
+ glAccount.getGlCode() + ")' does not of the required type", financialActivity.getCode(), financialActivity.getValue(),
|
||||||
|
financialActivity.getMappedGLAccountType().getCode(), glAccount.getName(), glAccount.getGlCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
+7
-6
@@ -3,7 +3,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.accountmapping.exception;
|
package org.mifosplatform.accounting.financialactivityaccount.exception;
|
||||||
|
|
||||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
||||||
|
|
||||||
@@ -13,12 +13,13 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceN
|
|||||||
*/
|
*/
|
||||||
public class FinancialActivityAccountNotFoundException extends AbstractPlatformResourceNotFoundException {
|
public class FinancialActivityAccountNotFoundException extends AbstractPlatformResourceNotFoundException {
|
||||||
|
|
||||||
public FinancialActivityAccountNotFoundException(final Long officeId, final String accountType) {
|
public FinancialActivityAccountNotFoundException(final Long id) {
|
||||||
super("error.msg.officeToAccountMapping.not.found", "Mapping for office with Id " + officeId
|
super("error.msg.financialActivityAccount.not.found", "Financial Activity account with Id " + id + " does not exist", id);
|
||||||
+ " does not exist for an account of type " + accountType, officeId, accountType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FinancialActivityAccountNotFoundException(final Long id) {
|
public FinancialActivityAccountNotFoundException(final Integer financialActivityType) {
|
||||||
super("error.msg.officeToAccountMapping.not.found", "Mapping for GL Account with Id " + id + " does not exist", id);
|
super("error.msg.financialActivityAccount.not.found", "Financial Activity account with for the financial Activity with Id "
|
||||||
|
+ financialActivityType + " does not exist", financialActivityType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+3
-3
@@ -3,9 +3,9 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.accountmapping.handler;
|
package org.mifosplatform.accounting.financialactivityaccount.handler;
|
||||||
|
|
||||||
import org.mifosplatform.accounting.accountmapping.service.FinancialActivityAccountWritePlatformService;
|
import org.mifosplatform.accounting.financialactivityaccount.service.FinancialActivityAccountWritePlatformService;
|
||||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
@@ -27,6 +27,6 @@ public class CreateFinancialActivityAccountHandler implements NewCommandSourceHa
|
|||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult processCommand(final JsonCommand command) {
|
public CommandProcessingResult processCommand(final JsonCommand command) {
|
||||||
|
|
||||||
return this.writePlatformService.createGLAccountActivityMapping(command);
|
return this.writePlatformService.createFinancialActivityAccountMapping(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -3,9 +3,9 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.accountmapping.handler;
|
package org.mifosplatform.accounting.financialactivityaccount.handler;
|
||||||
|
|
||||||
import org.mifosplatform.accounting.accountmapping.service.FinancialActivityAccountWritePlatformService;
|
import org.mifosplatform.accounting.financialactivityaccount.service.FinancialActivityAccountWritePlatformService;
|
||||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
+2
-2
@@ -3,9 +3,9 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.accountmapping.handler;
|
package org.mifosplatform.accounting.financialactivityaccount.handler;
|
||||||
|
|
||||||
import org.mifosplatform.accounting.accountmapping.service.FinancialActivityAccountWritePlatformService;
|
import org.mifosplatform.accounting.financialactivityaccount.service.FinancialActivityAccountWritePlatformService;
|
||||||
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
import org.mifosplatform.commands.handler.NewCommandSourceHandler;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
+104
@@ -0,0 +1,104 @@
|
|||||||
|
/**
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
package org.mifosplatform.accounting.financialactivityaccount.serialization;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.mifosplatform.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.api.FinancialActivityAccountsJsonInputParams;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
||||||
|
import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
||||||
|
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||||
|
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public final class FinancialActivityAccountDataValidator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The parameters supported for this command.
|
||||||
|
*/
|
||||||
|
private final Set<String> supportedParameters = FinancialActivityAccountsJsonInputParams.getAllValues();
|
||||||
|
|
||||||
|
private final FromJsonHelper fromApiJsonHelper;
|
||||||
|
|
||||||
|
private final String paramNameForFinancialActivity = FinancialActivityAccountsJsonInputParams.FINANCIAL_ACTIVITY_ID.getValue();
|
||||||
|
private final String paramNameForGLAccount = FinancialActivityAccountsJsonInputParams.GL_ACCOUNT_ID.getValue();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public FinancialActivityAccountDataValidator(final FromJsonHelper fromApiJsonHelper) {
|
||||||
|
this.fromApiJsonHelper = fromApiJsonHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateForCreate(final String json) {
|
||||||
|
validateJSONAndCheckForUnsupportedParams(json);
|
||||||
|
|
||||||
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
|
final DataValidatorBuilder baseDataValidator = getDataValidator(dataValidationErrors);
|
||||||
|
|
||||||
|
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||||
|
|
||||||
|
final Integer financialActivityId = this.fromApiJsonHelper.extractIntegerSansLocaleNamed(paramNameForFinancialActivity, element);
|
||||||
|
baseDataValidator.reset().parameter(paramNameForFinancialActivity).value(financialActivityId).notNull()
|
||||||
|
.isOneOfTheseValues(FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue());
|
||||||
|
|
||||||
|
final Long glAccountId = this.fromApiJsonHelper.extractLongNamed(paramNameForGLAccount, element);
|
||||||
|
baseDataValidator.reset().parameter(paramNameForGLAccount).value(glAccountId).notNull().integerGreaterThanZero();
|
||||||
|
|
||||||
|
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataValidatorBuilder getDataValidator(final List<ApiParameterError> dataValidationErrors) {
|
||||||
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("financialactivityaccount");
|
||||||
|
return baseDataValidator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validateForUpdate(final String json) {
|
||||||
|
validateJSONAndCheckForUnsupportedParams(json);
|
||||||
|
|
||||||
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
|
final DataValidatorBuilder baseDataValidator = getDataValidator(dataValidationErrors);
|
||||||
|
|
||||||
|
final JsonElement element = this.fromApiJsonHelper.parse(json);
|
||||||
|
|
||||||
|
if (this.fromApiJsonHelper.parameterExists(paramNameForFinancialActivity, element)) {
|
||||||
|
final Integer financialActivityId = this.fromApiJsonHelper
|
||||||
|
.extractIntegerSansLocaleNamed(paramNameForFinancialActivity, element);
|
||||||
|
baseDataValidator.reset().parameter(paramNameForFinancialActivity).value(financialActivityId).ignoreIfNull()
|
||||||
|
.isOneOfTheseValues(FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.fromApiJsonHelper.parameterExists(paramNameForGLAccount, element)) {
|
||||||
|
final Long glAccountId = this.fromApiJsonHelper.extractLongNamed(paramNameForGLAccount, element);
|
||||||
|
baseDataValidator.reset().parameter(paramNameForGLAccount).value(glAccountId).ignoreIfNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
|
||||||
|
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateJSONAndCheckForUnsupportedParams(final String json) {
|
||||||
|
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||||
|
|
||||||
|
final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
|
||||||
|
this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, json, this.supportedParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void throwExceptionIfValidationWarningsExist(final List<ApiParameterError> dataValidationErrors) {
|
||||||
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist",
|
||||||
|
"Validation errors exist.", dataValidationErrors); }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+5
-3
@@ -3,11 +3,11 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.accountmapping.service;
|
package org.mifosplatform.accounting.financialactivityaccount.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.mifosplatform.accounting.accountmapping.data.FinancialActivityAccountData;
|
import org.mifosplatform.accounting.financialactivityaccount.data.FinancialActivityAccountData;
|
||||||
|
|
||||||
public interface FinancialActivityAccountReadPlatformService {
|
public interface FinancialActivityAccountReadPlatformService {
|
||||||
|
|
||||||
@@ -15,6 +15,8 @@ public interface FinancialActivityAccountReadPlatformService {
|
|||||||
|
|
||||||
FinancialActivityAccountData retrieve(Long mappingId);
|
FinancialActivityAccountData retrieve(Long mappingId);
|
||||||
|
|
||||||
FinancialActivityAccountData retrieveTemplate();
|
FinancialActivityAccountData addTemplateDetails(FinancialActivityAccountData financialActivityAccountData);
|
||||||
|
|
||||||
|
FinancialActivityAccountData getFinancialActivityAccountTemplate();
|
||||||
|
|
||||||
}
|
}
|
||||||
+26
-13
@@ -1,13 +1,15 @@
|
|||||||
package org.mifosplatform.accounting.accountmapping.service;
|
package org.mifosplatform.accounting.financialactivityaccount.service;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.mifosplatform.accounting.accountmapping.data.FinancialActivityAccountData;
|
import org.mifosplatform.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY;
|
||||||
import org.mifosplatform.accounting.accountmapping.exception.FinancialActivityAccountNotFoundException;
|
|
||||||
import org.mifosplatform.accounting.common.AccountingDropdownReadPlatformService;
|
import org.mifosplatform.accounting.common.AccountingDropdownReadPlatformService;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.data.FinancialActivityAccountData;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.data.FinancialActivityData;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.exception.FinancialActivityAccountNotFoundException;
|
||||||
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
|
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
|
||||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||||
@@ -39,22 +41,31 @@ public class FinancialActivityAccountReadPlatformServiceImpl implements Financia
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FinancialActivityAccountData retrieve(Long mappingId) {
|
public FinancialActivityAccountData retrieve(Long financialActivityAccountId) {
|
||||||
try {
|
try {
|
||||||
StringBuilder sqlBuilder = new StringBuilder(200);
|
StringBuilder sqlBuilder = new StringBuilder(200);
|
||||||
sqlBuilder.append("select ");
|
sqlBuilder.append("select ");
|
||||||
sqlBuilder.append(this.financialActivityAccountMapper.schema());
|
sqlBuilder.append(this.financialActivityAccountMapper.schema());
|
||||||
sqlBuilder.append(" where faa.id=?");
|
sqlBuilder.append(" where faa.id=?");
|
||||||
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(), this.financialActivityAccountMapper, new Object[] { mappingId });
|
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(), this.financialActivityAccountMapper,
|
||||||
|
new Object[] { financialActivityAccountId });
|
||||||
} catch (final EmptyResultDataAccessException e) {
|
} catch (final EmptyResultDataAccessException e) {
|
||||||
throw new FinancialActivityAccountNotFoundException(mappingId);
|
throw new FinancialActivityAccountNotFoundException(financialActivityAccountId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FinancialActivityAccountData retrieveTemplate() {
|
public FinancialActivityAccountData addTemplateDetails(FinancialActivityAccountData financialActivityAccountData) {
|
||||||
final Map<String, List<GLAccountData>> accountOptions = this.accountingDropdownReadPlatformService.retrieveAccountMappingOptions();
|
final Map<String, List<GLAccountData>> accountOptions = this.accountingDropdownReadPlatformService.retrieveAccountMappingOptions();
|
||||||
return FinancialActivityAccountData.template(accountOptions);
|
financialActivityAccountData.setAccountingMappingOptions(accountOptions);
|
||||||
|
financialActivityAccountData.setFinancialActivityOptions(FINANCIAL_ACTIVITY.getAllFinancialActivities());
|
||||||
|
return financialActivityAccountData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FinancialActivityAccountData getFinancialActivityAccountTemplate() {
|
||||||
|
FinancialActivityAccountData financialActivityAccountData = new FinancialActivityAccountData();
|
||||||
|
return addTemplateDetails(financialActivityAccountData);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class FinancialActivityAccountMapper implements RowMapper<FinancialActivityAccountData> {
|
private static final class FinancialActivityAccountMapper implements RowMapper<FinancialActivityAccountData> {
|
||||||
@@ -63,7 +74,7 @@ public class FinancialActivityAccountReadPlatformServiceImpl implements Financia
|
|||||||
|
|
||||||
public FinancialActivityAccountMapper() {
|
public FinancialActivityAccountMapper() {
|
||||||
StringBuilder sb = new StringBuilder(300);
|
StringBuilder sb = new StringBuilder(300);
|
||||||
sb.append(" faa.id , glaccount.id as glAccountId,glaccount.name as glAccountName,glaccount.gl_code as glCode ");
|
sb.append(" faa.id as id, faa.financial_activity_type as financialActivityId, glaccount.id as glAccountId,glaccount.name as glAccountName,glaccount.gl_code as glCode ");
|
||||||
sb.append(" from acc_gl_financial_activity_account faa ");
|
sb.append(" from acc_gl_financial_activity_account faa ");
|
||||||
sb.append(" join acc_gl_account glaccount on glaccount.id = faa.gl_account_id");
|
sb.append(" join acc_gl_account glaccount on glaccount.id = faa.gl_account_id");
|
||||||
sql = sb.toString();
|
sql = sb.toString();
|
||||||
@@ -77,15 +88,17 @@ public class FinancialActivityAccountReadPlatformServiceImpl implements Financia
|
|||||||
public FinancialActivityAccountData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
public FinancialActivityAccountData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||||
final Long id = JdbcSupport.getLong(rs, "id");
|
final Long id = JdbcSupport.getLong(rs, "id");
|
||||||
final Long glAccountId = JdbcSupport.getLong(rs, "glAccountId");
|
final Long glAccountId = JdbcSupport.getLong(rs, "glAccountId");
|
||||||
|
final Integer financialActivityId = JdbcSupport.getInteger(rs, "financialActivityId");
|
||||||
final String glAccountName = rs.getString("glAccountName");
|
final String glAccountName = rs.getString("glAccountName");
|
||||||
final String glCode = rs.getString("glCode");
|
final String glCode = rs.getString("glCode");
|
||||||
|
|
||||||
final GLAccountData gLAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
|
final GLAccountData glAccountData = new GLAccountData(glAccountId, glAccountName, glCode);
|
||||||
|
final FinancialActivityData financialActivityData = FINANCIAL_ACTIVITY.toFinancialActivityData(financialActivityId);
|
||||||
|
|
||||||
final FinancialActivityAccountData accountMappingData = FinancialActivityAccountData.instance(id, gLAccountData);
|
final FinancialActivityAccountData financialActivityAccountData = new FinancialActivityAccountData(id, financialActivityData,
|
||||||
return accountMappingData;
|
glAccountData);
|
||||||
|
return financialActivityAccountData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+2
-2
@@ -3,14 +3,14 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
package org.mifosplatform.accounting.accountmapping.service;
|
package org.mifosplatform.accounting.financialactivityaccount.service;
|
||||||
|
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
|
|
||||||
public interface FinancialActivityAccountWritePlatformService {
|
public interface FinancialActivityAccountWritePlatformService {
|
||||||
|
|
||||||
CommandProcessingResult createGLAccountActivityMapping(JsonCommand command);
|
CommandProcessingResult createFinancialActivityAccountMapping(JsonCommand command);
|
||||||
|
|
||||||
CommandProcessingResult updateGLAccountActivityMapping(Long mappingId, JsonCommand command);
|
CommandProcessingResult updateGLAccountActivityMapping(Long mappingId, JsonCommand command);
|
||||||
|
|
||||||
+158
@@ -0,0 +1,158 @@
|
|||||||
|
package org.mifosplatform.accounting.financialactivityaccount.service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.mifosplatform.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.api.FinancialActivityAccountsJsonInputParams;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.domain.FinancialActivityAccount;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.domain.FinancialActivityAccountRepositoryWrapper;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.exception.DuplicateFinancialActivityAccountFoundException;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.exception.FinancialActivityAccountInvalidException;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.serialization.FinancialActivityAccountDataValidator;
|
||||||
|
import org.mifosplatform.accounting.glaccount.domain.GLAccount;
|
||||||
|
import org.mifosplatform.accounting.glaccount.domain.GLAccountRepositoryWrapper;
|
||||||
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||||
|
import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FinancialActivityAccountWritePlatformServiceImpl implements FinancialActivityAccountWritePlatformService {
|
||||||
|
|
||||||
|
private final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepository;
|
||||||
|
private final FinancialActivityAccountDataValidator fromApiJsonDeserializer;
|
||||||
|
private final GLAccountRepositoryWrapper glAccountRepositoryWrapper;
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(FinancialActivityAccountWritePlatformServiceImpl.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public FinancialActivityAccountWritePlatformServiceImpl(
|
||||||
|
final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepository,
|
||||||
|
final FinancialActivityAccountDataValidator fromApiJsonDeserializer, final GLAccountRepositoryWrapper glAccountRepositoryWrapper) {
|
||||||
|
this.financialActivityAccountRepository = financialActivityAccountRepository;
|
||||||
|
this.fromApiJsonDeserializer = fromApiJsonDeserializer;
|
||||||
|
this.glAccountRepositoryWrapper = glAccountRepositoryWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandProcessingResult createFinancialActivityAccountMapping(JsonCommand command) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
this.fromApiJsonDeserializer.validateForCreate(command.json());
|
||||||
|
|
||||||
|
final Integer financialActivityId = command
|
||||||
|
.integerValueSansLocaleOfParameterNamed(FinancialActivityAccountsJsonInputParams.FINANCIAL_ACTIVITY_ID.getValue());
|
||||||
|
final Long accountId = command.longValueOfParameterNamed(FinancialActivityAccountsJsonInputParams.GL_ACCOUNT_ID.getValue());
|
||||||
|
final GLAccount glAccount = glAccountRepositoryWrapper.findOneWithNotFoundDetection(accountId);
|
||||||
|
FinancialActivityAccount financialActivityAccount = FinancialActivityAccount.createNew(glAccount, financialActivityId);
|
||||||
|
|
||||||
|
validateFinancialActivityAndAccountMapping(financialActivityAccount);
|
||||||
|
this.financialActivityAccountRepository.save(financialActivityAccount);
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(financialActivityAccount.getId()) //
|
||||||
|
.build();
|
||||||
|
} catch (DataIntegrityViolationException dataIntegrityViolationException) {
|
||||||
|
handleFinancialActivityAccountDataIntegrityIssues(command, dataIntegrityViolationException);
|
||||||
|
return CommandProcessingResult.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate that the GL Account is appropriate for the particular Financial
|
||||||
|
* Activity Type
|
||||||
|
**/
|
||||||
|
private void validateFinancialActivityAndAccountMapping(FinancialActivityAccount financialActivityAccount) {
|
||||||
|
FINANCIAL_ACTIVITY financialActivity = FINANCIAL_ACTIVITY.fromInt(financialActivityAccount.getFinancialActivityType());
|
||||||
|
GLAccount glAccount = financialActivityAccount.getGlAccount();
|
||||||
|
if (!financialActivity.getMappedGLAccountType().getValue().equals(glAccount.getType())) { throw new FinancialActivityAccountInvalidException(
|
||||||
|
financialActivity, glAccount); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandProcessingResult updateGLAccountActivityMapping(Long financialActivityAccountId, JsonCommand command) {
|
||||||
|
try {
|
||||||
|
this.fromApiJsonDeserializer.validateForUpdate(command.json());
|
||||||
|
final FinancialActivityAccount financialActivityAccount = this.financialActivityAccountRepository
|
||||||
|
.findOneWithNotFoundDetection(financialActivityAccountId);
|
||||||
|
Map<String, Object> changes = findChanges(command, financialActivityAccount);
|
||||||
|
|
||||||
|
if (changes.containsKey(FinancialActivityAccountsJsonInputParams.GL_ACCOUNT_ID.getValue())) {
|
||||||
|
final Long accountId = command.longValueOfParameterNamed(FinancialActivityAccountsJsonInputParams.GL_ACCOUNT_ID.getValue());
|
||||||
|
final GLAccount glAccount = glAccountRepositoryWrapper.findOneWithNotFoundDetection(accountId);
|
||||||
|
financialActivityAccount.updateGlAccount(glAccount);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changes.containsKey(FinancialActivityAccountsJsonInputParams.FINANCIAL_ACTIVITY_ID.getValue())) {
|
||||||
|
final Integer financialActivityId = command
|
||||||
|
.integerValueSansLocaleOfParameterNamed(FinancialActivityAccountsJsonInputParams.FINANCIAL_ACTIVITY_ID.getValue());
|
||||||
|
financialActivityAccount.updateFinancialActivityType(financialActivityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!changes.isEmpty()) {
|
||||||
|
validateFinancialActivityAndAccountMapping(financialActivityAccount);
|
||||||
|
this.financialActivityAccountRepository.save(financialActivityAccount);
|
||||||
|
}
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(financialActivityAccountId) //
|
||||||
|
.with(changes) //
|
||||||
|
.build();
|
||||||
|
} catch (DataIntegrityViolationException dataIntegrityViolationException) {
|
||||||
|
handleFinancialActivityAccountDataIntegrityIssues(command, dataIntegrityViolationException);
|
||||||
|
return CommandProcessingResult.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommandProcessingResult deleteGLAccountActivityMapping(Long financialActivityAccountId, JsonCommand command) {
|
||||||
|
final FinancialActivityAccount financialActivityAccount = this.financialActivityAccountRepository
|
||||||
|
.findOneWithNotFoundDetection(financialActivityAccountId);
|
||||||
|
this.financialActivityAccountRepository.delete(financialActivityAccount);
|
||||||
|
return new CommandProcessingResultBuilder() //
|
||||||
|
.withCommandId(command.commandId()) //
|
||||||
|
.withEntityId(financialActivityAccountId) //
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleFinancialActivityAccountDataIntegrityIssues(final JsonCommand command, final DataIntegrityViolationException dve) {
|
||||||
|
final Throwable realCause = dve.getMostSpecificCause();
|
||||||
|
if (realCause.getMessage().contains("financial_activity_type")) {
|
||||||
|
final Integer financialActivityId = command
|
||||||
|
.integerValueSansLocaleOfParameterNamed(FinancialActivityAccountsJsonInputParams.FINANCIAL_ACTIVITY_ID.getValue());
|
||||||
|
throw new DuplicateFinancialActivityAccountFoundException(financialActivityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.error(dve.getMessage(), dve);
|
||||||
|
throw new PlatformDataIntegrityException("error.msg.glAccount.unknown.data.integrity.issue",
|
||||||
|
"Unknown data integrity issue with resource GL Account: " + realCause.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> findChanges(JsonCommand command, FinancialActivityAccount financialActivityAccount) {
|
||||||
|
|
||||||
|
Map<String, Object> changes = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
Long existingGLAccountId = financialActivityAccount.getGlAccount().getId();
|
||||||
|
Integer financialActivityType = financialActivityAccount.getFinancialActivityType();
|
||||||
|
|
||||||
|
// is the account Id changed?
|
||||||
|
if (command.isChangeInLongParameterNamed(FinancialActivityAccountsJsonInputParams.GL_ACCOUNT_ID.getValue(), existingGLAccountId)) {
|
||||||
|
final Long newValue = command.longValueOfParameterNamed(FinancialActivityAccountsJsonInputParams.GL_ACCOUNT_ID.getValue());
|
||||||
|
changes.put(FinancialActivityAccountsJsonInputParams.GL_ACCOUNT_ID.getValue(), newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// is the financial Activity changed
|
||||||
|
if (command.isChangeInIntegerSansLocaleParameterNamed(FinancialActivityAccountsJsonInputParams.FINANCIAL_ACTIVITY_ID.getValue(),
|
||||||
|
financialActivityType)) {
|
||||||
|
final Integer newValue = command
|
||||||
|
.integerValueSansLocaleOfParameterNamed(FinancialActivityAccountsJsonInputParams.FINANCIAL_ACTIVITY_ID.getValue());
|
||||||
|
changes.put(FinancialActivityAccountsJsonInputParams.FINANCIAL_ACTIVITY_ID.getValue(), newValue);
|
||||||
|
}
|
||||||
|
return changes;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -9,7 +9,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Enum of all parameters passed in while creating/updating a loan product
|
* Enum of all parameters passed in while creating/updating a GL Account
|
||||||
***/
|
***/
|
||||||
public enum GLAccountJsonInputParams {
|
public enum GLAccountJsonInputParams {
|
||||||
ID("id"), NAME("name"), PARENT_ID("parentId"), GL_CODE("glCode"), DISABLED("disabled"), MANUAL_ENTRIES_ALLOWED("manualEntriesAllowed"), TYPE(
|
ID("id"), NAME("name"), PARENT_ID("parentId"), GL_CODE("glCode"), DISABLED("disabled"), MANUAL_ENTRIES_ALLOWED("manualEntriesAllowed"), TYPE(
|
||||||
|
|||||||
+22
-31
@@ -14,15 +14,14 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.mifosplatform.accounting.accountmapping.domain.FinancialActivityAccount;
|
|
||||||
import org.mifosplatform.accounting.accountmapping.domain.FinancialActivityAccountRepository;
|
|
||||||
import org.mifosplatform.accounting.accountmapping.exception.FinancialActivityAccountNotFoundException;
|
|
||||||
import org.mifosplatform.accounting.closure.domain.GLClosure;
|
import org.mifosplatform.accounting.closure.domain.GLClosure;
|
||||||
import org.mifosplatform.accounting.closure.domain.GLClosureRepository;
|
import org.mifosplatform.accounting.closure.domain.GLClosureRepository;
|
||||||
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.CASH_ACCOUNTS_FOR_SAVINGS;
|
import org.mifosplatform.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SAVINGS;
|
||||||
import org.mifosplatform.accounting.common.AccountingConstants.ORGANIZATION_ACCOUNTS;
|
import org.mifosplatform.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.domain.FinancialActivityAccount;
|
||||||
|
import org.mifosplatform.accounting.financialactivityaccount.domain.FinancialActivityAccountRepositoryWrapper;
|
||||||
import org.mifosplatform.accounting.glaccount.domain.GLAccount;
|
import org.mifosplatform.accounting.glaccount.domain.GLAccount;
|
||||||
import org.mifosplatform.accounting.journalentry.data.ChargePaymentDTO;
|
import org.mifosplatform.accounting.journalentry.data.ChargePaymentDTO;
|
||||||
import org.mifosplatform.accounting.journalentry.data.LoanDTO;
|
import org.mifosplatform.accounting.journalentry.data.LoanDTO;
|
||||||
@@ -61,7 +60,7 @@ public class AccountingProcessorHelper {
|
|||||||
public static final String SAVINGS_TRANSACTION_IDENTIFIER = "S";
|
public static final String SAVINGS_TRANSACTION_IDENTIFIER = "S";
|
||||||
private final JournalEntryRepository glJournalEntryRepository;
|
private final JournalEntryRepository glJournalEntryRepository;
|
||||||
private final ProductToGLAccountMappingRepository accountMappingRepository;
|
private final ProductToGLAccountMappingRepository accountMappingRepository;
|
||||||
private final FinancialActivityAccountRepository officeToGLAccountMappingRepository;
|
private final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepository;
|
||||||
private final GLClosureRepository closureRepository;
|
private final GLClosureRepository closureRepository;
|
||||||
private final OfficeRepository officeRepository;
|
private final OfficeRepository officeRepository;
|
||||||
private final LoanTransactionRepository loanTransactionRepository;
|
private final LoanTransactionRepository loanTransactionRepository;
|
||||||
@@ -73,7 +72,7 @@ public class AccountingProcessorHelper {
|
|||||||
final ProductToGLAccountMappingRepository accountMappingRepository, final GLClosureRepository closureRepository,
|
final ProductToGLAccountMappingRepository accountMappingRepository, final GLClosureRepository closureRepository,
|
||||||
final OfficeRepository officeRepository, final LoanTransactionRepository loanTransactionRepository,
|
final OfficeRepository officeRepository, final LoanTransactionRepository loanTransactionRepository,
|
||||||
final SavingsAccountTransactionRepository savingsAccountTransactionRepository,
|
final SavingsAccountTransactionRepository savingsAccountTransactionRepository,
|
||||||
final FinancialActivityAccountRepository officeToGLAccountMappingRepository,
|
final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepository,
|
||||||
final AccountTransfersReadPlatformService accountTransfersReadPlatformService) {
|
final AccountTransfersReadPlatformService accountTransfersReadPlatformService) {
|
||||||
this.glJournalEntryRepository = glJournalEntryRepository;
|
this.glJournalEntryRepository = glJournalEntryRepository;
|
||||||
this.accountMappingRepository = accountMappingRepository;
|
this.accountMappingRepository = accountMappingRepository;
|
||||||
@@ -81,7 +80,7 @@ public class AccountingProcessorHelper {
|
|||||||
this.officeRepository = officeRepository;
|
this.officeRepository = officeRepository;
|
||||||
this.loanTransactionRepository = loanTransactionRepository;
|
this.loanTransactionRepository = loanTransactionRepository;
|
||||||
this.savingsAccountTransactionRepository = savingsAccountTransactionRepository;
|
this.savingsAccountTransactionRepository = savingsAccountTransactionRepository;
|
||||||
this.officeToGLAccountMappingRepository = officeToGLAccountMappingRepository;
|
this.financialActivityAccountRepository = financialActivityAccountRepository;
|
||||||
this.accountTransfersReadPlatformService = accountTransfersReadPlatformService;
|
this.accountTransfersReadPlatformService = accountTransfersReadPlatformService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,9 +349,8 @@ public class AccountingProcessorHelper {
|
|||||||
private void createJournalEntriesForLoan(final Office office, final String currencyCode, final int accountTypeToDebitId,
|
private void createJournalEntriesForLoan(final Office office, final String currencyCode, final int accountTypeToDebitId,
|
||||||
final int accountTypeToCreditId, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
final int accountTypeToCreditId, final Long loanProductId, final Long paymentTypeId, final Long loanId,
|
||||||
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
||||||
final GLAccount debitAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToDebitId, paymentTypeId, office.getId());
|
final GLAccount debitAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToDebitId, paymentTypeId);
|
||||||
final GLAccount creditAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToCreditId, paymentTypeId,
|
final GLAccount creditAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToCreditId, paymentTypeId);
|
||||||
office.getId());
|
|
||||||
createDebitJournalEntryForLoan(office, currencyCode, debitAccount, loanId, transactionId, transactionDate, amount);
|
createDebitJournalEntryForLoan(office, currencyCode, debitAccount, loanId, transactionId, transactionDate, amount);
|
||||||
createCreditJournalEntryForLoan(office, currencyCode, creditAccount, loanId, transactionId, transactionDate, amount);
|
createCreditJournalEntryForLoan(office, currencyCode, creditAccount, loanId, transactionId, transactionDate, amount);
|
||||||
}
|
}
|
||||||
@@ -360,10 +358,8 @@ public class AccountingProcessorHelper {
|
|||||||
private void createJournalEntriesForSavings(final Office office, final String currencyCode, final int accountTypeToDebitId,
|
private void createJournalEntriesForSavings(final Office office, final String currencyCode, final int accountTypeToDebitId,
|
||||||
final int accountTypeToCreditId, final Long savingsProductId, final Long paymentTypeId, final Long savingsId,
|
final int accountTypeToCreditId, final Long savingsProductId, final Long paymentTypeId, final Long savingsId,
|
||||||
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
final String transactionId, final Date transactionDate, final BigDecimal amount) {
|
||||||
final GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId,
|
final GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId);
|
||||||
office.getId());
|
final GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId);
|
||||||
final GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId,
|
|
||||||
office.getId());
|
|
||||||
createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount);
|
createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount);
|
||||||
createCreditJournalEntryForSavings(office, currencyCode, creditAccount, savingsId, transactionId, transactionDate, amount);
|
createCreditJournalEntryForSavings(office, currencyCode, creditAccount, savingsId, transactionId, transactionDate, amount);
|
||||||
}
|
}
|
||||||
@@ -371,7 +367,7 @@ public class AccountingProcessorHelper {
|
|||||||
public void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
|
public void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
|
||||||
final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate,
|
final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate,
|
||||||
final BigDecimal amount, final Boolean isReversal) {
|
final BigDecimal amount, final Boolean isReversal) {
|
||||||
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId, office.getId());
|
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||||
if (isReversal) {
|
if (isReversal) {
|
||||||
createCreditJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
createCreditJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
||||||
} else {
|
} else {
|
||||||
@@ -463,7 +459,7 @@ public class AccountingProcessorHelper {
|
|||||||
final 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, office.getId());
|
paymentTypeId);
|
||||||
if (isReversal) {
|
if (isReversal) {
|
||||||
createDebitJournalEntryForSavings(office, currencyCode, chargeSpecificAccount, loanId, transactionId, transactionDate,
|
createDebitJournalEntryForSavings(office, currencyCode, chargeSpecificAccount, loanId, transactionId, transactionDate,
|
||||||
totalAmount);
|
totalAmount);
|
||||||
@@ -488,7 +484,7 @@ public class AccountingProcessorHelper {
|
|||||||
private void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
|
private void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
|
||||||
final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate,
|
final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate,
|
||||||
final BigDecimal amount, final Boolean isReversal) {
|
final BigDecimal amount, final Boolean isReversal) {
|
||||||
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId, office.getId());
|
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
|
||||||
if (isReversal) {
|
if (isReversal) {
|
||||||
createDebitJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
createDebitJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
|
||||||
} else {
|
} else {
|
||||||
@@ -568,15 +564,12 @@ public class AccountingProcessorHelper {
|
|||||||
this.glJournalEntryRepository.saveAndFlush(journalEntry);
|
this.glJournalEntryRepository.saveAndFlush(journalEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
private GLAccount getLinkedGLAccountForLoanProduct(final Long loanProductId, final int accountMappingTypeId, final Long paymentTypeId,
|
private GLAccount getLinkedGLAccountForLoanProduct(final Long loanProductId, final int accountMappingTypeId, final Long paymentTypeId) {
|
||||||
Long officeId) {
|
|
||||||
GLAccount glAccount = null;
|
GLAccount glAccount = null;
|
||||||
if (isOrganizationAccount(accountMappingTypeId)) {
|
if (isOrganizationAccount(accountMappingTypeId)) {
|
||||||
FinancialActivityAccount financialActivityAccount = this.officeToGLAccountMappingRepository
|
FinancialActivityAccount financialActivityAccount = this.financialActivityAccountRepository
|
||||||
.findByFinancialActivityType(accountMappingTypeId);
|
.findByFinancialActivityTypeWithNotFoundDetection(accountMappingTypeId);
|
||||||
if (financialActivityAccount == null) { throw new FinancialActivityAccountNotFoundException(officeId,
|
glAccount = financialActivityAccount.getGlAccount();
|
||||||
String.valueOf(accountMappingTypeId)); }
|
|
||||||
glAccount = financialActivityAccount.glAccount();
|
|
||||||
} else {
|
} else {
|
||||||
ProductToGLAccountMapping accountMapping = this.accountMappingRepository.findCoreProductToFinAccountMapping(loanProductId,
|
ProductToGLAccountMapping accountMapping = this.accountMappingRepository.findCoreProductToFinAccountMapping(loanProductId,
|
||||||
PortfolioProductType.LOAN.getValue(), accountMappingTypeId);
|
PortfolioProductType.LOAN.getValue(), accountMappingTypeId);
|
||||||
@@ -649,14 +642,12 @@ public class AccountingProcessorHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GLAccount getLinkedGLAccountForSavingsProduct(final Long savingsProductId, final int accountMappingTypeId,
|
private GLAccount getLinkedGLAccountForSavingsProduct(final Long savingsProductId, final int accountMappingTypeId,
|
||||||
final Long paymentTypeId, Long officeId) {
|
final Long paymentTypeId) {
|
||||||
GLAccount glAccount = null;
|
GLAccount glAccount = null;
|
||||||
if (isOrganizationAccount(accountMappingTypeId)) {
|
if (isOrganizationAccount(accountMappingTypeId)) {
|
||||||
FinancialActivityAccount financialActivityAccount = this.officeToGLAccountMappingRepository
|
FinancialActivityAccount financialActivityAccount = this.financialActivityAccountRepository
|
||||||
.findByFinancialActivityType(accountMappingTypeId);
|
.findByFinancialActivityTypeWithNotFoundDetection(accountMappingTypeId);
|
||||||
if (financialActivityAccount == null) { throw new FinancialActivityAccountNotFoundException(officeId,
|
glAccount = financialActivityAccount.getGlAccount();
|
||||||
String.valueOf(accountMappingTypeId)); }
|
|
||||||
glAccount = financialActivityAccount.glAccount();
|
|
||||||
} else {
|
} else {
|
||||||
ProductToGLAccountMapping accountMapping = this.accountMappingRepository.findCoreProductToFinAccountMapping(savingsProductId,
|
ProductToGLAccountMapping accountMapping = this.accountMappingRepository.findCoreProductToFinAccountMapping(savingsProductId,
|
||||||
PortfolioProductType.SAVING.getValue(), accountMappingTypeId);
|
PortfolioProductType.SAVING.getValue(), accountMappingTypeId);
|
||||||
@@ -680,7 +671,7 @@ public class AccountingProcessorHelper {
|
|||||||
|
|
||||||
private boolean isOrganizationAccount(final int accountMappingTypeId) {
|
private boolean isOrganizationAccount(final int accountMappingTypeId) {
|
||||||
boolean isOrganizationAccount = false;
|
boolean isOrganizationAccount = false;
|
||||||
if (ORGANIZATION_ACCOUNTS.fromInt(accountMappingTypeId) != null) {
|
if (FINANCIAL_ACTIVITY.fromInt(accountMappingTypeId) != null) {
|
||||||
isOrganizationAccount = true;
|
isOrganizationAccount = true;
|
||||||
}
|
}
|
||||||
return isOrganizationAccount;
|
return isOrganizationAccount;
|
||||||
|
|||||||
+6
-6
@@ -11,7 +11,7 @@ import java.util.Date;
|
|||||||
import org.mifosplatform.accounting.closure.domain.GLClosure;
|
import org.mifosplatform.accounting.closure.domain.GLClosure;
|
||||||
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.ORGANIZATION_ACCOUNTS;
|
import org.mifosplatform.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY;
|
||||||
import org.mifosplatform.accounting.journalentry.data.LoanDTO;
|
import org.mifosplatform.accounting.journalentry.data.LoanDTO;
|
||||||
import org.mifosplatform.accounting.journalentry.data.LoanTransactionDTO;
|
import org.mifosplatform.accounting.journalentry.data.LoanTransactionDTO;
|
||||||
import org.mifosplatform.organisation.office.domain.Office;
|
import org.mifosplatform.organisation.office.domain.Office;
|
||||||
@@ -101,8 +101,8 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
// reversal)
|
// reversal)
|
||||||
if (loanTransactionDTO.isAccountTransfer()) {
|
if (loanTransactionDTO.isAccountTransfer()) {
|
||||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(),
|
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), loanProductId,
|
||||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversed);
|
paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversed);
|
||||||
} else {
|
} else {
|
||||||
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
this.helper.createAccrualBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||||
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId,
|
ACCRUAL_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), ACCRUAL_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId,
|
||||||
@@ -217,7 +217,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
} else {
|
} else {
|
||||||
if (loanTransactionDTO.isAccountTransfer()) {
|
if (loanTransactionDTO.isAccountTransfer()) {
|
||||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode,
|
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode,
|
||||||
ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(), loanProductId, paymentTypeId, loanId, transactionId,
|
FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), loanProductId, paymentTypeId, loanId, transactionId,
|
||||||
transactionDate, totalDebitAmount, isReversal);
|
transactionDate, totalDebitAmount, isReversal);
|
||||||
} else {
|
} else {
|
||||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode,
|
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode,
|
||||||
@@ -321,8 +321,8 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
|
|||||||
|
|
||||||
if (loanTransactionDTO.isAccountTransfer()) {
|
if (loanTransactionDTO.isAccountTransfer()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(),
|
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), loanProductId,
|
||||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal);
|
paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal);
|
||||||
} else {
|
} else {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId,
|
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId,
|
||||||
|
|||||||
+7
-8
@@ -10,7 +10,7 @@ import java.util.Date;
|
|||||||
|
|
||||||
import org.mifosplatform.accounting.closure.domain.GLClosure;
|
import org.mifosplatform.accounting.closure.domain.GLClosure;
|
||||||
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.ORGANIZATION_ACCOUNTS;
|
import org.mifosplatform.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY;
|
||||||
import org.mifosplatform.accounting.journalentry.data.LoanDTO;
|
import org.mifosplatform.accounting.journalentry.data.LoanDTO;
|
||||||
import org.mifosplatform.accounting.journalentry.data.LoanTransactionDTO;
|
import org.mifosplatform.accounting.journalentry.data.LoanTransactionDTO;
|
||||||
import org.mifosplatform.organisation.office.domain.Office;
|
import org.mifosplatform.organisation.office.domain.Office;
|
||||||
@@ -111,8 +111,8 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
|||||||
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
|
||||||
if (loanTransactionDTO.isAccountTransfer()) {
|
if (loanTransactionDTO.isAccountTransfer()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(),
|
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), loanProductId,
|
||||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversal);
|
paymentTypeId, loanId, transactionId, transactionDate, disbursalAmount, isReversal);
|
||||||
} else {
|
} else {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId,
|
CASH_ACCOUNTS_FOR_LOAN.LOAN_PORTFOLIO.getValue(), CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId,
|
||||||
@@ -147,8 +147,8 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
|||||||
|
|
||||||
if (loanTransactionDTO.isAccountTransfer()) {
|
if (loanTransactionDTO.isAccountTransfer()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(),
|
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), loanProductId,
|
||||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal);
|
paymentTypeId, loanId, transactionId, transactionDate, refundAmount, isReversal);
|
||||||
} else {
|
} else {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForLoan(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId,
|
CASH_ACCOUNTS_FOR_LOAN.OVERPAYMENT.getValue(), CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(), loanProductId,
|
||||||
@@ -218,9 +218,8 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
|
|||||||
|
|
||||||
/*** create a single debit entry (or reversal) for the entire amount **/
|
/*** create a single debit entry (or reversal) for the entire amount **/
|
||||||
if (loanTransactionDTO.isAccountTransfer()) {
|
if (loanTransactionDTO.isAccountTransfer()) {
|
||||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode,
|
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(),
|
||||||
ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(), loanProductId, paymentTypeId, loanId, transactionId,
|
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||||
transactionDate, totalDebitAmount, isReversal);
|
|
||||||
} else {
|
} else {
|
||||||
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(),
|
this.helper.createDebitJournalEntryOrReversalForLoan(office, currencyCode, CASH_ACCOUNTS_FOR_LOAN.FUND_SOURCE.getValue(),
|
||||||
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
loanProductId, paymentTypeId, loanId, transactionId, transactionDate, totalDebitAmount, isReversal);
|
||||||
|
|||||||
+14
-16
@@ -11,7 +11,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.mifosplatform.accounting.closure.domain.GLClosure;
|
import org.mifosplatform.accounting.closure.domain.GLClosure;
|
||||||
import org.mifosplatform.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SAVINGS;
|
import org.mifosplatform.accounting.common.AccountingConstants.CASH_ACCOUNTS_FOR_SAVINGS;
|
||||||
import org.mifosplatform.accounting.common.AccountingConstants.ORGANIZATION_ACCOUNTS;
|
import org.mifosplatform.accounting.common.AccountingConstants.FINANCIAL_ACTIVITY;
|
||||||
import org.mifosplatform.accounting.journalentry.data.ChargePaymentDTO;
|
import org.mifosplatform.accounting.journalentry.data.ChargePaymentDTO;
|
||||||
import org.mifosplatform.accounting.journalentry.data.SavingsDTO;
|
import org.mifosplatform.accounting.journalentry.data.SavingsDTO;
|
||||||
import org.mifosplatform.accounting.journalentry.data.SavingsTransactionDTO;
|
import org.mifosplatform.accounting.journalentry.data.SavingsTransactionDTO;
|
||||||
@@ -52,13 +52,13 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
|||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(),
|
||||||
ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(), savingsProductId, paymentTypeId, savingsId,
|
FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), savingsProductId, paymentTypeId, savingsId, transactionId,
|
||||||
transactionId, transactionDate, overdraftAmount, isReversal);
|
transactionDate, overdraftAmount, isReversal);
|
||||||
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) {
|
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(),
|
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(),
|
||||||
ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(), savingsProductId, paymentTypeId, savingsId,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
||||||
transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal);
|
amount.subtract(overdraftAmount), isReversal);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
@@ -75,14 +75,14 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
|||||||
} else if (savingsTransactionDTO.getTransactionType().isDeposit() && savingsTransactionDTO.isOverdraftTransaction()) {
|
} else if (savingsTransactionDTO.getTransactionType().isDeposit() && savingsTransactionDTO.isOverdraftTransaction()) {
|
||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(),
|
FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(),
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
CASH_ACCOUNTS_FOR_SAVINGS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
||||||
transactionId, transactionDate, overdraftAmount, isReversal);
|
transactionId, transactionDate, overdraftAmount, isReversal);
|
||||||
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) {
|
if (amount.subtract(overdraftAmount).compareTo(BigDecimal.ZERO) == 1) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(),
|
FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(),
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate,
|
||||||
transactionId, transactionDate, amount.subtract(overdraftAmount), isReversal);
|
amount.subtract(overdraftAmount), isReversal);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
@@ -102,9 +102,8 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
|||||||
else if (savingsTransactionDTO.getTransactionType().isDeposit()) {
|
else if (savingsTransactionDTO.getTransactionType().isDeposit()) {
|
||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(),
|
FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(),
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), savingsProductId, paymentTypeId, savingsId,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
transactionId, transactionDate, amount, isReversal);
|
|
||||||
} else {
|
} else {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(),
|
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(),
|
||||||
@@ -116,9 +115,8 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
|
|||||||
else if (savingsTransactionDTO.getTransactionType().isWithdrawal()) {
|
else if (savingsTransactionDTO.getTransactionType().isWithdrawal()) {
|
||||||
if (savingsTransactionDTO.isAccountTransfer()) {
|
if (savingsTransactionDTO.isAccountTransfer()) {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(),
|
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(),
|
||||||
ORGANIZATION_ACCOUNTS.LIABILITY_TRANSFER_SUSPENSE.getValue(), savingsProductId, paymentTypeId, savingsId,
|
savingsProductId, paymentTypeId, savingsId, transactionId, transactionDate, amount, isReversal);
|
||||||
transactionId, transactionDate, amount, isReversal);
|
|
||||||
} else {
|
} else {
|
||||||
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
this.helper.createCashBasedJournalEntriesAndReversalsForSavings(office, currencyCode,
|
||||||
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(),
|
CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_CONTROL.getValue(), CASH_ACCOUNTS_FOR_SAVINGS.SAVINGS_REFERENCE.getValue(),
|
||||||
|
|||||||
+2
-2
@@ -834,8 +834,8 @@ public class CommandWrapper {
|
|||||||
|
|
||||||
// End - Deposit accounts
|
// End - Deposit accounts
|
||||||
|
|
||||||
public boolean isOfficeToGLAccountMapping() {
|
public boolean isFinancialActivityAccountMapping() {
|
||||||
return this.entityName.equalsIgnoreCase("OFFICEGLACCOUNT");
|
return this.entityName.equalsIgnoreCase("FINANCIALACTIVITYACCOUNT");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRegisterDatatable() {
|
public boolean isRegisterDatatable() {
|
||||||
|
|||||||
+3
-3
@@ -1960,7 +1960,7 @@ public class CommandWrapperBuilder {
|
|||||||
|
|
||||||
public CommandWrapperBuilder createOfficeToGLAccountMapping() {
|
public CommandWrapperBuilder createOfficeToGLAccountMapping() {
|
||||||
this.actionName = "CREATE";
|
this.actionName = "CREATE";
|
||||||
this.entityName = "OFFICEGLACCOUNT";
|
this.entityName = "FINANCIALACTIVITYACCOUNT";
|
||||||
this.entityId = null;
|
this.entityId = null;
|
||||||
this.href = "/organizationglaccounts/template";
|
this.href = "/organizationglaccounts/template";
|
||||||
return this;
|
return this;
|
||||||
@@ -1968,7 +1968,7 @@ public class CommandWrapperBuilder {
|
|||||||
|
|
||||||
public CommandWrapperBuilder updateOfficeToGLAccountMapping(final Long mappingId) {
|
public CommandWrapperBuilder updateOfficeToGLAccountMapping(final Long mappingId) {
|
||||||
this.actionName = "UPDATE";
|
this.actionName = "UPDATE";
|
||||||
this.entityName = "OFFICEGLACCOUNT";
|
this.entityName = "FINANCIALACTIVITYACCOUNT";
|
||||||
this.entityId = mappingId;
|
this.entityId = mappingId;
|
||||||
this.href = "/organizationglaccounts/" + mappingId;
|
this.href = "/organizationglaccounts/" + mappingId;
|
||||||
return this;
|
return this;
|
||||||
@@ -1976,7 +1976,7 @@ public class CommandWrapperBuilder {
|
|||||||
|
|
||||||
public CommandWrapperBuilder deleteOfficeToGLAccountMapping(final Long mappingId) {
|
public CommandWrapperBuilder deleteOfficeToGLAccountMapping(final Long mappingId) {
|
||||||
this.actionName = "DELETE";
|
this.actionName = "DELETE";
|
||||||
this.entityName = "OFFICEGLACCOUNT";
|
this.entityName = "FINANCIALACTIVITYACCOUNT";
|
||||||
this.entityId = mappingId;
|
this.entityId = mappingId;
|
||||||
this.href = "/organizationglaccounts/" + mappingId;
|
this.href = "/organizationglaccounts/" + mappingId;
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
+1
-1
@@ -788,7 +788,7 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
|
|||||||
throw new UnsupportedCommandException(wrapper.commandName());
|
throw new UnsupportedCommandException(wrapper.commandName());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (wrapper.isOfficeToGLAccountMapping()) {
|
} else if (wrapper.isFinancialActivityAccountMapping()) {
|
||||||
if (wrapper.isCreate()) {
|
if (wrapper.isCreate()) {
|
||||||
handler = this.applicationContext.getBean("createFinancialActivityAccountHandler", NewCommandSourceHandler.class);
|
handler = this.applicationContext.getBean("createFinancialActivityAccountHandler", NewCommandSourceHandler.class);
|
||||||
} else if (wrapper.isUpdate()) {
|
} else if (wrapper.isUpdate()) {
|
||||||
|
|||||||
+1
-2
@@ -32,7 +32,6 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
import org.hibernate.annotations.LazyCollection;
|
import org.hibernate.annotations.LazyCollection;
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
import org.hibernate.annotations.LazyCollectionOption;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.Years;
|
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
import org.mifosplatform.infrastructure.codes.domain.CodeValue;
|
import org.mifosplatform.infrastructure.codes.domain.CodeValue;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
@@ -787,7 +786,7 @@ public final class Client extends AbstractPersistable<Long> {
|
|||||||
return this.dateOfBirth;
|
return this.dateOfBirth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate dateOfBirthLocalDate(){
|
public LocalDate dateOfBirthLocalDate() {
|
||||||
LocalDate dateOfBirth = null;
|
LocalDate dateOfBirth = null;
|
||||||
if (this.dateOfBirth != null) {
|
if (this.dateOfBirth != null) {
|
||||||
dateOfBirth = LocalDate.fromDateFields(this.dateOfBirth);
|
dateOfBirth = LocalDate.fromDateFields(this.dateOfBirth);
|
||||||
|
|||||||
-1
@@ -53,7 +53,6 @@ public class InterestRateChartSlabFields {
|
|||||||
@Column(name = "annual_interest_rate", scale = 6, precision = 19, nullable = false)
|
@Column(name = "annual_interest_rate", scale = 6, precision = 19, nullable = false)
|
||||||
private BigDecimal annualInterestRate;
|
private BigDecimal annualInterestRate;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Column(name = "currency_code", nullable = false)
|
@Column(name = "currency_code", nullable = false)
|
||||||
private String currencyCode;
|
private String currencyCode;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user