Пример #1
0
  /**
   * This method checks business rules related to Budget Expenses functionality
   *
   * @param budgetDocument
   * @return
   */
  protected boolean processBudgetExpenseBusinessRules(BudgetDocument budgetDocument) {
    boolean valid = true;
    // TODO - put budget expense validation rules here.
    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.getCostSharingAmount() != null
        // && budgetLineItem.getCostSharingAmount().isNegative()) {
        //                    errorMap.putError("budgetPeriod[" + i +"].budgetLineItem[" + j +
        // "].costSharingAmount", KeyConstants.ERROR_NEGATIVE_AMOUNT,"Cost Sharing");
        //                    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;
        }
        //                if (budgetLineItem!=null && budgetLineItem.getLineItemCost() != null &&
        // budgetLineItem.getLineItemCost().isNegative()) {
        //                    errorMap.putError("budgetPeriod[" + i +"].budgetLineItem[" + j +
        // "].lineItemCost", KeyConstants.ERROR_NEGATIVE_AMOUNT,"Total Base Cost");
        //                    valid = false;
        //                }
        //                if(budgetLineItem.getEndDate().compareTo(budgetLineItem.getStartDate())
        // <=0 ) {
        //
        // errorMap.putError("budgetPeriod["+i+"].budgetLineItem["+j+"].endDate",
        // KeyConstants.ERROR_LINE_ITEM_DATES);
        //                        return false;
        //                }

        j++;
      }
      i++;
    }
    return valid;
  }
Пример #2
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;
  }
  private boolean personnelDatesCheck(
      BudgetLineItem budgetLineItem,
      BudgetPersonnelDetails budgetPersonnelDetails,
      int selectedBudgetPeriodIndex,
      int selectedBudgetLineItemIndex,
      int detailIndex) {
    boolean errorFound = false;
    if (budgetPersonnelDetails.getEndDate().compareTo(budgetPersonnelDetails.getStartDate()) < 0) {
      GlobalVariables.getMessageMap()
          .putError(
              "budgetPeriod["
                  + selectedBudgetPeriodIndex
                  + "].budgetLineItems["
                  + selectedBudgetLineItemIndex
                  + "].budgetPersonnelDetailsList["
                  + detailIndex
                  + "].endDate",
              KeyConstants.ERROR_PERSONNEL_DETAIL_DATES);
      errorFound = true;
    }
    if (budgetLineItem.getEndDate().compareTo(budgetPersonnelDetails.getEndDate()) < 0) {
      GlobalVariables.getMessageMap()
          .putError(
              "budgetPeriod["
                  + selectedBudgetPeriodIndex
                  + "].budgetLineItems["
                  + selectedBudgetLineItemIndex
                  + "].budgetPersonnelDetailsList["
                  + detailIndex
                  + "].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(
              "budgetPeriod["
                  + selectedBudgetPeriodIndex
                  + "].budgetLineItems["
                  + selectedBudgetLineItemIndex
                  + "].budgetPersonnelDetailsList["
                  + detailIndex
                  + "].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(
              "budgetPeriod["
                  + selectedBudgetPeriodIndex
                  + "].budgetLineItems["
                  + selectedBudgetLineItemIndex
                  + "].budgetPersonnelDetailsList["
                  + detailIndex
                  + "].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(
              "budgetPeriod["
                  + selectedBudgetPeriodIndex
                  + "].budgetLineItems["
                  + selectedBudgetLineItemIndex
                  + "].budgetPersonnelDetailsList["
                  + detailIndex
                  + "].startDate",
              KeyConstants.ERROR_PERSONNEL_DETAIL_START_DATE,
              new String[] {"can not be after", "end date"});
      errorFound = true;
    }

    return errorFound;
  }