Пример #1
0
  @Override
  public void prepare() {
    if (id != null) overhead = overheadService.findById(id, false);

    // expenditureTypeList = (List) overheadService.findAllBy("select distinct expenditureType from
    // WorkType");
    expenditureTypeList =
        (List) overheadService.findAllBy("select distinct expenditureType from Overhead");
    super.prepare();
    setupDropdownDataExcluding("account");
    try {
      List<CChartOfAccounts> accounts = new ArrayList<CChartOfAccounts>();
      // TODO:
      if (worksService.getWorksConfigValue("OVERHEAD_PURPOSE") != null)
        accounts =
            commonsService.getAccountCodeByPurpose(
                Integer.valueOf(worksService.getWorksConfigValue("OVERHEAD_PURPOSE")));
      addDropdownData("accountList", accounts);
    } catch (final ApplicationException e) {
      logger.error("Unable to load accountcode :" + e.getMessage());
      addFieldError("accountcode", "Unable to load accountcode");
    }

    final String[] expenditure = parameters.get("expenditure");
    if (!ArrayUtils.isEmpty(expenditure) && !expenditure[0].equals("-1"))
      overhead.setExpenditureType(new ExpenditureType(expenditure[0]));
  }
 public void setDepositCodesFromString(
     final String depositCodesStr, final List<Long> depositCodeIds) {
   final List<CChartOfAccounts> coaList = new ArrayList<CChartOfAccounts>();
   if (StringUtils.isNotBlank(depositCodesStr)) {
     final String[] depositCodesFromStr = depositCodesStr.split(",");
     for (final String element : depositCodesFromStr)
       coaList.addAll(commonsService.getListOfDetailCode(element.split("-")[0]));
     final List<Long> depositCodeIdsLong = new ArrayList<Long>();
     if (coaList != null && coaList.size() > 0)
       for (final CChartOfAccounts coa : coaList) depositCodeIdsLong.add(coa.getId());
     depositCodeIds.addAll(depositCodeIdsLong);
   }
 }
 public void setBudgetHeadsFromString(
     final String budgetHeadsStr, final List<String> budgetHeads, final List<Long> budgetHeadIds) {
   final List<BudgetGroup> budgetHeadList = new ArrayList<BudgetGroup>();
   final List<CChartOfAccounts> coaList = new ArrayList<CChartOfAccounts>();
   if (StringUtils.isNotBlank(budgetHeadsStr)) {
     final String[] budgetHeadsFromString = budgetHeadsStr.split(",");
     for (final String element : budgetHeadsFromString)
       // Split and obtain only the glcode
       coaList.addAll(commonsService.getListOfDetailCode(element.split("-")[0]));
     budgetHeadList.addAll(budgetDetailsDAO.getBudgetHeadForGlcodeList(coaList));
     final List<Long> budgetHeadIdsLong = new ArrayList<Long>();
     final List<String> budgetHeadIdStr = new ArrayList<String>();
     if (budgetHeadList != null && budgetHeadList.size() > 0)
       for (final BudgetGroup bdgtGrp : budgetHeadList) {
         budgetHeadIdStr.add(bdgtGrp.getId().toString());
         budgetHeadIdsLong.add(bdgtGrp.getId());
       }
     budgetHeads.addAll(budgetHeadIdStr);
     budgetHeadIds.addAll(budgetHeadIdsLong);
   }
 }