KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > tools > Currency


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

14 package org.compiere.tools;
15
16 import java.util.*;
17
18 import org.compiere.model.*;
19 import org.compiere.util.*;
20
21
22 /**
23  * Create Currencies
24  *
25  * @author Jorg Janke
26  * @version $Id: Currency.java,v 1.3 2002/08/12 05:01:29 jjanke Exp $
27  */

28 public class Currency extends PO
29 {
30     /**
31      * Currency
32      * @param ctx context
33      * @param C_Currency_ID currency
34      */

35     public Currency (Properties ctx, int C_Currency_ID)
36     {
37         super (ctx, C_Currency_ID);
38         // Default Setting
39
if (C_Currency_ID == 0)
40         {
41             setValue("StdPrecision", new Integer JavaDoc(2));
42             setValue("CostingPrecision", new Integer JavaDoc(4));
43             setValue("IsEuro", new Boolean JavaDoc(false));
44             setValue("IsEMUMember", new Boolean JavaDoc(false));
45         }
46     } // Currency
47

48     /**
49      * Initialize and return PO_Info
50      * @param ctx context
51      * @return POInfo
52      */

53     protected POInfo initPO (Properties ctx)
54     {
55         int AD_Table_ID = 141;
56         POInfo poi = POInfo.getPOInfo (ctx, AD_Table_ID);
57         return poi;
58     } // initPO
59

60     /*************************************************************************/
61
62     /**
63      * Create Currency
64      * @param ISO_Code iso code
65      * @param CurSymbol symbol
66      * @param Description descriprion
67      * @return currency
68      */

69     public static Currency create (String JavaDoc ISO_Code, String JavaDoc CurSymbol, String JavaDoc Description)
70     {
71         Currency cur = new Currency(Env.getCtx(), 0);
72         cur.setValue("ISO_Code", ISO_Code);
73         cur.setValue("CurSymbol", CurSymbol);
74         cur.setValue("Description", Description);
75         cur.save();
76         return cur;
77     } // create
78

79     /**
80      * Test.
81      * http://www.unece.org/cefact/locode/service/main.htm
82      * @param args args
83      */

84     public static void main(String JavaDoc[] args)
85     {
86         Locale[] locales = Locale.getAvailableLocales();
87         for (int i = 0; i < locales.length; i++)
88         {
89             System.out.println(locales[i] + " - " + locales[i].getDisplayCountry());
90             try
91             {
92                 java.util.Currency JavaDoc c = java.util.Currency.getInstance(locales[i]);
93                 System.out.println(" " + c + " " + c.getDefaultFractionDigits() + " " + c.getSymbol());
94             }
95             catch (Exception JavaDoc ex)
96             {
97             }
98         }
99
100
101
102     // org.compiere.Compiere.startup(false);
103
//
104

105     } // main
106
} // Currency
107
Popular Tags