Пример #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);
  }
Пример #2
0
 private CustomerView getCusomerView(final CustomerBO customer) {
   CustomerView customerView = new CustomerView();
   customerView.setCustomerId(customer.getCustomerId());
   customerView.setCustomerLevelId(customer.getCustomerLevel().getId());
   customerView.setCustomerSearchId(customer.getSearchId());
   customerView.setDisplayName(customer.getDisplayName());
   customerView.setGlobalCustNum(customer.getGlobalCustNum());
   customerView.setOfficeId(customer.getOffice().getOfficeId());
   if (null != customer.getParentCustomer()) {
     customerView.setParentCustomerId(customer.getParentCustomer().getCustomerId());
   }
   customerView.setPersonnelId(customer.getPersonnel().getPersonnelId());
   customerView.setStatusId(customer.getCustomerStatus().getId());
   return customerView;
 }
Пример #3
0
  @SuppressWarnings("unchecked")
  public void testSuccessfulGet() throws Exception {

    MeetingBO meeting =
        TestObjectFactory.createMeeting(
            TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group =
        TestObjectFactory.createWeeklyFeeGroupUnderCenter(
            "Group", CustomerStatus.GROUP_ACTIVE, center);
    client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
    account = getLoanAccount(group, meeting);

    // Using utility method that uses builder pattern to create savings accounts - TestObjectFactory
    // was creating
    // installments for all savings accounts (which is wrong)
    TestCollectionSheetRetrieveSavingsAccountsUtils collectionSheetRetrieveSavingsAccountsUtils =
        new TestCollectionSheetRetrieveSavingsAccountsUtils();
    centerSavingsAccount =
        collectionSheetRetrieveSavingsAccountsUtils.createSavingsAccount(
            center, "cemi", "120.00", false, false);
    groupSavingsAccount =
        collectionSheetRetrieveSavingsAccountsUtils.createSavingsAccount(
            group, "gvcg", "180.00", true, false);
    clientSavingsAccount =
        collectionSheetRetrieveSavingsAccountsUtils.createSavingsAccount(
            client, "clm", "222.00", false, false);

    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    CustomerView customerView = new CustomerView();
    customerView.setCustomerId(center.getCustomerId());
    customerView.setCustomerSearchId(center.getSearchId());
    customerView.setCustomerLevelId(center.getCustomerLevel().getId());

    final OfficeView officeView =
        new OfficeView(
            Short.valueOf("3"), "", OfficeLevel.BRANCHOFFICE, "levelNameKey", Integer.valueOf(-1));
    final PersonnelView personnelView = new PersonnelView(Short.valueOf("3"), "");

    SessionUtils.setAttribute(
        CollectionSheetEntryConstants.COLLECTION_SHEET_ENTRY_FORM_DTO,
        createCollectionSheetDto(customerView, officeView, personnelView),
        request);

    SessionUtils.setCollectionAttribute(
        CollectionSheetEntryConstants.PAYMENT_TYPES_LIST,
        Arrays.asList(getPaymentTypeView()),
        request);
    SessionUtils.setAttribute(
        CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, Constants.YES, request);

    setMasterListInSession(center.getCustomerId());
    setRequestPathInfo("/collectionsheetaction.do");
    addRequestParameter("method", "get");
    addRequestParameter("officeId", "3");
    addRequestParameter("loanOfficerId", "3");
    addRequestParameter("paymentId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);

    Calendar meetinDateCalendar = new GregorianCalendar();
    meetinDateCalendar.setTime(getMeetingDates(meeting));
    int year = meetinDateCalendar.get(Calendar.YEAR);
    int month = meetinDateCalendar.get(Calendar.MONTH);
    int day = meetinDateCalendar.get(Calendar.DAY_OF_MONTH);
    meetinDateCalendar = new GregorianCalendar(year, month, day);
    SessionUtils.setAttribute(
        "LastMeetingDate", new java.sql.Date(meetinDateCalendar.getTimeInMillis()), request);
    addRequestDateParameter("transactionDate", day + "/" + (month + 1) + "/" + year);
    addRequestParameter("receiptId", "1");
    addRequestDateParameter("receiptDate", "20/03/2006");
    addRequestParameter("customerId", String.valueOf(center.getCustomerId().intValue()));
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward("get_success");
  }