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.fp.businessobject;
017    
018    import java.sql.Date;
019    import java.util.LinkedHashMap;
020    
021    import org.apache.commons.lang.StringUtils;
022    import org.apache.commons.lang.time.DateUtils;
023    import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
024    import org.kuali.rice.kns.util.KualiDecimal;
025    import org.kuali.rice.kns.util.NumberUtils;
026    
027    /**
028     * This class represents a check in the system. It is a generalized check business object that will be used by the Cash Receipts
029     * document, the Cashier document, etc.
030     */
031    
032    public class CheckBase extends PersistableBusinessObjectBase implements Check {
033        private String checkNumber;
034        private Date checkDate;
035        private String description;
036        private Integer sequenceId;
037        private KualiDecimal amount;
038        private String documentNumber;
039        private String financialDocumentTypeCode;
040        private String cashieringRecordSource;
041        private Integer financialDocumentDepositLineNumber;
042    
043        /**
044         * Constructs a CheckBase business object.
045         */
046        public CheckBase() {
047            super();
048            this.sequenceId = new Integer(1);
049            this.amount = KualiDecimal.ZERO;
050        }
051    
052        /**
053         * Gets the checkDate attribute.
054         * 
055         * @return Returns the checkDate.
056         */
057        public Date getCheckDate() {
058            return checkDate;
059        }
060    
061        /**
062         * Sets the checkDate attribute value.
063         * 
064         * @param checkDate The checkDate to set.
065         */
066        public void setCheckDate(Date checkDate) {
067            this.checkDate = checkDate;
068        }
069    
070        /**
071         * Gets the checkNumber attribute.
072         * 
073         * @return Returns the checkNumber.
074         */
075        public String getCheckNumber() {
076            return checkNumber;
077        }
078    
079        /**
080         * Sets the checkNumber attribute value.
081         * 
082         * @param checkNumber The checkNumber to set.
083         */
084        public void setCheckNumber(String checkNumber) {
085            this.checkNumber = checkNumber;
086        }
087    
088        /**
089         * Gets the description attribute.
090         * 
091         * @return Returns the description.
092         */
093        public String getDescription() {
094            return description;
095        }
096    
097        /**
098         * Sets the description attribute value.
099         * 
100         * @param description The description to set.
101         */
102        public void setDescription(String description) {
103            this.description = description;
104        }
105    
106        /**
107         * Gets the sequenceId attribute.
108         * 
109         * @return Returns the sequenceId.
110         */
111        public Integer getSequenceId() {
112            return sequenceId;
113        }
114    
115        /**
116         * Sets the sequenceId attribute value.
117         * 
118         * @param sequenceId The sequenceId to set.
119         */
120        public void setSequenceId(Integer sequenceId) {
121            this.sequenceId = sequenceId;
122        }
123    
124        /**
125         * Gets the amount attribute.
126         * 
127         * @return Returns the amount.
128         */
129        public KualiDecimal getAmount() {
130            return amount;
131        }
132    
133        /**
134         * Sets the amount attribute value.
135         * 
136         * @param amount The amount to set.
137         */
138        public void setAmount(KualiDecimal amount) {
139            this.amount = amount;
140        }
141    
142    
143        /**
144         * Gets the documentNumber attribute.
145         * 
146         * @return Returns the documentNumber.
147         */
148        public String getDocumentNumber() {
149            return documentNumber;
150        }
151    
152        /**
153         * Sets the documentNumber attribute value.
154         * 
155         * @param documentNumber The documentNumber to set.
156         */
157        public void setDocumentNumber(String documentNumber) {
158            this.documentNumber = documentNumber;
159        }
160    
161        /**
162         * Gets the cashieringRecordSource attribute.
163         * 
164         * @return Returns the cashieringRecordSource.
165         */
166        public String getCashieringRecordSource() {
167            return cashieringRecordSource;
168        }
169    
170        /**
171         * Sets the cashieringRecordSource attribute value.
172         * 
173         * @param cashieringRecordSource The cashieringRecordSource to set.
174         */
175        public void setCashieringRecordSource(String financialDocumentColumnTypeCode) {
176            this.cashieringRecordSource = financialDocumentColumnTypeCode;
177        }
178    
179        /**
180         * Gets the financialDocumentTypeCode attribute.
181         * 
182         * @return Returns the financialDocumentTypeCode.
183         */
184        public String getFinancialDocumentTypeCode() {
185            return financialDocumentTypeCode;
186        }
187    
188        /**
189         * Sets the financialDocumentTypeCode attribute value.
190         * 
191         * @param financialDocumentTypeCode The financialDocumentTypeCode to set.
192         */
193        public void setFinancialDocumentTypeCode(String financialDocumentTypeCode) {
194            this.financialDocumentTypeCode = financialDocumentTypeCode;
195        }
196    
197        /**
198         * Gets the financialDocumentDepositLineNumber attribute.
199         * 
200         * @return Returns the financialDocumentDepositLineNumber.
201         */
202        public Integer getFinancialDocumentDepositLineNumber() {
203            return financialDocumentDepositLineNumber;
204        }
205    
206        /**
207         * Sets the financialDocumentDepositLineNumber attribute value.
208         * 
209         * @param financialDocumentDepositLineNumber The financialDocumentDepositLineNumber to set.
210         */
211        public void setFinancialDocumentDepositLineNumber(Integer financialDocumentDepositLineNumber) {
212            this.financialDocumentDepositLineNumber = financialDocumentDepositLineNumber;
213        }
214    
215        /**
216         * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
217         */
218        protected LinkedHashMap toStringMapper() {
219            LinkedHashMap m = new LinkedHashMap();
220    
221            m.put("sequenceId", this.sequenceId);
222            m.put("checkNumber", this.checkNumber);
223            m.put("amount", this.amount);
224            m.put("checkDate", this.checkDate);
225            m.put("financialDocumentDepositLineNumber", this.financialDocumentDepositLineNumber);
226            m.put("description", this.description);
227            m.put("documentHeaderId", this.documentNumber);
228            m.put("financialDocumentTypeCode", this.financialDocumentTypeCode);
229            m.put("cashieringRecordSource", this.cashieringRecordSource);
230    
231            return m;
232        }
233    
234    
235        /**
236         * @see org.kuali.kfs.fp.businessobject.Check#isLike(org.kuali.kfs.fp.businessobject.Check)
237         */
238        public boolean isLike(Check other) {
239            boolean like = false;
240    
241            if (StringUtils.equals(checkNumber, other.getCheckNumber())) {
242                if (StringUtils.equals(description, other.getDescription())) {
243                    if (StringUtils.equals(financialDocumentTypeCode, other.getFinancialDocumentTypeCode()) && StringUtils.equals(cashieringRecordSource, other.getCashieringRecordSource())) {
244                        if (StringUtils.equals(documentNumber, other.getDocumentNumber())) {
245                            if (NumberUtils.equals(sequenceId, other.getSequenceId())) {
246                                if (NumberUtils.equals(financialDocumentDepositLineNumber, other.getFinancialDocumentDepositLineNumber())) {
247    
248                                    if (DateUtils.isSameDay(checkDate, other.getCheckDate())) {
249                                        if ((amount != null) && amount.equals(other.getAmount())) {
250                                            like = true;
251                                        }
252                                    }
253                                }
254                            }
255                        }
256                    }
257                }
258            }
259    
260            return like;
261        }
262    }