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


001:        /*
002:         * Copyright 2005-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.web.struts.action;
017:
018:        import java.io.ByteArrayOutputStream;
019:        import java.text.MessageFormat;
020:
021:        import javax.servlet.http.HttpServletRequest;
022:        import javax.servlet.http.HttpServletResponse;
023:
024:        import org.apache.commons.lang.StringUtils;
025:        import org.apache.struts.action.ActionForm;
026:        import org.apache.struts.action.ActionForward;
027:        import org.apache.struts.action.ActionMapping;
028:        import org.kuali.core.bo.user.UniversalUser;
029:        import org.kuali.core.service.BusinessObjectService;
030:        import org.kuali.core.service.DictionaryValidationService;
031:        import org.kuali.core.service.DocumentService;
032:        import org.kuali.core.service.KualiConfigurationService;
033:        import org.kuali.core.util.GlobalVariables;
034:        import org.kuali.core.util.KualiDecimal;
035:        import org.kuali.core.util.ObjectUtils;
036:        import org.kuali.core.util.WebUtils;
037:        import org.kuali.core.web.struts.form.KualiDocumentFormBase;
038:        import org.kuali.kfs.KFSConstants;
039:        import org.kuali.kfs.KFSKeyConstants;
040:        import org.kuali.kfs.KFSPropertyConstants;
041:        import org.kuali.kfs.context.SpringContext;
042:        import org.kuali.kfs.service.ParameterService;
043:        import org.kuali.kfs.web.struts.action.KualiAccountingDocumentActionBase;
044:        import org.kuali.module.financial.bo.DisbursementVoucherNonEmployeeExpense;
045:        import org.kuali.module.financial.bo.DisbursementVoucherNonEmployeeTravel;
046:        import org.kuali.module.financial.bo.DisbursementVoucherPreConferenceRegistrant;
047:        import org.kuali.module.financial.bo.Payee;
048:        import org.kuali.module.financial.bo.WireCharge;
049:        import org.kuali.module.financial.document.DisbursementVoucherDocument;
050:        import org.kuali.module.financial.service.DisbursementVoucherCoverSheetService;
051:        import org.kuali.module.financial.service.DisbursementVoucherTaxService;
052:        import org.kuali.module.financial.service.DisbursementVoucherTravelService;
053:        import org.kuali.module.financial.service.UniversityDateService;
054:        import org.kuali.module.financial.service.impl.DisbursementVoucherCoverSheetServiceImpl;
055:        import org.kuali.module.financial.web.struts.form.DisbursementVoucherForm;
056:
057:        import edu.iu.uis.eden.exception.WorkflowException;
058:
059:        /**
060:         * This class handles Actions for the DisbursementVoucher.
061:         */
062:        public class DisbursementVoucherAction extends
063:                KualiAccountingDocumentActionBase {
064:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
065:                    .getLogger(DisbursementVoucherAction.class);
066:
067:            /**
068:             * @see org.kuali.core.web.struts.action.KualiTransactionalDocumentActionBase#execute(org.apache.struts.action.ActionMapping,
069:             *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
070:             */
071:            @Override
072:            public ActionForward execute(ActionMapping mapping,
073:                    ActionForm form, HttpServletRequest request,
074:                    HttpServletResponse response) throws Exception {
075:                ActionForward dest = super .execute(mapping, form, request,
076:                        response);
077:
078:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
079:                if (form != null) {
080:                    DisbursementVoucherDocument dvDoc = (DisbursementVoucherDocument) dvForm
081:                            .getDocument();
082:                    if (dvDoc != null) {
083:                        DisbursementVoucherNonEmployeeTravel dvNet = dvDoc
084:                                .getDvNonEmployeeTravel();
085:                        if (dvNet != null) {
086:                            // clear values derived from travelMileageAmount if that amount has been (manually) cleared
087:                            Integer amount = dvNet
088:                                    .getDvPersonalCarMileageAmount();
089:                            if ((amount == null) || (amount.intValue() == 0)) {
090:                                clearTravelMileageAmount(dvNet);
091:                            }
092:
093:                            // clear values derived from perDiemRate if that amount has been (manually) cleared
094:                            KualiDecimal rate = dvNet.getDisbVchrPerdiemRate();
095:                            if ((rate == null) || rate.isZero()) {
096:                                clearTravelPerDiem(dvNet);
097:                            }
098:                        }
099:                    }
100:                }
101:
102:                return dest;
103:            }
104:
105:            /**
106:             * Do initialization for a new disbursement voucher
107:             * 
108:             * @see org.kuali.core.web.struts.action.KualiDocumentActionBase#createDocument(org.kuali.core.web.struts.form.KualiDocumentFormBase)
109:             */
110:            @Override
111:            protected void createDocument(
112:                    KualiDocumentFormBase kualiDocumentFormBase)
113:                    throws WorkflowException {
114:                super .createDocument(kualiDocumentFormBase);
115:                ((DisbursementVoucherDocument) kualiDocumentFormBase
116:                        .getDocument()).initiateDocument();
117:
118:                // set wire charge message in form
119:                ((DisbursementVoucherForm) kualiDocumentFormBase)
120:                        .setWireChargeMessage(retrieveWireChargeMessage());
121:            }
122:
123:            /**
124:             * @see org.kuali.core.web.struts.action.KualiAction#refresh(org.apache.struts.action.ActionMapping,
125:             *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
126:             */
127:            @Override
128:            public ActionForward refresh(ActionMapping mapping,
129:                    ActionForm form, HttpServletRequest request,
130:                    HttpServletResponse response) throws Exception {
131:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
132:                DisbursementVoucherDocument document = (DisbursementVoucherDocument) dvForm
133:                        .getDocument();
134:
135:                /* refresh from dv payee lookup */
136:                if ((KFSConstants.KUALI_LOOKUPABLE_IMPL.equals(dvForm
137:                        .getRefreshCaller()) || KFSConstants.KUALI_USER_LOOKUPABLE_IMPL
138:                        .equals(dvForm.getRefreshCaller()))
139:                        && request
140:                                .getParameter(KFSPropertyConstants.DOCUMENT
141:                                        + "."
142:                                        + KFSPropertyConstants.DV_PAYEE_DETAIL
143:                                        + "."
144:                                        + KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER) != null
145:                        && document.getDvPayeeDetail().isPayee()) {
146:                    String payeeIdNumber = ((DisbursementVoucherDocument) dvForm
147:                            .getDocument()).getDvPayeeDetail()
148:                            .getDisbVchrPayeeIdNumber();
149:                    Payee refreshPayee = new Payee();
150:                    refreshPayee.setPayeeIdNumber(payeeIdNumber);
151:                    refreshPayee = (Payee) SpringContext.getBean(
152:                            BusinessObjectService.class).retrieve(refreshPayee);
153:                    ((DisbursementVoucherDocument) dvForm.getDocument())
154:                            .templatePayee(refreshPayee);
155:                }
156:                /* refresh from employee lookup */
157:                else if ((KFSConstants.KUALI_LOOKUPABLE_IMPL.equals(dvForm
158:                        .getRefreshCaller()) || KFSConstants.KUALI_USER_LOOKUPABLE_IMPL
159:                        .equals(dvForm.getRefreshCaller()))
160:                        && request
161:                                .getParameter(KFSPropertyConstants.DOCUMENT
162:                                        + "."
163:                                        + KFSPropertyConstants.DV_PAYEE_DETAIL
164:                                        + "."
165:                                        + KFSPropertyConstants.DISB_VCHR_PAYEE_ID_NUMBER) != null
166:                        && document.getDvPayeeDetail().isEmployee()) {
167:                    String emplUuid = ((DisbursementVoucherDocument) dvForm
168:                            .getDocument()).getDvPayeeDetail()
169:                            .getDisbVchrPayeeIdNumber();
170:                    UniversalUser employee = new UniversalUser();
171:                    employee.setPersonUniversalIdentifier(emplUuid);
172:                    employee = (UniversalUser) SpringContext.getBean(
173:                            BusinessObjectService.class).retrieve(employee);
174:                    ((DisbursementVoucherDocument) dvForm.getDocument())
175:                            .templateEmployee(employee);
176:                }
177:
178:                return super .refresh(mapping, form, request, response);
179:            }
180:
181:            /**
182:             * Calls service to generate the disbursement voucher cover sheet as a pdf.
183:             * 
184:             * @param mapping
185:             * @param form
186:             * @param request
187:             * @param response
188:             * @return ActionForward
189:             * @throws Exception
190:             */
191:            public ActionForward printDisbursementVoucherCoverSheet(
192:                    ActionMapping mapping, ActionForm form,
193:                    HttpServletRequest request, HttpServletResponse response)
194:                    throws Exception {
195:                // get directory of tempate
196:                String directory = SpringContext.getBean(
197:                        KualiConfigurationService.class).getPropertyString(
198:                        KFSConstants.EXTERNALIZABLE_HELP_URL_KEY);
199:
200:                DisbursementVoucherDocument document = (DisbursementVoucherDocument) SpringContext
201:                        .getBean(DocumentService.class)
202:                        .getByDocumentHeaderId(
203:                                request
204:                                        .getParameter(KFSPropertyConstants.DOCUMENT_NUMBER));
205:
206:                // set worflow document back into form to prevent document authorizer "invalid (null)
207:                // document.documentHeader.workflowDocument" since we are bypassing form submit and just linking directly to the action
208:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
209:                dvForm.getDocument().getDocumentHeader().setWorkflowDocument(
210:                        document.getDocumentHeader().getWorkflowDocument());
211:                ByteArrayOutputStream baos = new ByteArrayOutputStream();
212:                DisbursementVoucherCoverSheetService coverSheetService = SpringContext
213:                        .getBean(DisbursementVoucherCoverSheetService.class);
214:
215:                coverSheetService
216:                        .generateDisbursementVoucherCoverSheet(
217:                                directory,
218:                                DisbursementVoucherCoverSheetServiceImpl.DV_COVERSHEET_TEMPLATE_NM,
219:                                document, baos);
220:                String fileName = document.getDocumentNumber()
221:                        + "_cover_sheet.pdf";
222:                WebUtils.saveMimeOutputStreamAsFile(response,
223:                        "application/pdf", baos, fileName);
224:                return (null);
225:
226:            }
227:
228:            /**
229:             * Calculates the travel per diem amount.
230:             * 
231:             * @param mapping
232:             * @param form
233:             * @param request
234:             * @param response
235:             * @return ActionForward
236:             * @throws Exception
237:             */
238:            public ActionForward calculateTravelPerDiem(ActionMapping mapping,
239:                    ActionForm form, HttpServletRequest request,
240:                    HttpServletResponse response) throws Exception {
241:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
242:                DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) dvForm
243:                        .getDocument();
244:
245:                try {
246:                    // call service to calculate per diem
247:                    KualiDecimal perDiemAmount = SpringContext.getBean(
248:                            DisbursementVoucherTravelService.class)
249:                            .calculatePerDiemAmount(
250:                                    dvDocument.getDvNonEmployeeTravel()
251:                                            .getDvPerdiemStartDttmStamp(),
252:                                    dvDocument.getDvNonEmployeeTravel()
253:                                            .getDvPerdiemEndDttmStamp(),
254:                                    dvDocument.getDvNonEmployeeTravel()
255:                                            .getDisbVchrPerdiemRate());
256:
257:                    dvDocument.getDvNonEmployeeTravel()
258:                            .setDisbVchrPerdiemCalculatedAmt(perDiemAmount);
259:                    dvDocument.getDvNonEmployeeTravel()
260:                            .setDisbVchrPerdiemActualAmount(perDiemAmount);
261:                } catch (RuntimeException e) {
262:                    String errorMessage = e.getMessage();
263:
264:                    if (StringUtils.isBlank(errorMessage)) {
265:                        errorMessage = "The per diem amount could not be calculated.  Please ensure all required per diem fields are filled in before attempting to calculate the per diem amount.";
266:                    }
267:
268:                    LOG.error("Error in calculating travel per diem: "
269:                            + errorMessage);
270:                    GlobalVariables.getErrorMap().putError(
271:                            "DVNonEmployeeTravelErrors",
272:                            KFSKeyConstants.ERROR_CUSTOM, errorMessage);
273:                }
274:
275:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
276:
277:            }
278:
279:            /**
280:             * Clears the travel per diem amount
281:             * 
282:             * @param mapping
283:             * @param form
284:             * @param request
285:             * @param response
286:             * @return ActionForward
287:             * @throws Exception
288:             */
289:            public ActionForward clearTravelPerDiem(ActionMapping mapping,
290:                    ActionForm form, HttpServletRequest request,
291:                    HttpServletResponse response) throws Exception {
292:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
293:                DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) dvForm
294:                        .getDocument();
295:
296:                DisbursementVoucherNonEmployeeTravel dvNet = dvDocument
297:                        .getDvNonEmployeeTravel();
298:                if (dvNet != null) {
299:                    clearTravelPerDiem(dvNet);
300:                }
301:
302:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
303:
304:            }
305:
306:            private void clearTravelPerDiem(
307:                    DisbursementVoucherNonEmployeeTravel dvNet) {
308:                dvNet.setDisbVchrPerdiemCalculatedAmt(null);
309:                dvNet.setDisbVchrPerdiemActualAmount(null);
310:            }
311:
312:            /**
313:             * Calculates the travel mileage amount.
314:             * 
315:             * @param mapping
316:             * @param form
317:             * @param request
318:             * @param response
319:             * @return ActionForward
320:             * @throws Exception
321:             */
322:            public ActionForward calculateTravelMileageAmount(
323:                    ActionMapping mapping, ActionForm form,
324:                    HttpServletRequest request, HttpServletResponse response)
325:                    throws Exception {
326:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
327:                DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) dvForm
328:                        .getDocument();
329:
330:                if (dvDocument.getDvNonEmployeeTravel()
331:                        .getDvPersonalCarMileageAmount() == null) {
332:                    LOG.error("Total Mileage must be given");
333:                    GlobalVariables.getErrorMap().putError(
334:                            "DVNonEmployeeTravelErrors",
335:                            KFSKeyConstants.ERROR_REQUIRED, "Total Mileage");
336:                }
337:
338:                if (dvDocument.getDvNonEmployeeTravel()
339:                        .getDvPerdiemStartDttmStamp() == null) {
340:                    LOG.error("Travel Start Date must be given");
341:                    GlobalVariables.getErrorMap()
342:                            .putError("DVNonEmployeeTravelErrors",
343:                                    KFSKeyConstants.ERROR_REQUIRED,
344:                                    "Travel Start Date");
345:                }
346:
347:                if (GlobalVariables.getErrorMap().isEmpty()) {
348:                    // call service to calculate mileage amount
349:                    KualiDecimal mileageAmount = SpringContext.getBean(
350:                            DisbursementVoucherTravelService.class)
351:                            .calculateMileageAmount(
352:                                    dvDocument.getDvNonEmployeeTravel()
353:                                            .getDvPersonalCarMileageAmount(),
354:                                    dvDocument.getDvNonEmployeeTravel()
355:                                            .getDvPerdiemStartDttmStamp());
356:
357:                    dvDocument.getDvNonEmployeeTravel()
358:                            .setDisbVchrMileageCalculatedAmt(mileageAmount);
359:                    dvDocument.getDvNonEmployeeTravel()
360:                            .setDisbVchrPersonalCarAmount(mileageAmount);
361:                }
362:
363:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
364:            }
365:
366:            /**
367:             * Clears the travel mileage amount
368:             * 
369:             * @param mapping
370:             * @param form
371:             * @param request
372:             * @param response
373:             * @return ActionForward
374:             * @throws Exception
375:             */
376:            public ActionForward clearTravelMileageAmount(
377:                    ActionMapping mapping, ActionForm form,
378:                    HttpServletRequest request, HttpServletResponse response)
379:                    throws Exception {
380:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
381:                DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) dvForm
382:                        .getDocument();
383:
384:                DisbursementVoucherNonEmployeeTravel dvNet = dvDocument
385:                        .getDvNonEmployeeTravel();
386:                if (dvNet != null) {
387:                    clearTravelMileageAmount(dvNet);
388:                }
389:
390:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
391:
392:            }
393:
394:            private void clearTravelMileageAmount(
395:                    DisbursementVoucherNonEmployeeTravel dvNet) {
396:                dvNet.setDisbVchrMileageCalculatedAmt(null);
397:                dvNet.setDisbVchrPersonalCarAmount(null);
398:            }
399:
400:            /**
401:             * Adds a new employee travel expense line.
402:             * 
403:             * @param mapping
404:             * @param form
405:             * @param request
406:             * @param response
407:             * @return ActionForward
408:             * @throws Exception
409:             */
410:            public ActionForward addNonEmployeeExpenseLine(
411:                    ActionMapping mapping, ActionForm form,
412:                    HttpServletRequest request, HttpServletResponse response)
413:                    throws Exception {
414:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
415:                DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) dvForm
416:                        .getDocument();
417:
418:                DisbursementVoucherNonEmployeeExpense newExpenseLine = dvForm
419:                        .getNewNonEmployeeExpenseLine();
420:
421:                // validate line
422:                GlobalVariables.getErrorMap().addToErrorPath(
423:                        KFSPropertyConstants.NEW_NONEMPLOYEE_EXPENSE_LINE);
424:                SpringContext.getBean(DictionaryValidationService.class)
425:                        .validateBusinessObject(newExpenseLine);
426:
427:                // Ensure all fields are filled in before attempting to add a new expense line
428:                if (StringUtils.isBlank(newExpenseLine
429:                        .getDisbVchrPrePaidExpenseCode())) {
430:                    GlobalVariables.getErrorMap().putError(
431:                            KFSPropertyConstants.DISB_VCHR_EXPENSE_CODE,
432:                            KFSKeyConstants.ERROR_DV_EXPENSE_CODE);
433:                }
434:                if (StringUtils.isBlank(newExpenseLine
435:                        .getDisbVchrPrePaidExpenseCompanyName())) {
436:                    GlobalVariables
437:                            .getErrorMap()
438:                            .putError(
439:                                    KFSPropertyConstants.DISB_VCHR_EXPENSE_COMPANY_NAME,
440:                                    KFSKeyConstants.ERROR_DV_EXPENSE_COMPANY_NAME);
441:                }
442:                if (ObjectUtils.isNull(newExpenseLine
443:                        .getDisbVchrExpenseAmount())) {
444:                    GlobalVariables.getErrorMap().putError(
445:                            KFSPropertyConstants.DISB_VCHR_EXPENSE_AMOUNT,
446:                            KFSKeyConstants.ERROR_DV_EXPENSE_AMOUNT);
447:                }
448:
449:                GlobalVariables.getErrorMap().removeFromErrorPath(
450:                        KFSPropertyConstants.NEW_NONEMPLOYEE_EXPENSE_LINE);
451:
452:                if (GlobalVariables.getErrorMap().isEmpty()) {
453:                    dvDocument.getDvNonEmployeeTravel()
454:                            .addDvNonEmployeeExpenseLine(newExpenseLine);
455:                    dvForm
456:                            .setNewNonEmployeeExpenseLine(new DisbursementVoucherNonEmployeeExpense());
457:                }
458:
459:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
460:            };
461:
462:            /**
463:             * Adds a new employee pre paid travel expense line.
464:             * 
465:             * @param mapping
466:             * @param form
467:             * @param request
468:             * @param response
469:             * @return ActionForward
470:             * @throws Exception
471:             */
472:            public ActionForward addPrePaidNonEmployeeExpenseLine(
473:                    ActionMapping mapping, ActionForm form,
474:                    HttpServletRequest request, HttpServletResponse response)
475:                    throws Exception {
476:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
477:                DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) dvForm
478:                        .getDocument();
479:
480:                DisbursementVoucherNonEmployeeExpense newExpenseLine = dvForm
481:                        .getNewPrePaidNonEmployeeExpenseLine();
482:
483:                // validate line
484:                GlobalVariables.getErrorMap().addToErrorPath(
485:                        KFSPropertyConstants.NEW_PREPAID_EXPENSE_LINE);
486:                SpringContext.getBean(DictionaryValidationService.class)
487:                        .validateBusinessObject(newExpenseLine);
488:
489:                // Ensure all fields are filled in before attempting to add a new expense line
490:                if (StringUtils.isBlank(newExpenseLine
491:                        .getDisbVchrPrePaidExpenseCode())) {
492:                    GlobalVariables
493:                            .getErrorMap()
494:                            .putError(
495:                                    KFSPropertyConstants.DISB_VCHR_PRE_PAID_EXPENSE_CODE,
496:                                    KFSKeyConstants.ERROR_DV_PREPAID_EXPENSE_CODE);
497:                }
498:                if (StringUtils.isBlank(newExpenseLine
499:                        .getDisbVchrPrePaidExpenseCompanyName())) {
500:                    GlobalVariables
501:                            .getErrorMap()
502:                            .putError(
503:                                    KFSPropertyConstants.DISB_VCHR_PRE_PAID_EXPENSE_COMPANY_NAME,
504:                                    KFSKeyConstants.ERROR_DV_PREPAID_EXPENSE_COMPANY_NAME);
505:                }
506:                if (ObjectUtils.isNull(newExpenseLine
507:                        .getDisbVchrExpenseAmount())) {
508:                    GlobalVariables.getErrorMap().putError(
509:                            KFSPropertyConstants.DISB_VCHR_EXPENSE_AMOUNT,
510:                            KFSKeyConstants.ERROR_DV_PREPAID_EXPENSE_AMOUNT);
511:                }
512:                GlobalVariables.getErrorMap().removeFromErrorPath(
513:                        KFSPropertyConstants.NEW_PREPAID_EXPENSE_LINE);
514:
515:                if (GlobalVariables.getErrorMap().isEmpty()) {
516:                    dvDocument.getDvNonEmployeeTravel()
517:                            .addDvPrePaidEmployeeExpenseLine(newExpenseLine);
518:                    dvForm
519:                            .setNewPrePaidNonEmployeeExpenseLine(new DisbursementVoucherNonEmployeeExpense());
520:                }
521:
522:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
523:            };
524:
525:            /**
526:             * Deletes a non employee travel expense line.
527:             * 
528:             * @param mapping
529:             * @param form
530:             * @param request
531:             * @param response
532:             * @return ActionForward
533:             * @throws Exception
534:             */
535:            public ActionForward deleteNonEmployeeExpenseLine(
536:                    ActionMapping mapping, ActionForm form,
537:                    HttpServletRequest request, HttpServletResponse response)
538:                    throws Exception {
539:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
540:                DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) dvForm
541:                        .getDocument();
542:
543:                int deleteIndex = getLineToDelete(request);
544:                dvDocument.getDvNonEmployeeTravel().getDvNonEmployeeExpenses()
545:                        .remove(deleteIndex);
546:
547:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
548:            }
549:
550:            /**
551:             * Deletes a pre paid travel expense line.
552:             * 
553:             * @param mapping
554:             * @param form
555:             * @param request
556:             * @param response
557:             * @return ActionForward
558:             * @throws Exception
559:             */
560:            public ActionForward deletePrePaidEmployeeExpenseLine(
561:                    ActionMapping mapping, ActionForm form,
562:                    HttpServletRequest request, HttpServletResponse response)
563:                    throws Exception {
564:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
565:                DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) dvForm
566:                        .getDocument();
567:
568:                int deleteIndex = getLineToDelete(request);
569:                dvDocument.getDvNonEmployeeTravel()
570:                        .getDvPrePaidEmployeeExpenses().remove(deleteIndex);
571:
572:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
573:            }
574:
575:            /**
576:             * Adds a new pre conference registrant line.
577:             * 
578:             * @param mapping
579:             * @param form
580:             * @param request
581:             * @param response
582:             * @return ActionForward
583:             * @throws Exception
584:             */
585:            public ActionForward addPreConfRegistrantLine(
586:                    ActionMapping mapping, ActionForm form,
587:                    HttpServletRequest request, HttpServletResponse response)
588:                    throws Exception {
589:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
590:                DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) dvForm
591:                        .getDocument();
592:
593:                DisbursementVoucherPreConferenceRegistrant newRegistrantLine = dvForm
594:                        .getNewPreConferenceRegistrantLine();
595:
596:                // validate line
597:                GlobalVariables.getErrorMap().addToErrorPath(
598:                        KFSPropertyConstants.NEW_PRECONF_REGISTRANT_LINE);
599:                SpringContext.getBean(DictionaryValidationService.class)
600:                        .validateBusinessObject(newRegistrantLine);
601:                GlobalVariables.getErrorMap().removeFromErrorPath(
602:                        KFSPropertyConstants.NEW_PRECONF_REGISTRANT_LINE);
603:
604:                if (GlobalVariables.getErrorMap().isEmpty()) {
605:                    dvDocument.addDvPrePaidRegistrantLine(newRegistrantLine);
606:                    dvForm
607:                            .setNewPreConferenceRegistrantLine(new DisbursementVoucherPreConferenceRegistrant());
608:                }
609:
610:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
611:
612:            }
613:
614:            /**
615:             * Deletes a pre conference registrant line.
616:             * 
617:             * @param mapping
618:             * @param form
619:             * @param request
620:             * @param response
621:             * @return ActionForward
622:             * @throws Exception
623:             */
624:            public ActionForward deletePreConfRegistrantLine(
625:                    ActionMapping mapping, ActionForm form,
626:                    HttpServletRequest request, HttpServletResponse response)
627:                    throws Exception {
628:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
629:                DisbursementVoucherDocument dvDocument = (DisbursementVoucherDocument) dvForm
630:                        .getDocument();
631:
632:                int deleteIndex = getLineToDelete(request);
633:                dvDocument.getDvPreConferenceDetail()
634:                        .getDvPreConferenceRegistrants().remove(deleteIndex);
635:
636:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
637:
638:            }
639:
640:            /**
641:             * Calls service to generate tax accounting lines and updates nra tax line string in action form.
642:             * 
643:             * @param mapping
644:             * @param form
645:             * @param request
646:             * @param response
647:             * @return ActionForward
648:             * @throws Exception
649:             */
650:            public ActionForward generateNonResidentAlienTaxLines(
651:                    ActionMapping mapping, ActionForm form,
652:                    HttpServletRequest request, HttpServletResponse response)
653:                    throws Exception {
654:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
655:                DisbursementVoucherDocument document = (DisbursementVoucherDocument) dvForm
656:                        .getDocument();
657:
658:                /* user should not have generate button if not in tax group, but check just to make sure */
659:                if (!GlobalVariables
660:                        .getUserSession()
661:                        .getUniversalUser()
662:                        .isMember(
663:                                SpringContext
664:                                        .getBean(ParameterService.class)
665:                                        .getParameterValue(
666:                                                DisbursementVoucherDocument.class,
667:                                                KFSConstants.FinancialApcParms.DV_TAX_WORKGROUP))) {
668:                    LOG
669:                            .info("User requested generateNonResidentAlienTaxLines who is not in the kuali tax group.");
670:                    GlobalVariables.getErrorMap().putError(
671:                            KFSConstants.DV_NRATAX_TAB_ERRORS,
672:                            KFSKeyConstants.ERROR_DV_NRA_PERMISSIONS_GENERATE);
673:                    return mapping.findForward(KFSConstants.MAPPING_BASIC);
674:                }
675:
676:                DisbursementVoucherTaxService taxService = SpringContext
677:                        .getBean(DisbursementVoucherTaxService.class);
678:
679:                /* call service to generate new tax lines */
680:                GlobalVariables.getErrorMap().addToErrorPath("document");
681:                taxService.processNonResidentAlienTax(document);
682:                GlobalVariables.getErrorMap().removeFromErrorPath("document");
683:
684:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
685:            }
686:
687:            /**
688:             * Calls service to clear tax accounting lines and updates nra tax line string in action form.
689:             * 
690:             * @param mapping
691:             * @param form
692:             * @param request
693:             * @param response
694:             * @return ActionForward
695:             * @throws Exception
696:             */
697:            public ActionForward clearNonResidentAlienTaxLines(
698:                    ActionMapping mapping, ActionForm form,
699:                    HttpServletRequest request, HttpServletResponse response)
700:                    throws Exception {
701:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
702:                DisbursementVoucherDocument document = (DisbursementVoucherDocument) dvForm
703:                        .getDocument();
704:
705:                /* user should not have generate button if not in tax group, but check just to make sure */
706:                if (!GlobalVariables
707:                        .getUserSession()
708:                        .getUniversalUser()
709:                        .isMember(
710:                                SpringContext
711:                                        .getBean(ParameterService.class)
712:                                        .getParameterValue(
713:                                                DisbursementVoucherDocument.class,
714:                                                KFSConstants.FinancialApcParms.DV_TAX_WORKGROUP))) {
715:                    LOG
716:                            .info("User requested generateNonResidentAlienTaxLines who is not in the kuali tax group.");
717:                    GlobalVariables.getErrorMap().putError(
718:                            KFSConstants.DV_NRATAX_TAB_ERRORS,
719:                            KFSKeyConstants.ERROR_DV_NRA_PERMISSIONS_GENERATE);
720:                    return mapping.findForward(KFSConstants.MAPPING_BASIC);
721:                }
722:
723:                DisbursementVoucherTaxService taxService = SpringContext
724:                        .getBean(DisbursementVoucherTaxService.class);
725:
726:                /* call service to clear previous lines */
727:                taxService.clearNRATaxLines(document);
728:
729:                return mapping.findForward(KFSConstants.MAPPING_BASIC);
730:            }
731:
732:            /**
733:             * Hook into performLookup to switch the payee lookup based on the payee type selected.
734:             * 
735:             * @see org.kuali.core.web.struts.action.KualiAction#performLookup(org.apache.struts.action.ActionMapping,
736:             *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
737:             */
738:            @Override
739:            public ActionForward performLookup(ActionMapping mapping,
740:                    ActionForm form, HttpServletRequest request,
741:                    HttpServletResponse response) throws Exception {
742:                // substitute bo class and mapping if the type is Employee, lookup already setup for Payee
743:                DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
744:                DisbursementVoucherDocument document = (DisbursementVoucherDocument) dvForm
745:                        .getDocument();
746:
747:                String fullParameter = (String) request
748:                        .getAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE);
749:                String boClassName = StringUtils.substringBetween(
750:                        fullParameter,
751:                        KFSConstants.METHOD_TO_CALL_BOPARM_LEFT_DEL,
752:                        KFSConstants.METHOD_TO_CALL_BOPARM_RIGHT_DEL);
753:
754:                if (Payee.class.getName().equals(boClassName)
755:                        && document.getDvPayeeDetail().isEmployee()) {
756:                    String conversionFields = StringUtils.substringBetween(
757:                            fullParameter,
758:                            KFSConstants.METHOD_TO_CALL_PARM1_LEFT_DEL,
759:                            KFSConstants.METHOD_TO_CALL_PARM1_RIGHT_DEL);
760:
761:                    fullParameter = StringUtils.replace(fullParameter,
762:                            boClassName, UniversalUser.class.getName());
763:                    fullParameter = StringUtils
764:                            .replace(fullParameter, conversionFields,
765:                                    "personUniversalIdentifier:document.dvPayeeDetail.disbVchrPayeeIdNumber");
766:                    request.setAttribute(KFSConstants.METHOD_TO_CALL_ATTRIBUTE,
767:                            fullParameter);
768:                }
769:
770:                return super .performLookup(mapping, form, request, response);
771:            }
772:
773:            /*
774:             * Builds the wire charge message for the current fiscal year.
775:             */
776:            private String retrieveWireChargeMessage() {
777:                String message = SpringContext.getBean(
778:                        KualiConfigurationService.class).getPropertyString(
779:                        KFSKeyConstants.MESSAGE_DV_WIRE_CHARGE);
780:                WireCharge wireCharge = new WireCharge();
781:                wireCharge.setUniversityFiscalYear(SpringContext.getBean(
782:                        UniversityDateService.class).getCurrentFiscalYear());
783:
784:                wireCharge = (WireCharge) SpringContext.getBean(
785:                        BusinessObjectService.class).retrieve(wireCharge);
786:                Object[] args = { wireCharge.getDomesticChargeAmt(),
787:                        wireCharge.getForeignChargeAmt() };
788:
789:                return MessageFormat.format(message, args);
790:            }
791:
792:        }
ww_w__.___j_a__v__a_2__s.c_o_m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.