KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openbravo > erpCommon > ad_forms > DocLine_Invoice


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

17 package org.openbravo.erpCommon.ad_forms;
18
19 import java.math.*;
20 import org.apache.log4j.Logger ;
21 // imports for transactions
22
import org.openbravo.database.ConnectionProvider;
23
24
25
26 public class DocLine_Invoice extends DocLine {
27   static Logger log4jDocLine_Invoice = Logger.getLogger(DocLine_Invoice.class);
28
29   public DocLine_Invoice (String JavaDoc DocumentType, String JavaDoc TrxHeader_ID, String JavaDoc TrxLine_ID){
30     super(DocumentType, TrxHeader_ID, TrxLine_ID);
31   }
32
33
34   /** Net Line Amt */
35   private String JavaDoc m_LineNetAmt = "0";
36   /** List Amount */
37   private String JavaDoc m_ListAmt = "0";
38   /** Discount Amount */
39   private String JavaDoc m_DiscountAmt = "0";
40
41
42
43   public void setAmount (String JavaDoc LineNetAmt, String JavaDoc PriceList, String JavaDoc Qty){
44     BigDecimal ZERO = new BigDecimal("0");
45     m_LineNetAmt = (LineNetAmt == "0")? ZERO.toString() : LineNetAmt;
46     BigDecimal b_Qty = new BigDecimal(Qty);
47     BigDecimal b_PriceList = new BigDecimal(PriceList);
48     if (PriceList != "" && Qty != "")
49       m_ListAmt = b_PriceList.multiply(b_Qty).toString();
50     if (m_ListAmt.equals(ZERO.toString()))
51       m_ListAmt = m_LineNetAmt;
52     BigDecimal b_LineNetAmt = new BigDecimal(LineNetAmt);
53     BigDecimal b_ListAmt = new BigDecimal(m_ListAmt);
54     m_DiscountAmt = b_ListAmt.subtract(b_LineNetAmt).toString();
55     //
56
setAmount (m_ListAmt, m_DiscountAmt);
57   } // setAmounts
58

59   /**
60    * Line Account from Product (or Charge).
61    *
62    * @param AcctType see ProoductInfo.ACCTTYPE_* (0..3)
63    * @param as Accounting schema
64    * @return Requested Product Account
65    */

66   public Account getAccount (String JavaDoc AcctType, AcctSchema as,ConnectionProvider conn){
67     // Charge Account
68
if (m_M_Product_ID.equals("") && !m_C_Charge_ID.equals("")){
69       BigDecimal amt = new BigDecimal (-1); // Revenue (-)
70
if (p_DocumentType.indexOf("AP") != -1)
71         amt = new BigDecimal (+1); // Expense (+)
72
Account acct = getChargeAccount(as, amt,conn);
73       if (acct != null)
74         return acct;
75     }
76     // Product Account
77
return p_productInfo.getAccount (AcctType, as,conn);
78   } // getAccount
79

80   public String JavaDoc getServletInfo() {
81     return "Servlet for the accounting";
82   } // end of getServletInfo() method
83
}
84
Popular Tags