Search in sources :

Example 1 with GroupPerformanceHistoryDto

use of org.mifos.dto.screen.GroupPerformanceHistoryDto in project head by mifos.

the class GroupServiceFacadeWebTier method assembleGroupPerformanceHistoryDto.

private GroupPerformanceHistoryDto assembleGroupPerformanceHistoryDto(GroupPerformanceHistoryEntity groupPerformanceHistory, String searchId, Short branchId, Integer groupId) {
    Integer activeClientCount = this.customerDao.getActiveAndOnHoldClientCountForGroup(searchId, branchId);
    Money lastGroupLoanAmountMoney = groupPerformanceHistory.getLastGroupLoanAmount();
    String lastGroupLoanAmount = "";
    if (lastGroupLoanAmountMoney != null) {
        lastGroupLoanAmount = lastGroupLoanAmountMoney.toString();
    }
    String avgLoanAmountForMember = this.customerDao.getAvgLoanAmountForMemberInGoodOrBadStanding(searchId, branchId);
    String totalLoanAmountForGroup = this.customerDao.getTotalLoanAmountForGroup(searchId, branchId);
    String portfolioAtRisk;
    String totalSavingsAmount;
    try {
        if (groupPerformanceHistory.getPortfolioAtRisk() == null) {
            portfolioAtRisk = "0";
        } else {
            portfolioAtRisk = groupPerformanceHistory.getPortfolioAtRisk().toString();
        }
    } catch (CurrencyMismatchException e) {
        portfolioAtRisk = localizedMessageLookup("errors.multipleCurrencies");
    }
    totalSavingsAmount = this.customerDao.getTotalSavingsAmountForGroupandClientsOfGroup(searchId, branchId);
    List<LoanCycleCounter> loanCycleCounters = this.customerDao.fetchLoanCycleCounter(groupId, CustomerLevel.GROUP.getValue());
    return new GroupPerformanceHistoryDto(activeClientCount.toString(), lastGroupLoanAmount, avgLoanAmountForMember, totalLoanAmountForGroup, portfolioAtRisk, totalSavingsAmount, loanCycleCounters);
}
Also used : Money(org.mifos.framework.util.helpers.Money) CurrencyMismatchException(org.mifos.core.CurrencyMismatchException) GroupPerformanceHistoryDto(org.mifos.dto.screen.GroupPerformanceHistoryDto) LoanCycleCounter(org.mifos.dto.screen.LoanCycleCounter)

Example 2 with GroupPerformanceHistoryDto

use of org.mifos.dto.screen.GroupPerformanceHistoryDto in project head by mifos.

the class GroupServiceFacadeWebTier method getGroupInformationDto.

//    private void checkPermissionForCreate(Short newState, UserContext userContext, Short recordOfficeId,
//            Short recordLoanOfficerId) throws ApplicationException {
//        if (!isPermissionAllowed(newState, userContext, recordOfficeId, recordLoanOfficerId)) {
//            logger.info("permission not allowed: " + userContext.toString() + " officeId: " + recordLoanOfficerId + " loanOfficerId: " + recordLoanOfficerId);
//            throw new AccountException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
//        }
//    }
//    private boolean isPermissionAllowed(Short newState, UserContext userContext, Short recordOfficeId,
//            Short recordLoanOfficerId) {
//        return ActivityMapper.getInstance().isSavePermittedForCustomer(newState.shortValue(), userContext,
//                recordOfficeId, recordLoanOfficerId);
//    }
@Override
public GroupInformationDto getGroupInformationDto(String globalCustNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    GroupBO group = this.customerDao.findGroupBySystemId(globalCustNum);
    if (group == null) {
        throw new MifosRuntimeException("Group not found for globalCustNum: " + globalCustNum);
    }
    try {
        personnelDao.checkAccessPermission(userContext, group.getOfficeId(), group.getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException("Access denied!", e);
    }
    GroupDisplayDto groupDisplay = this.customerDao.getGroupDisplayDto(group.getCustomerId(), userContext);
    Integer groupId = group.getCustomerId();
    String searchId = group.getSearchId();
    Short branchId = groupDisplay.getBranchId();
    CustomerAccountSummaryDto customerAccountSummary = this.customerDao.getCustomerAccountSummaryDto(groupId);
    GroupPerformanceHistoryDto groupPerformanceHistory = assembleGroupPerformanceHistoryDto(group.getGroupPerformanceHistory(), searchId, branchId, groupId);
    CustomerAddressDto groupAddress = this.customerDao.getCustomerAddressDto(group);
    List<CustomerDetailDto> clients = this.customerDao.findClientsThatAreNotCancelledOrClosedReturningDetailDto(searchId, branchId);
    List<CustomerNoteDto> recentCustomerNotes = this.customerDao.getRecentCustomerNoteDto(groupId);
    List<CustomerPositionOtherDto> customerPositions = this.customerDao.getCustomerPositionDto(groupId, userContext);
    List<CustomerFlagDto> customerFlags = this.customerDao.getCustomerFlagDto(group.getCustomerFlags());
    List<LoanDetailDto> loanDetail = this.customerDao.getLoanDetailDto(group.getOpenLoanAccountsAndGroupLoans());
    List<SavingsDetailDto> savingsDetail = this.customerDao.getSavingsDetailDto(groupId, userContext);
    CustomerMeetingDto customerMeeting = this.customerDao.getCustomerMeetingDto(group.getCustomerMeeting(), userContext);
    List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(groupId);
    List<LoanDetailDto> closedLoanAccounts = new ArrayList<LoanDetailDto>();
    List<SavingsDetailDto> closedSavingsAccounts = new ArrayList<SavingsDetailDto>();
    for (AccountBO closedAccount : allClosedLoanAndSavingsAccounts) {
        if (closedAccount.getAccountType().getAccountTypeId() == AccountTypes.LOAN_ACCOUNT.getValue().intValue()) {
            closedLoanAccounts.add(new LoanDetailDto(closedAccount.getGlobalAccountNum(), ((LoanBO) closedAccount).getLoanOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((LoanBO) closedAccount).getLoanSummary().getOutstandingBalance().toString(), closedAccount.getTotalAmountDue().toString(), closedAccount.getTotalAmountInArrears().toString()));
        } else {
            closedSavingsAccounts.add(new SavingsDetailDto(closedAccount.getGlobalAccountNum(), ((SavingsBO) closedAccount).getSavingsOffering().getPrdOfferingName(), closedAccount.getAccountState().getId(), closedAccount.getAccountState().getName(), ((SavingsBO) closedAccount).getSavingsBalance().toString()));
        }
    }
    boolean activeSurveys = false;
    //        boolean activeSurveys = new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.GROUP);
    List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
    List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
    return new GroupInformationDto(groupDisplay, customerAccountSummary, groupPerformanceHistory, groupAddress, clients, recentCustomerNotes, customerPositions, customerFlags, loanDetail, savingsDetail, customerMeeting, activeSurveys, customerSurveys, customFields, closedLoanAccounts, closedSavingsAccounts);
}
Also used : CustomerAccountSummaryDto(org.mifos.dto.domain.CustomerAccountSummaryDto) SurveyDto(org.mifos.dto.domain.SurveyDto) GroupDisplayDto(org.mifos.dto.screen.GroupDisplayDto) ArrayList(java.util.ArrayList) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AccountBO(org.mifos.accounts.business.AccountBO) CustomerMeetingDto(org.mifos.dto.domain.CustomerMeetingDto) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) UserContext(org.mifos.security.util.UserContext) LoanDetailDto(org.mifos.dto.domain.LoanDetailDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) MifosUser(org.mifos.security.MifosUser) CustomerFlagDto(org.mifos.dto.domain.CustomerFlagDto) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) GroupPerformanceHistoryDto(org.mifos.dto.screen.GroupPerformanceHistoryDto) AccountException(org.mifos.accounts.exceptions.AccountException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

GroupPerformanceHistoryDto (org.mifos.dto.screen.GroupPerformanceHistoryDto)2 ArrayList (java.util.ArrayList)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 CurrencyMismatchException (org.mifos.core.CurrencyMismatchException)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 GroupBO (org.mifos.customers.group.business.GroupBO)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 CustomerFlagDto (org.mifos.dto.domain.CustomerFlagDto)1 CustomerMeetingDto (org.mifos.dto.domain.CustomerMeetingDto)1 CustomerNoteDto (org.mifos.dto.domain.CustomerNoteDto)1 CustomerPositionOtherDto (org.mifos.dto.domain.CustomerPositionOtherDto)1 LoanDetailDto (org.mifos.dto.domain.LoanDetailDto)1 SavingsDetailDto (org.mifos.dto.domain.SavingsDetailDto)1 SurveyDto (org.mifos.dto.domain.SurveyDto)1 GroupDisplayDto (org.mifos.dto.screen.GroupDisplayDto)1