/**
   * Generate Query object for GeneralLedgerEntry search.
   *
   * @param fieldValues
   * @return
   */
  protected ReportQueryByCriteria getGeneralLedgerReportQuery(Map fieldValues) {
    Collection docTypeCodes = getDocumentType(fieldValues);
    Collection activityStatusCodes = getActivityStatusCode(fieldValues);

    Criteria criteria = OJBUtility.buildCriteriaFromMap(fieldValues, new GeneralLedgerEntry());

    // set document type code criteria
    if (!docTypeCodes.isEmpty()) {
      criteria.addIn(
          CabPropertyConstants.GeneralLedgerEntry.FINANCIAL_DOCUMENT_TYPE_CODE, docTypeCodes);
    }
    // set activity status code criteria
    if (!activityStatusCodes.isEmpty()) {
      criteria.addIn(
          CabPropertyConstants.GeneralLedgerEntry.ACTIVITY_STATUS_CODE, activityStatusCodes);
    }
    ReportQueryByCriteria query = QueryFactory.newReportQuery(GeneralLedgerEntry.class, criteria);

    List attributeList = buildAttributeList(false);

    // set the selection attributes
    String[] attributes = (String[]) attributeList.toArray(new String[attributeList.size()]);
    query.setAttributes(attributes);
    return query;
  }
Exemple #2
0
  /**
   * Find the maximum transactionLedgerEntrySequenceNumber in the entry table for a specific
   * transaction. This is used to make sure that rows added have a unique primary key.
   *
   * @param t the transaction to check
   * @return the max sequence number
   */
  public int getMaxSequenceNumber(Transaction t) {
    LOG.debug("getSequenceNumber() ");

    Criteria crit = new Criteria();
    crit.addEqualTo(UNIVERISITY_FISCAL_YEAR, t.getUniversityFiscalYear());
    crit.addEqualTo(CHART_OF_ACCOUNTS_CODE, t.getChartOfAccountsCode());
    crit.addEqualTo(ACCOUNT_NUMBER, t.getAccountNumber());
    crit.addEqualTo(SUB_ACCOUNT_NUMBER, t.getSubAccountNumber());
    crit.addEqualTo(FINANCIAL_OBJECT_CODE, t.getFinancialObjectCode());
    crit.addEqualTo(FINANCIAL_SUB_OBJECT_CODE, t.getFinancialSubObjectCode());
    crit.addEqualTo(FINANCIAL_BALANCE_TYPE_CODE, t.getFinancialBalanceTypeCode());
    crit.addEqualTo(FINANCIAL_OBJECT_TYPE_CODE, t.getFinancialObjectTypeCode());
    crit.addEqualTo(UNIVERISTY_FISCAL_PERIOD_CODE, t.getUniversityFiscalPeriodCode());
    crit.addEqualTo(FINANCIAL_DOCUMENT_TYPE_CODE, t.getFinancialDocumentTypeCode());
    crit.addEqualTo(FINANCIAL_SYSTEM_ORIGINATION_CODE, t.getFinancialSystemOriginationCode());
    crit.addEqualTo(KFSPropertyConstants.DOCUMENT_NUMBER, t.getDocumentNumber());

    ReportQueryByCriteria q = QueryFactory.newReportQuery(Entry.class, crit);
    q.setAttributes(new String[] {"max(transactionLedgerEntrySequenceNumber)"});

    Iterator iter = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(q);
    // would this work better? max = (BigDecimal)
    // getPersistenceBrokerTemplate().getObjectByQuery(q);
    BigDecimal max = null;
    while (iter.hasNext()) {
      Object[] data = (Object[]) iter.next();
      max = (BigDecimal) data[0]; // Don't know why OJB returns a BigDecimal, but it does
    }
    if (max == null) {
      return 0;
    } else {
      return max.intValue();
    }
  }
  /**
   * @see
   *     org.kuali.kfs.pdp.dataaccess.PaymentGroupDao#getDisbursementNumbersByDisbursementType(java.lang.Integer,
   *     java.lang.String, java.lang.String)
   */
  public List<Integer> getDisbursementNumbersByDisbursementTypeAndBankCode(
      Integer pid, String disbursementType, String bankCode) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("getDisbursementNumbersByDisbursementType() started");
    }

    List<Integer> results = new ArrayList<Integer>();

    Criteria criteria = new Criteria();
    criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PROCESS_ID, pid);
    criteria.addEqualTo(
        PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, disbursementType);
    criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE, bankCode);

    String[] fields =
        new String[] {PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_NBR};

    ReportQueryByCriteria rq =
        QueryFactory.newReportQuery(PaymentGroup.class, fields, criteria, true);
    rq.addOrderBy(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_NBR, true);

    Iterator i = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rq);
    while (i.hasNext()) {
      Object[] data = (Object[]) i.next();
      BigDecimal d = (BigDecimal) data[0];
      results.add(new Integer(d.intValue()));
    }
    return results;
  }
Exemple #4
0
  /**
   * @see org.kuali.kfs.gl.dataaccess.LedgerEntryBalancingDao#findEntryByGroup(java.lang.Integer,
   *     java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
   */
  public Object[] findEntryByGroup(
      Integer universityFiscalYear,
      String chartOfAccountsCode,
      String financialObjectCode,
      String financialBalanceTypeCode,
      String universityFiscalPeriodCode,
      String transactionDebitCreditCode) {
    Criteria criteria = new Criteria();
    criteria.addEqualTo(KFSConstants.UNIVERSITY_FISCAL_YEAR_PROPERTY_NAME, universityFiscalYear);
    criteria.addEqualTo(KFSConstants.CHART_OF_ACCOUNTS_CODE_PROPERTY_NAME, chartOfAccountsCode);
    criteria.addEqualTo(KFSConstants.FINANCIAL_OBJECT_CODE_PROPERTY_NAME, financialObjectCode);
    criteria.addEqualTo(
        KFSConstants.FINANCIAL_BALANCE_TYPE_CODE_PROPERTY_NAME, financialBalanceTypeCode);
    criteria.addEqualTo(
        KFSConstants.UNIVERSITY_FISCAL_PERIOD_CODE_PROPERTY_NAME, universityFiscalPeriodCode);
    criteria.addEqualTo(KFSConstants.TRANSACTION_DEBIT_CREDIT_CODE, transactionDebitCreditCode);

    ReportQueryByCriteria reportQuery = QueryFactory.newReportQuery(Entry.class, criteria);
    reportQuery.setAttributes(
        new String[] {"count(*)", "sum(" + KFSConstants.TRANSACTION_LEDGER_ENTRY_AMOUNT + ")"});
    reportQuery.addGroupBy(
        new String[] {
          KFSConstants.UNIVERSITY_FISCAL_YEAR_PROPERTY_NAME,
          KFSConstants.CHART_OF_ACCOUNTS_CODE_PROPERTY_NAME,
          KFSConstants.FINANCIAL_OBJECT_CODE_PROPERTY_NAME,
          KFSConstants.FINANCIAL_BALANCE_TYPE_CODE_PROPERTY_NAME,
          KFSConstants.UNIVERSITY_FISCAL_PERIOD_CODE_PROPERTY_NAME,
          KFSConstants.TRANSACTION_DEBIT_CREDIT_CODE
        });

    Iterator<Object[]> iterator =
        getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(reportQuery);
    Object[] returnResult = TransactionalServiceUtils.retrieveFirstAndExhaustIterator(iterator);

    if (ObjectUtils.isNull(returnResult)) {
      // Do nothing, we'll return null. Data wasn't found.
    } else if (returnResult[0] instanceof BigDecimal) {
      returnResult[0] = ((BigDecimal) returnResult[0]).intValue();
    } else {
      returnResult[0] = ((Long) returnResult[0]).intValue();
    }

    return returnResult;
  }
  /**
   * Given a process id and a disbursement type, finds a distinct list of bank codes used by payment
   * groups within that payment process
   *
   * @param pid payment process to query payment groups of
   * @param disbursementType the type of disbursements to query
   * @return a sorted List of bank codes
   */
  public List<String> getDistinctBankCodesForProcessAndType(Integer pid, String disbursementType) {
    List<String> results = new ArrayList<String>();

    Criteria criteria = new Criteria();
    criteria.addEqualTo(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_PROCESS_ID, pid);
    criteria.addEqualTo(
        PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_DISBURSEMENT_TYPE_CODE, disbursementType);

    String[] fields = new String[] {PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE};

    ReportQueryByCriteria rq =
        QueryFactory.newReportQuery(PaymentGroup.class, fields, criteria, true);
    rq.addOrderBy(PdpPropertyConstants.PaymentGroup.PAYMENT_GROUP_BANK_CODE, true);

    Iterator iter = getPersistenceBrokerTemplate().getReportQueryIteratorByQuery(rq);
    while (iter.hasNext()) {
      final Object[] row = (Object[]) iter.next();
      final String bankCode = (String) row[0];

      results.add(bankCode);
    }

    return results;
  }