Source Code Cross Referenced for CashieringTransactionRule.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) 


0001:        /*
0002:         * Copyright 2007 The Kuali Foundation.
0003:         * 
0004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
0005:         * you may not use this file except in compliance with the License.
0006:         * You may obtain a copy of the License at
0007:         * 
0008:         * http://www.opensource.org/licenses/ecl1.php
0009:         * 
0010:         * Unless required by applicable law or agreed to in writing, software
0011:         * distributed under the License is distributed on an "AS IS" BASIS,
0012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013:         * See the License for the specific language governing permissions and
0014:         * limitations under the License.
0015:         */
0016:        package org.kuali.module.financial.rules;
0017:
0018:        import java.util.Calendar;
0019:        import java.util.Date;
0020:        import java.util.GregorianCalendar;
0021:
0022:        import org.apache.log4j.Logger;
0023:        import org.kuali.core.util.GlobalVariables;
0024:        import org.kuali.core.util.KualiDecimal;
0025:        import org.kuali.kfs.KFSConstants;
0026:        import org.kuali.kfs.KFSKeyConstants;
0027:        import org.kuali.module.financial.bo.CashDrawer;
0028:        import org.kuali.module.financial.bo.CashieringItemInProcess;
0029:        import org.kuali.module.financial.bo.CashieringTransaction;
0030:        import org.kuali.module.financial.bo.Check;
0031:        import org.kuali.module.financial.bo.CoinDetail;
0032:        import org.kuali.module.financial.bo.CurrencyDetail;
0033:        import org.kuali.module.financial.document.CashManagementDocument;
0034:        import org.kuali.module.financial.service.CashDrawerService;
0035:
0036:        /**
0037:         * This class represents the rule used during cash management
0038:         */
0039:        public class CashieringTransactionRule {
0040:            private static final Logger LOG = Logger
0041:                    .getLogger(CashieringTransactionRule.class);
0042:            private CashDrawerService cashDrawerService;
0043:
0044:            /**
0045:             * Returns true if all application rules called by this method return true
0046:             * 
0047:             * @param cmDoc represents cash management document
0048:             * @return true if all cashiering transaction application rules do not fail
0049:             */
0050:            public boolean processCashieringTransactionApplicationRules(
0051:                    CashManagementDocument cmDoc) {
0052:                boolean success = true;
0053:                success &= checkMoneyInNoNegatives(cmDoc
0054:                        .getCurrentTransaction());
0055:                success &= checkMoneyOutNoNegatives(cmDoc
0056:                        .getCurrentTransaction());
0057:                success &= checkAllPaidBackItemsInProcess(cmDoc
0058:                        .getCurrentTransaction());
0059:                success &= checkNewItemInProcessDoesNotExceedCashDrawer(cmDoc,
0060:                        cmDoc.getCurrentTransaction());
0061:                success &= checkNewItemInProcessInPast(cmDoc
0062:                        .getCurrentTransaction());
0063:                success &= checkTransactionCheckTotalDoesNotExceedCashDrawer(
0064:                        cmDoc, cmDoc.getCurrentTransaction());
0065:                success &= checkItemInProcessIsNotPayingOffItemInProcess(cmDoc,
0066:                        cmDoc.getCurrentTransaction());
0067:                if (success) {
0068:                    success = checkEnoughCashForMoneyOut(cmDoc, cmDoc
0069:                            .getCurrentTransaction());
0070:                }
0071:                if (success) {
0072:                    success &= checkMoneyInMoneyOutBalance(cmDoc
0073:                            .getCurrentTransaction());
0074:                }
0075:                return success;
0076:            }
0077:
0078:            /**
0079:             * Returns true if none of the entered money-in amounts (cash and coin) are not negative in a cashiering transaction
0080:             * 
0081:             * @param trans represents cashiering transaction from document
0082:             * @return true if none of the amounts are negative
0083:             */
0084:            public boolean checkMoneyInNoNegatives(CashieringTransaction trans) {
0085:                boolean success = true;
0086:
0087:                // money in currency
0088:                if (trans.getMoneyInCurrency()
0089:                        .getFinancialDocumentHundredDollarAmount() != null
0090:                        && trans.getMoneyInCurrency()
0091:                                .getFinancialDocumentHundredDollarAmount()
0092:                                .isNegative()) {
0093:                    GlobalVariables
0094:                            .getErrorMap()
0095:                            .putError(
0096:                                    "document.currentTransaction.moneyInCurrency.hundredDollarCount",
0097:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0098:                                    new String[] {
0099:                                            trans.getMoneyInCurrency()
0100:                                                    .getHundredDollarCount()
0101:                                                    .toString(),
0102:                                            "hundred dollar count" });
0103:                    success = false;
0104:                }
0105:                if (trans.getMoneyInCurrency()
0106:                        .getFinancialDocumentFiftyDollarAmount() != null
0107:                        && trans.getMoneyInCurrency()
0108:                                .getFinancialDocumentFiftyDollarAmount()
0109:                                .isNegative()) {
0110:                    GlobalVariables
0111:                            .getErrorMap()
0112:                            .putError(
0113:                                    "document.currentTransaction.moneyInCurrency.fiftyDollarCount",
0114:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0115:                                    new String[] {
0116:                                            trans.getMoneyInCurrency()
0117:                                                    .getFiftyDollarCount()
0118:                                                    .toString(),
0119:                                            "fifty dollar count" });
0120:                    success = false;
0121:                }
0122:                if (trans.getMoneyInCurrency()
0123:                        .getFinancialDocumentTwentyDollarAmount() != null
0124:                        && trans.getMoneyInCurrency()
0125:                                .getFinancialDocumentTwentyDollarAmount()
0126:                                .isNegative()) {
0127:                    GlobalVariables
0128:                            .getErrorMap()
0129:                            .putError(
0130:                                    "document.currentTransaction.moneyInCurrency.twentyDollarCount",
0131:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0132:                                    new String[] {
0133:                                            trans.getMoneyInCurrency()
0134:                                                    .getTwentyDollarCount()
0135:                                                    .toString(),
0136:                                            "twenty dollar count" });
0137:                    success = false;
0138:                }
0139:                if (trans.getMoneyInCurrency()
0140:                        .getFinancialDocumentTenDollarAmount() != null
0141:                        && trans.getMoneyInCurrency()
0142:                                .getFinancialDocumentTenDollarAmount()
0143:                                .isNegative()) {
0144:                    GlobalVariables
0145:                            .getErrorMap()
0146:                            .putError(
0147:                                    "document.currentTransaction.moneyInCurrency.tenDollarCount",
0148:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0149:                                    new String[] {
0150:                                            trans.getMoneyInCurrency()
0151:                                                    .getTenDollarCount()
0152:                                                    .toString(),
0153:                                            "ten dollar count" });
0154:                    success = false;
0155:                }
0156:                if (trans.getMoneyInCurrency()
0157:                        .getFinancialDocumentFiveDollarAmount() != null
0158:                        && trans.getMoneyInCurrency()
0159:                                .getFinancialDocumentFiveDollarAmount()
0160:                                .isNegative()) {
0161:                    GlobalVariables
0162:                            .getErrorMap()
0163:                            .putError(
0164:                                    "document.currentTransaction.moneyInCurrency.fiveDollarCount",
0165:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0166:                                    new String[] {
0167:                                            trans.getMoneyInCurrency()
0168:                                                    .getFiveDollarCount()
0169:                                                    .toString(),
0170:                                            "five dollar count" });
0171:                    success = false;
0172:                }
0173:                if (trans.getMoneyInCurrency()
0174:                        .getFinancialDocumentTwoDollarAmount() != null
0175:                        && trans.getMoneyInCurrency()
0176:                                .getFinancialDocumentTwoDollarAmount()
0177:                                .isNegative()) {
0178:                    GlobalVariables
0179:                            .getErrorMap()
0180:                            .putError(
0181:                                    "document.currentTransaction.moneyInCurrency.twoDollarCount",
0182:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0183:                                    new String[] {
0184:                                            trans.getMoneyInCurrency()
0185:                                                    .getTwoDollarCount()
0186:                                                    .toString(),
0187:                                            "two dollar count" });
0188:                    success = false;
0189:                }
0190:                if (trans.getMoneyInCurrency()
0191:                        .getFinancialDocumentOneDollarAmount() != null
0192:                        && trans.getMoneyInCurrency()
0193:                                .getFinancialDocumentOneDollarAmount()
0194:                                .isNegative()) {
0195:                    GlobalVariables
0196:                            .getErrorMap()
0197:                            .putError(
0198:                                    "document.currentTransaction.moneyInCurrency.oneDollarCount",
0199:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0200:                                    new String[] {
0201:                                            trans.getMoneyInCurrency()
0202:                                                    .getOneDollarCount()
0203:                                                    .toString(),
0204:                                            "one dollar count" });
0205:                    success = false;
0206:                }
0207:                if (trans.getMoneyInCurrency()
0208:                        .getFinancialDocumentOtherDollarAmount() != null
0209:                        && trans.getMoneyInCurrency()
0210:                                .getFinancialDocumentOtherDollarAmount()
0211:                                .isNegative()) {
0212:                    GlobalVariables
0213:                            .getErrorMap()
0214:                            .putError(
0215:                                    "document.currentTransaction.moneyInCurrency.financialDocumentOtherDollarAmount",
0216:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0217:                                    new String[] {
0218:                                            trans
0219:                                                    .getMoneyInCurrency()
0220:                                                    .getFinancialDocumentOtherDollarAmount()
0221:                                                    .toString(),
0222:                                            "other dollar amount" });
0223:                    success = false;
0224:                }
0225:
0226:                // money in coin
0227:                if (trans.getMoneyInCoin()
0228:                        .getFinancialDocumentHundredCentAmount() != null
0229:                        && trans.getMoneyInCoin()
0230:                                .getFinancialDocumentHundredCentAmount()
0231:                                .isNegative()) {
0232:                    GlobalVariables
0233:                            .getErrorMap()
0234:                            .putError(
0235:                                    "document.currentTransaction.moneyInCoin.hundredCentCount",
0236:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0237:                                    new String[] {
0238:                                            trans.getMoneyInCoin()
0239:                                                    .getHundredCentCount()
0240:                                                    .toString(),
0241:                                            "hundred cent count" });
0242:                    success = false;
0243:                }
0244:                if (trans.getMoneyInCoin()
0245:                        .getFinancialDocumentFiftyCentAmount() != null
0246:                        && trans.getMoneyInCoin()
0247:                                .getFinancialDocumentFiftyCentAmount()
0248:                                .isNegative()) {
0249:                    GlobalVariables
0250:                            .getErrorMap()
0251:                            .putError(
0252:                                    "document.currentTransaction.moneyInCoin.fiftyCentCount",
0253:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0254:                                    new String[] {
0255:                                            trans.getMoneyInCoin()
0256:                                                    .getFiftyCentCount()
0257:                                                    .toString(),
0258:                                            "fifty cent count" });
0259:                    success = false;
0260:                }
0261:                if (trans.getMoneyInCoin().getFinancialDocumentTenCentAmount() != null
0262:                        && trans.getMoneyInCoin()
0263:                                .getFinancialDocumentTenCentAmount()
0264:                                .isNegative()) {
0265:                    GlobalVariables
0266:                            .getErrorMap()
0267:                            .putError(
0268:                                    "document.currentTransaction.moneyInCoin.tenCentCount",
0269:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0270:                                    new String[] {
0271:                                            trans.getMoneyInCoin()
0272:                                                    .getTenCentCount()
0273:                                                    .toString(),
0274:                                            "ten cent count" });
0275:                    success = false;
0276:                }
0277:                if (trans.getMoneyInCoin()
0278:                        .getFinancialDocumentTwentyFiveCentAmount() != null
0279:                        && trans.getMoneyInCoin()
0280:                                .getFinancialDocumentTwentyFiveCentAmount()
0281:                                .isNegative()) {
0282:                    GlobalVariables
0283:                            .getErrorMap()
0284:                            .putError(
0285:                                    "document.currentTransaction.moneyInCoin.twentyFiveCentCount",
0286:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0287:                                    new String[] {
0288:                                            trans.getMoneyInCoin()
0289:                                                    .getTwentyFiveCentCount()
0290:                                                    .toString(),
0291:                                            "twenty five cent count" });
0292:                    success = false;
0293:                }
0294:                if (trans.getMoneyInCoin().getFinancialDocumentFiveCentAmount() != null
0295:                        && trans.getMoneyInCoin()
0296:                                .getFinancialDocumentFiveCentAmount()
0297:                                .isNegative()) {
0298:                    GlobalVariables
0299:                            .getErrorMap()
0300:                            .putError(
0301:                                    "document.currentTransaction.moneyInCoin.fiveCentCount",
0302:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0303:                                    new String[] {
0304:                                            trans.getMoneyInCoin()
0305:                                                    .getFiveCentCount()
0306:                                                    .toString(),
0307:                                            "five cent count" });
0308:                    success = false;
0309:                }
0310:                if (trans.getMoneyInCoin().getFinancialDocumentOneCentAmount() != null
0311:                        && trans.getMoneyInCoin()
0312:                                .getFinancialDocumentOneCentAmount()
0313:                                .isNegative()) {
0314:                    GlobalVariables
0315:                            .getErrorMap()
0316:                            .putError(
0317:                                    "document.currentTransaction.moneyInCoin.oneCentCount",
0318:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0319:                                    new String[] {
0320:                                            trans.getMoneyInCoin()
0321:                                                    .getOneCentCount()
0322:                                                    .toString(),
0323:                                            "one cent count" });
0324:                    success = false;
0325:                }
0326:                if (trans.getMoneyInCoin()
0327:                        .getFinancialDocumentOtherCentAmount() != null
0328:                        && trans.getMoneyInCoin()
0329:                                .getFinancialDocumentOtherCentAmount()
0330:                                .isNegative()) {
0331:                    GlobalVariables
0332:                            .getErrorMap()
0333:                            .putError(
0334:                                    "document.currentTransaction.moneyInCoin.financialDocumentOtherCentAmount",
0335:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0336:                                    new String[] {
0337:                                            trans
0338:                                                    .getMoneyInCoin()
0339:                                                    .getFinancialDocumentOtherCentAmount()
0340:                                                    .toString(),
0341:                                            "other cent amount" });
0342:                    success = false;
0343:                }
0344:
0345:                // newItemInProcess amount
0346:                if (trans.getNewItemInProcess() != null
0347:                        && trans.getNewItemInProcess().isPopulated()
0348:                        && trans.getNewItemInProcess().getItemAmount()
0349:                                .isNegative()) {
0350:                    GlobalVariables
0351:                            .getErrorMap()
0352:                            .putError(
0353:                                    "document.currentTransaction.newItemInProcess.itemAmount",
0354:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_NEW_ITEM_IN_PROCESS_NOT_NEGATIVE,
0355:                                    new String[0]);
0356:                    success = false;
0357:                }
0358:
0359:                // checks
0360:                int count = 0;
0361:                for (Check check : trans.getMoneyInChecks()) {
0362:                    if (check.getAmount() != null
0363:                            && check.getAmount().isNegative()) {
0364:                        GlobalVariables
0365:                                .getErrorMap()
0366:                                .putError(
0367:                                        "document.currentTransaction.moneyInChecks["
0368:                                                + count + "].amount",
0369:                                        KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CHECK_AMOUNT_NOT_NEGATIVE,
0370:                                        new String[] {
0371:                                                check.getAmount().toString(),
0372:                                                check.getDescription() });
0373:                        success = false;
0374:                    }
0375:                    count += 1;
0376:                }
0377:
0378:                return success;
0379:            }
0380:
0381:            /**
0382:             * Returns true if none of the entered money-out amounts (cash and coin) are not negative in a cashiering transaction
0383:             * 
0384:             * @param trans represents cashiering transaction from document
0385:             * @return true if none of the amounts are negative
0386:             */
0387:            public boolean checkMoneyOutNoNegatives(CashieringTransaction trans) {
0388:                boolean success = true;
0389:
0390:                // money out currency
0391:                if (trans.getMoneyOutCurrency()
0392:                        .getFinancialDocumentHundredDollarAmount() != null
0393:                        && trans.getMoneyOutCurrency()
0394:                                .getFinancialDocumentHundredDollarAmount()
0395:                                .isNegative()) {
0396:                    GlobalVariables
0397:                            .getErrorMap()
0398:                            .putError(
0399:                                    "document.currentTransaction.moneyOutCurrency.hundredDollarCount",
0400:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0401:                                    new String[] {
0402:                                            trans.getMoneyOutCurrency()
0403:                                                    .getHundredDollarCount()
0404:                                                    .toString(),
0405:                                            "hundred dollar count" });
0406:                    success = false;
0407:                }
0408:                if (trans.getMoneyOutCurrency()
0409:                        .getFinancialDocumentFiftyDollarAmount() != null
0410:                        && trans.getMoneyOutCurrency()
0411:                                .getFinancialDocumentFiftyDollarAmount()
0412:                                .isNegative()) {
0413:                    GlobalVariables
0414:                            .getErrorMap()
0415:                            .putError(
0416:                                    "document.currentTransaction.moneyOutCurrency.fiftyDollarCount",
0417:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0418:                                    new String[] {
0419:                                            trans.getMoneyOutCurrency()
0420:                                                    .getFiftyDollarCount()
0421:                                                    .toString(),
0422:                                            "fifty dollar count" });
0423:                    success = false;
0424:                }
0425:                if (trans.getMoneyOutCurrency()
0426:                        .getFinancialDocumentTwentyDollarAmount() != null
0427:                        && trans.getMoneyOutCurrency()
0428:                                .getFinancialDocumentTwentyDollarAmount()
0429:                                .isNegative()) {
0430:                    GlobalVariables
0431:                            .getErrorMap()
0432:                            .putError(
0433:                                    "document.currentTransaction.moneyOutCurrency.twentyDollarCount",
0434:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0435:                                    new String[] {
0436:                                            trans.getMoneyOutCurrency()
0437:                                                    .getTwentyDollarCount()
0438:                                                    .toString(),
0439:                                            "twenty dollar count" });
0440:                    success = false;
0441:                }
0442:                if (trans.getMoneyOutCurrency()
0443:                        .getFinancialDocumentTenDollarAmount() != null
0444:                        && trans.getMoneyOutCurrency()
0445:                                .getFinancialDocumentTenDollarAmount()
0446:                                .isNegative()) {
0447:                    GlobalVariables
0448:                            .getErrorMap()
0449:                            .putError(
0450:                                    "document.currentTransaction.moneyOutCurrency.tenDollarCount",
0451:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0452:                                    new String[] {
0453:                                            trans.getMoneyInCurrency()
0454:                                                    .getTenDollarCount()
0455:                                                    .toString(),
0456:                                            "ten dollar count" });
0457:                    success = false;
0458:                }
0459:                if (trans.getMoneyOutCurrency()
0460:                        .getFinancialDocumentFiveDollarAmount() != null
0461:                        && trans.getMoneyOutCurrency()
0462:                                .getFinancialDocumentFiveDollarAmount()
0463:                                .isNegative()) {
0464:                    GlobalVariables
0465:                            .getErrorMap()
0466:                            .putError(
0467:                                    "document.currentTransaction.moneyOutCurrency.fiveDollarCount",
0468:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0469:                                    new String[] {
0470:                                            trans.getMoneyOutCurrency()
0471:                                                    .getFiveDollarCount()
0472:                                                    .toString(),
0473:                                            "five dollar count" });
0474:                    success = false;
0475:                }
0476:                if (trans.getMoneyOutCurrency()
0477:                        .getFinancialDocumentTwoDollarAmount() != null
0478:                        && trans.getMoneyOutCurrency()
0479:                                .getFinancialDocumentTwoDollarAmount()
0480:                                .isNegative()) {
0481:                    GlobalVariables
0482:                            .getErrorMap()
0483:                            .putError(
0484:                                    "document.currentTransaction.moneyOutCurrency.twoDollarCount",
0485:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0486:                                    new String[] {
0487:                                            trans.getMoneyOutCurrency()
0488:                                                    .getTwoDollarCount()
0489:                                                    .toString(),
0490:                                            "two dollar count" });
0491:                    success = false;
0492:                }
0493:                if (trans.getMoneyOutCurrency()
0494:                        .getFinancialDocumentOneDollarAmount() != null
0495:                        && trans.getMoneyOutCurrency()
0496:                                .getFinancialDocumentOneDollarAmount()
0497:                                .isNegative()) {
0498:                    GlobalVariables
0499:                            .getErrorMap()
0500:                            .putError(
0501:                                    "document.currentTransaction.moneyOutCurrency.oneDollarCount",
0502:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0503:                                    new String[] {
0504:                                            trans.getMoneyInCurrency()
0505:                                                    .getOneDollarCount()
0506:                                                    .toString(),
0507:                                            "one dollar count" });
0508:                    success = false;
0509:                }
0510:                if (trans.getMoneyOutCurrency()
0511:                        .getFinancialDocumentOtherDollarAmount() != null
0512:                        && trans.getMoneyOutCurrency()
0513:                                .getFinancialDocumentOtherDollarAmount()
0514:                                .isNegative()) {
0515:                    GlobalVariables
0516:                            .getErrorMap()
0517:                            .putError(
0518:                                    "document.currentTransaction.moneyOutCurrency.financialDocumentOtherDollarAmount",
0519:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0520:                                    new String[] {
0521:                                            trans
0522:                                                    .getMoneyInCurrency()
0523:                                                    .getFinancialDocumentOtherDollarAmount()
0524:                                                    .toString(),
0525:                                            "other dollar amount" });
0526:                    success = false;
0527:                }
0528:
0529:                // money out coin
0530:                if (trans.getMoneyOutCoin()
0531:                        .getFinancialDocumentHundredCentAmount() != null
0532:                        && trans.getMoneyOutCoin()
0533:                                .getFinancialDocumentHundredCentAmount()
0534:                                .isNegative()) {
0535:                    GlobalVariables
0536:                            .getErrorMap()
0537:                            .putError(
0538:                                    "document.currentTransaction.moneyOutCoin.hundredCentCount",
0539:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0540:                                    new String[] {
0541:                                            trans.getMoneyInCoin()
0542:                                                    .getHundredCentCount()
0543:                                                    .toString(),
0544:                                            "hundred cent count" });
0545:                    success = false;
0546:                }
0547:                if (trans.getMoneyOutCoin()
0548:                        .getFinancialDocumentFiftyCentAmount() != null
0549:                        && trans.getMoneyOutCoin()
0550:                                .getFinancialDocumentFiftyCentAmount()
0551:                                .isNegative()) {
0552:                    GlobalVariables
0553:                            .getErrorMap()
0554:                            .putError(
0555:                                    "document.currentTransaction.moneyOutCoin.fiftyCentCount",
0556:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0557:                                    new String[] {
0558:                                            trans.getMoneyInCoin()
0559:                                                    .getFiftyCentCount()
0560:                                                    .toString(),
0561:                                            "fifty cent count" });
0562:                    success = false;
0563:                }
0564:                if (trans.getMoneyOutCoin().getFinancialDocumentTenCentAmount() != null
0565:                        && trans.getMoneyOutCoin()
0566:                                .getFinancialDocumentTenCentAmount()
0567:                                .isNegative()) {
0568:                    GlobalVariables
0569:                            .getErrorMap()
0570:                            .putError(
0571:                                    "document.currentTransaction.moneyOutCoin.tenCentCount",
0572:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0573:                                    new String[] {
0574:                                            trans.getMoneyInCoin()
0575:                                                    .getTenCentCount()
0576:                                                    .toString(),
0577:                                            "ten cent count" });
0578:                    success = false;
0579:                }
0580:                if (trans.getMoneyOutCoin()
0581:                        .getFinancialDocumentTwentyFiveCentAmount() != null
0582:                        && trans.getMoneyOutCoin()
0583:                                .getFinancialDocumentTwentyFiveCentAmount()
0584:                                .isNegative()) {
0585:                    GlobalVariables
0586:                            .getErrorMap()
0587:                            .putError(
0588:                                    "document.currentTransaction.moneyOutCoin.twentyFiveCentCount",
0589:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0590:                                    new String[] {
0591:                                            trans.getMoneyInCoin()
0592:                                                    .getTwentyFiveCentCount()
0593:                                                    .toString(),
0594:                                            "twenty five cent count" });
0595:                    success = false;
0596:                }
0597:                if (trans.getMoneyOutCoin()
0598:                        .getFinancialDocumentFiveCentAmount() != null
0599:                        && trans.getMoneyOutCoin()
0600:                                .getFinancialDocumentFiveCentAmount()
0601:                                .isNegative()) {
0602:                    GlobalVariables
0603:                            .getErrorMap()
0604:                            .putError(
0605:                                    "document.currentTransaction.moneyOutCoin.fiveCentCount",
0606:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0607:                                    new String[] {
0608:                                            trans.getMoneyInCoin()
0609:                                                    .getFiveCentCount()
0610:                                                    .toString(),
0611:                                            "five cent count" });
0612:                    success = false;
0613:                }
0614:                if (trans.getMoneyOutCoin().getFinancialDocumentOneCentAmount() != null
0615:                        && trans.getMoneyOutCoin()
0616:                                .getFinancialDocumentOneCentAmount()
0617:                                .isNegative()) {
0618:                    GlobalVariables
0619:                            .getErrorMap()
0620:                            .putError(
0621:                                    "document.currentTransaction.moneyOutCoin.oneCentCount",
0622:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0623:                                    new String[] {
0624:                                            trans.getMoneyInCoin()
0625:                                                    .getOneCentCount()
0626:                                                    .toString(),
0627:                                            "one cent count" });
0628:                    success = false;
0629:                }
0630:                if (trans.getMoneyOutCoin()
0631:                        .getFinancialDocumentOtherCentAmount() != null
0632:                        && trans.getMoneyOutCoin()
0633:                                .getFinancialDocumentOtherCentAmount()
0634:                                .isNegative()) {
0635:                    GlobalVariables
0636:                            .getErrorMap()
0637:                            .putError(
0638:                                    "document.currentTransaction.moneyOutCoin.financialDocumentOtherCentAmount",
0639:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_NOT_NEGATIVE,
0640:                                    new String[] {
0641:                                            trans
0642:                                                    .getMoneyOutCoin()
0643:                                                    .getFinancialDocumentOtherCentAmount()
0644:                                                    .toString(),
0645:                                            "other cent amount" });
0646:                    success = false;
0647:                }
0648:
0649:                // open items in process amounts
0650:                int count = 0;
0651:                if (trans.getOpenItemsInProcess() != null) {
0652:                    for (CashieringItemInProcess itemInProc : trans
0653:                            .getOpenItemsInProcess()) {
0654:                        if (itemInProc.getCurrentPayment() != null
0655:                                && itemInProc.getCurrentPayment().isNegative()) {
0656:                            GlobalVariables
0657:                                    .getErrorMap()
0658:                                    .putError(
0659:                                            "document.currentTransaction.openItemsInProcess["
0660:                                                    + count
0661:                                                    + "].currentPayment",
0662:                                            KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_REDUCED_ITEM_IN_PROCESS_NOT_NEGATIVE,
0663:                                            new String[] { itemInProc
0664:                                                    .getItemIdentifier()
0665:                                                    .toString() });
0666:                            success = false;
0667:                        }
0668:                        count += 1;
0669:                    }
0670:                }
0671:
0672:                return success;
0673:            }
0674:
0675:            /**
0676:             * Returns true if money-in and money-out are in balance with each other
0677:             * 
0678:             * @param trans represents cashiering transaction from cash management document
0679:             * @return true if money-in and money-out are balanced
0680:             */
0681:            public boolean checkMoneyInMoneyOutBalance(
0682:                    CashieringTransaction trans) {
0683:                boolean success = true;
0684:                if (!trans.getMoneyInTotal().equals(trans.getMoneyOutTotal())) {
0685:                    GlobalVariables
0686:                            .getErrorMap()
0687:                            .putError(
0688:                                    "document.currentTransaction.moneyInCurrency.financialDocumentHundredDollarAmount",
0689:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_IN_OUT_DO_NOT_BALANCE,
0690:                                    new String[0]);
0691:                    success = false;
0692:                }
0693:                return success;
0694:            }
0695:
0696:            /**
0697:             * This method returns true if none of the coin (1 cent, 5 cents, etc) and cash increments (1 dollar, 2 dollars, 5 dollars etc. )
0698:             * from ( money-in + cash drawer ) exceed the amount for that increment from the money-out.
0699:             * 
0700:             * @param cmDoc represents cash management document
0701:             * @param trans represents cash transaction from cash management document
0702:             * @return true if none of the coin and cash increments from money-in + cash drawer excreed amount for increments in money-out 
0703:             */
0704:            public boolean checkEnoughCashForMoneyOut(
0705:                    CashManagementDocument cmDoc, CashieringTransaction trans) {
0706:                boolean success = true;
0707:
0708:                CashDrawer cashDrawer = cmDoc.getCashDrawer();
0709:
0710:                // money out currency
0711:                CurrencyDetail moneyInCurrency = trans.getMoneyInCurrency();
0712:                CurrencyDetail moneyOutCurrency = trans.getMoneyOutCurrency();
0713:
0714:                KualiDecimal existingHundredDollarAmount = new KualiDecimal(0);
0715:                if (cashDrawer.getFinancialDocumentHundredDollarAmount() != null) {
0716:                    existingHundredDollarAmount = existingHundredDollarAmount
0717:                            .add(cashDrawer
0718:                                    .getFinancialDocumentHundredDollarAmount());
0719:                }
0720:                if (moneyInCurrency.getFinancialDocumentHundredDollarAmount() != null) {
0721:                    existingHundredDollarAmount = existingHundredDollarAmount
0722:                            .add(moneyInCurrency
0723:                                    .getFinancialDocumentHundredDollarAmount());
0724:                }
0725:                if (moneyOutCurrency.getFinancialDocumentHundredDollarAmount() != null
0726:                        && existingHundredDollarAmount
0727:                                .isLessThan(moneyOutCurrency
0728:                                        .getFinancialDocumentHundredDollarAmount())) {
0729:                    GlobalVariables
0730:                            .getErrorMap()
0731:                            .putError(
0732:                                    "document.currentTransaction.moneyOutCurrency.financialDocumentHundredDollarAmount",
0733:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
0734:                                    new String[] {
0735:                                            "hundred dollar",
0736:                                            moneyOutCurrency
0737:                                                    .getFinancialDocumentHundredDollarAmount()
0738:                                                    .toString(),
0739:                                            cashDrawer
0740:                                                    .getFinancialDocumentHundredDollarAmount()
0741:                                                    .toString() });
0742:                    success = false;
0743:                }
0744:
0745:                KualiDecimal existingOtherDollarAmount = new KualiDecimal(0);
0746:                if (cashDrawer.getFinancialDocumentOtherDollarAmount() != null) {
0747:                    existingOtherDollarAmount = existingOtherDollarAmount
0748:                            .add(cashDrawer
0749:                                    .getFinancialDocumentOtherDollarAmount());
0750:                }
0751:                if (moneyInCurrency.getFinancialDocumentOtherDollarAmount() != null) {
0752:                    existingOtherDollarAmount = existingOtherDollarAmount
0753:                            .add(moneyInCurrency
0754:                                    .getFinancialDocumentOtherDollarAmount());
0755:                }
0756:                if (moneyOutCurrency.getFinancialDocumentOtherDollarAmount() != null
0757:                        && existingOtherDollarAmount
0758:                                .isLessThan(moneyOutCurrency
0759:                                        .getFinancialDocumentOtherDollarAmount())) {
0760:                    GlobalVariables
0761:                            .getErrorMap()
0762:                            .putError(
0763:                                    "document.currentTransaction.moneyOutCurrency.financialDocumentOtherDollarAmount",
0764:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
0765:                                    new String[] {
0766:                                            "other dollar",
0767:                                            moneyOutCurrency
0768:                                                    .getFinancialDocumentOtherDollarAmount()
0769:                                                    .toString(),
0770:                                            cashDrawer
0771:                                                    .getFinancialDocumentOtherDollarAmount()
0772:                                                    .toString() });
0773:                    success = false;
0774:                }
0775:
0776:                KualiDecimal existingTwoDollarAmount = new KualiDecimal(0);
0777:                if (cashDrawer.getFinancialDocumentTwoDollarAmount() != null) {
0778:                    existingTwoDollarAmount = existingTwoDollarAmount
0779:                            .add(cashDrawer
0780:                                    .getFinancialDocumentTwoDollarAmount());
0781:                }
0782:                if (moneyInCurrency.getFinancialDocumentTwoDollarAmount() != null) {
0783:                    existingTwoDollarAmount = existingTwoDollarAmount
0784:                            .add(moneyInCurrency
0785:                                    .getFinancialDocumentTwoDollarAmount());
0786:                }
0787:                if (moneyOutCurrency.getFinancialDocumentTwoDollarAmount() != null
0788:                        && existingTwoDollarAmount.isLessThan(moneyOutCurrency
0789:                                .getFinancialDocumentTwoDollarAmount())) {
0790:                    GlobalVariables
0791:                            .getErrorMap()
0792:                            .putError(
0793:                                    "document.currentTransaction.moneyOutCurrency.financialDocumentTwoDollarAmount",
0794:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
0795:                                    new String[] {
0796:                                            "two dollar",
0797:                                            moneyOutCurrency
0798:                                                    .getFinancialDocumentTwoDollarAmount()
0799:                                                    .toString(),
0800:                                            cashDrawer
0801:                                                    .getFinancialDocumentTwoDollarAmount()
0802:                                                    .toString() });
0803:                    success = false;
0804:                }
0805:
0806:                KualiDecimal existingFiftyDollarAmount = new KualiDecimal(0);
0807:                if (cashDrawer.getFinancialDocumentFiftyDollarAmount() != null) {
0808:                    existingFiftyDollarAmount = existingFiftyDollarAmount
0809:                            .add(cashDrawer
0810:                                    .getFinancialDocumentFiftyDollarAmount());
0811:                }
0812:                if (moneyInCurrency.getFinancialDocumentFiftyDollarAmount() != null) {
0813:                    existingFiftyDollarAmount = existingFiftyDollarAmount
0814:                            .add(moneyInCurrency
0815:                                    .getFinancialDocumentFiftyDollarAmount());
0816:                }
0817:                if (moneyOutCurrency.getFinancialDocumentFiftyDollarAmount() != null
0818:                        && existingFiftyDollarAmount
0819:                                .isLessThan(moneyOutCurrency
0820:                                        .getFinancialDocumentFiftyDollarAmount())) {
0821:                    GlobalVariables
0822:                            .getErrorMap()
0823:                            .putError(
0824:                                    "document.currentTransaction.moneyOutCurrency.financialDocumentFiftyDollarAmount",
0825:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
0826:                                    new String[] {
0827:                                            "fifty dollar",
0828:                                            moneyOutCurrency
0829:                                                    .getFinancialDocumentFiftyDollarAmount()
0830:                                                    .toString(),
0831:                                            cashDrawer
0832:                                                    .getFinancialDocumentFiftyDollarAmount()
0833:                                                    .toString() });
0834:                    success = false;
0835:                }
0836:
0837:                KualiDecimal existingTwentyDollarAmount = new KualiDecimal(0);
0838:                if (cashDrawer.getFinancialDocumentTwentyDollarAmount() != null) {
0839:                    existingTwentyDollarAmount = existingTwentyDollarAmount
0840:                            .add(cashDrawer
0841:                                    .getFinancialDocumentTwentyDollarAmount());
0842:                }
0843:                if (moneyInCurrency.getFinancialDocumentTwentyDollarAmount() != null) {
0844:                    existingTwentyDollarAmount = existingTwentyDollarAmount
0845:                            .add(moneyInCurrency
0846:                                    .getFinancialDocumentTwentyDollarAmount());
0847:                }
0848:                if (moneyOutCurrency.getFinancialDocumentTwentyDollarAmount() != null
0849:                        && existingTwentyDollarAmount
0850:                                .isLessThan(moneyOutCurrency
0851:                                        .getFinancialDocumentTwentyDollarAmount())) {
0852:                    GlobalVariables
0853:                            .getErrorMap()
0854:                            .putError(
0855:                                    "document.currentTransaction.moneyOutCurrency.financialDocumentTwentyDollarAmount",
0856:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
0857:                                    new String[] {
0858:                                            "twenty dollar",
0859:                                            moneyOutCurrency
0860:                                                    .getFinancialDocumentTwentyDollarAmount()
0861:                                                    .toString(),
0862:                                            cashDrawer
0863:                                                    .getFinancialDocumentTwentyDollarAmount()
0864:                                                    .toString() });
0865:                    success = false;
0866:                }
0867:
0868:                KualiDecimal existingTenDollarAmount = new KualiDecimal(0);
0869:                if (cashDrawer.getFinancialDocumentTenDollarAmount() != null) {
0870:                    existingTenDollarAmount = existingTenDollarAmount
0871:                            .add(cashDrawer
0872:                                    .getFinancialDocumentTenDollarAmount());
0873:                }
0874:                if (moneyInCurrency.getFinancialDocumentTenDollarAmount() != null) {
0875:                    existingTenDollarAmount = existingTenDollarAmount
0876:                            .add(moneyInCurrency
0877:                                    .getFinancialDocumentTenDollarAmount());
0878:                }
0879:                if (moneyOutCurrency.getFinancialDocumentTenDollarAmount() != null
0880:                        && existingTenDollarAmount.isLessThan(moneyOutCurrency
0881:                                .getFinancialDocumentTenDollarAmount())) {
0882:                    GlobalVariables
0883:                            .getErrorMap()
0884:                            .putError(
0885:                                    "document.currentTransaction.moneyOutCurrency.financialDocumentTenDollarAmount",
0886:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
0887:                                    new String[] {
0888:                                            "ten dollar",
0889:                                            moneyOutCurrency
0890:                                                    .getFinancialDocumentTenDollarAmount()
0891:                                                    .toString(),
0892:                                            cashDrawer
0893:                                                    .getFinancialDocumentTenDollarAmount()
0894:                                                    .toString() });
0895:                    success = false;
0896:                }
0897:
0898:                KualiDecimal existingFiveDollarAmount = new KualiDecimal(0);
0899:                if (cashDrawer.getFinancialDocumentFiveDollarAmount() != null) {
0900:                    existingFiveDollarAmount = existingFiveDollarAmount
0901:                            .add(cashDrawer
0902:                                    .getFinancialDocumentFiveDollarAmount());
0903:                }
0904:                if (moneyInCurrency.getFinancialDocumentFiveDollarAmount() != null) {
0905:                    existingFiveDollarAmount = existingFiveDollarAmount
0906:                            .add(moneyInCurrency
0907:                                    .getFinancialDocumentFiveDollarAmount());
0908:                }
0909:                if (moneyOutCurrency.getFinancialDocumentFiveDollarAmount() != null
0910:                        && existingFiveDollarAmount.isLessThan(moneyOutCurrency
0911:                                .getFinancialDocumentFiveDollarAmount())) {
0912:                    GlobalVariables
0913:                            .getErrorMap()
0914:                            .putError(
0915:                                    "document.currentTransaction.moneyOutCurrency.financialDocumentFiveDollarAmount",
0916:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
0917:                                    new String[] {
0918:                                            "five dollar",
0919:                                            moneyOutCurrency
0920:                                                    .getFinancialDocumentFiveDollarAmount()
0921:                                                    .toString(),
0922:                                            cashDrawer
0923:                                                    .getFinancialDocumentFiveDollarAmount()
0924:                                                    .toString() });
0925:                    success = false;
0926:                }
0927:
0928:                KualiDecimal existingOneDollarAmount = new KualiDecimal(0);
0929:                if (cashDrawer.getFinancialDocumentOneDollarAmount() != null) {
0930:                    existingOneDollarAmount = existingOneDollarAmount
0931:                            .add(cashDrawer
0932:                                    .getFinancialDocumentOneDollarAmount());
0933:                }
0934:                if (moneyInCurrency.getFinancialDocumentOneDollarAmount() != null) {
0935:                    existingOneDollarAmount = existingOneDollarAmount
0936:                            .add(moneyInCurrency
0937:                                    .getFinancialDocumentOneDollarAmount());
0938:                }
0939:                if (moneyOutCurrency.getFinancialDocumentOneDollarAmount() != null
0940:                        && existingOneDollarAmount.isLessThan(moneyOutCurrency
0941:                                .getFinancialDocumentOneDollarAmount())) {
0942:                    GlobalVariables
0943:                            .getErrorMap()
0944:                            .putError(
0945:                                    "document.currentTransaction.moneyOutCurrency.financialDocumentOneDollarAmount",
0946:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
0947:                                    new String[] {
0948:                                            "one dollar",
0949:                                            moneyOutCurrency
0950:                                                    .getFinancialDocumentOneDollarAmount()
0951:                                                    .toString(),
0952:                                            cashDrawer
0953:                                                    .getFinancialDocumentOneDollarAmount()
0954:                                                    .toString() });
0955:                    success = false;
0956:                }
0957:
0958:                // money out coin
0959:                CoinDetail moneyOutCoin = trans.getMoneyOutCoin();
0960:                CoinDetail moneyInCoin = trans.getMoneyInCoin();
0961:                KualiDecimal existingHundredCentAmount = new KualiDecimal(0);
0962:                if (cashDrawer.getFinancialDocumentHundredCentAmount() != null) {
0963:                    existingHundredCentAmount = existingHundredCentAmount
0964:                            .add(cashDrawer
0965:                                    .getFinancialDocumentHundredCentAmount());
0966:                }
0967:                if (moneyInCoin.getFinancialDocumentHundredCentAmount() != null) {
0968:                    existingHundredCentAmount = existingHundredCentAmount
0969:                            .add(moneyInCoin
0970:                                    .getFinancialDocumentHundredCentAmount());
0971:                }
0972:                if (moneyOutCoin.getFinancialDocumentHundredCentAmount() != null
0973:                        && existingHundredCentAmount.isLessThan(moneyOutCoin
0974:                                .getFinancialDocumentHundredCentAmount())) {
0975:                    GlobalVariables
0976:                            .getErrorMap()
0977:                            .putError(
0978:                                    "document.currentTransaction.moneyOutCoin.financialDocumentHundredCentAmount",
0979:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
0980:                                    new String[] {
0981:                                            "hundred cent",
0982:                                            moneyOutCoin
0983:                                                    .getFinancialDocumentHundredCentAmount()
0984:                                                    .toString(),
0985:                                            cashDrawer
0986:                                                    .getFinancialDocumentHundredCentAmount()
0987:                                                    .toString() });
0988:                    success = false;
0989:                }
0990:
0991:                KualiDecimal existingOtherCentAmount = new KualiDecimal(0);
0992:                if (cashDrawer.getFinancialDocumentOtherCentAmount() != null) {
0993:                    existingOtherCentAmount = existingOtherCentAmount
0994:                            .add(cashDrawer
0995:                                    .getFinancialDocumentOtherCentAmount());
0996:                }
0997:                if (moneyInCoin.getFinancialDocumentOtherCentAmount() != null) {
0998:                    existingOtherCentAmount = existingOtherCentAmount
0999:                            .add(moneyInCoin
1000:                                    .getFinancialDocumentOtherCentAmount());
1001:                }
1002:                if (moneyOutCoin.getFinancialDocumentOtherCentAmount() != null
1003:                        && existingOtherCentAmount.isLessThan(moneyOutCoin
1004:                                .getFinancialDocumentOtherCentAmount())) {
1005:                    GlobalVariables
1006:                            .getErrorMap()
1007:                            .putError(
1008:                                    "document.currentTransaction.moneyOutCoin.financialDocumentOtherCentAmount",
1009:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
1010:                                    new String[] {
1011:                                            "other cent",
1012:                                            moneyOutCoin
1013:                                                    .getFinancialDocumentOtherCentAmount()
1014:                                                    .toString(),
1015:                                            cashDrawer
1016:                                                    .getFinancialDocumentOtherCentAmount()
1017:                                                    .toString() });
1018:                    success = false;
1019:                }
1020:
1021:                KualiDecimal existingFiftyCentAmount = new KualiDecimal(0);
1022:                if (cashDrawer.getFinancialDocumentFiftyCentAmount() != null) {
1023:                    existingFiftyCentAmount = existingFiftyCentAmount
1024:                            .add(cashDrawer
1025:                                    .getFinancialDocumentFiftyCentAmount());
1026:                }
1027:                if (moneyInCoin.getFinancialDocumentFiftyCentAmount() != null) {
1028:                    existingFiftyCentAmount = existingFiftyCentAmount
1029:                            .add(moneyInCoin
1030:                                    .getFinancialDocumentFiftyCentAmount());
1031:                }
1032:                if (moneyOutCoin.getFinancialDocumentFiftyCentAmount() != null
1033:                        && existingFiftyCentAmount.isLessThan(moneyOutCoin
1034:                                .getFinancialDocumentFiftyCentAmount())) {
1035:                    GlobalVariables
1036:                            .getErrorMap()
1037:                            .putError(
1038:                                    "document.currentTransaction.moneyOutCoin.financialDocumentFiftyCentAmount",
1039:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
1040:                                    new String[] {
1041:                                            "fifty cent",
1042:                                            moneyOutCoin
1043:                                                    .getFinancialDocumentFiftyCentAmount()
1044:                                                    .toString(),
1045:                                            cashDrawer
1046:                                                    .getFinancialDocumentFiftyCentAmount()
1047:                                                    .toString() });
1048:                    success = false;
1049:                }
1050:
1051:                KualiDecimal existingTwentyFiveCentAmount = new KualiDecimal(0);
1052:                if (cashDrawer.getFinancialDocumentTwentyFiveCentAmount() != null) {
1053:                    existingTwentyFiveCentAmount = existingTwentyFiveCentAmount
1054:                            .add(cashDrawer
1055:                                    .getFinancialDocumentTwentyFiveCentAmount());
1056:                }
1057:                if (moneyInCoin.getFinancialDocumentTwentyFiveCentAmount() != null) {
1058:                    existingTwentyFiveCentAmount = existingTwentyFiveCentAmount
1059:                            .add(moneyInCoin
1060:                                    .getFinancialDocumentTwentyFiveCentAmount());
1061:                }
1062:                if (moneyOutCoin.getFinancialDocumentTwentyFiveCentAmount() != null
1063:                        && existingTwentyFiveCentAmount.isLessThan(moneyOutCoin
1064:                                .getFinancialDocumentTwentyFiveCentAmount())) {
1065:                    GlobalVariables
1066:                            .getErrorMap()
1067:                            .putError(
1068:                                    "document.currentTransaction.moneyOutCoin.financialDocumentTwentyFiveCentAmount",
1069:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
1070:                                    new String[] {
1071:                                            "twenty five cent",
1072:                                            moneyOutCoin
1073:                                                    .getFinancialDocumentTwentyFiveCentAmount()
1074:                                                    .toString(),
1075:                                            cashDrawer
1076:                                                    .getFinancialDocumentTwentyFiveCentAmount()
1077:                                                    .toString() });
1078:                    success = false;
1079:                }
1080:
1081:                KualiDecimal existingTenCentAmount = new KualiDecimal(0);
1082:                if (cashDrawer.getFinancialDocumentTenCentAmount() != null) {
1083:                    existingTenCentAmount = existingTenCentAmount
1084:                            .add(cashDrawer.getFinancialDocumentTenCentAmount());
1085:                }
1086:                if (moneyInCoin.getFinancialDocumentTenCentAmount() != null) {
1087:                    existingTenCentAmount = existingTenCentAmount
1088:                            .add(moneyInCoin
1089:                                    .getFinancialDocumentTenCentAmount());
1090:                }
1091:                if (moneyOutCoin.getFinancialDocumentTenCentAmount() != null
1092:                        && existingTenCentAmount.isLessThan(moneyOutCoin
1093:                                .getFinancialDocumentTenCentAmount())) {
1094:                    GlobalVariables
1095:                            .getErrorMap()
1096:                            .putError(
1097:                                    "document.currentTransaction.moneyOutCoin.financialDocumentTenCentAmount",
1098:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
1099:                                    new String[] {
1100:                                            "ten cent",
1101:                                            moneyOutCoin
1102:                                                    .getFinancialDocumentTenCentAmount()
1103:                                                    .toString(),
1104:                                            cashDrawer
1105:                                                    .getFinancialDocumentTenCentAmount()
1106:                                                    .toString() });
1107:                    success = false;
1108:                }
1109:
1110:                KualiDecimal existingFiveCentAmount = new KualiDecimal(0);
1111:                if (cashDrawer.getFinancialDocumentFiveCentAmount() != null) {
1112:                    existingFiveCentAmount = existingFiveCentAmount
1113:                            .add(cashDrawer
1114:                                    .getFinancialDocumentFiveCentAmount());
1115:                }
1116:                if (moneyInCoin.getFinancialDocumentFiveCentAmount() != null) {
1117:                    existingFiveCentAmount = existingFiveCentAmount
1118:                            .add(moneyInCoin
1119:                                    .getFinancialDocumentFiveCentAmount());
1120:                }
1121:                if (moneyOutCoin.getFinancialDocumentFiveCentAmount() != null
1122:                        && existingFiveCentAmount.isLessThan(moneyOutCoin
1123:                                .getFinancialDocumentFiveCentAmount())) {
1124:                    GlobalVariables
1125:                            .getErrorMap()
1126:                            .putError(
1127:                                    "document.currentTransaction.moneyOutCoin.financialDocumentFiveCentAmount",
1128:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
1129:                                    new String[] {
1130:                                            "five cent",
1131:                                            moneyOutCoin
1132:                                                    .getFinancialDocumentFiveCentAmount()
1133:                                                    .toString(),
1134:                                            cashDrawer
1135:                                                    .getFinancialDocumentFiveCentAmount()
1136:                                                    .toString() });
1137:                    success = false;
1138:                }
1139:
1140:                KualiDecimal existingOneCentAmount = new KualiDecimal(0);
1141:                if (cashDrawer.getFinancialDocumentOneCentAmount() != null) {
1142:                    existingOneCentAmount = existingOneCentAmount
1143:                            .add(cashDrawer.getFinancialDocumentOneCentAmount());
1144:                }
1145:                if (moneyInCoin.getFinancialDocumentOneCentAmount() != null) {
1146:                    existingOneCentAmount = existingOneCentAmount
1147:                            .add(moneyInCoin
1148:                                    .getFinancialDocumentOneCentAmount());
1149:                }
1150:                if (moneyOutCoin.getFinancialDocumentOneCentAmount() != null
1151:                        && existingOneCentAmount.isLessThan(moneyOutCoin
1152:                                .getFinancialDocumentOneCentAmount())) {
1153:                    GlobalVariables
1154:                            .getErrorMap()
1155:                            .putError(
1156:                                    "document.currentTransaction.moneyOutCoin.financialDocumentOneCentAmount",
1157:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CASH_COUNT_EXCEEDS_DRAWER,
1158:                                    new String[] {
1159:                                            "one cent",
1160:                                            moneyOutCoin
1161:                                                    .getFinancialDocumentOneCentAmount()
1162:                                                    .toString(),
1163:                                            cashDrawer
1164:                                                    .getFinancialDocumentOneCentAmount()
1165:                                                    .toString() });
1166:                    success = false;
1167:                }
1168:
1169:                return success;
1170:            }
1171:
1172:            /**
1173:             * This method returns true if the new item in process does not exceed the current amount in the cash drawer reserves
1174:             * 
1175:             * @param cmDoc submitted cash management document
1176:             * @param trans transaction from cash management document
1177:             * @return true if the new item in process does not exceed the current amount in the cash drawer reserves
1178:             */
1179:            public boolean checkNewItemInProcessDoesNotExceedCashDrawer(
1180:                    CashManagementDocument cmDoc, CashieringTransaction trans) {
1181:                boolean success = true;
1182:
1183:                if (trans.getNewItemInProcess().getItemAmount() != null
1184:                        && trans.getNewItemInProcess().getItemAmount()
1185:                                .isGreaterThan(
1186:                                        calculateTotalCashDrawerReserves(cmDoc,
1187:                                                trans))) {
1188:                    GlobalVariables
1189:                            .getErrorMap()
1190:                            .putError(
1191:                                    "document.currentTransaction.newItemInProcess",
1192:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_AMOUNT_EXCEEDS_DRAWER,
1193:                                    new String[] {
1194:                                            "new Item In Process",
1195:                                            trans.getNewItemInProcess()
1196:                                                    .getItemAmount().toString(),
1197:                                            calculateTotalCashDrawerReserves(
1198:                                                    cmDoc, trans).toString() });
1199:                    success = false;
1200:                }
1201:
1202:                return success;
1203:            }
1204:
1205:            /**
1206:             * This method returns true if check total from transaction does not exceed the current amount in the cash drawer reserves 
1207:             * 
1208:             * @param cmDoc submitted cash management document
1209:             * @param trans transaction from cash management document
1210:             * @return true if check total from transaction does not exceed the current amount in the cash drawer reserves
1211:             */
1212:            public boolean checkTransactionCheckTotalDoesNotExceedCashDrawer(
1213:                    CashManagementDocument cmDoc, CashieringTransaction trans) {
1214:                boolean success = true;
1215:
1216:                if (trans.getTotalCheckAmount().isGreaterThan(
1217:                        calculateTotalCashDrawerReserves(cmDoc, trans))) {
1218:                    GlobalVariables
1219:                            .getErrorMap()
1220:                            .putError(
1221:                                    "document.currentTransaction.newCheck",
1222:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_AMOUNT_EXCEEDS_DRAWER,
1223:                                    new String[] {
1224:                                            "given checks",
1225:                                            trans.getTotalCheckAmount()
1226:                                                    .toString(),
1227:                                            calculateTotalCashDrawerReserves(
1228:                                                    cmDoc, trans).toString() });
1229:                    success = false;
1230:                }
1231:
1232:                return success;
1233:            }
1234:
1235:            /**
1236:             * This method returns true if the current payment amount for the cashiering item in process does not exceed
1237:             * the actual item amount for the item in process
1238:             * 
1239:             * @param itemInProc cashiering item in process
1240:             * @param cashieringItemNumber cashiering item number
1241:             * @return true if the current payment amount for the cashiering item in process does not exceed
1242:             *          the actual item amount for the item in process
1243:             */
1244:            public boolean checkPaidBackItemInProcessDoesNotExceedTotal(
1245:                    CashieringItemInProcess itemInProc, int cashieringItemNumber) {
1246:                boolean success = true;
1247:                if (itemInProc.getCurrentPayment() != null
1248:                        && itemInProc.getCurrentPayment().isGreaterThan(
1249:                                itemInProc.getItemAmount())) {
1250:                    GlobalVariables
1251:                            .getErrorMap()
1252:                            .putError(
1253:                                    KFSConstants.CASHIERING_TRANSACTION_OPEN_ITEM_IN_PROCESS_PROPERTY
1254:                                            + "[" + cashieringItemNumber + "]",
1255:                                    KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_AMOUNT_PAID_BACK_EXCEEDS_AMOUNT_LEFT,
1256:                                    new String[] { itemInProc
1257:                                            .getItemIdentifier().toString() });
1258:                    success = false;
1259:                }
1260:                return success;
1261:            }
1262:
1263:            /**
1264:             * This method returns true if a new item in process is populated and none of the open item in process' amounts are greater than zero.
1265:             * 
1266:             * @param cmDoc submitted cash management document
1267:             * @param trans transaction from cash management document
1268:             * @return true if a new item in process is populated and none of the open item in process' amounts are greater than zero.
1269:             */
1270:            public boolean checkItemInProcessIsNotPayingOffItemInProcess(
1271:                    CashManagementDocument cmDoc, CashieringTransaction trans) {
1272:                boolean success = true;
1273:                if (trans.getNewItemInProcess().isPopulated()) {
1274:                    int count = 0;
1275:                    for (CashieringItemInProcess advance : trans
1276:                            .getOpenItemsInProcess()) {
1277:                        if (advance.getCurrentPayment() != null
1278:                                && advance.getCurrentPayment().isGreaterThan(
1279:                                        KualiDecimal.ZERO)) {
1280:                            GlobalVariables
1281:                                    .getErrorMap()
1282:                                    .putError(
1283:                                            KFSConstants.CASHIERING_TRANSACTION_OPEN_ITEM_IN_PROCESS_PROPERTY
1284:                                                    + "[" + count + "]",
1285:                                            KFSKeyConstants.CashManagement.ERROR_DOCUMENT_CASHIERING_TRANSACTION_CANNOT_PAY_OFF_ADVANCE_WITH_ADVANCE,
1286:                                            new String[] { advance
1287:                                                    .getItemIdentifier()
1288:                                                    .toString() });
1289:                            success = false;
1290:                        }
1291:                        count += 1;
1292:                    }
1293:                }
1294:                return success;
1295:            }
1296:
1297:            /**
1298:             * This method returns true if all open items in process amounts do not exceed the total for each specific item's amount total
1299:             * 
1300:             * @param trans transaction from cash management document
1301:             * @return true if all open items in process amounts do not exceed the total for each specific item's amount total
1302:             */
1303:            public boolean checkAllPaidBackItemsInProcess(
1304:                    CashieringTransaction trans) {
1305:                boolean success = true;
1306:                int count = 0;
1307:                if (trans.getOpenItemsInProcess() != null) {
1308:                    for (CashieringItemInProcess itemInProc : trans
1309:                            .getOpenItemsInProcess()) {
1310:                        success &= checkPaidBackItemInProcessDoesNotExceedTotal(
1311:                                itemInProc, count);
1312:                        count += 1;
1313:                    }
1314:                }
1315:                return success;
1316:            }
1317:
1318:            /**
1319:             * This method returns true if the current date is after all new items in process' open dates
1320:             * 
1321:             * @param trans transaction from cash management document
1322:             * @return true if the current date is after all new items in process' open dates
1323:             */
1324:            public boolean checkNewItemInProcessInPast(
1325:                    CashieringTransaction trans) {
1326:                boolean success = true;
1327:                if (trans.getNewItemInProcess().isPopulated()) {
1328:                    if (trans.getNewItemInProcess().getItemOpenDate() != null
1329:                            && convertDateToDayYear(trans.getNewItemInProcess()
1330:                                    .getItemOpenDate()) > convertDateToDayYear(new Date())) {
1331:                        GlobalVariables
1332:                                .getErrorMap()
1333:                                .putError(
1334:                                        "document.currentTransaction.newItemInProcess.itemOpenDate",
1335:                                        KFSKeyConstants.CashManagement.ERROR_NEW_ITEM_IN_PROCESS_IN_FUTURE,
1336:                                        new String[] {});
1337:                        success = false;
1338:                    }
1339:                }
1340:                return success;
1341:            }
1342:
1343:            /**
1344:             * This method calculates the total cash drawer reserves amount
1345:             * 
1346:             * @param cmDoc
1347:             * @param trans
1348:             * @return KualiDecimal as total from cash drawer reserves
1349:             */
1350:            private KualiDecimal calculateTotalCashDrawerReserves(
1351:                    CashManagementDocument cmDoc, CashieringTransaction trans) {
1352:                KualiDecimal reserves = new KualiDecimal(cmDoc.getCashDrawer()
1353:                        .getTotalAmount().bigDecimalValue());
1354:                reserves = reserves.add(trans.getMoneyInCurrency()
1355:                        .getTotalAmount());
1356:                reserves = reserves
1357:                        .add(trans.getMoneyInCoin().getTotalAmount());
1358:                return reserves;
1359:            }
1360:
1361:            /**
1362:             * This method returns the current day of year as an int for a specific date.
1363:             * 
1364:             * @param d date
1365:             * @return int as day of year
1366:             */
1367:            private int convertDateToDayYear(Date d) {
1368:                Calendar cal = new GregorianCalendar();
1369:                cal.setTime(d);
1370:                return cal.get(Calendar.YEAR) * 366
1371:                        + cal.get(Calendar.DAY_OF_YEAR);
1372:            }
1373:
1374:            /**
1375:             * Gets the cashDrawerService attribute.
1376:             * 
1377:             * @return Returns the cashDrawerService.
1378:             */
1379:            public CashDrawerService getCashDrawerService() {
1380:                return cashDrawerService;
1381:            }
1382:
1383:            /**
1384:             * Sets the cashDrawerService attribute value.
1385:             * 
1386:             * @param cashDrawerService The cashDrawerService to set.
1387:             */
1388:            public void setCashDrawerService(CashDrawerService cashDrawerService) {
1389:                this.cashDrawerService = cashDrawerService;
1390:            }
1391:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.