示例#1
0
 private void populateYearRange() {
   CFinancialYear financialYear = budgetDetail.getBudget().getFinancialYear();
   if (financialYear != null) {
     if ("BE".equalsIgnoreCase(budgetDetail.getBudget().getIsbere())) {
       currentYearRange =
           budgetDetailHelper.computePreviousYearRange(financialYear.getFinYearRange());
       lastYearRange = currentYearRange;
       nextYearRange = budgetDetailHelper.computeNextYearRange(currentYearRange);
     } else {
       currentYearRange = financialYear.getFinYearRange();
       lastYearRange = budgetDetailHelper.computePreviousYearRange(currentYearRange);
       nextYearRange = budgetDetailHelper.computeNextYearRange(currentYearRange);
     }
   }
 }
示例#2
0
 private void populatePreviousYearActuals(
     List<BudgetDetail> budgetDetails, CFinancialYear financialYear) {
   if (financialYear != null && financialYear.getId() != null)
     financialYear =
         (CFinancialYear)
             persistenceService.find("from CFinancialYear where id=?", financialYear.getId());
   Map<String, Object> paramMap;
   for (BudgetDetail detail : budgetDetails) {
     paramMap = budgetDetailHelper.constructParamMap(getValueStack(), detail);
     BigDecimal amount =
         budgetDetailHelper.getTotalPreviousActualData(paramMap, financialYear.getEndingDate());
     for (BudgetReportView row : budgetDetailsList) {
       if (row.getId().equals(detail.getId()))
         row.setActualsLastYear(amount == null ? BigDecimal.ZERO : amount);
     }
   }
 }
示例#3
0
 @ValidationErrorPage(value = "form")
 public String generateReport() {
   showResults = true;
   CFinancialYear finYear =
       budgetService
           .find("from Budget where id=?", budgetDetail.getBudget().getId())
           .getFinancialYear();
   List<BudgetDetail> currentYearBeList = new ArrayList<BudgetDetail>();
   List<BudgetDetail> nextYearBeList = new ArrayList<BudgetDetail>();
   List<BudgetDetail> lastYearBe = new ArrayList<BudgetDetail>();
   List<BudgetDetail> lastYearRe = new ArrayList<BudgetDetail>();
   Budget b = budgetService.findById(budgetDetail.getBudget().getId(), false);
   if ("BE".equalsIgnoreCase(b.getIsbere())) {
     CFinancialYear previousYear = budgetDetailHelper.getPreviousYearFor(finYear);
     if (previousYear != null) {
       lastYearBe =
           budgetDetailService.findAllBy(
               "from BudgetDetail where budget.financialYear.id=? and budget.isPrimaryBudget=1 and "
                   + "budget.isActiveBudget=1 and budget.isbere='BE'",
               previousYear.getId());
       lastYearRe =
           budgetDetailService.findAllBy(
               "from BudgetDetail where budget.financialYear.id=? and budget.isPrimaryBudget=1 and "
                   + "budget.isActiveBudget=1 and budget.isbere='RE'",
               previousYear.getId());
     }
   } else {
     nextYearBeList = populateNextYearBe(finYear);
   }
   List<BudgetDetail> results =
       budgetDetailService.findAllBudgetDetailsForParent(
           budgetDetail.getBudget(), budgetDetail, persistenceService);
   for (BudgetDetail detail : results) {
     BudgetReportView view = new BudgetReportView();
     view.setId(detail.getId());
     view.setDepartmentCode(detail.getExecutingDepartment().getCode());
     view.setFunctionCode(detail.getFunction().getCode());
     view.setBudgetGroupName(detail.getBudgetGroup().getName());
     if ("BE".equalsIgnoreCase(detail.getBudget().getIsbere())) {
       view.setBeNextYearApproved(detail.getApprovedAmount());
       view.setBeNextYearOriginal(detail.getOriginalAmount());
       for (BudgetDetail budgetDetail : lastYearBe) {
         if (compareDetails(budgetDetail, detail)) {
           view.setBeCurrentYearApproved(budgetDetail.getApprovedAmount());
         }
       }
       for (BudgetDetail budgetDetail : lastYearRe) {
         if (compareDetails(budgetDetail, detail)) {
           view.setReCurrentYearApproved(budgetDetail.getApprovedAmount());
           view.setReCurrentYearOriginal(budgetDetail.getOriginalAmount());
         }
       }
     } else {
       view.setReCurrentYearApproved(detail.getApprovedAmount());
       view.setReCurrentYearOriginal(detail.getOriginalAmount());
       currentYearBeList = populateCurrentYearBe();
       for (BudgetDetail budgetDetail : currentYearBeList) {
         if (compareDetails(budgetDetail, detail)) {
           view.setBeCurrentYearApproved(budgetDetail.getApprovedAmount());
         }
       }
     }
     for (BudgetDetail nextYear : nextYearBeList) {
       if (compareDetails(nextYear, detail)) {
         view.setBeNextYearApproved(nextYear.getApprovedAmount());
         view.setBeNextYearOriginal(nextYear.getOriginalAmount());
       }
     }
     budgetDetailsList.add(view);
   }
   populatePreviousYearActuals(results, budgetDetail.getBudget().getFinancialYear());
   ajaxLoadBudgets();
   populateYearRange();
   canViewREApprovedAmount = canViewApprovedAmount(budgetDetail.getBudget());
   canViewBEApprovedAmount =
       canViewApprovedAmount(budgetService.getReferenceBudgetFor(budgetDetail.getBudget()));
   return "form";
 }