use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class LoanBOTestUtils method getLoanAccount.
private LoanBO getLoanAccount(final AccountState state, final Date startDate) {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
CenterBO center = TestObjectFactory.createWeeklyFeeCenter(this.getClass().getSimpleName() + " Center", meeting);
GroupBO group = TestObjectFactory.createWeeklyFeeGroupUnderCenter(this.getClass().getSimpleName() + " Group", CustomerStatus.GROUP_ACTIVE, center);
LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
final int disbursalType = 3;
return TestObjectFactory.createLoanAccountWithDisbursement("99999999999", group, state, startDate, loanOffering, disbursalType);
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class GroupServiceFacadeWebTier method createNewGroup.
@Override
public CustomerDetailsDto createNewGroup(GroupCreationDetail groupCreationDetail, MeetingDto meetingDto) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId());
userContext.setBranchGlobalNum(userOffice.getGlobalOfficeNum());
GroupBO group;
try {
List<AccountFeesEntity> feesForCustomerAccount = convertFeeViewsToAccountFeeEntities(groupCreationDetail.getFeesToApply());
PersonnelBO formedBy = this.personnelDao.findPersonnelById(groupCreationDetail.getLoanOfficerId());
Short officeId;
String groupName = groupCreationDetail.getDisplayName();
CustomerStatus customerStatus = CustomerStatus.fromInt(groupCreationDetail.getCustomerStatus());
String externalId = groupCreationDetail.getExternalId();
boolean trained = groupCreationDetail.isTrained();
DateTime trainedOn = groupCreationDetail.getTrainedOn();
DateTime mfiJoiningDate = groupCreationDetail.getMfiJoiningDate();
DateTime activationDate = groupCreationDetail.getActivationDate();
AddressDto dto = groupCreationDetail.getAddressDto();
Address address = null;
if (dto != null) {
address = new Address(dto.getLine1(), dto.getLine2(), dto.getLine3(), dto.getCity(), dto.getState(), dto.getCountry(), dto.getZip(), dto.getPhoneNumber());
}
MeetingBO groupMeeting = null;
if (meetingDto != null) {
groupMeeting = new MeetingFactory().create(meetingDto);
groupMeeting.setUserContext(userContext);
}
if (ClientRules.getCenterHierarchyExists()) {
CenterBO parentCustomer = this.customerDao.findCenterBySystemId(groupCreationDetail.getParentSystemId());
// loanOfficerId = parentCustomer.getPersonnel().getPersonnelId();
officeId = parentCustomer.getOffice().getOfficeId();
groupMeeting = parentCustomer.getCustomerMeetingValue();
group = GroupBO.createGroupWithCenterAsParent(userContext, groupName, formedBy, parentCustomer, address, externalId, trained, trainedOn, customerStatus, mfiJoiningDate, activationDate);
} else {
// create group without center as parent
Short loanOfficerId = groupCreationDetail.getLoanOfficerId() != null ? groupCreationDetail.getLoanOfficerId() : userContext.getId();
officeId = groupCreationDetail.getOfficeId();
OfficeBO office = this.officeDao.findOfficeById(groupCreationDetail.getOfficeId());
PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(loanOfficerId);
int numberOfCustomersInOfficeAlready = customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(officeId);
group = GroupBO.createGroupAsTopOfCustomerHierarchy(userContext, groupName, formedBy, groupMeeting, loanOfficer, office, address, externalId, trained, trainedOn, customerStatus, numberOfCustomersInOfficeAlready, mfiJoiningDate, activationDate);
}
try {
personnelDao.checkAccessPermission(userContext, group.getOfficeId(), group.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
this.customerService.createGroup(group, groupMeeting, feesForCustomerAccount);
return new CustomerDetailsDto(group.getCustomerId(), group.getGlobalCustNum());
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class GroupServiceFacadeWebTier method transferGroupToCenter.
@Override
public CustomerDetailDto transferGroupToCenter(String groupSystemId, String centerSystemId, Integer previousGroupVersionNo) {
try {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
CenterBO transferToCenter = this.customerDao.findCenterBySystemId(centerSystemId);
transferToCenter.updateDetails(userContext);
GroupBO group = this.customerDao.findGroupBySystemId(groupSystemId);
group.updateDetails(userContext);
checkVersionMismatch(previousGroupVersionNo, group.getVersionNo());
String groupGlobalCustNum = this.customerService.transferGroupTo(group, transferToCenter);
GroupBO transferedGroup = this.customerDao.findGroupBySystemId(groupGlobalCustNum);
return transferedGroup.toCustomerDetailDto();
} catch (ApplicationException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class DashboardServiceFacadeWebTier method centerBOtoDashboardDetailDtos.
private List<DashboardDetailDto> centerBOtoDashboardDetailDtos(List<CenterBO> centerBOList) {
List<DashboardDetailDto> groupDtoList = new ArrayList<DashboardDetailDto>();
DashboardDetailDto dto;
for (CenterBO centerBO : centerBOList) {
dto = new DashboardDetailDto();
dto.setGlobalNumber(centerBO.getGlobalCustNum());
dto.setState(centerBO.getCustomerStatus().getName());
dto.setUrl("viewCenterDetails.ftl?globalCustNum=" + dto.getGlobalNumber());
dto.setLoanOfficer(centerBO.getPersonnel().getDisplayName());
dto.setBalance(centerBO.getLoanBalance(Money.getDefaultCurrency()).toString());
dto.setDisplayName(centerBO.getDisplayName());
groupDtoList.add(dto);
}
return groupDtoList;
}
use of org.mifos.customers.center.business.CenterBO in project head by mifos.
the class CenterCustAction method manage.
// NOTE edit center details
@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
CenterCustActionForm actionForm = (CenterCustActionForm) form;
actionForm.clearActionFormFields();
CenterBO center = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
final Integer centerId = center.getCustomerId();
center = this.customerDao.findCenterBySystemId(center.getGlobalCustNum());
SessionUtils.setAttribute(Constants.BUSINESS_KEY, null, request);
CenterDto centerDto = this.centerServiceFacade.retrieveCenterDetailsForUpdate(centerId);
actionForm.setLoanOfficerId(centerDto.getLoanOfficerIdAsString());
actionForm.setCustomerId(centerDto.getCustomerIdAsString());
actionForm.setGlobalCustNum(centerDto.getGlobalCustNum());
actionForm.setExternalId(centerDto.getExternalId());
actionForm.setMfiJoiningDate(centerDto.getMfiJoiningDateAsString());
actionForm.setMfiJoiningDate(centerDto.getMfiJoiningDate().getDayOfMonth(), centerDto.getMfiJoiningDate().getMonthOfYear(), centerDto.getMfiJoiningDate().getYear());
actionForm.setAddress(center.getAddress());
actionForm.setCustomerPositions(centerDto.getCustomerPositionViews());
actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
SessionUtils.setAttribute(Constants.BUSINESS_KEY, center, request);
SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, centerDto.getActiveLoanOfficersForBranch(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.POSITIONS, centerDto.getCustomerPositionViews(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.CLIENT_LIST, centerDto.getClientList(), request);
return mapping.findForward(ActionForwards.manage_success.toString());
}
Aggregations