Source Code Cross Referenced for BudgetAdjustmentLaborBenefitsServiceImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » financial » service » impl » 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.service.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-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.service.impl;
017:
018:        import java.util.ArrayList;
019:        import java.util.Collection;
020:        import java.util.HashMap;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Map;
024:
025:        import org.kuali.core.service.BusinessObjectService;
026:        import org.kuali.core.util.KualiDecimal;
027:        import org.kuali.core.util.KualiInteger;
028:        import org.kuali.core.util.ObjectUtils;
029:        import org.kuali.kfs.KFSPropertyConstants;
030:        import org.kuali.kfs.bo.SourceAccountingLine;
031:        import org.kuali.kfs.bo.TargetAccountingLine;
032:        import org.kuali.module.financial.bo.BudgetAdjustmentAccountingLine;
033:        import org.kuali.module.financial.bo.BudgetAdjustmentSourceAccountingLine;
034:        import org.kuali.module.financial.document.BudgetAdjustmentDocument;
035:        import org.kuali.module.financial.service.BudgetAdjustmentLaborBenefitsService;
036:        import org.kuali.module.labor.bo.BenefitsCalculation;
037:        import org.kuali.module.labor.bo.PositionObjectBenefit;
038:
039:        /**
040:         * 
041:         * This is the default implementation of the methods defined by the BudgetAdjustmentLaborBenefitsService.
042:         * 
043:         * These service performs methods related to the generation of labor benefit accounting lines for the budget 
044:         * adjustment document.
045:         * 
046:         */
047:        public class BudgetAdjustmentLaborBenefitsServiceImpl implements 
048:                BudgetAdjustmentLaborBenefitsService {
049:            private BusinessObjectService businessObjectService;
050:
051:            /**
052:             * This method generated labor benefit accounting lines to be added to the BudgetDocument provided.
053:             * 
054:             * @param budgetDocument The BudgetDocument to have the new labor benefit accounting lines added to.
055:             * 
056:             * @see org.kuali.module.financial.service.BudgetAdjustmentLaborBenefitsService#generateLaborBenefitsAccountingLines(org.kuali.module.financial.document.BudgetAdjustmentDocument)
057:             */
058:            public void generateLaborBenefitsAccountingLines(
059:                    BudgetAdjustmentDocument budgetDocument) {
060:                Integer fiscalYear = budgetDocument.getPostingYear();
061:
062:                List accountingLines = new ArrayList();
063:                accountingLines.addAll(budgetDocument
064:                        .getSourceAccountingLines());
065:                accountingLines.addAll(budgetDocument
066:                        .getTargetAccountingLines());
067:
068:                /*
069:                 * find lines that have labor object codes, then retrieve the benefit calculation records for the object code. Finally, for
070:                 * each benefit record, create an accounting line with properties set from the original line, but substituted with the
071:                 * benefit object code and calculated current and base amount.
072:                 */
073:                for (Iterator iter = accountingLines.iterator(); iter.hasNext();) {
074:                    BudgetAdjustmentAccountingLine line = (BudgetAdjustmentAccountingLine) iter
075:                            .next();
076:
077:                    // check if the line was previousely generated benefit line, if so delete and skip
078:                    if (line.isFringeBenefitIndicator()) {
079:                        if (line instanceof  BudgetAdjustmentSourceAccountingLine) {
080:                            budgetDocument.getSourceAccountingLines().remove(
081:                                    line);
082:                        } else {
083:                            budgetDocument.getTargetAccountingLines().remove(
084:                                    line);
085:                        }
086:                        continue;
087:                    }
088:
089:                    Collection objectBenefits = retrieveLaborObjectBenefits(
090:                            fiscalYear, line);
091:                    if (objectBenefits != null) {
092:                        for (Iterator iterator = objectBenefits.iterator(); iterator
093:                                .hasNext();) {
094:                            PositionObjectBenefit objectBenefit = (PositionObjectBenefit) iterator
095:                                    .next();
096:                            BenefitsCalculation benefitsCalculation = objectBenefit
097:                                    .getBenefitsCalculation();
098:
099:                            // now create and set properties for the benefit line
100:                            BudgetAdjustmentAccountingLine benefitLine = (BudgetAdjustmentAccountingLine) ObjectUtils
101:                                    .deepCopy(line);
102:                            benefitLine
103:                                    .setFinancialObjectCode(benefitsCalculation
104:                                            .getPositionFringeBenefitObjectCode());
105:                            benefitLine.refresh();
106:
107:                            KualiDecimal benefitCurrentAmount = line
108:                                    .getCurrentBudgetAdjustmentAmount()
109:                                    .multiply(
110:                                            benefitsCalculation
111:                                                    .getPositionFringeBenefitPercent()
112:                                                    .toKualiDecimal());
113:                            benefitLine
114:                                    .setCurrentBudgetAdjustmentAmount(benefitCurrentAmount);
115:
116:                            KualiInteger benefitBaseAmount = line
117:                                    .getBaseBudgetAdjustmentAmount()
118:                                    .multiply(
119:                                            benefitsCalculation
120:                                                    .getPositionFringeBenefitPercent()
121:                                                    .toKualiDecimal());
122:                            benefitLine
123:                                    .setBaseBudgetAdjustmentAmount(benefitBaseAmount);
124:
125:                            // clear monthly lines per KULEDOCS-1606
126:                            benefitLine
127:                                    .clearFinancialDocumentMonthLineAmounts();
128:
129:                            // set flag on line so we know it was a generated benefit line and can clear it out later if needed
130:                            benefitLine.setFringeBenefitIndicator(true);
131:
132:                            if (benefitLine instanceof  BudgetAdjustmentSourceAccountingLine) {
133:                                budgetDocument
134:                                        .addSourceAccountingLine((SourceAccountingLine) benefitLine);
135:                            } else {
136:                                budgetDocument
137:                                        .addTargetAccountingLine((TargetAccountingLine) benefitLine);
138:                            }
139:                        }
140:                    }
141:                }
142:            }
143:
144:            /**
145:             * @param budgetDocument
146:             * @return 
147:             * 
148:             * @see org.kuali.module.financial.service.BudgetAdjustmentLaborBenefitsService#hasLaborObjectCodes(org.kuali.module.financial.document.BudgetAdjustmentDocument)
149:             */
150:            public boolean hasLaborObjectCodes(
151:                    BudgetAdjustmentDocument budgetDocument) {
152:                boolean hasLaborObjectCodes = false;
153:
154:                List accountingLines = new ArrayList();
155:                accountingLines.addAll(budgetDocument
156:                        .getSourceAccountingLines());
157:                accountingLines.addAll(budgetDocument
158:                        .getTargetAccountingLines());
159:
160:                Integer fiscalYear = budgetDocument.getPostingYear();
161:                for (Iterator iter = accountingLines.iterator(); iter.hasNext();) {
162:                    BudgetAdjustmentAccountingLine line = (BudgetAdjustmentAccountingLine) iter
163:                            .next();
164:                    Collection objectBenefits = retrieveLaborObjectBenefits(
165:                            fiscalYear, line);
166:                    if (objectBenefits != null && !objectBenefits.isEmpty()) {
167:                        hasLaborObjectCodes = true;
168:                        break;
169:                    }
170:                }
171:
172:                return hasLaborObjectCodes;
173:            }
174:
175:            /**
176:             * Calls business object service to retrieve LaborObjectBenefit objects for the given fiscal year, and chart, 
177:             * object code from accounting line.
178:             * 
179:             * @param fiscalYear The fiscal year to be used as search criteria for looking up the labor object benefits.
180:             * @param line The account line the benefits are being retrieved for.
181:             * @return List of LaborObjectBenefit objects or null if one does not exist for parameters
182:             */
183:            private Collection retrieveLaborObjectBenefits(Integer fiscalYear,
184:                    BudgetAdjustmentAccountingLine line) {
185:                Map searchCriteria = new HashMap();
186:
187:                searchCriteria.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR,
188:                        fiscalYear);
189:                searchCriteria.put(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE,
190:                        line.getChartOfAccountsCode());
191:                searchCriteria.put(KFSPropertyConstants.FINANCIAL_OBJECT_CODE,
192:                        line.getFinancialObjectCode());
193:
194:                return getBusinessObjectService().findMatching(
195:                        PositionObjectBenefit.class, searchCriteria);
196:            }
197:
198:            /**
199:             * Gets the businessObjectService attribute.
200:             * 
201:             * @return Returns the businessObjectService.
202:             */
203:            public BusinessObjectService getBusinessObjectService() {
204:                return businessObjectService;
205:            }
206:
207:            /**
208:             * Sets the businessObjectService attribute value.
209:             * 
210:             * @param businessObjectService The businessObjectService to set.
211:             */
212:            public void setBusinessObjectService(
213:                    BusinessObjectService businessObjectService) {
214:                this.businessObjectService = businessObjectService;
215:            }
216:
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.