Search in sources :

Example 26 with CustomerDto

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

the class CollectionSheetServiceFacadeWebTierTest method shouldPopulateDtoWithLatestMeetingDateWhenBackDatedTransactionsAreAllowed.

@Test
public void shouldPopulateDtoWithLatestMeetingDateWhenBackDatedTransactionsAreAllowed() throws Exception {
    // setup
    final Integer customerId = Integer.valueOf(3);
    final CustomerDto customer1 = new CustomerDto();
    customer1.setCustomerId(customerId);
    final List<CustomerDto> customers = Arrays.asList(customer1);
    final Date expectedMeetingDateAsJavaDate = new DateTime().plusDays(2).toDate();
    final java.sql.Date expectedMeetingDateAsSqlDate = new java.sql.Date(expectedMeetingDateAsJavaDate.getTime());
    final CollectionSheetEntryFormDto previousCollectionSheetFormDto = new CollectionSheetEntryFormDto(new ArrayList<OfficeDetailsDto>(), new ArrayList<ListItem<Short>>(), new ArrayList<PersonnelDto>(), customers, Constants.YES, Constants.YES, Constants.YES);
    when(customerPersistence.getLastMeetingDateForCustomer(customerId)).thenReturn(expectedMeetingDateAsSqlDate);
    // NOTE: Backdated transactions is checked through static
    // AccountingRules so can't set up for now
    // exercise test
    CollectionSheetEntryFormDto formDto = collectionSheetServiceFacadeWebTier.loadMeetingDateForCustomer(customerId, previousCollectionSheetFormDto);
    // verification
    assertThat(formDto.getMeetingDate(), is(expectedMeetingDateAsJavaDate));
    // assert rest of data comes from previousDto
    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) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 27 with CustomerDto

use of org.mifos.dto.domain.CustomerDto 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 28 with CustomerDto

use of org.mifos.dto.domain.CustomerDto 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 29 with CustomerDto

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

the class BulkEntryDisplayHelperIntegrationTest method getCusomerView.

private CustomerDto getCusomerView(final CustomerBO customer) {
    CustomerDto customerDto = new CustomerDto();
    customerDto.setCustomerId(customer.getCustomerId());
    customerDto.setCustomerLevelId(customer.getCustomerLevel().getId());
    customerDto.setCustomerSearchId(customer.getSearchId());
    customerDto.setDisplayName(customer.getDisplayName());
    customerDto.setGlobalCustNum(customer.getGlobalCustNum());
    customerDto.setOfficeId(customer.getOffice().getOfficeId());
    if (null != customer.getParentCustomer()) {
        customerDto.setParentCustomerId(customer.getParentCustomer().getCustomerId());
    }
    customerDto.setPersonnelId(customer.getPersonnel().getPersonnelId());
    customerDto.setStatusId(customer.getCustomerStatus().getId());
    return customerDto;
}
Also used : CustomerDto(org.mifos.dto.domain.CustomerDto)

Example 30 with CustomerDto

use of org.mifos.dto.domain.CustomerDto 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

CustomerDto (org.mifos.dto.domain.CustomerDto)38 ArrayList (java.util.ArrayList)15 PersonnelDto (org.mifos.dto.domain.PersonnelDto)12 Test (org.junit.Test)11 OfficeDetailsDto (org.mifos.dto.domain.OfficeDetailsDto)10 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 UserReferenceDto (org.mifos.dto.domain.UserReferenceDto)7 DateTime (org.joda.time.DateTime)6 CustomerBO (org.mifos.customers.business.CustomerBO)6 AccountPaymentParametersDto (org.mifos.dto.domain.AccountPaymentParametersDto)6 AccountReferenceDto (org.mifos.dto.domain.AccountReferenceDto)6 MifosUser (org.mifos.security.MifosUser)6 UserContext (org.mifos.security.util.UserContext)6 Date (java.util.Date)5 LocalDate (org.joda.time.LocalDate)5 Money (org.mifos.framework.util.helpers.Money)5 HashMap (java.util.HashMap)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)4 PaymentTypeDto (org.mifos.dto.domain.PaymentTypeDto)4 BigDecimal (java.math.BigDecimal)3