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