001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.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/ecl2.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.kfs.module.ar.businessobject;
017
018 import java.sql.Date;
019 import java.util.LinkedHashMap;
020
021 import org.apache.commons.lang.StringUtils;
022 import org.kuali.kfs.coa.businessobject.Chart;
023 import org.kuali.kfs.coa.businessobject.Organization;
024 import org.kuali.kfs.coa.service.ChartService;
025 import org.kuali.kfs.coa.service.OrganizationService;
026 import org.kuali.kfs.sys.context.SpringContext;
027 import org.kuali.rice.kns.bo.DocumentHeader;
028 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
029 import org.kuali.rice.kns.service.DateTimeService;
030
031 /**
032 * @author Kuali Nervous System Team (kualidev@oncourse.iu.edu)
033 */
034 public class AccountsReceivableDocumentHeader extends PersistableBusinessObjectBase {
035
036 private String documentNumber;
037 private String customerNumber;
038 private String processingChartOfAccountCode;
039 private String processingOrganizationCode;
040 private Date entryDate;
041 private String financialDocumentExplanationText;
042
043 private Customer customer;
044 private Chart processingChartOfAccount;
045 private Organization processingOrganization;
046 private DocumentHeader documentHeader;
047
048 /**
049 * Default constructor.
050 */
051 public AccountsReceivableDocumentHeader() {
052
053 }
054
055 /**
056 * Gets the documentNumber attribute.
057 *
058 * @return Returns the documentNumber
059 *
060 */
061 public String getDocumentNumber() {
062 return documentNumber;
063 }
064
065 /**
066 * Sets the documentNumber attribute.
067 *
068 * @param documentNumber The documentNumber to set.
069 *
070 */
071 public void setDocumentNumber(String documentNumber) {
072 this.documentNumber = documentNumber;
073 }
074
075
076 /**
077 * Gets the customerNumber attribute.
078 *
079 * @return Returns the customerNumber
080 *
081 */
082 public String getCustomerNumber() {
083 return customerNumber;
084 }
085
086 /**
087 * Sets the customerNumber attribute.
088 *
089 * @param customerNumber The customerNumber to set.
090 *
091 */
092 public void setCustomerNumber(String customerNumber) {
093 this.customerNumber = null == customerNumber ? null : customerNumber.toUpperCase();
094 }
095
096 /**
097 * Gets the processingChartOfAccountCode attribute.
098 *
099 * @return Returns the processingChartOfAccountCode
100 *
101 */
102 public String getProcessingChartOfAccountCode() {
103 return processingChartOfAccountCode;
104 }
105
106 /**
107 * Sets the processingChartOfAccountCode attribute.
108 *
109 * @param processingChartOfAccountCode The processingChartOfAccountCode to set.
110 *
111 */
112 public void setProcessingChartOfAccountCode(String processingChartOfAccountCode) {
113 this.processingChartOfAccountCode = processingChartOfAccountCode;
114 }
115
116
117 /**
118 * Gets the processingOrganizationCode attribute.
119 *
120 * @return Returns the processingOrganizationCode
121 *
122 */
123 public String getProcessingOrganizationCode() {
124 return processingOrganizationCode;
125 }
126
127 /**
128 * Sets the processingOrganizationCode attribute.
129 *
130 * @param processingOrganizationCode The processingOrganizationCode to set.
131 *
132 */
133 public void setProcessingOrganizationCode(String processingOrganizationCode) {
134 this.processingOrganizationCode = processingOrganizationCode;
135 }
136
137
138 /**
139 * Gets the entryDate attribute.
140 *
141 * @return Returns the entryDate
142 *
143 */
144 public Date getEntryDate() {
145 return entryDate;
146 }
147
148 /**
149 * Sets the entryDate attribute.
150 *
151 * @param entryDate The entryDate to set.
152 *
153 */
154 public void setEntryDate(Date entryDate) {
155 this.entryDate = entryDate;
156 }
157
158
159 /**
160 * Gets the financialDocumentExplanationText attribute.
161 *
162 * @return Returns the financialDocumentExplanationText
163 *
164 */
165 public String getFinancialDocumentExplanationText() {
166 return financialDocumentExplanationText;
167 }
168
169 /**
170 * Sets the financialDocumentExplanationText attribute.
171 *
172 * @param financialDocumentExplanationText The financialDocumentExplanationText to set.
173 *
174 */
175 public void setFinancialDocumentExplanationText(String financialDocumentExplanationText) {
176 this.financialDocumentExplanationText = financialDocumentExplanationText;
177 }
178
179 /**
180 * Gets the customer attribute.
181 *
182 * @return Returns the customer
183 *
184 */
185 public Customer getCustomer() {
186 return customer;
187 }
188
189 /**
190 * Sets the customer attribute.
191 *
192 * @param customer The customer to set.
193 * @deprecated
194 */
195 public void setCustomer(Customer customer) {
196 this.customer = customer;
197 }
198
199 /**
200 * Gets the processingChartOfAccount attribute.
201 *
202 * @return Returns the processingChartOfAccount
203 *
204 */
205 public Chart getProcessingChartOfAccount() {
206 if(processingChartOfAccount==null) {
207 if(StringUtils.isNotBlank(getProcessingChartOfAccountCode())) {
208 processingChartOfAccount = SpringContext.getBean(ChartService.class).getByPrimaryId(getProcessingChartOfAccountCode());
209 }
210 }
211
212 return processingChartOfAccount;
213 }
214
215 /**
216 * Sets the processingChartOfAccount attribute.
217 *
218 * @param processingChartOfAccount The processingChartOfAccount to set.
219 * @deprecated
220 */
221 public void setProcessingChartOfAccount(Chart processingChartOfAccount) {
222 this.processingChartOfAccount = processingChartOfAccount;
223 }
224
225 /**
226 * Gets the processingOrganization attribute.
227 *
228 * @return Returns the processingOrganization
229 *
230 */
231 public Organization getProcessingOrganization() {
232 if(processingOrganization==null) {
233 if(StringUtils.isNotBlank(getProcessingOrganizationCode()) && StringUtils.isNotBlank(getProcessingChartOfAccountCode())) {
234 processingOrganization = SpringContext.getBean(OrganizationService.class).getByPrimaryId(getProcessingChartOfAccountCode(), getProcessingOrganizationCode());
235 }
236 }
237
238 return processingOrganization;
239 }
240
241 /**
242 * Sets the processingOrganization attribute.
243 *
244 * @param processingOrganization The processingOrganization to set.
245 * @deprecated
246 */
247 public void setProcessingOrganization(Organization processingOrganization) {
248 this.processingOrganization = processingOrganization;
249 }
250
251 /**
252 * Gets the documentHeader attribute.
253 * @return Returns the documentHeader.
254 */
255 public DocumentHeader getDocumentHeader() {
256 return documentHeader;
257 }
258
259 /**
260 * Sets the documentHeader attribute value.
261 * @param documentHeader The documentHeader to set.
262 * @deprecated
263 */
264 public void setDocumentHeader(DocumentHeader documentHeader) {
265 this.documentHeader = documentHeader;
266 }
267
268 /**
269 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
270 */
271 @SuppressWarnings("unchecked")
272 protected LinkedHashMap toStringMapper() {
273 LinkedHashMap m = new LinkedHashMap();
274 m.put("documentNumber", this.documentNumber);
275 return m;
276 }
277
278 /**
279 * Get a string representation for processing organization
280 * @return
281 */
282 public String getProcessingChartOfAccCodeAndOrgCode() {
283 String returnVal = getProcessingChartOfAccountCode() + "/" +getProcessingOrganizationCode();
284
285 return returnVal;
286 }
287
288 /**
289 * Gets the documentStatus attribute.
290 * @return Returns the documentStatus.
291 */
292 public String getDocumentStatus() {
293 return getDocumentHeader().getWorkflowDocument().getStatusDisplayValue();
294 }
295
296 /**
297 *
298 * This method...
299 * @return
300 */
301 public String getCreateDate() {
302 return SpringContext.getBean(DateTimeService.class).toDateString(getDocumentHeader().getWorkflowDocument().getCreateDate());
303 }
304
305 /**
306 *
307 * This method...
308 * @return
309 */
310 public String getInitiatorId() {
311 return getDocumentHeader().getWorkflowDocument().getInitiatorNetworkId();
312 }
313 }