/** * If the transaction has a reversal date, saves a new reversal based on the transaction * * @param t the transaction which is being posted * @param mode the mode the poster is currently running in * @param postDate the date this transaction should post to * @param posterReportWriterService the writer service where the poster is writing its report * @return the accomplished post type * @see * org.kuali.kfs.gl.batch.service.PostTransaction#post(org.kuali.kfs.gl.businessobject.Transaction, * int, java.util.Date) */ public String post( Transaction t, int mode, Date postDate, ReportWriterService posterReportWriterService) { LOG.debug("post() started"); if (t.getFinancialDocumentReversalDate() == null) { // No need to post this return GeneralLedgerConstants.EMPTY_CODE; } Reversal re = new Reversal(t); accountingCycleCachingService.insertReversal(re); return GeneralLedgerConstants.INSERT_CODE; }
/** * 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(); } }