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