SAP Business One SDK Support

Convert Total Amount to Words in Crystal Report

The Below code is to convert the Total Invoice amount to word with decimal points to paise. Place this below code in a formula field. In the below code there is {@GrandTotal} field that is to be replace with the field which you need.

Advertisement




//ToWords ({{@GrandTotal}},0 )
numbervar RmVal:=0;
numbervar Amt:=0;
numbervar pAmt:=0;
stringvar InWords :=" ";
Amt := {command.DocTotal};
if Amt > 10000000 then RmVal := truncate(Amt/10000000);
if Amt = 10000000 then RmVal := 1;
if RmVal = 1 then
InWords := InWords + " " + ProperCase (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) + " lakhs";

Amt := Amt - Rmval * 100000;
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 + " only";
ProperCase(InWords);


For Indian Rupee and Paise Download Formula here 
http://www.mediafire.com/view/?eqld0s7hv9blk2x

Convert Total to Words in AED , SAR, OMR 

Advertisement



The below code is for the Gulf Countries with AED, SAR, OMR with decimal points. Replace {@DOCTOT} with Your total field.

if {command.DocCur}="AED"
then

(numbervar RmVal:=0;
numbervar Amt:=0;
numbervar pAmt:=0;
stringvar InWords :={command.DocCur};

Amt:= {@DOCTOT};

if Amt > 10000000 then RmVal := truncate(Amt/10000000);
if Amt = 10000000 then RmVal := 1;
if RmVal = 1 then
InWords :=UpperCase ( InWords + " " + towords(RmVal,0) + " Billion" )
else
if RmVal > 1 then InWords := UpperCase (InWords + " " + towords(RmVal,0) + "Billions");

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

Amt := Amt - Rmval * 100000;
if Amt > 0 then InWords :=UpperCase ( InWords + " " + towords(truncate(Amt),0));
pAmt := (Amt - truncate(Amt)) * 100;
if pAmt > 0 then
InWords := UpperCase (InWords + " and " + towords(pAmt,0) + " Fils only")
else
InWords := UpperCase (InWords + " Only");)

else if {command.DocCur}="SAR"
then

(numbervar RmVal:=0;
numbervar Amt:=0;
numbervar pAmt:=0;
stringvar InWords :={command.DocCur};

Amt:= {@DOCTOT};

if Amt > 10000000 then RmVal := truncate(Amt/10000000);
if Amt = 10000000 then RmVal := 1;
if RmVal = 1 then
InWords := UpperCase (InWords + " " + towords(RmVal,0) + " Billion")
else
if RmVal > 1 then InWords := UpperCase (InWords + " " + towords(RmVal,0) + " Billions");
Amt := Amt - Rmval * 10000000;
if Amt > 100000 then RmVal := truncate(Amt/100000);
if Amt = 100000 then RmVal := 1;
if RmVal >=1 then
InWords := UpperCase (InWords + " " + towords(RmVal,0) + "Riyal");
Amt := Amt - Rmval * 100000;
if Amt > 0 then InWords :=UpperCase ( InWords + " " + towords(truncate(Amt),0));
pAmt := (Amt - truncate(Amt)) * 100;
if pAmt > 0 then
InWords := UpperCase (InWords + " and " + towords(pAmt,0) + " Hallallah only")
else
InWords :=UpperCase ( InWords + " Only"); )
else if {command.DocCur}="OMR"
then
(numbervar RmVal:=0;
numbervar Amt:=0;
numbervar pAmt:=0;
stringvar InWords :={command.DocCur};
Amt:= {@DOCTOT};
if Amt > 10000000 then RmVal := truncate(Amt/10000000);
if Amt = 10000000 then RmVal := 1;
if RmVal = 1 then
InWords :=UpperCase ( InWords + " " + towords(RmVal,0) + " Billion")
else
if RmVal > 1 then InWords := UpperCase (InWords + " " + towords(RmVal,0) + "Billions");

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

Amt := Amt - Rmval * 100000;
if Amt > 0 then InWords := UpperCase (InWords + " " + towords(truncate(Amt),0));
pAmt := (Amt - truncate(Amt)) * 100;
if pAmt > 0 then
InWords := UpperCase (InWords + " and " + towords(pAmt,0) + " Baisa only" )
else
InWords :=UpperCase ( InWords + " Only");)


For Gulf Country AED, SAR, OMR Download Formula here
http://www.mediafire.com/view/?exteygu3pu0bt46

Please let me know, if there is any other short formula or code. Thank You.



Advertisement



4 comments:

Bhupinder Kapoor said...

how to remove '-' in amounts in word

Vibin Varghese said...

Use a replace method in formula eg. tst := Replace (tst,"-" ,"" );

Unknown said...

how change the toword language (Arabic for ex)

Edge1 said...

how to convert value in to American accent