예제 #1
0
  @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());

    this.customerService.createCenter(center, meeting, feesForCustomerAccount);

    return new CustomerDetailsDto(center.getCustomerId(), center.getGlobalCustNum());
  }
예제 #2
0
  @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);

    Boolean activeSurveys =
        Boolean.FALSE; // new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.CENTER);

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