use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.
the class FinancialInitializer method initalizeFinancialAction.
@SuppressWarnings("unchecked")
public static void initalizeFinancialAction() throws FinancialException {
Session session = StaticHibernateUtil.getSessionTL();
try {
Query queryFinancialAction = session.getNamedQuery(FinancialQueryConstants.GET_ALL_FINANCIAL_ACTION);
List<FinancialActionTypeEntity> listFinancialAction = queryFinancialAction.list();
for (FinancialActionTypeEntity fabo : listFinancialAction) {
FinancialActionCache.addToCache(fabo);
}
} catch (Exception e) {
throw new FinancialException(FinancialExceptionConstants.FINANCIALACTION_INITFAILED, e);
}
}
use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.
the class FeeServiceFacadeWebTier method parameters.
private FeeParameters parameters() {
try {
List<GLCodeEntity> glCodes = generalLedgerDao.retreiveGlCodesBy(FinancialActionConstants.FEEPOSTING, FinancialConstants.CREDIT);
List<CategoryTypeEntity> categories = this.feeDao.doRetrieveFeeCategories();
List<FeeFormulaEntity> formulas = this.feeDao.retrieveFeeFormulae();
List<FeeFrequencyTypeEntity> frequencies = this.feeDao.retrieveFeeFrequencies();
List<FeePaymentEntity> timesOfCharging = this.feeDao.retrieveFeePayments();
List<MasterDataEntity> timesOfChargeingCustomer = new ArrayList<MasterDataEntity>();
for (MasterDataEntity timeOfCharging : timesOfCharging) {
if (timeOfCharging.getId().equals(FeePayment.UPFRONT.getValue())) {
timesOfChargeingCustomer.add(timeOfCharging);
}
}
return new FeeParameters(listToMap(categories), listToMap(timesOfCharging), listToMap(timesOfChargeingCustomer), listToMap(formulas), listToMap(frequencies), glCodesToMap(glCodes));
} catch (FinancialException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.accounts.financial.exceptions.FinancialException in project head by mifos.
the class ApplicationInitializer method dbUpgrade.
public void dbUpgrade(ApplicationContext applicationContext) throws ConfigurationException, PersistenceException, FinancialException, TaskSystemException {
logger.info("Logger has been initialised");
initializeHibernate(applicationContext);
logger.info(getDatabaseConnectionInfo());
// if a database upgrade loads an instance of Money then MoneyCompositeUserType needs the default
// currency
MoneyCompositeUserType.setDefaultCurrency(AccountingRules.getMifosCurrency(new ConfigurationPersistence()));
// load the additional currencies
AccountingRules.init();
Money.setDefaultCurrency(AccountingRules.getMifosCurrency(new ConfigurationPersistence()));
final MifosConfigurationManager configuration = MifosConfigurationManager.getInstance();
final String imageStorageConfig = configuration.getString(IMAGESTORE_CONFIG_KEY);
if (imageStorageConfig == null || !imageStorageConfig.equals(DB_CONFIG)) {
ImageStorageManager.initStorage();
}
DatabaseMigrator migrator = new DatabaseMigrator();
initializeDBConnectionForHibernate(migrator);
if (!databaseError.isError) {
try {
migrator.upgrade(applicationContext);
} catch (Throwable t) {
setDatabaseError(DatabaseErrorCode.UPGRADE_FAILURE, "Failed to upgrade database.", t);
}
}
if (databaseError.isError) {
databaseError.logError();
} else {
initializeDB(applicationContext);
/*
* John W - Added in G Release and back patched to F Release.
* Related to jira issue MIFOS-4948
*
* Can find all code and the related query by searching for mifos4948
*
*/
CustomJDBCService customJdbcService = applicationContext.getBean(CustomJDBCService.class);
boolean keyExists = customJdbcService.mifos4948IssueKeyExists();
if (!keyExists) {
try {
StaticHibernateUtil.startTransaction();
applyMifos4948Fix();
customJdbcService.insertMifos4948Issuekey();
StaticHibernateUtil.commitTransaction();
} catch (AccountException e) {
StaticHibernateUtil.rollbackTransaction();
e.printStackTrace();
} finally {
StaticHibernateUtil.closeSession();
}
}
boolean key5722Exists = customJdbcService.mifos5722IssueKeyExists();
if (!key5722Exists) {
try {
applyMifos5722Fix();
customJdbcService.insertMifos5722Issuekey();
} catch (Exception e) {
logger.error("Could not apply Mifos-5692 and mifos-5722 fix");
e.printStackTrace();
} finally {
StaticHibernateUtil.closeSession();
}
}
boolean key5763Exists = customJdbcService.mifos5763IssueKeyExists();
if (!key5763Exists) {
try {
applyMifos5763Fix();
customJdbcService.insertMifos5763Issuekey();
} catch (Exception e) {
logger.info("Failed to apply Mifos-5763 fix");
e.printStackTrace();
} finally {
StaticHibernateUtil.closeSession();
}
}
boolean key5632Exists = customJdbcService.mifos5632IssueKeyExists();
if (!key5632Exists) {
try {
applyMifos5632();
customJdbcService.insertMifos5632IssueKey();
} catch (Exception e) {
logger.info("Failed to apply Mifos-5632 fix");
e.printStackTrace();
} finally {
StaticHibernateUtil.closeSession();
}
}
}
}
use of org.mifos.accounts.financial.exceptions.FinancialException 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.exceptions.FinancialException in project head by mifos.
the class WebTierPenaltyServiceFacade method getPenaltyParameters.
@Override
public PenaltyParametersDto getPenaltyParameters() {
try {
List<GLCodeEntity> glCodes = generalLedgerDao.retreiveGlCodesBy(FinancialActionConstants.PENALTYPOSTING, FinancialConstants.CREDIT);
List<PenaltyCategoryEntity> categories = this.penaltyDao.getPenaltiesCategories();
List<PenaltyPeriodEntity> periods = this.penaltyDao.getPenaltiesPeriods();
List<PenaltyFormulaEntity> formulas = this.penaltyDao.getPenaltiesFormulas();
List<PenaltyFrequencyEntity> frequencies = this.penaltyDao.getPenaltiesFrequencies();
List<PenaltyStatusEntity> statuses = this.penaltyDao.getPenaltiesStatuses();
return new PenaltyParametersDto(listToMap(categories), listToMap(statuses), listToMap(periods), listToMap(formulas), listToMap(frequencies), glCodesToMap(glCodes));
} catch (FinancialException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
Aggregations