Click here to Skip to main content
15,123,619 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
hi... everybody...

i've designed one crystal report to display the total number in indian
currency format which works good...
following is my code.

PHP
numbervar RmVal:=0; 
numbervar Amt:=0; 
numbervar pAmt:=0; 
stringvar InWords :=" ";
numbervar totalAmt;
totalAmt := Sum ({employee.salary});
Amt := totalAmt;

if Amt > 10000000 then 
    RmVal := truncate(Amt/10000000); 
if Amt = 10000000 then 
    RmVal := 1;
if RmVal = 1 then 
    InWords := InWords + " " + towords(RmVal,0) + " crore" 
else 
    if RmVal > 1 then 
        InWords := InWords + " " + towords(RmVal,0) + " crores";
Amt := Amt - Rmval * 10000000;
if Amt > 100000 then 
    RmVal := truncate(Amt/100000); 
if Amt <= 100000 then 
    RmVal := 1;

if RmVal = 1 then 
    InWords := InWords + " " + towords(RmVal,0) + " lakh"
Else
    If RmVal > 1 then 
        InWords := InWords + " " + ToWords(RmVal,0) + " Lakhs";

Amt := Amt - Rmval * 100000;

if Amt > 1000 then 
    RmVal := truncate(Amt/1000);
if Amt = 1000 then 
    Rmval := 1;

if RmVal =1 then 
    Inwords := InWords + " " + towords(RmVal,0) + "Thousand"
Else
    if RmVal > 1 then 
        InWords := InWords + " " + towords(RmVal,0) + "thousand ";
Amt := Amt - RmVal * 1000;
        
if Amt > 0 then 
    InWords := InWords + "  " + towords(truncate(Amt),0);

pAmt := (Amt - truncate(Amt)) * 100;

if pAmt > 0 then 
    InWords := InWords + " and " + towords(pAmt,0) + " paisa only" 
else 
    InWords := InWords + " rupees only";

UPPERCASE(InWords)


if i give 2,13,45,000 display in words as (TWO CRORES THIRTEEN LAKHS FORTY-FIVETHOUSAND RUPEES ONLY ) which is correct...

but when i give 2,00,45,000 it will display wrong value
i.e(TWO CRORES ONE LAKH ONETHOUSAND RUPEES ONLY )

i want here to be printed as (TWO CRORES FORTY-FIVE THOUSAND RUPEES ONLY ) which i want...

please help me...
Posted
Updated 28-Oct-10 0:50am
v2

This article was posted recently here in CodeProject.

Convert Numeric Currency into words ( For INDIAN Currency Only )[^]

Hope this will help you!
   
Comments
Hiren solanki 28-Oct-10 6:51am
   
I was about to give redirection to this article.
Ankur\m/ 28-Oct-10 7:09am
   
I knew you will see this and reply. :)
raju melveetilpurayil 28-Oct-10 7:41am
   
Good one
Try this. Let me know if it's working.
numbervar RmVal:=0; 
numbervar Amt:=0; 
numbervar pAmt:=0; 
stringvar InWords :=" ";
numbervar totalAmt;
totalAmt := Sum ({employee.salary});
Amt := totalAmt;

if Amt >= 10000000 then
    RmVal := truncate(Amt/10000000); 
if RmVal = 1 then 
    InWords := InWords + " " + towords(RmVal,0) + " crore" 
else 
    if RmVal > 1 then 
        InWords := InWords + " " + towords(RmVal,0) + " crores";
Amt := Amt - Rmval * 10000000;

RmVal := 0;
if Amt >= 100000 then 
    RmVal := truncate(Amt/100000); 
if RmVal = 1 then 
    InWords := InWords + " " + towords(RmVal,0) + " lakh"
Else
    If RmVal > 1 then 
        InWords := InWords + " " + ToWords(RmVal,0) + " Lakhs";
Amt := Amt - Rmval * 100000;

RmVal := 0;
if Amt >= 1000 then 
    RmVal := truncate(Amt/1000);
if RmVal =1 then 
    Inwords := InWords + " " + towords(RmVal,0) + "Thousand"
Else
    if RmVal > 1 then 
        InWords := InWords + " " + towords(RmVal,0) + "thousand ";
Amt := Amt - RmVal * 1000;
        
if Amt > 0 then 
    InWords := InWords + "  " + towords(truncate(Amt),0);

pAmt := (Amt - truncate(Amt)) * 100;

if pAmt > 0 then 
    InWords := InWords + " and " + towords(pAmt,0) + " paisa only" 
else 
    InWords := InWords + " rupees only";

UPPERCASE(InWords)
   
Comments
vinu.1111 28-Oct-10 8:24am
   
Thanku very much........
i'm really satisfied with this....
once thank you...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900