use of org.mifos.dto.domain.SavingsDetailDto in project head by mifos.
the class CustomerDaoHibernate method retrieveSavingOfferingsApplicableToClient.
@SuppressWarnings("unchecked")
@Override
public List<SavingsDetailDto> retrieveSavingOfferingsApplicableToClient() {
List<SavingsDetailDto> savingDetails = new ArrayList<SavingsDetailDto>();
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("prdApplicableTo", ApplicableTo.CLIENTS.getValue());
List<SavingsOfferingBO> savingOfferings = (List<SavingsOfferingBO>) this.genericDao.executeNamedQuery(NamedQueryConstants.GET_ACTIVE_OFFERINGS_FOR_CUSTOMER, queryParameters);
for (SavingsOfferingBO savingsOffering : savingOfferings) {
SavingsDetailDto savingsDetailsWithOnlyPrdOfferingName = SavingsDetailDto.create(savingsOffering.getPrdOfferingId(), savingsOffering.getPrdOfferingName());
savingDetails.add(savingsDetailsWithOnlyPrdOfferingName);
}
return savingDetails;
}
use of org.mifos.dto.domain.SavingsDetailDto 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);
}
use of org.mifos.dto.domain.SavingsDetailDto 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);
}
use of org.mifos.dto.domain.SavingsDetailDto in project head by mifos.
the class ClientServiceFacadeWebTier method createNewClient.
@Override
public CustomerDetailsDto createNewClient(ClientCreationDetail clientCreationDetail, MeetingDto meetingDto, List<SavingsDetailDto> allowedSavingProducts) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId());
userContext.setBranchGlobalNum(userOffice.getGlobalOfficeNum());
try {
ClientBO client = null;
List<AccountFeesEntity> feesForCustomerAccount = convertFeeViewsToAccountFeeEntities(clientCreationDetail.getFeesToApply());
List<SavingsOfferingBO> selectedOfferings = new ArrayList<SavingsOfferingBO>();
for (Short productId : clientCreationDetail.getSelectedSavingProducts()) {
if (productId != null) {
for (SavingsDetailDto savingsOffering : allowedSavingProducts) {
if (productId.equals(savingsOffering.getPrdOfferingId())) {
SavingsOfferingBO savingsProduct = savingsProductDao.findById(productId.intValue());
selectedOfferings.add(savingsProduct);
}
}
}
}
List<ClientInitialSavingsOfferingEntity> offeringsAssociatedInCreate = new ArrayList<ClientInitialSavingsOfferingEntity>();
for (SavingsOfferingBO offering : selectedOfferings) {
offeringsAssociatedInCreate.add(new ClientInitialSavingsOfferingEntity(null, offering));
}
Short personnelId = null;
Short officeId = null;
ClientNameDetailDto spouseNameDetailView = null;
if (ClientRules.isFamilyDetailsRequired()) {
// actionForm.setFamilyDateOfBirth();
// actionForm.constructFamilyDetails();
} else {
spouseNameDetailView = clientCreationDetail.getSpouseFatherName();
}
String secondMiddleName = null;
ClientNameDetailEntity clientNameDetailEntity = new ClientNameDetailEntity(null, secondMiddleName, clientCreationDetail.getClientNameDetailDto());
ClientNameDetailEntity spouseFatherNameDetailEntity = null;
if (spouseNameDetailView != null) {
spouseFatherNameDetailEntity = new ClientNameDetailEntity(null, secondMiddleName, spouseNameDetailView);
}
ClientDetailEntity clientDetailEntity = new ClientDetailEntity();
clientDetailEntity.updateClientDetails(clientCreationDetail.getClientPersonalDetailDto());
DateTime dob = new DateTime(clientCreationDetail.getDateOfBirth());
boolean trainedBool = clientCreationDetail.isTrained();
DateTime trainedDateTime = null;
if (clientCreationDetail.getTrainedDate() != null) {
trainedDateTime = new DateTime(clientCreationDetail.getTrainedDate());
}
String clientFirstName = clientCreationDetail.getClientNameDetailDto().getFirstName();
String clientLastName = clientCreationDetail.getClientNameDetailDto().getLastName();
String secondLastName = clientCreationDetail.getClientNameDetailDto().getSecondLastName();
CustomerStatus clientStatus = CustomerStatus.fromInt(clientCreationDetail.getClientStatus());
PersonnelBO formedBy = this.personnelDao.findPersonnelById(clientCreationDetail.getFormedBy());
Address address = null;
if (clientCreationDetail.getAddress() != null) {
AddressDto dto = clientCreationDetail.getAddress();
address = new Address(dto.getLine1(), dto.getLine2(), dto.getLine3(), dto.getCity(), dto.getState(), dto.getCountry(), dto.getZip(), dto.getPhoneNumber());
}
if (YesNoFlag.YES.getValue().equals(clientCreationDetail.getGroupFlag())) {
Integer parentGroupId = Integer.parseInt(clientCreationDetail.getParentGroupId());
CustomerBO group = this.customerDao.findCustomerById(parentGroupId);
if (group.getPersonnel() != null) {
personnelId = group.getPersonnel().getPersonnelId();
}
officeId = group.getOffice().getOfficeId();
client = ClientBO.createNewInGroupHierarchy(userContext, clientCreationDetail.getClientName(), clientStatus, new DateTime(clientCreationDetail.getMfiJoiningDate()), group, formedBy, clientNameDetailEntity, dob, clientCreationDetail.getGovernmentId(), trainedBool, trainedDateTime, clientCreationDetail.getGroupFlag(), clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, offeringsAssociatedInCreate, clientCreationDetail.getExternalId(), address, clientCreationDetail.getActivationDate());
if (ClientRules.isFamilyDetailsRequired()) {
client.setFamilyAndNameDetailSets(clientCreationDetail.getFamilyNames(), clientCreationDetail.getFamilyDetails());
}
this.customerService.createClient(client, client.getCustomerMeetingValue(), feesForCustomerAccount, selectedOfferings);
} else {
personnelId = clientCreationDetail.getLoanOfficerId();
officeId = clientCreationDetail.getOfficeId();
PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(personnelId);
OfficeBO office = this.officeDao.findOfficeById(officeId);
int lastSearchIdCustomerValue = customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(officeId);
MeetingBO clientMeeting = null;
if (meetingDto != null) {
clientMeeting = new MeetingFactory().create(meetingDto);
clientMeeting.setUserContext(userContext);
}
client = ClientBO.createNewOutOfGroupHierarchy(userContext, clientCreationDetail.getClientName(), clientStatus, new DateTime(clientCreationDetail.getMfiJoiningDate()), office, loanOfficer, clientMeeting, formedBy, clientNameDetailEntity, dob, clientCreationDetail.getGovernmentId(), trainedBool, trainedDateTime, clientCreationDetail.getGroupFlag(), clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, offeringsAssociatedInCreate, clientCreationDetail.getExternalId(), address, lastSearchIdCustomerValue);
if (ClientRules.isFamilyDetailsRequired()) {
client.setFamilyAndNameDetailSets(clientCreationDetail.getFamilyNames(), clientCreationDetail.getFamilyDetails());
}
try {
personnelDao.checkAccessPermission(userContext, client.getOfficeId(), client.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
this.customerService.createClient(client, clientMeeting, feesForCustomerAccount, selectedOfferings);
}
clientPhotoService.create(client.getCustomerId().longValue(), clientCreationDetail.getPicture());
return new CustomerDetailsDto(client.getCustomerId(), client.getGlobalCustNum());
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e.getValues(), e);
}
}
use of org.mifos.dto.domain.SavingsDetailDto in project head by mifos.
the class CustomerDaoHibernate method getSavingsDetailDto.
@SuppressWarnings("unchecked")
@Override
public List<SavingsDetailDto> getSavingsDetailDto(Integer customerId, UserContext userContext) {
Map<String, Object> queryParameters = new HashMap<String, Object>();
queryParameters.put("CUSTOMER_ID", customerId);
List<Object[]> queryResult = (List<Object[]>) this.genericDao.executeNamedQuery("Customer.getSavingsDetailDto", queryParameters);
if (queryResult.size() == 0) {
return null;
}
List<SavingsDetailDto> savingsDetails = new ArrayList<SavingsDetailDto>();
String globalAccountNum;
String prdOfferingName;
Short accountStateId;
String accountStateName;
Money savingsBalance;
String lookupName;
Short currency;
BigDecimal maxWithdrawalAmount;
String savingsType = "";
MifosCurrency mifosCurrency = Money.getDefaultCurrency();
for (Object[] savingsDetail : queryResult) {
globalAccountNum = (String) savingsDetail[0];
prdOfferingName = (String) savingsDetail[1];
accountStateId = (Short) savingsDetail[2];
lookupName = (String) savingsDetail[3];
accountStateName = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupName);
// TODO - use default currency or retrieved currency?
currency = (Short) savingsDetail[4];
savingsBalance = new Money(mifosCurrency, (BigDecimal) savingsDetail[5]);
try {
SavingsBO savingsBO = (SavingsBO) new AccountBusinessService().findBySystemId(globalAccountNum);
maxWithdrawalAmount = savingsBO.getSavingsOffering().getMaxAmntWithdrawl().getAmount();
if (savingsBO.getSavingsOffering().getSavingsType().getLookUpValue() != null) {
savingsType = savingsBO.getSavingsOffering().getSavingsType().getName();
}
savingsDetails.add(new SavingsDetailDto(globalAccountNum, prdOfferingName, accountStateId, accountStateName, savingsBalance.toString(), maxWithdrawalAmount, savingsType));
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
return savingsDetails;
}
Aggregations