Пример #1
0
 protected boolean isBudgetPersonExistsInPersonnelDetails(
     List<BudgetLineItem> budgetLineItems, BudgetPerson budgetPerson) {
   for (BudgetLineItem budgetLineItem : budgetLineItems) {
     for (BudgetPersonnelDetails budgetPersonnelDetails :
         budgetLineItem.getBudgetPersonnelDetailsList()) {
       if (budgetPersonnelDetails
           .getPersonSequenceNumber()
           .equals(budgetPerson.getPersonSequenceNumber())) {
         return true;
       }
     }
   }
   return false;
 }
Пример #2
0
  /**
   * Gets a Collection of sequence numbers from every lines items personnel details
   *
   * @param budgetLineItems the lines items
   * @return Collection of sequence numbers
   */
  private Collection<Integer> getBudgetPersonSequencesFromPersonnelDetails(
      final Collection<BudgetLineItem> budgetLineItems) {
    assert budgetLineItems != null : "the budgetLineItems is null";

    final Collection<Integer> budgetPersonSequences = new ArrayList<Integer>();

    for (final BudgetLineItem budgetLineItem : budgetLineItems) {
      for (final BudgetPersonnelDetails budgetPersonnelDetails :
          budgetLineItem.getBudgetPersonnelDetailsList()) {
        budgetPersonSequences.add(budgetPersonnelDetails.getPersonSequenceNumber());
      }
    }
    return budgetPersonSequences;
  }
Пример #3
0
 /*
  * Check if this budget person has any budgetdetail set.  This is called before checking whether
  * this person can be deleted.  If retrieve from DB, then it might not be correct because
  * the deleted detail may have not been persisted before delete person is called.
  */
 private boolean isPersonDetailsFound(Budget budget, BudgetPerson budgetPerson) {
   for (BudgetPeriod budgetPeriod : budget.getBudgetPeriods()) {
     for (BudgetLineItem lineItem : budgetPeriod.getBudgetLineItems()) {
       for (BudgetPersonnelDetails budgetPersonnelDetail :
           lineItem.getBudgetPersonnelDetailsList()) {
         if (budgetPersonnelDetail
             .getPersonSequenceNumber()
             .equals(budgetPerson.getPersonSequenceNumber())) {
           return true;
         }
       }
     }
   }
   return false;
 }
 protected BudgetPersonnelDetails getPersonnelDetails(Date startDate, Date endDate) {
   BudgetPersonnelDetails details = new BudgetPersonnelDetails();
   details.setJobCode("AA000");
   details.setPercentCharged(new ScaleTwoDecimal(100L));
   details.setPercentEffort(new ScaleTwoDecimal(100L));
   details.setPersonId("1000001");
   details.setPersonNumber(2);
   details.setSalaryRequested(new ScaleTwoDecimal(100000L));
   if (startDate != null) {
     details.setStartDate(startDate);
   }
   if (endDate != null) {
     details.setEndDate(endDate);
   }
   return details;
 }
Пример #5
0
  /**
   * Updates personnel details job code from a person's job code.
   *
   * @param budgetLineItems the lines items
   * @param person the person
   */
  private void updateJobCodeOnDetailsFromPerson(
      final Collection<BudgetLineItem> budgetLineItems, final BudgetPerson person) {
    assert budgetLineItems != null : "the budgetLineItems is null";
    assert person != null : "the person is null";

    if (person.getJobCode() == null) {
      return;
    }

    for (final BudgetLineItem budgetLineItem : budgetLineItems) {
      for (final BudgetPersonnelDetails budgetPersonnelDetails :
          budgetLineItem.getBudgetPersonnelDetailsList()) {
        if (person
            .getPersonSequenceNumber()
            .equals(budgetPersonnelDetails.getPersonSequenceNumber())) {
          budgetPersonnelDetails.setJobCode(person.getJobCode());
        }
      }
    }
  }
Пример #6
0
  @KcEventMethod
  public boolean addPersonnelCheck(AddPersonnelBudgetEvent event) {
    boolean result = true;
    Budget budget = event.getBudget();
    BudgetPeriod budgetPeriod = event.getBudgetPeriod();
    BudgetLineItem newBudgetLineItem = event.getBudgetLineItem();
    BudgetPersonnelDetails budgetPersonDetails = event.getBudgetPersonnelDetails();
    String errorKey = event.getErrorKey();

    GlobalVariables.getMessageMap().addToErrorPath(errorKey);
    if (dictionaryValidationService.validate(newBudgetLineItem).getNumberOfErrors() > 0) {
      result = false;
    }
    GlobalVariables.getMessageMap().removeFromErrorPath(errorKey);

    if (budgetPeriod == null) {
      GlobalVariables.getMessageMap()
          .putError("viewBudgetPeriod", KeyConstants.ERROR_BUDGET_PERIOD_NOT_SELECTED);
      result = false;
    }
    if (newBudgetLineItem.getCostElement() == null
        || StringUtils.equalsIgnoreCase(newBudgetLineItem.getCostElement(), "")) {
      GlobalVariables.getMessageMap()
          .putError(errorKey, KeyConstants.ERROR_COST_ELEMENT_NOT_SELECTED);
      result = false;
    }
    if (budgetPersonDetails.getPersonSequenceNumber() == null) {
      GlobalVariables.getMessageMap()
          .putError(
              "newBudgetPersonnelDetails.personSequenceNumber",
              KeyConstants.ERROR_BUDGET_PERSONNEL_NOT_SELECTED);
      result = false;
    }
    if (!processCheckJobCodeObjectCodeCombo(budget, budgetPersonDetails, false)) {
      GlobalVariables.getMessageMap()
          .putError(errorKey, KeyConstants.ERROR_JOBCODE_COST_ELEMENT_COMBO_INVALID);
      result = false;
    }
    return result;
  }
Пример #7
0
  @Deprecated
  private boolean personnelDetailsCheck(
      Budget budget,
      BudgetLineItem budgetLineItem,
      BudgetPersonnelDetails budgetPersonnelDetails,
      String errorPath) {
    boolean errorFound = false;
    GlobalVariables.getMessageMap().addToErrorPath(errorPath);

    if (StringUtils.isEmpty(budgetPersonnelDetails.getPeriodTypeCode())) {
      GlobalVariables.getMessageMap()
          .putError("periodTypeCode", KeyConstants.ERROR_REQUIRED_PERIOD_TYPE);
      errorFound = true;
    }

    if (budgetPersonnelDetails.getPercentEffort().isGreaterThan(new ScaleTwoDecimal(100))) {
      GlobalVariables.getMessageMap()
          .putError("percentEffort", KeyConstants.ERROR_PERCENTAGE, Constants.PERCENT_EFFORT_FIELD);
      errorFound = true;
    }
    if (budgetPersonnelDetails.getPercentCharged().isGreaterThan(new ScaleTwoDecimal(100))) {
      GlobalVariables.getMessageMap()
          .putError(
              "percentCharged", KeyConstants.ERROR_PERCENTAGE, Constants.PERCENT_CHARGED_FIELD);
      errorFound = true;
    }
    if (budgetPersonnelDetails
        .getPercentCharged()
        .isGreaterThan(budgetPersonnelDetails.getPercentEffort())) {
      GlobalVariables.getMessageMap()
          .putError("percentCharged", KeyConstants.ERROR_PERCENT_EFFORT_LESS_THAN_PERCENT_CHARGED);
      errorFound = true;
    }
    errorFound =
        errorFound || personnelDatesCheck(budgetLineItem, budgetPersonnelDetails, errorPath);

    GlobalVariables.getMessageMap().removeFromErrorPath(errorPath);
    return errorFound;
  }
Пример #8
0
  @SuppressWarnings("unchecked")
  private List<ValidCeJobCode> getApplicableCostElements(
      Budget budget, BudgetPersonnelDetails newBudgetPersonnelDetails, boolean save) {
    List<ValidCeJobCode> validCostElements = null;

    if (save) {
      String jobCodeValidationEnabledInd =
          this.paramService.getParameterValueAsString(
              Budget.class, Constants.BUDGET_JOBCODE_VALIDATION_ENABLED);

      Map<String, Object> fieldValues = new HashMap<String, Object>();
      BudgetPerson budgetPerson = null;

      if (StringUtils.isNotEmpty(jobCodeValidationEnabledInd)
          && jobCodeValidationEnabledInd.equals("Y")) {

        List<BudgetPerson> budgetPersons = budget.getBudgetPersons();
        for (BudgetPerson tmpBudgetPerson : budgetPersons) {
          if (tmpBudgetPerson.getPersonSequenceNumber().intValue()
              == newBudgetPersonnelDetails.getPersonSequenceNumber().intValue()) {
            budgetPerson = tmpBudgetPerson;
            break;
          }
        }
        if (budgetPerson != null && StringUtils.isNotEmpty(budgetPerson.getJobCode())) {
          fieldValues.put("jobCode", budgetPerson.getJobCode().toUpperCase());
          validCostElements =
              (List<ValidCeJobCode>) this.boService.findMatching(ValidCeJobCode.class, fieldValues);
        }
      }

    } else {
      validCostElements =
          budgetPersonService.getApplicableCostElements(
              budget, newBudgetPersonnelDetails.getPersonSequenceNumber().toString());
    }

    return validCostElements;
  }
Пример #9
0
 private void addSalaryDataForCostElement(
     CostElement costElement, List<SalaryTypeVO> salaryTypeVoList) {
   SalaryTypeVO groupVO = new SalaryTypeVO();
   groupVO.setCostElement(costElement.getDescription());
   salaryTypeVoList.add(groupVO);
   for (BudgetPersonnelDetails details : budget.getObjectCodePersonnelList().get(costElement)) {
     SalaryTypeVO salaryTypeVoPerPerson = new SalaryTypeVO();
     salaryTypeVoPerPerson.setName(details.getBudgetPerson().getPersonName());
     salaryTypeVoPerPerson.setBudgetPeriodVOs(
         getBudgetPeriodData(
             budget
                 .getObjectCodePersonnelSalaryTotals()
                 .get(costElement.getCostElement() + "," + details.getPersonId())));
     salaryTypeVoList.add(salaryTypeVoPerPerson);
   }
   if (budget.getObjectCodePersonnelSalaryTotals().get(costElement.getCostElement()) != null) {
     SalaryTypeVO salaryTypeVoPerPerson = new SalaryTypeVO();
     salaryTypeVoPerPerson.setName("Summary Line Item");
     salaryTypeVoPerPerson.setBudgetPeriodVOs(
         getBudgetPeriodData(
             budget.getObjectCodePersonnelSalaryTotals().get(costElement.getCostElement())));
     salaryTypeVoList.add(salaryTypeVoPerPerson);
   }
 }
Пример #10
0
  protected boolean processCheckJobCodeObjectCodeCombo(
      Budget budget, BudgetPersonnelDetails newBudgetPersonnelDetails, boolean save) {
    List<ValidCeJobCode> validCostElements = null;
    boolean isValid = false;

    validCostElements = getApplicableCostElements(budget, newBudgetPersonnelDetails, save);

    if (CollectionUtils.isEmpty(validCostElements)) {
      isValid = true;
    } else {
      for (ValidCeJobCode validCeJobCode : validCostElements) {
        if (validCeJobCode
            .getCostElement()
            .equalsIgnoreCase(newBudgetPersonnelDetails.getCostElement())) {
          isValid = true;
          break;
        }
      }
    }

    return isValid;
  }
Пример #11
0
  /**
   * This method checks business rules related to Budget Personnel Budget functionality
   *
   * @param budgetDocument
   * @return
   */
  protected boolean processBudgetPersonnelBudgetBusinessRules(BudgetDocument budgetDocument) {
    boolean valid = true;

    MessageMap errorMap = GlobalVariables.getMessageMap();

    List<BudgetPeriod> budgetPeriods = budgetDocument.getBudget().getBudgetPeriods();
    int i = 0;
    int j = 0;
    int k = 0;
    for (BudgetPeriod budgetPeriod : budgetPeriods) {
      j = 0;
      List<BudgetLineItem> budgetLineItems = budgetPeriod.getBudgetLineItems();
      k = 0;
      for (BudgetLineItem budgetLineItem : budgetLineItems) {
        for (BudgetPersonnelDetails budgetPersonnelDetails :
            budgetLineItem.getBudgetPersonnelDetailsList()) {
          if (budgetPersonnelDetails != null
              && budgetPersonnelDetails.getStartDate() != null
              && budgetPersonnelDetails.getStartDate().before(budgetLineItem.getStartDate())) {
            errorMap.putError(
                "budgetPeriod["
                    + i
                    + "].budgetLineItems["
                    + j
                    + "].budgetPersonnelDetailsList["
                    + k
                    + "].startDate",
                KeyConstants.ERROR_PERSONNELBUDGETLINEITEM_STARTDATE_BEFORE_LINEITEM_STARTDATE);
            valid = false;
          }
          if (budgetPersonnelDetails != null
              && budgetPersonnelDetails.getEndDate() != null
              && budgetPersonnelDetails.getEndDate().after(budgetLineItem.getEndDate())) {
            errorMap.putError(
                "budgetPeriod["
                    + i
                    + "].budgetLineItems["
                    + j
                    + "].budgetPersonnelDetailsList["
                    + k
                    + "].endDate",
                KeyConstants.ERROR_PERSONNELBUDGETLINEITEM_ENDDATE_AFTER_LINEITEM_ENDDATE);
            valid = false;
          }
          if (budgetPersonnelDetails.getPercentEffort().isGreaterThan(new ScaleTwoDecimal(100))) {
            errorMap.putError(
                "budgetPeriod["
                    + i
                    + "].budgetLineItems["
                    + j
                    + "].budgetPersonnelDetailsList["
                    + k
                    + "].percentEffort",
                KeyConstants.ERROR_PERCENTAGE,
                Constants.PERCENT_EFFORT_FIELD);
          }
          if (budgetPersonnelDetails.getPercentCharged().isGreaterThan(new ScaleTwoDecimal(100))) {
            errorMap.putError(
                "budgetPeriod["
                    + i
                    + "].budgetLineItems["
                    + j
                    + "].budgetPersonnelDetailsList["
                    + k
                    + "].percentCharged",
                KeyConstants.ERROR_PERCENTAGE,
                Constants.PERCENT_CHARGED_FIELD);
          }
          if (budgetPersonnelDetails
              .getPercentCharged()
              .isGreaterThan(budgetPersonnelDetails.getPercentEffort())) {
            errorMap.putError(
                "budgetPeriod["
                    + i
                    + "].budgetLineItems["
                    + j
                    + "].budgetPersonnelDetailsList["
                    + k
                    + "].percentCharged",
                KeyConstants.ERROR_PERCENT_EFFORT_LESS_THAN_PERCENT_CHARGED);
          }
          k++;
        }
        j++;
      }
      i++;
    }
    return valid;
  }
Пример #12
0
  @Deprecated
  private boolean personnelDatesCheck(
      BudgetLineItem budgetLineItem,
      BudgetPersonnelDetails budgetPersonnelDetails,
      String errorPath) {
    boolean errorFound = false;

    if (budgetPersonnelDetails.getStartDate() == null) {
      GlobalVariables.getMessageMap()
          .putError(
              "startDate",
              RiceKeyConstants.ERROR_REQUIRED,
              new String[] {"Start Date (Start Date)"});
      errorFound = true;
    }
    if (budgetPersonnelDetails.getEndDate() == null) {
      GlobalVariables.getMessageMap()
          .putError(
              "endDate", RiceKeyConstants.ERROR_REQUIRED, new String[] {"End Date (End Date)"});
      errorFound = true;
    }

    if (!errorFound) {
      if (budgetPersonnelDetails.getEndDate().compareTo(budgetPersonnelDetails.getStartDate())
          < 0) {
        GlobalVariables.getMessageMap()
            .putError("endDate", KeyConstants.ERROR_PERSONNEL_DETAIL_DATES);
        errorFound = true;
      }
      if (budgetLineItem.getEndDate().compareTo(budgetPersonnelDetails.getEndDate()) < 0) {
        GlobalVariables.getMessageMap()
            .putError(
                "endDate",
                KeyConstants.ERROR_PERSONNEL_DETAIL_END_DATE,
                new String[] {"can not be after", "end date"});
        errorFound = true;
      }
      if (budgetLineItem.getStartDate().compareTo(budgetPersonnelDetails.getEndDate()) > 0) {
        GlobalVariables.getMessageMap()
            .putError(
                "endDate",
                KeyConstants.ERROR_PERSONNEL_DETAIL_END_DATE,
                new String[] {"can not be before", "start date"});
        errorFound = true;
      }
      if (budgetLineItem.getStartDate().compareTo(budgetPersonnelDetails.getStartDate()) > 0) {
        GlobalVariables.getMessageMap()
            .putError(
                "startDate",
                KeyConstants.ERROR_PERSONNEL_DETAIL_START_DATE,
                new String[] {"can not be before", "start date"});
        errorFound = true;
      }
      if (budgetLineItem.getEndDate().compareTo(budgetPersonnelDetails.getStartDate()) < 0) {
        GlobalVariables.getMessageMap()
            .putError(
                "startDate",
                KeyConstants.ERROR_PERSONNEL_DETAIL_START_DATE,
                new String[] {"can not be after", "end date"});
        errorFound = true;
      }
    }

    return errorFound;
  }
  protected BudgetLineItem getPersonnelLineItem(
      BudgetPeriod budgetPeriod, Date startDate, Date endDate) {
    BudgetLineItem lineItem = new BudgetLineItemMock();
    lineItem.setBudgetCategory(createBudgetCategory("26", "Test", "E"));
    lineItem.setBudgetCategoryCode("26");
    lineItem.setCostElement("400350");
    lineItem.setLineItemCost(new ScaleTwoDecimal(10000.00));
    lineItem.setEndDate(endDate);
    lineItem.setStartDate(startDate);
    lineItem.setCostElementBO(getCostElementTravel());
    lineItem.setApplyInRateFlag(Boolean.TRUE);
    lineItem.setOnOffCampusFlag(Boolean.TRUE);
    lineItem.setBudgetPeriodBO(budgetPeriod);
    lineItem.setBudgetPeriod(1);
    lineItem.setBudgetLineItemId(5L);
    lineItem.setLineItemNumber(3);
    lineItem.setBudgetCategoryCode(PERSONNEL_CATEGORY_CODE);
    final BudgetCategory budgetCategory = new BudgetCategory();
    budgetCategory.setBudgetCategoryTypeCode(PERSONNEL_CATEGORY_CODE);
    lineItem.setBudgetCategory(budgetCategory);

    BudgetPersonnelDetails budgetPersonnelDetails = new BudgetPersonnelDetails();
    budgetPersonnelDetails.setLineItemNumber(3);
    budgetPersonnelDetails.setPersonNumber(1);
    budgetPersonnelDetails.setOnOffCampusFlag(Boolean.TRUE);
    budgetPersonnelDetails.setEndDate(endDate);
    budgetPersonnelDetails.setStartDate(startDate);
    budgetPersonnelDetails.setApplyInRateFlag(Boolean.TRUE);
    budgetPersonnelDetails.setJobCode("AA000");
    budgetPersonnelDetails.setPercentCharged(ScaleTwoDecimal.ONE_HUNDRED);
    budgetPersonnelDetails.setPercentEffort(ScaleTwoDecimal.ONE_HUNDRED);
    budgetPersonnelDetails.setPersonId("10000000002");
    budgetPersonnelDetails.setSalaryRequested(new ScaleTwoDecimal(102000L));
    budgetPersonnelDetails.setCostElement("400350");
    budgetPersonnelDetails.setCostElementBO(getCostElementPersonnel());
    budgetPersonnelDetails.setBudgetLineItem(lineItem);
    budgetPersonnelDetails.setBudgetPeriod(1);
    budgetPersonnelDetails.setBudgetPeriodBO(budgetPeriod);
    lineItem.getBudgetPersonnelDetailsList().add(budgetPersonnelDetails);
    lineItem.setCostElementBO(getCostElementPersonnel());
    return lineItem;
  }