Search in sources :

Example 1 with CollectionSheetEntryGridDto

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);
    }
}
Also used : SystemException(org.mifos.framework.exceptions.SystemException) CustomValueListElementDto(org.mifos.application.master.business.CustomValueListElementDto) CollectionSheetEntryGridDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with CollectionSheetEntryGridDto

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;
}
Also used : CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto) CollectionSheetEntryGridDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)

Example 3 with CollectionSheetEntryGridDto

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);
}
Also used : CollectionSheetDataDto(org.mifos.application.collectionsheet.util.helpers.CollectionSheetDataDto) CollectionSheetDataViewAssembler(org.mifos.application.servicefacade.CollectionSheetDataViewAssembler) ActionErrors(org.apache.struts.action.ActionErrors) CollectionSheetEntryGridDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with CollectionSheetEntryGridDto

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);
}
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 5 with CollectionSheetEntryGridDto

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;
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomValueListElementDto(org.mifos.application.master.business.CustomValueListElementDto) ArrayList(java.util.ArrayList) LoanAccountDto(org.mifos.accounts.loan.util.helpers.LoanAccountDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Date(java.util.Date) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto) LoanAccountsProductDto(org.mifos.accounts.loan.util.helpers.LoanAccountsProductDto) ProductDto(org.mifos.application.servicefacade.ProductDto) CollectionSheetEntryGridDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)

Aggregations

CollectionSheetEntryGridDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)19 Test (org.junit.Test)9 CollectionSheetEntryDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryDto)6 CustomValueListElementDto (org.mifos.application.master.business.CustomValueListElementDto)6 Date (java.util.Date)5 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)5 PersonnelDto (org.mifos.dto.domain.PersonnelDto)5 ArrayList (java.util.ArrayList)4 ProductDto (org.mifos.application.servicefacade.ProductDto)4 LoanAccountDto (org.mifos.accounts.loan.util.helpers.LoanAccountDto)3 LoanAccountsProductDto (org.mifos.accounts.loan.util.helpers.LoanAccountsProductDto)3 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)3 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)3 SavingsAccountDto (org.mifos.accounts.savings.util.helpers.SavingsAccountDto)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)3 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2 LoanBO (org.mifos.accounts.loan.business.LoanBO)2 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)2