1. Class
class MSCAmountInWordsforIndonesia
{
public static str FirstWordUppercase(str p_strStatement)
{
//return strFmt('%1%2',strupr(substr(p_strStatement,1,1)),substr(p_strStatement,2,strlen(p_strStatement)));
return Global::str2CapitalWord(p_strStatement);
}
public static void main(Args args)
{
// print DPRTerbilang::SayReal(1.1);
// print DPRTerbilang::SayReal(-1.2);
// print DPRTerbilang::SayReal(0.3);
// print DPRTerbilang::SayReal(10000.0000001);
// print DPRTerbilang::SayReal(1000.12);
// print DPRTerbilang::SayReal(2.45);
// print DPRTerbilang::SayReal(10.3894);
// print DPRTerbilang::SayReal(11.10001203);
// print DPRTerbilang::SayReal(20.0000);
// print DPRTerbilang::SayReal(21.00010000);
//print DPR_Terbilang::SayReal(30.21);
// print DPRTerbilang::SayReal(100.091238);
// print DPRTerbilang::SayReal(101.5445);
// print DPRTerbilang::SayReal(111.7667);
// print DPRTerbilang::SayReal(1011.67867);
// print DPRTerbilang::SayReal(10011.5089);
// print DPRTerbilang::SayReal(100011.0912);
// print DPRTerbilang::SayReal(1000011.09120);
// print DPRTerbilang::SayReal(10000011.0009);
// print DPRTerbilang::SayReal(100000011.100000001);
// print DPRTerbilang::SayReal(-1000000011.1000000001);
// print DPRTerbilang::TerbilangReal(9999.99);
//print DPRTerbilang::say(1000.20);
//pause;
}
public static str Nol(str _nolSebelumAngka="")
{
str terbilangNol;
int totalNol = strLen(_nolSebelumAngka);
int no;
;
for(no=1; no <= totalNol; no++)
{
if(!terbilangNol)
terbilangNol = "nol";
else
terbilangNol += " nol";
}
return terbilangNol;
}
public static str Say(int lAngka,int p_intDigit = 0)
{
str sBilangan [,1];
str sKelipatan3 [,1];
str sKalimat = "";
str sAngka = int2str(lAngka<0?-lAngka:lAngka);
boolean bNegatif = lAngka < 0;
boolean bKelipatan3Ada = false;
boolean bBelas = false;
int i,j;
;
sBilangan [1] = "zero";
sBilangan [2] = "one";
sBilangan [3] = "two";
sBilangan [4] = "three";
sBilangan [5] = "four";
sBilangan [6] = "five";
sBilangan [7] = "six";
sBilangan [8] = "seven";
sBilangan [9] = "eight";
sBilangan [10] = "nine";
sKelipatan3 [1] = "thousand";
sKelipatan3 [2] = "million";
sKelipatan3 [3] = "billion";
sKelipatan3 [4] = "quintillion";
sKelipatan3 [5] = "pentillion";
for (i=1; i<=strlen(sAngka); i++)
{
j = strlen(sAngka) - i;
switch (j mod 3)
{
case 0: //satuan
if (bBelas)
{
switch (substr(sAngka,i,1))
{
case '1':
sKalimat += "eleven "; break;
case '2':
sKalimat += "twelve "; break;
case '3':
sKalimat += "thirteen "; break;
case '5':
sKalimat += "fifteen "; break;
case '8':
sKalimat += "eighteen "; break;
case '0':
sKalimat += "ten "; break;
default:
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + "teen "; break;
}
bKelipatan3Ada = true;
bBelas = false;
}
else if (substr(sAngka,i,1) > '0')
{
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + " ";
bKelipatan3Ada = true;
}
if (bKelipatan3Ada)
{
if (j / 3 > 0)
{
if (sKalimat == "one " && j / 3 == 1) //berubah jadi se
{
sKalimat = "a ";
}
sKalimat += sKelipatan3[j / 3] + " ";
}
bKelipatan3Ada = false;
}
break;
case 1: //puluhan
if (substr(sAngka,i,1) != '0')
{
switch (substr(sAngka,i,1))
{
case '1': //belasan
bBelas = true; break;
case '2':
sKalimat += "twenty "; break;
case '3':
sKalimat += "thirtty "; break;
case '5':
sKalimat += "fifty "; break;
case '8':
sKalimat += "eighty "; break;
default:
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + "ty "; break;
}
bKelipatan3Ada = true;
}
break;
case 2: //ratusan
if (substr(sAngka,i,1) != '0')
{
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + " hundred ";
bKelipatan3Ada = true;
}
break;
}
}
if (p_intDigit > strlen(sAngka)) //by SW
{
for (i=strlen(sAngka); i < p_intDigit; i++)
{
sKalimat = sBilangan[1] + " " + sKalimat;
}
}
if (sKalimat == "") sKalimat = sBilangan[1] + " ";
return (bNegatif?"negative ":"") + sKalimat;
}
public static str SayReal(real p_reaAngka,int p_intDecimalDigit = 3, CurrencyCode _currency = Ledger::accountingCurrency())
{
str sAngka = num2str(p_reaAngka,0,p_intDecimalDigit,1,0);
str sLeft;
str sRight;
int iPos;
str terbilang;
;
iPos = strfind(sAngka,".",1,strlen(sAngka));
if (iPos)
{
sLeft = substr(sAngka,1,iPos-1);
sRight = substr(sAngka,iPos+1,strlen(sAngka));
iPos = strfind(sRight,"123456789",strlen(sRight),-strlen(sRight));
if (iPos)
{
sRight = substr(sRight,1,iPos);
}
else
{
sRight = "0";
}
}
else
{
sLeft = sAngka;
sRight = "0";
}
if (sRight != "0")
terbilang = MSCAmountInWordsforIndonesia::FirstWordUppercase(strfmt("%1%2 %3", MSCAmountInWordsforIndonesia::Say(str2int(sLeft)), "point ", MSCAmountInWordsforIndonesia::Say(str2int(sRight),strlen(sRight))));
else
terbilang = MSCAmountInWordsforIndonesia::FirstWordUppercase(strFmt("%1", MSCAmountInWordsforIndonesia::Say(str2int(sLeft))));
return strFmt("%1 %2", terbilang, Currency::find(_currency).Txt);
}
public static str Terbilang(real lAngka, real p_intDigit = 0, CurrencyCode _currency = Ledger::accountingCurrency(), NoYes _isCurrency = NoYes::Yes)
{
str sBilangan [,1];
str sKelipatan3 [,1];
str currency;
str sKalimat = "";
//str sAngka = int2str(lAngka<0?-lAngka:lAngka);
str sAngka = num2str(lAngka<0?-lAngka:lAngka,12,0,0,0);
boolean bNegatif = lAngka < 0;
boolean bKelipatan3Ada = false;
boolean bBelas = false;
int i,j;
;
sBilangan [1] = "nol";
sBilangan [2] = "satu";
sBilangan [3] = "dua";
sBilangan [4] = "tiga";
sBilangan [5] = "empat";
sBilangan [6] = "lima";
sBilangan [7] = "enam";
sBilangan [8] = "tujuh";
sBilangan [9] = "delapan";
sBilangan [10] = "sembilan";
sKelipatan3 [1] = "ribu";
sKelipatan3 [2] = "juta";
sKelipatan3 [3] = "milyar";
sKelipatan3 [4] = "trilyun";
sKelipatan3 [5] = "bilyun";
for (i=1; i<=strlen(sAngka); i++)
{
j = strlen(sAngka) - i;
switch (j mod 3)
{
case 0: //satuan
if (bBelas)
{
if (substr(sAngka,i,1) == '1')
{
sKalimat += "sebelas ";
bKelipatan3Ada = true;
}
else if (substr(sAngka,i,1) > '1')
{
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + " belas ";
bKelipatan3Ada = true;
}
else //10
{
sKalimat += "sepuluh ";
bKelipatan3Ada = true;
}
bBelas = false;
}
else if (substr(sAngka,i,1) > '0')
{
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + " ";
bKelipatan3Ada = true;
}
if (bKelipatan3Ada)
{
if (j / 3 > 0)
{
if (sKalimat == "satu " && j / 3 == 1) //berubah jadi se
{
sKalimat = "se";
}
sKalimat += sKelipatan3[j / 3] + " ";
}
bKelipatan3Ada = false;
}
break;
case 1: //puluhan
if (substr(sAngka,i,1) == '1') //belasan
{
bBelas = true;
bKelipatan3Ada = true;
}
else if (substr(sAngka,i,1) > '1')
{
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + " puluh ";
bKelipatan3Ada = true;
}
break;
case 2: //ratusan
if (substr(sAngka,i,1) == '1') //se
{
sKalimat += "seratus ";
bKelipatan3Ada = true;
}
else if (substr(sAngka,i,1) > '1')
{
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + " ratus ";
bKelipatan3Ada = true;
}
break;
}
}
if (p_intDigit > strlen(sAngka)) //by SW
{
for (i=strlen(sAngka); i < p_intDigit; i++)
{
sKalimat = sBilangan[1] + " " + sKalimat;
}
}
if (sKalimat == "") sKalimat = sBilangan[1] + " ";
//by SF
currency = _isCurrency ? Currency::find(_currency).Txt : "";
return (bNegatif?" ":"") + MSCAmountInWordsforIndonesia::FirstWordUppercase(sKalimat) + " " + currency;
}
public static str TerbilangKomaNew(real p_reaAngka,CurrencyCode _currency = "",int p_intDecimalDigit = 3)
{
str sAngka = num2str(p_reaAngka,0,p_intDecimalDigit,1,0);
str sLeft;
str sRight;
int iPos;
str tempStrLeft, tempStrRight;
MSCAmountInWordsforIndonesia terbilang = new MSCAmountInWordsforIndonesia();
;
iPos = strfind(sAngka,".",1,strlen(sAngka));
if (iPos)
{
sLeft = substr(sAngka,1,iPos-1);
sRight = substr(sAngka,iPos+1,strlen(sAngka));
iPos = strfind(sRight,"123456789",strlen(sRight),-strlen(sRight));
if (iPos)
{
sRight = substr(sRight,1,iPos);
}
else
{
sRight = "0";
}
}
else
{
sLeft = sAngka;
sRight = "0";
}
if (sRight != "0")
{
tempStrLeft = MSCAmountInWordsforIndonesia::TerbilangNew(str2num(sLeft),_currency);
tempStrRight = MSCAmountInWordsforIndonesia::TerbilangNew(str2num(sRight));
return MSCAmountInWordsforIndonesia::FirstWordUppercase(strfmt ("%1 koma %2", tempStrLeft,tempStrRight));
}
else
{
if(_currency)
return MSCAmountInWordsforIndonesia::FirstWordUppercase(MSCAmountInWordsforIndonesia::TerbilangNew(str2num(sLeft),_currency));
else
return MSCAmountInWordsforIndonesia::FirstWordUppercase(MSCAmountInWordsforIndonesia::TerbilangNew(str2num(sLeft)));
}
}
public static str TerbilangNew(amount _num, CurrencyCode _currency = Ledger::accountingCurrency())
{
int numOfPennies = frac(_num)*100 mod 100;
int test = real2int(round(_num,0));
int numOfTenths;
str 20 ones[19], tenths[9], hundreds, thousands, millions, billions;
int temp;
str 200 returntxt;
int checkPower(int _test, int _power)
{
int numOfPower;
if (_test >= _power)
{
numOfPower = _test DIV _power;
if (numOfPower >= 100)
{
temp = numOfPower DIV 100;
returntxt = returntxt ? returntxt + ' ' + ones[temp] + ' ' + hundreds : ones[temp] + ' ' + hundreds;
numOfPower = numOfPower MOD 100;
}
if (numOfPower >= 20)
{
temp = numOfPower DIV 10;
returntxt = returntxt ? returntxt + ' ' + tenths[temp] : tenths[temp];
numOfPower = numOfPower MOD 10;
}
if (numOfPower >= 1)
{
returntxt = returntxt ? returntxt + ' ' + ones[numOfPower] : ones[numOfPower];
numOfPower = numOfPower MOD 10;
}
switch(_power)
{
case 1000000000 :
{
returntxt = returntxt ? returntxt + ' ' + billions : billions;
_test = _test MOD 1000000000;
break;
}
case 1000000 :
{
returntxt = returntxt ? returntxt + ' ' + millions : millions;
_test = _test MOD 1000000;
break;
}
case 1000 :
{
returntxt = returntxt ? returntxt + ' ' + thousands : thousands;
_test = _test MOD 1000;
break;
}
case 100 :
{
returntxt = returntxt ? returntxt + ' ' + hundreds : hundreds;
_test = _test MOD 100;
break;
}
}
}
return _test;
}
ones[1] = "Satu";
ones[2] = "Dua";
ones[3] = "Tiga";
ones[4] = "Empat";
ones[5] = "Lima";
ones[6] = "Enam";
ones[7] = "Tujuh";
ones[8] = "Delapan";
ones[9] = "Sembilan";
ones[10] = "Sepuluh";
ones[11] = "Sebelas";
ones[12] = "Dua Belas";
ones[13] = "Tiga Belas";
ones[14] = "Empat Belas";
ones[15] = "Lima Belas";
ones[16] = "Enam Belas";
ones[17] = "Tujuh Belas";
ones[18] = "Delapan Belas";
ones[19] = "Sembilan Belas";
tenths[1] = 'Not used';
tenths[2] = "Dua Puluh";
tenths[3] = "Tiga Puluh";
tenths[4] = "Empat Puluh";
tenths[5] = "Lima Puluh";
tenths[6] = "Enam Puluh";
tenths[7] = "Tujuh Puluh";
tenths[8] = "Delapan Puluh";
tenths[9] = "Sembilan Puluh";
hundreds = "Ratus";
thousands = "Ribu";
millions = "Juta";
billions = "Miliar";
test = checkPower(test, 1000000000);
test = checkPower(test, 1000000);
test = checkPower(test, 1000);
test = checkPower(test, 100);
if (test >= 20)
{
numOfTenths = test DIV 10;
returntxt = returntxt ? returntxt + ' ' + tenths[numofTenths] : tenths[numofTenths];
numOfTenths = numOfTenths MOD 10;
test = test MOD 10;
}
if (test >= 1)
{
numOfTenths = test;
returntxt = returntxt ? returntxt + ' ' + ones[numOfTenths] : ones[numOfTenths];
}
if (numOfPennies)
{
returntxt = returntxt + MSCAmountInWordsforIndonesia::TerbilangNew(numofpennies) ;//+ ' Sen';
}
if (strscan(strltrim(returntxt),"Satu Ribu",1,15)==1)
{
returntxt = strReplace(returntxt, "Satu Ribu", "Seribu");
}
returntxt = strReplace(returntxt, "Juta Satu Ribu", "Juta Seribu");
returntxt = strReplace(returntxt, "Satu Ratus", "Seratus");
if(_currency)
return returntxt + " " + Currency::find(_currency).Txt;
else
return returntxt;
}
public static str TerbilangNoMinus(real lAngka, real p_intDigit = 0)
{
str sBilangan [,1];
str sKelipatan3 [,1];
str sKalimat = "";
//str sAngka = int2str(lAngka<0?-lAngka:lAngka);
str sAngka = num2str(lAngka<0?-lAngka:lAngka,12,0,0,0);
boolean bNegatif = lAngka < 0;
boolean bKelipatan3Ada = false;
boolean bBelas = false;
int i,j;
;
sBilangan [1] = "Nol";
sBilangan [2] = "Satu";
sBilangan [3] = "Dua";
sBilangan [4] = "Tiga";
sBilangan [5] = "Empat";
sBilangan [6] = "Lima";
sBilangan [7] = "Enam";
sBilangan [8] = "Tujuh";
sBilangan [9] = "Delapan";
sBilangan [10] = "Sembilan";
sKelipatan3 [1] = "Ribu";
sKelipatan3 [2] = "Juta";
sKelipatan3 [3] = "Milyar";
sKelipatan3 [4] = "Trilyun";
sKelipatan3 [5] = "Bilyun";
for (i=1; i<=strlen(sAngka); i++)
{
j = strlen(sAngka) - i;
switch (j mod 3)
{
case 0: //satuan
if (bBelas)
{
if (substr(sAngka,i,1) == '1')
{
sKalimat += "Sebelas ";
bKelipatan3Ada = true;
}
else if (substr(sAngka,i,1) > '1')
{
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + " belas ";
bKelipatan3Ada = true;
}
else //10
{
sKalimat += "Sepuluh ";
bKelipatan3Ada = true;
}
bBelas = false;
}
else if (substr(sAngka,i,1) > '0')
{
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + " ";
bKelipatan3Ada = true;
}
if (bKelipatan3Ada)
{
if (j / 3 > 0)
{
if (sKalimat == "Satu " && j / 3 == 1) //berubah jadi se
{
sKalimat = "se";
}
sKalimat += sKelipatan3[j / 3] + " ";
}
bKelipatan3Ada = false;
}
break;
case 1: //puluhan
if (substr(sAngka,i,1) == '1') //belasan
{
bBelas = true;
bKelipatan3Ada = true;
}
else if (substr(sAngka,i,1) > '1')
{
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + " Puluh ";
bKelipatan3Ada = true;
}
break;
case 2: //ratusan
if (substr(sAngka,i,1) == '1') //se
{
sKalimat += "Seratus ";
bKelipatan3Ada = true;
}
else if (substr(sAngka,i,1) > '1')
{
sKalimat += sBilangan[1+str2int(substr(sAngka,i,1))] + " Ratus ";
bKelipatan3Ada = true;
}
break;
}
}
if (p_intDigit > strlen(sAngka)) //by SW
{
for (i=strlen(sAngka); i < p_intDigit; i++)
{
sKalimat = sBilangan[1] + " " + sKalimat;
}
}
if (sKalimat == "") sKalimat = sBilangan[1] + " ";
return (bNegatif?"":"") + sKalimat;
}
public static str TerbilangReal(real p_reaAngka,int p_intDecimalDigit = 2, CurrencyCode _currency = Ledger::accountingCurrency())
{
str sAngka = num2str(p_reaAngka,0,p_intDecimalDigit,1,0);
str sLeft;
str sRight;
str sZero;
int iPos;
;
iPos = strfind(sAngka,".",1,strlen(sAngka));
if (iPos)
{
sLeft = substr(sAngka,1,iPos-1);
sRight = substr(sAngka,iPos+1,strlen(sAngka));
//iPos = strfind(sRight,"123456789",strlen(sRight),-strlen(sRight));
iPos = strfind(sRight,"123456789",1,strlen(sRight));
if (iPos)
{
//sRight = substr(sRight,1,iPos);
sZero = substr(sRight,1,iPos-1);
}
else
{
sRight = "0";
}
}
else
{
sLeft = sAngka;
sRight = "0";
}
if (sRight != "0")
return MSCAmountInWordsforIndonesia::FirstWordUppercase(strfmt ("%1%2 %3%4",
MSCAmountInWordsforIndonesia::Terbilang(str2num(sLeft)),
"koma",
MSCAmountInWordsforIndonesia::Nol(sZero),
MSCAmountInWordsforIndonesia::Nol(sZero)?(" " + MSCAmountInWordsforIndonesia::Terbilang(str2int(sRight),strlen(sRight))):
MSCAmountInWordsforIndonesia::Terbilang(str2int(sRight),strlen(sRight))
));
return MSCAmountInWordsforIndonesia::FirstWordUppercase(MSCAmountInWordsforIndonesia::Terbilang(str2num(sLeft), p_intDecimalDigit, _currency));
}
public static str TerbilangRealNoMinus(real p_reaAngka,int p_intDecimalDigit = 3)
{
str sAngka = num2str(p_reaAngka,0,p_intDecimalDigit,1,0);
str sLeft;
str sRight;
str sZero;
int iPos;
;
iPos = strfind(sAngka,".",1,strlen(sAngka));
if (iPos)
{
sLeft = substr(sAngka,1,iPos-1);
sRight = substr(sAngka,iPos+1,strlen(sAngka));
//iPos = strfind(sRight,"123456789",strlen(sRight),-strlen(sRight));
iPos = strfind(sRight,"123456789",1,strlen(sRight));
if (iPos)
{
//sRight = substr(sRight,1,iPos);
sZero = substr(sRight,1,iPos-1);
}
else
{
sRight = "0";
}
}
else
{
sLeft = sAngka;
sRight = "0";
}
if (sRight != "0")
return MSCAmountInWordsforIndonesia::FirstWordUppercase(strfmt ("%1%2 %3%4",
MSCAmountInWordsforIndonesia::TerbilangNoMinus(str2num(sLeft)),
"koma",
MSCAmountInWordsforIndonesia::Nol(sZero),
MSCAmountInWordsforIndonesia::Nol(sZero)?(" " + MSCAmountInWordsforIndonesia::TerbilangNoMinus(str2int(sRight),strlen(sRight))):
MSCAmountInWordsforIndonesia::TerbilangNoMinus(str2int(sRight),strlen(sRight))
));
return MSCAmountInWordsforIndonesia::FirstWordUppercase(MSCAmountInWordsforIndonesia::TerbilangNoMinus(str2num(sLeft)));
}
}
2. Class :
class MSCGlobal
{
static TempStr numeralsToTxt_Indonesia(real _num)
{
int numOfPennies = real2int(decRound(frac(_num), 2) * 100) mod 100;
real test = _num - frac(_num);
int64 numOfTenths;
str 20 ones[19], tenths[9], hundreds, thousands, millions, billions, trillions;
int64 temp;
str 200 returntxt;
int64 testLoc;
real modOperator(real a1, real a2)
{
int tmpi;
real tmp1, tmp2;
tmp1 = a1 / a2;
tmpi = real2int(tmp1);
tmp2 = tmpi;
return (tmp1 - tmp2)*a2;
}
real checkPower(real _test, int64 _power)
{
int64 numOfPower;
if (_test >= _power)
{
testLoc = any2Int64(_test);
numOfPower = testLoc div _power;
if (numOfPower >= 100)
{
temp = numOfPower div 100;
returntxt = returntxt + ' ' + ones[temp] + ' ' + hundreds;
numOfPower = numOfPower mod 100;
}
if (numOfPower >= 20)
{
temp = numOfPower div 10;
returntxt = returntxt + ' ' + tenths[temp];
numOfPower = numOfPower mod 10;
}
if (numOfPower >= 1)
{
returntxt = returntxt + ' ' + ones[numOfPower];
numOfPower = numOfPower mod 10;
}
switch(_power)
{
case 1000000000000 :
returntxt = returntxt + ' ' + trillions;
_test = modOperator(_test, 1000000000000.00);
break;
case 1000000000 :
returntxt = returntxt + ' ' + billions;
_test = modOperator(_test, 1000000000);
break;
case 1000000 :
returntxt = returntxt + ' ' + millions;
_test = modOperator(_test, 1000000);
break;
case 1000 :
returntxt = returntxt + ' ' + thousands;
_test = modOperator(_test, 1000);
break;
case 100 :
returntxt = returntxt + ' ' + hundreds;
_test = modOperator(_test, 100);
break;
}
}
return _test;
}
#Define.text_1('Satu')
#Define.text_2('Dua')
#Define.text_3('Tiga')
#Define.text_4('Empat')
#Define.text_5('Lima')
#Define.text_6('Enam')
#Define.text_7('Tujuh')
#Define.text_8('Delapan')
#Define.text_9('Sembilan')
#Define.text_10('Sepuluh')
#Define.text_11('Sebelas')
#Define.text_12('Dua belas')
#Define.text_13('Tiga belas')
#Define.text_14('Empat belas')
#Define.text_15('Lima belas')
#Define.text_16('Enam belas')
#Define.text_17('Tujuh belas')
#Define.text_18('Delapan belas')
#Define.text_19('Sembilan belas')
#Define.text_20('Dua Puluh')
#Define.text_30('Tiga Puluh')
#Define.text_40('Empat Puluh')
#Define.text_50('Lima Puluh')
#Define.text_60('Enam Puluh')
#Define.text_70('Tujuh Puluh')
#Define.text_80('Delapan Puluh')
#Define.text_90('Sembilan Puluh')
#Define.text_100('Ratus')
#Define.text_1000('Ribu')
#Define.text_1000000('Juta')
#Define.text_1000000000('Billion') //"Miliar";
#Define.text_1000000000000('Trillion')
#Define.text_and('dan')
ones[1] = #text_1;
ones[2] = #text_2;
ones[3] = #text_3;
ones[4] = #text_4;
ones[5] = #text_5;
ones[6] = #text_6;
ones[7] = #text_7;
ones[8] = #text_8;
ones[9] = #text_9;
ones[10] = #text_10;
ones[11] = #text_11;
ones[12] = #text_12;
ones[13] = #text_13;
ones[14] = #text_14;
ones[15] = #text_15;
ones[16] = #text_16;
ones[17] = #text_17;
ones[18] = #text_18;
ones[19] = #text_19;
tenths[1] = 'Tidak digunakan';
tenths[2] = #text_20;
tenths[3] = #text_30;
tenths[4] = #text_40;
tenths[5] = #text_50;
tenths[6] = #text_60;
tenths[7] = #text_70;
tenths[8] = #text_80;
tenths[9] = #text_90;
hundreds = #text_100;
thousands = #text_1000;
millions = #text_1000000;
billions = #text_1000000000;
trillions = #text_1000000000000;
test = checkPower(test, 1000000000000);
test = checkPower(test, 1000000000);
test = checkPower(test, 1000000);
test = checkPower(test, 1000);
test = checkPower(test, 100);
if (test >= 20)
{
testLoc = any2int64(test);
numOfTenths = testLoc div 10;
returntxt = returntxt + ' ' + tenths[numofTenths];
numOfTenths = numOfTenths mod 10;
test = real2int(test) mod 10;
}
if (test >= 1)
{
numOfTenths = real2int(test);
returntxt = returntxt + ' ' + ones[numOfTenths];
}
if (numOfPennies)
{
returntxt = '***' + returntxt + ' ' + #text_and + ' ' + num2str(numOfPennies,0,0,0,0) + '/100';
}
else
{
returntxt = '***' + returntxt + ' ' + #text_and + ' ' + '00/100';
}
return returntxt;
}
public static Description1000 convertAmountInWords_Indonesia(real _amount, str _currency1, str _currency2)
{
real decimals;
int64 intNumValue;
Description1000 word, decWord;
int64 repPos, repPos1;
;
word = MSCGlobal::numeralsToTxt_Indonesia(_amount);
repPos = strscan(word, ' dan', 1, strlen(word));
intNumValue = _amount;
decimals = _amount - intNumValue;
if (decimals == 0.00)
{
word = strdel(strpoke(word, strfmt(' %1 dan Nol %2', _currency1, _currency2), repPos), 1, 4); //No
}
else
{
decWord = substr(num2str(decimals, 0, 2, 1, 1), 3, 2);
decWord = MSCGlobal::numeralsToTxt_Indonesia(str2num(decWord));
repPos1 = strscan(decWord, ' dan', 1, strlen(decWord));
decWord = strpoke(decWord, strfmt(' %1', _currency2), repPos1);
decWord = strdel(decWord, 1, 4);
word = strdel(strpoke(word, strFmt(' %1 dan %2', _currency1, decWord), repPos), 1, 4);
word = strdel(word, strscan(word, '/100', 1, strlen(word)), 4);
}
// added for Seratus and Seribu
word = strReplace(word, "Satu Ribu", "Seribu");
word = strReplace(word, "Satu Ratus", "Seratus");
return word;
}
public static Description1000 convertAmountInWords(real _amount, str _currency1, str _currency2)
{
real decimals;
int64 intNumValue;
Description1000 word, decWord;
int64 repPos, repPos1;
;
word = Global::numeralsToTxt_EN(_amount);
repPos = strscan(word, ' and', 1, strlen(word));
intNumValue = _amount;
decimals = _amount - intNumValue;
if (decimals == 0.00)
{
word = strdel(strpoke(word, strfmt(' %1 and No %2', _currency1, _currency2), repPos), 1, 4);
}
else
{
decWord = substr(num2str(decimals, 0, 2, 1, 1), 3, 2);
decWord = Global::numeralsToTxt_EN(str2num(decWord));
repPos1 = strscan(decWord, ' and', 1, strlen(decWord));
decWord = strpoke(decWord, strfmt(' %1', _currency2), repPos1);
decWord = strdel(decWord, 1, 4);
word = strdel(strpoke(word, strFmt(' %1 and %2', _currency1, decWord), repPos), 1, 4);
//word = strdel(word, strscan(word, '/100', 1, strlen(word)), 4);
word = strdel(word, strscan(word, '0/100', 1, strlen(word)), 5);
}
return word;
}
static TempStr conversionOfNumeralsToTxt(real _num)
{
int numOfPennies = (decRound(frac(_num), 2) * 100) mod 100;
real test = _num - frac(_num);
int64 numOfTenths;
str 20 ones[19], tenths[9], hundreds, thousands, millions, billions, trillions;
int64 temp;
str 200 returntxt;
int64 testLoc;
real modOperator(real a1, real a2)
{
int tmpi;
real tmp1, tmp2;
tmp1 = a1 / a2;
tmpi = real2int(tmp1);
tmp2 = tmpi;
return (tmp1 - tmp2)*a2;
}
real checkPower(real _test, int64 _power)
{
int64 numOfPower;
if (_test >= _power)
{
testLoc = real2double(_test);
numOfPower = testLoc div _power;
if (numOfPower >= 100)
{
temp = numOfPower div 100;
returntxt = returntxt + ' ' + ones[temp] + ' ' + hundreds;
numOfPower = numOfPower mod 100;
}
if (numOfPower >= 20)
{
temp = numOfPower div 10;
returntxt = returntxt + ' ' + tenths[temp];
numOfPower = numOfPower mod 10;
}
if (numOfPower >= 1)
{
returntxt = returntxt + ' ' + ones[numOfPower];
numOfPower = numOfPower mod 10;
}
switch(_power)
{
case 1000000000000 :
returntxt = returntxt + ' ' + trillions;
_test = modOperator(_test, 1000000000000.00);
break;
case 1000000000 :
returntxt = returntxt + ' ' + billions;
_test = modOperator(_test, 1000000000);
break;
case 1000000 :
returntxt = returntxt + ' ' + millions;
_test = modOperator(_test, 1000000);
break;
case 1000 :
returntxt = returntxt + ' ' + thousands;
_test = modOperator(_test, 1000);
break;
case 100 :
returntxt = returntxt + ' ' + hundreds;
_test = modOperator(_test, 100);
break;
}
}
return _test;
}
ones[1] = "@SYS26620";
ones[2] = "@SYS26621";
ones[3] = "@SYS26622";
ones[4] = "@SYS26626";
ones[5] = "@SYS26627";
ones[6] = "@SYS26628";
ones[7] = "@SYS26629";
ones[8] = "@SYS26630";
ones[9] = "@SYS26631";
ones[10] = "@SYS26632";
ones[11] = "@SYS26633";
ones[12] = "@SYS26634";
ones[13] = "@SYS26635";
ones[14] = "@SYS26636";
ones[15] = "@SYS26637";
ones[16] = "@SYS26638";
ones[17] = "@SYS26639";
ones[18] = "@SYS26640";
ones[19] = "@SYS26641";
tenths[1] = 'Not used';
tenths[2] = "@SYS26643";
tenths[3] = "@SYS26644";
tenths[4] = "@SYS26645";
tenths[5] = "@SYS26646";
tenths[6] = "@SYS26647";
tenths[7] = "@SYS26648";
tenths[8] = "@SYS26649";
tenths[9] = "@SYS26650";
hundreds = "@SYS26651";
thousands = "@SYS26652";
millions = "@SYS26653";
billions = "@SYS26654";
trillions = "@SYS101697";
test = checkPower(test, 1000000000000);
test = checkPower(test, 1000000000);
test = checkPower(test, 1000000);
test = checkPower(test, 1000);
test = checkPower(test, 100);
if (test >= 20)
{
testLoc = real2double(test);
numOfTenths = testLoc div 10;
returntxt = returntxt + ' ' + tenths[numofTenths];
numOfTenths = numOfTenths mod 10;
test = real2int(test) mod 10;
}
if (test >= 1)
{
numOfTenths = real2int(test);
returntxt = returntxt + ' ' + ones[numOfTenths];
}
if (numOfPennies)
{
//returntxt = '***' + returntxt + ' ' + "@SYS5534" + ' ' + num2str(numOfPennies,0,0,0,0) + '/100';
returntxt = returntxt + ' ' + "@SYS5534";
if (numOfPennies >= 20)
{
numOfTenths = numOfPennies div 10;
numOfPennies = numOfPennies mod 10;
returntxt = returntxt + ' ' + tenths[numofTenths];
}
if (numOfPennies >= 1)
{
numOfTenths = real2int(numOfPennies);
returntxt = returntxt + ' ' + ones[numOfTenths];
}
returntxt = returntxt + ' cents ';
}
else
{
returntxt = returntxt;
}
return returntxt;
}
}