use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.
the class CoaServiceFacadeWebTier method reloadCache.
private void reloadCache() {
ChartOfAccountsCache.clear();
FinancialActionCache.clear();
try {
FinancialInitializer.initialize();
} catch (FinancialException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.
the class SavingsAdjustmentAccountingEntryTest method runOneTestMockFinancialBusinessServiceThrowsException.
private void runOneTestMockFinancialBusinessServiceThrowsException(SavingsType savingsType, AccountActionTypes accountActionType, GLCategoryType bankCategoryType, GLCategoryType savingsCategoryType, FinancialActionConstants financialAction, FinancialConstants bankDebitCredit) throws FinancialException {
/*
* Test-specific settings
*/
setUpOneMandatorySavingsTest(savingsType, accountActionType, bankCategoryType, savingsCategoryType, bankDebitCredit, financialAction);
SavingsAdjustmentAccountingEntry entry = new SavingsAdjustmentAccountingEntry();
when(mockedFinancialBusinessService.getFinancialAction(financialAction)).thenThrow(new FinancialException("a FinancialException"));
doBuild(entry, mockedFinancialBusinessService, mockedSavingsHelper, mockedFinancialActivity);
}
use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.
the class SavingsBO method doPostInterest.
private void doPostInterest(LocalDate currentPostingDate, Money actualInterestToBePosted, PersonnelBO loggedInUser) {
this.savingsBalance = this.savingsBalance.add(actualInterestToBePosted);
this.savingsPerformance.setTotalInterestDetails(actualInterestToBePosted);
SavingsActivityEntity savingsActivity = SavingsActivityEntity.savingsInterestPosting(this, personnel, this.savingsBalance, actualInterestToBePosted, currentPostingDate.toDateMidnight().toDate());
savingsActivityDetails.add(savingsActivity);
AccountPaymentEntity interestPayment = AccountPaymentEntity.savingsInterestPosting(this, actualInterestToBePosted, currentPostingDate.toDateMidnight().toDate(), loggedInUser);
DateTime dueDate = new DateTime();
SavingsTrxnDetailEntity interestPostingTransaction = SavingsTrxnDetailEntity.savingsInterestPosting(interestPayment, this.customer, this.savingsBalance, currentPostingDate.toDateMidnight().toDate(), dueDate, loggedInUser);
interestPayment.addAccountTrxn(interestPostingTransaction);
this.addAccountPayment(interestPayment);
// NOTE: financial Transaction Processing should be decoupled from application domain model.
try {
BaseFinancialActivity baseFinancialActivity = new SavingsInterestPostingFinancialActivity(interestPostingTransaction);
baseFinancialActivity.buildAccountEntries();
} catch (FinancialException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.
the class FinancialInitializer method initialize.
public static void initialize() throws FinancialException {
try {
StaticHibernateUtil.startTransaction();
initalizeFinancialAction();
loadCOA();
StaticHibernateUtil.commitTransaction();
// necessary or cacheCOA() doesn't work correctly. Is that because
// the commitTransaction() isn't clearing the session?
StaticHibernateUtil.clearSession();
cacheCOA();
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
throw new FinancialException(FinancialExceptionConstants.ACTIONNOTFOUND, e);
}
}
use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.
the class FinancialInitializer method loadCOA.
/**
* Reads chart of accounts from a configuration file and inserts into the
* database. Deleting accounts is not currently supported, but if the user
* tries to do this (by leaving it out of the custom chart of accounts
* config file), there is currently no error reported.
* <p>
* QUESION: what if custom config was missing entries from default config,
* but then is moved _out_ of the app server classpath?
* <p>
* ANSWER: once ChartOfAccountsConfig.isLoaded() returns true, <em>only
* the custom CoA config file will be considered</em>. Using the custom
* config will be the only way to add new accounts after the initial CoA
* data is loaded in the database.
*/
public static void loadCOA() throws FinancialException {
Session session = StaticHibernateUtil.getSessionTL();
final String coaLocation;
try {
if (!ChartOfAccountsConfig.canLoadCoa(session)) {
logger.info("Chart of accounts data will not be modified since " + "the custom chart of accounts configuration file was " + "not found on the classpath.");
return;
}
coaLocation = ChartOfAccountsConfig.getCoaUri(session);
logger.info("going to load or modify chart of accounts " + "configuration from " + coaLocation);
} catch (IOException e) {
throw new FinancialException("Charts of accounts loading failed", e);
}
ChartOfAccountsConfig coa;
try {
coa = ChartOfAccountsConfig.load(coaLocation);
} catch (ConfigurationException e) {
throw new FinancialException(coaLocation + " loading failed", e);
}
LegacyAccountDao ap = ApplicationContextProvider.getBean(LegacyAccountDao.class);
for (GLAccount glAccount : coa.getGLAccounts()) {
Short accountId = ap.getAccountIdFromGlCode(glAccount.glCode);
if (null == accountId) {
logger.info("Adding new general ledger account: " + glAccount);
ap.addGeneralLedgerAccount(glAccount.name, glAccount.glCode, glAccount.parentGlCode, glAccount.categoryType);
} else {
COABO account = (COABO) session.load(COABO.class, accountId);
if (account.getCategoryType() != glAccount.categoryType) {
throw new FinancialException("category type change not supported");
}
if (!accountHierarchyMatch(account, glAccount)) {
throw new FinancialException("chart of accounts hierarchy change not supported");
}
if (!account.getAccountName().equals(glAccount.name)) {
logger.info("updating general ledger account name. code=" + account.getGlCode() + ". old name=" + account.getAccountName() + ", new name=" + glAccount.name);
ap.updateAccountName(account, glAccount.name);
}
}
}
}
Aggregations