Search in sources :

Example 6 with LoanSummaryEntity

use of org.mifos.accounts.loan.business.LoanSummaryEntity in project head by mifos.

the class RepayLoanActionStrutsTest method testMakeRepaymentForCurrentDateLiesBetweenInstallmentDatesWithInterestWaiver.

@Test
public void testMakeRepaymentForCurrentDateLiesBetweenInstallmentDatesWithInterestWaiver() throws Exception {
    setMifosUserFromContext();
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    accountBO.changeFirstInstallmentDateBy(-1);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
    Money amount = ((LoanBO) accountBO).getEarlyRepayAmount();
    Money waivedAmount = amount.subtract(((LoanBO) accountBO).waiverAmount());
    SessionUtils.setAttribute(LoanConstants.WAIVED_REPAYMENT_AMOUNT, waivedAmount, request);
    SessionUtils.setAttribute(LoanConstants.TOTAL_REPAYMENT_AMOUNT, amount, request);
    setRequestPathInfo("/repayLoanAction");
    addRequestParameter("method", "makeRepayment");
    addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
    addRequestParameter("paymentTypeId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    RepayLoanActionForm repayLoanActionForm = new RepayLoanActionForm();
    repayLoanActionForm.setAmount(amount.toString());
    repayLoanActionForm.setWaiverInterest(true);
    setActionForm(repayLoanActionForm);
    repayLoanActionForm.setDateOfPayment("23/12/2010");
    actionPerform();
    verifyForward(Constants.UPDATE_SUCCESS);
    Assert.assertEquals(accountBO.getAccountState().getId(), Short.valueOf(AccountStates.LOANACC_OBLIGATIONSMET));
    LoanSummaryEntity loanSummaryEntity = ((LoanBO) accountBO).getLoanSummary();
    Assert.assertEquals(waivedAmount, loanSummaryEntity.getPrincipalPaid().add(loanSummaryEntity.getFeesPaid()).add(loanSummaryEntity.getInterestPaid()).add(loanSummaryEntity.getPenaltyPaid()));
}
Also used : Money(org.mifos.framework.util.helpers.Money) LoanBO(org.mifos.accounts.loan.business.LoanBO) RepayLoanActionForm(org.mifos.accounts.loan.struts.actionforms.RepayLoanActionForm) LoanSummaryEntity(org.mifos.accounts.loan.business.LoanSummaryEntity) Test(org.junit.Test)

Aggregations

LoanBO (org.mifos.accounts.loan.business.LoanBO)6 LoanSummaryEntity (org.mifos.accounts.loan.business.LoanSummaryEntity)6 Test (org.junit.Test)5 Money (org.mifos.framework.util.helpers.Money)5 RepayLoanActionForm (org.mifos.accounts.loan.struts.actionforms.RepayLoanActionForm)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)1 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)1 PaymentData (org.mifos.accounts.util.helpers.PaymentData)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 LoanSummaryDto (org.mifos.dto.screen.LoanSummaryDto)1