use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class CenterServiceFacadeWebTier method getCenterInformationDto.
@Override
public CenterInformationDto getCenterInformationDto(String globalCustNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
CenterBO center = customerDao.findCenterBySystemId(globalCustNum);
if (center == null) {
throw new MifosRuntimeException("Center not found for globalCustNum" + globalCustNum);
}
try {
personnelDao.checkAccessPermission(userContext, center.getOfficeId(), center.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
CenterDisplayDto centerDisplay = customerDao.getCenterDisplayDto(center.getCustomerId(), userContext);
Integer centerId = center.getCustomerId();
String searchId = center.getSearchId();
Short branchId = centerDisplay.getBranchId();
CustomerAccountSummaryDto customerAccountSummary = customerDao.getCustomerAccountSummaryDto(centerId);
CenterPerformanceHistoryDto centerPerformanceHistory = customerDao.getCenterPerformanceHistory(searchId, branchId);
CustomerAddressDto centerAddress = customerDao.getCustomerAddressDto(center);
List<CustomerDetailDto> groups = customerDao.getGroupsOtherThanClosedAndCancelledForGroup(searchId, branchId);
List<CustomerNoteDto> recentCustomerNotes = customerDao.getRecentCustomerNoteDto(centerId);
List<CustomerPositionOtherDto> customerPositions = customerDao.getCustomerPositionDto(centerId, userContext);
List<SavingsDetailDto> savingsDetail = customerDao.getSavingsDetailDto(centerId, userContext);
CustomerMeetingDto customerMeeting = customerDao.getCustomerMeetingDto(center.getCustomerMeeting(), userContext);
List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(centerId);
List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.SAVINGS_ACCOUNT.getValue().intValue()) {
closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
}
}
//new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.CENTER);
Boolean activeSurveys = Boolean.FALSE;
List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
return new CenterInformationDto(centerDisplay, customerAccountSummary, centerPerformanceHistory, centerAddress, groups, recentCustomerNotes, customerPositions, savingsDetail, customerMeeting, activeSurveys, customerSurveys, customFields, closedSavingsAccounts);
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class CenterServiceFacadeWebTier method createNewCenter.
@Override
public CustomerDetailsDto createNewCenter(CenterCreationDetail createCenterDetail, MeetingDto meetingDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId());
userContext.setBranchGlobalNum(userOffice.getGlobalOfficeNum());
String centerName = createCenterDetail.getDisplayName();
String externalId = createCenterDetail.getExternalId();
AddressDto addressDto = createCenterDetail.getAddressDto();
Address centerAddress = new Address(addressDto.getLine1(), addressDto.getLine2(), addressDto.getLine3(), addressDto.getCity(), addressDto.getState(), addressDto.getCountry(), addressDto.getZip(), addressDto.getPhoneNumber());
PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(createCenterDetail.getLoanOfficerId());
OfficeBO centerOffice = this.officeDao.findOfficeById(createCenterDetail.getOfficeId());
List<AccountFeesEntity> feesForCustomerAccount = createAccountFeeEntities(createCenterDetail.getFeesToApply());
DateTime mfiJoiningDate = null;
if (createCenterDetail.getMfiJoiningDate() != null) {
mfiJoiningDate = createCenterDetail.getMfiJoiningDate().toDateMidnight().toDateTime();
}
MeetingBO meeting = new MeetingFactory().create(meetingDto);
meeting.setUserContext(userContext);
CenterBO center = CenterBO.createNew(userContext, centerName, mfiJoiningDate, meeting, loanOfficer, centerOffice, centerAddress, externalId, new DateMidnight().toDateTime());
try {
personnelDao.checkAccessPermission(userContext, center.getOfficeId(), center.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
this.customerService.createCenter(center, meeting, feesForCustomerAccount);
return new CustomerDetailsDto(center.getCustomerId(), center.getGlobalCustNum());
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class CenterPersistence method createCenter.
/**
* @deprecated use {@link CustomerDao#save(org.mifos.customers.business.CustomerBO)} with {@link CustomerBO} static
* factory methods.
*/
@Deprecated
public CenterBO createCenter(UserContext userContext, CenterTemplate template) throws Exception {
OfficeBO centerOffice = officePersistence.getOffice(template.getOfficeId());
PersonnelBO loanOfficer = legacyPersonnelDao.getPersonnel(template.getLoanOfficerId());
MeetingBO meeting = template.getMeeting();
CenterBO center = CenterBO.createNew(userContext, template.getDisplayName(), new DateTime(template.getMfiJoiningDate()), meeting, loanOfficer, centerOffice, template.getAddress(), template.getExternalId(), new DateMidnight().toDateTime());
CustomerDao customerDao = ApplicationContextProvider.getBean(CustomerDao.class);
try {
StaticHibernateUtil.startTransaction();
customerDao.save(center);
center.generateGlobalCustomerNumber();
customerDao.save(center);
StaticHibernateUtil.commitTransaction();
} catch (Exception e) {
StaticHibernateUtil.rollbackTransaction();
} finally {
StaticHibernateUtil.closeSession();
}
return center;
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class CenterPersistence method findBySystemId.
@SuppressWarnings("unchecked")
public CenterBO findBySystemId(String globalCustNum) throws PersistenceException {
Map<String, String> queryParameters = new HashMap<String, String>();
CenterBO center = null;
queryParameters.put("globalCustNum", globalCustNum);
List<CenterBO> queryResult = executeNamedQuery(NamedQueryConstants.GET_CENTER_BY_SYSTEMID, queryParameters);
if (null != queryResult && queryResult.size() > 0) {
center = queryResult.get(0);
}
return center;
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class GroupCustAction method load.
@TransactionDemarcate(saveToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
GroupCustActionForm actionForm = (GroupCustActionForm) form;
actionForm.cleanForm();
SessionUtils.removeAttribute(CustomerConstants.CUSTOMER_MEETING, request.getSession());
GroupCreation groupCreation = null;
boolean isCenterHierarchyExists = ClientRules.getCenterHierarchyExists();
if (isCenterHierarchyExists) {
String centerSystemId = actionForm.getCenterSystemId();
CenterBO center = this.customerDao.findCenterBySystemId(centerSystemId);
groupCreation = new GroupCreation(actionForm.getOfficeIdValue(), centerSystemId);
// inherit these settings from center/parent if center hierarchy is configured
actionForm.setParentCustomer(center);
actionForm.setOfficeId(center.getOfficeId().toString());
actionForm.setFormedByPersonnel(center.getLoanOfficerId().toString());
} else {
groupCreation = new GroupCreation(actionForm.getOfficeIdValue(), "");
}
GroupFormCreationDto groupFormCreationDto = this.groupServiceFacade.retrieveGroupFormCreationData(groupCreation);
actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
actionForm.setDefaultFees(groupFormCreationDto.getDefaultFees());
SessionUtils.setCollectionAttribute(CustomerConstants.ADDITIONAL_FEES_LIST, groupFormCreationDto.getAdditionalFees(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, groupFormCreationDto.getPersonnelList(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.FORMEDBY_LOAN_OFFICER_LIST, groupFormCreationDto.getFormedByPersonnel(), request);
SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, groupFormCreationDto.isCenterHierarchyExists(), request);
return mapping.findForward(ActionForwards.load_success.toString());
}
Aggregations