View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.module.purap.document.web.struts;
20  
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpServletResponse;
23  
24  import org.apache.struts.action.ActionForm;
25  import org.apache.struts.action.ActionForward;
26  import org.apache.struts.action.ActionMapping;
27  import org.kuali.kfs.module.purap.document.ElectronicInvoiceRejectDocument;
28  import org.kuali.kfs.sys.KFSConstants;
29  import org.kuali.kfs.sys.document.web.struts.FinancialSystemTransactionalDocumentActionBase;
30  import org.kuali.rice.krad.bo.Note;
31  import org.kuali.rice.krad.util.GlobalVariables;
32  
33  /**
34   * Struts Action for Electronic invoice document.
35   */
36  public class ElectronicInvoiceRejectAction extends FinancialSystemTransactionalDocumentActionBase {
37  
38      public ActionForward startResearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
39  
40          ElectronicInvoiceRejectForm electronicInvoiceRejectForm = (ElectronicInvoiceRejectForm) form;
41          ElectronicInvoiceRejectDocument eirDocument = (ElectronicInvoiceRejectDocument) electronicInvoiceRejectForm.getDocument();
42          eirDocument.setInvoiceResearchIndicator(true);
43  
44          Note noteObj = getDocumentService().createNoteFromDocument(eirDocument, "Research started by: " + GlobalVariables.getUserSession().getPerson().getName());
45          eirDocument.addNote(noteObj);
46          getNoteService().save(noteObj);
47          getDocumentService().saveDocument(eirDocument);
48  
49          return mapping.findForward(KFSConstants.MAPPING_BASIC);
50      }
51  
52      public ActionForward completeResearch(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
53  
54          ElectronicInvoiceRejectForm electronicInvoiceRejectForm = (ElectronicInvoiceRejectForm) form;
55          ElectronicInvoiceRejectDocument eirDocument = (ElectronicInvoiceRejectDocument) electronicInvoiceRejectForm.getDocument();
56          eirDocument.setInvoiceResearchIndicator(false);
57  
58          Note noteObj = getDocumentService().createNoteFromDocument(eirDocument, "Research completed by: " + GlobalVariables.getUserSession().getPerson().getName());
59          eirDocument.addNote(noteObj);
60          getNoteService().save(noteObj);
61          getDocumentService().saveDocument(eirDocument);
62  
63          return mapping.findForward(KFSConstants.MAPPING_BASIC);
64  
65      }
66  
67  }
68