Search in sources :

Example 1 with TransactionHistoryDto

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());
}
Also used : PaymentData(org.mifos.accounts.util.helpers.PaymentData) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) TransactionHistoryDto(org.mifos.dto.screen.TransactionHistoryDto) Date(java.sql.Date) Test(org.junit.Test)

Example 2 with TransactionHistoryDto

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;
}
Also used : FinancialTransactionBO(org.mifos.accounts.financial.business.FinancialTransactionBO) ArrayList(java.util.ArrayList) TransactionHistoryDto(org.mifos.dto.screen.TransactionHistoryDto)

Example 3 with TransactionHistoryDto

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());
    }
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) PaymentData(org.mifos.accounts.util.helpers.PaymentData) AccountBO(org.mifos.accounts.business.AccountBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TransactionHistoryDto(org.mifos.dto.screen.TransactionHistoryDto) Date(java.util.Date) Test(org.junit.Test)

Example 4 with TransactionHistoryDto

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());
    }
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) TransactionHistoryDto(org.mifos.dto.screen.TransactionHistoryDto) Session(org.hibernate.Session) Test(org.junit.Test)

Example 5 with TransactionHistoryDto

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);
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) ServiceException(org.mifos.framework.exceptions.ServiceException) AccountException(org.mifos.accounts.exceptions.AccountException) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) MifosUser(org.mifos.security.MifosUser) TransactionHistoryDto(org.mifos.dto.screen.TransactionHistoryDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

TransactionHistoryDto (org.mifos.dto.screen.TransactionHistoryDto)8 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)4 AccountBO (org.mifos.accounts.business.AccountBO)3 PaymentData (org.mifos.accounts.util.helpers.PaymentData)3 Date (java.sql.Date)2 FinancialTransactionBO (org.mifos.accounts.financial.business.FinancialTransactionBO)2 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)2 IncludePage (freemarker.ext.servlet.IncludePage)1 Date (java.util.Date)1 List (java.util.List)1 Session (org.hibernate.Session)1 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)1 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 AccountingConfigurationDto (org.mifos.config.servicefacade.dto.AccountingConfigurationDto)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 CustomerBO (org.mifos.customers.business.CustomerBO)1 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)1