Exemplo n.º 1
0
 private List<BudgetDetail> populateCurrentYearBe() {
   BudgetDetail detail = new BudgetDetail();
   detail.copyFrom(budgetDetail);
   detail.setBudget(null);
   return budgetDetailService.searchByCriteriaWithTypeAndFY(
       budgetDetail.getBudget().getFinancialYear().getId(), "BE", detail);
 }
Exemplo n.º 2
0
 private List<BudgetDetail> populateNextYearBe(CFinancialYear finYear) {
   BudgetDetail detail = new BudgetDetail();
   detail.copyFrom(budgetDetail);
   detail.setBudget(null);
   Date nextYear = getNextYearFor(finYear.getStartingDate());
   return budgetDetailService.searchByCriteriaWithTypeAndFY(
       financialYearDAO.getFinYearByDate(nextYear).getId(), "BE", detail);
 }
Exemplo n.º 3
0
 Map<String, Object> getParamMap() {
   Map<String, Object> paramMap = new HashMap<String, Object>();
   String budgetName = "";
   if (budgetDetail.getBudget() != null) budgetName = budgetDetail.getBudget().getName();
   paramMap.put("heading", "Budget Report For " + budgetName);
   paramMap.put("enableReApproved", Boolean.valueOf(canViewREApprovedAmount));
   paramMap.put("enableBeApproved", Boolean.valueOf(canViewBEApprovedAmount));
   return paramMap;
 }
Exemplo n.º 4
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);
     }
   }
 }
Exemplo n.º 5
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);
     }
   }
 }
Exemplo n.º 6
0
 @Action(value = "/report/budgetReport-ajaxLoadBudgets")
 public String ajaxLoadBudgets() {
   String isbere = budgetDetail.getBudget().getIsbere();
   if (budgetDetail.getBudget() != null
       && budgetDetail.getBudget().getFinancialYear() != null
       && isbere != null) {
     Long finYearId = budgetDetail.getBudget().getFinancialYear().getId();
     setBudgetList(
         getPersistenceService()
             .findAllBy(
                 "from Budget where isbere=? and financialYear.id=? and isPrimaryBudget=1 "
                     + "and isActiveBudget=1 and id not in (select parent from Budget where parent is not null and isbere=? and "
                     + "financialYear.id=? and isPrimaryBudget=1) order by name",
                 isbere,
                 finYearId,
                 isbere,
                 finYearId));
   }
   return "budgets";
 }
Exemplo n.º 7
0
 private boolean compareDetails(BudgetDetail nextYear, BudgetDetail current) {
   if (nextYear.getExecutingDepartment() != null
       && current.getExecutingDepartment() != null
       && current.getExecutingDepartment().getId() != nextYear.getExecutingDepartment().getId())
     return false;
   if (nextYear.getFunction() != null
       && current.getFunction() != null
       && current.getFunction().getId() != nextYear.getFunction().getId()) return false;
   if (nextYear.getFund() != null
       && current.getFund() != null
       && current.getFund().getId() != nextYear.getFund().getId()) return false;
   if (nextYear.getFunctionary() != null
       && current.getFunctionary() != null
       && current.getFunctionary().getId() != nextYear.getFunctionary().getId()) return false;
   if (nextYear.getScheme() != null
       && current.getScheme() != null
       && current.getScheme().getId() != nextYear.getScheme().getId()) return false;
   if (nextYear.getSubScheme() != null
       && current.getSubScheme() != null
       && current.getSubScheme().getId() != nextYear.getSubScheme().getId()) return false;
   if (nextYear.getBoundary() != null
       && current.getBoundary() != null
       && current.getBoundary().getId() != nextYear.getBoundary().getId()) return false;
   if (nextYear.getBudgetGroup() != null
       && current.getBudgetGroup() != null
       && current.getBudgetGroup().getId() != nextYear.getBudgetGroup().getId()) return false;
   if (nextYear.getBudget() != null
       && current.getBudget() != null
       && current.getBudget().getId() == nextYear.getBudget().getId()) return false;
   return true;
 }
Exemplo n.º 8
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";
 }