Exemplo n.º 1
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());
            }
          }
        }
      }
    }
  }
Exemplo n.º 2
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);
  }
  /**
   * This method is used to return back to expenses tab
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return mapping forward
   * @throws Exception
   */
  public ActionForward returnToExpenses(
      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);
    int k = 0;
    boolean errorFound = false;
    GlobalVariables.getMessageMap().addToErrorPath("document");
    for (BudgetPersonnelDetails budgetPersonnelDetails :
        selectedBudgetLineItem.getBudgetPersonnelDetailsList()) {
      errorFound =
          errorFound
              || personnelDatesCheck(
                  selectedBudgetLineItem,
                  budgetPersonnelDetails,
                  selectedBudgetPeriodIndex,
                  selectedBudgetLineItemIndex,
                  k);
      k++;
    }
    GlobalVariables.getMessageMap().removeFromErrorPath("document");
    if (errorFound) {
      return mapping.findForward(Constants.MAPPING_BASIC);
    } else {
      getCalculationService().calculateBudgetLineItem(budget, selectedBudgetLineItem);

      BudgetCategoryTypeValuesFinder budgetCategoryTypeValuesFinder =
          new BudgetCategoryTypeValuesFinder();
      List<KeyValue> budgetCategoryTypes = new ArrayList<KeyValue>();
      budgetCategoryTypes = budgetCategoryTypeValuesFinder.getKeyValues();
      for (int i = 0; i < budgetCategoryTypes.size(); i++) {
        budgetForm.getNewBudgetLineItems().add(budget.getNewBudgetLineItem());
      }
      budget.setBudgetCategoryTypeCodes(budgetCategoryTypes);
      request.setAttribute(
          "fromPersonnelBudget"
              + budgetForm.getViewBudgetPeriod()
              + ""
              + selectedBudgetLineItemIndex,
          true);

      return mapping.findForward("expenses");
    }
  }
 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++;
     }
   }
 }
Exemplo n.º 5
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);
  }
 @Override
 public ActionForward save(
     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);
   int k = 0;
   boolean errorFound = false;
   GlobalVariables.getMessageMap().addToErrorPath("document");
   for (BudgetPersonnelDetails budgetPersonnelDetails :
       selectedBudgetLineItem.getBudgetPersonnelDetailsList()) {
     errorFound |=
         personnelDatesCheck(
             selectedBudgetLineItem,
             budgetPersonnelDetails,
             selectedBudgetPeriodIndex,
             selectedBudgetLineItemIndex,
             k);
     k++;
   }
   GlobalVariables.getMessageMap().removeFromErrorPath("document");
   if (errorFound) {
     getCalculationService().calculateBudgetLineItem(budget, selectedBudgetLineItem);
     return mapping.findForward(Constants.MAPPING_BASIC);
   } else {
     ActionForward actionForward = super.save(mapping, form, request, response);
     selectedBudgetLineItem.setBudgetPersonnelLineItemDeleted(false);
     return actionForward;
   }
 }
Exemplo n.º 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 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);
 }