Ejemplo n.º 1
0
  @Override
  public CenterDto retrieveCenterDetailsForUpdate(Integer centerId) {

    MifosUser user =
        (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);

    CustomerBO center = customerDao.findCustomerById(centerId);

    Short officeId = center.getOffice().getOfficeId();
    String searchId = center.getSearchId();
    Short loanOfficerId = extractLoanOfficerId(center);

    CenterCreation centerCreation =
        new CenterCreation(
            officeId,
            userContext.getId(),
            userContext.getLevelId(),
            userContext.getPreferredLocale());
    List<PersonnelDto> activeLoanOfficersForBranch =
        personnelDao.findActiveLoanOfficersForOffice(centerCreation);

    List<CustomerDto> customerList =
        customerDao.findClientsThatAreNotCancelledOrClosed(searchId, officeId);

    List<CustomerPositionDto> customerPositionDtos =
        generateCustomerPositionViews(center, userContext.getLocaleId());

    DateTime mfiJoiningDate = new DateTime();
    String mfiJoiningDateAsString = "";
    if (center.getMfiJoiningDate() != null) {
      mfiJoiningDate = new DateTime(center.getMfiJoiningDate());
      mfiJoiningDateAsString =
          DateUtils.getUserLocaleDate(
              userContext.getPreferredLocale(), center.getMfiJoiningDate().toString());
    }

    AddressDto address = null;
    if (center.getAddress() != null) {
      address = Address.toDto(center.getAddress());
    }
    return new CenterDto(
        loanOfficerId,
        center.getCustomerId(),
        center.getGlobalCustNum(),
        mfiJoiningDate,
        mfiJoiningDateAsString,
        center.getExternalId(),
        address,
        customerPositionDtos,
        customerList,
        activeLoanOfficersForBranch,
        true);
  }
Ejemplo n.º 2
0
  @Override
  public CenterFormCreationDto retrieveCenterFormCreationData(CenterCreation centerCreation) {

    MifosUser user =
        (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);

    List<PersonnelDto> activeLoanOfficersForBranch =
        personnelDao.findActiveLoanOfficersForOffice(centerCreation);

    List<FeeBO> fees = customerDao.retrieveFeesApplicableToCenters();
    CustomerApplicableFeesDto applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);

    List<ApplicableAccountFeeDto> applicableDefaultAccountFees =
        new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getDefaultFees()) {
      applicableDefaultAccountFees.add(
          new ApplicableAccountFeeDto(
              fee.getFeeIdValue().intValue(),
              fee.getFeeName(),
              fee.getAmount(),
              fee.isRemoved(),
              fee.isWeekly(),
              fee.isMonthly(),
              fee.isPeriodic(),
              fee.getFeeSchedule()));
    }

    List<ApplicableAccountFeeDto> applicableDefaultAdditionalFees =
        new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getAdditionalFees()) {
      applicableDefaultAdditionalFees.add(
          new ApplicableAccountFeeDto(
              fee.getFeeIdValue().intValue(),
              fee.getFeeName(),
              fee.getAmount(),
              fee.isRemoved(),
              fee.isWeekly(),
              fee.isMonthly(),
              fee.isPeriodic(),
              fee.getFeeSchedule()));
    }

    return new CenterFormCreationDto(
        activeLoanOfficersForBranch, applicableDefaultAdditionalFees, applicableDefaultAccountFees);
  }