KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.*;
18 import java.sql.*;
19
20 import org.compiere.model.*;
21 import org.compiere.util.*;
22
23 /**
24  * Price Project Line.
25  *
26  * @author Jorg Janke
27  * @version $Id: ProjectLinePricing.java,v 1.2 2003/10/11 05:20:32 jjanke Exp $
28  */

29 public class ProjectLinePricing extends SvrProcess
30 {
31     /** Project Line from Record */
32     private int m_C_ProjectLine_ID = 0;
33
34     /**
35      * Prepare - e.g., get Parameters.
36      */

37     protected void prepare()
38     {
39         ProcessInfoParameter[] para = getParameter();
40         for (int i = 0; i < para.length; i++)
41         {
42             String JavaDoc name = para[i].getParameterName();
43             if (para[i].getParameter() == null)
44                 ;
45             else
46                 log.error("prepare - Unknown Parameter: " + name);
47         }
48         m_C_ProjectLine_ID = getRecord_ID();
49     } // prepare
50

51     /**
52      * Perrform process.
53      * @return Message (clear text)
54      * @throws Exception if not successful
55      */

56     protected String JavaDoc doIt() throws Exception JavaDoc
57     {
58         if (m_C_ProjectLine_ID == 0)
59             throw new IllegalArgumentException JavaDoc("No Project Line");
60         MProjectLine projectLine = new MProjectLine (getCtx(), m_C_ProjectLine_ID);
61         log.info("doIt - " + projectLine);
62         if (projectLine.getM_Product_ID() == 0)
63             throw new IllegalArgumentException JavaDoc("No Product");
64         //
65
MProject project = new MProject (getCtx(), projectLine.getC_Project_ID());
66         if (project.getM_PriceList_ID() == 0)
67             throw new IllegalArgumentException JavaDoc("No PriceList");
68         //
69
MProductPriceVO pp = MProductPriceVO.getBOMPricesPL
70             (projectLine.getM_Product_ID(), project.getM_PriceList_ID(), project.getDateContract());
71         if (pp == null)
72             throw new Exception JavaDoc ("No Price found");
73         //
74
projectLine.setPlannedPrice(pp.PriceStd);
75         projectLine.setPlannedMarginAmt(pp.PriceStd.subtract(pp.PriceLimit));
76         projectLine.save();
77         //
78
String JavaDoc retValue = Msg.getElement(getCtx(), "PriceList") + pp.PriceList + " - "
79             + Msg.getElement(getCtx(), "PriceStd") + pp.PriceStd + " - "
80             + Msg.getElement(getCtx(), "PriceLimit") + pp.PriceLimit;
81         return retValue;
82     } // doIt
83

84 } // ProjectLinePricing
85
Popular Tags