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 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 PersonnelView getPersonnelView(final PersonnelBO personnel) { PersonnelView personnelView = new PersonnelView(personnel.getPersonnelId(), personnel.getDisplayName()); return personnelView; }