示例#1
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;
  }