Search in sources :

Example 21 with PersonnelDto

use of org.mifos.dto.domain.PersonnelDto in project head by mifos.

the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithValueToForceFormNotToBeRefreshedWhenAllDropdownListDataIsFetched.

@Test
public void shouldPopulateDtoWithValueToForceFormNotToBeRefreshedWhenAllDropdownListDataIsFetched() throws Exception {
    // setup
    final Short branchId = userContext.getBranchId();
    final Short levelId = OfficeLevel.BRANCHOFFICE.getValue();
    OfficeDetailsDto officeStub1 = new OfficeDetailsDto(branchId, "branchName1", levelId, Integer.valueOf(1));
    List<OfficeDetailsDto> onlyOneActiveBranch = Arrays.asList(officeStub1);
    final PersonnelDto loanOfficer1 = new PersonnelDto(Short.valueOf("1"), "LoanOfficer1");
    List<PersonnelDto> onlyOneActiveLoanOfficer = Arrays.asList(loanOfficer1);
    final CustomerDto customer1 = new CustomerDto();
    List<CustomerDto> customers = Arrays.asList(customer1);
    // stub interaction with DAO/Persistence layer.
    when(officePersistence.getActiveOffices(branchId)).thenReturn(onlyOneActiveBranch);
    when(personnelPersistence.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId())).thenReturn(onlyOneActiveLoanOfficer);
    when(customerPersistence.getActiveParentList(loanOfficer1.getPersonnelId(), CustomerLevel.CENTER.getValue(), branchId)).thenReturn(customers);
    // exercise test
    CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadAllActiveBranchesAndSubsequentDataIfApplicable(userContext);
    // verification
    assertThat(formDto.getReloadFormAutomatically(), is(Constants.NO));
}
Also used : CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Test(org.junit.Test)

Example 22 with PersonnelDto

use of org.mifos.dto.domain.PersonnelDto in project head by mifos.

the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithCustomersWhenOnlyOneActiveBranchAndOneLoanOfficerExists.

@Ignore
@Test
public void shouldPopulateDtoWithCustomersWhenOnlyOneActiveBranchAndOneLoanOfficerExists() throws Exception {
    // setup
    final Short branchId = userContext.getBranchId();
    final Short levelId = OfficeLevel.BRANCHOFFICE.getValue();
    OfficeDetailsDto officeStub1 = new OfficeDetailsDto(branchId, "branchName1", levelId, Integer.valueOf(1));
    List<OfficeDetailsDto> onlyOneActiveBranch = Arrays.asList(officeStub1);
    final PersonnelDto loanOfficer1 = new PersonnelDto(Short.valueOf("1"), "LoanOfficer1");
    List<PersonnelDto> onlyOneActiveLoanOfficer = Arrays.asList(loanOfficer1);
    final CustomerDto customer1 = new CustomerDto();
    List<CustomerDto> customers = Arrays.asList(customer1);
    // stub interaction with DAO/Persistence layer.
    when(officePersistence.getActiveOffices(branchId)).thenReturn(onlyOneActiveBranch);
    when(personnelPersistence.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId())).thenReturn(onlyOneActiveLoanOfficer);
    when(customerPersistence.getActiveParentList(loanOfficer1.getPersonnelId(), CustomerLevel.CENTER.getValue(), branchId)).thenReturn(customers);
    // exercise test
    CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadAllActiveBranchesAndSubsequentDataIfApplicable(userContext);
    // verification
    assertThat(formDto.getCustomerList(), is(customers));
}
Also used : CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 23 with PersonnelDto

use of org.mifos.dto.domain.PersonnelDto in project head by mifos.

the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithLoanOfficersWhenOnlyOneActiveBranchExists.

@Test
public void shouldPopulateDtoWithLoanOfficersWhenOnlyOneActiveBranchExists() throws Exception {
    // setup
    final Short branchId = userContext.getBranchId();
    final Short levelId = OfficeLevel.BRANCHOFFICE.getValue();
    OfficeDetailsDto officeStub1 = new OfficeDetailsDto(branchId, "branchName1", levelId, Integer.valueOf(1));
    List<OfficeDetailsDto> onlyOneActiveBranch = Arrays.asList(officeStub1);
    final PersonnelDto loanOfficer1 = new PersonnelDto(Short.valueOf("1"), "LoanOfficer1");
    final PersonnelDto loanOfficer2 = new PersonnelDto(Short.valueOf("2"), "LoanOfficer2");
    List<PersonnelDto> loanOfficers = Arrays.asList(loanOfficer1, loanOfficer2);
    // stub interaction with DAO/Persistence layer.
    when(officePersistence.getActiveOffices(branchId)).thenReturn(onlyOneActiveBranch);
    when(personnelPersistence.getActiveLoanOfficersInBranch(PersonnelConstants.LOAN_OFFICER, branchId, userContext.getId(), userContext.getLevelId())).thenReturn(loanOfficers);
    // exercise test
    CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadAllActiveBranchesAndSubsequentDataIfApplicable(userContext);
    // verification
    assertThat(formDto.getLoanOfficerList(), is(loanOfficers));
}
Also used : PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Test(org.junit.Test)

Example 24 with PersonnelDto

use of org.mifos.dto.domain.PersonnelDto in project head by mifos.

the class BulkEntryActionStrutsTest method getSuccessfulBulkEntry.

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);
    CollectionSheetEntryDto bulkEntryParent = new CollectionSheetEntryDto(getCusomerView(center), null);
    SavingsAccountDto centerSavingsAccountView = getSavingsAccountView(centerSavingsAccount);
    centerSavingsAccountView.setDepositAmountEntered("100");
    centerSavingsAccountView.setWithDrawalAmountEntered("10");
    bulkEntryParent.addSavingsAccountDetail(centerSavingsAccountView);
    bulkEntryParent.setCustomerAccountDetails(getCustomerAccountView(center));
    CollectionSheetEntryDto bulkEntryChild = new CollectionSheetEntryDto(getCusomerView(group), null);
    LoanAccountDto groupLoanAccountView = getLoanAccountView(groupAccount);
    SavingsAccountDto groupSavingsAccountView = getSavingsAccountView(groupSavingsAccount);
    groupSavingsAccountView.setDepositAmountEntered("100");
    groupSavingsAccountView.setWithDrawalAmountEntered("10");
    bulkEntryChild.addLoanAccountDetails(groupLoanAccountView);
    bulkEntryChild.addSavingsAccountDetail(groupSavingsAccountView);
    bulkEntryChild.setCustomerAccountDetails(getCustomerAccountView(group));
    CollectionSheetEntryDto bulkEntrySubChild = new CollectionSheetEntryDto(getCusomerView(client), null);
    LoanAccountDto clientLoanAccountView = getLoanAccountView(clientAccount);
    clientLoanAccountView.setAmountPaidAtDisbursement(0.0);
    SavingsAccountDto 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);
    LoanAccountsProductDto childView = bulkEntryChild.getLoanAccountDetails().get(0);
    childView.setPrdOfferingId(groupLoanAccountView.getPrdOfferingId());
    childView.setEnteredAmount("100.0");
    LoanAccountsProductDto 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 PersonnelDto loanOfficer = getPersonnelView(center.getPersonnel());
    final OfficeDetailsDto officeDetailsDto = null;
    final List<CustomValueListElementDto> attendanceTypesList = new ArrayList<CustomValueListElementDto>();
    bulkEntryParent.setCountOfCustomers(3);
    final CollectionSheetEntryGridDto bulkEntry = new CollectionSheetEntryGridDto(bulkEntryParent, loanOfficer, officeDetailsDto, getPaymentTypeView(), startDate, "324343242", startDate, loanProducts, savingsProducts, attendanceTypesList);
    return bulkEntry;
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomValueListElementDto(org.mifos.application.master.business.CustomValueListElementDto) ArrayList(java.util.ArrayList) LoanAccountDto(org.mifos.accounts.loan.util.helpers.LoanAccountDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Date(java.util.Date) LoanAccountsProductDto(org.mifos.accounts.loan.util.helpers.LoanAccountsProductDto) SavingsAccountDto(org.mifos.accounts.savings.util.helpers.SavingsAccountDto) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto) LoanAccountsProductDto(org.mifos.accounts.loan.util.helpers.LoanAccountsProductDto) ProductDto(org.mifos.application.servicefacade.ProductDto) CollectionSheetEntryGridDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)

Example 25 with PersonnelDto

use of org.mifos.dto.domain.PersonnelDto in project head by mifos.

the class BulkEntryActionStrutsTest method testSuccessfulGet.

@SuppressWarnings("unchecked")
@Test
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);
    CustomerDto customerDto = new CustomerDto();
    customerDto.setCustomerId(center.getCustomerId());
    customerDto.setCustomerSearchId(center.getSearchId());
    customerDto.setCustomerLevelId(center.getCustomerLevel().getId());
    final OfficeDetailsDto officeDetailsDto = new OfficeDetailsDto(Short.valueOf("3"), "", OfficeLevel.BRANCHOFFICE.getValue(), "levelNameKey", Integer.valueOf(-1));
    final PersonnelDto personnelDto = new PersonnelDto(Short.valueOf("3"), "");
    SessionUtils.setAttribute(CollectionSheetEntryConstants.COLLECTION_SHEET_ENTRY_FORM_DTO, createCollectionSheetDto(customerDto, officeDetailsDto, personnelDto), 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(account.getOffice().getOfficeId(), 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");
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) TestCollectionSheetRetrieveSavingsAccountsUtils(org.mifos.application.servicefacade.TestCollectionSheetRetrieveSavingsAccountsUtils) CustomerDto(org.mifos.dto.domain.CustomerDto) GregorianCalendar(java.util.GregorianCalendar) PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) Test(org.junit.Test)

Aggregations

PersonnelDto (org.mifos.dto.domain.PersonnelDto)27 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)19 ArrayList (java.util.ArrayList)15 CustomerDto (org.mifos.dto.domain.CustomerDto)12 MifosUser (org.mifos.security.MifosUser)9 UserContext (org.mifos.security.util.UserContext)9 CenterCreation (org.mifos.dto.domain.CenterCreation)8 Date (java.util.Date)7 Test (org.junit.Test)7 MeetingBO (org.mifos.application.meeting.business.MeetingBO)6 CollectionSheetEntryGridDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)5 DateTime (org.joda.time.DateTime)4 CollectionSheetEntryDto (org.mifos.application.collectionsheet.business.CollectionSheetEntryDto)4 FeeBO (org.mifos.accounts.fees.business.FeeBO)3 FeeDto (org.mifos.accounts.fees.business.FeeDto)3 LoanAccountDto (org.mifos.accounts.loan.util.helpers.LoanAccountDto)3 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)3 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)3 CustomValueListElementDto (org.mifos.application.master.business.CustomValueListElementDto)3 ProductDto (org.mifos.application.servicefacade.ProductDto)3