You need to sign in to do that
Don't have an account?

Currency to Words
Hi all,
I have a currecy field and needs to convert it into words.
Ex: Amount : $ 1,10,521
It should be converted into text as "1 lakh 10 thousand five hundred and twenty 1 dollars only".
Plese suggest me
I have a currecy field and needs to convert it into words.
Ex: Amount : $ 1,10,521
It should be converted into text as "1 lakh 10 thousand five hundred and twenty 1 dollars only".
Plese suggest me
http://salesforcewithkiran.blogspot.in/2013/05/number-to-words-in-apex.html
I used that one but doesn't work for lakhs like for the example I have mentioned above.
To execute this do something like below, Do not include commas, use long formats only
When I applied the apex class and the trigger you provided in the link above, it returns with the "word conversion of the integer portion" but does not return decimal places. For 121,56 It returns "One Hundred Twenty One and", does not bring "56"
I have given the answer here (Class AmountInWords_New) -> https://developer.salesforce.com/forums/?id=906F000000090L4IAI
Thank You,
Adiga,
Hosanagara.
public class testingClass2 {
public String[] units = new String[]{'Zero ','One ','Two ','Three ','Four ','Five ','Six ','Seven ','Eight ','Nine ','Ten ',
'Eleven ','Twelve ','Thirteen ','Fourteen ','Fifteen ',
'Sixteen ','Seventeen ','Eighteen ','Nineteen '};
public String[] tens = new String[]{'','','Twenty','Thirty','Forty','Fifty','Sixty','Seventy','Eighty','Ninety'};
//This method is used to convert the integer to words
public String convert(long i) {
if( i < 20) {
system.debug('in 20');
//return units[integer.valueOf(i)];
return units[i.intValue()];
}
if( i < 100) {
system.debug('in 100');
//return tens[i.intValue()/10] + ((math.mod(i , 10) > 0)? '' + convert(math.mod(i , 10)):'');
return tens[integer.valueOf(i)/10] + ((math.mod(i , 10) > 0)? '' + convert(math.mod(i , 10)):'');
}
if( i < 1000) {
system.debug('in 1000');
return units[integer.valueOf(i)/100] + ' Hundred ' + ((math.mod(i , 100) > 0)?' ' + convert(math.mod(i , 100)):'');
}
if( i < 10000) {
system.debug('in 10000');
return units[integer.valueOf(i)/1000] + ' Thousand ' + ((math.mod(i , 1000) > 0)?' ' + convert(math.mod(i , 1000)):'');
}
if( i < 100000) {
system.debug('in 100000');
return convert(i / 1000) + ' Thousand ' + ((math.mod(i , 1000) > 0)? '' + convert(math.mod(i ,1000)):'') ;
}
if( i < 1000000) {
system.debug('in 1000000');
return units[integer.valueOf(i)/100000] + ' Lakh ' + ((math.mod(i , 100000) > 0)? '' + convert(math.mod(i ,100000)):'') ;
}
if( i < 10000000) {
system.debug('in 10000000');
return convert(i / 100000) + ' Lakh ' + ((math.mod(i , 100000) > 0)? '' + convert(math.mod(i ,100000)):'') ;
}
if(i < 100000000) {
system.debug('in 100000000');
return units[integer.valueOf(i)/10000000] + ' Crore ' + ((math.mod(i , 10000000) > 0)? '' + convert(math.mod(i , 10000000)):'') ;
}
if(i < 1000000000) {
system.debug('in 1000000000');
return convert(i / 10000000) + 'Crore ' + ((math.mod(i , 10000000) > 0)? '' + convert(math.mod(i , 10000000)):'') ;
}
return convert(i / 1000000000) + ' Hundred Crore ' + ((math.mod(i , 1000000000) > 0) ? '' + convert(math.mod(i , 1000000000)):'') ;
}
}