use of org.mifos.accounts.business.AccountBO 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.business.AccountBO in project head by mifos.
the class EditStatusActionStrutsTest method updateSuccessForLoan.
@Ignore("Convert to unit test")
public void updateSuccessForLoan() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
// createInitialObjects();
createCenterGroupClientHierarchy();
accountBO = getLoanAccount(client, meeting, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
setRequestPathInfo("/editStatusAction.do");
addRequestParameter("method", "load");
addRequestParameter("input", "loan");
addRequestParameter("accountId", accountBO.getAccountId().toString());
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward("load_success");
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
setRequestPathInfo("/editStatusAction.do");
addRequestParameter("method", "preview");
addRequestParameter("input", "loan");
addRequestParameter("notes", "Test");
addRequestParameter("accountTypeId", accountBO.getType().getValue().toString());
addRequestParameter("newStatusId", "8");
addRequestParameter("flagId", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward("preview_success");
StaticHibernateUtil.flushSession();
setRequestPathInfo("/editStatusAction.do");
addRequestParameter("method", "update");
addRequestParameter("notes", "Test");
addRequestParameter("accountTypeId", accountBO.getType().getValue().toString());
addRequestParameter("newStatusId", "8");
addRequestParameter("flagId", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward(ActionForwards.loan_detail_page.toString());
verifyNoActionErrors();
verifyNoActionMessages();
accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.LOAN, accountBO.getAccountId());
Assert.assertEquals(1, auditLogList.size());
Assert.assertEquals(EntityType.LOAN.getValue(), auditLogList.get(0).getEntityType());
Assert.assertEquals(3, auditLogList.get(0).getAuditLogRecords().size());
for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
if (auditLogRecord.getFieldName().equalsIgnoreCase("Explanation")) {
Assert.assertEquals("-", auditLogRecord.getOldValue());
Assert.assertEquals("Withdraw", auditLogRecord.getNewValue());
} else if (auditLogRecord.getFieldName().equalsIgnoreCase("Status")) {
Assert.assertEquals("Active in Good Standing", auditLogRecord.getOldValue());
Assert.assertEquals("Closed- Rescheduled", auditLogRecord.getNewValue());
}
}
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class NotesAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
clearActionForm(form);
NotesActionForm notesActionForm = (NotesActionForm) form;
Integer accountId = Integer.valueOf(notesActionForm.getAccountId());
AccountBO account = new AccountBusinessService().getAccount(accountId);
if (account.isLoanAccount() || account.isGroupLoanAccount()) {
LoanAccountDetailDto loanAccountDto = this.loanAccountServiceFacade.retrieveLoanAccountNotes(accountId.longValue());
if (account.isLoanAccount()) {
notesActionForm.setAccountTypeId(AccountTypes.LOAN_ACCOUNT.getValue().toString());
} else {
notesActionForm.setAccountTypeId(AccountTypes.GROUP_LOAN_ACCOUNT.getValue().toString());
}
notesActionForm.setGlobalAccountNum(loanAccountDto.getGlobalAccountNum());
notesActionForm.setPrdOfferingName(loanAccountDto.getProductDetails().getPrdOfferingName());
} else if (account.isSavingsAccount()) {
SavingsAccountDetailDto savingsAccountDto = this.savingsServiceFacade.retrieveSavingsAccountNotes(accountId.longValue());
notesActionForm.setPrdOfferingName(savingsAccountDto.getProductDetails().getProductDetails().getName());
notesActionForm.setAccountTypeId(AccountTypes.SAVINGS_ACCOUNT.getValue().toString());
notesActionForm.setGlobalAccountNum(savingsAccountDto.getGlobalAccountNum());
}
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class NotesAction method create.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
NotesActionForm notesActionForm = (NotesActionForm) form;
UserContext uc = getUserContext(request);
CreateAccountNote accountNote = (CreateAccountNote) SessionUtils.getAttribute("model.accountNote", request);
AccountBO accountBO = new AccountBusinessService().getAccount(accountNote.getAccountId());
if (accountBO.getPersonnel() != null) {
checkPermissionForAddingNotes(accountBO.getType(), null, uc, accountBO.getOffice().getOfficeId(), accountBO.getPersonnel().getPersonnelId());
} else {
checkPermissionForAddingNotes(accountBO.getType(), null, uc, accountBO.getOffice().getOfficeId(), uc.getId());
}
if (accountBO.isSavingsAccount()) {
this.savingsServiceFacade.addNote(accountNote);
} else {
this.loanAccountServiceFacade.addNote(accountNote);
}
return mapping.findForward(chooseForward(Short.valueOf(notesActionForm.getAccountTypeId())));
}
use of org.mifos.accounts.business.AccountBO in project head by mifos.
the class NotesAction method getSearchResult.
@Override
protected QueryResult getSearchResult(ActionForm form) throws Exception {
Integer accountId = Integer.valueOf(((NotesActionForm) form).getAccountId());
AccountBO account = new AccountBusinessService().getAccount(accountId);
if (account.isSavingsAccount()) {
NoteSearchDto noteSearchDto = new NoteSearchDto(accountId, Integer.valueOf(1), Integer.valueOf(10));
NotesSearchResultsDto noteResults = this.savingsServiceFacade.retrievePagedNotesDto(noteSearchDto);
}
return legacyAccountDao.getAllAccountNotes(accountId);
}
Aggregations