/**
  * This method will set the values to salaryType VO for budget line calculated amount
  *
  * @param salaryTypeVoList is a list contains set of salary types based on budget line calculated
  *     amount
  */
 protected void setSalaryTypesForLineItemCalcuAmount(
     List<SalaryTypeVO> salaryTypeVoList, boolean includeNonPersonnel) {
   List<String> calculatedAmountDescList = new ArrayList<String>();
   SalaryTypeVO salaryTypeVO = new SalaryTypeVO();
   salaryTypeVO.setCostElement(CALCULATED_AMOUNT_COST_ELEMENT_DESC);
   salaryTypeVoList.add(salaryTypeVO);
   for (BudgetPeriod budgetPeriod : budget.getBudgetPeriods()) {
     for (BudgetLineItem budgetLineItem : new ArrayList<>(budgetPeriod.getBudgetLineItems())) {
       List<BudgetLineItemCalculatedAmount> budgetLineItemCalculatedAmounts =
           budgetLineItem.getBudgetLineItemCalculatedAmounts();
       for (BudgetLineItemCalculatedAmount budgetLineItemCalcAmount :
           budgetLineItemCalculatedAmounts) {
         String rateClassCode = budgetLineItemCalcAmount.getRateClassCode();
         String rateTypeCode = budgetLineItemCalcAmount.getRateTypeCode();
         RateClass rateClass = getRateClassBo(rateClassCode);
         String costElementDesc =
             getCostElementDescriptionForLineItem(budgetLineItemCalcAmount, rateClass);
         if (costElementDesc != null && !calculatedAmountDescList.contains(costElementDesc)) {
           calculatedAmountDescList.add(costElementDesc);
           SalaryTypeVO salaryTypeVOForCalculatedAmount = new SalaryTypeVO();
           salaryTypeVOForCalculatedAmount.setName(costElementDesc);
           List<BudgetDataPeriodVO> budgetPeriodDataList =
               getBudgetDataPeriodsForCalculatedAmounts(
                   rateClassCode, rateTypeCode, includeNonPersonnel);
           salaryTypeVOForCalculatedAmount.setBudgetPeriodVOs(budgetPeriodDataList);
           salaryTypeVoList.add(salaryTypeVOForCalculatedAmount);
         }
       }
     }
   }
 }
 /**
  * This method gets SalaryTypeVO for costElement. For given cost element description get's list of
  * budget period data's and finally set to SalaryTypeVO;
  *
  * @param costElemetDesc
  * @param costElementCode
  * @return SalaryTypeVO
  */
 protected SalaryTypeVO getSalaryTypeVOForCostElement(
     String costElemetDesc, String costElementCode) {
   SalaryTypeVO salaryTypeVO = new SalaryTypeVO();
   salaryTypeVO.setCostElement(costElemetDesc);
   salaryTypeVO.setCostElementCode(costElementCode);
   salaryTypeVO.setName(costElemetDesc);
   salaryTypeVO.setBudgetPeriodVOs(getBudgetDataPeriodVOsForCostElement(costElemetDesc));
   return salaryTypeVO;
 }
Esempio n. 3
0
 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);
   }
 }
  /**
   * This method will iterate over salaryTypeVo List and set to xml bean SalaryType and sort the
   * List based on costElement
   *
   * @param salaryTypeVoList
   * @return list of SalaryType xml bean
   */
  protected List<SalaryType> getListOfSalaryTypeXmlObjects(List<SalaryTypeVO> salaryTypeVoList) {
    List<SalaryType> salaryTypeList = new ArrayList<SalaryType>();
    Map<Integer, ScaleTwoDecimal> budgetPeriodWiseTotalMap =
        new HashMap<Integer, ScaleTwoDecimal>();
    if (!salaryTypeVoList.isEmpty()) {
      for (SalaryTypeVO salaryTypeVO : salaryTypeVoList) {
        BudgetPeriodData[] budgetPeriodArray = null;
        List<BudgetDataPeriodVO> budgetDataPeriodVOs = salaryTypeVO.getBudgetPeriodVOs();
        if (budgetDataPeriodVOs != null) {
          ScaleTwoDecimal total = ScaleTwoDecimal.ZERO;
          budgetPeriodArray =
              getBudgetDataPeriodXmlObjects(budgetDataPeriodVOs, budgetPeriodWiseTotalMap);
          total = getTotalForCostElementOfAllPeriodsCost(budgetDataPeriodVOs);
          salaryTypeVO.setTotal(total);
        }

        salaryTypeList.add(
            getSalaryTypeXmlObject(
                salaryTypeVO.getCostElement(),
                salaryTypeVO.getCostElementCode(),
                salaryTypeVO.getName(),
                budgetPeriodArray,
                salaryTypeVO.getTotal()));
      }
      setTotalForPeriodWise(salaryTypeList, budgetPeriodWiseTotalMap);
    }
    Collections.sort(
        salaryTypeList,
        new Comparator<SalaryType>() {
          public int compare(SalaryType salaryType1, SalaryType salaryType2) {
            int i = 0;
            if (salaryType1.getCostElementCode() != null
                && salaryType2.getCostElementCode() != null) {
              i = salaryType1.getCostElementCode().compareTo(salaryType2.getCostElementCode());
            }
            return i;
          }
        });
    return salaryTypeList;
  }