예제 #1
0
  @SuppressWarnings("unchecked")
  public void testLoadCustomers() throws PageExpiredException {
    MeetingBO meeting =
        TestObjectFactory.createMeeting(
            TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    center = TestObjectFactory.createWeeklyFeeCenter("Center_Active", meeting);

    setRequestPathInfo("/collectionsheetaction.do");
    addRequestParameter("method", "loadCustomerList");
    addRequestParameter("officeId", "3");
    addRequestParameter("loanOfficerId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);

    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(
        CollectionSheetEntryConstants.COLLECTION_SHEET_ENTRY_FORM_DTO,
        createDefaultCollectionSheetDto(),
        request);

    actionPerform();
    verifyForward("load_success");
    List<CustomerView> parentCustomerList =
        (List<CustomerView>)
            SessionUtils.getAttribute(CollectionSheetEntryConstants.CUSTOMERSLIST, request);

    Assert.assertEquals(1, parentCustomerList.size());
    Assert.assertEquals(
        "The value for isCenter Hierarchy Exists",
        SessionUtils.getAttribute(CollectionSheetEntryConstants.ISCENTERHIERARCHYEXISTS, request),
        Constants.YES);
  }
예제 #2
0
  private CollectionSheetEntryGridDto getFailureBulkEntry() throws Exception {
    Date startDate = new Date(System.currentTimeMillis());

    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);
    LoanOfferingBO loanOffering1 = TestObjectFactory.createLoanOffering(startDate, meeting);
    LoanOfferingBO loanOffering2 =
        TestObjectFactory.createLoanOffering("Loan2345", "313f", startDate, meeting);
    groupAccount =
        TestObjectFactory.createLoanAccount(
            "42423142341",
            group,
            AccountState.LOAN_ACTIVE_IN_GOOD_STANDING,
            startDate,
            loanOffering1);
    clientAccount =
        TestObjectFactory.createLoanAccount(
            "3243", client, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering2);
    MeetingBO meetingIntCalc =
        TestObjectFactory.createMeeting(
            TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    MeetingBO meetingIntPost =
        TestObjectFactory.createMeeting(
            TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    SavingsOfferingBO savingsOffering =
        TestObjectFactory.createSavingsProduct(
            "SavingPrd123c",
            "ased",
            ApplicableTo.GROUPS,
            startDate,
            PrdStatus.SAVINGS_ACTIVE,
            300.0,
            RecommendedAmountUnit.PER_INDIVIDUAL,
            1.2,
            200.0,
            200.0,
            SavingsType.VOLUNTARY,
            InterestCalcType.MINIMUM_BALANCE,
            meetingIntCalc,
            meetingIntPost);
    SavingsOfferingBO savingsOffering1 =
        TestObjectFactory.createSavingsProduct(
            "SavingPrd1we",
            "vbgr",
            ApplicableTo.GROUPS,
            startDate,
            PrdStatus.SAVINGS_ACTIVE,
            300.0,
            RecommendedAmountUnit.PER_INDIVIDUAL,
            1.2,
            200.0,
            200.0,
            SavingsType.VOLUNTARY,
            InterestCalcType.MINIMUM_BALANCE,
            meetingIntCalc,
            meetingIntPost);
    centerSavingsAccount =
        TestObjectFactory.createSavingsAccount(
            "432434", center, Short.valueOf("16"), startDate, savingsOffering);
    clientSavingsAccount =
        TestObjectFactory.createSavingsAccount(
            "432434", client, Short.valueOf("16"), startDate, savingsOffering1);

    CollectionSheetEntryView bulkEntryParent =
        new CollectionSheetEntryView(getCusomerView(center), null);
    bulkEntryParent.addSavingsAccountDetail(getSavingsAccountView(centerSavingsAccount));
    bulkEntryParent.setCustomerAccountDetails(getCustomerAccountView(center));

    CollectionSheetEntryView bulkEntryChild =
        new CollectionSheetEntryView(getCusomerView(group), null);
    LoanAccountView groupLoanAccountView = getLoanAccountView(groupAccount);
    bulkEntryChild.addLoanAccountDetails(groupLoanAccountView);
    bulkEntryChild.setCustomerAccountDetails(getCustomerAccountView(group));
    CollectionSheetEntryView bulkEntrySubChild =
        new CollectionSheetEntryView(getCusomerView(client), null);
    LoanAccountView clientLoanAccountView = getLoanAccountView(clientAccount);
    bulkEntrySubChild.addLoanAccountDetails(clientLoanAccountView);
    bulkEntrySubChild.addSavingsAccountDetail(getSavingsAccountView(clientSavingsAccount));
    bulkEntrySubChild.setCustomerAccountDetails(getCustomerAccountView(client));

    bulkEntryChild.addChildNode(bulkEntrySubChild);
    bulkEntryParent.addChildNode(bulkEntryChild);
    bulkEntryChild.getLoanAccountDetails().get(0).setEnteredAmount("100.0");
    bulkEntryChild
        .getLoanAccountDetails()
        .get(0)
        .setPrdOfferingId(groupLoanAccountView.getPrdOfferingId());
    bulkEntrySubChild.getLoanAccountDetails().get(0).setEnteredAmount("100.0");
    bulkEntrySubChild
        .getLoanAccountDetails()
        .get(0)
        .setPrdOfferingId(clientLoanAccountView.getPrdOfferingId());

    ProductDto loanOfferingDto =
        new ProductDto(loanOffering1.getPrdOfferingId(), loanOffering1.getPrdOfferingShortName());
    ProductDto loanOfferingDto2 =
        new ProductDto(loanOffering2.getPrdOfferingId(), loanOffering2.getPrdOfferingShortName());

    List<ProductDto> loanProducts = Arrays.asList(loanOfferingDto, loanOfferingDto2);

    ProductDto savingsOfferingDto =
        new ProductDto(
            savingsOffering.getPrdOfferingId(), savingsOffering.getPrdOfferingShortName());
    List<ProductDto> savingsProducts = Arrays.asList(savingsOfferingDto);

    final PersonnelView loanOfficer = getPersonnelView(center.getPersonnel());
    final OfficeView officeView = null;
    final List<CustomValueListElement> attendanceTypesList =
        new ArrayList<CustomValueListElement>();

    bulkEntryParent.setCountOfCustomers(3);
    final CollectionSheetEntryGridDto bulkEntry =
        new CollectionSheetEntryGridDto(
            bulkEntryParent,
            loanOfficer,
            officeView,
            getPaymentTypeView(),
            startDate,
            "324343242",
            startDate,
            loanProducts,
            savingsProducts,
            attendanceTypesList);

    return bulkEntry;
  }
예제 #3
0
  private CollectionSheetEntryGridDto getSuccessfulBulkEntry() throws Exception {

    MeetingBO meeting =
        TestObjectFactory.createMeeting(
            TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    Date startDate = new Date(System.currentTimeMillis());
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group =
        TestObjectFactory.createWeeklyFeeGroupUnderCenter(
            "Group", CustomerStatus.GROUP_ACTIVE, center);
    client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
    LoanOfferingBO loanOffering1 = TestObjectFactory.createLoanOffering(startDate, meeting);
    LoanOfferingBO loanOffering2 =
        TestObjectFactory.createLoanOffering(
            "Loan2345",
            "313f",
            ApplicableTo.CLIENTS,
            startDate,
            PrdStatus.LOAN_ACTIVE,
            300.0,
            1.2,
            3,
            InterestType.FLAT,
            meeting);
    groupAccount =
        TestObjectFactory.createLoanAccount(
            "42423142341",
            group,
            AccountState.LOAN_ACTIVE_IN_GOOD_STANDING,
            startDate,
            loanOffering1);
    clientAccount = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1, loanOffering2);
    Date currentDate = new Date(System.currentTimeMillis());
    // 2010-01-18: JohnW - This use of TestObjectFactory.createSavingsProduct used to break a number
    // of
    // business rules.
    // E.g all the savings products were set up as applicable for Groups and "per individual" which
    // is wrong for
    // centers and clients. In the case of the client being wrongly set up as "Per Individual" it
    // now triggers save
    // collection sheet validation (which checks that the account associated with the client marked
    // "per individual"
    // matches its parent group or center)
    // Also, when creating the center savings accounts (which is effectively "per individual") and
    // the group savings
    // account which is "per individual" the saving_schedule entries for the client are not written
    // (they are in the
    // production code).
    //
    // Considered using/updating the savingsProductBuilder functionality but that doesn't deal with
    // the
    // "per individual" aspect either (update: it does, but still problem with builder creating
    // installments).
    // Decided not to try and fix it up (good deal of effort involved) but rather change the
    // TestObjectFactory.createSavingsProduct to accept a RecommendedAmountUnit parameter.
    // Unfortunately it wouldn't allow a null parameter (which is valid for centers and clients)
    // through so, where
    // necessary, I picked a value that worked for the test but was wrong in a business rule sense
    // (just as its
    // always been).
    // So the savings product test data doesn't adhere to business rules but all tests pass here and
    // in others
    // tests.
    SavingsOfferingBO savingsOffering1 =
        TestObjectFactory.createSavingsProduct(
            "SavingPrd1", "ased", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
    SavingsOfferingBO savingsOffering2 =
        TestObjectFactory.createSavingsProduct(
            "SavingPrd2", "cvdf", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
    SavingsOfferingBO savingsOffering3 =
        TestObjectFactory.createSavingsProduct(
            "SavingPrd3", "zxsd", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);

    centerSavingsAccount =
        TestObjectFactory.createSavingsAccount(
            "43244334", center, Short.valueOf("16"), startDate, savingsOffering1);
    groupSavingsAccount =
        TestObjectFactory.createSavingsAccount(
            "43234434", group, Short.valueOf("16"), startDate, savingsOffering2);
    clientSavingsAccount =
        TestObjectFactory.createSavingsAccount(
            "43245434", client, Short.valueOf("16"), startDate, savingsOffering3);

    CollectionSheetEntryView bulkEntryParent =
        new CollectionSheetEntryView(getCusomerView(center), null);
    SavingsAccountView centerSavingsAccountView = getSavingsAccountView(centerSavingsAccount);
    centerSavingsAccountView.setDepositAmountEntered("100");
    centerSavingsAccountView.setWithDrawalAmountEntered("10");
    bulkEntryParent.addSavingsAccountDetail(centerSavingsAccountView);
    bulkEntryParent.setCustomerAccountDetails(getCustomerAccountView(center));

    CollectionSheetEntryView bulkEntryChild =
        new CollectionSheetEntryView(getCusomerView(group), null);
    LoanAccountView groupLoanAccountView = getLoanAccountView(groupAccount);
    SavingsAccountView groupSavingsAccountView = getSavingsAccountView(groupSavingsAccount);
    groupSavingsAccountView.setDepositAmountEntered("100");
    groupSavingsAccountView.setWithDrawalAmountEntered("10");
    bulkEntryChild.addLoanAccountDetails(groupLoanAccountView);
    bulkEntryChild.addSavingsAccountDetail(groupSavingsAccountView);
    bulkEntryChild.setCustomerAccountDetails(getCustomerAccountView(group));

    CollectionSheetEntryView bulkEntrySubChild =
        new CollectionSheetEntryView(getCusomerView(client), null);
    LoanAccountView clientLoanAccountView = getLoanAccountView(clientAccount);
    clientLoanAccountView.setAmountPaidAtDisbursement(0.0);
    SavingsAccountView clientSavingsAccountView = getSavingsAccountView(clientSavingsAccount);
    clientSavingsAccountView.setDepositAmountEntered("100");
    clientSavingsAccountView.setWithDrawalAmountEntered("10");
    bulkEntrySubChild.addLoanAccountDetails(clientLoanAccountView);
    bulkEntrySubChild.setAttendence(new Short("2"));
    bulkEntrySubChild.addSavingsAccountDetail(clientSavingsAccountView);
    bulkEntrySubChild.setCustomerAccountDetails(getCustomerAccountView(client));

    bulkEntryChild.addChildNode(bulkEntrySubChild);
    bulkEntryParent.addChildNode(bulkEntryChild);

    LoanAccountsProductView childView = bulkEntryChild.getLoanAccountDetails().get(0);
    childView.setPrdOfferingId(groupLoanAccountView.getPrdOfferingId());
    childView.setEnteredAmount("100.0");
    LoanAccountsProductView subchildView = bulkEntrySubChild.getLoanAccountDetails().get(0);
    subchildView.setDisBursementAmountEntered(clientAccount.getLoanAmount().toString());
    subchildView.setPrdOfferingId(clientLoanAccountView.getPrdOfferingId());

    ProductDto loanOfferingDto =
        new ProductDto(loanOffering1.getPrdOfferingId(), loanOffering1.getPrdOfferingShortName());
    ProductDto loanOfferingDto2 =
        new ProductDto(loanOffering2.getPrdOfferingId(), loanOffering2.getPrdOfferingShortName());

    List<ProductDto> loanProducts = Arrays.asList(loanOfferingDto, loanOfferingDto2);

    ProductDto savingsOfferingDto =
        new ProductDto(
            savingsOffering1.getPrdOfferingId(), savingsOffering1.getPrdOfferingShortName());
    ProductDto savingsOfferingDto2 =
        new ProductDto(
            savingsOffering2.getPrdOfferingId(), savingsOffering2.getPrdOfferingShortName());
    ProductDto savingsOfferingDto3 =
        new ProductDto(
            savingsOffering3.getPrdOfferingId(), savingsOffering3.getPrdOfferingShortName());
    List<ProductDto> savingsProducts =
        Arrays.asList(savingsOfferingDto, savingsOfferingDto2, savingsOfferingDto3);

    final PersonnelView loanOfficer = getPersonnelView(center.getPersonnel());
    final OfficeView officeView = null;
    final List<CustomValueListElement> attendanceTypesList =
        new ArrayList<CustomValueListElement>();

    bulkEntryParent.setCountOfCustomers(3);
    final CollectionSheetEntryGridDto bulkEntry =
        new CollectionSheetEntryGridDto(
            bulkEntryParent,
            loanOfficer,
            officeView,
            getPaymentTypeView(),
            startDate,
            "324343242",
            startDate,
            loanProducts,
            savingsProducts,
            attendanceTypesList);

    return bulkEntry;
  }
예제 #4
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");
  }
예제 #5
0
  public void testGetLastMeetingDateForCustomer() throws Exception {
    MeetingBO meeting =
        TestObjectFactory.createMeeting(
            TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    center = TestObjectFactory.createWeeklyFeeCenter("Center_Active", meeting);
    setRequestPathInfo("/collectionsheetaction.do");
    addRequestParameter("method", "getLastMeetingDateForCustomer");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("officeId", "3");
    addRequestParameter("loanOfficerId", "1");
    addRequestParameter("customerId", String.valueOf(center.getCustomerId().intValue()));

    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(
        CollectionSheetEntryConstants.COLLECTION_SHEET_ENTRY_FORM_DTO,
        createDefaultCollectionSheetDto(),
        request);

    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward("load_success");

    if (AccountingRules.isBackDatedTxnAllowed()) {
      Assert.assertEquals(
          "The value for isBackDated Trxn Allowed",
          SessionUtils.getAttribute(CollectionSheetEntryConstants.ISBACKDATEDTRXNALLOWED, request),
          Constants.YES);
      Assert.assertEquals(
          new java.sql.Date(
                  DateUtils.getDateWithoutTimeStamp(getMeetingDates(meeting).getTime()).getTime())
              .toString(),
          SessionUtils.getAttribute("LastMeetingDate", request).toString());
      Assert.assertEquals(
          new java.util.Date(
              DateUtils.getDateWithoutTimeStamp(getMeetingDates(meeting).getTime()).getTime()),
          DateUtils.getDate(
              ((BulkEntryActionForm)
                      request
                          .getSession()
                          .getAttribute(CollectionSheetEntryConstants.BULKENTRYACTIONFORM))
                  .getTransactionDate()));
    } else {
      Assert.assertEquals(
          "The value for isBackDated Trxn Allowed",
          SessionUtils.getAttribute(CollectionSheetEntryConstants.ISBACKDATEDTRXNALLOWED, request),
          Constants.NO);
      Assert.assertEquals(
          new java.sql.Date(
                  DateUtils.getDateWithoutTimeStamp(getMeetingDates(meeting).getTime()).getTime())
              .toString(),
          SessionUtils.getAttribute("LastMeetingDate", request).toString());
      Assert.assertEquals(
          DateUtils.getUserLocaleDate(
              getUserLocale(request),
              new java.sql.Date(DateUtils.getCurrentDateWithoutTimeStamp().getTime()).toString()),
          ((BulkEntryActionForm)
                  request
                      .getSession()
                      .getAttribute(CollectionSheetEntryConstants.BULKENTRYACTIONFORM))
              .getTransactionDate());
    }
  }