use of org.mifos.accounts.financial.business.COABO in project head by mifos.
the class LegacyAccountDao method deleteLedgerAccount.
public void deleteLedgerAccount(Short accountId) throws PersistenceException {
Session session = StaticHibernateUtil.getSessionTL();
Transaction transaction = session.beginTransaction();
try {
COABO coa = (COABO) session.load(COABO.class, accountId);
COABO parent = coa.getCoaHierarchy().getParentAccount().getCoa();
Short parentId = parent.getAccountId();
Short glCodeId = coa.getAssociatedGlcode().getGlcodeId();
Query query = session.getNamedQuery(NamedQueryConstants.REMOVE_COA_PARENT);
query.setShort("coa_id", coa.getAccountId().shortValue());
query.setShort("parent_id", parentId);
query.executeUpdate();
query = session.getNamedQuery(NamedQueryConstants.REMOVE_COA);
query.setShort("coa_id", coa.getAccountId().shortValue());
query.executeUpdate();
query = session.getNamedQuery(NamedQueryConstants.REMOVE_GLCODE);
query.setShort("glcode_id", glCodeId);
query.executeUpdate();
transaction.commit();
session.flush();
} catch (HibernateException e) {
transaction.rollback();
throw new PersistenceException(e);
}
}
use of org.mifos.accounts.financial.business.COABO in project head by mifos.
the class LegacyAccountDao method dumpChartOfAccounts.
public String dumpChartOfAccounts() throws ConfigurationException {
XMLConfiguration config = new XMLConfiguration();
Query topLevelAccounts = getSession().getNamedQuery(NamedQueryConstants.GET_TOP_LEVEL_ACCOUNTS);
List listAccounts = topLevelAccounts.list();
Iterator it = listAccounts.iterator();
LegacyAccountDao ap = new LegacyAccountDao();
String assetsAccountGLCode = ap.getCategory(GLCategoryType.ASSET).getGlCode();
String liabilitiesAccountGLCode = ap.getCategory(GLCategoryType.LIABILITY).getGlCode();
String incomeAccountGLCode = ap.getCategory(GLCategoryType.INCOME).getGlCode();
String expenditureAccountGLCode = ap.getCategory(GLCategoryType.EXPENDITURE).getGlCode();
while (it.hasNext()) {
COABO coa = (COABO) it.next();
String name = coa.getAccountName();
String glCode = coa.getAssociatedGlcode().getGlcode();
String path = "ChartOfAccounts";
if (glCode.equals(assetsAccountGLCode)) {
path = path + ASSETS_GL_ACCOUNT_TAG;
} else if (glCode.equals(liabilitiesAccountGLCode)) {
path = path + LIABILITIES_GL_ACCOUNT_TAG;
} else if (glCode.equals(incomeAccountGLCode)) {
path = path + INCOME_GL_ACCOUNT_TAG;
} else if (glCode.equals(expenditureAccountGLCode)) {
path = path + EXPENDITURE_GL_ACCOUNT_TAG;
} else {
throw new RuntimeException("Unrecognized top level GLCode: " + glCode);
}
config.addProperty(path + "(-1)[@code]", glCode);
config.addProperty(path + "[@name]", name);
addAccountSubcategories(config, coa, path + GL_ACCOUNT_TAG);
}
StringWriter stringWriter = new StringWriter();
config.save(stringWriter);
String chart = stringWriter.toString();
return chart;
}
use of org.mifos.accounts.financial.business.COABO in project head by mifos.
the class ChartOfAccountsConfig method isLoaded.
/**
* @return true if the chart of accounts has been loaded from the on-disk
* configuration file into the database.
*/
public static boolean isLoaded(Session session) {
// A more comprehensive check would also make sure no rows exist in
// the following tables: coahierarchy, coa_idmapper, gl_code
Query query = session.getNamedQuery(NamedQueryConstants.GET_ALL_COA);
List<COABO> coaBoList = query.list();
return !coaBoList.isEmpty();
}
Aggregations