KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > wstore > WebBasketLine


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.wstore;
15
16 import java.util.*;
17 import java.sql.*;
18 import java.math.*;
19
20 import org.apache.log4j.Logger;
21
22 import org.compiere.model.*;
23 import org.compiere.util.DB;
24 import org.compiere.util.Env;
25 import org.compiere.www.*;
26
27 /**
28  * Web Basket Line
29  *
30  * @author Jorg Janke
31  * @version $Id: WebBasketLine.java,v 1.1 2003/04/09 05:06:43 jjanke Exp $
32  */

33 public class WebBasketLine
34 {
35     /**
36      * Web Basket Line
37      * @param M_Product_ID product
38      * @param Name Name
39      * @param Qty Qty
40      * @param Price Price
41      */

42     public WebBasketLine (int M_Product_ID, String JavaDoc Name, BigDecimal Qty, BigDecimal Price)
43     {
44         setM_Product_ID(M_Product_ID);
45         setName(Name);
46         setQuantity(Qty);
47         setPrice(Price);
48     } // WebBasketLine
49

50     private int m_line;
51     private int m_M_Product_ID;
52     private String JavaDoc m_Name;
53     private BigDecimal m_Price;
54     private BigDecimal m_Quantity;
55     private BigDecimal m_Total;
56
57     public static BigDecimal ONE = new BigDecimal(1);
58
59     /**
60      * String Representation
61      * @return info
62      */

63     public String JavaDoc toString()
64     {
65         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("WebBasketLine[");
66         sb.append(m_line).append("-M_Product_ID=") .append(m_M_Product_ID)
67             .append(",Qty=").append(m_Quantity).append(",Price=").append(m_Price)
68             .append(",Total=").append(m_Total)
69             .append("]");
70         return sb.toString();
71     } // toString
72

73
74     public int getLine()
75     {
76         return m_line;
77     }
78     public void setLine (int line)
79     {
80         m_line = line;
81     }
82
83     public int getM_Product_ID()
84     {
85         return m_M_Product_ID;
86     }
87     public void setM_Product_ID (int M_Product_ID)
88     {
89         m_M_Product_ID = M_Product_ID;
90     }
91
92     public String JavaDoc getName()
93     {
94         if (m_Name == null)
95             return "-";
96         return m_Name;
97     }
98     public void setName(String JavaDoc name)
99     {
100         m_Name = name;
101     }
102
103     public BigDecimal getPrice()
104     {
105         if (m_Price == null)
106             return ONE;
107         return m_Price;
108     }
109     public void setPrice(BigDecimal price)
110     {
111         m_Price = price;
112         m_Total = null;
113     }
114
115     public BigDecimal getQuantity()
116     {
117         if (m_Quantity == null)
118             return ONE;
119         return m_Quantity;
120     }
121     public void setQuantity(BigDecimal quantity)
122     {
123         m_Quantity = quantity;
124         m_Total = null;
125     }
126
127     public BigDecimal getTotal()
128     {
129         if (m_Total == null)
130             m_Total = getQuantity().multiply(getPrice());
131         return m_Total;
132     }
133
134 } // WebBasketLine
135
Popular Tags