View Javadoc
1   /*
2    * Copyright 2006 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.service;
17  
18  import org.kuali.ole.fp.businessobject.CashDrawer;
19  import org.kuali.rice.core.api.util.type.KualiDecimal;
20  
21  /**
22   * This service interface defines methods that a CashDrawerService implementation must provide.
23   * 
24   */
25  public interface CashDrawerService {
26      /**
27       * Closes the CashDrawer instance associated with the given campus code, creating one if necessary.
28       * 
29       * @param campusCode The campus code used to retrieve the cash drawer to be closed.
30       */
31      public void closeCashDrawer(String campusCode);
32  
33      /**
34       * Closes the cash drawer associated with the given document
35       * 
36       * @param cd The cash drawer to closed.
37       */
38      public void closeCashDrawer(CashDrawer cd);
39  
40      /**
41       * 
42       * Opens the CashDrawer instance associated with the given campus, creating one if necessary. Records the given
43       * documentId as the document which opened the cashdrawer.
44       * 
45       * @param campusCode The campus code to be used to retrieve the cash drawer to be closed.
46       * @param documentId The id of the document used to open the cash drawer.
47       * @return The opened version of the cash drawer.
48       */
49      public CashDrawer openCashDrawer(String campusCode, String documentId);
50      
51      /**
52       * Opens the given cash drawer
53       * 
54       * @param cd The cash drawer to open
55       * @param documentId the document number which is opening the cash drawer
56       * @return The opened version of the cash drawer
57       */
58      public CashDrawer openCashDrawer(CashDrawer cd, String documentId);
59  
60      /**
61       * Locks the currently-open CashDrawer instance associated with the given campus, throwing an IllegalStateException if
62       * that cashDrawer is not open (i.e. is closed or locked). Records the given documentId as the document which locked the
63       * cashDrawer.
64       * 
65       * @param campusCode The campus code used to retrieve the cash drawer to be locked.
66       * @param documentId The id of the document used to lock the cash drawer.
67       */
68      public void lockCashDrawer(String campusCode, String documentId);
69      
70      /**
71       * Locks the given cash drawer, if it is open
72       * 
73       * @param cd The cash drawer to open
74       * @param documentId The document id which is locking the cash drawer
75       */
76      public void lockCashDrawer(CashDrawer cd, String documentId);
77  
78      /**
79       * Unlocks the currently-locked CashDrawer instance associated with the given campus code, 
80       * throwing an IllegalStateException if that cashDrawer is not locked (i.e. is closed or open). 
81       * Records the given documentId as the document which unlocked the cashDrawer.
82       * 
83       * @param campusCode The campus code used to retrieve the cash drawer to be unlocked.
84       * @param documentId The id of the document used to unlock the cash drawer.
85       */
86      public void unlockCashDrawer(String campusCode, String documentId);
87      
88      /**
89       * Unlocks the given cash drawer, if it is open and locked
90       * 
91       * @param cd The cash drawer to unlock
92       * @param documentId The document which is unlocking the cash drawer
93       */
94      public void unlockCashDrawer(CashDrawer cd, String documentId);
95  
96      /**
97       * Retrieves the CashDrawer instance associated with the given campus code, if any. If autocreate is true, 
98       * and no CashDrawer for the given campus exists, getByCampusCode will return a newly-created 
99       * (non-persisted) CashDrawer instance.
100      * 
101      * @param campusCode The campus code used to retrieve the cash drawer.
102      * @return CashDrawer instance or null
103      */
104     public CashDrawer getByCampusCode(String campusCode);
105     
106     /**
107      * Calculates the total amount of all the currency in the drawer.  
108      * NOTE: The value returned only refers to paper currency in the drawer and does not include coin amounts.
109      * 
110      * @param drawer The cash drawer to calculate the currency total from.
111      * @return The summed amount of currency in the cash drawer.
112      */
113     public KualiDecimal getCurrencyTotal(CashDrawer drawer);
114     
115     /**
116      * Calculates the total amount of all the coins in the drawer. 
117      * 
118      * @param drawer The drawer to calculate the coin total from.
119      * @return The summed value of coins in the drawer.
120      */
121     public KualiDecimal getCoinTotal(CashDrawer drawer);
122 }