Search in sources :

Example 11 with COABO

use of org.mifos.accounts.financial.business.COABO in project head by mifos.

the class ChartOfAccountsCacheTest method testAddAndGet.

public void testAddAndGet() throws FinancialException {
    COABO cachedAccount = ChartOfAccountsCache.get(GL_CODE);
    Assert.assertEquals(GL_CODE, cachedAccount.getGlCode());
    Assert.assertEquals(ACCOUNT_NAME, cachedAccount.getAccountName());
    Assert.assertEquals(testAccount, cachedAccount);
}
Also used : COABO(org.mifos.accounts.financial.business.COABO)

Example 12 with COABO

use of org.mifos.accounts.financial.business.COABO in project head by mifos.

the class CoaServiceFacadeWebTier method delete.

@Override
public void delete(Short id) {
    try {
        COABO coaBo = legacyAccountDao.getPersistentObject(COABO.class, id);
        if (coaBo == null || !isModifiable(coaBo)) {
            throw new BusinessRuleException(CANNOT_MODIFY);
        }
        legacyAccountDao.deleteLedgerAccount(coaBo.getAccountId());
        reloadCache();
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) COABO(org.mifos.accounts.financial.business.COABO) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 13 with COABO

use of org.mifos.accounts.financial.business.COABO in project head by mifos.

the class CoaServiceFacadeWebTier method getList.

@Override
public List<CoaDto> getList(Short id) {
    List<COABO> coaBoList = null;
    if (id == null) {
        coaBoList = legacyAccountDao.getCOAlist();
    } else {
        coaBoList = legacyAccountDao.getCOAChildList(id);
    }
    List<CoaDto> coaDtoList = new ArrayList<CoaDto>();
    boolean userHasAccess = canModifyCOA();
    for (COABO coaBo : coaBoList) {
        CoaDto dto = coaBo.toDto();
        if (userHasAccess) {
            dto.setModifiable(isModifiable(coaBo));
        } else {
            dto.setModifiable(false);
        }
        coaDtoList.add(dto);
    }
    return coaDtoList;
}
Also used : CoaDto(org.mifos.application.admin.servicefacade.CoaDto) COABO(org.mifos.accounts.financial.business.COABO) ArrayList(java.util.ArrayList)

Example 14 with COABO

use of org.mifos.accounts.financial.business.COABO in project head by mifos.

the class FinancialBusinessService method getGLCodes.

/**
     * @deprecated - use {@link GeneralLedgerDao#retreiveGlCodesBy(FinancialActionConstants, FinancialConstants)}
     */
@Deprecated
public List<GLCodeEntity> getGLCodes(FinancialActionConstants financialAction, FinancialConstants debitCredit) throws SystemException, ApplicationException {
    List<GLCodeEntity> glCodeList = new ArrayList<GLCodeEntity>();
    Set<COABO> applicableCategory = null;
    FinancialActionTypeEntity finActionFees = FinancialActionCache.getFinancialAction(financialAction);
    if (debitCredit.equals(FinancialConstants.DEBIT)) {
        applicableCategory = finActionFees.getApplicableDebitCharts();
    } else if (debitCredit.equals(FinancialConstants.CREDIT)) {
        applicableCategory = finActionFees.getApplicableCreditCharts();
    }
    for (COABO chartOfAccounts : applicableCategory) {
        GLCodeEntity codeEntity = new GLCodeEntity(chartOfAccounts.getAssociatedGlcode().getGlcodeId(), chartOfAccounts.getAssociatedGlcode().getGlcode(), chartOfAccounts.getAssociatedGlcode().getAssociatedCOA());
        glCodeList.add(codeEntity);
    }
    return glCodeList;
}
Also used : FinancialActionTypeEntity(org.mifos.accounts.financial.business.FinancialActionTypeEntity) COABO(org.mifos.accounts.financial.business.COABO) ArrayList(java.util.ArrayList) GLCodeEntity(org.mifos.accounts.financial.business.GLCodeEntity)

Example 15 with COABO

use of org.mifos.accounts.financial.business.COABO in project head by mifos.

the class CoaServiceFacadeWebTier method modify.

@Override
public void modify(CoaDto coaDto) {
    try {
        COABO coaBo = legacyAccountDao.getPersistentObject(COABO.class, coaDto.getAccountId());
        Short parentId = legacyAccountDao.getAccountIdFromGlCode(coaDto.getParentGlCode());
        Short accountId = legacyAccountDao.getAccountIdFromGlCode(coaDto.getGlCodeString());
        if (!StringUtils.hasText(coaDto.getGlCodeString())) {
            throw new BusinessRuleException(EMPTY_GLCODE);
        }
        if (accountId != null && !accountId.equals(coaBo.getAccountId())) {
            throw new BusinessRuleException(GLCODE_ALREADY_EXISTS);
        }
        if (coaBo == null || !isModifiable(coaBo)) {
            throw new BusinessRuleException(CANNOT_MODIFY);
        }
        if (parentId == null) {
            throw new BusinessRuleException(PARENT_DOESNT_EXIST);
        }
        legacyAccountDao.updateLedgerAccount(coaBo, coaDto.getAccountName(), coaDto.getGlCodeString(), coaDto.getParentGlCode());
        reloadCache();
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) COABO(org.mifos.accounts.financial.business.COABO) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

COABO (org.mifos.accounts.financial.business.COABO)28 GLCodeEntity (org.mifos.accounts.financial.business.GLCodeEntity)10 FinancialActionTypeEntity (org.mifos.accounts.financial.business.FinancialActionTypeEntity)6 Query (org.hibernate.Query)5 ArrayList (java.util.ArrayList)4 COAHierarchyEntity (org.mifos.accounts.financial.business.COAHierarchyEntity)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 PersistenceException (org.mifos.framework.exceptions.PersistenceException)4 Session (org.hibernate.Session)3 Test (org.junit.Test)3 FinancialActionConstants (org.mifos.accounts.financial.util.helpers.FinancialActionConstants)3 LegacyAccountDao (org.mifos.accounts.persistence.LegacyAccountDao)3 HashMap (java.util.HashMap)2 BeforeClass (org.junit.BeforeClass)2 FinancialException (org.mifos.accounts.financial.exceptions.FinancialException)2 ChartOfAccountsCache (org.mifos.accounts.financial.util.helpers.ChartOfAccountsCache)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Iterator (java.util.Iterator)1