📄 mcurrency.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution. The Initial
* Developer of the Original Code is Jorg Janke. Portions created by Jorg Janke
* are Copyright (C) 1999-2005 Jorg Janke.
* All parts are Copyright (C) 1999-2005 ComPiere, Inc. All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.model;
import java.util.*;
import org.compiere.util.*;
/**
* Currency Model.
*
* @author Jorg Janke
* @version $Id: MCurrency.java,v 1.8 2005/10/08 02:03:34 jjanke Exp $
*/
public class MCurrency extends X_C_Currency
{
/**
* Currency Constructor
* @param ctx context
* @param C_Currency_ID id
*/
public MCurrency (Properties ctx, int C_Currency_ID, String trxName)
{
super (ctx, C_Currency_ID, trxName);
if (C_Currency_ID == 0)
{
setIsEMUMember (false);
setIsEuro (false);
setStdPrecision (2);
setCostingPrecision (4);
}
} // MCurrency
/**
* Currency Constructor
* @param ctx context
* @param ISO_Code ISO
* @param Description Name
* @param CurSymbol symbol
* @param StdPrecision prec
* @param CostingPrecision prec
*/
public MCurrency (Properties ctx, String ISO_Code,
String Description, String CurSymbol, int StdPrecision, int CostingPrecision, String trxName)
{
super(ctx, 0, trxName);
setISO_Code(ISO_Code);
setDescription(Description);
setCurSymbol(CurSymbol);
setStdPrecision (StdPrecision);
setCostingPrecision (CostingPrecision);
setIsEMUMember (false);
setIsEuro (false);
} // MCurrency
/** Store System Currencies **/
private static CCache<Integer,MCurrency> s_currencies = new CCache<Integer,MCurrency>("C_Currency", 50);
/**
* Get Currency
* @param ctx Context
* @param C_Currency_ID currency
* @return ISO Code
*/
public static MCurrency get (Properties ctx, int C_Currency_ID)
{
// Try Cache
Integer key = new Integer(C_Currency_ID);
MCurrency retValue = (MCurrency)s_currencies.get(key);
if (retValue != null)
return retValue;
// Create it
retValue = new MCurrency(ctx, C_Currency_ID, null);
// Save in System
if (retValue.getAD_Client_ID() == 0)
s_currencies.put(key, retValue);
return retValue;
} // get
/**
* Get Currency Iso Code.
* @param ctx Context
* @param C_Currency_ID currency
* @return ISO Code
*/
public static String getISO_Code (Properties ctx, int C_Currency_ID)
{
String contextKey = "C_Currency_" + C_Currency_ID;
String retValue = ctx.getProperty(contextKey);
if (retValue != null)
return retValue;
// Create it
MCurrency c = get(ctx, C_Currency_ID);
retValue = c.getISO_Code();
ctx.setProperty(contextKey, retValue);
return retValue;
} // getISO
/**
* Get Standard Precision.
* @param ctx Context
* @param C_Currency_ID currency
* @return Standard Precision
*/
public static int getStdPrecision (Properties ctx, int C_Currency_ID)
{
MCurrency c = get(ctx, C_Currency_ID);
return c.getStdPrecision();
} // getStdPrecision
/**
* String Representation
* @return info
*/
public String toString()
{
return "MCurrency[" + getC_Currency_ID()
+ "-" + getISO_Code() + "-" + getCurSymbol()
+ "," + getDescription()
+ ",Precision=" + getStdPrecision() + "/" + getCostingPrecision();
} // toString
/*************************************************************************/
/**
* Load/link Currencies
* @param args args
*
public static void main (String[] args)
{
System.out.println("Currency");
Compiere.startupClient();
// Loop through
for (int i = 0; i < s_table.length; i++)
{
/**
System.out.println(s_table[i][I_Currency] + " - " + s_table[i][I_Name]);
int prec = Integer.parseInt(s_table[i][I_Precision]);
MCurrency cur = new MCurrency(Env.getCtx(), s_table[i][I_Currency],
s_table[i][I_Name], s_table[i][I_Symbol], prec, prec+2);
cur.save();
System.out.println(cur);
**
String ISO = s_table[i][I_Currency];
String Country = s_table[i][I_Country];
String sql = "UPDATE C_Country SET C_Currency_ID="
+ "(SELECT C_Currency_ID FROM C_Currency WHERE ISO_Code='" + ISO + "') "
+ "WHERE CountryCode='" + Country + "'";
int no = DB.executeUpdate(sql);
System.out.println(ISO + " - " + Country + " - " + no);
System.out.println("");
}
} // main
static int I_Country = 0;
static int I_Currency = 1;
static int I_Precision = 2;
static int I_Symbol = 3;
static int I_DecimalPoint = 4;
static int I_FormatIndex = 5;
static int I_Name = 6;
static String[][] s_table = new String[][] {
new String[]{"US","USD","2","$",".","0", "US Dollar"},
new String[]{"AR","ARS","2","$",",","0", "Argentine Peso"},
new String[]{"AS","USD","2","$",".","0","US Dollar"},
new String[]{"CC","AUD","2","$",".","0","Australian Dollar"},
new String[]{"CK","NZD","2","$",".","0","New Zealand Dollar"},
new String[]{"CX","AUD","2","$",".","0","Australian Dollar"},
new String[]{"EC","USD","2","$",".","0","US Dollar"},
new String[]{"FM","USD","2","$",".","0","US Dollar"},
new String[]{"GU","USD","2","$",".","0","US Dollar"},
new String[]{"KI","AUD","2","$",".","0","Australian Dollar"},
new String[]{"LR","LRD","2","$",".","0","Liberian Dollar"},
new String[]{"MH","USD","2","$",".","0","US Dollar"},
new String[]{"MP","USD","2","$",".","0","US Dollar"},
new String[]{"MX","MXN","2","$",".","0","Mexican Peso"},
new String[]{"NF","AUD","2","$",".","0","Australian Dollar"},
new String[]{"NR","AUD","2","$",".","0","Australian Dollar"},
new String[]{"NU","NZD","2","$",".","0","New Zealand Dollar"},
new String[]{"NZ","NZD","2","$",".","0","New Zealand Dollar"},
new String[]{"PR","USD","2","$",".","0","US Dollar"},
new String[]{"PW","USD","2","$",".","0","US Dollar"},
new String[]{"TC","USD","2","$",".","0","US Dollar"},
new String[]{"TK","NZD","2","$",".","0","New Zealand Dollar"},
new String[]{"TV","AUD","2","$",".","0","Australian Dollar"},
new String[]{"VG","USD","2","$",".","0","US Dollar"},
new String[]{"VI","USD","2","$",".","0","US Dollar"},
new String[]{"UY","UYU","2","$U",",","2","Peso Uruguayo"},
new String[]{"AM","AMD","2","",".","0","Armenian Dram"},
new String[]{"AO","AOA","2","",".","0","Kwanza"},
new String[]{"AZ","AZM","2","",".","0","Azerbaijanian Manat"},
new String[]{"BO","BOB","2","",".","0","Boliviano"},
new String[]{"CD","CDF","2","",".","0","Franc Congolais"},
new String[]{"CZ","CZK","2","",",","3","Czech Koruna"},
new String[]{"GE","GEL","2","",".","0","Lari"},
new String[]{"IR","IRR","2","",".","2","Iranian Rial"},
new String[]{"LT","LTL","2","",",","3","Lithuanian Litus"},
new String[]{"MD","MDL","2","",".","0","Moldovan Leu"},
new String[]{"PH","PHP","2","",".","0","Philippine Peso"},
new String[]{"PL","PLN","2","",",","3","Zloty"},
new String[]{"RU","RUR","2","",",","1","Russian Ruble"},
new String[]{"SD","SDD","2","",".","0","Sudanese Dinar"},
new String[]{"TJ","TJS","2","",".","0","Somoni"},
new String[]{"TM","TMM","2","",".","0","Manat"},
new String[]{"TP","TPE","0","",".","0","Timor Escudo"},
new String[]{"UA","UAH","2","",",","3","Hryvnia"},
new String[]{"UZ","UZS","2","",".","0","Uzbekistan Sum"},
new String[]{"GB","GBP","2","
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -