@Override public void addNoteToPersonnel(Short personnelId, String comment) { MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); UserContext userContext = toUserContext(user); try { PersonnelBO personnel = this.personnelDao.findPersonnelById(personnelId); PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId()); if (personnel != null) { checkPermissionForAddingNotesToPersonnel( userContext, personnel.getOffice().getOfficeId(), personnel.getPersonnelId()); } this.transactionHelper.startTransaction(); PersonnelNotesEntity personnelNote = new PersonnelNotesEntity(comment, loggedInUser, personnel); personnel.addNotes(userContext.getId(), personnelNote); this.personnelDao.save(personnel); this.transactionHelper.commitTransaction(); } catch (Exception e) { this.transactionHelper.rollbackTransaction(); throw new MifosRuntimeException(e); } finally { this.transactionHelper.closeSession(); } }
private Short extractLoanOfficerId(CustomerBO customer) { Short loanOfficerId = null; PersonnelBO loanOfficer = customer.getPersonnel(); if (loanOfficer != null) { loanOfficerId = loanOfficer.getPersonnelId(); } return loanOfficerId; }
private void checkPermissionForAdjustment(AccountBO accountBO) throws ServiceException { AccountPaymentEntity lastPmntToBeAdjusted = accountBO.getLastPmntToBeAdjusted(); if (lastPmntToBeAdjusted == null) return; UserContext userContext = accountBO.getUserContext(); Date lastPaymentDate = lastPmntToBeAdjusted.getPaymentDate(); PersonnelBO personnel = accountBO.getPersonnel(); Short personnelId = personnel != null ? personnel.getPersonnelId() : userContext.getId(); Short officeId = accountBO.getOfficeId(); accountBusinessService.checkPermissionForAdjustment( AccountTypes.LOAN_ACCOUNT, null, userContext, officeId, personnelId); accountBusinessService.checkPermissionForAdjustmentOnBackDatedPayments( lastPaymentDate, userContext, officeId, personnelId); }
private PersonnelBO createPersonnel(OfficeBO office, PersonnelLevel personnelLevel) throws Exception { List<CustomFieldDto> customFieldDto = new ArrayList<CustomFieldDto>(); customFieldDto.add( new CustomFieldDto(Short.valueOf("9"), "123456", CustomFieldType.NUMERIC.getValue())); Address address = new Address("abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd"); Name name = new Name("XYZ", null, null, null); java.util.Date date = new java.util.Date(); personnel = new PersonnelBO( personnelLevel, office, Integer.valueOf("1"), Short.valueOf("1"), "ABCD", "XYZ", "*****@*****.**", null, customFieldDto, name, "111111", date, Integer.valueOf("1"), Integer.valueOf("1"), date, date, address, userContext.getId()); IntegrationTestObjectMother.createPersonnel(personnel); return IntegrationTestObjectMother.findPersonnelById(personnel.getPersonnelId()); }
@Override public CustomerNoteFormDto retrieveCustomerNote(String globalCustNum) { MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); UserContext userContext = toUserContext(user); CustomerBO customer = this.customerDao.findCustomerBySystemId(globalCustNum); PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId()); Integer customerLevel = customer.getCustomerLevel().getId().intValue(); String globalNum = customer.getGlobalCustNum(); String displayName = customer.getDisplayName(); LocalDate commentDate = new LocalDate(); String commentUser = loggedInUser.getDisplayName(); return new CustomerNoteFormDto( globalNum, displayName, customerLevel, commentDate, commentUser, ""); }
@TransactionDemarcate(joinToken = true) public ActionForward load( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { logger.debug("In CustomerNotesAction::load()"); clearActionForm(form); UserContext userContext = getUserContext(request); CustomerBO customerBO = getCustomerBusinessService() .getCustomer(Integer.valueOf(((CustomerNotesActionForm) form).getCustomerId())); customerBO.setUserContext(userContext); setFormAttributes(userContext, form, customerBO); PersonnelBO personnelBO = new PersonnelPersistence().getPersonnel(userContext.getId()); SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request); SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerBO, request); SessionUtils.setAttribute( CustomerConstants.PERSONNEL_NAME, personnelBO.getDisplayName(), request); return mapping.findForward(ActionForwards.load_success.toString()); }
public String getPersonnelName() { return personnel.getDisplayName(); }
private PersonnelView getPersonnelView(final PersonnelBO personnel) { PersonnelView personnelView = new PersonnelView(personnel.getPersonnelId(), personnel.getDisplayName()); return personnelView; }