use of org.mifos.customers.client.business.ClientBO 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.customers.client.business.ClientBO in project head by mifos.
the class ClientServiceFacadeWebTier method retrieveMfiInfoForEdit.
@Override
public ClientMfiInfoDto retrieveMfiInfoForEdit(String clientSystemId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
ClientBO client = this.customerDao.findClientBySystemId(clientSystemId);
String groupDisplayName = "";
String centerDisplayName = "";
if (client.getParentCustomer() != null) {
groupDisplayName = client.getParentCustomer().getDisplayName();
if (client.getParentCustomer().getParentCustomer() != null) {
centerDisplayName = client.getParentCustomer().getParentCustomer().getDisplayName();
}
}
List<PersonnelDto> loanOfficersList = new ArrayList<PersonnelDto>();
if (!client.isClientUnderGroup()) {
CenterCreation centerCreation = new CenterCreation(client.getOffice().getOfficeId(), userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
loanOfficersList = this.personnelDao.findActiveLoanOfficersForOffice(centerCreation);
}
CustomerDetailDto customerDetail = client.toCustomerDetailDto();
ClientDetailDto clientDetail = client.toClientDetailDto(ClientRules.isFamilyDetailsRequired());
return new ClientMfiInfoDto(groupDisplayName, centerDisplayName, loanOfficersList, customerDetail, clientDetail);
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class ClientServiceFacadeWebTier method retrieveFamilyInfoForEdit.
@Override
public ClientFamilyInfoDto retrieveFamilyInfoForEdit(String clientGlobalCustNum) {
ClientBO client = this.customerDao.findClientBySystemId(clientGlobalCustNum);
ClientDropdownsDto clientDropdowns = retrieveClientDropdownData();
ClientRulesDto clientRules = retrieveClientRules();
CustomerDetailDto customerDetail = client.toCustomerDetailDto();
ClientDetailDto clientDetail = client.toClientDetailDto(clientRules.isFamilyDetailsRequired());
List<ClientNameDetailDto> familyMembers = new ArrayList<ClientNameDetailDto>();
Map<Integer, List<ClientFamilyDetailDto>> clientFamilyDetails = new HashMap<Integer, List<ClientFamilyDetailDto>>();
int familyMemberCount = 0;
for (ClientNameDetailEntity clientNameDetailEntity : client.getNameDetailSet()) {
if (clientNameDetailEntity.isNotClientNameType()) {
ClientNameDetailDto nameView1 = clientNameDetailEntity.toDto();
familyMembers.add(nameView1);
for (ClientFamilyDetailEntity clientFamilyDetailEntity : client.getFamilyDetailSet()) {
if (clientNameDetailEntity.matchesCustomerId(clientFamilyDetailEntity.getClientName().getCustomerNameId())) {
ClientFamilyDetailDto clientFamilyDetail = clientFamilyDetailEntity.toDto();
addFamilyDetailsDtoToMap(clientFamilyDetails, familyMemberCount, clientFamilyDetail);
}
}
familyMemberCount++;
}
}
return new ClientFamilyInfoDto(clientDropdowns, customerDetail, clientDetail, familyMembers, clientFamilyDetails);
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class ClientServiceFacadeWebTier method removeGroupMembership.
@Override
public void removeGroupMembership(String globalCustNum, Short loanOfficerId, String comment) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(mifosUser);
ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
client.updateDetails(userContext);
PersonnelBO loanOfficer = null;
if (loanOfficerId != null) {
loanOfficer = this.personnelDao.findPersonnelById(loanOfficerId);
}
PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
java.sql.Date commentDate = new DateTimeService().getCurrentJavaSqlDate();
CustomerNoteEntity accountNotesEntity = new CustomerNoteEntity(comment, commentDate, loggedInUser, client);
customerService.removeGroupMembership(client, loanOfficer, accountNotesEntity, userContext.getLocaleId());
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class ClientServiceFacadeWebTier method previewClient.
@Override
public ProcessRulesDto previewClient(String governmentId, DateTime dateOfBirth, String clientName, boolean defaultFeeRemoval, Short officeId, Short loanOfficerId) {
try {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
boolean clientPendingApprovalStateEnabled = ProcessFlowRules.isClientPendingApprovalStateEnabled();
boolean governmentIdValidationFailing = false;
boolean duplicateNameOnClosedClient = false;
boolean duplicateNameOnBlackListedClient = false;
boolean governmentIdValidationUnclosedFailing = false;
boolean duplicateNameOnClient = false;
List<ClientBO> matchedClients = new ArrayList<ClientBO>();
List<ClientBO> temp;
if (defaultFeeRemoval) {
customerDao.checkPermissionForDefaultFeeRemoval(userContext, officeId, loanOfficerId);
}
if (StringUtils.isNotBlank(governmentId)) {
temp = this.customerDao.validateGovernmentIdForUnclosedClient(governmentId);
if (temp != null) {
matchedClients.addAll(temp);
}
governmentIdValidationUnclosedFailing = temp != null && temp.size() > 0;
if (!governmentIdValidationUnclosedFailing) {
temp = this.customerDao.validateGovernmentIdForClient(governmentId);
if (temp != null) {
matchedClients.addAll(temp);
}
governmentIdValidationFailing = temp != null && temp.size() > 0;
}
}
if (!governmentIdValidationFailing && !governmentIdValidationUnclosedFailing) {
temp = this.customerDao.validateForBlackListedClientsOnNameAndDob(clientName, dateOfBirth);
if (temp != null) {
matchedClients.addAll(temp);
}
duplicateNameOnBlackListedClient = temp != null && temp.size() > 0;
if (!duplicateNameOnBlackListedClient) {
temp = this.customerDao.validateForClosedClientsOnNameAndDob(clientName, dateOfBirth);
if (temp != null) {
matchedClients.addAll(temp);
}
duplicateNameOnClosedClient = temp != null && temp.size() > 0;
if (!duplicateNameOnClosedClient) {
temp = this.customerDao.validateForClientsOnName(clientName);
if (temp != null) {
matchedClients.addAll(temp);
}
duplicateNameOnClient = temp != null && temp.size() > 0;
}
}
}
List<MatchedClientDto> matched = new ArrayList<MatchedClientDto>();
for (ClientBO client : matchedClients) {
matched.add(new MatchedClientDto(client.getGlobalCustNum(), client.getDisplayName(), client.getAddress().getPhoneNumber(), client.getGovernmentId(), client.getDisplayAddress(), client.getOffice().getOfficeName(), client.getOffice().getGlobalOfficeNum()));
}
return new ProcessRulesDto(clientPendingApprovalStateEnabled, governmentIdValidationFailing, duplicateNameOnClosedClient, duplicateNameOnBlackListedClient, governmentIdValidationUnclosedFailing, duplicateNameOnClient, matched);
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
Aggregations