Search in sources :

Example 1 with AccountUpdateStatus

use of org.mifos.dto.domain.AccountUpdateStatus in project head by mifos.

the class AccountStatusAction method update.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse httpservletresponse) throws Exception {
    AccountStatusActionForm accountStatusActionForm = (AccountStatusActionForm) form;
    List<AccountUpdateStatus> accountsForUpdate = new ArrayList<AccountUpdateStatus>();
    List<AccountUpdateStatus> individualAccountsForUpdate = new ArrayList<AccountUpdateStatus>();
    for (String accountId : accountStatusActionForm.getAccountRecords()) {
        if (StringUtils.isNotBlank(accountId)) {
            Long accountIdValue = Long.parseLong(accountId);
            //GLIM
            List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(Integer.valueOf(accountId));
            for (LoanBO indivdual : individualLoans) {
                Short newStatusId = getShortValue(accountStatusActionForm.getNewStatus());
                individualAccountsForUpdate.add(new AccountUpdateStatus(indivdual.getAccountId().longValue(), newStatusId, null, accountStatusActionForm.getComments()));
            }
            this.loanAccountServiceFacade.updateSeveralLoanAccountStatuses(individualAccountsForUpdate, null);
            Short newStatusId = getShortValue(accountStatusActionForm.getNewStatus());
            Short flagId = null;
            String comment = accountStatusActionForm.getComments();
            accountsForUpdate.add(new AccountUpdateStatus(accountIdValue, newStatusId, flagId, comment));
        }
    }
    List<String> accountNumbers = this.loanAccountServiceFacade.updateSeveralLoanAccountStatuses(accountsForUpdate, null);
    request.setAttribute(LoanConstants.ACCOUNTS_LIST, accountNumbers);
    return mapping.findForward(ActionForwards.changeAccountStatusConfirmation_success.toString());
}
Also used : AccountUpdateStatus(org.mifos.dto.domain.AccountUpdateStatus) LoanBO(org.mifos.accounts.loan.business.LoanBO) AccountStatusActionForm(org.mifos.accounts.loan.struts.actionforms.AccountStatusActionForm) ArrayList(java.util.ArrayList) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with AccountUpdateStatus

use of org.mifos.dto.domain.AccountUpdateStatus in project head by mifos.

the class LoanAccountServiceFacadeWebTier method updateSeveralLoanAccountStatuses.

@Override
public List<String> updateSeveralLoanAccountStatuses(List<AccountUpdateStatus> accountsForUpdate, Date transactionDate) {
    List<String> updatedAccountNumbers = new ArrayList<String>();
    for (AccountUpdateStatus accountUpdate : accountsForUpdate) {
        String accountNumber = updateLoanAccountStatus(accountUpdate, transactionDate);
        updatedAccountNumbers.add(accountNumber);
    }
    return updatedAccountNumbers;
}
Also used : AccountUpdateStatus(org.mifos.dto.domain.AccountUpdateStatus) ArrayList(java.util.ArrayList)

Example 3 with AccountUpdateStatus

use of org.mifos.dto.domain.AccountUpdateStatus in project head by mifos.

the class EditStatusAction method update.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    UserContext userContext = getUserContext(request);
    EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
    Integer accountId = Integer.valueOf(editStatusActionForm.getAccountId());
    AccountBO accountBO = new AccountBusinessService().getAccount(accountId);
    Short flagId = null;
    Short newStatusId = null;
    String updateComment = editStatusActionForm.getNotes();
    if (StringUtils.isNotBlank(editStatusActionForm.getFlagId())) {
        flagId = getShortValue(editStatusActionForm.getFlagId());
    }
    if (StringUtils.isNotBlank(editStatusActionForm.getNewStatusId())) {
        newStatusId = getShortValue(editStatusActionForm.getNewStatusId());
    }
    Date trxnDate = editStatusActionForm.getTransactionDateValue(userContext.getPreferredLocale());
    if (editStatusActionForm.getNewStatusId().equals(AccountState.LOAN_APPROVED) && !AccountingRules.isBackDatedApprovalAllowed()) {
        trxnDate = new DateTimeService().getCurrentJavaDateTime();
    }
    checkPermission(accountBO, getUserContext(request), newStatusId, flagId);
    if (accountBO.isLoanAccount() || accountBO.isGroupLoanAccount()) {
        initializeLoanQuestionnaire(accountBO.getGlobalAccountNum(), newStatusId != null ? newStatusId.toString() : null);
        loanQuestionnaire.saveResponses(request, editStatusActionForm, accountId);
        //GLIM
        List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(accountId);
        List<AccountUpdateStatus> updateStatus = new ArrayList<AccountUpdateStatus>(individualLoans.size() + 1);
        updateStatus.add(new AccountUpdateStatus(accountId.longValue(), newStatusId, flagId, updateComment));
        for (LoanBO individual : individualLoans) {
            updateStatus.add(new AccountUpdateStatus(individual.getAccountId().longValue(), newStatusId, flagId, updateComment));
        }
        try {
            if (individualLoans.size() == 0) {
                this.loanAccountServiceFacade.updateSingleLoanAccountStatus(updateStatus.get(0), trxnDate);
            } else {
                this.loanAccountServiceFacade.updateSeveralLoanAccountStatuses(updateStatus, trxnDate);
            }
        } catch (AccessDeniedException e) {
            throw new ServiceException(SecurityConstants.KEY_ACTIVITY_APPROVE_LOAN_NOT_ALLOWED);
        }
        return mapping.findForward(ActionForwards.loan_detail_page.toString());
    }
    if (accountBO.isSavingsAccount()) {
        AccountUpdateStatus updateStatus = new AccountUpdateStatus(accountId.longValue(), newStatusId, flagId, updateComment);
        this.savingsServiceFacade.updateSavingsAccountStatus(updateStatus);
        return mapping.findForward(ActionForwards.savings_details_page.toString());
    }
    // nothing but loan of savings account should be detected. customer account status change goes through separate action.
    return null;
}
Also used : AccountUpdateStatus(org.mifos.dto.domain.AccountUpdateStatus) EditStatusActionForm(org.mifos.accounts.struts.actionforms.EditStatusActionForm) AccessDeniedException(org.springframework.security.access.AccessDeniedException) UserContext(org.mifos.security.util.UserContext) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) Date(java.util.Date) AccountBO(org.mifos.accounts.business.AccountBO) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) DateTimeService(org.mifos.framework.util.DateTimeService) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with AccountUpdateStatus

use of org.mifos.dto.domain.AccountUpdateStatus in project head by mifos.

the class MaxLoanAmountForApprovePermission method isAllowed.

@Override
public boolean isAllowed(Authentication authentication, Object targetDomainObject) throws ServiceException {
    if (targetDomainObject instanceof AccountUpdateStatus) {
        AccountUpdateStatus accountUpdateStatus = (AccountUpdateStatus) targetDomainObject;
        MifosUser user = (MifosUser) authentication.getPrincipal();
        return checkPermissionByAccountUpdateStatus(user, accountUpdateStatus);
    } else if (targetDomainObject instanceof List) {
        boolean isAllowed = true;
        List<AccountUpdateStatus> accountsUpdateStatus = (List<AccountUpdateStatus>) targetDomainObject;
        MifosUser user = (MifosUser) authentication.getPrincipal();
        for (AccountUpdateStatus accountUpdateStatus : accountsUpdateStatus) {
            isAllowed = checkPermissionByAccountUpdateStatus(user, accountUpdateStatus);
            if (!isAllowed) {
                return false;
            }
        }
        return isAllowed;
    }
    return true;
}
Also used : AccountUpdateStatus(org.mifos.dto.domain.AccountUpdateStatus) MifosUser(org.mifos.security.MifosUser) List(java.util.List)

Aggregations

AccountUpdateStatus (org.mifos.dto.domain.AccountUpdateStatus)4 ArrayList (java.util.ArrayList)3 LoanBO (org.mifos.accounts.loan.business.LoanBO)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 Date (java.util.Date)1 List (java.util.List)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)1 AccountStatusActionForm (org.mifos.accounts.loan.struts.actionforms.AccountStatusActionForm)1 EditStatusActionForm (org.mifos.accounts.struts.actionforms.EditStatusActionForm)1 ServiceException (org.mifos.framework.exceptions.ServiceException)1 DateTimeService (org.mifos.framework.util.DateTimeService)1 CloseSession (org.mifos.framework.util.helpers.CloseSession)1 MifosUser (org.mifos.security.MifosUser)1 UserContext (org.mifos.security.util.UserContext)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1