Search in sources :

Example 16 with PersonnelDto

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

the class ClientServiceFacadeWebTier method retrieveClientFormCreationData.

@Override
public ClientFormCreationDto retrieveClientFormCreationData(Short groupFlag, Short officeId, String parentGroupId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    List<PersonnelDto> personnelList = new ArrayList<PersonnelDto>();
    MeetingBO parentCustomerMeeting = null;
    Short formedByPersonnelId = null;
    String formedByPersonnelName = "";
    String centerDisplayName = "";
    String groupDisplayName = "";
    String officeName = "";
    List<FeeBO> fees = new ArrayList<FeeBO>();
    Short applicableOfficeId = officeId;
    if (YesNoFlag.YES.getValue().equals(groupFlag)) {
        Integer parentCustomerId = Integer.valueOf(parentGroupId);
        CustomerBO parentCustomer = this.customerDao.findCustomerById(parentCustomerId);
        groupDisplayName = parentCustomer.getDisplayName();
        if (parentCustomer.getPersonnel() != null) {
            formedByPersonnelId = parentCustomer.getPersonnel().getPersonnelId();
            formedByPersonnelName = parentCustomer.getPersonnel().getDisplayName();
        }
        if (parentCustomer.getParentCustomer() != null) {
            centerDisplayName = parentCustomer.getParentCustomer().getDisplayName();
        }
        applicableOfficeId = parentCustomer.getOffice().getOfficeId();
        officeName = parentCustomer.getOffice().getOfficeName();
        if (parentCustomer.getCustomerMeeting() != null) {
            parentCustomerMeeting = parentCustomer.getCustomerMeetingValue();
            fees = this.customerDao.retrieveFeesApplicableToClientsRefinedBy(parentCustomer.getCustomerMeetingValue());
        } else {
            fees = this.customerDao.retrieveFeesApplicableToClients();
        }
    } else if (YesNoFlag.NO.getValue().equals(groupFlag)) {
        CenterCreation centerCreation = new CenterCreation(applicableOfficeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        personnelList = this.personnelDao.findActiveLoanOfficersForOffice(centerCreation);
        fees = this.customerDao.retrieveFeesApplicableToClients();
    }
    CustomerApplicableFeesDto applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);
    List<ApplicableAccountFeeDto> defaultFees = new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getDefaultFees()) {
        defaultFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
    }
    List<ApplicableAccountFeeDto> additionalFees = new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getAdditionalFees()) {
        additionalFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
    }
    List<SavingsDetailDto> savingsOfferings = this.customerDao.retrieveSavingOfferingsApplicableToClient();
    ClientRulesDto clientRules = retrieveClientRules();
    ClientDropdownsDto clientDropdowns = retrieveClientDropdownData();
    List<PersonnelDto> formedByPersonnel = this.customerDao.findLoanOfficerThatFormedOffice(applicableOfficeId);
    MeetingDto parentMeeting = null;
    if (parentCustomerMeeting != null) {
        parentMeeting = parentCustomerMeeting.toDto();
    }
    return new ClientFormCreationDto(clientDropdowns, clientRules, applicableOfficeId, officeName, formedByPersonnelId, formedByPersonnelName, personnelList, formedByPersonnel, savingsOfferings, parentMeeting, centerDisplayName, groupDisplayName, additionalFees, defaultFees);
}
Also used : SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) CustomerMeetingDto(org.mifos.dto.domain.CustomerMeetingDto) MeetingDto(org.mifos.dto.domain.MeetingDto) CenterCreation(org.mifos.dto.domain.CenterCreation) ClientRulesDto(org.mifos.dto.domain.ClientRulesDto) CustomerBO(org.mifos.customers.business.CustomerBO) FeeBO(org.mifos.accounts.fees.business.FeeBO) ClientFormCreationDto(org.mifos.dto.screen.ClientFormCreationDto) ClientDropdownsDto(org.mifos.dto.screen.ClientDropdownsDto)

Example 17 with PersonnelDto

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

the class ProductDtoComparator method toLegacyDto.

@Override
public CollectionSheetEntryGridDto toLegacyDto(final CollectionSheetDto collectionSheet, final CollectionSheetFormEnteredDataDto formEnteredDataDto, final List<CustomValueListElementDto> attendanceTypesList, final MifosCurrency currency) {
    final CollectionSheetEntryDto collectionSheetEntryViewHierarchy = createEntryViewHierarchyFromCollectionSheetData(collectionSheet.getCollectionSheetCustomer(), currency);
    final PersonnelDto loanOfficer = formEnteredDataDto.getLoanOfficer();
    final OfficeDetailsDto office = formEnteredDataDto.getOffice();
    final ListItem<Short> paymentType = formEnteredDataDto.getPaymentType();
    final Date meetingDate = formEnteredDataDto.getMeetingDate();
    final String receiptId = formEnteredDataDto.getReceiptId();
    final Date receiptDate = formEnteredDataDto.getReceiptDate();
    final List<ProductDto> loanProductDtos = createListOfLoanProducts(collectionSheet.getCollectionSheetCustomer());
    final List<ProductDto> savingProductDtos = createListOfSavingProducts(collectionSheet.getCollectionSheetCustomer());
    final CollectionSheetEntryGridDto translatedGridDto = new CollectionSheetEntryGridDto(collectionSheetEntryViewHierarchy, loanOfficer, office, paymentType, meetingDate, receiptId, receiptDate, loanProductDtos, savingProductDtos, attendanceTypesList);
    return translatedGridDto;
}
Also used : PersonnelDto(org.mifos.dto.domain.PersonnelDto) OfficeDetailsDto(org.mifos.dto.domain.OfficeDetailsDto) CollectionSheetEntryDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryDto) Date(java.util.Date) CollectionSheetEntryGridDto(org.mifos.application.collectionsheet.business.CollectionSheetEntryGridDto)

Example 18 with PersonnelDto

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

the class CenterServiceFacadeWebTier method retrieveCenterFormCreationData.

@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);
}
Also used : UserContext(org.mifos.security.util.UserContext) CenterFormCreationDto(org.mifos.dto.screen.CenterFormCreationDto) ArrayList(java.util.ArrayList) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) FeeBO(org.mifos.accounts.fees.business.FeeBO) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto)

Example 19 with PersonnelDto

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

the class CenterServiceFacadeWebTier method retrieveCenterDetailsForUpdate.

@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);
}
Also used : UserContext(org.mifos.security.util.UserContext) CustomerDto(org.mifos.dto.domain.CustomerDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) CenterDto(org.mifos.dto.domain.CenterDto) MifosUser(org.mifos.security.MifosUser) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AddressDto(org.mifos.dto.domain.AddressDto) DateTime(org.joda.time.DateTime) CenterCreation(org.mifos.dto.domain.CenterCreation) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto)

Example 20 with PersonnelDto

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

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