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());
  }
Ejemplo n.º 2
0
  @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();
    }
  }
Ejemplo n.º 3
0
 private Short extractLoanOfficerId(CustomerBO customer) {
   Short loanOfficerId = null;
   PersonnelBO loanOfficer = customer.getPersonnel();
   if (loanOfficer != null) {
     loanOfficerId = loanOfficer.getPersonnelId();
   }
   return loanOfficerId;
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
 private PersonnelView getPersonnelView(final PersonnelBO personnel) {
   PersonnelView personnelView =
       new PersonnelView(personnel.getPersonnelId(), personnel.getDisplayName());
   return personnelView;
 }