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    
017    package org.kuali.kfs.fp.businessobject;
018    
019    import java.sql.Date;
020    import java.util.ArrayList;
021    import java.util.LinkedHashMap;
022    import java.util.List;
023    
024    import org.kuali.kfs.fp.document.CashManagementDocument;
025    import org.kuali.kfs.fp.document.CashReceiptDocument;
026    import org.kuali.kfs.sys.KFSPropertyConstants;
027    import org.kuali.kfs.sys.businessobject.Bank;
028    import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
029    import org.kuali.rice.kns.util.KualiDecimal;
030    
031    
032    /**
033     * This class represents a deposit used in the cash management document
034     */
035    public class Deposit extends PersistableBusinessObjectBase {
036        // primary key
037        private String documentNumber;
038        private Integer financialDocumentDepositLineNumber;
039        // attributes
040        private String depositTypeCode;
041        private Date depositDate;
042        private KualiDecimal depositAmount;
043        private String depositTicketNumber;
044        // related objects and foreign keys
045        private String depositBankCode;
046    
047        private CurrencyDetail depositedCurrency;
048        private CoinDetail depositedCoin;
049    
050        private Bank bank;
051        private CashManagementDocument cashManagementDocument;
052        private List depositCashReceiptControl;
053    
054    
055        /**
056         * Default constructor.
057         */
058        public Deposit() {
059            depositCashReceiptControl = new ArrayList();
060            bank = new Bank();
061        }
062    
063        /**
064         * Gets the bank attribute. 
065         * @return Returns the bank.
066         */
067        public Bank getBank() {
068            return bank;
069        }
070    
071        /**
072         * Sets the bank attribute value.
073         * @param bank The bank to set.
074         */
075        public void setBank(Bank bank) {
076            this.bank = bank;
077        }
078    
079        /**
080         * @return current value of cashManagementDocument.
081         */
082        public CashManagementDocument getCashManagementDocument() {
083            return cashManagementDocument;
084        }
085    
086        /**
087         * Sets the cashManagementDocument attribute value.
088         * 
089         * @param cashManagementDocument The cashManagementDocument to set.
090         */
091        public void setCashManagementDocument(CashManagementDocument cashManagementDocument) {
092            this.cashManagementDocument = cashManagementDocument;
093        }
094    
095    
096        /**
097         * @return current value of depositCashReceiptControl.
098         */
099        public List getDepositCashReceiptControl() {
100            return depositCashReceiptControl;
101        }
102    
103        /**
104         * Sets the depositCashReceiptControl attribute value.
105         * 
106         * @param depositCashReceiptControl The depositCashReceiptControl to set.
107         */
108        public void setDepositCashReceiptControl(List depositCashReceiptControl) {
109            this.depositCashReceiptControl = depositCashReceiptControl;
110        }
111    
112        /**
113         * @return current value of depositAmount.
114         */
115        public KualiDecimal getDepositAmount() {
116            return depositAmount;
117        }
118    
119        /**
120         * Sets the depositAmount attribute value.
121         * 
122         * @param depositAmount The depositAmount to set.
123         */
124        public void setDepositAmount(KualiDecimal depositAmount) {
125            this.depositAmount = depositAmount;
126        }
127    
128    
129        /**
130         * @return current value of depositBankCode.
131         */
132        public String getDepositBankCode() {
133            return depositBankCode;
134        }
135    
136        /**
137         * Sets the depositBankCode attribute value.
138         * 
139         * @param depositBankCode The depositBankCode to set.
140         */
141        public void setDepositBankCode(String depositBankCode) {
142            this.depositBankCode = depositBankCode;
143        }
144    
145    
146        /**
147         * @return current value of depositDate.
148         */
149        public Date getDepositDate() {
150            return depositDate;
151        }
152    
153        /**
154         * Sets the depositDate attribute value.
155         * 
156         * @param depositDate The depositDate to set.
157         */
158        public void setDepositDate(Date depositDate) {
159            this.depositDate = depositDate;
160        }
161    
162    
163        /**
164         * @return current value of depositTicketNumber.
165         */
166        public String getDepositTicketNumber() {
167            return depositTicketNumber;
168        }
169    
170        /**
171         * Sets the depositTicketNumber attribute value.
172         * 
173         * @param depositTicketNumber The depositTicketNumber to set.
174         */
175        public void setDepositTicketNumber(String depositTicketNumber) {
176            this.depositTicketNumber = depositTicketNumber;
177        }
178    
179        /**
180         * @return current value of depositTypeCode, under a different name, to prevent the POJO code from reformatting it
181         */
182        public String getRawDepositTypeCode() {
183            return depositTypeCode;
184        }
185    
186        /**
187         * @return current value of depositTypeCode.
188         */
189        public String getDepositTypeCode() {
190            return depositTypeCode;
191        }
192    
193        /**
194         * Sets the depositTypeCode attribute value.
195         * 
196         * @param depositTypeCode The depositTypeCode to set.
197         */
198        public void setDepositTypeCode(String depositTypeCode) {
199            this.depositTypeCode = depositTypeCode;
200        }
201    
202    
203        /**
204         * @return current value of financialDocumentDepositLineNumber.
205         */
206        public Integer getFinancialDocumentDepositLineNumber() {
207            return financialDocumentDepositLineNumber;
208        }
209    
210        /**
211         * Sets the financialDocumentDepositLineNumber attribute value.
212         * 
213         * @param financialDocumentDepositLineNumber The financialDocumentDepositLineNumber to set.
214         */
215        public void setFinancialDocumentDepositLineNumber(Integer financialDocumentDepositLineNumber) {
216            this.financialDocumentDepositLineNumber = financialDocumentDepositLineNumber;
217        }
218    
219    
220        /**
221         * @return current value of documentNumber.
222         */
223        public String getDocumentNumber() {
224            return documentNumber;
225        }
226    
227        /**
228         * Sets the documentNumber attribute value.
229         * 
230         * @param documentNumber The documentNumber to set.
231         */
232        public void setDocumentNumber(String documentNumber) {
233            this.documentNumber = documentNumber;
234        }
235    
236    
237        /**
238         * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
239         */
240        @Override
241        protected LinkedHashMap toStringMapper() {
242            LinkedHashMap m = new LinkedHashMap();
243            m.put(KFSPropertyConstants.DOCUMENT_NUMBER, getDocumentNumber());
244            m.put("financialDocumentDepositLineNumber", getFinancialDocumentDepositLineNumber());
245            return m;
246        }
247    
248    
249        /**
250         * Returns true if this deposit has the same document deposit line number as the passed in Deposit
251         * 
252         * @param other
253         * @return true if the given Deposit has primary key values equal to this Deposit
254         */
255        public boolean keysEqual(Deposit other) {
256            boolean keysEqual = false;
257    
258            if (getDocumentNumber().equals(other.getDocumentNumber())) {
259                if (getFinancialDocumentDepositLineNumber().equals(other.getFinancialDocumentDepositLineNumber())) {
260                    keysEqual = true;
261                }
262            }
263    
264            return keysEqual;
265        }
266    
267        /**
268         * This method returns whether the given deposit contains the parameter cash receipt document
269         * 
270         * @param crDoc the cash receipt document to look for
271         * @return true if the cash receipt document is part of the deposit, false if otherwise
272         */
273        public boolean containsCashReceipt(CashReceiptDocument crDoc) {
274            boolean result = false;
275            for (int i = 0; i < this.getDepositCashReceiptControl().size() && !result; i++) {
276                DepositCashReceiptControl crCtrl = (DepositCashReceiptControl) getDepositCashReceiptControl().get(i);
277                result = crCtrl.getFinancialDocumentCashReceiptNumber().equals(crDoc.getDocumentNumber());
278            }
279            return result;
280        }
281    
282        /**
283         * Gets the depositedCoin attribute.
284         * 
285         * @return Returns the depositedCoin.
286         */
287        public CoinDetail getDepositedCoin() {
288            return depositedCoin;
289        }
290    
291    
292        /**
293         * Sets the depositedCoin attribute value.
294         * 
295         * @param depositedCoin The depositedCoin to set.
296         */
297        public void setDepositedCoin(CoinDetail depositedCoin) {
298            this.depositedCoin = depositedCoin;
299        }
300    
301    
302        /**
303         * Gets the depositedCurrency attribute.
304         * 
305         * @return Returns the depositedCurrency.
306         */
307        public CurrencyDetail getDepositedCurrency() {
308            return depositedCurrency;
309        }
310    
311    
312        /**
313         * Sets the depositedCurrency attribute value.
314         * 
315         * @param depositedCurrency The depositedCurrency to set.
316         */
317        public void setDepositedCurrency(CurrencyDetail depositedCurrency) {
318            this.depositedCurrency = depositedCurrency;
319        }
320    }