Search in sources :

Example 21 with AccountApplyPaymentActionForm

use of org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm in project head by mifos.

the class ApplyPaymentActionStrutsTest method xtestApplyPaymentAndRetrievalForLoanWhenStatusIsChanged.

public void xtestApplyPaymentAndRetrievalForLoanWhenStatusIsChanged() throws Exception {
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    accountBO = createLoanAccount();
    SessionUtils.setAttribute(Constants.ACCOUNT_VERSION, accountBO.getVersionNo(), request);
    SessionUtils.setAttribute(Constants.ACCOUNT_TYPE, AccountTypes.getAccountType(accountBO.getAccountType().getAccountTypeId()).name(), request);
    SessionUtils.setAttribute(Constants.ACCOUNT_ID, accountBO.getAccountId(), request);
    accountBO.setUserContext(TestObjectFactory.getContext());
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    accountBO.changeStatus(AccountState.LOAN_ACTIVE_IN_BAD_STANDING, null, "", loggedInUser);
    AccountApplyPaymentActionForm accountApplyPaymentActionForm = new AccountApplyPaymentActionForm();
    accountApplyPaymentActionForm.setAmount("212");
    request.getSession().setAttribute("applyPaymentActionForm", accountApplyPaymentActionForm);
    setRequestPathInfo("/applyPaymentAction");
    addRequestParameter("input", "loan");
    addRequestParameter("method", "applyPayment");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("accountId", accountBO.getAccountId().toString());
    addRequestParameter("receiptId", "101");
    String currentDate = DateUtils.makeDateAsSentFromBrowser();
    addRequestDateParameter("receiptDate", currentDate);
    addRequestDateParameter("transactionDate", currentDate);
    addRequestParameter("paymentTypeId", "1");
    actionPerform();
    verifyForward("loan_detail_page");
    center = TestObjectFactory.getCenter(center.getCustomerId());
    group = TestObjectFactory.getGroup(group.getCustomerId());
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
    Assert.assertEquals(new Money(getCurrency()), accountBO.getTotalPaymentDue());
    Assert.assertEquals(0, accountBO.getTotalInstallmentsDue().size());
    Assert.assertEquals(AccountStates.LOANACC_ACTIVEINGOODSTANDING, accountBO.getAccountState().getId().shortValue());
    setRequestPathInfo("/loanAccountAction");
    addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("method", "get");
    actionPerform();
    //LoanBO loan = (LoanBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    LoanBO loan = (LoanBO) StaticHibernateUtil.getSessionTL().load(LoanBO.class, accountBO.getAccountId());
    Assert.assertEquals(AccountStates.LOANACC_ACTIVEINGOODSTANDING, loan.getAccountState().getId().shortValue());
    Assert.assertNotNull(loan.getAccountState().getName());
    accountBO = (AccountBO) StaticHibernateUtil.getSessionTL().load(AccountBO.class, accountBO.getAccountId());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm)

Aggregations

AccountApplyPaymentActionForm (org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm)21 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)14 AccountPaymentDto (org.mifos.accounts.servicefacade.AccountPaymentDto)7 UserContext (org.mifos.security.util.UserContext)7 AccountReferenceDto (org.mifos.dto.domain.AccountReferenceDto)6 UserReferenceDto (org.mifos.dto.domain.UserReferenceDto)6 BigDecimal (java.math.BigDecimal)5 Test (org.junit.Test)4 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)4 ActionForward (org.apache.struts.action.ActionForward)3 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 AccountPaymentParametersDto (org.mifos.dto.domain.AccountPaymentParametersDto)3 PaymentTypeDto (org.mifos.dto.domain.PaymentTypeDto)3 CloseSession (org.mifos.framework.util.helpers.CloseSession)3 Money (org.mifos.framework.util.helpers.Money)3 GroupIndividualLoanDto (org.mifos.dto.domain.GroupIndividualLoanDto)2 Date (java.util.Date)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 AccountBO (org.mifos.accounts.business.AccountBO)1 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)1