Search in sources :

Example 1 with ApplicableCharge

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());
}
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 2 with ApplicableCharge

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;
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) ServiceException(org.mifos.framework.exceptions.ServiceException) LoanBO(org.mifos.accounts.loan.business.LoanBO) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) PersistenceException(org.mifos.framework.exceptions.PersistenceException) FeeCategory(org.mifos.accounts.fees.util.helpers.FeeCategory)

Example 3 with ApplicableCharge

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);
}
Also used : ApplicableCharge(org.mifos.dto.domain.ApplicableCharge)

Example 4 with 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);
        }
    }
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) Money(org.mifos.framework.util.helpers.Money) UserContext(org.mifos.security.util.UserContext) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) Test(org.junit.Test)

Example 5 with ApplicableCharge

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;
}
Also used : HashMap(java.util.HashMap) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) CustomerBO(org.mifos.customers.business.CustomerBO) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ApplicableCharge (org.mifos.dto.domain.ApplicableCharge)13 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)6 AccountBO (org.mifos.accounts.business.AccountBO)5 Test (org.junit.Test)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)4 UserContext (org.mifos.security.util.UserContext)4 Money (org.mifos.framework.util.helpers.Money)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 ServiceException (org.mifos.framework.exceptions.ServiceException)2 LocalizationConverter (org.mifos.framework.util.LocalizationConverter)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 Ignore (org.junit.Ignore)1 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)1 FeeBO (org.mifos.accounts.fees.business.FeeBO)1 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)1 FeeCategory (org.mifos.accounts.fees.util.helpers.FeeCategory)1 AmountPenaltyBO (org.mifos.accounts.penalties.business.AmountPenaltyBO)1