Search in sources :

Example 1 with BulkEntryActionForm

use of org.mifos.application.collectionsheet.struts.actionforms.BulkEntryActionForm in project head by mifos.

the class CollectionSheetEntryAction method create.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws PageExpiredException {
    logTrackingInfo("create", request, form);
    final BulkEntryActionForm collectionSheetActionForm = (BulkEntryActionForm) form;
    final CollectionSheetEntryGridDto previousCollectionSheetEntryDto = retrieveFromRequestCollectionSheetEntryDto(request);
    final CollectionSheetEntryDecomposedDto decomposedViews = new CollectionSheetEntryViewTranslator().toDecomposedView(previousCollectionSheetEntryDto.getBulkEntryParent());
    logBeforeSave(request, collectionSheetActionForm, previousCollectionSheetEntryDto);
    final long beforeSaveData = System.currentTimeMillis();
    final CollectionSheetErrorsDto collectionSheetErrors = this.collectionSheetServiceFacade.saveCollectionSheet(previousCollectionSheetEntryDto, getUserContext(request).getId());
    logAfterSave(request, decomposedViews, System.currentTimeMillis() - beforeSaveData, collectionSheetErrors.isDatabaseError());
    storeOnRequestErrorAndCollectionSheetData(request, decomposedViews, collectionSheetErrors);
    request.setAttribute(CollectionSheetEntryConstants.CENTER, previousCollectionSheetEntryDto.getBulkEntryParent().getCustomerDetail().getDisplayName());
    setErrorMessagesIfErrorsExist(request, collectionSheetErrors);
    /*
         * Visit CREATESUCCESS if user entered data that breaks business rules, such as withdrawing more than the total
         * amount in a savings account. Is this intended? It seems like we wouldn't want to even call
         * saveCollectionSheet if business rules were violated in this manner.
         *
         * JohnW: Yes it is intended. The collection sheet logic 'does what it can' in terms of updating accounts. It
         * allows for accounts with no issues to be persisted while building up error lists (warning lists really) for
         * accounts that have problems (including breaking business rules) preventing them being persisted.
         *
         * So, in summary, what happens is, although "saveCollectionSheet" is called, part of the responsibility of the
         * "saveCollectionSheet" process is to identify for each account if rules are broken. Only accounts that 'pass'
         * are saved, the others are identified so that a warning message can be shown.
         */
    return mapping.findForward(CollectionSheetEntryConstants.CREATESUCCESS);
}
Also used : BulkEntryActionForm(org.mifos.application.collectionsheet.struts.actionforms.BulkEntryActionForm) CollectionSheetEntryDecomposedDto(org.mifos.application.servicefacade.CollectionSheetEntryDecomposedDto) CollectionSheetErrorsDto(org.mifos.application.servicefacade.CollectionSheetErrorsDto) CollectionSheetEntryViewTranslator(org.mifos.application.servicefacade.CollectionSheetEntryViewTranslator) CollectionSheetEntryGridDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with BulkEntryActionForm

use of org.mifos.application.collectionsheet.struts.actionforms.BulkEntryActionForm in project head by mifos.

the class CollectionSheetEntryAction method getLastMeetingDateForCustomer.

/**
     * This method retrieves the last meeting date for the chosen customer. This meeting date is put as the default date
     * for the transaction date in the search criteria
     *
     */
@TransactionDemarcate(joinToken = true)
public ActionForward getLastMeetingDateForCustomer(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    final BulkEntryActionForm actionForm = (BulkEntryActionForm) form;
    final Integer customerId = Integer.valueOf(actionForm.getCustomerId());
    final CollectionSheetEntryFormDto previousCollectionSheetEntryFormDto = retrieveFromRequestCollectionSheetEntryFormDto(request);
    final CollectionSheetEntryFormDto latestCollectionSheetEntryFormDto = collectionSheetServiceFacade.loadMeetingDateForCustomer(customerId, previousCollectionSheetEntryFormDto);
    actionForm.setTransactionDate(latestCollectionSheetEntryFormDto.getMeetingDate());
    storeOnRequestCollectionSheetEntryFormDto(request, latestCollectionSheetEntryFormDto);
    return mapping.findForward(CollectionSheetEntryConstants.LOADSUCCESS);
}
Also used : BulkEntryActionForm(org.mifos.application.collectionsheet.struts.actionforms.BulkEntryActionForm) CollectionSheetEntryFormDto(org.mifos.application.servicefacade.CollectionSheetEntryFormDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with BulkEntryActionForm

use of org.mifos.application.collectionsheet.struts.actionforms.BulkEntryActionForm in project head by mifos.

the class BulkEntryActionStrutsTest method testGetLastMeetingDateForCustomer.

@Test
public void testGetLastMeetingDateForCustomer() throws Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    center = TestObjectFactory.createWeeklyFeeCenter("Center_Active", meeting);
    setRequestPathInfo("/collectionsheetaction.do");
    addRequestParameter("method", "getLastMeetingDateForCustomer");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("officeId", "3");
    addRequestParameter("loanOfficerId", "1");
    addRequestParameter("customerId", String.valueOf(center.getCustomerId().intValue()));
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(CollectionSheetEntryConstants.COLLECTION_SHEET_ENTRY_FORM_DTO, createDefaultCollectionSheetDto(), request);
    Short officeId = center.getOfficeId();
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward("load_success");
    if (AccountingRules.isBackDatedTxnAllowed()) {
        Assert.assertEquals("The value for isBackDated Trxn Allowed", SessionUtils.getAttribute(CollectionSheetEntryConstants.ISBACKDATEDTRXNALLOWED, request), Constants.YES);
        Assert.assertEquals(new java.sql.Date(DateUtils.getDateWithoutTimeStamp(getMeetingDates(officeId, meeting).getTime()).getTime()).toString(), SessionUtils.getAttribute("LastMeetingDate", request).toString());
        Assert.assertEquals(new java.util.Date(DateUtils.getDateWithoutTimeStamp(getMeetingDates(officeId, meeting).getTime()).getTime()), DateUtils.getDate(((BulkEntryActionForm) request.getSession().getAttribute(CollectionSheetEntryConstants.BULKENTRYACTIONFORM)).getTransactionDate()));
    } else {
        Assert.assertEquals("The value for isBackDated Trxn Allowed", SessionUtils.getAttribute(CollectionSheetEntryConstants.ISBACKDATEDTRXNALLOWED, request), Constants.NO);
        Assert.assertEquals(new java.sql.Date(DateUtils.getDateWithoutTimeStamp(getMeetingDates(officeId, meeting).getTime()).getTime()).toString(), SessionUtils.getAttribute("LastMeetingDate", request).toString());
        Assert.assertEquals(DateUtils.getUserLocaleDate(getUserLocale(request), new java.sql.Date(DateUtils.getCurrentDateWithoutTimeStamp().getTime()).toString()), ((BulkEntryActionForm) request.getSession().getAttribute(CollectionSheetEntryConstants.BULKENTRYACTIONFORM)).getTransactionDate());
    }
}
Also used : BulkEntryActionForm(org.mifos.application.collectionsheet.struts.actionforms.BulkEntryActionForm) MeetingBO(org.mifos.application.meeting.business.MeetingBO) Date(java.util.Date) Date(java.util.Date) Test(org.junit.Test)

Example 4 with BulkEntryActionForm

use of org.mifos.application.collectionsheet.struts.actionforms.BulkEntryActionForm in project head by mifos.

the class CollectionSheetServiceFacadeWebTierTest method setupSUTAndInjectMocksAsDependencies.

@Before
public void setupSUTAndInjectMocksAsDependencies() {
    userContext = new UserContext();
    userContext.setBranchId(Short.valueOf("1"));
    userContext.setId(Short.valueOf("1"));
    userContext.setLevel(PersonnelLevel.LOAN_OFFICER);
    collectionSheetForm = new BulkEntryActionForm();
    collectionSheetForm.setOfficeId("2");
    collectionSheetForm.setLoanOfficerId("2");
    collectionSheetForm.setCustomerId("2");
    collectionSheetForm.setPaymentId("2");
    collectionSheetServiceFacadeWebTier = new CollectionSheetServiceFacadeWebTier(officePersistence, legacyMasterDao, personnelPersistence, customerPersistence, collectionSheetService, collectionSheetTranslator, monthClosingServiceFacade, null, null);
}
Also used : BulkEntryActionForm(org.mifos.application.collectionsheet.struts.actionforms.BulkEntryActionForm) UserContext(org.mifos.security.util.UserContext) Before(org.junit.Before)

Example 5 with BulkEntryActionForm

use of org.mifos.application.collectionsheet.struts.actionforms.BulkEntryActionForm in project head by mifos.

the class CollectionSheetEntryAction method loadLoanOfficers.

@TransactionDemarcate(joinToken = true)
public ActionForward loadLoanOfficers(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    final BulkEntryActionForm bulkEntryActionForm = (BulkEntryActionForm) form;
    final Short officeId = Short.valueOf(bulkEntryActionForm.getOfficeId());
    final UserContext userContext = getUserContext(request);
    final CollectionSheetEntryFormDto previousCollectionSheetEntryFormDto = collectionSheetServiceFacade.loadAllActiveBranchesAndSubsequentDataIfApplicable(userContext);
    final CollectionSheetEntryFormDto latestCollectionSheetEntryFormDto = collectionSheetServiceFacade.loadLoanOfficersForBranch(officeId, userContext, previousCollectionSheetEntryFormDto);
    // add reference data for view
    storeOnRequestCollectionSheetEntryFormDto(request, latestCollectionSheetEntryFormDto);
    return mapping.findForward(CollectionSheetEntryConstants.LOADSUCCESS);
}
Also used : BulkEntryActionForm(org.mifos.application.collectionsheet.struts.actionforms.BulkEntryActionForm) UserContext(org.mifos.security.util.UserContext) CollectionSheetEntryFormDto(org.mifos.application.servicefacade.CollectionSheetEntryFormDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

BulkEntryActionForm (org.mifos.application.collectionsheet.struts.actionforms.BulkEntryActionForm)8 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)5 CollectionSheetEntryFormDto (org.mifos.application.servicefacade.CollectionSheetEntryFormDto)4 CollectionSheetEntryGridDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)2 UserContext (org.mifos.security.util.UserContext)2 Date (java.util.Date)1 Before (org.junit.Before)1 Test (org.junit.Test)1 MifosCurrency (org.mifos.application.master.business.MifosCurrency)1 MeetingBO (org.mifos.application.meeting.business.MeetingBO)1 CollectionSheetEntryDecomposedDto (org.mifos.application.servicefacade.CollectionSheetEntryDecomposedDto)1 CollectionSheetEntryFormDtoDecorator (org.mifos.application.servicefacade.CollectionSheetEntryFormDtoDecorator)1 CollectionSheetEntryViewTranslator (org.mifos.application.servicefacade.CollectionSheetEntryViewTranslator)1 CollectionSheetErrorsDto (org.mifos.application.servicefacade.CollectionSheetErrorsDto)1 CollectionSheetFormEnteredDataDto (org.mifos.application.servicefacade.CollectionSheetFormEnteredDataDto)1 FormEnteredDataAssembler (org.mifos.application.servicefacade.FormEnteredDataAssembler)1