use of org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto in project head by mifos.
the class CollectionSheetServiceFacadeWebTier method generateCollectionSheetEntryGridView.
@Override
public CollectionSheetEntryGridDto generateCollectionSheetEntryGridView(final CollectionSheetFormEnteredDataDto formEnteredDataDto, final MifosCurrency currency) {
final CollectionSheetDto collectionSheet = getCollectionSheet(formEnteredDataDto.getCustomer().getCustomerId(), DateUtils.getLocalDateFromDate(formEnteredDataDto.getMeetingDate()));
try {
final List<CustomValueListElementDto> attendanceTypesList = legacyMasterDao.getCustomValueList(MasterConstants.ATTENDENCETYPES, "org.mifos.application.master.business.CustomerAttendanceType", "attendanceId").getCustomValueListElements();
final CollectionSheetEntryGridDto translatedGridView = collectionSheetTranslator.toLegacyDto(collectionSheet, formEnteredDataDto, attendanceTypesList, currency);
return translatedGridView;
} catch (SystemException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto in project head by mifos.
the class CollectionSheetServiceFacadeWebTier method previewCollectionSheetEntry.
@Override
public CollectionSheetEntryGridDto previewCollectionSheetEntry(final CollectionSheetEntryGridDto previousCollectionSheetEntryDto, final CollectionSheetDataDto dataView) {
CollectionSheetEntryGridDto newCollectionSheetEntryGridDto = null;
final CollectionSheetEntryDto bulkEntryParent = previousCollectionSheetEntryDto.getBulkEntryParent();
switch(CustomerLevel.getLevel(bulkEntryParent.getCustomerDetail().getCustomerLevelId())) {
case CENTER:
newCollectionSheetEntryGridDto = new CollectionSheetEntryGridDtoTranslator().translateAsCenter(previousCollectionSheetEntryDto, dataView);
break;
case GROUP:
case CLIENT:
newCollectionSheetEntryGridDto = new CollectionSheetEntryGridDtoTranslator().translateAsGroup(previousCollectionSheetEntryDto, dataView);
break;
}
return newCollectionSheetEntryGridDto;
}
use of org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto in project head by mifos.
the class CollectionSheetEntryAction method preview.
@TransactionDemarcate(joinToken = true)
public ActionForward preview(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
logTrackingInfo("preview", request, form);
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
final CollectionSheetEntryGridDto previousCollectionSheetEntryDto = retrieveFromRequestCollectionSheetEntryDto(request);
final CollectionSheetDataDto dataView = new CollectionSheetDataViewAssembler().toDto(request, previousCollectionSheetEntryDto);
final CollectionSheetEntryGridDto collectionSheetEntry = collectionSheetServiceFacade.previewCollectionSheetEntry(previousCollectionSheetEntryDto, dataView);
storeOnRequestCollectionSheetEntryDto(request, collectionSheetEntry);
final ActionErrors errors = new ActionErrors();
final ActionErrors errorsFromValidation = new CollectionSheetEntryDtoPostPreviewValidator().validate(collectionSheetEntry.getBulkEntryParent(), errors, getUserContext(request).getPreferredLocale());
if (errorsFromValidation.size() > 0) {
this.addErrors(request, errorsFromValidation);
return mapping.findForward(CollectionSheetEntryConstants.PREVIEWFAILURE);
}
return mapping.findForward(CollectionSheetEntryConstants.PREVIEWSUCCESS);
}
use of org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto 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.business.CollectionSheetEntryGridDto in project head by mifos.
the class BulkEntryActionStrutsTest method getFailureBulkEntry.
private CollectionSheetEntryGridDto getFailureBulkEntry() throws Exception {
Date startDate = new Date(System.currentTimeMillis());
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
LoanOfferingBO loanOffering1 = TestObjectFactory.createLoanOffering(startDate, meeting);
LoanOfferingBO loanOffering2 = TestObjectFactory.createLoanOffering("Loan2345", "313f", startDate, meeting);
groupAccount = TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering1);
clientAccount = TestObjectFactory.createLoanAccount("3243", client, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering2);
MeetingBO meetingIntCalc = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
MeetingBO meetingIntPost = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
SavingsOfferingBO savingsOffering = TestObjectFactory.createSavingsProduct("SavingPrd123c", "ased", ApplicableTo.GROUPS, startDate, PrdStatus.SAVINGS_ACTIVE, 300.0, RecommendedAmountUnit.PER_INDIVIDUAL, 1.2, 200.0, 200.0, SavingsType.VOLUNTARY, InterestCalcType.MINIMUM_BALANCE, meetingIntCalc, meetingIntPost);
SavingsOfferingBO savingsOffering1 = TestObjectFactory.createSavingsProduct("SavingPrd1we", "vbgr", ApplicableTo.GROUPS, startDate, PrdStatus.SAVINGS_ACTIVE, 300.0, RecommendedAmountUnit.PER_INDIVIDUAL, 1.2, 200.0, 200.0, SavingsType.VOLUNTARY, InterestCalcType.MINIMUM_BALANCE, meetingIntCalc, meetingIntPost);
centerSavingsAccount = TestObjectFactory.createSavingsAccount("432434", center, Short.valueOf("16"), startDate, savingsOffering);
clientSavingsAccount = TestObjectFactory.createSavingsAccount("432434", client, Short.valueOf("16"), startDate, savingsOffering1);
CollectionSheetEntryDto bulkEntryParent = new CollectionSheetEntryDto(getCusomerView(center), null);
bulkEntryParent.addSavingsAccountDetail(getSavingsAccountView(centerSavingsAccount));
bulkEntryParent.setCustomerAccountDetails(getCustomerAccountView(center));
CollectionSheetEntryDto bulkEntryChild = new CollectionSheetEntryDto(getCusomerView(group), null);
LoanAccountDto groupLoanAccountView = getLoanAccountView(groupAccount);
bulkEntryChild.addLoanAccountDetails(groupLoanAccountView);
bulkEntryChild.setCustomerAccountDetails(getCustomerAccountView(group));
CollectionSheetEntryDto bulkEntrySubChild = new CollectionSheetEntryDto(getCusomerView(client), null);
LoanAccountDto clientLoanAccountView = getLoanAccountView(clientAccount);
bulkEntrySubChild.addLoanAccountDetails(clientLoanAccountView);
bulkEntrySubChild.addSavingsAccountDetail(getSavingsAccountView(clientSavingsAccount));
bulkEntrySubChild.setCustomerAccountDetails(getCustomerAccountView(client));
bulkEntryChild.addChildNode(bulkEntrySubChild);
bulkEntryParent.addChildNode(bulkEntryChild);
bulkEntryChild.getLoanAccountDetails().get(0).setEnteredAmount("100.0");
bulkEntryChild.getLoanAccountDetails().get(0).setPrdOfferingId(groupLoanAccountView.getPrdOfferingId());
bulkEntrySubChild.getLoanAccountDetails().get(0).setEnteredAmount("100.0");
bulkEntrySubChild.getLoanAccountDetails().get(0).setPrdOfferingId(clientLoanAccountView.getPrdOfferingId());
ProductDto loanOfferingDto = new ProductDto(loanOffering1.getPrdOfferingId(), loanOffering1.getPrdOfferingShortName());
ProductDto loanOfferingDto2 = new ProductDto(loanOffering2.getPrdOfferingId(), loanOffering2.getPrdOfferingShortName());
List<ProductDto> loanProducts = Arrays.asList(loanOfferingDto, loanOfferingDto2);
ProductDto savingsOfferingDto = new ProductDto(savingsOffering.getPrdOfferingId(), savingsOffering.getPrdOfferingShortName());
List<ProductDto> savingsProducts = Arrays.asList(savingsOfferingDto);
final PersonnelDto loanOfficer = getPersonnelView(center.getPersonnel());
final OfficeDetailsDto officeDetailsDto = null;
final List<CustomValueListElementDto> attendanceTypesList = new ArrayList<CustomValueListElementDto>();
bulkEntryParent.setCountOfCustomers(3);
final CollectionSheetEntryGridDto bulkEntry = new CollectionSheetEntryGridDto(bulkEntryParent, loanOfficer, officeDetailsDto, getPaymentTypeView(), startDate, "324343242", startDate, loanProducts, savingsProducts, attendanceTypesList);
return bulkEntry;
}
Aggregations