Example #1
0
  public ActionForward summaryTotals(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    BudgetForm budgetForm = (BudgetForm) form;
    BudgetDocument budgetDocument = budgetForm.getDocument();
    populatePersonnelRoles(budgetDocument);
    Budget budget = budgetDocument.getBudget();
    for (BudgetPeriod period : budget.getBudgetPeriods()) {
      for (BudgetLineItem lineItem : period.getBudgetLineItems()) {
        for (BudgetPersonnelDetails budgetPersonnelDetails :
            lineItem.getBudgetPersonnelDetailsList()) {
          budgetPersonnelDetails.refreshReferenceObject("budgetPerson");
        }
      }
    }

    budget.getBudgetTotals();
    budgetForm.setProposalHierarchyIndirectObjectCode(
        getParameterService()
            .getParameterValue(
                BudgetDocument.class, "proposalHierarchySubProjectIndirectCostElement"));
    return mapping.findForward(Constants.BUDGET_SUMMARY_TOTALS_PAGE);
  }
 private void updatePersonnelBudgetRate(BudgetLineItem budgetLineItem) {
   int j = 0;
   for (BudgetPersonnelDetails budgetPersonnelDetails :
       budgetLineItem.getBudgetPersonnelDetailsList()) {
     j = 0;
     for (BudgetPersonnelCalculatedAmount budgetPersonnelCalculatedAmount :
         budgetPersonnelDetails.getBudgetPersonnelCalculatedAmounts()) {
       budgetPersonnelCalculatedAmount.setApplyRateFlag(
           budgetLineItem.getBudgetLineItemCalculatedAmounts().get(j).getApplyRateFlag());
       j++;
     }
   }
 }
Example #3
0
  private void copyLineItemToPersonnelDetails(BudgetDocument budgetDocument) {
    for (BudgetPeriod budgetPeriod : budgetDocument.getBudget().getBudgetPeriods()) {
      if (budgetPeriod.getBudgetLineItems() != null
          && !budgetPeriod.getBudgetLineItems().isEmpty()) {
        for (BudgetLineItem budgetLineItem : budgetPeriod.getBudgetLineItems()) {

          if (budgetLineItem.getBudgetPersonnelDetailsList() != null
              && !budgetLineItem.getBudgetPersonnelDetailsList().isEmpty()) {
            for (BudgetPersonnelDetails budgetPersonnelDetails :
                budgetLineItem.getBudgetPersonnelDetailsList()) {
              //
              // budgetPersonnelDetails.setProposalNumber(budgetLineItem.getProposalNumber());
              //
              // budgetPersonnelDetails.setBudgetVersionNumber(budgetLineItem.getBudgetVersionNumber());
              budgetPersonnelDetails.setBudgetId(budgetLineItem.getBudgetId());
              budgetPersonnelDetails.setBudgetPeriod(budgetLineItem.getBudgetPeriod());
              budgetPersonnelDetails.setLineItemNumber(budgetLineItem.getLineItemNumber());
              budgetPersonnelDetails.setCostElement(budgetLineItem.getCostElement());
              budgetPersonnelDetails.setCostElementBO(budgetLineItem.getCostElementBO());
            }
          }
        }
      }
    }
  }
Example #4
0
  public ActionForward personnel(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    BudgetForm budgetForm = (BudgetForm) form;
    populatePersonnelHierarchySummary(budgetForm);
    populatePersonnelCategoryTypeCodes(budgetForm);
    if (budgetForm.getBudgetDocument().getBudget().getBudgetPersons().isEmpty()) {
      KraServiceLocator.getService(BudgetPersonService.class)
          .synchBudgetPersonsToProposal(budgetForm.getBudgetDocument().getBudget());
    }
    reconcilePersonnelRoles(budgetForm.getDocument());
    BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
    Budget budget = budgetDocument.getBudget();
    for (BudgetPeriod period : budget.getBudgetPeriods()) {
      for (BudgetLineItem lineItem : period.getBudgetLineItems()) {
        for (BudgetPersonnelDetails budgetPersonnelDetails :
            lineItem.getBudgetPersonnelDetailsList()) {
          budgetPersonnelDetails.refreshReferenceObject("budgetPerson");
          ObjectUtils.materializeObjects(
              budgetPersonnelDetails.getBudgetPersonnelCalculatedAmounts());
          for (BudgetPersonnelCalculatedAmount budgetPersonnelCalculatedAmount :
              budgetPersonnelDetails.getBudgetPersonnelCalculatedAmounts()) {
            if (budgetPersonnelCalculatedAmount.getRateClass() == null) {
              budgetPersonnelCalculatedAmount.refreshReferenceObject("rateClass");
            }
          }
        }

        for (BudgetLineItemCalculatedAmount lineItemCalculatedAmount :
            lineItem.getBudgetLineItemCalculatedAmounts()) {
          if (lineItemCalculatedAmount.getRateClass() == null) {
            lineItemCalculatedAmount.refreshReferenceObject("rateClass");
          }
        }
      }
    }
    return mapping.findForward(Constants.BUDGET_PERSONNEL_PAGE);
  }
 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);
   }
 }
  public ActionForward deleteBudgetPersonnelDetails(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    BudgetForm budgetForm = (BudgetForm) form;
    BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
    Budget budget = budgetDocument.getBudget();
    int selectedBudgetPeriodIndex = budgetForm.getViewBudgetPeriod() - 1;
    int selectedBudgetLineItemIndex = budgetForm.getSelectedBudgetLineItemIndex();
    BudgetPersonnelBudgetService budgetPersonnelBudgetService =
        KraServiceLocator.getService(BudgetPersonnelBudgetService.class);
    budgetPersonnelBudgetService.deleteBudgetPersonnelDetails(
        budget, selectedBudgetPeriodIndex, selectedBudgetLineItemIndex, getLineToDelete(request));
    HashMap uniqueBudgetPersonnelCount = new HashMap();
    int qty = 0;
    for (BudgetPersonnelDetails budgetPersonnelDetails :
        budget
            .getBudgetPeriod(selectedBudgetPeriodIndex)
            .getBudgetLineItem(selectedBudgetLineItemIndex)
            .getBudgetPersonnelDetailsList()) {
      if (!uniqueBudgetPersonnelCount.containsValue(budgetPersonnelDetails.getPersonId())) {
        uniqueBudgetPersonnelCount.put(qty, budgetPersonnelDetails.getPersonId());
        qty = qty + 1;
      }
    }
    budget
        .getBudgetPeriod(selectedBudgetPeriodIndex)
        .getBudgetLineItem(selectedBudgetLineItemIndex)
        .setQuantity(new Integer(qty));

    getCalculationService()
        .calculateBudgetPeriod(budget, budget.getBudgetPeriod(selectedBudgetPeriodIndex));
    return mapping.findForward(Constants.MAPPING_BASIC);
  }
Example #7
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;
  }
  /**
   * This method is used to add a new Budget Line Item
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return mapping forward
   * @throws Exception
   */
  public ActionForward addBudgetPersonnelDetails(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    BudgetForm budgetForm = (BudgetForm) form;
    BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
    Budget budget = budgetDocument.getBudget();
    int selectedBudgetPeriodIndex = budgetForm.getViewBudgetPeriod() - 1;
    int selectedBudgetLineItemIndex = budgetForm.getSelectedBudgetLineItemIndex();
    BudgetPersonnelDetails newBudgetPersonnelDetails = budgetForm.getNewBudgetPersonnelDetails();

    boolean errorFound = false;
    if (newBudgetPersonnelDetails.getPercentEffort().isGreaterThan(new BudgetDecimal(100))) {
      GlobalVariables.getMessageMap()
          .putError(
              "newBudgetPersonnelDetails.percentEffort",
              KeyConstants.ERROR_PERCENTAGE,
              Constants.PERCENT_EFFORT_FIELD);
      errorFound = true;
    }
    if (newBudgetPersonnelDetails.getPercentCharged().isGreaterThan(new BudgetDecimal(100))) {
      GlobalVariables.getMessageMap()
          .putError(
              "newBudgetPersonnelDetails.percentCharged",
              KeyConstants.ERROR_PERCENTAGE,
              Constants.PERCENT_CHARGED_FIELD);
      errorFound = true;
    }
    if (newBudgetPersonnelDetails
        .getPercentCharged()
        .isGreaterThan(newBudgetPersonnelDetails.getPercentEffort())) {
      GlobalVariables.getMessageMap()
          .putError(
              "newBudgetPersonnelDetails.percentCharged",
              KeyConstants.ERROR_PERCENT_EFFORT_LESS_THAN_PERCENT_CHARGED);
      errorFound = true;
    }
    if (StringUtils.isBlank((budgetForm.getNewBudgetPersonnelDetails().getPeriodTypeCode()))) {
      GlobalVariables.getMessageMap()
          .putError(
              "newBudgetPersonnelDetails.periodTypeCode",
              RiceKeyConstants.ERROR_REQUIRED,
              new String[] {"Period Type (Period Type)"});
      errorFound = true;
    }
    if (budgetForm.getNewBudgetPersonnelDetails().getPersonSequenceNumber() == null) {
      GlobalVariables.getMessageMap()
          .putError(
              "newBudgetPersonnelDetails.personSequenceNumber",
              RiceKeyConstants.ERROR_REQUIRED,
              new String[] {"Person (Person)"});
      errorFound = true;
    }

    HashMap uniqueBudgetPersonnelCount = new HashMap();
    int qty = 0;
    if (!errorFound) {
      BudgetPersonnelBudgetService budgetPersonnelBudgetService =
          KraServiceLocator.getService(BudgetPersonnelBudgetService.class);
      for (BudgetPersonnelDetails budgetPersonnelDetails :
          budget
              .getBudgetPeriod(selectedBudgetPeriodIndex)
              .getBudgetLineItem(selectedBudgetLineItemIndex)
              .getBudgetPersonnelDetailsList()) {
        if (!uniqueBudgetPersonnelCount.containsValue(budgetPersonnelDetails.getPersonId())) {
          uniqueBudgetPersonnelCount.put(qty, budgetPersonnelDetails.getPersonId());
          qty = qty + 1;
        }
      }
      budget
          .getBudgetPeriod(selectedBudgetPeriodIndex)
          .getBudgetLineItem(selectedBudgetLineItemIndex)
          .setQuantity(new Integer(qty));
      updatePersonnelBudgetRate(
          budget
              .getBudgetPeriod(selectedBudgetPeriodIndex)
              .getBudgetLineItem(selectedBudgetLineItemIndex));
      getCalculationService()
          .calculateBudgetPeriod(budget, budget.getBudgetPeriod(selectedBudgetPeriodIndex));
    }
    return mapping.findForward(Constants.MAPPING_BASIC);
  }
  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;
  }
 /**
  * This method calculates the salary
  *
  * @param mapping
  * @param form
  * @param request
  * @param response
  * @return mapping forward
  * @throws Exception
  */
 public ActionForward calculateSalary(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   BudgetForm budgetForm = (BudgetForm) form;
   BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
   Budget budget = budgetDocument.getBudget();
   int selectedBudgetPeriodIndex = budgetForm.getViewBudgetPeriod() - 1;
   int selectedBudgetLineItemIndex = budgetForm.getSelectedBudgetLineItemIndex();
   BudgetLineItem selectedBudgetLineItem =
       budget
           .getBudgetPeriod(selectedBudgetPeriodIndex)
           .getBudgetLineItem(selectedBudgetLineItemIndex);
   BudgetPersonnelDetails budgetPersonnelDetails =
       selectedBudgetLineItem.getBudgetPersonnelDetailsList().get(getLineToDelete(request));
   boolean errorFound = false;
   GlobalVariables.getMessageMap().addToErrorPath("document");
   if (budgetPersonnelDetails.getPercentEffort().isGreaterThan(new BudgetDecimal(100))) {
     GlobalVariables.getMessageMap()
         .putError(
             "budgetPeriod["
                 + selectedBudgetPeriodIndex
                 + "].budgetLineItems["
                 + selectedBudgetLineItemIndex
                 + "].budgetPersonnelDetailsList["
                 + getLineToDelete(request)
                 + "].percentEffort",
             KeyConstants.ERROR_PERCENTAGE,
             Constants.PERCENT_EFFORT_FIELD);
     errorFound = true;
   }
   if (budgetPersonnelDetails.getPercentCharged().isGreaterThan(new BudgetDecimal(100))) {
     GlobalVariables.getMessageMap()
         .putError(
             "budgetPeriod["
                 + selectedBudgetPeriodIndex
                 + "].budgetLineItems["
                 + selectedBudgetLineItemIndex
                 + "].budgetPersonnelDetailsList["
                 + getLineToDelete(request)
                 + "].percentCharged",
             KeyConstants.ERROR_PERCENTAGE,
             Constants.PERCENT_CHARGED_FIELD);
     errorFound = true;
   }
   if (budgetPersonnelDetails
       .getPercentCharged()
       .isGreaterThan(budgetPersonnelDetails.getPercentEffort())) {
     GlobalVariables.getMessageMap()
         .putError(
             "budgetPeriod["
                 + selectedBudgetPeriodIndex
                 + "].budgetLineItems["
                 + selectedBudgetLineItemIndex
                 + "].budgetPersonnelDetailsList["
                 + getLineToDelete(request)
                 + "].percentCharged",
             KeyConstants.ERROR_PERCENT_EFFORT_LESS_THAN_PERCENT_CHARGED);
     errorFound = true;
   }
   errorFound =
       errorFound
           || personnelDatesCheck(
               selectedBudgetLineItem,
               budgetPersonnelDetails,
               selectedBudgetPeriodIndex,
               selectedBudgetLineItemIndex,
               getLineToDelete(request));
   if (!errorFound) {
     BudgetPersonnelBudgetService budgetPersonnelBudgetService =
         KraServiceLocator.getService(BudgetPersonnelBudgetService.class);
     budgetPersonnelBudgetService.calculateBudgetPersonnelBudget(
         budget, selectedBudgetLineItem, budgetPersonnelDetails, getLineToDelete(request));
   }
   return mapping.findForward(Constants.MAPPING_BASIC);
 }