Search in sources :

Example 1 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class ApplyChargeAction method divide.

@TransactionDemarcate(joinToken = true)
public ActionForward divide(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ApplyChargeActionForm chargeForm = (ApplyChargeActionForm) form;
    chargeForm.getIndividualValues().clear();
    Short feeId = Short.valueOf(chargeForm.getFeeId());
    FeeBO fee = feeDao.findById(feeId);
    String amount;
    List<GroupIndividualLoanDto> memberAccounts = groupLoanService.getMemberLoansAndDefaultPayments(Integer.valueOf(chargeForm.getAccountId()), new BigDecimal(chargeForm.getCharge()));
    if (null == fee || fee.getFeeType().equals(RateAmountFlag.AMOUNT)) {
        for (int i = 0; i < memberAccounts.size(); i++) {
            amount = String.valueOf(memberAccounts.get(i).getDefaultAmount().doubleValue());
            chargeForm.getIndividualValues().put(memberAccounts.get(i).getAccountId(), amount);
        }
    } else {
        for (int i = 0; i < memberAccounts.size(); i++) {
            amount = chargeForm.getCharge();
            chargeForm.getIndividualValues().put(memberAccounts.get(i).getAccountId(), amount);
        }
    }
    List<LoanBO> memberInfos = getMemberAccountsInformation(chargeForm.getAccountId());
    SessionUtils.setCollectionAttribute("memberInfos", memberInfos, request);
    return mapping.findForward("divide");
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) GroupIndividualLoanDto(org.mifos.dto.domain.GroupIndividualLoanDto) FeeBO(org.mifos.accounts.fees.business.FeeBO) ApplyChargeActionForm(org.mifos.accounts.struts.actionforms.ApplyChargeActionForm) BigDecimal(java.math.BigDecimal) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class ApplyChargeAction method cancel.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    request.removeAttribute(AccountConstants.APPLICABLE_CHARGE_LIST);
    ApplyChargeActionForm applyChargeActionForm = (ApplyChargeActionForm) form;
    Integer accountId = Integer.valueOf(applyChargeActionForm.getAccountId());
    AccountTypeCustomerLevelDto accountTypeCustomerLevel = accountServiceFacade.getAccountTypeCustomerLevelDto(accountId);
    return mapping.findForward(getDetailAccountPage(accountTypeCustomerLevel));
}
Also used : AccountTypeCustomerLevelDto(org.mifos.dto.screen.AccountTypeCustomerLevelDto) ApplyChargeActionForm(org.mifos.accounts.struts.actionforms.ApplyChargeActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class ApplyChargeAction method load.

@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ApplyChargeActionForm applyChargeActionForm = (ApplyChargeActionForm) form;
    AccountBO account = ApplicationContextProvider.getBean(LegacyAccountDao.class).getAccount(Integer.valueOf(applyChargeActionForm.getAccountId()));
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, account, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, account, request.getSession());
    applyChargeActionForm.clear();
    request.removeAttribute(AccountConstants.APPLICABLE_CHARGE_LIST);
    Integer accountId = Integer.valueOf(request.getParameter("accountId"));
    List<ApplicableCharge> applicableCharges = this.accountServiceFacade.getApplicableFees(accountId);
    LoanBO loan = loanDao.findById(accountId);
    if (loan != null) {
        for (int i = applicableCharges.size() - 1; i >= 0; --i) {
            if (applicableCharges.get(i).getFeeId().equals(AccountConstants.MISC_PENALTY)) {
                applicableCharges.remove(i);
                break;
            }
        }
        applicableCharges.addAll(this.loanAccountServiceFacade.getApplicablePenalties(accountId));
    }
    SessionUtils.setCollectionAttribute(AccountConstants.APPLICABLE_CHARGE_LIST, applicableCharges, request);
    if (null != loan && (null == loan.getParentAccount() && loan.isGroupLoanAccount())) {
        SessionUtils.setAttribute(Constants.ACCOUNT_TYPE, "newGlim", request);
    }
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBO(org.mifos.accounts.business.AccountBO) LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) LoanBO(org.mifos.accounts.loan.business.LoanBO) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) ApplyChargeActionForm(org.mifos.accounts.struts.actionforms.ApplyChargeActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate 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 5 with TransactionDemarcate

use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.

the class EditStatusAction method preview.

@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    AccountBO accountBO = (AccountBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
    // FIXME - ElsieF - KEITHW - is checklist functionality being removed from application?
    List<AccountCheckListBO> checklist = new AccountBusinessService().getStatusChecklist(getShortValue(editStatusActionForm.getNewStatusId()), getShortValue(editStatusActionForm.getAccountTypeId()));
    SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_CHECK_LIST, checklist, request);
    String newStatusId = editStatusActionForm.getNewStatusId();
    String newStatusName = null;
    if (StringUtils.isNotBlank(editStatusActionForm.getNewStatusId())) {
        newStatusName = new AccountBusinessService().getStatusName(AccountState.fromShort(getShortValue(editStatusActionForm.getNewStatusId())), accountBO.getType());
    }
    SessionUtils.setAttribute(SavingsConstants.NEW_STATUS_NAME, newStatusName, request);
    initializeLoanQuestionnaire(accountBO.getGlobalAccountNum(), newStatusId);
    if (loanApproved(newStatusId) || loanClosed(newStatusId)) {
        return loanQuestionnaire.fetchAppliedQuestions(mapping, editStatusActionForm, request, ActionForwards.preview_success);
    }
    return mapping.findForward(ActionForwards.preview_success.toString());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) EditStatusActionForm(org.mifos.accounts.struts.actionforms.EditStatusActionForm) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)259 UserContext (org.mifos.security.util.UserContext)72 ArrayList (java.util.ArrayList)41 CloseSession (org.mifos.framework.util.helpers.CloseSession)35 LoanBO (org.mifos.accounts.loan.business.LoanBO)26 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)21 CustomerBO (org.mifos.customers.business.CustomerBO)20 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)19 AccountBO (org.mifos.accounts.business.AccountBO)18 ApplicationException (org.mifos.framework.exceptions.ApplicationException)17 ActionErrors (org.apache.struts.action.ActionErrors)14 LocalDate (org.joda.time.LocalDate)14 AccountApplyPaymentActionForm (org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm)14 ClientBO (org.mifos.customers.client.business.ClientBO)14 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)13 List (java.util.List)12 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)12 CustomFieldDefinitionEntity (org.mifos.application.master.business.CustomFieldDefinitionEntity)12 MeetingBO (org.mifos.application.meeting.business.MeetingBO)12 ActionForward (org.apache.struts.action.ActionForward)11