001: /*
002: * Copyright 2005-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.chart.bo;
018:
019: import java.sql.Date;
020: import java.util.Calendar;
021: import java.util.LinkedHashMap;
022:
023: import org.kuali.core.bo.PersistableBusinessObjectBase;
024: import org.kuali.core.service.DateTimeService;
025: import org.kuali.kfs.KFSConstants;
026: import org.kuali.kfs.bo.Options;
027: import org.kuali.kfs.context.SpringContext;
028:
029: /**
030: *
031: */
032: public class AccountingPeriod extends PersistableBusinessObjectBase {
033:
034: private Integer universityFiscalYear;
035: private String universityFiscalPeriodCode;
036: private String universityFiscalPeriodName;
037: private String universityFiscalPeriodStatusCode; // TODO - should this be another bo?
038: private boolean budgetRolloverIndicator;
039:
040: private Date universityFiscalPeriodEndDate;
041: private Options options;
042:
043: /**
044: * Default constructor.
045: */
046: public AccountingPeriod() {
047:
048: }
049:
050: /**
051: * Gets the universityFiscalYear attribute.
052: *
053: * @return Returns the universityFiscalYear
054: */
055: public Integer getUniversityFiscalYear() {
056: return universityFiscalYear;
057: }
058:
059: /**
060: * Sets the universityFiscalYear attribute.
061: *
062: * @param universityFiscalYear The universityFiscalYear to set.
063: */
064: public void setUniversityFiscalYear(Integer universityFiscalYear) {
065: this .universityFiscalYear = universityFiscalYear;
066: }
067:
068: /**
069: * Gets the universityFiscalPeriodCode attribute.
070: *
071: * @return Returns the universityFiscalPeriodCode
072: */
073: public String getUniversityFiscalPeriodCode() {
074: return universityFiscalPeriodCode;
075: }
076:
077: /**
078: * Sets the universityFiscalPeriodCode attribute.
079: *
080: * @param universityFiscalPeriodCode The universityFiscalPeriodCode to set.
081: */
082: public void setUniversityFiscalPeriodCode(
083: String universityFiscalPeriodCode) {
084: this .universityFiscalPeriodCode = universityFiscalPeriodCode;
085: }
086:
087: /**
088: * Gets the universityFiscalPeriodName attribute.
089: *
090: * @return Returns the universityFiscalPeriodName
091: */
092: public String getUniversityFiscalPeriodName() {
093: return universityFiscalPeriodName;
094: }
095:
096: /**
097: * Sets the universityFiscalPeriodName attribute.
098: *
099: * @param universityFiscalPeriodName The universityFiscalPeriodName to set.
100: */
101: public void setUniversityFiscalPeriodName(
102: String universityFiscalPeriodName) {
103: this .universityFiscalPeriodName = universityFiscalPeriodName;
104: }
105:
106: /**
107: * Gets the universityFiscalPeriodStatusCode attribute.
108: *
109: * @return Returns the universityFiscalPeriodStatusCode
110: */
111: public String getUniversityFiscalPeriodStatusCode() {
112: return universityFiscalPeriodStatusCode;
113: }
114:
115: /**
116: * Sets the universityFiscalPeriodStatusCode attribute.
117: *
118: * @param universityFiscalPeriodStatusCode The universityFiscalPeriodStatusCode to set.
119: */
120: public void setUniversityFiscalPeriodStatusCode(
121: String universityFiscalPeriodStatusCode) {
122: this .universityFiscalPeriodStatusCode = universityFiscalPeriodStatusCode;
123: }
124:
125: /**
126: * Gets the budgetRolloverIndicator attribute.
127: *
128: * @return Returns the budgetRolloverIndicator
129: */
130: public boolean isBudgetRolloverIndicator() {
131: return budgetRolloverIndicator;
132: }
133:
134: /**
135: * Sets the budgetRolloverIndicator attribute.
136: *
137: * @param budgetRolloverIndicator The budgetRolloverIndicator to set.
138: */
139: public void setBudgetRolloverIndicator(
140: boolean budgetRolloverIndicator) {
141: this .budgetRolloverIndicator = budgetRolloverIndicator;
142: }
143:
144: /**
145: * Gets the universityFiscalPeriodEndDate attribute.
146: *
147: * @return Returns the universityFiscalPeriodEndDate
148: */
149: public Date getUniversityFiscalPeriodEndDate() {
150: return universityFiscalPeriodEndDate;
151: }
152:
153: /**
154: * Sets the universityFiscalPeriodEndDate attribute.
155: *
156: * @param universityFiscalPeriodEndDate The universityFiscalPeriodEndDate to set.
157: */
158: public void setUniversityFiscalPeriodEndDate(
159: Date universityFiscalPeriodEndDate) {
160: this .universityFiscalPeriodEndDate = universityFiscalPeriodEndDate;
161: }
162:
163: /**
164: * Determine if the current account period is open
165: *
166: * @return true if the accounting period is open; otherwise, false
167: */
168: public boolean isOpen() {
169: return KFSConstants.ACCOUNTING_PERIOD_STATUS_OPEN.equals(this
170: .getUniversityFiscalPeriodStatusCode());
171: }
172:
173: /**
174: * @return Returns the options.
175: */
176: public Options getOptions() {
177: return options;
178: }
179:
180: /**
181: * @param options The options to set.
182: * @deprecated
183: */
184: public void setOptions(Options options) {
185: this .options = options;
186: }
187:
188: /**
189: * This method returns the month that this period represents
190: *
191: * @return the actual month (1 - 12) that this period represents
192: */
193: public int getMonth() {
194: DateTimeService dateTimeService = SpringContext
195: .getBean(DateTimeService.class);
196: Calendar cal = dateTimeService.getCalendar(new Date(
197: this .universityFiscalPeriodEndDate.getTime()));
198: return cal.get(Calendar.MONTH) + 1;
199: }
200:
201: /**
202: * @see org.kuali.core.bo.BusinessObjectBase#toStringMapper()
203: */
204: protected LinkedHashMap toStringMapper() {
205: LinkedHashMap m = new LinkedHashMap();
206: m.put("universityFiscalYear", "" + this .universityFiscalYear);
207: m.put("universityFiscalPeriodCode",
208: this .universityFiscalPeriodCode);
209: return m;
210: }
211:
212: /**
213: * generates a hash code for this accounting period, based on the primary keys of the AccountingPeriod BusinesObject: university
214: * fiscal year and university fiscal period code
215: *
216: * @see java.lang.Object#hashCode()
217: */
218: @Override
219: public int hashCode() {
220: final int PRIME = 31;
221: int result = 1;
222: result = PRIME
223: * result
224: + ((universityFiscalPeriodCode == null) ? 0
225: : universityFiscalPeriodCode.hashCode());
226: result = PRIME
227: * result
228: + ((universityFiscalYear == null) ? 0
229: : universityFiscalYear.hashCode());
230: return result;
231: }
232:
233: /**
234: * determines if two accounting periods are equal, based on the primary keys of the AccountingPeriod BusinesObject: university
235: * fiscal year and university fiscal period code
236: *
237: * @see java.lang.Object#equals(java.lang.Object)
238: */
239: @Override
240: public boolean equals(Object obj) {
241: // this method was added so that
242: // org.kuali.module.financial.web.struts.form.AuxiliaryVoucherForm.populateAccountingPeriodListForRendering works properly
243: if (this == obj)
244: return true;
245: if (obj == null)
246: return false;
247: if (getClass() != obj.getClass())
248: return false;
249: final AccountingPeriod other = (AccountingPeriod) obj;
250: if (universityFiscalPeriodCode == null) {
251: if (other.universityFiscalPeriodCode != null)
252: return false;
253: } else if (!universityFiscalPeriodCode
254: .equals(other.universityFiscalPeriodCode))
255: return false;
256: if (universityFiscalYear == null) {
257: if (other.universityFiscalYear != null)
258: return false;
259: } else if (!universityFiscalYear
260: .equals(other.universityFiscalYear))
261: return false;
262: return true;
263: }
264:
265: }
|