001: /*
002: * Copyright 2006-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:
017: package org.kuali.module.labor.bo;
018:
019: import java.sql.Timestamp;
020: import java.util.ArrayList;
021: import java.util.LinkedHashMap;
022: import java.util.List;
023:
024: import org.kuali.core.bo.user.UniversalUser;
025: import org.kuali.core.exceptions.UserNotFoundException;
026: import org.kuali.core.util.KualiDecimal;
027: import org.kuali.kfs.KFSConstants;
028: import org.kuali.kfs.KFSPropertyConstants;
029: import org.kuali.kfs.context.SpringContext;
030: import org.kuali.module.chart.bo.Chart;
031: import org.kuali.module.chart.bo.ObjectType;
032: import org.kuali.module.gl.bo.Balance;
033: import org.kuali.module.labor.service.LaborUserService;
034:
035: /**
036: * Labor business object for LedgerBalance.
037: */
038: public class LedgerBalance extends Balance {
039: private String financialObjectCode;
040: private String financialSubObjectCode;
041: private String financialBalanceTypeCode;
042: private String financialObjectTypeCode;
043: private String positionNumber;
044: private String emplid;
045: private KualiDecimal financialBeginningBalanceLineAmount;
046: private Timestamp transactionDateTimeStamp;
047: private String financialObjectFringeOrSalaryCode;
048: private Chart chartOfAccounts;
049: private ObjectType financialObjectType;
050: private UniversalUser ledgerPerson;
051: private LaborObject laborObject;
052:
053: @Deprecated
054: private Balance financialBalance; // this field is unnecessary
055:
056: /**
057: * Default constructor.
058: */
059: public LedgerBalance() {
060: super ();
061: this .setAccountLineAnnualBalanceAmount(KualiDecimal.ZERO);
062: this .setFinancialBeginningBalanceLineAmount(KualiDecimal.ZERO);
063: this
064: .setContractsGrantsBeginningBalanceAmount(KualiDecimal.ZERO);
065: }
066:
067: /**
068: * Constructs a LedgerBalance.java.
069: *
070: * @param transaction
071: */
072: public LedgerBalance(LaborTransaction transaction) {
073: this ();
074: this .setChartOfAccountsCode(transaction
075: .getChartOfAccountsCode());
076: this .setAccountNumber(transaction.getAccountNumber());
077: this .setFinancialBalanceTypeCode(transaction
078: .getFinancialBalanceTypeCode());
079: this .setEmplid(transaction.getEmplid());
080: this .setFinancialObjectCode(transaction
081: .getFinancialObjectCode());
082: this .setFinancialObjectTypeCode(transaction
083: .getFinancialObjectTypeCode());
084: this .setFinancialSubObjectCode(transaction
085: .getFinancialSubObjectCode());
086: this .setPositionNumber(transaction.getPositionNumber());
087: this .setUniversityFiscalYear(transaction
088: .getUniversityFiscalYear());
089: this .setSubAccountNumber(transaction.getSubAccountNumber());
090: }
091:
092: /**
093: * Gets the emplid
094: *
095: * @return Returns the emplid.
096: */
097: public String getEmplid() {
098: return emplid;
099: }
100:
101: /**
102: * Sets the emplid
103: *
104: * @param emplid The emplid to set.
105: */
106: public void setEmplid(String emplid) {
107: this .emplid = emplid;
108: }
109:
110: /**
111: * Gets the financialBalance
112: *
113: * @return Returns the financialBalance.
114: */
115: @Deprecated
116: public Balance getFinancialBalance() {
117: return financialBalance;
118: }
119:
120: /**
121: * Sets the financialBalance
122: *
123: * @param financialBalance The financialBalance to set.
124: */
125: @Deprecated
126: public void setFinancialBalance(Balance financialBalance) {
127: this .financialBalance = financialBalance;
128: }
129:
130: /**
131: * Gets the financialBalanceTypeCode
132: *
133: * @return Returns the financialBalanceTypeCode.
134: */
135: public String getFinancialBalanceTypeCode() {
136: return financialBalanceTypeCode;
137: }
138:
139: /**
140: * Sets the financialBalanceTypeCode
141: *
142: * @param financialBalanceTypeCode The financialBalanceTypeCode to set.
143: */
144: public void setFinancialBalanceTypeCode(
145: String financialBalanceTypeCode) {
146: this .financialBalanceTypeCode = financialBalanceTypeCode;
147: }
148:
149: /**
150: * Gets the financialBeginningBalanceLineAmount
151: *
152: * @return Returns the financialBeginningBalanceLineAmount.
153: */
154: public KualiDecimal getFinancialBeginningBalanceLineAmount() {
155: return financialBeginningBalanceLineAmount;
156: }
157:
158: /**
159: * Sets the financialBeginningBalanceLineAmount
160: *
161: * @param financialBeginningBalanceLineAmount The financialBeginningBalanceLineAmount to set.
162: */
163: public void setFinancialBeginningBalanceLineAmount(
164: KualiDecimal financialBeginningBalanceLineAmount) {
165: this .financialBeginningBalanceLineAmount = financialBeginningBalanceLineAmount;
166: }
167:
168: /**
169: * Gets the financialObjectCode
170: *
171: * @return Returns the financialObjectCode.
172: */
173: public String getFinancialObjectCode() {
174: return financialObjectCode;
175: }
176:
177: /**
178: * Sets the financialObjectCode
179: *
180: * @param financialObjectCode The financialObjectCode to set.
181: */
182: public void setFinancialObjectCode(String financialObjectCode) {
183: this .financialObjectCode = financialObjectCode;
184: }
185:
186: /**
187: * Gets the financialObjectTypeCode
188: *
189: * @return Returns the financialObjectTypeCode.
190: */
191: public String getFinancialObjectTypeCode() {
192: return financialObjectTypeCode;
193: }
194:
195: /**
196: * Sets the financialObjectTypeCode
197: *
198: * @param financialObjectTypeCode The financialObjectTypeCode to set.
199: */
200: public void setFinancialObjectTypeCode(
201: String financialObjectTypeCode) {
202: this .financialObjectTypeCode = financialObjectTypeCode;
203: }
204:
205: /**
206: * Gets the financialSubObjectCode
207: *
208: * @return Returns the financialSubObjectCode.
209: */
210: public String getFinancialSubObjectCode() {
211: return financialSubObjectCode;
212: }
213:
214: /**
215: * Sets the financialSubObjectCode
216: *
217: * @param financialSubObjectCode The financialSubObjectCode to set.
218: */
219: public void setFinancialSubObjectCode(String financialSubObjectCode) {
220: this .financialSubObjectCode = financialSubObjectCode;
221: }
222:
223: /**
224: * Gets the positionNumber
225: *
226: * @return Returns the positionNumber.
227: */
228: public String getPositionNumber() {
229: return positionNumber;
230: }
231:
232: /**
233: * Sets the positionNumber
234: *
235: * @param positionNumber The positionNumber to set.
236: */
237: public void setPositionNumber(String positionNumber) {
238: this .positionNumber = positionNumber;
239: }
240:
241: /**
242: * Gets the transactionDateTimeStamp
243: *
244: * @return Returns the transactionDateTimeStamp.
245: */
246: public Timestamp getTransactionDateTimeStamp() {
247: return transactionDateTimeStamp;
248: }
249:
250: /**
251: * Sets the transactionDateTimeStamp
252: *
253: * @param transactionDateTimeStamp The transactionDateTimeStamp to set.
254: */
255: public void setTransactionDateTimeStamp(
256: Timestamp transactionDateTimeStamp) {
257: this .transactionDateTimeStamp = transactionDateTimeStamp;
258: }
259:
260: /**
261: * Gets the getFinancialBalanceTypeCode
262: *
263: * @return getFinancialBalanceTypeCode
264: * @see org.kuali.module.gl.bo.Balance#getBalanceTypeCode()
265: */
266: @Override
267: public String getBalanceTypeCode() {
268: return this .getFinancialBalanceTypeCode();
269: }
270:
271: /**
272: * Sets the setFinancialBalanceTypeCode
273: *
274: * @param balanceTypeCode
275: * @see org.kuali.module.gl.bo.Balance#setBalanceTypeCode(java.lang.String)
276: */
277: @Override
278: public void setBalanceTypeCode(String balanceTypeCode) {
279: this .setFinancialBalanceTypeCode(balanceTypeCode);
280: }
281:
282: /**
283: * Gets the getChartOfAccounts
284: *
285: * @return getChartOfAccounts
286: * @see org.kuali.module.gl.bo.Balance#getChart()
287: */
288: @Override
289: public Chart getChart() {
290: return this .getChartOfAccounts();
291: }
292:
293: /**
294: * Sets the setChartOfAccounts
295: *
296: * @param chart
297: * @see org.kuali.module.gl.bo.Balance#setChart(org.kuali.module.chart.bo.Chart)
298: */
299: @Override
300: public void setChart(Chart chart) {
301: this .setChartOfAccounts(chart);
302: }
303:
304: /**
305: * Gets the chartOfAccounts
306: *
307: * @return Returns the chartOfAccounts.
308: */
309: public Chart getChartOfAccounts() {
310: return chartOfAccounts;
311: }
312:
313: /**
314: * Sets the chartOfAccounts
315: *
316: * @param chartOfAccounts The chartOfAccounts to set.
317: */
318: public void setChartOfAccounts(Chart chartOfAccounts) {
319: this .chartOfAccounts = chartOfAccounts;
320: }
321:
322: /**
323: * Gets the financialObjectType
324: *
325: * @return Returns the financialObjectType.
326: */
327: public ObjectType getFinancialObjectType() {
328: return financialObjectType;
329: }
330:
331: /**
332: * Sets the financialObjectType
333: *
334: * @param financialObjectType The financialObjectType to set.
335: */
336: public void setFinancialObjectType(ObjectType financialObjectType) {
337: this .financialObjectType = financialObjectType;
338: }
339:
340: /**
341: * Adds amounts in a period.
342: *
343: * @param period, amount
344: * @see org.kuali.module.gl.bo.Balance#addAmount(java.lang.String, org.kuali.core.util.KualiDecimal)
345: */
346: @Override
347: public void addAmount(String period, KualiDecimal amount) {
348: if (KFSConstants.PERIOD_CODE_ANNUAL_BALANCE.equals(period)) {
349: this .setAccountLineAnnualBalanceAmount(this
350: .getAccountLineAnnualBalanceAmount().add(amount));
351: } else if (KFSConstants.PERIOD_CODE_BEGINNING_BALANCE
352: .equals(period)) {
353: this .setFinancialBeginningBalanceLineAmount(this
354: .getFinancialBeginningBalanceLineAmount().add(
355: amount));
356: } else if (KFSConstants.PERIOD_CODE_CG_BEGINNING_BALANCE
357: .equals(period)) {
358: this .setContractsGrantsBeginningBalanceAmount(this
359: .getContractsGrantsBeginningBalanceAmount().add(
360: amount));
361: } else if (KFSConstants.MONTH1.equals(period)) {
362: setMonth1Amount(getMonth1Amount().add(amount));
363: this .setAccountLineAnnualBalanceAmount(this
364: .getAccountLineAnnualBalanceAmount().add(amount));
365: } else if (KFSConstants.MONTH2.equals(period)) {
366: setMonth2Amount(getMonth2Amount().add(amount));
367: this .setAccountLineAnnualBalanceAmount(this
368: .getAccountLineAnnualBalanceAmount().add(amount));
369: } else if (KFSConstants.MONTH3.equals(period)) {
370: setMonth3Amount(getMonth3Amount().add(amount));
371: this .setAccountLineAnnualBalanceAmount(this
372: .getAccountLineAnnualBalanceAmount().add(amount));
373: } else if (KFSConstants.MONTH4.equals(period)) {
374: setMonth4Amount(getMonth4Amount().add(amount));
375: this .setAccountLineAnnualBalanceAmount(this
376: .getAccountLineAnnualBalanceAmount().add(amount));
377: } else if (KFSConstants.MONTH5.equals(period)) {
378: setMonth5Amount(getMonth5Amount().add(amount));
379: this .setAccountLineAnnualBalanceAmount(this
380: .getAccountLineAnnualBalanceAmount().add(amount));
381: } else if (KFSConstants.MONTH6.equals(period)) {
382: setMonth6Amount(getMonth6Amount().add(amount));
383: this .setAccountLineAnnualBalanceAmount(this
384: .getAccountLineAnnualBalanceAmount().add(amount));
385: } else if (KFSConstants.MONTH7.equals(period)) {
386: setMonth7Amount(getMonth7Amount().add(amount));
387: this .setAccountLineAnnualBalanceAmount(this
388: .getAccountLineAnnualBalanceAmount().add(amount));
389: } else if (KFSConstants.MONTH8.equals(period)) {
390: setMonth8Amount(getMonth8Amount().add(amount));
391: this .setAccountLineAnnualBalanceAmount(this
392: .getAccountLineAnnualBalanceAmount().add(amount));
393: } else if (KFSConstants.MONTH9.equals(period)) {
394: setMonth9Amount(getMonth9Amount().add(amount));
395: this .setAccountLineAnnualBalanceAmount(this
396: .getAccountLineAnnualBalanceAmount().add(amount));
397: } else if (KFSConstants.MONTH10.equals(period)) {
398: setMonth10Amount(getMonth10Amount().add(amount));
399: this .setAccountLineAnnualBalanceAmount(this
400: .getAccountLineAnnualBalanceAmount().add(amount));
401: } else if (KFSConstants.MONTH11.equals(period)) {
402: setMonth11Amount(getMonth11Amount().add(amount));
403: this .setAccountLineAnnualBalanceAmount(this
404: .getAccountLineAnnualBalanceAmount().add(amount));
405: } else if (KFSConstants.MONTH12.equals(period)) {
406: setMonth12Amount(getMonth12Amount().add(amount));
407: this .setAccountLineAnnualBalanceAmount(this
408: .getAccountLineAnnualBalanceAmount().add(amount));
409: } else if (KFSConstants.MONTH13.equals(period)) {
410: setMonth13Amount(getMonth13Amount().add(amount));
411: this .setAccountLineAnnualBalanceAmount(this
412: .getAccountLineAnnualBalanceAmount().add(amount));
413: }
414: }
415:
416: /**
417: * Retrieve the associated <code>{@link LaborObject}</code> linked by chart of accounts code, financial object code, and
418: * university fiscal year
419: *
420: * @return Returns the Labor Object
421: */
422: public LaborObject getLaborObject() {
423: return laborObject;
424: }
425:
426: /**
427: * For OJB to assign a Labor Object association
428: *
429: * @param lobj
430: */
431: @Deprecated
432: public void setLaborObject(LaborObject lobj) {
433: laborObject = lobj;
434: }
435:
436: /**
437: * Gets the UniversalUser
438: *
439: * @return Returns the UniversalUser
440: */
441: public UniversalUser getLedgerPerson() {
442: if (ledgerPerson == null) {
443: // Try to find a ledger person for this emplid if one exists
444: try {
445: setLedgerPerson(SpringContext.getBean(
446: LaborUserService.class)
447: .getLaborUserByPersonPayrollIdentifier(emplid)
448: .getUniversalUser());
449: } catch (UserNotFoundException unfe) {
450: // The user is not valid. We don't have a user
451: setLedgerPerson(null);
452: }
453: }
454:
455: return ledgerPerson;
456: }
457:
458: /**
459: * Sets the ledgerPerson
460: *
461: * @param ledgerPerson The ledgerPerson to set.
462: */
463: public void setLedgerPerson(UniversalUser ledgerPerson) {
464: this .ledgerPerson = ledgerPerson;
465: }
466:
467: /**
468: * construct the primary key list of the business object
469: *
470: * @return the primary key list of the business object
471: */
472: public List<String> getPrimaryKeyList() {
473: List<String> primaryKeyList = new ArrayList<String>();
474: primaryKeyList.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
475: primaryKeyList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
476: primaryKeyList.add(KFSPropertyConstants.ACCOUNT_NUMBER);
477: primaryKeyList.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
478: primaryKeyList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
479: primaryKeyList
480: .add(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
481: primaryKeyList
482: .add(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE);
483: primaryKeyList
484: .add(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE);
485: primaryKeyList.add(KFSPropertyConstants.POSITION_NUMBER);
486: primaryKeyList.add(KFSPropertyConstants.EMPLID);
487:
488: return primaryKeyList;
489: }
490:
491: /**
492: * @see org.kuali.module.gl.bo.Balance#toStringMapper()
493: */
494: @Override
495: protected LinkedHashMap toStringMapper() {
496: LinkedHashMap map = new LinkedHashMap();
497: map.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR,
498: getUniversityFiscalYear());
499: map.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE,
500: getChartOfAccountsCode());
501: map
502: .put(KFSPropertyConstants.ACCOUNT_NUMBER,
503: getAccountNumber());
504: map.put(KFSPropertyConstants.SUB_ACCOUNT_NUMBER,
505: getSubAccountNumber());
506: map.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE,
507: getFinancialObjectCode());
508: map.put(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE,
509: getFinancialSubObjectCode());
510: map.put(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE,
511: getFinancialBalanceTypeCode());
512: map.put(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE,
513: getFinancialObjectTypeCode());
514: map.put(KFSPropertyConstants.POSITION_NUMBER, this
515: .getPositionNumber());
516: map.put(KFSPropertyConstants.EMPLID, this.getEmplid());
517: return map;
518: }
519: }
|