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);
}
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);
}
}
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;
}
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;
}
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);
}
}
Aggregations