use of org.mifos.dto.screen.RepayLoanDto in project head by mifos.
the class LoanAccountServiceFacadeWebTierTest method shouldReturnRepayLoanDtoWithAllDataPopulatedForDecliningBalanceInterestRecalculation.
@Test
public void shouldReturnRepayLoanDtoWithAllDataPopulatedForDecliningBalanceInterestRecalculation() {
setMifosUserFromContext();
String accountNumber = "1234";
LoanBO loanBO = mock(LoanBO.class);
Money repaymentAmount = TestUtils.createMoney("1234");
Money interest = TestUtils.createMoney("100");
DateTime currentDate = new DateTime(2010, 10, 30, 0, 0, 0, 0);
new DateTimeService().setCurrentDateTime(currentDate);
RepaymentResultsHolder repaymentResultsHolder = new RepaymentResultsHolder();
repaymentResultsHolder.setTotalRepaymentAmount(repaymentAmount.getAmount());
repaymentResultsHolder.setWaiverAmount(interest.getAmount());
when(loanDao.findByGlobalAccountNum(accountNumber)).thenReturn(loanBO);
when(scheduleCalculatorAdaptor.computeRepaymentAmount(loanBO, currentDate.toDate())).thenReturn(repaymentResultsHolder);
when(loanBO.getCurrency()).thenReturn(repaymentAmount.getCurrency());
when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(true);
when(loanBO.getOfficeId()).thenReturn((short) 1);
when(loanBO.getCustomer()).thenReturn(customer);
when(customer.getLoanOfficerId()).thenReturn((short) 1);
RepayLoanDto repayLoanDto = this.loanAccountServiceFacade.retrieveLoanRepaymentDetails(accountNumber);
verify(loanDao).findByGlobalAccountNum(accountNumber);
verify(scheduleCalculatorAdaptor).computeRepaymentAmount(loanBO, currentDate.toDate());
verify(loanBO, never()).waiverAmount();
verify(loanBO, never()).getEarlyRepayAmount();
verify(loanBO).isDecliningBalanceInterestRecalculation();
assertEquals(repayLoanDto.getEarlyRepaymentMoney(), repaymentAmount.toString());
assertEquals(repayLoanDto.getWaivedRepaymentMoney(), repaymentAmount.subtract(interest).toString());
}
use of org.mifos.dto.screen.RepayLoanDto in project head by mifos.
the class LoanAccountServiceFacadeWebTierTest method shouldReturnRepayLoanDtoWithAllDataPopulated.
@Test
public void shouldReturnRepayLoanDtoWithAllDataPopulated() {
setMifosUserFromContext();
String accountNumber = "1234";
LoanBO loanBO = mock(LoanBO.class);
Money repaymentAmount = TestUtils.createMoney("1234");
Money interest = TestUtils.createMoney("100");
when(loanDao.findByGlobalAccountNum(accountNumber)).thenReturn(loanBO);
when(loanBO.getEarlyRepayAmount()).thenReturn(repaymentAmount);
when(loanBO.waiverAmount()).thenReturn(interest);
when(loanBO.isDecliningBalanceInterestRecalculation()).thenReturn(false);
when(loanBO.getOfficeId()).thenReturn((short) 1);
when(loanBO.getCustomer()).thenReturn(customer);
when(customer.getLoanOfficerId()).thenReturn((short) 1);
Money waivedAmount = repaymentAmount.subtract(interest);
RepayLoanDto repayLoanDto = this.loanAccountServiceFacade.retrieveLoanRepaymentDetails(accountNumber);
verify(loanDao).findByGlobalAccountNum(accountNumber);
verify(loanBO).waiverAmount();
verify(loanBO).getEarlyRepayAmount();
verify(loanBO).isDecliningBalanceInterestRecalculation();
assertEquals(repayLoanDto.getEarlyRepaymentMoney(), repaymentAmount.toString());
assertEquals(repayLoanDto.getWaivedRepaymentMoney(), waivedAmount.toString());
}
use of org.mifos.dto.screen.RepayLoanDto in project head by mifos.
the class LoanAccountRESTController method isLoanInterestWaivable.
@RequestMapping(value = "/account/loan/num-{globalAccountNum}/interestWaivable", method = RequestMethod.GET)
@ResponseBody
public Map<String, String> isLoanInterestWaivable(@PathVariable String globalAccountNum) throws Exception {
RepayLoanDto repayLoanDto = this.loanAccountServiceFacade.retrieveLoanRepaymentDetails(globalAccountNum);
Map<String, String> map = new HashMap<String, String>();
map.put("isInterestWaivable", Boolean.toString(repayLoanDto.shouldWaiverInterest()));
map.put("defaultValue", Boolean.toString(repayLoanDto.shouldWaiverInterest()));
return map;
}
Aggregations