Merge remote-tracking branch 'goutham/Mifosx-286' into develop
This commit is contained in:
+40
@@ -127,4 +127,44 @@ public class GLAccountData {
|
|||||||
return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, type, usage, description, nameDecorated, tagId);
|
return new GLAccountData(id, name, parentId, glCode, disabled, manualEntriesAllowed, type, usage, description, nameDecorated, tagId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GLAccountData(final Long id, final String name, final String glCode) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.parentId = null;
|
||||||
|
this.glCode = glCode;
|
||||||
|
this.disabled = false;
|
||||||
|
this.manualEntriesAllowed = false;
|
||||||
|
this.type = null;
|
||||||
|
this.usage = null;
|
||||||
|
this.description = null;
|
||||||
|
this.nameDecorated = null;
|
||||||
|
this.tagId = null;
|
||||||
|
this.accountTypeOptions = null;
|
||||||
|
this.usageOptions = null;
|
||||||
|
this.assetHeaderAccountOptions = null;
|
||||||
|
this.liabilityHeaderAccountOptions = null;
|
||||||
|
this.equityHeaderAccountOptions = null;
|
||||||
|
this.incomeHeaderAccountOptions = null;
|
||||||
|
this.expenseHeaderAccountOptions = null;
|
||||||
|
this.allowedAssetsTagOptions = null;
|
||||||
|
this.allowedLiabilitiesTagOptions = null;
|
||||||
|
this.allowedEquityTagOptions=null;
|
||||||
|
this.allowedIncomeTagOptions=null;
|
||||||
|
this.allowedExpensesTagOptions=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGlCode() {
|
||||||
|
return this.glCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-1
@@ -83,7 +83,7 @@ public class AccountingRuleApiResource {
|
|||||||
|
|
||||||
context.authenticatedUser().validateHasReadPermission(resourceNameForPermission);
|
context.authenticatedUser().validateHasReadPermission(resourceNameForPermission);
|
||||||
|
|
||||||
AccountingRuleData accountingRuleData = this.accountingRuleReadPlatformService.retrieveNewAccountingRuleDetails();
|
AccountingRuleData accountingRuleData = null;
|
||||||
accountingRuleData = handleTemplate(accountingRuleData);
|
accountingRuleData = handleTemplate(accountingRuleData);
|
||||||
|
|
||||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ 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 loan product
|
||||||
***/
|
***/
|
||||||
public enum AccountingRuleJsonInputParams {
|
public enum AccountingRuleJsonInputParams {
|
||||||
ID("id"), OFFICE_ID("officeId"), ACCOUNT_TO_DEBIT("accountToDebitId"), ACCOUNT_TO_CREDIT("accountToCreditId"), NAME("name"), DESCRIPTION(
|
ID("id"), OFFICE_ID("officeId"), ACCOUNT_TO_DEBIT("debitAccountHead"), ACCOUNT_TO_CREDIT("creditAccountHead"), NAME("name"), DESCRIPTION(
|
||||||
"description"), SYSTEM_DEFINED("systemDefined");
|
"description"), SYSTEM_DEFINED("systemDefined");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
|
|||||||
+2
-2
@@ -62,9 +62,9 @@ public class AccountingRuleCommand {
|
|||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("AccountingRule");
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("AccountingRule");
|
||||||
|
|
||||||
baseDataValidator.reset().parameter(AccountingRuleJsonInputParams.ACCOUNT_TO_DEBIT.getValue()).value(this.accountToDebitId)
|
baseDataValidator.reset().parameter(AccountingRuleJsonInputParams.ACCOUNT_TO_DEBIT.getValue()).value(this.accountToDebitId)
|
||||||
.ignoreIfNull().integerGreaterThanZero();
|
.ignoreIfNull().notBlank().integerGreaterThanZero();
|
||||||
baseDataValidator.reset().parameter(AccountingRuleJsonInputParams.ACCOUNT_TO_CREDIT.getValue()).value(this.accountToCreditId)
|
baseDataValidator.reset().parameter(AccountingRuleJsonInputParams.ACCOUNT_TO_CREDIT.getValue()).value(this.accountToCreditId)
|
||||||
.ignoreIfNull().integerGreaterThanZero();
|
.ignoreIfNull().notBlank().integerGreaterThanZero();
|
||||||
baseDataValidator.reset().parameter(AccountingRuleJsonInputParams.OFFICE_ID.getValue()).value(this.officeId).ignoreIfNull()
|
baseDataValidator.reset().parameter(AccountingRuleJsonInputParams.OFFICE_ID.getValue()).value(this.officeId).ignoreIfNull()
|
||||||
.integerGreaterThanZero();
|
.integerGreaterThanZero();
|
||||||
baseDataValidator.reset().parameter(AccountingRuleJsonInputParams.NAME.getValue()).value(this.name).ignoreIfNull().notBlank()
|
baseDataValidator.reset().parameter(AccountingRuleJsonInputParams.NAME.getValue()).value(this.name).ignoreIfNull().notBlank()
|
||||||
|
|||||||
+28
-32
@@ -22,15 +22,11 @@ public class AccountingRuleData {
|
|||||||
private final Long id;
|
private final Long id;
|
||||||
private final Long officeId;
|
private final Long officeId;
|
||||||
private final String officeName;
|
private final String officeName;
|
||||||
private final Long accountToDebitId;
|
|
||||||
private final Long accountToCreditId;
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String description;
|
private final String description;
|
||||||
private final boolean systemDefined;
|
private final boolean systemDefined;
|
||||||
private final String debitAccountName;
|
private final GLAccountData debitAccountHead;
|
||||||
private final String creditAccountName;
|
private final GLAccountData creditAccountHead;
|
||||||
private final String debitAccountGLCode;
|
|
||||||
private final String creditAccountGLCode;
|
|
||||||
|
|
||||||
// template
|
// template
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@@ -38,36 +34,30 @@ public class AccountingRuleData {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private List<GLAccountData> allowedAccounts = new ArrayList<GLAccountData>();
|
private List<GLAccountData> allowedAccounts = new ArrayList<GLAccountData>();
|
||||||
|
|
||||||
public AccountingRuleData(final Long id, final Long accountToDebitId, final Long accountToCreditId) {
|
/*public AccountingRuleData(final Long id, final Long accountToDebitId, final Long accountToCreditId) {
|
||||||
this(id, null, null, accountToDebitId, accountToCreditId, null, null, true, null, null, null, null, null, null);
|
this(id, null, null, accountToDebitId, accountToCreditId, null, null, true, null, null, null, null, null, null);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public AccountingRuleData(final Long id, final Long officeId, final String officeName, final Long accountToDebitId,
|
/*public AccountingRuleData(final Long id, final Long officeId, final String officeName, final Long accountToDebitId,
|
||||||
final Long accountToCreditId, final String name, final String description, final boolean systemDefined,
|
final Long accountToCreditId, final String name, final String description, final boolean systemDefined,
|
||||||
final String debitAccountName, final String creditAccountName, final String debitAccountGLCode,
|
final String debitAccountName, final String creditAccountName, final String debitAccountGLCode,
|
||||||
final String creditAccountGLCode) {
|
final String creditAccountGLCode) {
|
||||||
this(id, officeId, officeName, accountToDebitId, accountToCreditId, name, description, systemDefined, debitAccountName,
|
this(id, officeId, officeName, accountToDebitId, accountToCreditId, name, description, systemDefined, debitAccountName,
|
||||||
creditAccountName, debitAccountGLCode, creditAccountGLCode, null, null);
|
creditAccountName, debitAccountGLCode, creditAccountGLCode, null, null);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public AccountingRuleData(final Long id, final Long officeId, final String officeName, final Long accountToDebitId,
|
public AccountingRuleData(final Long id, final Long officeId, final String officeName, final String name, final String description,
|
||||||
final Long accountToCreditId, final String name, final String description, final boolean systemDefined,
|
final boolean systemDefined, final List<OfficeData> allowedOffices, final List<GLAccountData> allowedAccounts) {
|
||||||
final String debitAccountName, final String creditAccountName, final String debitAccountGLCode,
|
|
||||||
final String creditAccountGLCode, final List<OfficeData> allowedOffices, final List<GLAccountData> allowedAccounts) {
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.officeId = officeId;
|
this.officeId = officeId;
|
||||||
this.officeName = officeName;
|
this.officeName = officeName;
|
||||||
this.accountToDebitId = accountToDebitId;
|
|
||||||
this.accountToCreditId = accountToCreditId;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.systemDefined = systemDefined;
|
this.systemDefined = systemDefined;
|
||||||
this.allowedOffices = allowedOffices;
|
this.allowedOffices = allowedOffices;
|
||||||
this.allowedAccounts = allowedAccounts;
|
this.allowedAccounts = allowedAccounts;
|
||||||
this.debitAccountName = debitAccountName;
|
this.debitAccountHead = null;
|
||||||
this.creditAccountName = creditAccountName;
|
this.creditAccountHead = null;
|
||||||
this.debitAccountGLCode = debitAccountGLCode;
|
|
||||||
this.creditAccountGLCode = creditAccountGLCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountingRuleData(final AccountingRuleData accountingRuleData,
|
public AccountingRuleData(final AccountingRuleData accountingRuleData,
|
||||||
@@ -75,33 +65,39 @@ public class AccountingRuleData {
|
|||||||
this.id = accountingRuleData.id;
|
this.id = accountingRuleData.id;
|
||||||
this.officeId = accountingRuleData.officeId;
|
this.officeId = accountingRuleData.officeId;
|
||||||
this.officeName = accountingRuleData.officeName;
|
this.officeName = accountingRuleData.officeName;
|
||||||
this.accountToDebitId = accountingRuleData.accountToDebitId;
|
|
||||||
this.accountToCreditId = accountingRuleData.accountToCreditId;
|
|
||||||
this.name = accountingRuleData.name;
|
this.name = accountingRuleData.name;
|
||||||
this.description = accountingRuleData.description;
|
this.description = accountingRuleData.description;
|
||||||
this.systemDefined = accountingRuleData.systemDefined;
|
this.systemDefined = accountingRuleData.systemDefined;
|
||||||
this.allowedOffices = allowedOffices;
|
this.allowedOffices = allowedOffices;
|
||||||
this.allowedAccounts = allowedAccounts;
|
this.allowedAccounts = allowedAccounts;
|
||||||
this.debitAccountName = accountingRuleData.debitAccountName;
|
this.debitAccountHead = accountingRuleData.debitAccountHead;
|
||||||
this.creditAccountName = accountingRuleData.creditAccountName;
|
this.creditAccountHead = accountingRuleData.creditAccountHead;
|
||||||
this.debitAccountGLCode = accountingRuleData.debitAccountGLCode;
|
|
||||||
this.creditAccountGLCode = accountingRuleData.creditAccountGLCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountingRuleData(final List<GLAccountData> allowedAccounts, final List<OfficeData> allowedOffices) {
|
public AccountingRuleData(final List<GLAccountData> allowedAccounts, final List<OfficeData> allowedOffices) {
|
||||||
this.id = null;
|
this.id = null;
|
||||||
this.officeId = null;
|
this.officeId = null;
|
||||||
this.officeName = null;
|
this.officeName = null;
|
||||||
this.accountToDebitId = null;
|
|
||||||
this.accountToCreditId = null;
|
|
||||||
this.name = null;
|
this.name = null;
|
||||||
this.description = null;
|
this.description = null;
|
||||||
this.systemDefined = false;
|
this.systemDefined = false;
|
||||||
this.allowedOffices = allowedOffices;
|
this.allowedOffices = allowedOffices;
|
||||||
this.allowedAccounts = allowedAccounts;
|
this.allowedAccounts = allowedAccounts;
|
||||||
this.debitAccountName = null;
|
this.debitAccountHead = null;
|
||||||
this.creditAccountName = null;
|
this.creditAccountHead = null;
|
||||||
this.debitAccountGLCode = null;
|
}
|
||||||
this.creditAccountGLCode = null;
|
|
||||||
|
public AccountingRuleData(Long id, Long officeId, String officeName, String name, String description,
|
||||||
|
boolean systemDefined, GLAccountData debitAccountData, GLAccountData creditAccountData) {
|
||||||
|
this.id = id;
|
||||||
|
this.officeId = officeId;
|
||||||
|
this.officeName = officeName;
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.systemDefined = systemDefined;
|
||||||
|
this.allowedOffices = null;
|
||||||
|
this.allowedAccounts = null;
|
||||||
|
this.debitAccountHead = debitAccountData;
|
||||||
|
this.creditAccountHead = creditAccountData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-2
@@ -15,6 +15,4 @@ public interface AccountingRuleReadPlatformService {
|
|||||||
|
|
||||||
AccountingRuleData retrieveAccountingRuleById(long accountingRuleId);
|
AccountingRuleData retrieveAccountingRuleById(long accountingRuleId);
|
||||||
|
|
||||||
AccountingRuleData retrieveNewAccountingRuleDetails();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-15
@@ -9,6 +9,7 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
|
||||||
import org.mifosplatform.accounting.rule.data.AccountingRuleData;
|
import org.mifosplatform.accounting.rule.data.AccountingRuleData;
|
||||||
import org.mifosplatform.accounting.rule.exception.AccountingRuleNotFoundException;
|
import org.mifosplatform.accounting.rule.exception.AccountingRuleNotFoundException;
|
||||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||||
@@ -35,7 +36,7 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
|
|||||||
|
|
||||||
public AccountingRuleMapper() {
|
public AccountingRuleMapper() {
|
||||||
final StringBuilder sqlBuilder = new StringBuilder(400);
|
final StringBuilder sqlBuilder = new StringBuilder(400);
|
||||||
sqlBuilder.append(" rule.id as id,rule.name as name, rule.office_id as officeId,office.name as officeName,")
|
sqlBuilder.append("distinct rule.id as id,rule.name as name, rule.office_id as officeId,office.name as officeName,")
|
||||||
.append(" rule.debit_account_id as debitAccountId,rule.credit_account_id as creditAccountId,")
|
.append(" rule.debit_account_id as debitAccountId,rule.credit_account_id as creditAccountId,")
|
||||||
.append(" rule.description as description, rule.system_defined as systemDefined, ")
|
.append(" rule.description as description, rule.system_defined as systemDefined, ")
|
||||||
.append("debitAccount.glName as debitAccountName, debitAccount.glCode as debitAccountGLCode,")
|
.append("debitAccount.glName as debitAccountName, debitAccount.glCode as debitAccountGLCode,")
|
||||||
@@ -69,22 +70,24 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
|
|||||||
final String debitAccountGLCode = rs.getString("debitAccountGLCode");
|
final String debitAccountGLCode = rs.getString("debitAccountGLCode");
|
||||||
final String creditAccountGLCode = rs.getString("creditAccountGLCode");
|
final String creditAccountGLCode = rs.getString("creditAccountGLCode");
|
||||||
|
|
||||||
return new AccountingRuleData(id, officeId, officeName, accountToDebitId, accountToCreditId, name, description, systemDefined,
|
final GLAccountData debitAccountData = new GLAccountData(accountToDebitId, debitAccountName, debitAccountGLCode);
|
||||||
debitAccountName, creditAccountName, debitAccountGLCode, creditAccountGLCode);
|
final GLAccountData creditAccountData = new GLAccountData(accountToCreditId, creditAccountName, creditAccountGLCode);
|
||||||
|
|
||||||
|
return new AccountingRuleData(id, officeId, officeName, name, description, systemDefined, debitAccountData, creditAccountData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AccountingRuleData> retrieveAllAccountingRules(Long officeId) {
|
public List<AccountingRuleData> retrieveAllAccountingRules(Long officeId) {
|
||||||
final AccountingRuleMapper rm = new AccountingRuleMapper();
|
final AccountingRuleMapper rm = new AccountingRuleMapper();
|
||||||
|
Object[] arguments = new Object[]{};
|
||||||
|
String sql = "select " + rm.schema() +" and system_defined=0 ";
|
||||||
if(officeId != null) {
|
if(officeId != null) {
|
||||||
String sql = "select " + rm.schema() + " where system_defined=0 and office.id = ?";
|
sql = sql +" and office.id = ?";
|
||||||
sql = sql + " order by rule.id asc";
|
arguments = new Object[] { officeId };
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] { officeId });
|
|
||||||
}
|
}
|
||||||
String sql = "select " + rm.schema() + " and system_defined=0 ";
|
|
||||||
sql = sql + " order by rule.id asc";
|
sql = sql + " order by rule.id asc";
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
return this.jdbcTemplate.query(sql, rm, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -100,11 +103,4 @@ public class AccountingRuleReadPlatformServiceImpl implements AccountingRuleRead
|
|||||||
throw new AccountingRuleNotFoundException(accountingRuleId);
|
throw new AccountingRuleNotFoundException(accountingRuleId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public AccountingRuleData retrieveNewAccountingRuleDetails() {
|
|
||||||
// Modify if any default values required
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user