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