Requested by Sureeraya Limpaibul
This commit is contained in:
parent
678a9117ff
commit
593b413282
|
@ -1,18 +1,15 @@
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
* The contents of this file are subject to the Compiere License Version 1.1
|
||||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
* ("License"); You may not use this file except in compliance with the License
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* You may obtain a copy of the License at http://www.compiere.org/license.html
|
||||||
* under the terms version 2 of the GNU General Public License as published *
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
* by the Free Software Foundation. This program is distributed in the hope *
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
* the specific language governing rights and limitations under the License.
|
||||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
* The Original Code is Compiere ERP & CRM Business Solution
|
||||||
* See the GNU General Public License for more details. *
|
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
|
||||||
* You should have received a copy of the GNU General Public License along *
|
* Portions created by Jorg Janke are Copyright (C) 1999-2005 Jorg Janke, parts
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
* Contributor(s): ______________________________________.
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
|
||||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
|
||||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.util;
|
package org.compiere.util;
|
||||||
|
|
||||||
|
@ -20,30 +17,27 @@ package org.compiere.util;
|
||||||
/**
|
/**
|
||||||
* Amount in Words for Thai
|
* Amount in Words for Thai
|
||||||
*
|
*
|
||||||
* @author Sureeraya Limpaibul - http://www.rgagnon.com/javadetails/java-0426.html
|
* @author Sureeraya Limpaibul - http://www.rgagnon.com/javadetails/java-0426.h
|
||||||
* @version $Id: AmtInWords_TH.java,v 1.3 2006/07/30 00:54:35 jjanke Exp $
|
tml
|
||||||
|
* @version $Id: AmtInWords_TH.java,v 1.2 2005/04/19 04:43:31 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class AmtInWords_TH implements AmtInWords
|
public class AmtInWords_TH implements AmtInWords
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AmtInWords_TH
|
* AmtInWords_TH
|
||||||
*
|
*
|
||||||
* 0.23 = <EFBFBD>ٹ<EFBFBD><EFBFBD> 23/100
|
* 0.23 = \u0e28\u0e39\u0e19\u0e22\u0e4c 23/100
|
||||||
* 1.23 = ˹<EFBFBD>觺ҷ 23/100
|
* 1.23 = \u0e2b\u0e19\u0e36\u0e48\u0e07\u0e1a\u0e32\u0e17 23/100
|
||||||
* 11.45 = <EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 45/100
|
* 11.45 = \u0e2a\u0e34\u0e1a\u0e40\u0e2d\u0e47\u0e14\u0e1a\u0e32\u0e17 45/100
|
||||||
* 121.45 = ˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 45/100
|
* 121.45 = \u0e2b\u0e19\u0e36\u0e48\u0e07\u0e23\u0e49\u0e2d\u0e22\u0e22\u0e35\u0e48\u0e2a\u0e34\u0e1a\u0e40\u0e2d\u0e47\u0e14\u0e1a\u0e32\u0e17 45/100
|
||||||
* 1231.56 = ˹<EFBFBD>觾ѹ<EFBFBD>ͧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 56/100
|
* 1231.56 = \u0e2b\u0e19\u0e36\u0e48\u0e07\u0e1e\u0e31\u0e19\u0e2a\u0e2d\u0e07\u0e23\u0e49\u0e2d\u0e22\u0e2a\u0e32\u0e21\u0e2a\u0e34\u0e1a\u0e40\u0e2d\u0e47\u0e14\u0e1a\u0e32\u0e17 56/100
|
||||||
* 12341.78 = ˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͧ<EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 78/100
|
* 12341.78 = \u0e2b\u0e19\u0e36\u0e48\u0e07\u0e2b\u0e21\u0e37\u0e48\u0e19\u0e2a\u0e2d\u0e07\u0e1e\u0e31\u0e19\u0e2a\u0e32\u0e21\u0e23\u0e49\u0e2d\u0e22\u0e2a\u0e35\u0e48\u0e2a\u0e34\u0e1a\u0e40\u0e2d\u0e47\u0e14\u0e1a\u0e32\u0e17 78/100
|
||||||
* 123451.89 = ˹<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ͧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>~ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 89/100
|
* 123451.89 = \u0e2b\u0e19\u0e36\u0e48\u0e07\u0e41\u0e2a\u0e19\u0e2a\u0e2d\u0e07\u0e2b\u0e21\u0e37\u0e48\u0e19\u0e2a\u0e32\u0e21\u0e1e\u0e31\u0e19\u0e2a\u0e35\u0e48\u0e23\u0e49\u0e2d\u0e22\u0e2b\u0e49\u0e32\u0e2a\u0e34\u0e1a\u0e40\u0e2d\u0e47\u0e14\u0e1a\u0e32\u0e17 89/100
|
||||||
* 12234571.90 = <EFBFBD>Ժ<EFBFBD>ͧ<EFBFBD><EFBFBD>ҹ <EFBFBD>ͧ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 90/100
|
* 12234571.90 = \u0e2a\u0e34\u0e1a\u0e2a\u0e2d\u0e07\u0e25\u0e49\u0e32\u0e19 \u0e2a\u0e2d\u0e07\u0e41\u0e2a\u0e19\u0e2a\u0e32\u0e21\u0e2b\u0e21\u0e37\u0e48\u0e19\u0e2a\u0e35\u0e48\u0e1e\u0e31\u0e19\u0e2b\u0e49\u0e32\u0e23\u0e49\u0e2d\u0e22\u0e40\u0e08\u0e47\u0e14\u0e2a\u0e34\u0e1a\u0e40\u0e2d\u0e47\u0e14\u0e1a\u0e32\u0e17 90/100
|
||||||
* 123234571.90 = ˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹ <EFBFBD>ͧ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 90/100
|
* 123234571.90 = \u0e2b\u0e19\u0e36\u0e48\u0e07\u0e23\u0e49\u0e2d\u0e22\u0e22\u0e35\u0e48\u0e2a\u0e34\u0e1a\u0e2a\u0e32\u0e21\u0e25\u0e49\u0e32\u0e19 \u0e2a\u0e2d\u0e07\u0e41\u0e2a\u0e19\u0e2a\u0e32\u0e21\u0e2b\u0e21\u0e37\u0e48\u0e19\u0e2a\u0e35\u0e48\u0e1e\u0e31\u0e19\u0e2b\u0e49\u0e32\u0e23\u0e49\u0e2d\u0e22\u0e40\u0e08\u0e47\u0e14\u0e2a\u0e34\u0e1a\u0e40\u0e2d\u0e47\u0e14\u0e1a\u0e32\u0e17 90/100
|
||||||
* 1987234571.90 = ˹<EFBFBD>觾ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ỵ<EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹ <EFBFBD>ͧ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 90/100
|
* 1987234571.90 = \u0e2b\u0e19\u0e36\u0e48\u0e07\u0e1e\u0e31\u0e19\u0e40\u0e01\u0e49\u0e32\u0e23\u0e49\u0e2d\u0e22\u0e41\u0e1b\u0e14\u0e2a\u0e34\u0e1a\u0e40\u0e08\u0e47\u0e14\u0e25\u0e49\u0e32\u0e19 \u0e2a\u0e2d\u0e07\u0e41\u0e2a\u0e19\u0e2a\u0e32\u0e21\u0e2b\u0e21\u0e37\u0e48\u0e19\u0e2a\u0e35\u0e48\u0e1e\u0e31\u0e19\u0e2b\u0e49\u0e32\u0e23\u0e49\u0e2d\u0e22\u0e40\u0e08\u0e47\u0e14\u0e2a\u0e34\u0e1a\u0e40\u0e2d\u0e47\u0e14\u0e1a\u0e32\u0e17 90/100
|
||||||
* 11123234571.90 = ˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˹<EFBFBD>觾ѹ˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹ <EFBFBD>ͧ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 90/100
|
* 0.00 = \u0e28\u0e39\u0e19\u0e22\u0e4c 00/100
|
||||||
* 123123234571.90 = ˹<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ͧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>~ѹ˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹ <EFBFBD>ͧ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 90/100
|
|
||||||
* 2123123234571.90 = <EFBFBD>ͧ<EFBFBD><EFBFBD>ҹ ˹<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ͧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>~ѹ˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹ <EFBFBD>ͧ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 90/100
|
|
||||||
* 23,123,123,234,571.90 = <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹ ˹<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ͧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>~ѹ˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹ <EFBFBD>ͧ<EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ժ<EFBFBD><EFBFBD>紺ҷ 90/100
|
|
||||||
* 100,000,000,000,000.90 = ˹<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҹ<EFBFBD><EFBFBD>ҹ <EFBFBD>ҷ 90/100
|
|
||||||
* 0.00 = <EFBFBD>ٹ<EFBFBD><EFBFBD> 00/100
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public AmtInWords_TH ()
|
public AmtInWords_TH ()
|
||||||
|
@ -146,18 +140,20 @@ public class AmtInWords_TH implements AmtInWords
|
||||||
/**
|
/**
|
||||||
* Convert Less Than One Thousand
|
* Convert Less Than One Thousand
|
||||||
* @param number
|
* @param number
|
||||||
* @return amt
|
* @return
|
||||||
*/
|
*/
|
||||||
private String convertLessThanOneMillion (int number)
|
private String convertLessThanOneMillion (int number)
|
||||||
{
|
{
|
||||||
String soFar;
|
String soFar = new String();
|
||||||
// Esta dentro de los 1os. diecinueve?? ISCAP
|
// Esta dentro de los 1os. diecinueve?? ISCAP
|
||||||
if (number % 100 < 20)
|
System.out.println("[convertLessThanOneMillion] number = " + number);
|
||||||
|
/* if (number % 100 < 20)
|
||||||
{
|
{
|
||||||
soFar = numNames[(number % 100)];
|
soFar = numNames[(number % 100)];
|
||||||
number /= 100;
|
number /= 100;
|
||||||
}
|
}
|
||||||
else
|
*/
|
||||||
|
if (number != 0)
|
||||||
{
|
{
|
||||||
soFar = numNames[number % 10];
|
soFar = numNames[number % 10];
|
||||||
if (number != 1 && soFar.equals("\u0e2b\u0e19\u0e36\u0e48\u0e07")) {
|
if (number != 1 && soFar.equals("\u0e2b\u0e19\u0e36\u0e48\u0e07")) {
|
||||||
|
@ -181,18 +177,18 @@ public class AmtInWords_TH implements AmtInWords
|
||||||
number /= 10;
|
number /= 10;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (number == 0)
|
if (number == 0) {
|
||||||
return soFar;
|
return soFar;
|
||||||
|
}
|
||||||
return numNames[number] + "\u0e23\u0e49\u0e2d\u0e22\u0e25\u0e49\u0e32\u0e19" + soFar;
|
return numNames[number] + "\u0e23\u0e49\u0e2d\u0e22\u0e25\u0e49\u0e32\u0e19" + soFar;
|
||||||
} // convertLessThanOneThousand
|
} // convertLessThanOneThousand
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert
|
* Convert
|
||||||
* @param number
|
* @param number
|
||||||
* @return amt
|
* @return
|
||||||
*/
|
*/
|
||||||
private String convert (double number)
|
private String convert (int number)
|
||||||
{
|
{
|
||||||
/* special case */
|
/* special case */
|
||||||
if (number == 0)
|
if (number == 0)
|
||||||
|
@ -200,7 +196,8 @@ public class AmtInWords_TH implements AmtInWords
|
||||||
return "\u0e28\u0e39\u0e19\u0e22\u0e4c";
|
return "\u0e28\u0e39\u0e19\u0e22\u0e4c";
|
||||||
}
|
}
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
String subfix = "\u0e1a\u0e32\u0e17";
|
// \u0e1a\u0e32\u0e17
|
||||||
|
// String subfix = "\u0e1a\u0e32\u0e17";
|
||||||
|
|
||||||
if (number < 0)
|
if (number < 0)
|
||||||
{
|
{
|
||||||
|
@ -224,15 +221,16 @@ public class AmtInWords_TH implements AmtInWords
|
||||||
number /= 1000000d;
|
number /= 1000000d;
|
||||||
} while (number > 0);
|
} while (number > 0);
|
||||||
|
|
||||||
return (prefix + soFar + subfix).trim ();
|
return (prefix + soFar).trim ();
|
||||||
|
// return (prefix + soFar + subfix).trim ();
|
||||||
} // convert
|
} // convert
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/***********************************************************************
|
||||||
|
***
|
||||||
* Get Amount in Words
|
* Get Amount in Words
|
||||||
* @param amount numeric amount (352.80)
|
* @param amount numeric amount (352.80)
|
||||||
* @return amount in words (three*five*two 80/100)
|
* @return amount in words (three*five*two 80/100)
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
public String getAmtInWords (String amount) throws Exception
|
public String getAmtInWords (String amount) throws Exception
|
||||||
{
|
{
|
||||||
|
@ -240,24 +238,96 @@ public class AmtInWords_TH implements AmtInWords
|
||||||
return amount;
|
return amount;
|
||||||
//
|
//
|
||||||
StringBuffer sb = new StringBuffer ();
|
StringBuffer sb = new StringBuffer ();
|
||||||
double pos = (double)amount.lastIndexOf ('.');
|
int pos = amount.lastIndexOf ('.');
|
||||||
double pos2 = (double)amount.lastIndexOf (',');
|
int pos2 = amount.lastIndexOf (',');
|
||||||
if (pos2 > pos)
|
if (pos2 > pos)
|
||||||
pos = pos2;
|
pos = pos2;
|
||||||
String oldamt = amount;
|
String oldamt = amount;
|
||||||
amount = amount.replaceAll (",", "");
|
amount = amount.replaceAll (",", "");
|
||||||
int newpos = amount.lastIndexOf ('.');
|
int newpos = amount.lastIndexOf ('.');
|
||||||
double pesos = Double.parseDouble (amount.substring (0, newpos));
|
if (newpos != -1) {
|
||||||
sb.append (convert (pesos));
|
int pesos = Integer.parseInt(amount.substring(0, newpos));
|
||||||
for (int i = 0; i < oldamt.length (); i++)
|
System.out.println(pesos);
|
||||||
{
|
sb.append(convert(pesos)).append("\u0e1a\u0e32\u0e17");
|
||||||
if (pos == i) // we are done
|
for (int i = 0; i < oldamt.length(); i++) {
|
||||||
{
|
if (pos == i) { // we are done
|
||||||
String cents = oldamt.substring (i + 1);
|
String cents = oldamt.substring(i + 1);
|
||||||
sb.append (' ').append (cents).append ("/100");
|
int stang = Integer.parseInt(cents);
|
||||||
|
if (stang != 0) {
|
||||||
|
sb.append(convert(stang)).append("\u0e2a\u0e15\u0e32\u0e07\u0e04\u0e4c");
|
||||||
|
} else {
|
||||||
|
sb.append("\u0e16\u0e49\u0e27\u0e19");
|
||||||
|
}
|
||||||
|
// sb.append (' ').append (cents).append ("/100");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
int pesos = Integer.parseInt(amount);
|
||||||
|
sb.append(convert(pesos)).append("\u0e1a\u0e32\u0e17").append("\u0e16\u0e49\u0e27\u0e19");
|
||||||
|
}
|
||||||
|
return sb.toString ();
|
||||||
|
} // getAmtInWords
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
***
|
||||||
|
* Get Amount in Words
|
||||||
|
* @param amount numeric amount (352.80)
|
||||||
|
* @return amount in words (three*five*two 80/100)
|
||||||
|
*/
|
||||||
|
public String getAmtInWords (String amount, String iso) throws Exception
|
||||||
|
{
|
||||||
|
if (amount == null)
|
||||||
|
return amount;
|
||||||
|
//
|
||||||
|
StringBuffer sb = new StringBuffer ();
|
||||||
|
int pos = amount.lastIndexOf ('.');
|
||||||
|
int pos2 = amount.lastIndexOf (',');
|
||||||
|
if (pos2 > pos)
|
||||||
|
pos = pos2;
|
||||||
|
String oldamt = amount;
|
||||||
|
amount = amount.replaceAll (",", "");
|
||||||
|
int newpos = amount.lastIndexOf ('.');
|
||||||
|
if (newpos != -1) {
|
||||||
|
int pesos = Integer.parseInt(amount.substring(0, newpos));
|
||||||
|
System.out.println(pesos);
|
||||||
|
if (iso.equals("THB")) {
|
||||||
|
sb.append(convert(pesos)).append("\u0e1a\u0e32\u0e17");
|
||||||
|
for (int i = 0; i < oldamt.length(); i++) {
|
||||||
|
if (pos == i) { // we are done
|
||||||
|
String cents = oldamt.substring(i + 1);
|
||||||
|
int stang = Integer.parseInt(cents);
|
||||||
|
if (stang != 0) {
|
||||||
|
sb.append(convert(stang)).append("\u0e2a\u0e15\u0e32\u0e07\u0e04\u0e4c");
|
||||||
|
} else {
|
||||||
|
sb.append("\u0e16\u0e49\u0e27\u0e19");
|
||||||
|
}
|
||||||
|
// sb.append (' ').append (cents).append ("/100");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sb.append(convert(pesos)).append("\u0e40\u0e2b\u0e23\u0e35\u0e22\u0e0d");
|
||||||
|
for (int i = 0; i < oldamt.length(); i++) {
|
||||||
|
if (pos == i) { // we are done
|
||||||
|
String cents = oldamt.substring(i + 1);
|
||||||
|
int stang = Integer.parseInt(cents);
|
||||||
|
if (stang != 0) {
|
||||||
|
sb.append(convert(stang)).append("\u0e40\u0e0b\u0e47\u0e19\u0e15\u0e4c").append( " [" +iso +"]");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int pesos = Integer.parseInt(amount);
|
||||||
|
if (iso.equals("THB")) {
|
||||||
|
sb.append(convert(pesos)).append("\u0e1a\u0e32\u0e17").
|
||||||
|
append("\u0e16\u0e49\u0e27\u0e19");
|
||||||
|
} else {
|
||||||
|
sb.append(convert(pesos)).append("\u0e40\u0e2b\u0e23\u0e35\u0e22\u0e0d").append( " [" +iso +"]");
|
||||||
|
}
|
||||||
|
}
|
||||||
return sb.toString ();
|
return sb.toString ();
|
||||||
} // getAmtInWords
|
} // getAmtInWords
|
||||||
|
|
||||||
|
@ -276,6 +346,21 @@ public class AmtInWords_TH implements AmtInWords
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} // print
|
} // print
|
||||||
|
/**
|
||||||
|
* Test Print
|
||||||
|
* @param amt amount
|
||||||
|
*/
|
||||||
|
private void print (String amt, String currency)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
System.out.println(amt + " = " + getAmtInWords(amt));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} // print
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test
|
* Test
|
||||||
|
@ -285,22 +370,22 @@ public class AmtInWords_TH implements AmtInWords
|
||||||
{
|
{
|
||||||
AmtInWords_TH aiw = new AmtInWords_TH();
|
AmtInWords_TH aiw = new AmtInWords_TH();
|
||||||
// aiw.print (".23"); Error
|
// aiw.print (".23"); Error
|
||||||
aiw.print ("0.23");
|
// aiw.print ("0.23");
|
||||||
aiw.print ("1.23");
|
// aiw.print ("1.23");
|
||||||
aiw.print ("11.45");
|
// aiw.print ("11.45");
|
||||||
aiw.print ("121.45");
|
// aiw.print ("121.45");
|
||||||
aiw.print ("1231.56");
|
aiw.print ("3,026.00");
|
||||||
aiw.print ("12341.78");
|
aiw.print ("65341.78");
|
||||||
aiw.print ("123451.89");
|
// aiw.print ("123451.89");
|
||||||
aiw.print ("12234571.90");
|
// aiw.print ("12234571.90");
|
||||||
aiw.print ("123234571.90");
|
// aiw.print ("123234571.90");
|
||||||
aiw.print ("1987234571.90");
|
// aiw.print ("1,987,234,571.90");
|
||||||
aiw.print ("11123234571.90");
|
// aiw.print ("11123234571.90");
|
||||||
aiw.print ("123123234571.90");
|
// aiw.print ("123123234571.90");
|
||||||
aiw.print ("2123123234571.90");
|
// aiw.print ("2123123234571.90");
|
||||||
aiw.print ("23,123,123,234,571.90");
|
// aiw.print ("23,123,123,234,571.90");
|
||||||
aiw.print ("100,000,000,000,000.90");
|
// aiw.print ("100,000,000,000,000.90");
|
||||||
aiw.print ("0.00");
|
// aiw.print ("0.00");
|
||||||
} // main
|
} // main
|
||||||
|
|
||||||
} // AmtInWords_TH
|
} // AmtInWords_TH
|
||||||
|
|
Loading…
Reference in New Issue