/**
   * This method is checks individual line item start and end dates for validity and proper
   * ordering.
   *
   * @param currentBudgetPeriod the period containing the line item
   * @param budgetLineItem the number of the line item
   * @return true if the dates are valid, false otherwise
   */
  protected boolean processCheckLineItemDates(
      BudgetPeriod currentBudgetPeriod, BudgetLineItem budgetLineItem, String errorPath) {
    boolean valid = true;
    MessageMap errorMap = getGlobalVariableService().getMessageMap();

    if (budgetLineItem.getEndDate() == null) {
      errorMap.putError(errorPath + END_DATE, KeyConstants.ERROR_REQUIRED, UPPER_END_DATE);
      valid = false;
    }

    if (budgetLineItem.getStartDate() == null) {
      errorMap.putError(errorPath + START_DATE, KeyConstants.ERROR_REQUIRED, UPPER_START_DATE);
      valid = false;
    }

    if (!valid) return valid;

    if (budgetLineItem.getEndDate().compareTo(budgetLineItem.getStartDate()) < 0) {
      errorMap.putError(errorPath + END_DATE, KeyConstants.ERROR_LINE_ITEM_DATES);
      valid = false;
    }

    if (currentBudgetPeriod.getEndDate().compareTo(budgetLineItem.getEndDate()) < 0) {
      errorMap.putError(
          errorPath + END_DATE,
          KeyConstants.ERROR_LINE_ITEM_END_DATE,
          new String[] {CAN_NOT_BE_AFTER, LOWER_END_DATE});
      valid = false;
    }
    if (currentBudgetPeriod.getStartDate().compareTo(budgetLineItem.getEndDate()) > 0) {
      errorMap.putError(
          errorPath + END_DATE,
          KeyConstants.ERROR_LINE_ITEM_END_DATE,
          new String[] {CAN_NOT_BE_BEFORE, LOWER_START_DATE});
      valid = false;
    }
    if (currentBudgetPeriod.getStartDate().compareTo(budgetLineItem.getStartDate()) > 0) {
      errorMap.putError(
          errorPath + START_DATE,
          KeyConstants.ERROR_LINE_ITEM_START_DATE,
          new String[] {CAN_NOT_BE_BEFORE, LOWER_START_DATE});
      valid = false;
    }
    if (currentBudgetPeriod.getEndDate().compareTo(budgetLineItem.getStartDate()) < 0) {
      errorMap.putError(
          errorPath + START_DATE,
          KeyConstants.ERROR_LINE_ITEM_START_DATE,
          new String[] {CAN_NOT_BE_AFTER, LOWER_END_DATE});
      valid = false;
    }

    return valid;
  }
示例#2
0
  /**
   * This method checks business rules related to Budget Expenses functionality
   *
   * @param budgetDocument
   * @return
   */
  protected boolean processBudgetExpenseBusinessRules(BudgetDocument budgetDocument) {
    boolean valid = true;

    MessageMap errorMap = GlobalVariables.getMessageMap();

    List<BudgetPeriod> budgetPeriods = budgetDocument.getBudget().getBudgetPeriods();
    int i = 0;
    int j = 0;
    for (BudgetPeriod budgetPeriod : budgetPeriods) {
      j = 0;
      List<BudgetLineItem> budgetLineItems = budgetPeriod.getBudgetLineItems();
      for (BudgetLineItem budgetLineItem : budgetLineItems) {
        if (budgetLineItem != null
            && budgetLineItem.getStartDate() != null
            && budgetLineItem.getStartDate().before(budgetPeriod.getStartDate())) {
          errorMap.putError(
              "budgetCategoryTypes["
                  + budgetLineItem.getBudgetCategory().getBudgetCategoryTypeCode()
                  + "].budgetPeriods["
                  + i
                  + "].budgetLineItems["
                  + j
                  + "].startDate",
              KeyConstants.ERROR_LINEITEM_STARTDATE_BEFORE_PERIOD_STARTDATE);
          valid = false;
        }
        if (budgetLineItem != null
            && budgetLineItem.getEndDate() != null
            && budgetLineItem.getEndDate().after(budgetPeriod.getEndDate())) {
          errorMap.putError(
              "budgetCategoryTypes["
                  + budgetLineItem.getBudgetCategory().getBudgetCategoryTypeCode()
                  + "].budgetPeriods["
                  + i
                  + "].budgetLineItems["
                  + j
                  + "].endDate",
              KeyConstants.ERROR_LINEITEM_ENDDATE_AFTER_PERIOD_ENDDATE);
          valid = false;
        }

        if (budgetLineItem != null
            && budgetLineItem.getQuantity() != null
            && budgetLineItem.getQuantity().intValue() < 0) {
          errorMap.putError(
              "budgetPeriod[" + i + "].budgetLineItem[" + j + "].quantity",
              KeyConstants.ERROR_NEGATIVE_AMOUNT,
              "Quantity");
          valid = false;
        }

        j++;
      }
      i++;
    }
    return valid;
  }
 public BudgetPersonnelDetails(BudgetLineItem personnelBudgetSummaryLineItem) {
   initializeBudgetPersonnelDetails();
   this.budgetLineItem = personnelBudgetSummaryLineItem;
   this.startDate = personnelBudgetSummaryLineItem.getStartDate();
   this.endDate = personnelBudgetSummaryLineItem.getEndDate();
   this.budgetPeriod = personnelBudgetSummaryLineItem.getBudgetPeriod();
   this.budgetId = personnelBudgetSummaryLineItem.getBudgetId();
   this.salaryRequested = personnelBudgetSummaryLineItem.getLineItemCost();
   this.personSequenceNumber =
       BudgetConstants.BudgetPerson.SUMMARYPERSON.getPersonSequenceNumber();
   this.personId = BudgetConstants.BudgetPerson.SUMMARYPERSON.getPersonId();
 }
 protected BudgetPersonnelRateAndBase getNewBudgetPersonnelRateAndBase(
     ScaleTwoDecimal applicableRate,
     String rateClassCode,
     String rateTypeCode,
     ScaleTwoDecimal calculatedCost,
     ScaleTwoDecimal baseCost,
     String rateClassTypeCode,
     BudgetLineItem lineItem) {
   BudgetPersonnelRateAndBase rateAndBase = new BudgetPersonnelRateAndBaseMock();
   rateAndBase.setRateClassCode(rateClassCode);
   rateAndBase.setRateTypeCode(rateTypeCode);
   rateAndBase.setAppliedRate(applicableRate);
   rateAndBase.setCalculatedCost(calculatedCost);
   rateAndBase.setCalculatedCostSharing(ScaleTwoDecimal.ZERO);
   rateAndBase.setSalaryRequested(baseCost);
   rateAndBase.setRateClass(new RateClass());
   rateAndBase.getRateClass().setRateClassTypeCode(rateClassTypeCode);
   rateAndBase.setStartDate(lineItem.getStartDate());
   rateAndBase.setEndDate(lineItem.getEndDate());
   return rateAndBase;
 }
示例#5
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;
  }
  @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;
  }