use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class RepayLoanActionStrutsTest method testMakeRepaymentForCurrentDateLiesBetweenInstallmentDates.
@Test
public void testMakeRepaymentForCurrentDateLiesBetweenInstallmentDates() throws Exception {
setMifosUserFromContext();
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
accountBO.changeFirstInstallmentDateBy(-1);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
Money amount = ((LoanBO) accountBO).getEarlyRepayAmount();
SessionUtils.setAttribute(LoanConstants.WAIVED_REPAYMENT_AMOUNT, Money.zero(), 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(false);
repayLoanActionForm.setDateOfPayment("23/12/2010");
setActionForm(repayLoanActionForm);
actionPerform();
verifyForward(Constants.UPDATE_SUCCESS);
Assert.assertEquals(accountBO.getAccountState().getId(), Short.valueOf(AccountStates.LOANACC_OBLIGATIONSMET));
LoanSummaryEntity loanSummaryEntity = ((LoanBO) accountBO).getLoanSummary();
Assert.assertEquals(amount, loanSummaryEntity.getPrincipalPaid().add(loanSummaryEntity.getFeesPaid()).add(loanSummaryEntity.getInterestPaid()).add(loanSummaryEntity.getPenaltyPaid()));
}
use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class LoanAccountActionStrutsTest method testGet.
@Test
public void testGet() throws Exception {
setMifosUserFromContext();
Date startDate = new Date(System.currentTimeMillis());
accountBO = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1);
LoanBO loan = (LoanBO) accountBO;
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter("method", "get");
addRequestParameter("globalAccountNum", loan.getGlobalAccountNum());
actionPerform();
verifyForward("get_success");
Assert.assertEquals(0, loan.getPerformanceHistory().getNoOfPayments().intValue());
// Assert.assertEquals((accountBO).getTotalAmountDue().getAmountDoubleValue(), 212.0);
modifyActionDateForFirstInstallment();
Assert.assertEquals("Total no. of notes should be 5", 5, accountBO.getAccountNotes().size());
// LoanInformationDto loanInformationDto = retrieveLoanInformationDtoFromSession();
// Assert.assertEquals("Total no. of recent notes should be 3", 3, loanInformationDto.getRecentAccountNotes().size());
}
use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class AccountActionStrutsTest method testGetTrxnHistorySucess.
@Test
public void testGetTrxnHistorySucess() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
Date currentDate = new Date(System.currentTimeMillis());
setRequestPathInfo("/accountAppAction");
addRequestParameter("method", "getTrxnHistory");
addRequestParameter("accountId", accountBO.getAccountId().toString());
addRequestParameter("feeId", "123");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
LoanBO loan = (LoanBO) accountBO;
loan.setUserContext(TestUtils.makeUser());
List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
accntActionDates.addAll(loan.getAccountActionDates());
PaymentData accountPaymentDataView = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(0), null, loan.getPersonnel(), "receiptNum", Short.valueOf("1"), currentDate, currentDate);
IntegrationTestObjectMother.applyAccountPayment(loan, accountPaymentDataView);
actionPerform();
verifyForward("getTransactionHistory_success");
StaticHibernateUtil.flushSession();
accountBO = TestObjectFactory.getObject(AccountBO.class, loan.getAccountId());
List<TransactionHistoryDto> trxnHistoryList = (List<TransactionHistoryDto>) SessionUtils.getAttribute(SavingsConstants.TRXN_HISTORY_LIST, request);
for (TransactionHistoryDto transactionHistoryDto : trxnHistoryList) {
Assert.assertEquals(accountBO.getUserContext().getName(), transactionHistoryDto.getPostedBy());
}
}
use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class ApplyAdjustmentActionStrutsTest method getLoanAccount.
private AccountBO getLoanAccount() {
Date startDate = new Date(System.currentTimeMillis());
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter(this.getClass().getSimpleName() + " Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter(this.getClass().getSimpleName() + " Group", CustomerStatus.GROUP_ACTIVE, center);
LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
LoanBO loan = TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
StaticHibernateUtil.flushSession();
return TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
}
use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class ApplyAdjustmentActionStrutsTest method testApplyAdjustment.
@Ignore
@Test
public void testApplyAdjustment() throws Exception {
PersonnelBO personnel = legacyPersonnelDao.getPersonnel(PersonnelConstants.SYSTEM_USER);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
loan = (LoanBO) getLoanAccount();
applyPayment(loan, 212);
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
applyPayment(loan, 700);
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
AccountStatusChangeHistoryEntity historyEntity = new AccountStatusChangeHistoryEntity(new AccountStateEntity(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING), new AccountStateEntity(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING), personnel, loan);
AccountTestUtils.addToAccountStatusChangeHistory(loan, historyEntity);
TestObjectFactory.updateObject(loan);
StaticHibernateUtil.flushAndClearSession();
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
loan.setUserContext(userContext);
for (AccountStatusChangeHistoryEntity accountStatus : loan.getAccountStatusChangeHistory()) {
Assert.assertEquals(loan.getAccountId(), accountStatus.getAccount().getAccountId());
Assert.assertNotNull(accountStatus.getAccountStatusChangeId());
Assert.assertEquals(AccountState.LOAN_ACTIVE_IN_GOOD_STANDING.getValue(), accountStatus.getNewStatus().getId());
Assert.assertEquals(personnel.getPersonnelId(), accountStatus.getPersonnel().getPersonnelId());
Assert.assertEquals(personnel.getDisplayName(), accountStatus.getPersonnel().getDisplayName());
Assert.assertEquals("-", accountStatus.getOldStatusName());
Assert.assertNotNull(accountStatus.getNewStatusName());
Assert.assertNull(accountStatus.getLocale());
Assert.assertNotNull(accountStatus.getUserPrefferedTransactionDate());
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
setRequestPathInfo("/applyAdjustment");
addRequestParameter("method", "applyAdjustment");
addRequestParameter("adjustmentNote", "Loan adjustment testing");
addRequestParameter("globalAccountNum", loan.getGlobalAccountNum());
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
setUpSecurityContext();
getRequest().getSession().setAttribute(Constants.USERCONTEXT, TestUtils.makeUser());
actionPerform();
loan = (LoanBO) TestObjectFactory.getObject(AccountBO.class, loan.getAccountId());
verifyForward("applyadj_success");
}
Aggregations