Search in sources :

Example 6 with CenterCustActionForm

use of org.mifos.customers.center.struts.actionforms.CenterCustActionForm in project head by mifos.

the class CenterActionStrutsTest method testLoad.

@Test
public void testLoad() throws Exception {
    setRequestPathInfo("/centerCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "3");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.load_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(CustomerConstants.LOAN_OFFICER_LIST, request));
    //        Assert.assertNotNull(SessionUtils.getAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, request));
    CenterCustActionForm actionForm = (CenterCustActionForm) request.getSession().getAttribute("centerCustActionForm");
    String currentDate = DateUtils.getCurrentDate(TestUtils.ukLocale());
    SimpleDateFormat retrievedFormat = new SimpleDateFormat(dateFormat);
    SimpleDateFormat localFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, TestUtils.ukLocale());
    Date curDate = localFormat.parse(currentDate);
    Date retrievedDate = retrievedFormat.parse(actionForm.getMfiJoiningDate());
    Assert.assertEquals(curDate, retrievedDate);
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 7 with CenterCustActionForm

use of org.mifos.customers.center.struts.actionforms.CenterCustActionForm in project head by mifos.

the class CenterActionStrutsTest method testSuccessfulCreate.

@Test
public void testSuccessfulCreate() throws Exception {
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    AmountFeeBO monthlyPeriodicFeeForFirstClients = new FeeBuilder().appliesToCenterOnly().withFeeAmount("200.0").withName("PeriodicAmountFee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(monthlyPeriodicFeeForFirstClients);
    setRequestPathInfo("/centerCustAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("officeId", "1");
    actionPerform();
    SessionUtils.setAttribute(CustomerConstants.CUSTOMER_MEETING, weeklyMeeting, request);
    List<ApplicableAccountFeeDto> feeList = retrieveAdditionalFeesFromSession();
    ApplicableAccountFeeDto fee = feeList.get(0);
    setRequestPathInfo("/centerCustAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("displayName", "center");
    addRequestParameter("loanOfficerId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    addRequestParameter("selectedFee[0].feeId", fee.getFeeId().toString());
    addRequestParameter("selectedFee[0].amount", fee.getAmount());
    actionPerform();
    verifyForward(ActionForwards.preview_success.toString());
    setRequestPathInfo("/centerCustAction.do");
    addRequestParameter("method", "create");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.create_success.toString());
    CenterCustActionForm actionForm = (CenterCustActionForm) request.getSession().getAttribute("centerCustActionForm");
    center = TestObjectFactory.getCenter(actionForm.getCustomerIdAsInt());
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) MeetingBO(org.mifos.application.meeting.business.MeetingBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 8 with CenterCustActionForm

use of org.mifos.customers.center.struts.actionforms.CenterCustActionForm in project head by mifos.

the class CenterCustAction method update.

// NOTE - manage->preview->update
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CenterBO centerFromSession = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    CenterCustActionForm actionForm = (CenterCustActionForm) form;
    AddressDto dto = null;
    if (actionForm.getAddress() != null) {
        dto = Address.toDto(actionForm.getAddress());
    }
    CenterUpdate centerUpdate = new CenterUpdate(centerFromSession.getCustomerId(), actionForm.getDisplayName(), centerFromSession.getVersionNo(), actionForm.getLoanOfficerIdValue(), actionForm.getExternalId(), actionForm.getMfiJoiningDate(), dto, actionForm.getCustomFields(), actionForm.getCustomerPositions());
    try {
        this.centerServiceFacade.updateCenter(centerUpdate);
    } catch (BusinessRuleException e) {
        throw new ApplicationException(e.getMessageKey(), e);
    }
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) CenterUpdate(org.mifos.dto.domain.CenterUpdate) CenterBO(org.mifos.customers.center.business.CenterBO) AddressDto(org.mifos.dto.domain.AddressDto) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 9 with CenterCustActionForm

use of org.mifos.customers.center.struts.actionforms.CenterCustActionForm in project head by mifos.

the class CenterCustAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CenterInformationDto centerInformationDto;
    try {
        centerInformationDto = this.centerServiceFacade.getCenterInformationDto(((CenterCustActionForm) form).getGlobalCustNum());
    } catch (MifosRuntimeException e) {
        if (e.getCause() instanceof ApplicationException) {
            throw (ApplicationException) e.getCause();
        }
        throw e;
    }
    SessionUtils.removeThenSetAttribute("centerInformationDto", centerInformationDto, request);
    // John W - 'BusinessKey' attribute used by breadcrumb but is not in associated jsp
    CenterBO centerBO = (CenterBO) this.customerDao.findCustomerById(centerInformationDto.getCenterDisplay().getCustomerId());
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, centerBO, request);
    setCurrentPageUrl(request, centerBO);
    setQuestionGroupInstances(request, centerBO);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) CenterBO(org.mifos.customers.center.business.CenterBO) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 10 with CenterCustActionForm

use of org.mifos.customers.center.struts.actionforms.CenterCustActionForm in project head by mifos.

the class CenterCustAction method searchTransfer.

@TransactionDemarcate(joinToken = true)
public ActionForward searchTransfer(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    cleanUpSearch(request);
    CenterCustActionForm actionForm = (CenterCustActionForm) form;
    String searchString = actionForm.getSearchString();
    CustomerSearch searchResult = this.customerServiceFacade.search(searchString);
    addSeachValues(searchString, searchResult.getOfficeId(), searchResult.getOfficeName(), request);
    SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, searchResult.getSearchResult(), request);
    return mapping.findForward(ActionForwards.transferSearch_success.toString());
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) CustomerSearch(org.mifos.application.servicefacade.CustomerSearch) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

CenterCustActionForm (org.mifos.customers.center.struts.actionforms.CenterCustActionForm)11 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)8 Test (org.junit.Test)3 CenterBO (org.mifos.customers.center.business.CenterBO)3 ApplicationException (org.mifos.framework.exceptions.ApplicationException)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 CustomerSearch (org.mifos.application.servicefacade.CustomerSearch)2 AddressDto (org.mifos.dto.domain.AddressDto)2 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ActionForward (org.apache.struts.action.ActionForward)1 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)1 ActionForwards (org.mifos.application.util.helpers.ActionForwards)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 FeeBuilder (org.mifos.domain.builders.FeeBuilder)1