Merge branch 'develop' of github.com:openMF/mifosx into develop

This commit is contained in:
Vishwas Babu A J
2015-03-04 22:44:14 +05:30
6 changed files with 36 additions and 34 deletions
@@ -222,8 +222,8 @@ public class AccountingConstants {
public static enum FINANCIAL_ACTIVITY {
ASSET_TRANSFER(100, "assetTransfer", GLAccountType.ASSET), LIABILITY_TRANSFER(200, "liabilityTransfer", GLAccountType.LIABILITY),
CASH_AT_MAINVAULT (300, "cashAtMainVault", GLAccountType.ASSET),
CASH_AT_TELLER (400, "cashAtTeller", GLAccountType.ASSET);
CASH_AT_MAINVAULT (101, "cashAtMainVault", GLAccountType.ASSET),
CASH_AT_TELLER (102, "cashAtTeller", GLAccountType.ASSET),OPENING_BALANCES_TRANSFER_CONTRA (300,"openingBalancesTransferContra",GLAccountType.EQUITY);;
private final Integer value;
private final String code;
@@ -86,6 +86,14 @@ public class AccountingDropdownReadPlatformServiceImpl implements AccountingDrop
liabilityAccountOptions = null;
}
accountOptions.put("liabilityAccountOptions", liabilityAccountOptions);
List<GLAccountData> equityAccountOptions = this.accountReadPlatformService
.retrieveAllEnabledDetailGLAccounts(GLAccountType.EQUITY);
if (equityAccountOptions.isEmpty()) {
equityAccountOptions = null;
}
accountOptions.put("equityAccountOptions",equityAccountOptions);
return accountOptions;
}
@@ -19,7 +19,7 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
@Table(name = "acc_gl_financial_activity_account")
public class FinancialActivityAccount extends AbstractPersistable<Long> {
@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "gl_account_id")
private GLAccount glAccount;
@@ -54,7 +54,7 @@ public final class FinancialActivityAccountDataValidator {
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(),
FINANCIAL_ACTIVITY.CASH_AT_MAINVAULT.getValue(), FINANCIAL_ACTIVITY.CASH_AT_TELLER.getValue());
FINANCIAL_ACTIVITY.CASH_AT_MAINVAULT.getValue(), FINANCIAL_ACTIVITY.CASH_AT_TELLER.getValue(),FINANCIAL_ACTIVITY.OPENING_BALANCES_TRANSFER_CONTRA.getValue());
final Long glAccountId = this.fromApiJsonHelper.extractLongNamed(paramNameForGLAccount, element);
baseDataValidator.reset().parameter(paramNameForGLAccount).value(glAccountId).notNull().integerGreaterThanZero();
@@ -79,7 +79,7 @@ public final class FinancialActivityAccountDataValidator {
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());
.isOneOfTheseValues(FINANCIAL_ACTIVITY.ASSET_TRANSFER.getValue(), FINANCIAL_ACTIVITY.LIABILITY_TRANSFER.getValue(),FINANCIAL_ACTIVITY.OPENING_BALANCES_TRANSFER_CONTRA.getValue());
}
if (this.fromApiJsonHelper.parameterExists(paramNameForGLAccount, element)) {
@@ -18,6 +18,8 @@ import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.joda.time.LocalDate;
import org.mifosplatform.accounting.common.AccountingEnumerations;
import org.mifosplatform.accounting.financialactivityaccount.domain.FinancialActivityAccount;
import org.mifosplatform.accounting.financialactivityaccount.domain.FinancialActivityAccountRepositoryWrapper;
import org.mifosplatform.accounting.glaccount.data.GLAccountData;
import org.mifosplatform.accounting.glaccount.domain.GLAccountType;
import org.mifosplatform.accounting.glaccount.service.GLAccountReadPlatformService;
@@ -28,7 +30,6 @@ import org.mifosplatform.accounting.journalentry.data.TransactionDetailData;
import org.mifosplatform.accounting.journalentry.data.TransactionTypeEnumData;
import org.mifosplatform.accounting.journalentry.exception.JournalEntriesNotFoundException;
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomainService;
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
import org.mifosplatform.infrastructure.core.exception.GeneralPlatformDomainRuleException;
@@ -58,20 +59,19 @@ import org.springframework.util.CollectionUtils;
public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlatformService {
private final JdbcTemplate jdbcTemplate;
private final ConfigurationDomainService configurationDomainService;
private final GLAccountReadPlatformService glAccountReadPlatformService;
private final OfficeReadPlatformService officeReadPlatformService;
private final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepositoryWrapper;
private final PaginationHelper<JournalEntryData> paginationHelper = new PaginationHelper<>();
@Autowired
public JournalEntryReadPlatformServiceImpl(final RoutingDataSource dataSource,
final ConfigurationDomainService configurationDomainService, final GLAccountReadPlatformService glAccountReadPlatformService,
final OfficeReadPlatformService officeReadPlatformService) {
public JournalEntryReadPlatformServiceImpl(final RoutingDataSource dataSource, final GLAccountReadPlatformService glAccountReadPlatformService,
final OfficeReadPlatformService officeReadPlatformService, final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepositoryWrapper) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.configurationDomainService = configurationDomainService;
this.glAccountReadPlatformService = glAccountReadPlatformService;
this.officeReadPlatformService = officeReadPlatformService;
this.financialActivityAccountRepositoryWrapper = financialActivityAccountRepositoryWrapper;
}
private static final class GLJournalEntryMapper implements RowMapper<JournalEntryData> {
@@ -356,15 +356,12 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
@Override
public OfficeOpeningBalancesData retrieveOfficeOpeningBalances(final Long officeId) {
/**
* Global configuration 'office-opening-balances-contra-account'
* property value must not be null and it should be a equity account.
*/
final Long contraId = this.configurationDomainService.retrieveOpeningBalancesContraAccount();
if (contraId == null) { throw new GeneralPlatformDomainRuleException(
"error.msg.configuration.opening.balance.contra.account.cannot.be.null",
"Configuration property 'office-opening-balances-contra-account' value can not be null",
"office-opening-balances-contra-account"); }
final FinancialActivityAccount financialActivityAccountId = this.financialActivityAccountRepositoryWrapper.findByFinancialActivityTypeWithNotFoundDetection(300);
final Long contraId = financialActivityAccountId.getGlAccount().getId();
if (contraId == null) { throw new GeneralPlatformDomainRuleException(
"error.msg.financial.activity.mapping.opening.balance.contra.account.cannot.be.null",
"office-opening-balances-contra-account value can not be null",
"office-opening-balances-contra-account");}
final JournalEntryAssociationParametersData associationParametersData = new JournalEntryAssociationParametersData();
final GLAccountData contraAccount = this.glAccountReadPlatformService.retrieveGLAccountById(contraId, associationParametersData);
@@ -16,6 +16,8 @@ import org.apache.commons.lang.StringUtils;
import org.joda.time.LocalDate;
import org.mifosplatform.accounting.closure.domain.GLClosure;
import org.mifosplatform.accounting.closure.domain.GLClosureRepository;
import org.mifosplatform.accounting.financialactivityaccount.domain.FinancialActivityAccount;
import org.mifosplatform.accounting.financialactivityaccount.domain.FinancialActivityAccountRepositoryWrapper;
import org.mifosplatform.accounting.glaccount.data.GLAccountDataForLookup;
import org.mifosplatform.accounting.glaccount.domain.GLAccount;
import org.mifosplatform.accounting.glaccount.domain.GLAccountRepository;
@@ -80,7 +82,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
private final OrganisationCurrencyRepositoryWrapper organisationCurrencyRepository;
private final PlatformSecurityContext context;
private final PaymentDetailWritePlatformService paymentDetailWritePlatformService;
private final ConfigurationDomainService configurationDomainService;
private final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepositoryWrapper;
@Autowired
public JournalEntryWritePlatformServiceJpaRepositoryImpl(final GLClosureRepository glClosureRepository,
@@ -91,8 +93,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final AccountingProcessorForSavingsFactory accountingProcessorForSavingsFactory,
final GLAccountReadPlatformService glAccountReadPlatformService,
final OrganisationCurrencyRepositoryWrapper organisationCurrencyRepository, final PlatformSecurityContext context,
final PaymentDetailWritePlatformService paymentDetailWritePlatformService,
final ConfigurationDomainService configurationDomainService) {
final PaymentDetailWritePlatformService paymentDetailWritePlatformService,final FinancialActivityAccountRepositoryWrapper financialActivityAccountRepositoryWrapper) {
this.glClosureRepository = glClosureRepository;
this.officeRepository = officeRepository;
this.glJournalEntryRepository = glJournalEntryRepository;
@@ -106,7 +107,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
this.organisationCurrencyRepository = organisationCurrencyRepository;
this.context = context;
this.paymentDetailWritePlatformService = paymentDetailWritePlatformService;
this.configurationDomainService = configurationDomainService;
this.financialActivityAccountRepositoryWrapper = financialActivityAccountRepositoryWrapper;
}
@Transactional
@@ -450,16 +451,12 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final JournalEntryCommand journalEntryCommand = this.fromApiJsonDeserializer.commandFromApiJson(command.json());
journalEntryCommand.validateForCreate();
/**
* Global configuration 'office-opening-balances-contra-account'
* property value must not be null and it should be a equity
* account.
*/
final Long contraId = this.configurationDomainService.retrieveOpeningBalancesContraAccount();
if (contraId == null) { throw new GeneralPlatformDomainRuleException(
"error.msg.configuration.opening.balance.contra.account.cannot.be.null",
"Configuration property 'office-opening-balances-contra-account' value can not be null",
"office-opening-balances-contra-account"); }
final FinancialActivityAccount financialActivityAccountId = this.financialActivityAccountRepositoryWrapper.findByFinancialActivityTypeWithNotFoundDetection(300);
final Long contraId = financialActivityAccountId.getGlAccount().getId();
if (contraId == null) { throw new GeneralPlatformDomainRuleException(
"error.msg.financial.activity.mapping.opening.balance.contra.account.cannot.be.null",
"office-opening-balances-contra-account value can not be null",
"office-opening-balances-contra-account");}
validateJournalEntriesArePostedBefore(contraId);