Search in sources :

Example 1 with CenterPerformanceHistoryDto

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

the class CenterServiceFacadeWebTier method getCenterInformationDto.

@Override
public CenterInformationDto getCenterInformationDto(String globalCustNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    CenterBO center = customerDao.findCenterBySystemId(globalCustNum);
    if (center == null) {
        throw new MifosRuntimeException("Center not found for globalCustNum" + globalCustNum);
    }
    try {
        personnelDao.checkAccessPermission(userContext, center.getOfficeId(), center.getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException("Access denied!", e);
    }
    CenterDisplayDto centerDisplay = customerDao.getCenterDisplayDto(center.getCustomerId(), userContext);
    Integer centerId = center.getCustomerId();
    String searchId = center.getSearchId();
    Short branchId = centerDisplay.getBranchId();
    CustomerAccountSummaryDto customerAccountSummary = customerDao.getCustomerAccountSummaryDto(centerId);
    CenterPerformanceHistoryDto centerPerformanceHistory = customerDao.getCenterPerformanceHistory(searchId, branchId);
    CustomerAddressDto centerAddress = customerDao.getCustomerAddressDto(center);
    List<CustomerDetailDto> groups = customerDao.getGroupsOtherThanClosedAndCancelledForGroup(searchId, branchId);
    List<CustomerNoteDto> recentCustomerNotes = customerDao.getRecentCustomerNoteDto(centerId);
    List<CustomerPositionOtherDto> customerPositions = customerDao.getCustomerPositionDto(centerId, userContext);
    List<SavingsDetailDto> savingsDetail = customerDao.getSavingsDetailDto(centerId, userContext);
    CustomerMeetingDto customerMeeting = customerDao.getCustomerMeetingDto(center.getCustomerMeeting(), userContext);
    List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(centerId);
    List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
    for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
        if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.SAVINGS_ACCOUNT.getValue().intValue()) {
            closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
        }
    }
    //new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.CENTER);
    Boolean activeSurveys = Boolean.FALSE;
    List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    return new CenterInformationDto(centerDisplay, customerAccountSummary, centerPerformanceHistory, centerAddress, groups, recentCustomerNotes, customerPositions, savingsDetail, customerMeeting, activeSurveys, customerSurveys, customFields, closedSavingsAccounts);
}
Also used : CustomerAccountSummaryDto(org.mifos.dto.domain.CustomerAccountSummaryDto) SurveyDto(org.mifos.dto.domain.SurveyDto) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) CenterPerformanceHistoryDto(org.mifos.dto.domain.CenterPerformanceHistoryDto) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) CustomerMeetingDto(org.mifos.dto.domain.CustomerMeetingDto) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) MifosUser(org.mifos.security.MifosUser) AccountException(org.mifos.accounts.exceptions.AccountException) CenterDisplayDto(org.mifos.dto.domain.CenterDisplayDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with CenterPerformanceHistoryDto

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

the class CustomerDaoHibernate method getCenterPerformanceHistory.

/**
     * FIXME: THIS METHOD DOES NOT WORK. Specifically, the portfolioAtRisk calculation. Please see issue 2204.
     */
@Override
public CenterPerformanceHistoryDto getCenterPerformanceHistory(String searchId, Short officeId) {
    Integer activeAndOnHoldGroupCount;
    Integer activeAndOnHoldClientCount;
    String totalSavings;
    String totalLoan;
    activeAndOnHoldGroupCount = getActiveAndOnHoldChildrenCount(searchId, officeId, CustomerLevel.GROUP);
    activeAndOnHoldClientCount = getActiveAndOnHoldChildrenCount(searchId, officeId, CustomerLevel.CLIENT);
    try {
        totalSavings = retrieveTotalSavings(searchId, officeId).toString();
    } catch (CurrencyMismatchException e) {
        totalSavings = localizedMessageLookup("errors.multipleCurrencies");
    }
    try {
        totalLoan = retrieveTotalLoan(searchId, officeId).toString();
    } catch (CurrencyMismatchException e) {
        totalLoan = localizedMessageLookup("errors.multipleCurrencies");
    }
    String portfolioAtRisk = "0.2";
    return new CenterPerformanceHistoryDto(activeAndOnHoldGroupCount, activeAndOnHoldClientCount, totalLoan, totalSavings, portfolioAtRisk);
}
Also used : BigInteger(java.math.BigInteger) CurrencyMismatchException(org.mifos.core.CurrencyMismatchException) CenterPerformanceHistoryDto(org.mifos.dto.domain.CenterPerformanceHistoryDto)

Aggregations

CenterPerformanceHistoryDto (org.mifos.dto.domain.CenterPerformanceHistoryDto)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 CurrencyMismatchException (org.mifos.core.CurrencyMismatchException)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)1 CenterBO (org.mifos.customers.center.business.CenterBO)1 CenterDisplayDto (org.mifos.dto.domain.CenterDisplayDto)1 CenterInformationDto (org.mifos.dto.domain.CenterInformationDto)1 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)1 CustomerAccountSummaryDto (org.mifos.dto.domain.CustomerAccountSummaryDto)1 CustomerAddressDto (org.mifos.dto.domain.CustomerAddressDto)1 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)1 CustomerMeetingDto (org.mifos.dto.domain.CustomerMeetingDto)1 CustomerNoteDto (org.mifos.dto.domain.CustomerNoteDto)1 CustomerPositionOtherDto (org.mifos.dto.domain.CustomerPositionOtherDto)1 SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)1 SurveyDto (org.mifos.dto.domain.SurveyDto)1