Search in sources :

Example 26 with OfficeDetailsDto

use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.

the class OffAction method loadParent.

@TransactionDemarcate(joinToken = true)
public ActionForward loadParent(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm offActionForm = (OffActionForm) form;
    String officeLevel = request.getParameter("officeLevel");
    if (StringUtils.isNotBlank(officeLevel)) {
        offActionForm.setOfficeLevel(officeLevel);
        List<OfficeDetailsDto> parents = this.officeServiceFacade.retrieveActiveParentOffices(Short.valueOf(officeLevel));
        OfficeDto office = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
        if (offActionForm.getInput() != null && offActionForm.getInput().equals("edit") && office != null) {
            for (int i = 0; i < parents.size(); i++) {
                OfficeDetailsDto view = parents.get(i);
                if (view.getOfficeId().equals(office.getOfficeId())) {
                    parents.remove(view);
                }
            }
        }
        SessionUtils.setCollectionAttribute(OfficeConstants.PARENTS, parents, request);
    }
    if (offActionForm.getInput() != null && offActionForm.getInput().equals("edit")) {
        return mapping.findForward(ActionForwards.edit_success.toString());
    }
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 27 with OfficeDetailsDto

use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.

the class OffAction method edit.

@TransactionDemarcate(joinToken = true)
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm offActionForm = (OffActionForm) form;
    OfficeDto sessionOffice = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
    OfficeBO office = this.officeDao.findOfficeById(sessionOffice.getOfficeId());
    checkVersionMismatch(sessionOffice.getVersionNum(), office.getVersionNo());
    String officeLevel = request.getParameter("officeLevel");
    OfficeDetailsForEdit officeDetailsForEdit = this.officeServiceFacade.retrieveOfficeDetailsForEdit(officeLevel);
    if (StringUtils.isNotBlank(officeLevel)) {
        offActionForm.setOfficeLevel(officeLevel);
        List<OfficeDetailsDto> parents = this.officeServiceFacade.retrieveActiveParentOffices(Short.valueOf(officeLevel));
        OfficeDto office1 = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
        if (offActionForm.getInput() != null && offActionForm.getInput().equals("edit") && office1 != null) {
            for (int i = 0; i < parents.size(); i++) {
                OfficeDetailsDto view = parents.get(i);
                if (view.getOfficeId().equals(office1.getOfficeId())) {
                    parents.remove(view);
                }
            }
        }
        SessionUtils.setCollectionAttribute(OfficeConstants.PARENTS, parents, request);
    }
    offActionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    SessionUtils.setCollectionAttribute(OfficeConstants.OFFICELEVELLIST, officeDetailsForEdit.getConfiguredOfficeLevels(), request);
    SessionUtils.setCollectionAttribute(OfficeConstants.OFFICESTATUSLIST, officeDetailsForEdit.getStatusList(), request);
    List<CustomFieldDefinitionEntity> customFieldDefs = new ArrayList<CustomFieldDefinitionEntity>();
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, customFieldDefs, request);
    return mapping.findForward(ActionForwards.edit_success.toString());
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) OfficeDetailsForEdit(org.mifos.dto.screen.OfficeDetailsForEdit) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) OfficeBO(org.mifos.customers.office.business.OfficeBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 28 with OfficeDetailsDto

use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.

the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithLatestMeetingDateWhenBackDatedTransactionsAreAllowed.

@Test
public void shouldPopulateDtoWithLatestMeetingDateWhenBackDatedTransactionsAreAllowed() throws Exception {
    // setup
    final Integer customerId = Integer.valueOf(3);
    final CustomerDto customer1 = new CustomerDto();
    customer1.setCustomerId(customerId);
    final List<CustomerDto> customers = Arrays.asList(customer1);
    final Date expectedMeetingDateAsJavaDate = new DateTime().plusDays(2).toDate();
    final java.sql.Date expectedMeetingDateAsSqlDate = new java.sql.Date(expectedMeetingDateAsJavaDate.getTime());
    final CollectionSheetEntryFormDto previousCollectionSheetFormDto = new CollectionSheetEntryFormDto(new ArrayList<OfficeDetailsDto>(), new ArrayList<ListItem<Short>>(), new ArrayList<PersonnelDto>(), customers, Constants.YES, Constants.YES, Constants.YES);
    when(customerPersistence.getLastMeetingDateForCustomer(customerId)).thenReturn(expectedMeetingDateAsSqlDate);
    // NOTE: Backdated transactions is checked through static
    // AccountingRules so can't set up for now
    // exercise test
    CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadMeetingDateForCustomer(customerId, previousCollectionSheetFormDto);
    // verification
    assertThat(formDto.getMeetingDate(), is(expectedMeetingDateAsJavaDate));
    // assert rest of data comes from previousDto
    assertThat(formDto.getCustomerList(), is(customers));
}
Also used : CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 29 with OfficeDetailsDto

use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.

the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithValueToForceFormNotToBeRefreshedWhenAllDropdownListDataIsFetched.

@Test
public void shouldPopulateDtoWithValueToForceFormNotToBeRefreshedWhenAllDropdownListDataIsFetched() throws Exception {
    // setup
    final Short branchId = userContext.getBranchId();
    final Short levelId = OfficeLevel.BRANCHOFFICE.getValue();
    OfficeDetailsDto officeStub1 = new OfficeDetailsDto(branchId, "branchName1", levelId, Integer.valueOf(1));
    List<OfficeDetailsDto> onlyOneActiveBranch = Arrays.asList(officeStub1);
    final PersonnelDto loanOfficer1 = new PersonnelDto(Short.valueOf("1"), "LoanOfficer1");
    List<PersonnelDto> onlyOneActiveLoanOfficer = Arrays.asList(loanOfficer1);
    final CustomerDto customer1 = new CustomerDto();
    List<CustomerDto> customers = Arrays.asList(customer1);
    // stub interaction with DAO/Persistence layer.
    when(officePersistence.getActiveOffices(branchId)).thenReturn(onlyOneActiveBranch);
    when(personnelPersistence.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId())).thenReturn(onlyOneActiveLoanOfficer);
    when(customerPersistence.getActiveParentList(loanOfficer1.getPersonnelId(), CustomerLevel.CENTER.getValue(), branchId)).thenReturn(customers);
    // exercise test
    CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadAllActiveBranchesAndSubsequentDataIfApplicable(userContext);
    // verification
    assertThat(formDto.getReloadFormAutomatically(), is(Constants.NO));
}
Also used : CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Test(org.junit.Test)

Example 30 with OfficeDetailsDto

use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.

the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithCustomersWhenOnlyOneActiveBranchAndOneLoanOfficerExists.

@Ignore
@Test
public void shouldPopulateDtoWithCustomersWhenOnlyOneActiveBranchAndOneLoanOfficerExists() throws Exception {
    // setup
    final Short branchId = userContext.getBranchId();
    final Short levelId = OfficeLevel.BRANCHOFFICE.getValue();
    OfficeDetailsDto officeStub1 = new OfficeDetailsDto(branchId, "branchName1", levelId, Integer.valueOf(1));
    List<OfficeDetailsDto> onlyOneActiveBranch = Arrays.asList(officeStub1);
    final PersonnelDto loanOfficer1 = new PersonnelDto(Short.valueOf("1"), "LoanOfficer1");
    List<PersonnelDto> onlyOneActiveLoanOfficer = Arrays.asList(loanOfficer1);
    final CustomerDto customer1 = new CustomerDto();
    List<CustomerDto> customers = Arrays.asList(customer1);
    // stub interaction with DAO/Persistence layer.
    when(officePersistence.getActiveOffices(branchId)).thenReturn(onlyOneActiveBranch);
    when(personnelPersistence.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId())).thenReturn(onlyOneActiveLoanOfficer);
    when(customerPersistence.getActiveParentList(loanOfficer1.getPersonnelId(), CustomerLevel.CENTER.getValue(), branchId)).thenReturn(customers);
    // exercise test
    CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadAllActiveBranchesAndSubsequentDataIfApplicable(userContext);
    // verification
    assertThat(formDto.getCustomerList(), is(customers));
}
Also used : CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)37 PersonnelDto (org.mifos.dto.domain.PersonnelDto)19 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)13 CustomerDto (org.mifos.dto.domain.CustomerDto)10 Date (java.util.Date)7 OfficeBO (org.mifos.customers.office.business.OfficeBO)7 UserContext (org.mifos.security.util.UserContext)6 CollectionSheetEntryGridDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)5 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)5 OfficeDto (org.mifos.dto.domain.OfficeDto)5 CollectionSheetEntryDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryDto)4 MessageLookup (org.mifos.application.master.MessageLookup)4 MeetingBO (org.mifos.application.meeting.business.MeetingBO)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 MifosUser (org.mifos.security.MifosUser)4 LoanAccountDto (org.mifos.accounts.loan.util.helpers.LoanAccountDto)3 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)3 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)3 CustomValueListElementDto (org.mifos.application.master.business.CustomValueListElementDto)3