View Javadoc
1   /*
2    * Copyright 2005 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.fp.businessobject;
17  
18  import java.sql.Date;
19  import java.util.LinkedHashMap;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.apache.commons.lang.time.DateUtils;
23  import org.kuali.rice.core.api.util.type.KualiDecimal;
24  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
25  import org.springframework.util.ObjectUtils;
26  
27  /**
28   * This class represents a check in the system. It is a generalized check business object that will be used by the Cash Receipts
29   * document, the Cashier document, etc.
30   */
31  
32  public class CheckBase extends PersistableBusinessObjectBase implements Check {
33      private String checkNumber;
34      private Date checkDate;
35      private String description;
36      private Integer sequenceId;
37      private KualiDecimal amount;
38      private String documentNumber;
39      private String financialDocumentTypeCode;
40      private String cashieringStatus;
41      private Integer financialDocumentDepositLineNumber;
42  
43      /**
44       * Constructs a CheckBase business object.
45       */
46      public CheckBase() {
47          super();
48          this.sequenceId = new Integer(1);
49          this.amount = KualiDecimal.ZERO;
50      }
51  
52      /**
53       * Gets the checkDate attribute.
54       * 
55       * @return Returns the checkDate.
56       */
57      @Override
58      public Date getCheckDate() {
59          return checkDate;
60      }
61  
62      /**
63       * Sets the checkDate attribute value.
64       * 
65       * @param checkDate The checkDate to set.
66       */
67      @Override
68      public void setCheckDate(Date checkDate) {
69          this.checkDate = checkDate;
70      }
71  
72      /**
73       * Gets the checkNumber attribute.
74       * 
75       * @return Returns the checkNumber.
76       */
77      @Override
78      public String getCheckNumber() {
79          return checkNumber;
80      }
81  
82      /**
83       * Sets the checkNumber attribute value.
84       * 
85       * @param checkNumber The checkNumber to set.
86       */
87      @Override
88      public void setCheckNumber(String checkNumber) {
89          this.checkNumber = checkNumber;
90      }
91  
92      /**
93       * Gets the description attribute.
94       * 
95       * @return Returns the description.
96       */
97      @Override
98      public String getDescription() {
99          return description;
100     }
101 
102     /**
103      * Sets the description attribute value.
104      * 
105      * @param description The description to set.
106      */
107     @Override
108     public void setDescription(String description) {
109         this.description = description;
110     }
111 
112     /**
113      * Gets the sequenceId attribute.
114      * 
115      * @return Returns the sequenceId.
116      */
117     @Override
118     public Integer getSequenceId() {
119         return sequenceId;
120     }
121 
122     /**
123      * Sets the sequenceId attribute value.
124      * 
125      * @param sequenceId The sequenceId to set.
126      */
127     @Override
128     public void setSequenceId(Integer sequenceId) {
129         this.sequenceId = sequenceId;
130     }
131 
132     /**
133      * Gets the amount attribute.
134      * 
135      * @return Returns the amount.
136      */
137     @Override
138     public KualiDecimal getAmount() {
139         return amount;
140     }
141 
142     /**
143      * Sets the amount attribute value.
144      * 
145      * @param amount The amount to set.
146      */
147     @Override
148     public void setAmount(KualiDecimal amount) {
149         this.amount = amount;
150     }
151 
152 
153     /**
154      * Gets the documentNumber attribute.
155      * 
156      * @return Returns the documentNumber.
157      */
158     @Override
159     public String getDocumentNumber() {
160         return documentNumber;
161     }
162 
163     /**
164      * Sets the documentNumber attribute value.
165      * 
166      * @param documentNumber The documentNumber to set.
167      */
168     @Override
169     public void setDocumentNumber(String documentNumber) {
170         this.documentNumber = documentNumber;
171     }
172 
173     /**
174      * Gets the cashieringStatus attribute.
175      * 
176      * @return Returns the cashieringStatus.
177      */
178     @Override
179     public String getCashieringStatus() {
180         return cashieringStatus;
181     }
182 
183     /**
184      * Sets the cashieringStatus attribute value.
185      * 
186      * @param cashieringStatus The cashieringStatus to set.
187      */
188     @Override
189     public void setCashieringStatus(String financialDocumentColumnTypeCode) {
190         this.cashieringStatus = financialDocumentColumnTypeCode;
191     }
192 
193     /**
194      * Gets the financialDocumentTypeCode attribute.
195      * 
196      * @return Returns the financialDocumentTypeCode.
197      */
198     @Override
199     public String getFinancialDocumentTypeCode() {
200         return financialDocumentTypeCode;
201     }
202 
203     /**
204      * Sets the financialDocumentTypeCode attribute value.
205      * 
206      * @param financialDocumentTypeCode The financialDocumentTypeCode to set.
207      */
208     @Override
209     public void setFinancialDocumentTypeCode(String financialDocumentTypeCode) {
210         this.financialDocumentTypeCode = financialDocumentTypeCode;
211     }
212 
213     /**
214      * Gets the financialDocumentDepositLineNumber attribute.
215      * 
216      * @return Returns the financialDocumentDepositLineNumber.
217      */
218     @Override
219     public Integer getFinancialDocumentDepositLineNumber() {
220         return financialDocumentDepositLineNumber;
221     }
222 
223     /**
224      * Sets the financialDocumentDepositLineNumber attribute value.
225      * 
226      * @param financialDocumentDepositLineNumber The financialDocumentDepositLineNumber to set.
227      */
228     @Override
229     public void setFinancialDocumentDepositLineNumber(Integer financialDocumentDepositLineNumber) {
230         this.financialDocumentDepositLineNumber = financialDocumentDepositLineNumber;
231     }
232 
233     /**
234      * @see org.kuali.rice.krad.bo.BusinessObjectBase#toStringMapper()
235      */
236     protected LinkedHashMap toStringMapper_RICE20_REFACTORME() {
237         LinkedHashMap m = new LinkedHashMap();
238 
239         m.put("sequenceId", this.sequenceId);
240         m.put("checkNumber", this.checkNumber);
241         m.put("amount", this.amount);
242         m.put("checkDate", this.checkDate);
243         m.put("financialDocumentDepositLineNumber", this.financialDocumentDepositLineNumber);
244         m.put("description", this.description);
245         m.put("documentHeaderId", this.documentNumber);
246         m.put("financialDocumentTypeCode", this.financialDocumentTypeCode);
247         m.put("cashieringStatus", this.cashieringStatus);
248 
249         return m;
250     }
251 
252 
253     /**
254      * @see org.kuali.ole.fp.businessobject.Check#isLike(org.kuali.ole.fp.businessobject.Check)
255      */
256     @Override
257     public boolean isLike(Check other) {
258         boolean like = false;
259 
260         if (StringUtils.equals(checkNumber, other.getCheckNumber())) {
261             if (StringUtils.equals(description, other.getDescription())) {
262                 if (StringUtils.equals(financialDocumentTypeCode, other.getFinancialDocumentTypeCode()) && StringUtils.equals(cashieringStatus, other.getCashieringStatus())) {
263                     if (StringUtils.equals(documentNumber, other.getDocumentNumber())) {
264                         if (ObjectUtils.nullSafeEquals(sequenceId, other.getSequenceId())) {
265                             if (ObjectUtils.nullSafeEquals(financialDocumentDepositLineNumber, other.getFinancialDocumentDepositLineNumber())) {
266 
267                                 if (DateUtils.isSameDay(checkDate, other.getCheckDate())) {
268                                     if ((amount != null) && amount.equals(other.getAmount())) {
269                                         like = true;
270                                     }
271                                 }
272                             }
273                         }
274                     }
275                 }
276             }
277         }
278 
279         return like;
280     }
281 }