Beispiel #1
0
  /**
   * @param searchObject
   * @return
   * @throws SystemException
   */
  public List fiscalYearList(IfoBalanceSheetSearch searchObject) throws SystemException {
    final String LOCATION = "fiscalYearList(criteriaObject:" + searchObject + " )";
    if (log.isDebugEnabled()) log.debug(LOCATION + ":: BEGIN");
    try {
      Map paramMap = new HashMap();
      StringBuffer sql =
          new StringBuffer(
              "SELECT DISTINCT TO_CHAR(FISCAL_DATE, 'YYYY') AS FISCAL_YEAR FROM IFO_INCOME_VIEW WHERE COMPANY_ID = :COMPANY_ID AND REPORT_TYPE IN ('QUARTER','ANNUAL')  ORDER BY FISCAL_YEAR DESC");
      paramMap.put("COMPANY_ID", searchObject.getCompanyId());
      SearchResult result =
          OracleDAOHelper.query(this.getDataSource(), sql.toString(), paramMap, fiscalYearMapper);

      if (log.isDebugEnabled()) log.debug(LOCATION + ":: END - result: " + result.size());
      return result;
    } catch (RuntimeException sysex) {
      throw new SystemException(LOCATION, sysex);
    } catch (Exception ex) {
      throw new SystemException(LOCATION, ex);
    }
  }
Beispiel #2
0
  public List findByCurrentCompany(IfoBalanceSheetSearch searchObject) throws SystemException {
    final String LOCATION = "findByCurrentCompany(criteriaObject:" + searchObject + ")";
    if (log.isDebugEnabled()) log.debug(LOCATION + ":: BEGIN");

    // List result = new ArrayList();
    try {
      // List params = new ArrayList();
      Map paramMap = new HashMap();
      StringBuffer sql = new StringBuffer();
      sql.append("SELECT distinct t0.* FROM IFO_INCOME_VIEW t0 ");
      sql.append("WHERE t0.COMPANY_ID = :COMPANY_ID ");
      sql.append("AND t0.REPORT_TYPE = :REPORT_TYPE ");
      paramMap.put("REPORT_TYPE", searchObject.getReportType());
      sql.append("AND UPPER(t0.LOCALE) = :LOCALE ");
      paramMap.put("LOCALE", searchObject.getLocale().toUpperCase());

      Date fiscalDateTo;
      Date fiscalDateFrom;
      if (!searchObject.isAnnual()) {
        String fiscalDateToStr = "";
        if ("Q1".equals(searchObject.getFiscalQuarter())) {
          fiscalDateToStr = "31/03/" + searchObject.getFiscalYear();
        } else if ("Q2".equals(searchObject.getFiscalQuarter())) {
          fiscalDateToStr = "30/06/" + searchObject.getFiscalYear();
        } else if ("Q3".equals(searchObject.getFiscalQuarter())) {
          fiscalDateToStr = "30/09/" + searchObject.getFiscalYear();
        } else if ("Q4".equals(searchObject.getFiscalQuarter())) {
          fiscalDateToStr = "31/12/" + searchObject.getFiscalYear();
        }
        fiscalDateTo =
            VNDirectDateUtils.stringToDate(
                fiscalDateToStr, VNDirectDateUtils.Formats.STR_DATE_TIME_FORMAT_DDMMYYYY);
        fiscalDateFrom =
            VNDirectDateUtils.addMonth(fiscalDateTo, -3 * searchObject.getNumberTerm());
        fiscalDateFrom = VNDirectDateUtils.addDay(fiscalDateFrom, 2);
      } else {
        String fiscalDateToStr = "31/12/" + searchObject.getFiscalYear();
        fiscalDateTo =
            VNDirectDateUtils.stringToDate(
                fiscalDateToStr, VNDirectDateUtils.Formats.STR_DATE_TIME_FORMAT_DDMMYYYY);
        fiscalDateFrom = VNDirectDateUtils.addYear(fiscalDateTo, -searchObject.getNumberTerm());
        fiscalDateFrom = VNDirectDateUtils.addDay(fiscalDateFrom, 2);
      }

      sql.append(" AND t0.FISCAL_DATE BETWEEN :FISCAL_DATE_FROM AND :FISCAL_DATE_TO ");
      sql.append(" ORDER BY t0.DISPLAY_ORDER, t0.FISCAL_DATE DESC ");

      paramMap.put("COMPANY_ID", searchObject.getCompanyId());
      paramMap.put("FISCAL_DATE_FROM", fiscalDateFrom);
      paramMap.put("FISCAL_DATE_TO", fiscalDateTo);

      SearchResult result =
          OracleDAOHelper.query(
              this.getDataSource(), sql.toString(), paramMap, ifoIncomeViewRowMapper, null);

      if (log.isDebugEnabled()) log.debug(LOCATION + ":: END - result:" + result.size());
      return result;
    } catch (RuntimeException sysex) {
      throw new SystemException(LOCATION, sysex);
    } catch (Exception ex) {
      throw new SystemException(LOCATION, ex);
    }
  }