Source Code Cross Referenced for CashieringTransactionRuleTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » financial » rules » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » org.kuali.module.financial.rules 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.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/ecl1.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.module.financial.rules;
017:
018:        import java.sql.Date;
019:        import java.util.ArrayList;
020:        import java.util.Calendar;
021:        import java.util.GregorianCalendar;
022:        import java.util.HashMap;
023:        import java.util.Map;
024:
025:        import org.kuali.core.service.BusinessObjectService;
026:        import org.kuali.core.util.KualiDecimal;
027:        import org.kuali.kfs.context.KualiTestBase;
028:        import org.kuali.kfs.context.SpringContext;
029:        import org.kuali.module.financial.bo.CashDrawer;
030:        import org.kuali.module.financial.bo.CashDrawerTest;
031:        import org.kuali.module.financial.bo.CashieringItemInProcess;
032:        import org.kuali.module.financial.bo.CashieringTransaction;
033:        import org.kuali.module.financial.bo.Check;
034:        import org.kuali.module.financial.bo.CheckBase;
035:        import org.kuali.module.financial.bo.CoinDetail;
036:        import org.kuali.module.financial.bo.CoinDetailTest;
037:        import org.kuali.module.financial.bo.CurrencyDetail;
038:        import org.kuali.module.financial.bo.CurrencyDetailTest;
039:        import org.kuali.module.financial.document.CashManagementDocument;
040:        import org.kuali.module.financial.service.CashDrawerService;
041:        import org.kuali.module.financial.service.CashManagementService;
042:        import org.kuali.test.ConfigureContext;
043:        import org.kuali.test.fixtures.UserNameFixture;
044:
045:        @ConfigureContext(session=UserNameFixture.TWATSON)
046:        public class CashieringTransactionRuleTest extends KualiTestBase {
047:            static final String CMST_WORKGROUP = "KUALI_BRSR_KO";
048:
049:            public void testMoneyInOutBalanceRule() {
050:                CashManagementDocument cmDoc = this 
051:                        .cashManagementDocumentFixture("testMoneyInNoNegatives");
052:                CashieringTransactionRule rule = SpringContext
053:                        .getBean(CashieringTransactionRule.class);
054:
055:                // currency and currency
056:                CashieringTransaction transaction = cmDoc
057:                        .getCurrentTransaction();
058:                resetTransaction(transaction);
059:
060:                transaction
061:                        .setMoneyInCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
062:                                .convertToCurrencyDetail());
063:                transaction
064:                        .setMoneyInCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
065:                                .convertToCoinDetail());
066:                transaction
067:                        .setMoneyOutCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
068:                                .convertToCurrencyDetail());
069:                transaction
070:                        .setMoneyOutCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
071:                                .convertToCoinDetail());
072:                assertTrue(rule.checkMoneyInMoneyOutBalance(transaction));
073:
074:                transaction
075:                        .setMoneyInCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_TENS_AMOUNT
076:                                .convertToCurrencyDetail());
077:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
078:                transaction
079:                        .setMoneyInCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
080:                                .convertToCurrencyDetail());
081:                assertTrue(rule.checkMoneyInMoneyOutBalance(transaction));
082:
083:                transaction
084:                        .setMoneyInCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_TENS_COIN_AMOUNT
085:                                .convertToCoinDetail());
086:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
087:                transaction
088:                        .setMoneyInCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
089:                                .convertToCoinDetail());
090:                assertTrue(rule.checkMoneyInMoneyOutBalance(transaction));
091:
092:                transaction
093:                        .setMoneyOutCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_TENS_AMOUNT
094:                                .convertToCurrencyDetail());
095:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
096:                transaction
097:                        .setMoneyOutCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
098:                                .convertToCurrencyDetail());
099:                assertTrue(rule.checkMoneyInMoneyOutBalance(transaction));
100:
101:                transaction
102:                        .setMoneyOutCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_TENS_COIN_AMOUNT
103:                                .convertToCoinDetail());
104:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
105:                transaction
106:                        .setMoneyOutCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
107:                                .convertToCoinDetail());
108:                assertTrue(rule.checkMoneyInMoneyOutBalance(transaction));
109:
110:                // checks and currency
111:                resetTransaction(transaction);
112:                transaction
113:                        .setMoneyOutCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
114:                                .convertToCurrencyDetail());
115:                transaction
116:                        .setMoneyOutCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
117:                                .convertToCoinDetail());
118:                Check justEnoughCheck = new CheckBase();
119:                justEnoughCheck.setAmount(new KualiDecimal(3530.0));
120:                transaction.getMoneyInChecks().add(justEnoughCheck);
121:                assertTrue(rule.checkMoneyInMoneyOutBalance(transaction));
122:
123:                resetTransaction(transaction);
124:                transaction
125:                        .setMoneyOutCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
126:                                .convertToCurrencyDetail());
127:                transaction
128:                        .setMoneyOutCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
129:                                .convertToCoinDetail());
130:                Check notEnoughCheck = new CheckBase();
131:                notEnoughCheck.setAmount(new KualiDecimal(3.0));
132:                transaction.getMoneyInChecks().add(notEnoughCheck);
133:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
134:
135:                resetTransaction(transaction);
136:                transaction
137:                        .setMoneyOutCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
138:                                .convertToCurrencyDetail());
139:                transaction
140:                        .setMoneyOutCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
141:                                .convertToCoinDetail());
142:                Check tooMuchCheck = new CheckBase();
143:                tooMuchCheck.setAmount(new KualiDecimal(1500000.0));
144:                transaction.getMoneyInChecks().add(tooMuchCheck);
145:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
146:
147:                // misc advance and currency
148:                resetTransaction(transaction);
149:                transaction
150:                        .setMoneyOutCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
151:                                .convertToCurrencyDetail());
152:                transaction
153:                        .setMoneyOutCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
154:                                .convertToCoinDetail());
155:                CashieringItemInProcess currAdvance = transaction
156:                        .getNewItemInProcess();
157:                currAdvance.setItemAmount(new KualiDecimal(3530.0));
158:                currAdvance.setItemIdentifier(new Integer(27));
159:                currAdvance.setItemOpenDate(new Date(new GregorianCalendar()
160:                        .getTimeInMillis()));
161:                assertTrue(rule.checkMoneyInMoneyOutBalance(transaction));
162:
163:                resetTransaction(transaction);
164:                transaction
165:                        .setMoneyOutCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
166:                                .convertToCurrencyDetail());
167:                transaction
168:                        .setMoneyOutCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
169:                                .convertToCoinDetail());
170:                currAdvance = transaction.getNewItemInProcess();
171:                currAdvance.setItemAmount(new KualiDecimal(30.0));
172:                currAdvance.setItemIdentifier(new Integer(27));
173:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
174:
175:                resetTransaction(transaction);
176:                transaction
177:                        .setMoneyOutCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
178:                                .convertToCurrencyDetail());
179:                transaction
180:                        .setMoneyOutCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
181:                                .convertToCoinDetail());
182:                currAdvance = transaction.getNewItemInProcess();
183:                currAdvance.setItemAmount(new KualiDecimal(1000000.0));
184:                currAdvance.setItemIdentifier(new Integer(27));
185:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
186:
187:                // currency and misc advance
188:                resetTransaction(transaction);
189:                CashieringItemInProcess oldAdvance = new CashieringItemInProcess();
190:                oldAdvance.setCurrentPayment(new KualiDecimal(3530.0));
191:                oldAdvance.setItemRemainingAmount(new KualiDecimal(10000.0));
192:                oldAdvance.setItemIdentifier(new Integer(58));
193:                oldAdvance.setItemOpenDate(new Date(new GregorianCalendar()
194:                        .getTimeInMillis()));
195:                transaction.getOpenItemsInProcess().add(oldAdvance);
196:                transaction
197:                        .setMoneyInCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
198:                                .convertToCurrencyDetail());
199:                transaction
200:                        .setMoneyInCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
201:                                .convertToCoinDetail());
202:                assertTrue(rule.checkMoneyInMoneyOutBalance(transaction));
203:
204:                resetTransaction(transaction);
205:                oldAdvance = new CashieringItemInProcess();
206:                oldAdvance.setCurrentPayment(new KualiDecimal(3530.0));
207:                oldAdvance.setItemRemainingAmount(new KualiDecimal(10000.0));
208:                oldAdvance.setItemIdentifier(new Integer(58));
209:                oldAdvance.setItemOpenDate(new Date(new GregorianCalendar()
210:                        .getTimeInMillis()));
211:                transaction.getOpenItemsInProcess().add(oldAdvance);
212:                transaction
213:                        .setMoneyInCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ZERO_AMOUNT
214:                                .convertToCurrencyDetail());
215:                transaction
216:                        .setMoneyInCoin(CoinDetailTest.CoinDetailAmountFixture.ZERO_COIN_AMOUNT
217:                                .convertToCoinDetail());
218:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
219:
220:                resetTransaction(transaction);
221:                oldAdvance = new CashieringItemInProcess();
222:                oldAdvance.setCurrentPayment(new KualiDecimal(3530.0));
223:                oldAdvance.setItemRemainingAmount(new KualiDecimal(10000.0));
224:                oldAdvance.setItemIdentifier(new Integer(58));
225:                oldAdvance.setItemOpenDate(new Date(new GregorianCalendar()
226:                        .getTimeInMillis()));
227:                transaction.getOpenItemsInProcess().add(oldAdvance);
228:                transaction
229:                        .setMoneyInCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_TENS_AMOUNT
230:                                .convertToCurrencyDetail());
231:                transaction
232:                        .setMoneyInCoin(CoinDetailTest.CoinDetailAmountFixture.ALL_TENS_COIN_AMOUNT
233:                                .convertToCoinDetail());
234:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
235:
236:                // checks and misc advance
237:                resetTransaction(transaction);
238:                oldAdvance = new CashieringItemInProcess();
239:                oldAdvance.setCurrentPayment(new KualiDecimal(50.0));
240:                oldAdvance.setItemRemainingAmount(new KualiDecimal(10000.0));
241:                oldAdvance.setItemIdentifier(new Integer(58));
242:                oldAdvance.setItemOpenDate(new Date(new GregorianCalendar()
243:                        .getTimeInMillis()));
244:                justEnoughCheck = new CheckBase();
245:                justEnoughCheck.setAmount(new KualiDecimal(50.0));
246:                transaction.getMoneyInChecks().add(justEnoughCheck);
247:                transaction.getOpenItemsInProcess().add(oldAdvance);
248:                assertTrue(rule.checkMoneyInMoneyOutBalance(transaction));
249:
250:                resetTransaction(transaction);
251:                oldAdvance = new CashieringItemInProcess();
252:                oldAdvance.setCurrentPayment(new KualiDecimal(3530.0));
253:                oldAdvance.setItemRemainingAmount(new KualiDecimal(10000.0));
254:                oldAdvance.setItemIdentifier(new Integer(58));
255:                oldAdvance.setItemOpenDate(new Date(new GregorianCalendar()
256:                        .getTimeInMillis()));
257:                transaction.getOpenItemsInProcess().add(oldAdvance);
258:                notEnoughCheck = new CheckBase();
259:                notEnoughCheck.setAmount(new KualiDecimal(3.0));
260:                transaction.getMoneyInChecks().add(notEnoughCheck);
261:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
262:
263:                resetTransaction(transaction);
264:                oldAdvance = new CashieringItemInProcess();
265:                oldAdvance.setCurrentPayment(new KualiDecimal(3530.0));
266:                oldAdvance.setItemRemainingAmount(new KualiDecimal(10000.0));
267:                oldAdvance.setItemIdentifier(new Integer(58));
268:                oldAdvance.setItemOpenDate(new Date(new GregorianCalendar()
269:                        .getTimeInMillis()));
270:                transaction.getOpenItemsInProcess().add(oldAdvance);
271:                tooMuchCheck = new CheckBase();
272:                tooMuchCheck.setAmount(new KualiDecimal(1500000.0));
273:                transaction.getMoneyInChecks().add(tooMuchCheck);
274:                assertFalse(rule.checkMoneyInMoneyOutBalance(transaction));
275:            }
276:
277:            public void testMoneyInNoNegatives() {
278:                CashManagementDocument cmDoc = this 
279:                        .cashManagementDocumentFixture("testMoneyInNoNegatives");
280:                CashieringTransactionRule rule = SpringContext
281:                        .getBean(CashieringTransactionRule.class);
282:
283:                cmDoc
284:                        .getCurrentTransaction()
285:                        .setMoneyInCurrency(
286:                                CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
287:                                        .convertToCurrencyDetail());
288:                cmDoc
289:                        .getCurrentTransaction()
290:                        .setMoneyInCoin(
291:                                CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
292:                                        .convertToCoinDetail());
293:                assertTrue(rule.checkMoneyInNoNegatives(cmDoc
294:                        .getCurrentTransaction()));
295:
296:                cmDoc
297:                        .getCurrentTransaction()
298:                        .setMoneyInCurrency(
299:                                CurrencyDetailTest.CurrencyDetailAmountFixture.NEGATIVE_AMOUNT
300:                                        .convertToCurrencyDetail());
301:                assertFalse("Hundred Dollar", rule
302:                        .checkMoneyInNoNegatives(cmDoc.getCurrentTransaction()));
303:                cmDoc.getCurrentTransaction().getMoneyInCurrency()
304:                        .setFinancialDocumentHundredDollarAmount(
305:                                new KualiDecimal(100));
306:                assertFalse("Fifty Dollar", rule.checkMoneyInNoNegatives(cmDoc
307:                        .getCurrentTransaction()));
308:                cmDoc.getCurrentTransaction().getMoneyInCurrency()
309:                        .setFinancialDocumentFiftyDollarAmount(
310:                                new KualiDecimal(100));
311:                assertFalse("Twenty Dollar", rule.checkMoneyInNoNegatives(cmDoc
312:                        .getCurrentTransaction()));
313:                cmDoc.getCurrentTransaction().getMoneyInCurrency()
314:                        .setFinancialDocumentTwentyDollarAmount(
315:                                new KualiDecimal(100));
316:                assertFalse("Ten Dollar", rule.checkMoneyInNoNegatives(cmDoc
317:                        .getCurrentTransaction()));
318:                cmDoc.getCurrentTransaction().getMoneyInCurrency()
319:                        .setFinancialDocumentTenDollarAmount(
320:                                new KualiDecimal(100));
321:                assertFalse("Five Dollar", rule.checkMoneyInNoNegatives(cmDoc
322:                        .getCurrentTransaction()));
323:                cmDoc.getCurrentTransaction().getMoneyInCurrency()
324:                        .setFinancialDocumentFiveDollarAmount(
325:                                new KualiDecimal(100));
326:                assertFalse("Two Dollar", rule.checkMoneyInNoNegatives(cmDoc
327:                        .getCurrentTransaction()));
328:                cmDoc.getCurrentTransaction().getMoneyInCurrency()
329:                        .setFinancialDocumentTwoDollarAmount(
330:                                new KualiDecimal(100));
331:                assertFalse("One Dollar", rule.checkMoneyInNoNegatives(cmDoc
332:                        .getCurrentTransaction()));
333:                cmDoc.getCurrentTransaction().getMoneyInCurrency()
334:                        .setFinancialDocumentOneDollarAmount(
335:                                new KualiDecimal(100));
336:                assertTrue(rule.checkMoneyInNoNegatives(cmDoc
337:                        .getCurrentTransaction()));
338:
339:                cmDoc
340:                        .getCurrentTransaction()
341:                        .setMoneyInCoin(
342:                                CoinDetailTest.CoinDetailAmountFixture.NEGATIVE_COIN_AMOUNT
343:                                        .convertToCoinDetail());
344:                assertFalse("Hundred Cent", rule.checkMoneyInNoNegatives(cmDoc
345:                        .getCurrentTransaction()));
346:                cmDoc.getCurrentTransaction().getMoneyInCoin()
347:                        .setFinancialDocumentHundredCentAmount(
348:                                new KualiDecimal(1));
349:                assertFalse("Fifty Cent", rule.checkMoneyInNoNegatives(cmDoc
350:                        .getCurrentTransaction()));
351:                cmDoc.getCurrentTransaction().getMoneyInCoin()
352:                        .setFinancialDocumentFiftyCentAmount(
353:                                new KualiDecimal(1));
354:                assertFalse("Twenty Five Cent", rule
355:                        .checkMoneyInNoNegatives(cmDoc.getCurrentTransaction()));
356:                cmDoc.getCurrentTransaction().getMoneyInCoin()
357:                        .setFinancialDocumentTwentyFiveCentAmount(
358:                                new KualiDecimal(1));
359:                assertFalse("Ten Cent", rule.checkMoneyInNoNegatives(cmDoc
360:                        .getCurrentTransaction()));
361:                cmDoc.getCurrentTransaction().getMoneyInCoin()
362:                        .setFinancialDocumentTenCentAmount(new KualiDecimal(1));
363:                assertFalse("Five Cent", rule.checkMoneyInNoNegatives(cmDoc
364:                        .getCurrentTransaction()));
365:                cmDoc
366:                        .getCurrentTransaction()
367:                        .getMoneyInCoin()
368:                        .setFinancialDocumentFiveCentAmount(new KualiDecimal(1));
369:                assertFalse("One Cent", rule.checkMoneyInNoNegatives(cmDoc
370:                        .getCurrentTransaction()));
371:                cmDoc.getCurrentTransaction().getMoneyInCoin()
372:                        .setFinancialDocumentOneCentAmount(new KualiDecimal(1));
373:                assertTrue(rule.checkMoneyInNoNegatives(cmDoc
374:                        .getCurrentTransaction()));
375:
376:                cmDoc
377:                        .getCurrentTransaction()
378:                        .setMoneyInCurrency(
379:                                CurrencyDetailTest.CurrencyDetailAmountFixture.NULL_AMOUNT
380:                                        .convertToCurrencyDetail());
381:                assertTrue(rule.checkMoneyInNoNegatives(cmDoc
382:                        .getCurrentTransaction()));
383:                cmDoc.getCurrentTransaction().setMoneyInCoin(
384:                        CoinDetailTest.CoinDetailAmountFixture.NULL_COIN_AMOUNT
385:                                .convertToCoinDetail());
386:                assertTrue(rule.checkMoneyInNoNegatives(cmDoc
387:                        .getCurrentTransaction()));
388:
389:                cmDoc
390:                        .getCurrentTransaction()
391:                        .setMoneyInCurrency(
392:                                CurrencyDetailTest.CurrencyDetailAmountFixture.ZERO_AMOUNT
393:                                        .convertToCurrencyDetail());
394:                assertTrue(rule.checkMoneyInNoNegatives(cmDoc
395:                        .getCurrentTransaction()));
396:                cmDoc.getCurrentTransaction().setMoneyInCoin(
397:                        CoinDetailTest.CoinDetailAmountFixture.ZERO_COIN_AMOUNT
398:                                .convertToCoinDetail());
399:                assertTrue(rule.checkMoneyInNoNegatives(cmDoc
400:                        .getCurrentTransaction()));
401:            }
402:
403:            public void testMoneyOutNoNegatives() {
404:                CashManagementDocument cmDoc = this 
405:                        .cashManagementDocumentFixture("testMoneyOutNoNegatives");
406:                CashieringTransactionRule rule = SpringContext
407:                        .getBean(CashieringTransactionRule.class);
408:
409:                cmDoc
410:                        .getCurrentTransaction()
411:                        .setMoneyOutCurrency(
412:                                CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
413:                                        .convertToCurrencyDetail());
414:                cmDoc
415:                        .getCurrentTransaction()
416:                        .setMoneyOutCoin(
417:                                CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
418:                                        .convertToCoinDetail());
419:                assertTrue(rule.checkMoneyOutNoNegatives(cmDoc
420:                        .getCurrentTransaction()));
421:
422:                cmDoc
423:                        .getCurrentTransaction()
424:                        .setMoneyOutCurrency(
425:                                CurrencyDetailTest.CurrencyDetailAmountFixture.NEGATIVE_AMOUNT
426:                                        .convertToCurrencyDetail());
427:                assertFalse("Hundred Dollar",
428:                        rule.checkMoneyOutNoNegatives(cmDoc
429:                                .getCurrentTransaction()));
430:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
431:                        .setFinancialDocumentHundredDollarAmount(
432:                                new KualiDecimal(100));
433:                assertFalse("Fifty Dollar", rule.checkMoneyOutNoNegatives(cmDoc
434:                        .getCurrentTransaction()));
435:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
436:                        .setFinancialDocumentFiftyDollarAmount(
437:                                new KualiDecimal(100));
438:                assertFalse("Twenty Dollar",
439:                        rule.checkMoneyOutNoNegatives(cmDoc
440:                                .getCurrentTransaction()));
441:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
442:                        .setFinancialDocumentTwentyDollarAmount(
443:                                new KualiDecimal(100));
444:                assertFalse("Ten Dollar", rule.checkMoneyOutNoNegatives(cmDoc
445:                        .getCurrentTransaction()));
446:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
447:                        .setFinancialDocumentTenDollarAmount(
448:                                new KualiDecimal(100));
449:                assertFalse("Five Dollar", rule.checkMoneyOutNoNegatives(cmDoc
450:                        .getCurrentTransaction()));
451:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
452:                        .setFinancialDocumentFiveDollarAmount(
453:                                new KualiDecimal(100));
454:                assertFalse("Two Dollar", rule.checkMoneyOutNoNegatives(cmDoc
455:                        .getCurrentTransaction()));
456:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
457:                        .setFinancialDocumentTwoDollarAmount(
458:                                new KualiDecimal(100));
459:                assertFalse("One Dollar", rule.checkMoneyOutNoNegatives(cmDoc
460:                        .getCurrentTransaction()));
461:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
462:                        .setFinancialDocumentOneDollarAmount(
463:                                new KualiDecimal(100));
464:                assertTrue(rule.checkMoneyOutNoNegatives(cmDoc
465:                        .getCurrentTransaction()));
466:
467:                cmDoc
468:                        .getCurrentTransaction()
469:                        .setMoneyOutCoin(
470:                                CoinDetailTest.CoinDetailAmountFixture.NEGATIVE_COIN_AMOUNT
471:                                        .convertToCoinDetail());
472:                assertFalse("Hundred Cent", rule.checkMoneyOutNoNegatives(cmDoc
473:                        .getCurrentTransaction()));
474:                cmDoc.getCurrentTransaction().getMoneyOutCoin()
475:                        .setFinancialDocumentHundredCentAmount(
476:                                new KualiDecimal(1));
477:                assertFalse("Fifty Cent", rule.checkMoneyOutNoNegatives(cmDoc
478:                        .getCurrentTransaction()));
479:                cmDoc.getCurrentTransaction().getMoneyOutCoin()
480:                        .setFinancialDocumentFiftyCentAmount(
481:                                new KualiDecimal(1));
482:                assertFalse("Twenty Five Cent",
483:                        rule.checkMoneyOutNoNegatives(cmDoc
484:                                .getCurrentTransaction()));
485:                cmDoc.getCurrentTransaction().getMoneyOutCoin()
486:                        .setFinancialDocumentTwentyFiveCentAmount(
487:                                new KualiDecimal(1));
488:                assertFalse("Ten Cent", rule.checkMoneyOutNoNegatives(cmDoc
489:                        .getCurrentTransaction()));
490:                cmDoc.getCurrentTransaction().getMoneyOutCoin()
491:                        .setFinancialDocumentTenCentAmount(new KualiDecimal(1));
492:                assertFalse("Five Cent", rule.checkMoneyOutNoNegatives(cmDoc
493:                        .getCurrentTransaction()));
494:                cmDoc
495:                        .getCurrentTransaction()
496:                        .getMoneyOutCoin()
497:                        .setFinancialDocumentFiveCentAmount(new KualiDecimal(1));
498:                assertFalse("One Cent", rule.checkMoneyOutNoNegatives(cmDoc
499:                        .getCurrentTransaction()));
500:                cmDoc.getCurrentTransaction().getMoneyOutCoin()
501:                        .setFinancialDocumentOneCentAmount(new KualiDecimal(1));
502:                assertTrue(rule.checkMoneyOutNoNegatives(cmDoc
503:                        .getCurrentTransaction()));
504:
505:                cmDoc
506:                        .getCurrentTransaction()
507:                        .setMoneyOutCurrency(
508:                                CurrencyDetailTest.CurrencyDetailAmountFixture.NULL_AMOUNT
509:                                        .convertToCurrencyDetail());
510:                assertTrue(rule.checkMoneyOutNoNegatives(cmDoc
511:                        .getCurrentTransaction()));
512:                cmDoc.getCurrentTransaction().setMoneyOutCoin(
513:                        CoinDetailTest.CoinDetailAmountFixture.NULL_COIN_AMOUNT
514:                                .convertToCoinDetail());
515:                assertTrue(rule.checkMoneyOutNoNegatives(cmDoc
516:                        .getCurrentTransaction()));
517:
518:                cmDoc
519:                        .getCurrentTransaction()
520:                        .setMoneyOutCurrency(
521:                                CurrencyDetailTest.CurrencyDetailAmountFixture.ZERO_AMOUNT
522:                                        .convertToCurrencyDetail());
523:                assertTrue(rule.checkMoneyOutNoNegatives(cmDoc
524:                        .getCurrentTransaction()));
525:                cmDoc.getCurrentTransaction().setMoneyOutCoin(
526:                        CoinDetailTest.CoinDetailAmountFixture.ZERO_COIN_AMOUNT
527:                                .convertToCoinDetail());
528:                assertTrue(rule.checkMoneyOutNoNegatives(cmDoc
529:                        .getCurrentTransaction()));
530:
531:            }
532:
533:            public void testCheckNewItemInProcessDoesNotExceedCashDrawer() {
534:                CashManagementDocument cmDoc = this 
535:                        .cashManagementDocumentFixture("testCheckNewItemInProcessDoesNotExceedCashDrawer");
536:                CashieringTransactionRule rule = SpringContext
537:                        .getBean(CashieringTransactionRule.class);
538:
539:                putFixtureDataIntoCashDrawer(
540:                        cmDoc.getCashDrawer(),
541:                        CashDrawerTest.CashDrawerAmountFixture.ALL_FIVES_CASH_DRAWER);
542:                resetTransaction(cmDoc.getCurrentTransaction());
543:                cmDoc.getCurrentTransaction().getNewItemInProcess()
544:                        .setItemAmount(new KualiDecimal(100));
545:                assertTrue(rule.checkNewItemInProcessDoesNotExceedCashDrawer(
546:                        cmDoc, cmDoc.getCurrentTransaction()));
547:                cmDoc.getCurrentTransaction().getNewItemInProcess()
548:                        .setItemAmount(new KualiDecimal(10000000));
549:                assertFalse(rule.checkNewItemInProcessDoesNotExceedCashDrawer(
550:                        cmDoc, cmDoc.getCurrentTransaction()));
551:
552:                putFixtureDataIntoCashDrawer(cmDoc.getCashDrawer(),
553:                        CashDrawerTest.CashDrawerAmountFixture.ZERO_CASH_DRAWER);
554:                cmDoc.getCurrentTransaction().getNewItemInProcess()
555:                        .setItemAmount(new KualiDecimal(100));
556:                assertFalse(rule.checkNewItemInProcessDoesNotExceedCashDrawer(
557:                        cmDoc, cmDoc.getCurrentTransaction()));
558:            }
559:
560:            public void testCheckTransactionCheckTotalDoesNotExceedCashDrawer() {
561:                CashManagementDocument cmDoc = this 
562:                        .cashManagementDocumentFixture("testCheckTransactionCheckTotalDoesNotExceedCashDrawer");
563:                CashieringTransactionRule rule = SpringContext
564:                        .getBean(CashieringTransactionRule.class);
565:
566:                putFixtureDataIntoCashDrawer(
567:                        cmDoc.getCashDrawer(),
568:                        CashDrawerTest.CashDrawerAmountFixture.ALL_FIVES_CASH_DRAWER);
569:                resetTransaction(cmDoc.getCurrentTransaction());
570:                Check smallCheck = new CheckBase();
571:                smallCheck.setAmount(new KualiDecimal(50.0));
572:                cmDoc.getCurrentTransaction().addCheck(smallCheck);
573:                assertTrue(rule
574:                        .checkTransactionCheckTotalDoesNotExceedCashDrawer(
575:                                cmDoc, cmDoc.getCurrentTransaction()));
576:
577:                Check largeCheck = new CheckBase();
578:                largeCheck.setAmount(new KualiDecimal(1000000000.0));
579:                cmDoc.getCurrentTransaction().addCheck(largeCheck);
580:                assertFalse(rule
581:                        .checkTransactionCheckTotalDoesNotExceedCashDrawer(
582:                                cmDoc, cmDoc.getCurrentTransaction()));
583:
584:                putFixtureDataIntoCashDrawer(cmDoc.getCashDrawer(),
585:                        CashDrawerTest.CashDrawerAmountFixture.ZERO_CASH_DRAWER);
586:                resetTransaction(cmDoc.getCurrentTransaction());
587:                cmDoc.getCurrentTransaction().addCheck(smallCheck);
588:                assertFalse(rule
589:                        .checkTransactionCheckTotalDoesNotExceedCashDrawer(
590:                                cmDoc, cmDoc.getCurrentTransaction()));
591:            }
592:
593:            public void testCheckPaidBackItemInProcessDoesNotExceedTotal() {
594:                CashManagementDocument cmDoc = this 
595:                        .cashManagementDocumentFixture("testCheckPaidBackItemInProcessDoesNotExceedTotal");
596:                CashieringTransactionRule rule = SpringContext
597:                        .getBean(CashieringTransactionRule.class);
598:
599:                CashieringItemInProcess oldAdvance = new CashieringItemInProcess();
600:                oldAdvance.setCurrentPayment(new KualiDecimal(3530.0));
601:                oldAdvance.setItemAmount(new KualiDecimal(10000.0));
602:                oldAdvance.setItemIdentifier(new Integer(82));
603:                oldAdvance.setItemOpenDate(new Date(new GregorianCalendar()
604:                        .getTimeInMillis()));
605:                assertTrue(rule.checkPaidBackItemInProcessDoesNotExceedTotal(
606:                        oldAdvance, 0));
607:                oldAdvance.setCurrentPayment(null);
608:                assertTrue(rule.checkPaidBackItemInProcessDoesNotExceedTotal(
609:                        oldAdvance, 0));
610:                oldAdvance.setCurrentPayment(new KualiDecimal(20000.0));
611:                assertFalse(rule.checkPaidBackItemInProcessDoesNotExceedTotal(
612:                        oldAdvance, 0));
613:            }
614:
615:            public void testEnoughCashOnHand() {
616:                CashManagementDocument cmDoc = this 
617:                        .cashManagementDocumentFixture("testEnoughCashOnHand");
618:                CashieringTransactionRule rule = SpringContext
619:                        .getBean(CashieringTransactionRule.class);
620:
621:                CurrencyDetail goodCurrency = CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
622:                        .convertToCurrencyDetail();
623:                CurrencyDetail excessiveCurrency = CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_TENS_AMOUNT
624:                        .convertToCurrencyDetail();
625:                CoinDetail goodCoin = CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
626:                        .convertToCoinDetail();
627:                CoinDetail excessiveCoin = CoinDetailTest.CoinDetailAmountFixture.ALL_TENS_COIN_AMOUNT
628:                        .convertToCoinDetail();
629:                putFixtureDataIntoCashDrawer(
630:                        cmDoc.getCashDrawer(),
631:                        CashDrawerTest.CashDrawerAmountFixture.ALL_SEVENS_CASH_DRAWER);
632:                cmDoc
633:                        .getCurrentTransaction()
634:                        .setMoneyInCurrency(
635:                                CurrencyDetailTest.CurrencyDetailAmountFixture.ZERO_AMOUNT
636:                                        .convertToCurrencyDetail());
637:                cmDoc.getCurrentTransaction().setMoneyInCoin(
638:                        CoinDetailTest.CoinDetailAmountFixture.ZERO_COIN_AMOUNT
639:                                .convertToCoinDetail());
640:
641:                cmDoc.getCurrentTransaction().setMoneyOutCurrency(goodCurrency);
642:                cmDoc.getCurrentTransaction().setMoneyOutCoin(goodCoin);
643:                assertTrue(rule.checkEnoughCashForMoneyOut(cmDoc, cmDoc
644:                        .getCurrentTransaction()));
645:
646:                cmDoc.getCurrentTransaction().setMoneyOutCurrency(
647:                        excessiveCurrency);
648:                assertFalse("Hundred Dollar", rule.checkEnoughCashForMoneyOut(
649:                        cmDoc, cmDoc.getCurrentTransaction()));
650:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
651:                        .setFinancialDocumentHundredDollarAmount(
652:                                new KualiDecimal(100));
653:                assertFalse("Fifty Dollar", rule.checkEnoughCashForMoneyOut(
654:                        cmDoc, cmDoc.getCurrentTransaction()));
655:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
656:                        .setFinancialDocumentFiftyDollarAmount(
657:                                new KualiDecimal(100));
658:                assertFalse("Twenty Dollar", rule.checkEnoughCashForMoneyOut(
659:                        cmDoc, cmDoc.getCurrentTransaction()));
660:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
661:                        .setFinancialDocumentTwentyDollarAmount(
662:                                new KualiDecimal(100));
663:                assertFalse("Ten Dollar", rule.checkEnoughCashForMoneyOut(
664:                        cmDoc, cmDoc.getCurrentTransaction()));
665:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
666:                        .setFinancialDocumentTenDollarAmount(
667:                                new KualiDecimal(100));
668:                assertFalse("Five Dollar", rule.checkEnoughCashForMoneyOut(
669:                        cmDoc, cmDoc.getCurrentTransaction()));
670:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
671:                        .setFinancialDocumentFiveDollarAmount(
672:                                new KualiDecimal(100));
673:                assertFalse("Two Dollar", rule.checkEnoughCashForMoneyOut(
674:                        cmDoc, cmDoc.getCurrentTransaction()));
675:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
676:                        .setFinancialDocumentTwoDollarAmount(
677:                                new KualiDecimal(100));
678:                assertFalse("One", rule.checkEnoughCashForMoneyOut(cmDoc, cmDoc
679:                        .getCurrentTransaction()));
680:                cmDoc.getCurrentTransaction().getMoneyOutCurrency()
681:                        .setFinancialDocumentOneDollarAmount(
682:                                new KualiDecimal(100));
683:                assertTrue("Dollars are good", rule.checkEnoughCashForMoneyOut(
684:                        cmDoc, cmDoc.getCurrentTransaction()));
685:
686:                cmDoc.getCurrentTransaction().setMoneyOutCoin(excessiveCoin);
687:                assertFalse("Hundred Cent", rule.checkEnoughCashForMoneyOut(
688:                        cmDoc, cmDoc.getCurrentTransaction()));
689:                cmDoc.getCurrentTransaction().getMoneyOutCoin()
690:                        .setFinancialDocumentHundredCentAmount(
691:                                new KualiDecimal(1));
692:                assertFalse("Fifty Cent", rule.checkEnoughCashForMoneyOut(
693:                        cmDoc, cmDoc.getCurrentTransaction()));
694:                cmDoc.getCurrentTransaction().getMoneyOutCoin()
695:                        .setFinancialDocumentFiftyCentAmount(
696:                                new KualiDecimal(1));
697:                assertFalse("Twenty Five Cent", rule
698:                        .checkEnoughCashForMoneyOut(cmDoc, cmDoc
699:                                .getCurrentTransaction()));
700:                cmDoc.getCurrentTransaction().getMoneyOutCoin()
701:                        .setFinancialDocumentTwentyFiveCentAmount(
702:                                new KualiDecimal(1));
703:                assertFalse("Ten Cent", rule.checkEnoughCashForMoneyOut(cmDoc,
704:                        cmDoc.getCurrentTransaction()));
705:                cmDoc.getCurrentTransaction().getMoneyOutCoin()
706:                        .setFinancialDocumentTenCentAmount(new KualiDecimal(1));
707:                assertFalse("Five Cent", rule.checkEnoughCashForMoneyOut(cmDoc,
708:                        cmDoc.getCurrentTransaction()));
709:                cmDoc
710:                        .getCurrentTransaction()
711:                        .getMoneyOutCoin()
712:                        .setFinancialDocumentFiveCentAmount(new KualiDecimal(1));
713:                assertFalse("One Cent", rule.checkEnoughCashForMoneyOut(cmDoc,
714:                        cmDoc.getCurrentTransaction()));
715:                cmDoc.getCurrentTransaction().getMoneyOutCoin()
716:                        .setFinancialDocumentOneCentAmount(new KualiDecimal(1));
717:
718:                assertTrue(rule.checkEnoughCashForMoneyOut(cmDoc, cmDoc
719:                        .getCurrentTransaction()));
720:
721:                putFixtureDataIntoCashDrawer(cmDoc.getCashDrawer(),
722:                        CashDrawerTest.CashDrawerAmountFixture.ZERO_CASH_DRAWER);
723:                cmDoc
724:                        .getCurrentTransaction()
725:                        .setMoneyInCurrency(
726:                                CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
727:                                        .convertToCurrencyDetail());
728:                cmDoc
729:                        .getCurrentTransaction()
730:                        .setMoneyInCoin(
731:                                CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
732:                                        .convertToCoinDetail());
733:                cmDoc
734:                        .getCurrentTransaction()
735:                        .setMoneyOutCurrency(
736:                                CurrencyDetailTest.CurrencyDetailAmountFixture.ALL_FIVES_AMOUNT
737:                                        .convertToCurrencyDetail());
738:                cmDoc
739:                        .getCurrentTransaction()
740:                        .setMoneyOutCoin(
741:                                CoinDetailTest.CoinDetailAmountFixture.ALL_FIVES_COIN_AMOUNT
742:                                        .convertToCoinDetail());
743:                assertTrue(rule.checkEnoughCashForMoneyOut(cmDoc, cmDoc
744:                        .getCurrentTransaction()));
745:                putFixtureDataIntoCashDrawer(cmDoc.getCashDrawer(),
746:                        CashDrawerTest.CashDrawerAmountFixture.NULL_CASH_DRAWER);
747:                assertTrue(rule.checkEnoughCashForMoneyOut(cmDoc, cmDoc
748:                        .getCurrentTransaction()));
749:            }
750:
751:            public void testAdvancesDoNotPayOffOtherAdvances() {
752:                CashManagementDocument cmDoc = this 
753:                        .cashManagementDocumentFixture("testAdvancesDoNotPayOffOtherAdvances");
754:                CashieringTransactionRule rule = SpringContext
755:                        .getBean(CashieringTransactionRule.class);
756:
757:                assertTrue(rule.checkItemInProcessIsNotPayingOffItemInProcess(
758:                        cmDoc, cmDoc.getCurrentTransaction()));
759:                CashieringItemInProcess openAdvance = new CashieringItemInProcess();
760:                openAdvance.setItemAmount(new KualiDecimal(10000.0));
761:                openAdvance.setItemIdentifier(new Integer(82));
762:                openAdvance.setCurrentPayment(new KualiDecimal(25.0));
763:                openAdvance.setItemOpenDate(new Date(new GregorianCalendar()
764:                        .getTimeInMillis()));
765:                cmDoc.getCurrentTransaction().getOpenItemsInProcess().add(
766:                        openAdvance);
767:                assertTrue(rule.checkItemInProcessIsNotPayingOffItemInProcess(
768:                        cmDoc, cmDoc.getCurrentTransaction()));
769:                cmDoc.getCurrentTransaction().getNewItemInProcess()
770:                        .setItemIdentifier(new Integer(80));
771:                cmDoc.getCurrentTransaction().getNewItemInProcess()
772:                        .setItemAmount(new KualiDecimal(52));
773:                cmDoc.getCurrentTransaction().getNewItemInProcess()
774:                        .setItemOpenDate(
775:                                new Date(new GregorianCalendar()
776:                                        .getTimeInMillis()));
777:                assertFalse(rule.checkItemInProcessIsNotPayingOffItemInProcess(
778:                        cmDoc, cmDoc.getCurrentTransaction()));
779:                cmDoc.getCurrentTransaction().getOpenItemsInProcess().remove(0);
780:                assertTrue(rule.checkItemInProcessIsNotPayingOffItemInProcess(
781:                        cmDoc, cmDoc.getCurrentTransaction()));
782:            }
783:
784:            public void testNewAdvanceNotInFuture() {
785:                CashManagementDocument cmDoc = this 
786:                        .cashManagementDocumentFixture("testAdvancesDoNotPayOffOtherAdvances");
787:                CashieringTransactionRule rule = SpringContext
788:                        .getBean(CashieringTransactionRule.class);
789:
790:                cmDoc.getCurrentTransaction().getNewItemInProcess()
791:                        .setItemIdentifier(new Integer(80));
792:                cmDoc.getCurrentTransaction().getNewItemInProcess()
793:                        .setItemAmount(new KualiDecimal(52));
794:                cmDoc.getCurrentTransaction().getNewItemInProcess()
795:                        .setItemOpenDate(oneWeekAgo());
796:                assertTrue(rule.checkNewItemInProcessInPast(cmDoc
797:                        .getCurrentTransaction()));
798:                cmDoc.getCurrentTransaction().getNewItemInProcess()
799:                        .setItemOpenDate(oneWeekFromNow());
800:                assertFalse(rule.checkNewItemInProcessInPast(cmDoc
801:                        .getCurrentTransaction()));
802:            }
803:
804:            private CashManagementDocument cashManagementDocumentFixture(
805:                    String testName) {
806:                // delete fake cash drawer if we can find it; these ideas are pretty much nicked from CashManagementServiceTest
807:                Map deleteCriteria = new HashMap();
808:                deleteCriteria.put("workgroupName", CMST_WORKGROUP);
809:                SpringContext.getBean(BusinessObjectService.class)
810:                        .deleteMatching(CashDrawer.class, deleteCriteria);
811:
812:                // create a new cash drawer
813:                CashDrawer cashDrawer = SpringContext.getBean(
814:                        CashDrawerService.class).getByWorkgroupName(
815:                        CMST_WORKGROUP, true);
816:
817:                CashManagementDocument cmDoc = SpringContext.getBean(
818:                        CashManagementService.class)
819:                        .createCashManagementDocument(CMST_WORKGROUP,
820:                                "Document Created for " + testName, "CMD");
821:                return cmDoc;
822:            }
823:
824:            private void putFixtureDataIntoCashDrawer(CashDrawer drawer,
825:                    CashDrawerTest.CashDrawerAmountFixture fixture) {
826:                CashDrawer fixtureDrawer = fixture.convertToCashDrawer();
827:                drawer.setFinancialDocumentHundredDollarAmount(fixtureDrawer
828:                        .getFinancialDocumentHundredDollarAmount());
829:                drawer.setFinancialDocumentFiftyDollarAmount(fixtureDrawer
830:                        .getFinancialDocumentFiftyDollarAmount());
831:                drawer.setFinancialDocumentTwentyDollarAmount(fixtureDrawer
832:                        .getFinancialDocumentTwentyDollarAmount());
833:                drawer.setFinancialDocumentTenDollarAmount(fixtureDrawer
834:                        .getFinancialDocumentTenDollarAmount());
835:                drawer.setFinancialDocumentFiveDollarAmount(fixtureDrawer
836:                        .getFinancialDocumentFiveDollarAmount());
837:                drawer.setFinancialDocumentTwoDollarAmount(fixtureDrawer
838:                        .getFinancialDocumentTwoDollarAmount());
839:                drawer.setFinancialDocumentOneDollarAmount(fixtureDrawer
840:                        .getFinancialDocumentOneDollarAmount());
841:                drawer.setFinancialDocumentOtherDollarAmount(fixtureDrawer
842:                        .getFinancialDocumentOtherDollarAmount());
843:                drawer.setFinancialDocumentHundredCentAmount(fixtureDrawer
844:                        .getFinancialDocumentHundredCentAmount());
845:                drawer.setFinancialDocumentFiftyCentAmount(fixtureDrawer
846:                        .getFinancialDocumentFiftyCentAmount());
847:                drawer.setFinancialDocumentTwentyFiveCentAmount(fixtureDrawer
848:                        .getFinancialDocumentTwentyFiveCentAmount());
849:                drawer.setFinancialDocumentTenCentAmount(fixtureDrawer
850:                        .getFinancialDocumentTenCentAmount());
851:                drawer.setFinancialDocumentFiveCentAmount(fixtureDrawer
852:                        .getFinancialDocumentFiveCentAmount());
853:                drawer.setFinancialDocumentOneCentAmount(fixtureDrawer
854:                        .getFinancialDocumentOneCentAmount());
855:                drawer.setFinancialDocumentOtherCentAmount(fixtureDrawer
856:                        .getFinancialDocumentOtherCentAmount());
857:            }
858:
859:            private void resetTransaction(CashieringTransaction transaction) {
860:                transaction
861:                        .setMoneyInCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ZERO_AMOUNT
862:                                .convertToCurrencyDetail());
863:                transaction
864:                        .setMoneyInCoin(CoinDetailTest.CoinDetailAmountFixture.ZERO_COIN_AMOUNT
865:                                .convertToCoinDetail());
866:                transaction
867:                        .setMoneyOutCurrency(CurrencyDetailTest.CurrencyDetailAmountFixture.ZERO_AMOUNT
868:                                .convertToCurrencyDetail());
869:                transaction
870:                        .setMoneyOutCoin(CoinDetailTest.CoinDetailAmountFixture.ZERO_COIN_AMOUNT
871:                                .convertToCoinDetail());
872:                transaction.setMoneyInChecks(new ArrayList<Check>());
873:                transaction.setBaselineChecks(new ArrayList());
874:                transaction.getNewItemInProcess().setItemAmount(
875:                        KualiDecimal.ZERO);
876:                transaction.getNewItemInProcess().setItemReducedAmount(
877:                        KualiDecimal.ZERO);
878:                transaction.getNewItemInProcess().setItemRemainingAmount(
879:                        KualiDecimal.ZERO);
880:                transaction
881:                        .setOpenItemsInProcess(new ArrayList<CashieringItemInProcess>());
882:            }
883:
884:            private Date oneWeekAgo() {
885:                Calendar cal = new GregorianCalendar();
886:                cal.add(Calendar.DATE, -7);
887:                return new Date(cal.getTimeInMillis());
888:            }
889:
890:            private Date oneWeekFromNow() {
891:                Calendar cal = new GregorianCalendar();
892:                cal.add(Calendar.DATE, 7);
893:                return new Date(cal.getTimeInMillis());
894:            }
895:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.