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);
}
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);
}
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());
}
}
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);
}
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);
}
Aggregations