Search in sources :

Example 6 with ApplicableCharge

use of org.mifos.dto.domain.ApplicableCharge in project head by mifos.

the class LoanAccountRESTController method getApplicableFees.

@RequestMapping(value = "/account/loan/num-{globalAccountNum}/fees", method = RequestMethod.GET)
@ResponseBody
public Map<String, Map<String, String>> getApplicableFees(@PathVariable String globalAccountNum) throws Exception {
    LoanBO loan = loanDao.findByGlobalAccountNum(globalAccountNum);
    Integer accountId = loan.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) LoanBO(org.mifos.accounts.loan.business.LoanBO) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) Map(java.util.Map) HashMap(java.util.HashMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with ApplicableCharge

use of org.mifos.dto.domain.ApplicableCharge in project head by mifos.

the class AccountBusinessService method populaleApplicableCharge.

private void populaleApplicableCharge(List<ApplicableCharge> applicableChargeList, List<FeeBO> feeList, UserContext userContext) {
    for (FeeBO fee : feeList) {
        ApplicableCharge applicableCharge = new ApplicableCharge();
        applicableCharge.setFeeId(fee.getFeeId().toString());
        applicableCharge.setFeeName(fee.getFeeName());
        applicableCharge.setIsPenaltyType(false);
        if (fee.getFeeType().getValue().equals(RateAmountFlag.RATE.getValue())) {
            applicableCharge.setAmountOrRate(new LocalizationConverter().getDoubleStringForInterest(((RateFeeBO) fee).getRate()));
            applicableCharge.setFormula(((RateFeeBO) fee).getFeeFormula().getFormulaStringThatHasName());
            applicableCharge.setIsRateType(true);
        } else {
            applicableCharge.setAmountOrRate(((AmountFeeBO) fee).getFeeAmount().toString());
            applicableCharge.setIsRateType(false);
        }
        MeetingBO meeting = fee.getFeeFrequency().getFeeMeetingFrequency();
        if (meeting != null) {
            applicableCharge.setPeriodicity(new MeetingHelper().getDetailMessageWithFrequency(meeting, userContext));
        } else {
            applicableCharge.setPaymentType(fee.getFeeFrequency().getFeePayment().getName());
        }
        applicableChargeList.add(applicableCharge);
    }
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) LocalizationConverter(org.mifos.framework.util.LocalizationConverter) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) FeeBO(org.mifos.accounts.fees.business.FeeBO) RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) MeetingHelper(org.mifos.application.meeting.util.helpers.MeetingHelper) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Example 8 with ApplicableCharge

use of org.mifos.dto.domain.ApplicableCharge in project head by mifos.

the class AccountServiceIntegrationTest method testGetAppllicableFees.

@Test
public void testGetAppllicableFees() throws Exception {
    AccountBusinessService accountBusinessService = new AccountBusinessService();
    accountBO = getLoanAccount();
    StaticHibernateUtil.flushSession();
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
    UserContext uc = TestUtils.makeUser();
    List<ApplicableCharge> applicableChargeList = accountBusinessService.getAppllicableFees(accountBO.getAccountId(), uc);
    Assert.assertEquals(2, applicableChargeList.size());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) UserContext(org.mifos.security.util.UserContext) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) Test(org.junit.Test)

Example 9 with ApplicableCharge

use of org.mifos.dto.domain.ApplicableCharge in project head by mifos.

the class AccountServiceIntegrationTest method testGetAppllicableFeesForInstallmentStartingOnCurrentDate.

@Test
@Ignore
public void testGetAppllicableFeesForInstallmentStartingOnCurrentDate() throws Exception {
    AccountBusinessService accountBusinessService = new AccountBusinessService();
    accountBO = getLoanAccountWithAllTypesOfFees();
    StaticHibernateUtil.flushSession();
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
    StaticHibernateUtil.flushAndClearSession();
    UserContext uc = TestUtils.makeUser();
    List<ApplicableCharge> applicableChargeList = accountBusinessService.getAppllicableFees(accountBO.getAccountId(), uc);
    Assert.assertEquals(4, applicableChargeList.size());
    for (ApplicableCharge applicableCharge : applicableChargeList) {
        if (applicableCharge.getFeeName().equalsIgnoreCase("Upfront Fee")) {
            Assert.assertEquals(new Money(getCurrency(), "20.0"), new Money(getCurrency(), applicableCharge.getAmountOrRate()));
            Assert.assertNotNull(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("Misc Fee")) {
            Assert.assertNull(applicableCharge.getAmountOrRate());
            Assert.assertNull(applicableCharge.getFormula());
            Assert.assertNull(applicableCharge.getPeriodicity());
        }
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) 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) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with ApplicableCharge

use of org.mifos.dto.domain.ApplicableCharge in project head by mifos.

the class AccountServiceIntegrationTest method testGetAppllicableFeesForInstallmentStartingAfterCurrentDate.

@Test
public void testGetAppllicableFeesForInstallmentStartingAfterCurrentDate() throws Exception {
    AccountBusinessService accountBusinessService = new AccountBusinessService();
    accountBO = getLoanAccountWithAllTypesOfFees();
    incrementInstallmentDate(accountBO, 1, Short.valueOf("1"));
    accountBO.setUserContext(TestObjectFactory.getContext());
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    accountBO.changeStatus(AccountState.LOAN_DISBURSED_TO_LOAN_OFFICER, null, "", loggedInUser);
    TestObjectFactory.updateObject(accountBO);
    StaticHibernateUtil.flushSession();
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    StaticHibernateUtil.flushAndClearSession();
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
    UserContext uc = TestUtils.makeUser();
    List<ApplicableCharge> applicableChargeList = accountBusinessService.getAppllicableFees(accountBO.getAccountId(), uc);
    Assert.assertEquals(3, applicableChargeList.size());
    for (ApplicableCharge applicableCharge : applicableChargeList) {
        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("Misc Fee")) {
            Assert.assertNull(applicableCharge.getAmountOrRate());
            Assert.assertNull(applicableCharge.getFormula());
            Assert.assertNull(applicableCharge.getPeriodicity());
        }
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) ApplicableCharge(org.mifos.dto.domain.ApplicableCharge) Test(org.junit.Test)

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