use of org.mifos.accounts.financial.business.COABO in project head by mifos.
the class BaseAccountingEntry method getGLcode.
/**
* gets the general ledger code (an entity object) for the account to be credited or debited, from a set of COABO
* objects. If the set is empty, return null. If the set contains exactly one COABO object, return its associated
* GLCodeEntity. If the set contains two or more COABO objects, return the associated GLCodeEntity for one chosen at
* random (determined by the implementation of the set's iterator.)
* <p>
* The account returned must be at the lowest level in the chart-of-accounts hierarchy (see this <a href="http://www.mifos.org/knowledge/functional-specifications/system-setup/chart-of-accounts#debit-credit-financial-transactions"
* > functional specification</a>, "The entries should be made against the lowest level GL Code under a category".
* Subclasses enforces this rule by creating the set by invoking <code>COABO.getAssociatedChartOfAccounts()</code>
* which creates a set of only lowest-level COABO objects below the give COABO.
* <p>
* This random behavior occurs when the GL code mapped to by a financial action is not at the lowest level. For
* example, in the default financial action mapping,
*
* @param a set of GL accounts
* @return the GL account code entity of the member of the account set, if it contains just one account. If the set
* is empty, return null. If the set contains two or more accounts, return an account code chosen at random.
*/
protected GLCodeEntity getGLcode(final Set<COABO> chartsOfAccounts) {
Iterator<COABO> iter = chartsOfAccounts.iterator();
GLCodeEntity glcode = null;
while (iter.hasNext()) {
glcode = iter.next().getAssociatedGlcode();
}
return glcode;
}
use of org.mifos.accounts.financial.business.COABO in project head by mifos.
the class InterestPostingAccountingEntryTest method setupAndInjectMocks.
@Before
public void setupAndInjectMocks() {
// Build a little Chart of Accounts
coaLiability = makeCategory((short) 1, GLCategoryType.LIABILITY, "22000");
coaSavingsInterestPayable = makeChildCoaboOf(coaLiability, (short) 2, "SavingsInterest Payable", "22100");
coaClientsSavings = makeChildCoaboOf(coaLiability, (short) 3, "ClientsSavings", "22200");
interestPostingAccountingEntry = new InterestPostingAccountingEntry() {
@Override
protected FinancialActionTypeEntity getFinancialAction(@SuppressWarnings("unused") final FinancialActionConstants financialActionId) throws FinancialException {
return financialAction;
}
@Override
protected COABO getChartOfAccountsEntry(final String glcode) throws FinancialException {
if (glcode.equals("22000")) {
return coaLiability;
} else if (glcode.equals("22100")) {
return coaSavingsInterestPayable;
} else if (glcode.equals("22200")) {
return coaClientsSavings;
} else {
throw new FinancialException("unexpected glcode: " + glcode);
}
}
};
}
use of org.mifos.accounts.financial.business.COABO in project head by mifos.
the class InterestPostingAccountingEntryTest method makeCategory.
protected COABO makeCategory(Short categoryId, GLCategoryType categoryType, String glCode) {
COABO category = new COABO(categoryId, categoryType.name(), new GLCodeEntity(categoryId, glCode));
COAHierarchyEntity hierarchy = new COAHierarchyEntity(category, null);
category.setCoaHierarchy(hierarchy);
category.setCategoryType(categoryType);
return category;
}
use of org.mifos.accounts.financial.business.COABO in project head by mifos.
the class ChartOfAccountsCacheTest method createMockAccountPersistance.
private LegacyAccountDao createMockAccountPersistance() {
LegacyAccountDao ap = createMock(LegacyAccountDao.class);
expect(ap.getCategory(GLCategoryType.INCOME)).andReturn(new COABO(ACCOUNT_ID, ACCOUNT_NAME));
replay(ap);
return ap;
}
use of org.mifos.accounts.financial.business.COABO in project head by mifos.
the class ChartOfAccountsCacheTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
GLCodeEntity glCodeEntityForStandardAccount = new GLCodeEntity(GL_CODE_ENTITY_ID, GL_CODE);
testAccount = new COABO(ACCOUNT_ID, ACCOUNT_NAME, glCodeEntityForStandardAccount);
/*
* Hack. Has no effect when this test is run alone. When running as part
* of a full unit/integration test, the ChartOfAccounts static cache
* will have already been populated, so the add (below) would otherwise
* cause an exception to be thrown.
*/
ChartOfAccountsCache.remove(testAccount);
ChartOfAccountsCache.add(testAccount);
GLCodeEntity glCodeEntityForTopLevelAccount = new GLCodeEntity(GL_CODE_ENTITY_ID, INCOME_GL_ACCOUNT_CODE);
COABO testIncomeAccount = new COABO(ACCOUNT_ID, ACCOUNT_NAME, glCodeEntityForTopLevelAccount);
/*
* Hack. Has no effect when this test is run alone. When running as part
* of a full unit/integration test, the ChartOfAccounts static cache
* will have already been populated, so the add (below) would otherwise
* cause an exception to be thrown.
*/
ChartOfAccountsCache.remove(testIncomeAccount);
ChartOfAccountsCache.add(testIncomeAccount);
}
Aggregations