KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > acct > DocLine_Invoice


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 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-2001 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.acct;
15
16 import java.sql.*;
17 import java.math.*;
18
19 import org.compiere.util.Env;
20 import org.compiere.model.*;
21
22 /**
23  * Invoice Document Line
24  *
25  * @author Jorg Janke
26  * @version $Id: DocLine_Invoice.java,v 1.8 2003/09/07 06:14:41 jjanke Exp $
27  */

28 public class DocLine_Invoice extends DocLine
29 {
30     /**
31      * Constructor
32      * @param DocumentType document type
33      * @param TrxHeader_ID trx header
34      * @param TrxLine_ID trx line
35      */

36     public DocLine_Invoice (String JavaDoc DocumentType, int TrxHeader_ID, int TrxLine_ID)
37     {
38         super(DocumentType, TrxHeader_ID, TrxLine_ID);
39     } // DocLine_Invoice
40

41     /** Net Line Amt */
42     private BigDecimal m_LineNetAmt = null;
43     /** List Amount */
44     private BigDecimal m_ListAmt = Env.ZERO;
45     /** Discount Amount */
46     private BigDecimal m_DiscountAmt = Env.ZERO;
47
48     /**
49      * Set Product Amounts
50      * @param LineNetAmt Line Net Amt
51      * @param PriceList Price List
52      * @param Qty Qty
53      */

54     public void setAmount (BigDecimal LineNetAmt, BigDecimal PriceList, BigDecimal Qty)
55     {
56         m_LineNetAmt = LineNetAmt == null ? Env.ZERO : LineNetAmt;
57
58         if (PriceList != null && Qty != null)
59             m_ListAmt = PriceList.multiply(Qty);
60         if (m_ListAmt.equals(Env.ZERO))
61             m_ListAmt = m_LineNetAmt;
62         m_DiscountAmt = m_ListAmt.subtract(LineNetAmt);
63         //
64
setAmount (m_ListAmt, m_DiscountAmt);
65     // Log.trace(this,Log.l6_Database, "DocLine_Invoice.setAmount",
66
// "LineNet=" + m_LineNetAmt + ", List=" + m_ListAmt + ", Discount=" + m_DiscountAmt
67
// + " => Amount=" + getAmount());
68
} // setAmounts
69

70     /**
71      * Line Discount
72      * @return discount amount
73      */

74     public BigDecimal getDiscount()
75     {
76         return m_DiscountAmt;
77     } // getDiscount
78

79     /**
80      * Line List Amount
81      * @return list amount
82      */

83     public BigDecimal getListAmount()
84     {
85         return m_ListAmt;
86     } // getListAmount
87

88     /*************************************************************************/
89
90     /**
91      * Line Account from Product (or Charge).
92      *
93      * @param AcctType see ProoductInfo.ACCTTYPE_* (0..3)
94      * @param as Accounting schema
95      * @return Requested Product Account
96      */

97     public Account getAccount (int AcctType, AcctSchema as)
98     {
99         // Charge Account
100
if (getM_Product_ID() == 0 && getC_Charge_ID() != 0)
101         {
102             BigDecimal amt = new BigDecimal (-1); // Revenue (-)
103
if (p_DocumentType.indexOf("AP") != -1)
104                 amt = new BigDecimal (+1); // Expense (+)
105
Account acct = getChargeAccount(as, amt);
106             if (acct != null)
107                 return acct;
108         }
109         // Product Account
110
return p_productInfo.getAccount (AcctType, as);
111     } // getAccount
112

113
114     /**
115      * Get Document Org
116      * @return if
117      *
118     public int getAD_Org_ID()
119     {
120         return super.getAD_Org_ID();
121     } // getAD_Org_ID
122
123     /**/

124 } // DocLine_Invoice
125
Popular Tags