Search in sources :

Example 1 with AdminDocAccStateMixBO

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

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

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

the class SavingsAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    SavingsActionForm actionForm = (SavingsActionForm) form;
    actionForm.setInput(null);
    String globalAccountNum = actionForm.getGlobalAccountNum();
    if (StringUtils.isBlank(actionForm.getGlobalAccountNum())) {
        SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
        globalAccountNum = savings.getGlobalAccountNum();
    }
    logger.debug(" Retrieving for globalAccountNum: " + globalAccountNum);
    SavingsBO savings = this.savingsDao.findBySystemId(globalAccountNum);
    savings.setUserContext(uc);
    SavingsAccountDetailDto savingsAccountDto;
    try {
        savingsAccountDto = this.savingsServiceFacade.retrieveSavingsAccountDetails(savings.getAccountId().longValue());
    } catch (MifosRuntimeException e) {
        if (e.getCause() instanceof ApplicationException) {
            throw (ApplicationException) e.getCause();
        }
        throw e;
    }
    List<AdminDocumentBO> allAdminDocuments = legacyAdminDocumentDao.getAllActiveAdminDocuments();
    List<AdminDocumentBO> savingsAdminDocuments = new ArrayList();
    for (AdminDocumentBO adminDocumentBO : allAdminDocuments) {
        List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(adminDocumentBO.getAdmindocId());
        if (!savingsAdminDocuments.contains(adminDocumentBO) && admindoclist.size() > 0 && admindoclist.get(0).getAccountStateID().getPrdType().getProductTypeID().equals(Short.valueOf("2"))) {
            savingsAdminDocuments.add(adminDocumentBO);
        }
    }
    SessionUtils.setCollectionAttribute("administrativeDocumentsList", savingsAdminDocuments, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
    SessionUtils.setCollectionAttribute(MasterConstants.SAVINGS_TYPE, legacyMasterDao.findMasterDataEntitiesWithLocale(SavingsTypeEntity.class), request);
    SessionUtils.setCollectionAttribute(MasterConstants.RECOMMENDED_AMOUNT_UNIT, legacyMasterDao.findMasterDataEntitiesWithLocale(RecommendedAmntUnitEntity.class), request);
    List<CustomFieldDefinitionEntity> customFieldDefinitions = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(SavingsConstants.CUSTOM_FIELDS, customFieldDefinitions, request);
    SessionUtils.setAttribute(SavingsConstants.PRDOFFERING, savings.getSavingsOffering(), request);
    actionForm.setRecommendedAmount(savingsAccountDto.getRecommendedOrMandatoryAmount());
    actionForm.clear();
    SessionUtils.setCollectionAttribute(SavingsConstants.RECENTY_ACTIVITY_DETAIL_PAGE, savingsAccountDto.getRecentActivity(), request);
    SessionUtils.setCollectionAttribute(SavingsConstants.NOTES, savings.getRecentAccountNotes(), request);
    logger.info(" Savings object retrieved successfully");
    setCurrentPageUrl(request, savings);
    setQuestionGroupInstances(request, savings);
    request.getSession().setAttribute("backPageUrl", request.getAttribute("currentPageUrl"));
    return mapping.findForward("get_success");
}
Also used : UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) RecommendedAmntUnitEntity(org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) SavingsActionForm(org.mifos.accounts.savings.struts.actionforms.SavingsActionForm) ApplicationException(org.mifos.framework.exceptions.ApplicationException) SavingsTypeEntity(org.mifos.accounts.productdefinition.business.SavingsTypeEntity) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with AdminDocAccStateMixBO

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

the class PentahoReportsServiceIntegrationTest method testGetAdminReport.

@Test
public void testGetAdminReport() throws Exception {
    String adminDocumentUploadPath = viewOrganizationSettingsServiceFacade.getAdminDocumentStorageDirectory();
    String adminDocumentPath = "IntegrationTest_Loan_template.prpt";
    File adminDocumentSrc = new File(this.getClass().getResource("/Loan_template.prpt").toString().replace("file:", ""));
    File adminDocumentDst = new File(adminDocumentUploadPath + "/" + adminDocumentPath);
    try {
        FileUtils.copyFile(adminDocumentSrc, adminDocumentDst);
        AdminDocumentBO adminDocumentBO = new AdminDocumentBO();
        adminDocumentBO.setAdmindocId(Short.valueOf("1"));
        adminDocumentBO.setAdminDocumentName("IntegrationTest_Loan_template");
        adminDocumentBO.setIsActive(Short.valueOf("1"));
        adminDocumentBO.setAdminDocumentIdentifier(adminDocumentPath);
        AdminDocAccStateMixBO adminDocAccStateMixBO = new AdminDocAccStateMixBO();
        AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.LOAN_APPROVED);
        adminDocAccStateMixBO.setAccountStateID(accountStateEntity);
        adminDocAccStateMixBO.setAdminDocumentID(adminDocumentBO);
        legacyAdminDocumentDao.createOrUpdate(adminDocumentBO);
        Map<String, AbstractPentahoParameter> params = new HashMap<String, AbstractPentahoParameter>();
        PentahoInputParameter entityIdParameter = new PentahoInputParameter();
        entityIdParameter.setParamName("entity_id");
        entityIdParameter.setValue("000100000000002");
        params.put("entity_id", entityIdParameter);
        Integer adminDocId = Integer.parseInt(adminDocumentBO.getAdmindocId().toString());
        for (PentahoOutputType outputType : PentahoOutputType.values()) {
            PentahoReport report = pentahoReportsServiceImpl.getAdminReport(adminDocId, outputType.getId(), params);
            Assert.assertTrue(report.getFileExtension() == outputType.getFileExtension());
            Assert.assertTrue(report.getContentType() == outputType.getContentType());
            Assert.assertTrue(report.getErrors().isEmpty());
        }
    } catch (Exception e) {
        throw e;
    } finally {
        if (adminDocumentDst.exists()) {
            adminDocumentDst.delete();
        }
    }
}
Also used : PentahoReport(org.mifos.reports.pentaho.PentahoReport) AbstractPentahoParameter(org.mifos.reports.pentaho.params.AbstractPentahoParameter) HashMap(java.util.HashMap) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) PentahoOutputType(org.mifos.reports.pentaho.util.PentahoOutputType) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) PentahoInputParameter(org.mifos.reports.pentaho.params.PentahoInputParameter) File(java.io.File) Test(org.junit.Test)

Example 5 with AdminDocAccStateMixBO

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

the class BirtAdminDocumentUploadAction method editThenUpload.

@SuppressWarnings("unchecked")
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward editThenUpload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    BirtAdminDocumentUploadActionForm uploadForm = (BirtAdminDocumentUploadActionForm) form;
    FormFile formFile = uploadForm.getFile();
    boolean newFile = false;
    if (StringUtils.isEmpty(formFile.getFileName())) {
        formFile.destroy();
    } else {
        uploadFile(formFile);
        newFile = true;
    }
    AdminDocumentBO admindoc = legacyAdminDocumentDao.getAdminDocumentById(Short.valueOf(SessionUtils.getAttribute("admindocId", request).toString()));
    admindoc.setAdminDocumentName(uploadForm.getAdminiDocumentTitle());
    admindoc.setIsActive(Short.valueOf(uploadForm.getIsActive()));
    if (newFile) {
        admindoc.setAdminDocumentIdentifier(formFile.getFileName());
    }
    legacyAdminDocumentDao.createOrUpdate(admindoc);
    if (Short.valueOf(uploadForm.getAccountTypeId()).shortValue() <= 2) {
        List<AccountStateEntity> masterList = (List<AccountStateEntity>) SessionUtils.getAttribute("SelectedStatus", request);
        List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(Short.valueOf(SessionUtils.getAttribute("admindocId", request).toString()));
        for (AdminDocAccStateMixBO temp : admindoclist) {
            legacyAdminDocAccStateMixDao.delete(temp);
        }
        AdminDocAccStateMixBO admindocaccstatemixBO = new AdminDocAccStateMixBO();
        for (AccountStateEntity acc : masterList) {
            admindocaccstatemixBO = new AdminDocAccStateMixBO();
            admindocaccstatemixBO.setAccountStateID(acc);
            admindocaccstatemixBO.setAdminDocumentID(admindoc);
            legacyAdminDocAccStateMixDao.createOrUpdate(admindocaccstatemixBO);
        }
    } else {
        List<AccountActionEntity> masterList = (List<AccountActionEntity>) SessionUtils.getAttribute("SelectedStatus", request);
        List<AdminDocAccActionMixBO> admindoclist = legacyAdminDocAccStateMixDao.getAccActionMixByAdminDocument(Short.valueOf(SessionUtils.getAttribute("admindocId", request).toString()));
        for (AdminDocAccActionMixBO temp : admindoclist) {
            legacyAdminDocAccStateMixDao.delete(temp);
        }
        AdminDocAccActionMixBO adminDocAccActionMixBO = new AdminDocAccActionMixBO();
        for (AccountActionEntity acc : masterList) {
            adminDocAccActionMixBO = new AdminDocAccActionMixBO();
            adminDocAccActionMixBO.setAccountAction(acc);
            adminDocAccActionMixBO.setAdminDocument(admindoc);
            legacyAdminDocAccStateMixDao.createOrUpdate(adminDocAccActionMixBO);
        }
    }
    return getViewBirtAdminDocumentPage(mapping, form, request, response);
}
Also used : BirtAdminDocumentUploadActionForm(org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm) 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) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) ArrayList(java.util.ArrayList) List(java.util.List) AdminDocAccActionMixBO(org.mifos.reports.admindocuments.business.AdminDocAccActionMixBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

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