KickJava   Java API By Example, From Geeks To Geeks.

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


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 javax.servlet.*;
20 import org.apache.log4j.Logger ;
21 // imports for transactions
22
import org.openbravo.database.ConnectionProvider;
23
24
25
26 public class DocTax {
27   static Logger log4jDocTax = Logger.getLogger(DocTax.class);
28   
29   public DocTax (String JavaDoc C_Tax_ID, String JavaDoc name, String JavaDoc rate, String JavaDoc taxBaseAmt, String JavaDoc amount){
30     m_C_Tax_ID = C_Tax_ID;
31     m_name = name;
32     m_rate = rate;
33     m_amount = amount;
34   } // DocTax
35

36   /** Tax ID */
37   public String JavaDoc m_C_Tax_ID = "";
38   /** Amount */
39   public String JavaDoc m_amount = "";
40   /** Tax Rate */
41   public String JavaDoc m_rate = "";
42   /** Name */
43   public String JavaDoc m_name = "";
44
45   /** Tax Due Acct */
46   public static final int ACCTTYPE_TaxDue = 0;
47   /** Tax Liability */
48   public static final int ACCTTYPE_TaxLiability = 1;
49   /** Tax Credit */
50   public static final int ACCTTYPE_TaxCredit = 2;
51   /** Tax Receivables */
52   public static final int ACCTTYPE_TaxReceivables = 3;
53   /** Tax Expense */
54   public static final int ACCTTYPE_TaxExpense = 4;
55
56
57     /**
58    * Get Account
59    * @param AcctType see ACCTTYPE_*
60    * @param as account schema
61    * @return Account
62    */

63   public Account getAccount (int AcctType, AcctSchema as,ConnectionProvider conn){
64     if (AcctType < 0 || AcctType > 4)
65       return null;
66     String JavaDoc validCombination_ID = "";
67     DocTaxData [] data = null;
68     Account acc = null;
69     try{
70       data = DocTaxData.select(conn,m_C_Tax_ID,as.m_C_AcctSchema_ID);
71       if (data.length > 0){
72         switch (AcctType){
73         case 0: validCombination_ID = data[0].tDueAcct;
74             break;
75         case 1: validCombination_ID = data[0].tLiabilityAcct;
76             break;
77         case 2: validCombination_ID = data[0].tCreditAcct;
78             break;
79         case 3: validCombination_ID = data[0].tReceivablesAcct;
80             break;
81         case 4: validCombination_ID = data[0].tExpenseAcct;
82             break;
83         }
84       }
85       if (validCombination_ID.equals(""))
86         return null;
87       acc = Account.getAccount(conn,validCombination_ID);
88     }catch(ServletException e){
89       log4jDocTax.warn(e);
90     }
91     return acc;
92   } // getAccount
93

94   /**
95    * Get Amount
96    * @return gross amount
97    */

98   public String JavaDoc getAmount(){
99     return m_amount;
100   }
101
102 }
103
Popular Tags