Search in sources :

Example 16 with AccountStateEntity

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());
    }
}
Also used : AccountStateFlagEntity(org.mifos.accounts.business.AccountStateFlagEntity) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity)

Example 17 with AccountStateEntity

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);
    }
}
Also used : AccountStatusDto(org.mifos.dto.domain.AccountStatusDto) ChangeAccountStatusDto(org.mifos.dto.screen.ChangeAccountStatusDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) ValueListElement(org.mifos.dto.domain.ValueListElement) ListElement(org.mifos.dto.screen.ListElement) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 18 with AccountStateEntity

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);
}
Also used : AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) BirtAdminDocumentUploadActionForm(org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm) ArrayList(java.util.ArrayList) List(java.util.List) AdminDocAccActionMixBO(org.mifos.reports.admindocuments.business.AdminDocAccActionMixBO) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) AccountActionEntity(org.mifos.accounts.business.AccountActionEntity) FormFile(org.apache.struts.upload.FormFile) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 19 with AccountStateEntity

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);
}
Also used : AccountActionTypes(org.mifos.accounts.util.helpers.AccountActionTypes) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ArrayList(java.util.ArrayList) List(java.util.List) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) AccountActionEntity(org.mifos.accounts.business.AccountActionEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 20 with AccountStateEntity

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");
}
Also used : PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) AccountStatusChangeHistoryEntity(org.mifos.accounts.business.AccountStatusChangeHistoryEntity) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)49 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)11 AccountStatusChangeHistoryEntity (org.mifos.accounts.business.AccountStatusChangeHistoryEntity)11 AccountException (org.mifos.accounts.exceptions.AccountException)8 PersistenceException (org.mifos.framework.exceptions.PersistenceException)7 Money (org.mifos.framework.util.helpers.Money)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)6 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)5 AdminDocAccStateMixBO (org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO)5 AdminDocumentBO (org.mifos.reports.admindocuments.business.AdminDocumentBO)5 Date (java.util.Date)4 List (java.util.List)4 LocalDate (org.joda.time.LocalDate)4 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)4 AccountStateFlagEntity (org.mifos.accounts.business.AccountStateFlagEntity)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)4 DateTimeService (org.mifos.framework.util.DateTimeService)4 UserContext (org.mifos.security.util.UserContext)4