Пример #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());
            }
          }
        }
      }
    }
  }
Пример #2
0
  public boolean processSyncModularBusinessRules(Document document) {
    if (!(document instanceof BudgetDocument)) {
      return false;
    }

    boolean valid = true;

    BudgetDocument budgetDocument = (BudgetDocument) document;

    GlobalVariables.getMessageMap().addToErrorPath("document");

    List budgetPeriods = budgetDocument.getBudget().getBudgetPeriods();
    if (ObjectUtils.isNotNull(budgetPeriods) || budgetPeriods.size() >= 1) {
      BudgetPeriod period1 = (BudgetPeriod) budgetPeriods.get(0);
      if (ObjectUtils.isNull(period1.getBudgetLineItems())
          || period1.getBudgetLineItems().isEmpty()) {
        valid = false;
      }
    } else {
      valid = false;
    }

    if (!valid) {
      GlobalVariables.getMessageMap()
          .putError("modularBudget", KeyConstants.ERROR_NO_DETAILED_BUDGET);
    }

    GlobalVariables.getMessageMap().removeFromErrorPath("document");

    return valid;
  }
Пример #3
0
 protected List<BudgetLineItem> findSubAwardLineItems(
     BudgetPeriod budgetPeriod, Integer subAwardNumber) {
   List<BudgetLineItem> lineItems = new ArrayList<BudgetLineItem>();
   if (budgetPeriod.getBudgetLineItems() != null) {
     for (BudgetLineItem item : budgetPeriod.getBudgetLineItems()) {
       if (ObjectUtils.equals(item.getSubAwardNumber(), subAwardNumber)) {
         lineItems.add(item);
       }
     }
   }
   return lineItems;
 }
Пример #4
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);
  }
Пример #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);
  }
Пример #6
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;
  }
Пример #7
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;
  }
Пример #8
0
  /**
   * This method is to get estimated project funds for RRSF424
   *
   * @return EstimatedProjectFunding estimated total cost for the project.
   * @throws S2SException
   */
  private EstimatedProjectFunding getProjectFunding() throws S2SException {
    BudgetDocument budgetDocument = null;
    try {
      budgetDocument = proposalBudgetService.getFinalBudgetVersion(pdDoc);
    } catch (WorkflowException e) {
      throw new S2SException(e);
    }
    Budget budget = budgetDocument == null ? null : budgetDocument.getBudget();
    EstimatedProjectFunding funding = EstimatedProjectFunding.Factory.newInstance();
    funding.setTotalEstimatedAmount(BigDecimal.ZERO);
    funding.setTotalfedNonfedrequested(BigDecimal.ZERO);
    funding.setEstimatedProgramIncome(BigDecimal.ZERO);
    boolean hasBudgetLineItem = false;
    if (budget != null) {
      if (budget.getModularBudgetFlag()) {
        ScaleTwoDecimal fundsRequested = ScaleTwoDecimal.ZERO;
        ScaleTwoDecimal totalDirectCost = ScaleTwoDecimal.ZERO;
        ScaleTwoDecimal totalCost = ScaleTwoDecimal.ZERO;
        // get modular budget amounts instead of budget detail amounts
        for (BudgetPeriod budgetPeriod : budget.getBudgetPeriods()) {
          totalDirectCost =
              totalDirectCost.add(budgetPeriod.getBudgetModular().getTotalDirectCost());
          for (BudgetModularIdc budgetModularIdc :
              budgetPeriod.getBudgetModular().getBudgetModularIdcs()) {
            fundsRequested = fundsRequested.add(budgetModularIdc.getFundsRequested());
          }
        }
        totalCost = totalCost.add(totalDirectCost);
        totalCost = totalCost.add(fundsRequested);
        budget.setTotalIndirectCost(fundsRequested);
        budget.setTotalCost(totalCost);
      }
      ScaleTwoDecimal fedNonFedCost = budget.getTotalCost();

      BigDecimal totalProjectIncome = BigDecimal.ZERO;

      ScaleTwoDecimal costSharingAmount = ScaleTwoDecimal.ZERO;

      for (BudgetPeriod budgetPeriod : budget.getBudgetPeriods()) {
        for (BudgetLineItem lineItem : budgetPeriod.getBudgetLineItems()) {
          hasBudgetLineItem = true;
          if (budget.getSubmitCostSharingFlag() && lineItem.getSubmitCostSharingFlag()) {
            costSharingAmount = costSharingAmount.add(lineItem.getCostSharingAmount());
            List<BudgetLineItemCalculatedAmount> calculatedAmounts =
                lineItem.getBudgetCalculatedAmounts();
            for (BudgetLineItemCalculatedAmount budgetLineItemCalculatedAmount :
                calculatedAmounts) {
              costSharingAmount =
                  costSharingAmount.add(budgetLineItemCalculatedAmount.getCalculatedCostSharing());
            }
          }
        }
      }
      if (!hasBudgetLineItem && budget.getSubmitCostSharingFlag()) {
        costSharingAmount = budget.getCostSharingAmount();
      }
      fedNonFedCost = fedNonFedCost.add(costSharingAmount);

      for (BudgetProjectIncome budgetProjectIncome : budget.getBudgetProjectIncomes()) {
        totalProjectIncome =
            totalProjectIncome.add(budgetProjectIncome.getProjectIncome().bigDecimalValue());
      }

      funding = EstimatedProjectFunding.Factory.newInstance();
      funding.setTotalEstimatedAmount(budget.getTotalCost().bigDecimalValue());
      funding.setTotalfedNonfedrequested(fedNonFedCost.bigDecimalValue());
      funding.setEstimatedProgramIncome(totalProjectIncome);
    }
    return funding;
  }
Пример #9
0
 public void generateSubAwardLineItems(BudgetSubAwards subAward, Budget budget) {
   BudgetDecimal amountChargeFA = new BudgetDecimal(25000);
   String directLtCostElement =
       getParameterService()
           .getParameterValueAsString(
               BudgetDocument.class, Constants.SUBCONTRACTOR_DIRECT_LT_25K_PARAM);
   String directGtCostElement =
       getParameterService()
           .getParameterValueAsString(
               BudgetDocument.class, Constants.SUBCONTRACTOR_DIRECT_GT_25K_PARAM);
   String inDirectLtCostElement =
       getParameterService()
           .getParameterValueAsString(
               BudgetDocument.class, Constants.SUBCONTRACTOR_F_AND_A_LT_25K_PARAM);
   String inDirectGtCostElement =
       getParameterService()
           .getParameterValueAsString(
               BudgetDocument.class, Constants.SUBCONTRACTOR_F_AND_A_GT_25K_PARAM);
   for (BudgetSubAwardPeriodDetail detail : subAward.getBudgetSubAwardPeriodDetails()) {
     BudgetPeriod budgetPeriod = findBudgetPeriod(detail, budget);
     List<BudgetLineItem> currentLineItems =
         findSubAwardLineItems(budgetPeriod, subAward.getSubAwardNumber());
     // zero out existing line items before recalculating
     for (BudgetLineItem item : currentLineItems) {
       item.setDirectCost(BudgetDecimal.ZERO);
       item.setCostSharingAmount(BudgetDecimal.ZERO);
       item.setSubAwardNumber(subAward.getSubAwardNumber());
       item.setLineItemDescription(subAward.getOrganizationName());
     }
     if (BudgetDecimal.returnZeroIfNull(detail.getDirectCost()).isNonZero()
         || hasBeenChanged(detail, true)) {
       BudgetDecimal ltValue = lesserValue(detail.getDirectCost(), amountChargeFA);
       BudgetDecimal gtValue = detail.getDirectCost().subtract(ltValue);
       if (ltValue.isNonZero()) {
         BudgetLineItem lt =
             findOrCreateLineItem(
                 currentLineItems, detail, subAward, budgetPeriod, directLtCostElement);
         lt.setLineItemCost(ltValue);
       }
       if (gtValue.isNonZero()) {
         BudgetLineItem gt =
             findOrCreateLineItem(
                 currentLineItems, detail, subAward, budgetPeriod, directGtCostElement);
         gt.setLineItemCost(gtValue);
       }
       amountChargeFA = amountChargeFA.subtract(ltValue);
     }
     if (BudgetDecimal.returnZeroIfNull(detail.getIndirectCost()).isNonZero()
         || hasBeenChanged(detail, false)) {
       BudgetDecimal ltValue = lesserValue(detail.getIndirectCost(), amountChargeFA);
       BudgetDecimal gtValue = detail.getIndirectCost().subtract(ltValue);
       if (ltValue.isNonZero()) {
         BudgetLineItem lt =
             findOrCreateLineItem(
                 currentLineItems, detail, subAward, budgetPeriod, inDirectLtCostElement);
         lt.setLineItemCost(ltValue);
       }
       if (gtValue.isNonZero()) {
         BudgetLineItem gt =
             findOrCreateLineItem(
                 currentLineItems, detail, subAward, budgetPeriod, inDirectGtCostElement);
         gt.setLineItemCost(gtValue);
       }
       amountChargeFA = amountChargeFA.subtract(ltValue);
     }
     Collections.sort(
         currentLineItems,
         new Comparator<BudgetLineItem>() {
           public int compare(BudgetLineItem arg0, BudgetLineItem arg1) {
             return arg0.getLineItemNumber().compareTo(arg1.getLineItemNumber());
           }
         });
     Iterator<BudgetLineItem> iter = currentLineItems.iterator();
     while (iter.hasNext()) {
       BudgetLineItem lineItem = iter.next();
       if (BudgetDecimal.returnZeroIfNull(lineItem.getLineItemCost()).isZero()) {
         budgetPeriod.getBudgetLineItems().remove(lineItem);
         iter.remove();
       } else {
         if (!budgetPeriod.getBudgetLineItems().contains(lineItem)) {
           budgetPeriod.getBudgetLineItems().add(lineItem);
         }
       }
     }
     if (!currentLineItems.isEmpty()
         && BudgetDecimal.returnZeroIfNull(detail.getCostShare()).isNonZero()) {
       currentLineItems.get(0).setCostSharingAmount(detail.getCostShare());
     }
   }
 }