Search in sources :

Example 1 with ApplyChargeActionForm

use of org.mifos.accounts.struts.actionforms.ApplyChargeActionForm 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 ApplyChargeActionForm

use of org.mifos.accounts.struts.actionforms.ApplyChargeActionForm 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 ApplyChargeActionForm

use of org.mifos.accounts.struts.actionforms.ApplyChargeActionForm 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 ApplyChargeActionForm

use of org.mifos.accounts.struts.actionforms.ApplyChargeActionForm in project head by mifos.

the class ApplyChargeAction method update.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ApplyChargeActionForm applyChargeActionForm = (ApplyChargeActionForm) form;
    Short feeId = Short.valueOf(applyChargeActionForm.getFeeId());
    Double chargeAmount = 0.0;
    AccountBO account = new AccountBusinessService().getAccount(Integer.valueOf(applyChargeActionForm.getAccountId()));
    if (!(account instanceof CustomerAccountBO) && null == ((LoanBO) account).getParentAccount() && account.isGroupLoanAccount()) {
        this.accountServiceFacade.applyGroupCharge(applyChargeActionForm.getIndividualValues(), feeId, applyChargeActionForm.isPenaltyType());
    } else {
        chargeAmount = getDoubleValue(request.getParameter("charge"));
        this.accountServiceFacade.applyCharge(account.getAccountId(), feeId, chargeAmount, applyChargeActionForm.isPenaltyType());
    }
    AccountTypeCustomerLevelDto accountTypeCustomerLevel = accountServiceFacade.getAccountTypeCustomerLevelDto(account.getAccountId());
    return mapping.findForward(getDetailAccountPage(accountTypeCustomerLevel));
}
Also used : AccountTypeCustomerLevelDto(org.mifos.dto.screen.AccountTypeCustomerLevelDto) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ApplyChargeActionForm(org.mifos.accounts.struts.actionforms.ApplyChargeActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 5 with ApplyChargeActionForm

use of org.mifos.accounts.struts.actionforms.ApplyChargeActionForm in project head by mifos.

the class ApplyChargeActionStrutsTest method testCancel.

@Test
public void testCancel() throws Exception {
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    createInitialObjects();
    setRequestPathInfo("/applyChargeAction.do");
    addRequestParameter("method", "cancel");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    accountBO = getLoanAccount(client, meeting);
    ApplyChargeActionForm applyChargeActionForm = new ApplyChargeActionForm();
    applyChargeActionForm.setAccountId(accountBO.getAccountId().toString());
    setActionForm(applyChargeActionForm);
    actionPerform();
    verifyForward("loanDetails_success");
    verifyNoActionErrors();
    verifyNoActionMessages();
}
Also used : ApplyChargeActionForm(org.mifos.accounts.struts.actionforms.ApplyChargeActionForm) Test(org.junit.Test)

Aggregations

ApplyChargeActionForm (org.mifos.accounts.struts.actionforms.ApplyChargeActionForm)5 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)4 AccountBO (org.mifos.accounts.business.AccountBO)2 LoanBO (org.mifos.accounts.loan.business.LoanBO)2 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)2 AccountTypeCustomerLevelDto (org.mifos.dto.screen.AccountTypeCustomerLevelDto)2 BigDecimal (java.math.BigDecimal)1 Test (org.junit.Test)1 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)1 FeeBO (org.mifos.accounts.fees.business.FeeBO)1 LegacyAccountDao (org.mifos.accounts.persistence.LegacyAccountDao)1 ApplicableCharge (org.mifos.dto.domain.ApplicableCharge)1 GroupIndividualLoanDto (org.mifos.dto.domain.GroupIndividualLoanDto)1