use of org.mifos.dto.domain.CustomerAddressDto in project head by mifos.
the class ClientServiceFacadeWebTier method getClientInformationDto.
@Override
public ClientInformationDto getClientInformationDto(String globalCustNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
ClientBO client = customerDao.findClientBySystemId(globalCustNum);
if (client == null) {
throw new MifosRuntimeException("Client not found for globalCustNum, levelId: " + globalCustNum);
}
try {
personnelDao.checkAccessPermission(userContext, client.getOfficeId(), client.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
ClientDisplayDto clientDisplay = this.customerDao.getClientDisplayDto(client.getCustomerId(), userContext);
Integer clientId = client.getCustomerId();
CustomerAccountSummaryDto customerAccountSummary = this.customerDao.getCustomerAccountSummaryDto(clientId);
ClientPerformanceHistoryDto clientPerformanceHistory = assembleClientPerformanceHistoryDto(client.getClientPerformanceHistory(), clientId);
CustomerAddressDto clientAddress = this.customerDao.getCustomerAddressDto(client);
List<CustomerNoteDto> recentCustomerNotes = customerDao.getRecentCustomerNoteDto(clientId);
List<CustomerFlagDto> customerFlags = customerDao.getCustomerFlagDto(client.getCustomerFlags());
List<LoanDetailDto> loanDetail = customerDao.getLoanDetailDto(client.getOpenLoanAccounts());
List<LoanDetailDto> groupLoanDetail = customerDao.getLoanDetailDto(client.getOpenGroupLoanAccounts());
List<SavingsDetailDto> savingsDetail = customerDao.getSavingsDetailDto(clientId, userContext);
CustomerMeetingDto customerMeeting = customerDao.getCustomerMeetingDto(client.getCustomerMeeting(), userContext);
List<AccountBO> allClosedLoanAndSavingsAccounts = customerDao.retrieveAllClosedLoanAndSavingsAccounts(clientId);
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 = Boolean.FALSE;
// Boolean activeSurveys = new SurveysPersistence().isActiveSurveysForSurveyType(SurveyType.CLIENT);
List<SurveyDto> customerSurveys = new ArrayList<SurveyDto>();
List<LoanDetailDto> guarantedLoanAccounts = new ArrayList<LoanDetailDto>();
try {
List<GuarantyEntity> guaranties = legacyAccountDao.getGuarantyByGurantorId(clientId);
if (guaranties != null && guaranties.size() > 0) {
for (GuarantyEntity guaranty : guaranties) {
if (guaranty != null && guaranty.getState() != null && guaranty.getState()) {
LoanBO loan = loanDao.findById(guaranty.getLoanId());
guarantedLoanAccounts.add(new LoanDetailDto(loan.getGlobalAccountNum(), loan.getLoanOffering().getPrdOfferingName(), loan.getAccountState().getId(), loan.getAccountState().getName(), loan.getLoanSummary().getOutstandingBalance().toString(), loan.getTotalAmountDue().toString(), loan.getAccountType().getAccountTypeId(), loan.getTotalAmountInArrears().toString()));
}
}
}
} catch (PersistenceException e) {
throw new MifosRuntimeException("Can not get guaranted loan accounts", e);
}
return new ClientInformationDto(clientDisplay, customerAccountSummary, clientPerformanceHistory, clientAddress, recentCustomerNotes, customerFlags, loanDetail, groupLoanDetail, savingsDetail, customerMeeting, activeSurveys, customerSurveys, closedLoanAccounts, closedSavingsAccounts, guarantedLoanAccounts);
}
use of org.mifos.dto.domain.CustomerAddressDto 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);
}
use of org.mifos.dto.domain.CustomerAddressDto 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);
}
Aggregations