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.kuali.kfs.module.ar.document.CashControlDocument;
022    import org.kuali.kfs.module.ar.document.PaymentApplicationDocument;
023    import org.kuali.kfs.sys.context.SpringContext;
024    import org.kuali.rice.kew.exception.WorkflowException;
025    import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
026    import org.kuali.rice.kns.service.DocumentService;
027    import org.kuali.rice.kns.util.KualiDecimal;
028    
029    /**
030     * @author Kuali Nervous System Team (kualidev@oncourse.iu.edu)
031     */
032    public class CashControlDetail extends PersistableBusinessObjectBase {
033    
034            private String documentNumber;
035            private String referenceFinancialDocumentNumber;
036            private String customerPaymentMediumIdentifier;
037            private KualiDecimal financialDocumentLineAmount;
038            private String customerPaymentDescription;
039            private String customerNumber;
040            private Date customerPaymentDate;
041    
042        private transient PaymentApplicationDocument referenceFinancialDocument;
043        private transient CashControlDocument cashControlDocument;
044            private Customer customer;
045        
046        private String status;
047        
048            /**
049             * Default constructor.
050             */
051            public CashControlDetail() {
052            financialDocumentLineAmount = new KualiDecimal(0);
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 referenceFinancialDocumentNumber attribute.
078             * 
079             * @return Returns the referenceFinancialDocumentNumber
080             * 
081             */
082            public String getReferenceFinancialDocumentNumber() { 
083                    return referenceFinancialDocumentNumber;
084            }
085    
086            /**
087             * Sets the referenceFinancialDocumentNumber attribute.
088             * 
089             * @param referenceFinancialDocumentNumber The referenceFinancialDocumentNumber to set.
090             */
091            public void setReferenceFinancialDocumentNumber(String referenceFinancialDocumentNumber) {
092                    this.referenceFinancialDocumentNumber = referenceFinancialDocumentNumber;
093            }
094    
095    
096            /**
097             * Gets the customerPaymentMediumIdentifier attribute.
098             * 
099             * @return Returns the customerPaymentMediumIdentifier
100             * 
101             */
102            public String getCustomerPaymentMediumIdentifier() { 
103                    return customerPaymentMediumIdentifier;
104            }
105    
106            /**
107             * Sets the customerPaymentMediumIdentifier attribute.
108             * 
109             * @param customerPaymentMediumIdentifier The customerPaymentMediumIdentifier to set.
110             * 
111             */
112            public void setCustomerPaymentMediumIdentifier(String customerPaymentMediumIdentifier) {
113                    this.customerPaymentMediumIdentifier = customerPaymentMediumIdentifier;
114            }
115    
116    
117            /**
118             * Gets the financialDocumentLineAmount attribute.
119             * 
120             * @return Returns the financialDocumentLineAmount
121             * 
122             */
123            public KualiDecimal getFinancialDocumentLineAmount() { 
124                    return financialDocumentLineAmount;
125            }
126    
127            /**
128             * Sets the financialDocumentLineAmount attribute.
129             * 
130             * @param financialDocumentLineAmount The financialDocumentLineAmount to set.
131             * 
132             */
133            public void setFinancialDocumentLineAmount(KualiDecimal financialDocumentLineAmount) {
134                    this.financialDocumentLineAmount = financialDocumentLineAmount;
135            }
136    
137    
138            /**
139             * Gets the customerPaymentDescription attribute.
140             * 
141             * @return Returns the customerPaymentDescription
142             * 
143             */
144            public String getCustomerPaymentDescription() { 
145                    return customerPaymentDescription;
146            }
147    
148            /**
149             * Sets the customerPaymentDescription attribute.
150             * 
151             * @param customerPaymentDescription The customerPaymentDescription to set.
152             * 
153             */
154            public void setCustomerPaymentDescription(String customerPaymentDescription) {
155                    this.customerPaymentDescription = customerPaymentDescription;
156            }
157    
158    
159            /**
160             * Gets the customerNumber attribute.
161             * 
162             * @return Returns the customerNumber
163             * 
164             */
165            public String getCustomerNumber() { 
166                    return customerNumber;
167            }
168    
169            /**
170             * Sets the customerNumber attribute.
171             * 
172             * @param customerNumber The customerNumber to set.
173             * 
174             */
175            public void setCustomerNumber(String customerNumber) {
176                    this.customerNumber = customerNumber;
177            }
178    
179    
180            /**
181             * Gets the customerPaymentDate attribute.
182             * 
183             * @return Returns the customerPaymentDate
184             * 
185             */
186            public Date getCustomerPaymentDate() { 
187                    return customerPaymentDate;
188            }
189    
190            /**
191             * Sets the customerPaymentDate attribute.
192             * 
193             * @param customerPaymentDate The customerPaymentDate to set.
194             * 
195             */
196            public void setCustomerPaymentDate(Date customerPaymentDate) {
197                    this.customerPaymentDate = customerPaymentDate;
198            }
199    
200    
201            /**
202             * Gets the referenceFinancialDocument attribute.
203             * 
204             * @return Returns the referenceFinancialDocument
205             * 
206             */
207            public PaymentApplicationDocument getReferenceFinancialDocument() { 
208                if (referenceFinancialDocument == null) {
209                    try {
210                    referenceFinancialDocument = (PaymentApplicationDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(this.referenceFinancialDocumentNumber);
211                }
212                catch (WorkflowException e) {
213                    throw new RuntimeException("WorkflowException caught while trying to load PayApp Document #" + referenceFinancialDocumentNumber + ".", e);
214                }
215                }
216                    return referenceFinancialDocument;
217            }
218    
219            /**
220             * Sets the referenceFinancialDocument attribute.
221             * 
222             * @param referenceFinancialDocument The referenceFinancialDocument to set.
223             * 
224             */
225            public void setReferenceFinancialDocument(PaymentApplicationDocument referenceFinancialDocument) {
226                    this.referenceFinancialDocument = referenceFinancialDocument;
227            }
228    
229            /**
230             * Gets the customer attribute.
231             * 
232             * @return Returns the customer
233             * 
234             */
235            public Customer getCustomer() { 
236                    return customer;
237            }
238    
239            /**
240             * Sets the customer attribute.
241             * 
242             * @param customer The customer to set.
243             * @deprecated
244             */
245            public void setCustomer(Customer customer) {
246                    this.customer = customer;
247            }
248    
249        /**
250             * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
251             */
252        @SuppressWarnings("unchecked")
253            protected LinkedHashMap toStringMapper() {
254                LinkedHashMap m = new LinkedHashMap();          
255            m.put("documentNumber", this.documentNumber);
256            m.put("referenceFinancialDocumentNumber", this.referenceFinancialDocumentNumber);
257                return m;
258        }
259    
260        public CashControlDocument getCashControlDocument() {
261            if (cashControlDocument == null) {
262                try {
263                    String n = getDocumentNumber();
264                    if(null == n) {
265                        return null;
266                    }
267                    cashControlDocument = (CashControlDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(n);
268                }
269                //TODO Andrew - this probably shouldnt throw an exception, because sometimes its okay for there not 
270                //     to be a document ... but how can a detail ever exist without a parent document?
271                catch (WorkflowException e) {
272                    throw new RuntimeException("WorkflowException caught while trying to load CashControl Document #" + referenceFinancialDocumentNumber + ".", e);
273                }
274            }
275            return cashControlDocument;
276        }
277    
278        public void setCashControlDocument(CashControlDocument cashControlDocument) {
279            this.cashControlDocument = cashControlDocument;
280        }
281    
282        /**
283         * This method gets cash control detail status
284         * @return cash control detail status
285         */
286        public String getStatus() {
287            return status;
288        }
289    
290        /**
291         * This method sets cash control detail status
292         * @param status
293         */
294        public void setStatus(String status) {
295            this.status = status;
296        }
297        
298    }