Exemplo n.º 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);
  }
Exemplo n.º 2
0
  /**
   * Need to suppress buttons here when 'Totals' tab is clicked.
   *
   * @see
   *     org.kuali.core.web.struts.action.KualiDocumentActionBase#execute(org.apache.struts.action.ActionMapping,
   *     org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
   *     javax.servlet.http.HttpServletResponse)
   */
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    final BudgetForm budgetForm = (BudgetForm) form;
    if (budgetForm.getMethodToCall().equals("close")) {
      setupDocumentExit();
    }
    ActionForward actionForward = null;

    actionForward = super.execute(mapping, budgetForm, request, response);

    if (actionForward != null) {
      if ("summaryTotals".equals(actionForward.getName())) {
        budgetForm.suppressButtonsForTotalPage();
      }
    }
    // check if audit rule check is done from PD
    if (budgetForm.isAuditActivated() && !"route".equals(((KualiForm) form).getMethodToCall())) {
      KraServiceLocator.getService(KualiRuleService.class)
          .applyRules(new DocumentAuditEvent(budgetForm.getDocument()));
    }

    return actionForward;
  }
Exemplo n.º 3
0
  private ActionForward getReturnToAwardForward(BudgetForm budgetForm) throws Exception {
    assert budgetForm != null : "the form is null";

    final DocumentService docService = KraServiceLocator.getService(DocumentService.class);
    Award award = ((AwardDocument) budgetForm.getBudgetDocument().getParentDocument()).getAward();

    // find the newest, uncanceled award document to return to
    String docNumber = budgetForm.getBudgetDocument().getParentDocument().getDocumentNumber();
    List<VersionHistory> versions =
        KraServiceLocator.getService(VersionHistoryService.class)
            .loadVersionHistory(Award.class, award.getAwardNumber());
    for (VersionHistory version : versions) {
      if (version.getSequenceOwnerSequenceNumber() > award.getSequenceNumber()
          && version.getStatus() != VersionStatus.CANCELED) {
        docNumber = ((Award) version.getSequenceOwner()).getAwardDocument().getDocumentNumber();
      }
    }
    final AwardDocument awardDocument = (AwardDocument) docService.getByDocumentHeaderId(docNumber);
    String forwardUrl =
        buildForwardUrl(awardDocument.getDocumentHeader().getWorkflowDocument().getRouteHeaderId());
    if (budgetForm.isAuditActivated()) {
      forwardUrl = StringUtils.replace(forwardUrl, "Award.do?", "Actions.do?");
    }
    // add showAllBudgetVersion to the url to persist that flag until they leave the document
    forwardUrl =
        StringUtils.replace(
            forwardUrl,
            ".do?",
            ".do?showAllBudgetVersions=" + budgetForm.isShowAllBudgetVersions() + "&");

    return new ActionForward(forwardUrl, true);
  }
  @Override
  public ActionForward reload(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    BudgetForm budgetForm = (BudgetForm) form;
    // setBudgetPersonDefaultPeriodTypeCode(budgetForm);
    ActionForward actionForward = super.reload(mapping, form, request, response);
    BusinessObjectService bos = KraServiceLocator.getService(BusinessObjectService.class);
    BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
    Budget budget = budgetDocument.getBudget();
    Map queryMap = new HashMap();
    queryMap.put("budgetId", budget.getBudgetId());
    Collection budgetPersons = bos.findMatching(BudgetPerson.class, queryMap);
    budget.setBudgetPersons(budgetPersons == null ? new ArrayList() : (List) budgetPersons);

    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);

    return actionForward;
  }
Exemplo n.º 5
0
 public ActionForward modularBudget(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response) {
   BudgetForm budgetForm = (BudgetForm) form;
   BudgetModularService budgetModularService =
       KraServiceLocator.getService(BudgetModularService.class);
   budgetForm.setBudgetModularSummary(
       budgetModularService.generateModularSummary(budgetForm.getDocument().getBudget()));
   return mapping.findForward(Constants.BUDGET_MODULAR_PAGE);
 }
Exemplo n.º 6
0
 public ActionForward budgetActions(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response) {
   BudgetForm budgetForm = (BudgetForm) form;
   BudgetDocument budgetDocument = budgetForm.getDocument();
   Budget budget = budgetDocument.getBudget();
   populateBudgetPrintForms(budget);
   KraServiceLocator.getService(BudgetSubAwardService.class)
       .populateBudgetSubAwardAttachments(budget);
   return mapping.findForward(Constants.BUDGET_ACTIONS_PAGE);
 }
Exemplo n.º 7
0
 public ActionForward versions(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response) {
   BudgetForm budgetForm = (BudgetForm) form;
   BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
   BudgetParentDocument parentDocument = budgetDocument.getParentDocument();
   //        proposal.refreshReferenceObject("budgetDocumentVersions");
   budgetForm.setFinalBudgetVersion(
       getFinalBudgetVersion(parentDocument.getBudgetDocumentVersions()));
   setBudgetStatuses(parentDocument);
   return mapping.findForward(Constants.BUDGET_VERSIONS_PAGE);
 }
Exemplo n.º 8
0
  public ActionForward hierarchy(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    BudgetForm budgetForm = (BudgetForm) form;
    ProposalDevelopmentDocument aDoc =
        (ProposalDevelopmentDocument) budgetForm.getDocument().getParentDocument();

    budgetForm.setHierarchyProposalSummaries(
        getHierarchyHelper()
            .getHierarchyProposalSummaries(aDoc.getDevelopmentProposal().getProposalNumber()));
    return mapping.findForward(Constants.HIERARCHY_PAGE);
  }
Exemplo n.º 9
0
 protected void populatePersonnelHierarchySummary(BudgetForm budgetForm) {
   if (Boolean.valueOf(budgetForm.getDocument().getParentDocument().getProposalBudgetFlag())) {
     ProposalDevelopmentDocument parentDocument =
         (ProposalDevelopmentDocument) budgetForm.getDocument().getParentDocument();
     String proposalNumber = parentDocument.getDevelopmentProposal().getProposalNumber();
     budgetForm.setHierarchyPersonnelSummaries(
         getHierarchyHelper().getHierarchyPersonnelSummaries(proposalNumber));
     for (HierarchyPersonnelSummary hierarchyPersonnelSummary :
         budgetForm.getHierarchyPersonnelSummaries()) {
       for (Budget budget : hierarchyPersonnelSummary.getHierarchyBudgets()) {
         reconcilePersonnelRoles(budget.getBudgetDocument());
       }
     }
   }
 }
Exemplo n.º 10
0
  public ActionForward expenses(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response) {
    BudgetForm budgetForm = (BudgetForm) form;

    populateNonPersonnelCategoryTypeCodes(budgetForm);

    BudgetDocument budgetDocument = budgetForm.getDocument();
    Budget budget = budgetDocument.getBudget();
    budget.refreshReferenceObject("budgetPeriods");

    return mapping.findForward(Constants.BUDGET_EXPENSES_PAGE);
  }
Exemplo n.º 11
0
  /**
   * Gets the correct return-to-proposal action forward.
   *
   * @param form the budget form
   * @return the action forward
   * @throws WorkflowException if there is a problem interacting with workflow
   */
  private ActionForward getReturnToProposalForward(final BudgetForm form) throws WorkflowException {
    assert form != null : "the form is null";
    final DocumentService docService = KraServiceLocator.getService(DocumentService.class);
    final String docNumber = form.getDocument().getParentDocument().getDocumentNumber();

    final ProposalDevelopmentDocument pdDoc =
        (ProposalDevelopmentDocument) docService.getByDocumentHeaderId(docNumber);
    String forwardUrl =
        buildForwardUrl(pdDoc.getDocumentHeader().getWorkflowDocument().getRouteHeaderId());
    if (form.isAuditActivated()) {
      forwardUrl =
          StringUtils.replace(forwardUrl, "Proposal.do?", "Actions.do?auditActivated=true&");
    }
    forwardUrl += "&methodToCallAttribute=methodToCall.reload";
    return new ActionForward(forwardUrl, true);
  }
Exemplo n.º 12
0
  /**
   * @see
   *     org.kuali.core.web.struts.action.KualiDocumentActionBase#docHandler(org.apache.struts.action.ActionMapping,
   *     org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
   *     javax.servlet.http.HttpServletResponse)
   */
  @Override
  public ActionForward docHandler(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    ActionForward forward = super.docHandler(mapping, form, request, response);
    BudgetForm budgetForm = (BudgetForm) form;
    if (KEWConstants.INITIATE_COMMAND.equals(budgetForm.getCommand())) {
      budgetForm.getDocument().initialize();
    } else {
      budgetForm.initialize();
    }
    BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
    if (budgetDocument.isBudgetDeleted()) {
      return mapping.findForward("deleted");
    }
    Budget budget = budgetDocument.getBudget();
    copyLineItemToPersonnelDetails(budgetDocument);
    if (budget.getActivityTypeCode().equals("x")) {
      budget.setActivityTypeCode(
          KraServiceLocator.getService(BudgetService.class)
              .getActivityTypeForBudget(budgetDocument));
    }

    if (budget.getOhRateClassCode() != null
        && ((BudgetForm) GlobalVariables.getKualiForm()) != null) {
      ((BudgetForm) GlobalVariables.getKualiForm())
          .setOhRateClassCodePrevValue(budget.getOhRateClassCode());
    }
    if (budget.getUrRateClassCode() != null
        && ((BudgetForm) GlobalVariables.getKualiForm()) != null) {
      ((BudgetForm) GlobalVariables.getKualiForm())
          .setUrRateClassCodePrevValue(budget.getUrRateClassCode());
    }

    if (budgetDocument.getParentDocument() instanceof AwardDocument
        && StringUtils.isNotBlank(budgetForm.getSyncBudgetRate())
        && budgetForm.getSyncBudgetRate().equals("Y")) {
      getBudgetRatesService().syncParentDocumentRates(budgetDocument);
      getBudgetCommonService(budgetDocument.getParentDocument()).calculateBudgetOnSave(budget);
    }

    reconcileBudgetStatus(budgetForm);
    if ("Personnel".equals(budgetForm.getActivePanelName())) {
      forward = personnel(mapping, budgetForm, request, response);
    }
    return forward;
  }
Exemplo n.º 13
0
  protected void populateNonPersonnelCategoryTypeCodes(BudgetForm budgetForm) {
    BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
    Budget budget = budgetDocument.getBudget();

    BudgetCategoryTypeValuesFinder budgetCategoryTypeValuesFinder =
        new BudgetCategoryTypeValuesFinder();
    List<KeyLabelPair> budgetCategoryTypes = new ArrayList<KeyLabelPair>();
    String personnelBudgetCategoryTypeCode = getPersonnelBudgetCategoryTypeCode();

    for (KeyLabelPair budgetCategoryType : budgetCategoryTypeValuesFinder.getKeyValues()) {
      String budgetCategoryTypeCode = (String) budgetCategoryType.getKey();
      if (StringUtils.isNotBlank(budgetCategoryTypeCode)
          && !StringUtils.equalsIgnoreCase(
              budgetCategoryTypeCode, personnelBudgetCategoryTypeCode)) {
        budgetCategoryTypes.add(budgetCategoryType);
        BudgetLineItem newBudgetLineItem = budget.getNewBudgetLineItem();
        budgetForm.getNewBudgetLineItems().add(newBudgetLineItem);
      }
    }
    budget.setBudgetCategoryTypeCodes(budgetCategoryTypes);
  }
 @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.º 15
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);
  }
Exemplo n.º 16
0
  /** {@inheritDoc} */
  @Override
  public ActionForward reload(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    final ActionForward forward = super.reload(mapping, form, request, response);
    final BudgetForm budgetForm = (BudgetForm) form;
    BudgetDocument budgetDocument = budgetForm.getBudgetDocument();
    BudgetParentDocument parentDocument = budgetDocument.getParentDocument();

    budgetForm.setFinalBudgetVersion(
        getFinalBudgetVersion(parentDocument.getBudgetDocumentVersions()));
    setBudgetStatuses(budgetDocument.getParentDocument());

    final BudgetTDCValidator tdcValidator = new BudgetTDCValidator(request);
    tdcValidator.validateGeneratingWarnings(budgetDocument.getParentDocument());

    populateBudgetPrintForms(budgetDocument.getBudget());
    return forward;
  }
Exemplo n.º 17
0
  public ActionForward returnToAward(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    final BudgetForm budgetForm = (BudgetForm) form;
    ActionForward forward = null;

    if (!"true"
        .equals(budgetForm.getEditingMode().get(AuthorizationConstants.EditMode.VIEW_ONLY))) {
      forward = this.save(mapping, form, request, response);
    }

    setupDocumentExit();

    if (forward == null || !forward.getPath().contains(KNSConstants.QUESTION_ACTION)) {
      return this.getReturnToAwardForward(budgetForm);
    }

    return forward;
  }
  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);
  }
  /**
   * 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");
    }
  }
Exemplo n.º 20
0
 protected void reconcileBudgetStatus(BudgetForm budgetForm) {
   BudgetDocument budgetDocument = budgetForm.getDocument();
   Budget budget = budgetDocument.getBudget();
   BudgetParent budgetParent = budgetDocument.getParentDocument().getBudgetParent();
   if (budgetParent instanceof DevelopmentProposal) {
     DevelopmentProposal proposal = (DevelopmentProposal) budgetParent;
     KraServiceLocator.getService(ProposalStatusService.class).loadBudgetStatus(proposal);
   }
   if (budget.getFinalVersionFlag() != null && Boolean.TRUE.equals(budget.getFinalVersionFlag())) {
     budget.setBudgetStatus(budgetParent.getBudgetStatus());
   } else {
     String budgetStatusIncompleteCode =
         this.getParameterService()
             .getParameterValue(BudgetDocument.class, Constants.BUDGET_STATUS_INCOMPLETE_CODE);
     budget.setBudgetStatus(budgetStatusIncompleteCode);
   }
 }
Exemplo n.º 21
0
  /**
   * This method sets additional document information in the document header of the budget form. If
   * the document contained in the budget form is null then empty values will be placed for the
   * additional information.
   *
   * @param budgetForm the budget form
   */
  private void setAdditionalDocumentHeaderInfo(final BudgetForm budgetForm) {
    assert budgetForm != null : "the budgetForm is null";

    final BudgetDocument budgetDocument = budgetForm.getDocument();
    Budget budget = budgetDocument.getBudget();
    BudgetParentDocument parentDocument = budgetDocument.getParentDocument();
    if (budget != null
        && parentDocument != null
        && parentDocument.getBudgetDocumentVersions() != null) {
      boolean setAdditionalInfo = false;
      for (final BudgetDocumentVersion budgetVersion : parentDocument.getBudgetDocumentVersions()) {
        if (budgetVersion
            .getBudgetVersionOverview()
            .getBudgetVersionNumber()
            .equals(budget.getBudgetVersionNumber())) {
          budgetForm
              .getDocInfo()
              .add(
                  new HeaderField(
                      BudgetForm.BUDGET_NAME_KEY,
                      budgetVersion.getBudgetVersionOverview().getDocumentDescription()));
          setAdditionalInfo = true;
          break;
        } else {
          budgetForm
              .getDocInfo()
              .add(new HeaderField(BudgetForm.BUDGET_NAME_KEY, Constants.EMPTY_STRING));
        }
      }
      if (!setAdditionalInfo) {
        budgetForm
            .getDocInfo()
            .add(new HeaderField(BudgetForm.BUDGET_NAME_KEY, Constants.EMPTY_STRING));
      }

      if (budget.getBudgetVersionNumber() != null) {
        budgetForm
            .getDocInfo()
            .add(
                new HeaderField(
                    BudgetForm.VERSION_NUMBER_KEY, budget.getBudgetVersionNumber().toString()));
      } else {
        budgetForm
            .getDocInfo()
            .add(new HeaderField(BudgetForm.VERSION_NUMBER_KEY, Constants.EMPTY_STRING));
      }
    }
  }
Exemplo n.º 22
0
  /** {@inheritDoc} */
  @Override
  public ActionForward save(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    BudgetForm budgetForm = (BudgetForm) form;
    final BudgetDocument budgetDoc = budgetForm.getDocument();
    fixDocHeaderVersion(budgetDoc);
    Budget budget = budgetDoc.getBudget();
    getBudgetCommonService(budgetDoc.getParentDocument()).calculateBudgetOnSave(budget);
    ActionForward forward = super.save(mapping, form, request, response);
    BudgetForm savedBudgetForm = (BudgetForm) form;
    BudgetDocument savedBudgetDoc = savedBudgetForm.getDocument();
    refreshBudgetDocumentVersion(savedBudgetDoc);
    getBusinessObjectService().save(savedBudgetDoc.getParentDocument().getBudgetDocumentVersions());

    final BudgetTDCValidator tdcValidator = new BudgetTDCValidator(request);
    if (budgetForm.toBudgetVersionsPage()
        || "BudgetVersionsAction".equals(budgetForm.getActionName())) {
      GlobalVariables.getErrorMap()
          .addToErrorPath(KNSConstants.DOCUMENT_PROPERTY_NAME + ".proposal");
      tdcValidator.validateGeneratingErrorsAndWarnings(budgetDoc.getParentDocument());
    } else {
      tdcValidator.validateGeneratingWarnings(budgetDoc.getParentDocument());
    }

    if (budgetForm.getMethodToCall().equals("save") && budgetForm.isAuditActivated()) {
      if (Boolean.valueOf(savedBudgetDoc.getParentDocument().getProposalBudgetFlag())) {
        forward = this.getReturnToProposalForward(budgetForm);
      } else {
        forward = mapping.findForward("budgetActions");
      }
    }

    return forward;
  }
 /**
  * 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);
 }
  /**
   * 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);
  }