Source Code Cross Referenced for AccountBalanceObjectDaoJdbc.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » gl » dao » jdbc » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » org.kuali.module.gl.dao.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         * http://www.opensource.org/licenses/ecl1.php
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.kuali.module.gl.dao.jdbc;
017:
018:        import java.math.BigDecimal;
019:        import java.util.ArrayList;
020:        import java.util.List;
021:        import java.util.Map;
022:
023:        import org.kuali.core.dbplatform.RawSQL;
024:        import org.kuali.core.util.Guid;
025:        import org.kuali.kfs.KFSConstants;
026:        import org.kuali.kfs.bo.Options;
027:        import org.kuali.kfs.context.SpringContext;
028:        import org.kuali.module.financial.service.UniversityDateService;
029:        import org.kuali.module.gl.GLConstants;
030:        import org.kuali.module.gl.bo.UniversityDate;
031:        import org.kuali.module.gl.dao.AccountBalanceObjectDao;
032:        import org.kuali.module.gl.service.AccountBalanceService;
033:        import org.springframework.dao.IncorrectResultSizeDataAccessException;
034:        import org.springframework.jdbc.support.rowset.SqlRowSet;
035:
036:        /**
037:         * Calculate Balance By Object Balance Inquiry Screen
038:         */
039:        @RawSQL
040:        public class AccountBalanceObjectDaoJdbc extends
041:                AccountBalanceDaoJdbcBase implements  AccountBalanceObjectDao {
042:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
043:                    .getLogger(AccountBalanceObjectDaoJdbc.class);
044:
045:            /**
046:             * Returns a collection of report data for the account balance by object inquiry
047:             * 
048:             * @param universityFiscalYear the university fiscal year of reported on account balances
049:             * @param chartOfAccountsCode the chart of accounts code of reported on account balances
050:             * @param accountNumber the account number of reported on account balances
051:             * @param financialObjectLevelCode the object level code of reported on account balances
052:             * @param financialReportingSortCode the sort code for reported results
053:             * @param isCostShareExcluded whether cost share account balances should be excluded from the query or not
054:             * @param isConsolidated whether the results of the query should be consolidated
055:             * @param pendingEntriesCode whether this query should account for no pending entries, approved pending entries, or all pending entries
056:             * @return a List of Maps with the results of the query
057:             * @see org.kuali.module.gl.dao.AccountBalanceDao#findAccountBalanceByObject(java.lang.Integer, java.lang.String,
058:             *      java.lang.String, java.lang.String, java.lang.String, boolean, boolean, int)
059:             */
060:            @RawSQL
061:            public List findAccountBalanceByObject(
062:                    Integer universityFiscalYear, String chartOfAccountsCode,
063:                    String accountNumber, String financialObjectLevelCode,
064:                    String financialReportingSortCode,
065:                    boolean isCostShareExcluded, boolean isConsolidated,
066:                    int pendingEntriesCode) {
067:                LOG.debug("findAccountBalanceByObject() started");
068:
069:                Options options = optionsService
070:                        .getOptions(universityFiscalYear);
071:                List<Map<String, Object>> data = null;
072:                String sessionId = new Guid().toString();
073:                try {
074:                    // Delete any data for this session if it exists already
075:                    clearTempTable("fp_bal_by_obj_mt", "SESID", sessionId);
076:                    clearTempTable("fp_interim1_obj_mt", "SESID", sessionId);
077:
078:                    // Add in all the data we need
079:                    getSimpleJdbcTemplate()
080:                            .update(
081:                                    "INSERT INTO fp_interim1_obj_mt (UNIV_FISCAL_YR, FIN_COA_CD, ACCOUNT_NBR, SUB_ACCT_NBR,FIN_OBJECT_CD, FIN_SUB_OBJ_CD, CURR_BDLN_BAL_AMT,"
082:                                            + " ACLN_ACTLS_BAL_AMT, ACLN_ENCUM_BAL_AMT, TIMESTAMP,SESID) "
083:                                            + " SELECT A.UNIV_FISCAL_YR, A.FIN_COA_CD, A.ACCOUNT_NBR, A.SUB_ACCT_NBR,"
084:                                            + " A.FIN_OBJECT_CD, A.FIN_SUB_OBJ_CD, A.CURR_BDLN_BAL_AMT,A.ACLN_ACTLS_BAL_AMT, A.ACLN_ENCUM_BAL_AMT, A.TIMESTAMP, ?"
085:                                            + " FROM gl_acct_balances_t a, ca_object_code_t o WHERE a.univ_fiscal_yr = ? "
086:                                            + " AND a.fin_coa_cd = ?"
087:                                            + " AND a.account_nbr = ?"
088:                                            + " AND a.univ_fiscal_yr = o.univ_fiscal_yr AND a.fin_coa_cd = o.fin_coa_cd AND a.fin_object_cd = o.fin_object_cd "
089:                                            + "AND o.fin_obj_level_cd = ?",
090:                                    sessionId, universityFiscalYear,
091:                                    chartOfAccountsCode, accountNumber,
092:                                    financialObjectLevelCode);
093:
094:                    // Summarize pending entries into fp_interim1_level_mt if necessary
095:                    if ((pendingEntriesCode == AccountBalanceService.PENDING_ALL)
096:                            || (pendingEntriesCode == AccountBalanceService.PENDING_APPROVED)) {
097:                        if (getMatchingPendingEntriesByObject(options,
098:                                universityFiscalYear, chartOfAccountsCode,
099:                                accountNumber, financialObjectLevelCode,
100:                                isCostShareExcluded, pendingEntriesCode,
101:                                sessionId)) {
102:                            summarizePendingEntriesByObject(options, sessionId);
103:                        }
104:                    }
105:
106:                    // Delete what we don't need
107:                    if (isCostShareExcluded) {
108:                        purgeCostShareEntries("fp_interim1_obj_mt", "sesid",
109:                                sessionId);
110:                    }
111:
112:                    // Summarize
113:                    if (isConsolidated) {
114:                        getSimpleJdbcTemplate()
115:                                .update(
116:                                        "INSERT INTO fp_bal_by_obj_mt (SUB_ACCT_NBR, FIN_OBJECT_CD, CURR_BDLN_BAL_AMT, ACLN_ACTLS_BAL_AMT, ACLN_ENCUM_BAL_AMT, FIN_REPORT_SORT_CD, "
117:                                                + "SESID) SELECT  '*ALL*',fin_object_cd, SUM(curr_bdln_bal_amt),SUM(acln_actls_bal_amt), SUM(acln_encum_bal_amt),"
118:                                                + "'B', ? "
119:                                                + " FROM fp_interim1_obj_mt WHERE fp_interim1_obj_mt.SESID  = ?"
120:                                                + " GROUP BY fin_object_cd",
121:                                        sessionId, sessionId);
122:                    } else {
123:                        getSimpleJdbcTemplate()
124:                                .update(
125:                                        "INSERT INTO fp_bal_by_obj_mt (SUB_ACCT_NBR, FIN_OBJECT_CD, CURR_BDLN_BAL_AMT, ACLN_ACTLS_BAL_AMT, ACLN_ENCUM_BAL_AMT, FIN_REPORT_SORT_CD, "
126:                                                + "SESID) SELECT  sub_acct_nbr, fin_object_cd, SUM(curr_bdln_bal_amt), SUM(acln_actls_bal_amt),SUM(acln_encum_bal_amt), "
127:                                                + " 'B', ? "
128:                                                + " FROM fp_interim1_obj_mt WHERE fp_interim1_obj_mt.SESID = ? "
129:                                                + " GROUP BY sub_acct_nbr, fin_object_cd",
130:                                        sessionId, sessionId);
131:                    }
132:
133:                    // Here's the data
134:                    data = getSimpleJdbcTemplate()
135:                            .queryForList(
136:                                    "select SUB_ACCT_NBR, FIN_OBJECT_CD, CURR_BDLN_BAL_AMT, ACLN_ACTLS_BAL_AMT, ACLN_ENCUM_BAL_AMT, FIN_REPORT_SORT_CD from fp_bal_by_obj_mt "
137:                                            + " where SESID = ? "
138:                                            + " order by fin_object_cd",
139:                                    sessionId);
140:                } finally {
141:                    // Clean up everything
142:                    clearTempTable("fp_bal_by_obj_mt", "SESID", sessionId);
143:                    clearTempTable("fp_interim1_obj_mt", "SESID", sessionId);
144:                    clearTempTable("gl_pending_entry_mt", "SESID", sessionId);
145:                }
146:                return data;
147:            }
148:
149:            /**
150:             * Summarizes all the pending ledger entries that would need to be reported on by this inquiry, 
151:             * and saves all of that data to a temporary table
152:             * 
153:             * @param options a set of system options
154:             * @param sessionId the unique web id of the currently inquiring user, used as a key for the temp table
155:             */
156:            @RawSQL
157:            private void summarizePendingEntriesByObject(Options options,
158:                    String sessionId) {
159:                LOG.debug("summarizePendingEntriesByObject() started");
160:
161:                try {
162:
163:                    String balanceStatementSql = "SELECT CURR_BDLN_BAL_AMT,ACLN_ACTLS_BAL_AMT,ACLN_ENCUM_BAL_AMT "
164:                            + "FROM fp_interim1_obj_mt "
165:                            + "WHERE sesid = ? AND univ_fiscal_yr = ? AND fin_coa_cd = ? AND account_nbr = ? AND sub_acct_nbr = ?"
166:                            + " AND fin_object_cd = ? AND fin_sub_obj_cd = ?";
167:
168:                    String updateBalanceStatementSql = "UPDATE fp_interim1_obj_mt "
169:                            + " SET curr_bdln_bal_amt = ?,acln_actls_bal_amt = ?,acln_encum_bal_amt = ? "
170:                            + " WHERE sesid = ? AND univ_fiscal_yr = ? AND fin_coa_cd = ? AND account_nbr = ? AND sub_acct_nbr = ?"
171:                            + " AND fin_object_cd = ? AND fin_sub_obj_cd = ?";
172:
173:                    String insertBalanceStatementSql = "INSERT INTO fp_interim1_obj_mt (UNIV_FISCAL_YR, FIN_COA_CD, ACCOUNT_NBR, SUB_ACCT_NBR, FIN_OBJECT_CD, "
174:                            + "FIN_SUB_OBJ_CD, CURR_BDLN_BAL_AMT, ACLN_ACTLS_BAL_AMT, ACLN_ENCUM_BAL_AMT, TIMESTAMP, SESID) "
175:                            + "VALUES (?,?,?,?,?,?,?,?,?,"
176:                            + getDbPlatform().getCurTimeFunction() + ",?)";
177:
178:                    SqlRowSet pendingEntryRowSet = getJdbcTemplate()
179:                            .queryForRowSet(
180:                                    "SELECT b.FIN_OFFST_GNRTN_CD,t.FIN_OBJTYP_DBCR_CD,e.* "
181:                                            + "FROM gl_pending_entry_mt e,CA_OBJ_TYPE_T t,CA_BALANCE_TYPE_T b "
182:                                            + "WHERE e.SESID = ?"
183:                                            + " AND e.FIN_OBJ_TYP_CD = t.FIN_OBJ_TYP_CD AND e.fin_balance_typ_cd = b.fin_balance_typ_cd "
184:                                            + "ORDER BY e.univ_fiscal_yr,e.account_nbr,e.sub_acct_nbr,e.fin_object_cd,e.fin_sub_obj_cd,e.fin_obj_typ_cd",
185:                                    new Object[] { sessionId });
186:
187:                    int updateCount = 0;
188:                    int insertCount = 0;
189:                    while (pendingEntryRowSet.next()) {
190:
191:                        Map<String, Object> balance = null;
192:                        try {
193:                            balance = getSimpleJdbcTemplate()
194:                                    .queryForMap(
195:                                            balanceStatementSql,
196:                                            sessionId,
197:                                            pendingEntryRowSet
198:                                                    .getInt(GLConstants.ColumnNames.UNIVERSITY_FISCAL_YEAR),
199:                                            pendingEntryRowSet
200:                                                    .getString(GLConstants.ColumnNames.CHART_OF_ACCOUNTS_CODE),
201:                                            pendingEntryRowSet
202:                                                    .getString(GLConstants.ColumnNames.ACCOUNT_NUMBER),
203:                                            pendingEntryRowSet
204:                                                    .getString(GLConstants.ColumnNames.SUB_ACCOUNT_NUMBER),
205:                                            pendingEntryRowSet
206:                                                    .getString(GLConstants.ColumnNames.OBJECT_CODE),
207:                                            pendingEntryRowSet
208:                                                    .getString(GLConstants.ColumnNames.SUB_OBJECT_CODE));
209:                        } catch (IncorrectResultSizeDataAccessException ex) {
210:                            if (ex.getActualSize() != 0) {
211:                                LOG
212:                                        .error(
213:                                                "balance request sql returned more than one row, aborting",
214:                                                ex);
215:                                throw ex;
216:                            }
217:                            // no rows returned - that's ok
218:                        }
219:
220:                        String balanceType = pendingEntryRowSet
221:                                .getString(GLConstants.ColumnNames.BALANCE_TYPE_CODE);
222:                        String debitCreditCode = pendingEntryRowSet
223:                                .getString(GLConstants.ColumnNames.DEBIT_CREDIT_CODE);
224:                        String objectTypeDebitCreditCode = pendingEntryRowSet
225:                                .getString(GLConstants.ColumnNames.OBJECT_TYPE_DEBIT_CREDIT_CODE);
226:                        String offsetGenerationCode = pendingEntryRowSet
227:                                .getString(GLConstants.ColumnNames.OFFSET_GENERATION_CODE);
228:
229:                        if (balance != null) {
230:                            updateCount++;
231:
232:                            BigDecimal budget = (BigDecimal) balance
233:                                    .get(GLConstants.ColumnNames.CURRENT_BDLN_BALANCE_AMOUNT);
234:                            BigDecimal actual = (BigDecimal) balance
235:                                    .get(GLConstants.ColumnNames.ACCOUNTING_LINE_ACTUALS_BALANCE_AMOUNT);
236:                            BigDecimal encumb = (BigDecimal) balance
237:                                    .get(GLConstants.ColumnNames.ACCOUNTING_LINE_ENCUMBRANCE_BALANCE_AMOUNT);
238:
239:                            if (balanceType.equals(options
240:                                    .getBudgetCheckingBalanceTypeCd())) {
241:                                budget = budget
242:                                        .add(pendingEntryRowSet
243:                                                .getBigDecimal(GLConstants.ColumnNames.TRANSACTION_LEDGER_ENTRY_AMOUNT));
244:                            } else if (balanceType.equals(options
245:                                    .getActualFinancialBalanceTypeCd())) {
246:                                if (debitCreditCode
247:                                        .equals(objectTypeDebitCreditCode)
248:                                        || (("N".equals(offsetGenerationCode) && KFSConstants.GL_BUDGET_CODE
249:                                                .equals(debitCreditCode)))) {
250:                                    actual = actual
251:                                            .add(pendingEntryRowSet
252:                                                    .getBigDecimal(GLConstants.ColumnNames.TRANSACTION_LEDGER_ENTRY_AMOUNT));
253:                                } else {
254:                                    actual = actual
255:                                            .subtract(pendingEntryRowSet
256:                                                    .getBigDecimal(GLConstants.ColumnNames.TRANSACTION_LEDGER_ENTRY_AMOUNT));
257:                                }
258:                            } else if (balanceType.equals(options
259:                                    .getExtrnlEncumFinBalanceTypCd())
260:                                    || balanceType.equals(options
261:                                            .getIntrnlEncumFinBalanceTypCd())
262:                                    || balanceType.equals(options
263:                                            .getPreencumbranceFinBalTypeCd())
264:                                    || "CE".equals(balanceType)) {
265:                                if (debitCreditCode
266:                                        .equals(objectTypeDebitCreditCode)
267:                                        || (("N".equals(offsetGenerationCode) && KFSConstants.GL_BUDGET_CODE
268:                                                .equals(debitCreditCode)))) {
269:                                    encumb = encumb
270:                                            .add(pendingEntryRowSet
271:                                                    .getBigDecimal(GLConstants.ColumnNames.TRANSACTION_LEDGER_ENTRY_AMOUNT));
272:                                } else {
273:                                    encumb = encumb
274:                                            .subtract(pendingEntryRowSet
275:                                                    .getBigDecimal(GLConstants.ColumnNames.TRANSACTION_LEDGER_ENTRY_AMOUNT));
276:                                }
277:                            }
278:
279:                            // A balance exists, so we need to update it
280:                            getSimpleJdbcTemplate()
281:                                    .update(
282:                                            updateBalanceStatementSql,
283:                                            budget,
284:                                            actual,
285:                                            encumb,
286:                                            sessionId,
287:                                            pendingEntryRowSet
288:                                                    .getInt(GLConstants.ColumnNames.UNIVERSITY_FISCAL_YEAR),
289:                                            pendingEntryRowSet
290:                                                    .getString(GLConstants.ColumnNames.CHART_OF_ACCOUNTS_CODE),
291:                                            pendingEntryRowSet
292:                                                    .getString(GLConstants.ColumnNames.ACCOUNT_NUMBER),
293:                                            pendingEntryRowSet
294:                                                    .getString(GLConstants.ColumnNames.SUB_ACCOUNT_NUMBER),
295:                                            pendingEntryRowSet
296:                                                    .getString(GLConstants.ColumnNames.OBJECT_CODE),
297:                                            pendingEntryRowSet
298:                                                    .getString(GLConstants.ColumnNames.SUB_OBJECT_CODE));
299:                        } else {
300:                            insertCount++;
301:
302:                            BigDecimal budget = new BigDecimal("0");
303:                            BigDecimal actual = new BigDecimal("0");
304:                            BigDecimal encumb = new BigDecimal("0");
305:
306:                            if (balanceType.equals(options
307:                                    .getBudgetCheckingBalanceTypeCd())) {
308:                                budget = pendingEntryRowSet
309:                                        .getBigDecimal(GLConstants.ColumnNames.TRANSACTION_LEDGER_ENTRY_AMOUNT);
310:                            } else if (balanceType.equals(options
311:                                    .getActualFinancialBalanceTypeCd())) {
312:                                if (debitCreditCode
313:                                        .equals(objectTypeDebitCreditCode)
314:                                        || (("N".equals(offsetGenerationCode) && KFSConstants.GL_BUDGET_CODE
315:                                                .equals(debitCreditCode)))) {
316:                                    actual = pendingEntryRowSet
317:                                            .getBigDecimal(GLConstants.ColumnNames.TRANSACTION_LEDGER_ENTRY_AMOUNT);
318:                                } else {
319:                                    actual = pendingEntryRowSet
320:                                            .getBigDecimal(
321:                                                    GLConstants.ColumnNames.TRANSACTION_LEDGER_ENTRY_AMOUNT)
322:                                            .negate();
323:                                }
324:                            } else if (balanceType.equals(options
325:                                    .getExtrnlEncumFinBalanceTypCd())
326:                                    || balanceType.equals(options
327:                                            .getIntrnlEncumFinBalanceTypCd())
328:                                    || balanceType.equals(options
329:                                            .getPreencumbranceFinBalTypeCd())
330:                                    || "CE".equals(balanceType)) {
331:                                if (debitCreditCode
332:                                        .equals(objectTypeDebitCreditCode)
333:                                        || (("N".equals(offsetGenerationCode) && KFSConstants.GL_BUDGET_CODE
334:                                                .equals(debitCreditCode)))) {
335:                                    encumb = pendingEntryRowSet
336:                                            .getBigDecimal(GLConstants.ColumnNames.TRANSACTION_LEDGER_ENTRY_AMOUNT);
337:                                } else {
338:                                    encumb = pendingEntryRowSet
339:                                            .getBigDecimal(
340:                                                    GLConstants.ColumnNames.TRANSACTION_LEDGER_ENTRY_AMOUNT)
341:                                            .negate();
342:                                }
343:                            }
344:
345:                            // No balance exists, so we need to insert one
346:                            getSimpleJdbcTemplate()
347:                                    .update(
348:                                            insertBalanceStatementSql,
349:                                            pendingEntryRowSet
350:                                                    .getInt(GLConstants.ColumnNames.UNIVERSITY_FISCAL_YEAR),
351:                                            pendingEntryRowSet
352:                                                    .getString(GLConstants.ColumnNames.CHART_OF_ACCOUNTS_CODE),
353:                                            pendingEntryRowSet
354:                                                    .getString(GLConstants.ColumnNames.ACCOUNT_NUMBER),
355:                                            pendingEntryRowSet
356:                                                    .getString(GLConstants.ColumnNames.SUB_ACCOUNT_NUMBER),
357:                                            pendingEntryRowSet
358:                                                    .getString(GLConstants.ColumnNames.OBJECT_CODE),
359:                                            pendingEntryRowSet
360:                                                    .getString(GLConstants.ColumnNames.SUB_OBJECT_CODE),
361:                                            budget, actual, encumb, sessionId);
362:                        }
363:                    }
364:                    LOG.info("summarizePendingEntriesByObject() INSERTS: "
365:                            + insertCount);
366:                    LOG.info("summarizePendingEntriesByObject() UPDATES: "
367:                            + updateCount);
368:                } catch (RuntimeException ex) {
369:                    LOG
370:                            .error(
371:                                    "summarizePendingEntriesByObject() Exception running sql",
372:                                    ex);
373:                    throw ex;
374:                }
375:            }
376:
377:            /**
378:             * Get any matching pending entries. Return true if there were some, false if not.
379:             * 
380:             * @param universityFiscalYear the university fiscal year of pending entries to summarize
381:             * @param chartOfAccountsCode the chart of accounts code of pending entries to summarize
382:             * @param accountNumber the account number of pending entries to summarize
383:             * @param financialObjectLevelCode the object level code of pending entries to summarize
384:             * @param pendingEntriesCode whether to summarize all, approved, or no pending entries
385:             * @return true if any matching pending entries were found, false otherwise
386:             */
387:            @RawSQL
388:            private boolean getMatchingPendingEntriesByObject(Options options,
389:                    Integer universityFiscalYear, String chartOfAccountsCode,
390:                    String accountNumber, String financialObjectLevelCode,
391:                    boolean isCostShareExcluded, int pendingEntriesCode,
392:                    String sessionId) {
393:                LOG.debug("getMatchingPendingEntriesByObject() started");
394:
395:                // If they have specified this year, we will get all the pending entries where the year is equal or the year is null
396:                // (because most eDocs don't fill in the year field).
397:                // If they have specified a previous year, we will get all the pending entries where the year is equal to their selection
398:                // without the nulls (because we will post eDocs
399:                // with blank years tonight most probably.
400:
401:                UniversityDate today = SpringContext.getBean(
402:                        UniversityDateService.class).getCurrentUniversityDate();
403:
404:                clearTempTable("gl_pending_entry_mt", "SESID", sessionId);
405:
406:                List<Object> params = new ArrayList<Object>(20);
407:
408:                String insertSql = "insert into GL_PENDING_ENTRY_MT (SESID, FS_ORIGIN_CD, FDOC_NBR, TRN_ENTR_SEQ_NBR, "
409:                        + "FIN_COA_CD, ACCOUNT_NBR, SUB_ACCT_NBR, FIN_OBJECT_CD, FIN_SUB_OBJ_CD, FIN_BALANCE_TYP_CD,"
410:                        + "FIN_OBJ_TYP_CD, UNIV_FISCAL_YR, UNIV_FISCAL_PRD_CD, TRN_LDGR_ENTR_DESC, TRN_LDGR_ENTR_AMT, TRN_DEBIT_CRDT_CD,"
411:                        + "TRANSACTION_DT, FDOC_TYP_CD, ORG_DOC_NBR, PROJECT_CD, ORG_REFERENCE_ID, FDOC_REF_TYP_CD, FS_REF_ORIGIN_CD,FDOC_REF_NBR, "
412:                        + "FDOC_REVERSAL_DT, TRN_ENCUM_UPDT_CD, FDOC_APPROVED_CD, ACCT_SF_FINOBJ_CD, TRN_ENTR_OFST_CD,TRNENTR_PROCESS_TM) ";
413:
414:                String selectSql = "SELECT ?, p.FS_ORIGIN_CD, p.FDOC_NBR, p.TRN_ENTR_SEQ_NBR, p.FIN_COA_CD, p.ACCOUNT_NBR, "
415:                        + getDbPlatform().getIsNullFunction("p.SUB_ACCT_NBR",
416:                                "'-----'")
417:                        + ", "
418:                        + " p.FIN_OBJECT_CD, "
419:                        + getDbPlatform().getIsNullFunction("p.FIN_SUB_OBJ_CD",
420:                                "'---'")
421:                        + ", p.FIN_BALANCE_TYP_CD,p.FIN_OBJ_TYP_CD, p.UNIV_FISCAL_YR, "
422:                        + " p.UNIV_FISCAL_PRD_CD, p.TRN_LDGR_ENTR_DESC, p.TRN_LDGR_ENTR_AMT, p.TRN_DEBIT_CRDT_CD,"
423:                        + "p.TRANSACTION_DT, p.FDOC_TYP_CD, p.ORG_DOC_NBR, PROJECT_CD, p.ORG_REFERENCE_ID, p.FDOC_REF_TYP_CD, p.FS_REF_ORIGIN_CD,p.FDOC_REF_NBR, p.FDOC_REVERSAL_DT, p.TRN_ENCUM_UPDT_CD, p.FDOC_APPROVED_CD, p.ACCT_SF_FINOBJ_CD, p.TRN_ENTR_OFST_CD,p.TRNENTR_PROCESS_TM "
424:                        + "FROM gl_pending_entry_t p,ca_object_code_t o,fp_doc_header_t d "
425:                        + "WHERE o.FIN_COA_CD = p.FIN_COA_CD AND o.FIN_OBJECT_CD = p.FIN_OBJECT_CD AND o.FIN_OBJ_LEVEL_CD = ?"
426:                        + " AND p.fdoc_nbr = d.fdoc_nbr AND "
427:                        + " p.FIN_COA_CD = ?"
428:                        + " and p.account_nbr = ?"
429:                        + " and o.univ_fiscal_yr = ?";
430:                params.add(sessionId);
431:                params.add(financialObjectLevelCode);
432:                params.add(chartOfAccountsCode);
433:                params.add(accountNumber);
434:                params.add(universityFiscalYear);
435:
436:                if (pendingEntriesCode == AccountBalanceService.PENDING_ALL) {
437:                    selectSql = selectSql + " AND d.fdoc_status_cd <> '"
438:                            + KFSConstants.DocumentStatusCodes.DISAPPROVED
439:                            + "' ";
440:                } else {
441:                    selectSql = selectSql + " AND d.fdoc_status_cd = '"
442:                            + KFSConstants.DocumentStatusCodes.APPROVED + "' ";
443:                }
444:                selectSql = selectSql + " AND d.fdoc_status_cd <> '"
445:                        + KFSConstants.DocumentStatusCodes.CANCELLED + "' ";
446:                selectSql = selectSql + " AND p.FDOC_APPROVED_CD <> '"
447:                        + KFSConstants.DocumentStatusCodes.CANCELLED + "' ";
448:
449:                if (today.getUniversityFiscalYear()
450:                        .equals(universityFiscalYear)) {
451:                    selectSql = selectSql
452:                            + "AND (p.univ_fiscal_yr is null OR p.univ_fiscal_yr = ? )";
453:                    params.add(universityFiscalYear);
454:                } else {
455:                    selectSql = selectSql + "AND p.univ_fiscal_yr = ?";
456:                    params.add(universityFiscalYear);
457:                }
458:
459:                getSimpleJdbcTemplate().update(insertSql + selectSql,
460:                        params.toArray());
461:
462:                if (isCostShareExcluded) {
463:                    purgeCostShareEntries("gl_pending_entry_mt", "sesid",
464:                            sessionId);
465:                }
466:
467:                if (!hasEntriesInPendingTable(sessionId)) {
468:                    return false;
469:                }
470:
471:                fixPendingEntryDisplay(options.getUniversityFiscalYear(),
472:                        sessionId);
473:
474:                return true;
475:            }
476:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.