KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > process > CopyFromInvoice


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Smart Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.process;
15
16 import java.math.*;
17
18 import org.compiere.model.*;
19
20 /**
21  * Copy Invoice Lines
22  *
23  * @author Jorg Janke
24  * @version $Id: CopyFromInvoice.java,v 1.2 2003/08/11 05:55:38 jjanke Exp $
25  */

26 public class CopyFromInvoice extends SvrProcess
27 {
28     private int m_C_Invoice_ID = 0;
29
30     /**
31      * Prepare - e.g., get Parameters.
32      */

33     protected void prepare()
34     {
35         ProcessInfoParameter[] para = getParameter();
36         for (int i = 0; i < para.length; i++)
37         {
38             String JavaDoc name = para[i].getParameterName();
39             if (para[i].getParameter() == null)
40                 ;
41             else if (name.equals("C_Invoice_ID"))
42                 m_C_Invoice_ID = ((BigDecimal)para[i].getParameter()).intValue();
43             else
44                 log.error("prepare - Unknown Parameter: " + name);
45         }
46     } // prepare
47

48     /**
49      * Perrform process.
50      * @return Message (clear text)
51      * @throws Exception if not successful
52      */

53     protected String JavaDoc doIt() throws Exception JavaDoc
54     {
55         int To_C_Invoice_ID = getRecord_ID();
56         log.info("doIt - From C_Invoice_ID=" + m_C_Invoice_ID + " to " + To_C_Invoice_ID);
57         if (To_C_Invoice_ID == 0)
58             throw new IllegalArgumentException JavaDoc("Target C_Invoice_ID == 0");
59         if (m_C_Invoice_ID == 0)
60             throw new IllegalArgumentException JavaDoc("Source C_Invoice_ID == 0");
61         MInvoice from = new MInvoice (getCtx(), m_C_Invoice_ID);
62         MInvoice to = new MInvoice (getCtx(), To_C_Invoice_ID);
63         //
64
int no = to.copyLinesFrom (from);
65         //
66
return "@Copied@=" + no;
67     } // doIt
68

69 } // CopyFromInvoice
70
Popular Tags