use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class LegacyAccountDao method initializeAccountStates.
private void initializeAccountStates(List<AccountStateEntity> queryResult) {
for (AccountStateEntity accountStateEntity : queryResult) {
for (AccountStateFlagEntity accountStateFlagEntity : accountStateEntity.getFlagSet()) {
Hibernate.initialize(accountStateFlagEntity);
Hibernate.initialize(accountStateFlagEntity.getNames());
}
Hibernate.initialize(accountStateEntity.getNames());
}
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class LoanAccountServiceFacadeWebTier method retrieveAccountStatuses.
@Override
public AccountStatusDto retrieveAccountStatuses(Long loanAccountId) {
LoanBO loanAccount = this.loanDao.findById(loanAccountId.intValue());
try {
List<ListElement> loanStatesList = new ArrayList<ListElement>();
AccountStateMachines.getInstance().initializeLoanStates();
List<AccountStateEntity> statusList = AccountStateMachines.getInstance().getLoanStatusList(loanAccount.getAccountState());
for (AccountStateEntity accountState : statusList) {
loanStatesList.add(new ListElement(accountState.getId().intValue(), accountState.getName()));
}
return new AccountStatusDto(loanStatesList);
} catch (StatesInitializationException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class BirtAdminDocumentUploadAction method upload.
@SuppressWarnings("unchecked")
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
BirtAdminDocumentUploadActionForm uploadForm = (BirtAdminDocumentUploadActionForm) form;
FormFile formFile = uploadForm.getFile();
uploadFile(formFile);
AdminDocumentBO admindocBO = createOrUpdateAdminDocument(uploadForm.getAdminiDocumentTitle(), Short.valueOf("1"), formFile.getFileName());
AdminDocAccStateMixBO admindocaccstatemixBO = new AdminDocAccStateMixBO();
if (Short.valueOf(uploadForm.getAccountTypeId()).shortValue() <= 2) {
List<AccountStateEntity> masterList = (List<AccountStateEntity>) SessionUtils.getAttribute("SelectedStatus", request);
for (AccountStateEntity acc : masterList) {
admindocaccstatemixBO = new AdminDocAccStateMixBO();
admindocaccstatemixBO.setAccountStateID(acc);
admindocaccstatemixBO.setAdminDocumentID(admindocBO);
legacyAdminDocAccStateMixDao.createOrUpdate(admindocaccstatemixBO);
}
} else {
List<AccountActionEntity> masterList = (List<AccountActionEntity>) SessionUtils.getAttribute("SelectedStatus", request);
for (AccountActionEntity accountActionEntity : masterList) {
AdminDocAccActionMixBO adminDocAccActionMixBO = new AdminDocAccActionMixBO();
adminDocAccActionMixBO.setAccountAction(accountActionEntity);
adminDocAccActionMixBO.setAdminDocument(admindocBO);
legacyAdminDocumentDao.createOrUpdate(adminDocAccActionMixBO);
}
}
request.setAttribute("report", admindocBO);
return getViewBirtAdminDocumentPage(mapping, form, request, response);
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class BirtAdminDocumentUploadAction method updateSelectedStatus.
@TransactionDemarcate(joinToken = true)
private void updateSelectedStatus(HttpServletRequest request, BirtAdminDocumentUploadActionForm uploadForm) throws PageExpiredException, ServiceException {
List selectList = null;
if (uploadForm.getStatusList() != null) {
Short accountTypeId = Short.valueOf(uploadForm.getAccountTypeId());
if (accountTypeId.shortValue() <= 2) {
selectList = new ArrayList<AccountStateEntity>();
List<AccountStateEntity> masterList = new AccountBusinessService().retrieveAllActiveAccountStateList(AccountTypes.getAccountType(accountTypeId));
for (AccountStateEntity product : masterList) {
for (String productStatusId : uploadForm.getStatusList()) {
if (productStatusId != null && product.getId().intValue() == Integer.valueOf(productStatusId).intValue()) {
selectList.add(product);
}
}
}
} else {
Short currentLocaleId = (Short) SessionUtils.getAttribute("CURRENT_LOCALE_ID", request);
selectList = new ArrayList<AccountActionEntity>();
List<AccountActionEntity> masterList = getAvailableLoanTransactions(currentLocaleId);
for (String accountActionId : uploadForm.getStatusList()) {
AccountActionTypes accountActionType = AccountActionTypes.fromInt(Integer.valueOf(accountActionId));
AccountActionEntity accountAction = new AccountBusinessService().getAccountAction(accountActionType.getValue(), currentLocaleId);
if (masterList.contains(accountAction)) {
selectList.add(accountAction);
}
}
}
}
SessionUtils.setCollectionAttribute("SelectedStatus", selectList, request);
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class ApplyAdjustmentActionStrutsTest method testApplyAdjustment.
@Ignore
@Test
public void testApplyAdjustment() throws Exception {
PersonnelBO personnel = legacyPersonnelDao.getPersonnel(PersonnelConstants.SYSTEM_USER);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
loan = (LoanBO) getLoanAccount();
applyPayment(loan, 212);
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
applyPayment(loan, 700);
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
AccountStatusChangeHistoryEntity historyEntity = new AccountStatusChangeHistoryEntity(new AccountStateEntity(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING), new AccountStateEntity(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING), personnel, loan);
AccountTestUtils.addToAccountStatusChangeHistory(loan, historyEntity);
TestObjectFactory.updateObject(loan);
StaticHibernateUtil.flushAndClearSession();
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
loan.setUserContext(userContext);
for (AccountStatusChangeHistoryEntity accountStatus : loan.getAccountStatusChangeHistory()) {
Assert.assertEquals(loan.getAccountId(), accountStatus.getAccount().getAccountId());
Assert.assertNotNull(accountStatus.getAccountStatusChangeId());
Assert.assertEquals(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING.getValue(), accountStatus.getNewStatus().getId());
Assert.assertEquals(personnel.getPersonnelId(), accountStatus.getPersonnel().getPersonnelId());
Assert.assertEquals(personnel.getDisplayName(), accountStatus.getPersonnel().getDisplayName());
Assert.assertEquals("-", accountStatus.getOldStatusName());
Assert.assertNotNull(accountStatus.getNewStatusName());
Assert.assertNull(accountStatus.getLocale());
Assert.assertNotNull(accountStatus.getUserPrefferedTransactionDate());
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
setRequestPathInfo("/applyAdjustment");
addRequestParameter("method", "applyAdjustment");
addRequestParameter("adjustmentNote", "Loan adjustment testing");
addRequestParameter("globalAccountNum", loan.getGlobalAccountNum());
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
setUpSecurityContext();
getRequest().getSession().setAttribute(Constants.USERCONTEXT, TestUtils.makeUser());
actionPerform();
loan = (LoanBO) TestObjectFactory.getObject(AccountBO.class, loan.getAccountId());
verifyForward("applyadj_success");
}
Aggregations