use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.
the class CollectionSheetServiceFacadeWebTier method loadAllActiveBranchesAndSubsequentDataIfApplicable.
@Override
public CollectionSheetEntryFormDto loadAllActiveBranchesAndSubsequentDataIfApplicable(final UserContext userContext) {
final Short branchId = userContext.getBranchId();
final Short centerHierarchyExists = ClientRules.getCenterHierarchyExists() ? Constants.YES : Constants.NO;
List<OfficeDetailsDto> activeBranches = new ArrayList<OfficeDetailsDto>();
List<ListItem<Short>> paymentTypesDtoList = new ArrayList<ListItem<Short>>();
List<CustomerDto> customerList = new ArrayList<CustomerDto>();
List<PersonnelDto> loanOfficerList = new ArrayList<PersonnelDto>();
Short reloadFormAutomatically = Constants.YES;
final Short backDatedTransactionAllowed = Constants.NO;
try {
final List<PaymentTypeEntity> paymentTypesList = legacyMasterDao.findMasterDataEntitiesWithLocale(PaymentTypeEntity.class);
paymentTypesDtoList = convertToPaymentTypesListItemDto(paymentTypesList);
activeBranches = officePersistence.getActiveOffices(branchId);
if (activeBranches.size() == 1) {
loanOfficerList = legacyPersonnelDao.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId());
if (loanOfficerList.size() == 1) {
Short customerLevel;
if (centerHierarchyExists.equals(Constants.YES)) {
customerLevel = Short.valueOf(CustomerLevel.CENTER.getValue());
} else {
customerLevel = Short.valueOf(CustomerLevel.GROUP.getValue());
}
customerList = customerPersistence.getActiveParentList(loanOfficerList.get(0).getPersonnelId(), customerLevel, branchId);
if (customerList.size() == 1) {
reloadFormAutomatically = Constants.YES;
}
reloadFormAutomatically = Constants.NO;
}
}
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
return new CollectionSheetEntryFormDto(activeBranches, paymentTypesDtoList, loanOfficerList, customerList, reloadFormAutomatically, centerHierarchyExists, backDatedTransactionAllowed);
}
use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.
the class ClientServiceFacadeWebTier method retreiveClientDetailsForRemovalFromGroup.
@Override
public ClientRemovalFromGroupDto retreiveClientDetailsForRemovalFromGroup(String globalCustNum) {
try {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
client.updateDetails(userContext);
client.checkIfClientIsATitleHolder();
List<OfficeDetailsDto> activeBranches = this.officeDao.findActiveBranches(userContext.getBranchId());
boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
boolean isActive = client.isActive();
Short loanOfficerId = client.getPersonnel().getPersonnelId();
CenterCreation clientDetails = new CenterCreation(client.getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
List<PersonnelDto> loanOfficers = this.personnelDao.findActiveLoanOfficersForOffice(clientDetails);
return new ClientRemovalFromGroupDto(client.getGlobalCustNum(), isActive, isCenterHierarchyExists, loanOfficerId, loanOfficers, activeBranches);
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.
the class OfficeServiceFacadeWebTier method retrieveOfficeDetailsForEdit.
@Override
public OfficeDetailsForEdit retrieveOfficeDetailsForEdit(String officeLevel) {
List<OfficeDetailsDto> parents = new ArrayList<OfficeDetailsDto>();
if (StringUtils.isNotBlank(officeLevel)) {
parents = retrieveActiveParentOffices(Short.valueOf(officeLevel));
}
try {
List<OfficeDetailsDto> configuredOfficeLevels = new OfficePersistence().getActiveLevels();
for (OfficeDetailsDto officeDetailsDto : configuredOfficeLevels) {
String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey());
officeDetailsDto.setLevelName(levelName);
}
List<OfficeDetailsDto> statusList = new OfficePersistence().getStatusList();
for (OfficeDetailsDto officeDetailsDto : statusList) {
officeDetailsDto.setLevelName(ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey()));
}
return new OfficeDetailsForEdit(parents, statusList, configuredOfficeLevels);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.
the class OfficeServiceFacadeWebTier method retrieveActiveParentOffices.
@Override
public List<OfficeDetailsDto> retrieveActiveParentOffices(Short officeLevelId) {
OfficeLevel Level = OfficeLevel.getOfficeLevel(officeLevelId);
try {
List<OfficeDetailsDto> officeParents = new OfficePersistence().getActiveParents(Level);
for (OfficeDetailsDto officeDetailsDto : officeParents) {
String levelName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(officeDetailsDto.getLevelNameKey());
officeDetailsDto.setLevelName(levelName);
}
return officeParents;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.dto.domain.OfficeDetailsDto in project head by mifos.
the class OfficeListTag method getOfficeList.
String getOfficeList(Locale preferredUserLocale, List<OfficeDetailsDto> levels, String loggedInOfficeSearchId, List<OfficeHierarchyDto> officeHierarchy, List<OfficeBO> officesTillBranchOffice) {
String termForBranch = "";
String regional = "";
String subregional = "";
String area = "";
for (OfficeDetailsDto level : levels) {
if (level.getLevelId().equals(OfficeLevel.BRANCHOFFICE.getValue())) {
termForBranch = level.getLevelName();
} else if (level.getLevelId().equals(OfficeLevel.AREAOFFICE.getValue())) {
area = level.getLevelName();
} else if (level.getLevelId().equals(OfficeLevel.REGIONALOFFICE.getValue())) {
regional = level.getLevelName();
} else if (level.getLevelId().equals(OfficeLevel.SUBREGIONALOFFICE.getValue())) {
subregional = level.getLevelName();
}
}
XmlBuilder result = new XmlBuilder();
if (onlyBranchOffices != null) {
getBranchOffices(result, officeHierarchy, preferredUserLocale, loggedInOfficeSearchId, termForBranch);
} else {
getAboveBranches(result, officesTillBranchOffice, regional, subregional, area);
getBranchOffices(result, officeHierarchy, preferredUserLocale, loggedInOfficeSearchId, termForBranch);
}
return result.getOutput();
}
Aggregations