use of org.mifos.dto.screen.TransactionHistoryDto in project head by mifos.
the class AccountBOIntegrationTest method testGetTransactionHistoryViewByOtherUser.
@Test
public void testGetTransactionHistoryViewByOtherUser() throws Exception {
Date currentDate = new Date(System.currentTimeMillis());
LoanBO loan = groupLoan;
loan.setUserContext(TestUtils.makeUser());
List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>();
accntActionDates.addAll(loan.getAccountActionDates());
PersonnelBO personnel = legacyPersonnelDao.getPersonnel(Short.valueOf("2"));
PaymentData accountPaymentDataView = TestObjectFactory.getLoanAccountPaymentData(accntActionDates, TestUtils.createMoney(100), null, personnel, "receiptNum", Short.valueOf("1"), currentDate, currentDate);
IntegrationTestObjectMother.applyAccountPayment(loan, accountPaymentDataView);
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
loan.setUserContext(TestUtils.makeUser());
List<TransactionHistoryDto> trxnHistlist = loan.getTransactionHistoryView();
Assert.assertNotNull("Account TrxnHistoryView list object should not be null", trxnHistlist);
Assert.assertTrue("Account TrxnHistoryView list object Size should be greater than zero", trxnHistlist.size() > 0);
for (TransactionHistoryDto transactionHistoryDto : trxnHistlist) {
Assert.assertEquals(transactionHistoryDto.getPostedBy(), personnel.getDisplayName());
}
StaticHibernateUtil.flushSession();
groupLoan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
}
use of org.mifos.dto.screen.TransactionHistoryDto in project head by mifos.
the class AccountBO method getTransactionHistoryView.
public List<TransactionHistoryDto> getTransactionHistoryView() {
List<TransactionHistoryDto> trxnHistory = new ArrayList<TransactionHistoryDto>();
for (AccountPaymentEntity accountPayment : getAccountPayments()) {
for (AccountTrxnEntity accountTrxn : accountPayment.getAccountTrxns()) {
for (FinancialTransactionBO financialTrxn : accountTrxn.getFinancialTransactions()) {
TransactionHistoryDto transactionHistory = new TransactionHistoryDto();
setFinancialEntries(financialTrxn, transactionHistory);
setAccountingEntries(accountTrxn, transactionHistory);
trxnHistory.add(transactionHistory);
}
}
}
return trxnHistory;
}
use of org.mifos.dto.screen.TransactionHistoryDto 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.dto.screen.TransactionHistoryDto in project head by mifos.
the class CloseLoanActionStrutsTest method testRescheduleLoan.
@Test
public void testRescheduleLoan() throws Exception {
loanBO = getLoanAccount();
loanBO.approve(legacyPersonnelDao.getPersonnel(PersonnelConstants.TEST_USER), "approved", currentDate.toLocalDate());
addRequestParameter("recordLoanOfficerId", "1");
addRequestParameter("accountId", loanBO.getAccountId().toString());
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loanBO, request);
request.getSession().setAttribute(Constants.USER_CONTEXT_KEY, userContext);
addRequestParameter("notes", "reschedule");
addRequestParameter("newStatusId", "8");
addRequestParameter("input", "loan");
addRequestParameter("method", "update");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
actionPerform();
verifyForward(ActionForwards.loan_detail_page.toString());
CustomerAccountBO closedAccount = group.getCustomerAccount();
Assert.assertEquals(AccountState.CUSTOMER_ACCOUNT_ACTIVE, closedAccount.getState());
Session session = StaticHibernateUtil.getSessionTL();
// session.beginTransaction();
loanBO = (LoanBO) session.get(LoanBO.class, loanBO.getAccountId());
List<TransactionHistoryDto> history = loanBO.getTransactionHistoryView();
for (TransactionHistoryDto entry : history) {
Assert.assertEquals(AccountConstants.LOAN_RESCHEDULED, entry.getType());
}
}
use of org.mifos.dto.screen.TransactionHistoryDto in project head by mifos.
the class CenterServiceFacadeWebTier method retrieveAccountTransactionHistory.
@Override
public List<TransactionHistoryDto> retrieveAccountTransactionHistory(String globalAccountNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().findBySystemId(globalAccountNum);
CustomerBO customerBO = account.getCustomer();
account.updateDetails(userContext);
personnelDao.checkAccessPermission(userContext, customerBO.getOfficeId(), customerBO.getLoanOfficerId());
List<TransactionHistoryDto> transactionHistories = account.getTransactionHistoryView();
for (TransactionHistoryDto transactionHistoryDto : transactionHistories) {
transactionHistoryDto.setUserPrefferedPostedDate(DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), transactionHistoryDto.getPostedDate().toString()));
transactionHistoryDto.setUserPrefferedTransactionDate(DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), transactionHistoryDto.getTransactionDate().toString()));
}
return transactionHistories;
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
}
Aggregations