use of org.mifos.accounts.fees.struts.actionforms.FeeActionForm in project head by mifos.
the class FeeAction method editPreview.
@TransactionDemarcate(joinToken = true)
public ActionForward editPreview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
Short feeId = ((FeeActionForm) form).getFeeIdValue();
FeeDto feeDto = this.feeDao.findDtoById(feeId);
Short appliedFeeId = this.feeDao.findFeeAppliedToLoan(feeId);
boolean isInProducts = appliedFeeId == null ? true : false;
List<Short> feesAppliedLoanAccountList = this.feeDao.getAllUsedLoansWithAttachedFee();
boolean isFeeAppliedToLoan = feesAppliedLoanAccountList.contains(feeId);
Short feeInSchedule = this.feeDao.findFeeInSchedule(feeId);
boolean isFeeInSchedule = feeInSchedule == null ? false : true;
ActionMessages messages = new ActionMessages();
if (!(((FeeActionForm) form).isToRemove() && feeDto.getFeeStatus().getId().equalsIgnoreCase("2"))) {
form.reset(mapping, request);
}
if (((FeeActionForm) form).isToRemove()) {
if (!isInProducts && !isFeeAppliedToLoan) {
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemoved"));
} else if (isFeeAppliedToLoan) {
if (!isFeeInSchedule) {
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemovedFromPrd"));
((FeeActionForm) form).setCantBeRemoved(true);
} else {
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemovedFromPrdButNotDeleted"));
}
} else {
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeNotUsedRemove"));
}
} else {
if (((FeeActionForm) form).getFeeStatusValue().getValue() == 2) {
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Fees.feeRemovedFromPrdWhenInActive"));
}
}
saveErrors(request, messages);
request.getSession().setAttribute("feeModel", feeDto);
return mapping.findForward(ActionForwards.editPreview_success.toString());
}
use of org.mifos.accounts.fees.struts.actionforms.FeeActionForm in project head by mifos.
the class FeeAction method get.
@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
Short feeId = ((FeeActionForm) form).getFeeIdValue();
FeeDto feeDto = this.feeDao.findDtoById(feeId);
request.setAttribute("feeModel", feeDto);
request.setAttribute("GlNamesMode", AccountingRules.getGlNamesMode());
return mapping.findForward(ActionForwards.get_success.toString());
}
use of org.mifos.accounts.fees.struts.actionforms.FeeActionForm in project head by mifos.
the class FeeAction method editPrevious.
@TransactionDemarcate(joinToken = true)
public ActionForward editPrevious(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
Short feeId = ((FeeActionForm) form).getFeeIdValue();
FeeDto feeDto = this.feeDao.findDtoById(feeId);
request.setAttribute("feeModel", feeDto);
return mapping.findForward(ActionForwards.editprevious_success.toString());
}
use of org.mifos.accounts.fees.struts.actionforms.FeeActionForm in project head by mifos.
the class FeeActionStrutsTest method testSuccessfulEditPreview.
@Ignore
@Test
public void testSuccessfulEditPreview() throws Exception {
fee = TestObjectFactory.createOneTimeAmountFee("One Time Fee", FeeCategory.ALLCUSTOMERS, "12.34", FeePayment.UPFRONT);
LookUpValueEntity lookUpValue = new LookUpValueEntity();
fee.getFeeFrequency().getFeeFrequencyType().setLookUpValue(lookUpValue);
fee.getFeeFrequency().getFeePayment().setLookUpValue(lookUpValue);
String feeId = fee.getFeeId().toString();
request.setAttribute("feeModel", TestObjectFactory.getAmountBasedFee(feeId, "1", "12.34"));
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
setRequestPathInfo("/feeaction.do");
addRequestParameter("method", "manage");
addRequestParameter("feeId", feeId);
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
setRequestPathInfo("/feeaction.do");
addRequestParameter("method", "editPreview");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter("amount", "200.0");
addRequestParameter("feeStatus", FeeStatus.INACTIVE.getValue().toString());
actionPerform();
verifyNoActionErrors();
verifyForward(ActionForwards.editPreview_success.toString());
FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
Assert.assertEquals("200.0", actionForm.getAmount());
Assert.assertEquals(FeeStatus.INACTIVE, actionForm.getFeeStatusValue());
Assert.assertNull(actionForm.getRate());
Assert.assertNull(actionForm.getFeeFormula());
}
use of org.mifos.accounts.fees.struts.actionforms.FeeActionForm in project head by mifos.
the class FeeActionStrutsTest method testSuccessfulManage_AmountFee.
@Test
public void testSuccessfulManage_AmountFee() throws Exception {
fee = TestObjectFactory.createOneTimeAmountFee("One Time Fee", FeeCategory.ALLCUSTOMERS, "12.34", FeePayment.UPFRONT);
LookUpValueEntity lookUpValue = new LookUpValueEntity();
fee.getFeeFrequency().getFeeFrequencyType().setLookUpValue(lookUpValue);
fee.getFeeFrequency().getFeePayment().setLookUpValue(lookUpValue);
String feeId = fee.getFeeId().toString();
request.setAttribute("feefeeModel", TestObjectFactory.getAmountBasedFee(feeId, "StatusID", "12.34"));
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
setRequestPathInfo("/feeaction.do");
addRequestParameter("method", "manage");
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
addRequestParameter("feeId", feeId);
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward(ActionForwards.manage_success.toString());
FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
Assert.assertEquals("12.3", actionForm.getAmount());
Assert.assertNull(actionForm.getRate());
Assert.assertNull(actionForm.getFeeFormula());
Assert.assertEquals("The size of master data for status", 2, ((List<MasterDataEntity>) SessionUtils.getAttribute(FeeConstants.STATUSLIST, request)).size());
}
Aggregations