use of org.mifos.dto.domain.ApplicableCharge 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.dto.domain.ApplicableCharge in project head by mifos.
the class AccountBusinessService method getAppllicableFees.
public List<ApplicableCharge> getAppllicableFees(Integer accountId, UserContext userContext) throws ServiceException {
List<ApplicableCharge> applicableChargeList = null;
try {
AccountBO account = getlegacyAccountDao().getAccount(accountId);
FeeCategory categoryType = getCategoryType(account.getCustomer());
if (account.getType() == AccountTypes.LOAN_ACCOUNT || account.getType() == AccountTypes.GROUP_LOAN_ACCOUNT) {
applicableChargeList = getLoanApplicableCharges(getlegacyAccountDao().getAllApplicableFees(accountId, FeeCategory.LOAN), userContext, (LoanBO) account);
} else if (account.getType() == AccountTypes.CUSTOMER_ACCOUNT) {
if (account.getCustomer().getCustomerMeeting() == null) {
throw new ServiceException(AccountExceptionConstants.APPLY_CAHRGE_NO_CUSTOMER_MEETING_EXCEPTION);
}
applicableChargeList = getCustomerApplicableCharges(getlegacyAccountDao().getAllApplicableFees(accountId, categoryType), userContext, ((CustomerAccountBO) account).getCustomer().getCustomerMeeting().getMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId());
}
addMiscFeeAndPenalty(applicableChargeList);
} catch (PersistenceException pe) {
throw new ServiceException(pe);
}
return applicableChargeList;
}
use of org.mifos.dto.domain.ApplicableCharge in project head by mifos.
the class AccountBusinessService method addMiscFeeAndPenalty.
private void addMiscFeeAndPenalty(List<ApplicableCharge> applicableChargeList) {
ApplicableCharge applicableCharge = new ApplicableCharge();
applicableCharge.setFeeId(AccountConstants.MISC_FEES);
applicableCharge.setFeeName("Misc Fees");
applicableCharge.setIsRateType(false);
applicableCharge.setIsPenaltyType(false);
applicableChargeList.add(applicableCharge);
applicableCharge = new ApplicableCharge();
applicableCharge.setFeeId(AccountConstants.MISC_PENALTY);
applicableCharge.setFeeName("Misc Penalty");
applicableCharge.setIsRateType(false);
applicableCharge.setIsPenaltyType(false);
applicableChargeList.add(applicableCharge);
}
use of org.mifos.dto.domain.ApplicableCharge in project head by mifos.
the class AccountServiceIntegrationTest method testGetAppllicableFeesForMeetingStartingOnCurrentDate.
@Test
public void testGetAppllicableFeesForMeetingStartingOnCurrentDate() throws Exception {
// FIXME some test leaves database table (apart from CUSTOMER and
// PRD_OFFERING) in dirty state Failures are noticed on windows xp
// system, the execution order differs for surefire from OS to OS.
AccountBusinessService accountBusinessService = new AccountBusinessService();
CustomerAccountBO customerAccountBO = getCustomerAccountWithAllTypesOfFees();
StaticHibernateUtil.flushSession();
center = TestObjectFactory.getCustomer(center.getCustomerId());
StaticHibernateUtil.flushAndClearSession();
UserContext uc = TestUtils.makeUser();
List<ApplicableCharge> applicableChargeList = accountBusinessService.getAppllicableFees(customerAccountBO.getAccountId(), uc);
Assert.assertEquals(4, applicableChargeList.size());
for (ApplicableCharge applicableCharge : applicableChargeList) {
if (applicableCharge.getFeeName().equalsIgnoreCase("Upfront Fee")) {
// this is a rate, so we shouldn't have a trailing ".0"
Assert.assertEquals("20", applicableCharge.getAmountOrRate());
Assert.assertNotNull(applicableCharge.getFormula());
Assert.assertNull(applicableCharge.getPeriodicity());
} else if (applicableCharge.getFeeName().equalsIgnoreCase("Misc Fee")) {
Assert.assertNull(applicableCharge.getAmountOrRate());
Assert.assertNull(applicableCharge.getFormula());
Assert.assertNull(applicableCharge.getPeriodicity());
} else if (applicableCharge.getFeeName().equalsIgnoreCase("Periodic Fee")) {
Assert.assertEquals(new Money(getCurrency(), "200.0"), new Money(getCurrency(), applicableCharge.getAmountOrRate()));
Assert.assertNull(applicableCharge.getFormula());
Assert.assertNotNull(applicableCharge.getPeriodicity());
} else if (applicableCharge.getFeeName().equalsIgnoreCase("Mainatnence Fee")) {
Assert.assertFalse(true);
}
}
}
use of org.mifos.dto.domain.ApplicableCharge in project head by mifos.
the class CustomerRESTController method getApplicableFees.
@RequestMapping(value = "/customer/num-{globalCustNum}/fees", method = RequestMethod.GET)
@ResponseBody
public Map<String, Map<String, String>> getApplicableFees(@PathVariable String globalCustNum) throws Exception {
CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
Integer accountId = customerBO.getCustomerAccount().getAccountId();
List<ApplicableCharge> applicableCharges = this.accountServiceFacade.getApplicableFees(accountId);
Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>();
for (ApplicableCharge applicableCharge : applicableCharges) {
Map<String, String> feeMap = new HashMap<String, String>();
feeMap.put("feeId", applicableCharge.getFeeId());
feeMap.put("amountOrRate", applicableCharge.getAmountOrRate());
feeMap.put("formula", applicableCharge.getFormula());
feeMap.put("periodicity", applicableCharge.getPeriodicity());
feeMap.put("paymentType", applicableCharge.getPaymentType());
feeMap.put("isRateType", applicableCharge.getIsRateType());
map.put(applicableCharge.getFeeName(), feeMap);
}
return map;
}
Aggregations