Search in sources :

Example 1 with AdminDocumentBO

use of org.mifos.reports.admindocuments.business.AdminDocumentBO in project head by mifos.

the class EditStatusAction method load.

@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    EditStatusActionForm actionForm = (EditStatusActionForm) form;
    actionForm.setSelectedItems(null);
    actionForm.setNotes(null);
    actionForm.setNewStatusId(null);
    actionForm.setFlagId(null);
    actionForm.setQuestionGroups(null);
    actionForm.setTransactionDate(DateUtils.makeDateAsSentFromBrowser());
    actionForm.setAllowBackDatedApprovals(AccountingRules.isBackDatedApprovalAllowed());
    request.getSession().removeAttribute(Constants.BUSINESS_KEY);
    UserContext userContext = getUserContext(request);
    Integer accountId = Integer.valueOf(actionForm.getAccountId());
    AccountBO accountBO = new AccountBusinessService().getAccount(accountId);
    java.util.Date lastPaymentDate = new java.util.Date(0);
    AccountPaymentEntity lastPayment = accountBO.findMostRecentNonzeroPaymentByPaymentDate();
    if (lastPayment != null) {
        lastPaymentDate = lastPayment.getPaymentDate();
    }
    actionForm.setLastPaymentDate(lastPaymentDate);
    if (accountBO.isLoanAccount() || accountBO.isGroupLoanAccount()) {
        // NOTE - not using dto values at present but available when ui is refactored away from jsp
        AccountStatusDto accountStatuses = this.loanAccountServiceFacade.retrieveAccountStatuses(accountId.longValue());
        LoanBO loanAccount = this.loanDao.findById(accountId);
        EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
        editStatusActionForm.setAccountTypeId(AccountTypes.LOAN_ACCOUNT.getValue().toString());
        editStatusActionForm.setCurrentStatusId(loanAccount.getAccountState().getId().toString());
        editStatusActionForm.setGlobalAccountNum(loanAccount.getGlobalAccountNum());
        editStatusActionForm.setAccountName(loanAccount.getLoanOffering().getPrdOfferingName());
        if (loanAccount.isGroupLoanAccount() && loanAccount.getParentAccount() == null) {
            editStatusActionForm.setInput("grouploan");
        } else {
            editStatusActionForm.setInput("loan");
        }
        if (loanAccount.getAccountState().getId().equals(Short.valueOf("2"))) {
            List<AdminDocumentBO> allAdminDocuments = legacyAdminDocumentDao.getAllActiveAdminDocuments();
            List<AdminDocumentBO> loanAdminDocuments = new ArrayList();
            for (AdminDocumentBO adminDocumentBO : allAdminDocuments) {
                List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(adminDocumentBO.getAdmindocId());
                if (!loanAdminDocuments.contains(adminDocumentBO) && admindoclist.size() > 0 && admindoclist.get(0).getAccountStateID().getPrdType().getProductTypeID().equals(loanAccount.getType().getValue().shortValue())) {
                    for (AdminDocAccStateMixBO admindoc : admindoclist) {
                        if (admindoc.getAccountStateID().getId().shortValue() == loanAccount.getAccountState().getId().shortValue()) {
                            loanAdminDocuments.add(adminDocumentBO);
                        }
                    }
                }
            }
            SessionUtils.setCollectionAttribute("editAccountStatusDocumentsList", loanAdminDocuments, request);
        } else {
            SessionUtils.setCollectionAttribute("editAccountStatusDocumentsList", null, request);
        }
    }
    if (accountBO.isSavingsAccount()) {
        // NOTE - not using dto values at present but available when ui is refactored away from jsp
        AccountStatusDto accountStatuses = this.savingsServiceFacade.retrieveAccountStatuses(accountId.longValue());
        SavingsBO savingsAccount = this.savingsDao.findById(accountId.longValue());
        EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
        editStatusActionForm.setAccountTypeId(AccountTypes.SAVINGS_ACCOUNT.getValue().toString());
        editStatusActionForm.setCurrentStatusId(savingsAccount.getAccountState().getId().toString());
        editStatusActionForm.setGlobalAccountNum(savingsAccount.getGlobalAccountNum());
        editStatusActionForm.setAccountName(savingsAccount.getSavingsOffering().getPrdOfferingName());
        editStatusActionForm.setInput("savings");
    }
    List<AccountStateEntity> accountStatuses = new AccountBusinessService().getStatusList(accountBO.getAccountState(), accountBO.getType(), userContext.getLocaleId());
    for (AccountStateEntity customerStatusEntity : accountStatuses) {
        for (AccountStateFlagEntity flag : customerStatusEntity.getFlagSet()) {
            String statusMessageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(flag.getLookUpValue().getPropertiesKey());
            flag.setStatusFlagMessageText(statusMessageText);
        }
    }
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
    SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_LIST, accountStatuses, request);
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : AccountStatusDto(org.mifos.dto.domain.AccountStatusDto) EditStatusActionForm(org.mifos.accounts.struts.actionforms.EditStatusActionForm) UserContext(org.mifos.security.util.UserContext) Date(java.util.Date) LoanBO(org.mifos.accounts.loan.business.LoanBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) ArrayList(java.util.ArrayList) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Date(java.util.Date) AccountBO(org.mifos.accounts.business.AccountBO) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) AccountStateFlagEntity(org.mifos.accounts.business.AccountStateFlagEntity) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) MessageLookup(org.mifos.application.master.MessageLookup) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with AdminDocumentBO

use of org.mifos.reports.admindocuments.business.AdminDocumentBO in project head by mifos.

the class BirtAdminDocumentUploadAction method createOrUpdateAdminDocument.

private AdminDocumentBO createOrUpdateAdminDocument(String admindocTitle, Short isActive, String fileName) throws PersistenceException {
    AdminDocumentBO admindocBO = new AdminDocumentBO();
    admindocBO.setAdminDocumentName(admindocTitle);
    admindocBO.setIsActive(isActive);
    admindocBO.setAdminDocumentIdentifier(fileName);
    legacyAdminDocumentDao.createOrUpdate(admindocBO);
    return admindocBO;
}
Also used : AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO)

Example 3 with AdminDocumentBO

use of org.mifos.reports.admindocuments.business.AdminDocumentBO 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 4 with AdminDocumentBO

use of org.mifos.reports.admindocuments.business.AdminDocumentBO in project head by mifos.

the class BirtAdminDocumentUploadActionStrutsTest method testEdit.

@Test
public void testEdit() {
    setRequestPathInfo("/birtAdminDocumentUploadAction.do");
    addRequestParameter("method", "edit");
    addRequestParameter("admindocId", "1");
    actionPerform();
    AdminDocumentBO adminDocument = (AdminDocumentBO) request.getAttribute(Constants.BUSINESS_KEY);
    Assert.assertEquals("1", adminDocument.getAdmindocId().toString());
    verifyNoActionErrors();
    verifyForward(ActionForwards.edit_success.toString());
}
Also used : AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) Test(org.junit.Test)

Example 5 with AdminDocumentBO

use of org.mifos.reports.admindocuments.business.AdminDocumentBO in project head by mifos.

the class AdminDocumentsServiceImpl method getAdminDocumentsForAccountPayment.

@Override
public List<AdminDocumentDto> getAdminDocumentsForAccountPayment(Integer paymentId) {
    try {
        List<AdminDocumentDto> adminDocuments = new ArrayList<AdminDocumentDto>();
        AccountPaymentEntity accountPaymentEntity = legacyAccountDao.findPaymentById(paymentId);
        Set<AccountTrxnEntity> accountTrxnEntities = accountPaymentEntity.getAccountTrxns();
        for (AccountTrxnEntity accountTrxnEntity : accountTrxnEntities) {
            List<AdminDocumentBO> adminDocumentBOs = legacyAdminDocumentDao.getActiveAdminDocumentsByAccountActionId(accountTrxnEntity.getAccountActionEntity().getId());
            if (adminDocumentBOs != null && !adminDocumentBOs.isEmpty()) {
                for (AdminDocumentBO adminDocumentBO : adminDocumentBOs) {
                    AdminDocumentDto adminDocumentDto = new AdminDocumentDto(adminDocumentBO.getAdmindocId().intValue(), adminDocumentBO.getAdminDocumentName(), adminDocumentBO.getAdminDocumentIdentifier(), BooleanUtils.toBoolean(adminDocumentBO.getIsActive().intValue()));
                    if (!adminDocuments.contains(adminDocumentDto)) {
                        adminDocuments.add(adminDocumentDto);
                    }
                }
            }
        }
        return adminDocuments;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : AccountTrxnEntity(org.mifos.accounts.business.AccountTrxnEntity) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) ArrayList(java.util.ArrayList) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AdminDocumentDto(org.mifos.dto.domain.AdminDocumentDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

AdminDocumentBO (org.mifos.reports.admindocuments.business.AdminDocumentBO)11 ArrayList (java.util.ArrayList)6 AdminDocAccStateMixBO (org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO)6 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)5 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)5 Test (org.junit.Test)4 BirtAdminDocumentUploadActionForm (org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm)4 List (java.util.List)3 AdminDocAccActionMixBO (org.mifos.reports.admindocuments.business.AdminDocAccActionMixBO)3 FormFile (org.apache.struts.upload.FormFile)2 AccountActionEntity (org.mifos.accounts.business.AccountActionEntity)2 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)2 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)2 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 UserContext (org.mifos.security.util.UserContext)2 File (java.io.File)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 AccountBO (org.mifos.accounts.business.AccountBO)1