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");
}
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));
}
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());
}
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));
}
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();
}
Aggregations