Skip to Content
0
J S
Oct 01, 2020 at 05:53 AM

Amount in words not working

55 Views Last edit Oct 02, 2020 at 05:41 PM 4 rev

Hi

I have written below code . I want in USD format

Value is 1071013.690000

one million seventy-one thousand thirteen dollars and Sixty Nine cents

numbervar RmVal:=0;
numbervar Amt:=0;
numbervar pAmt:=0;
if {Command.DocCur}="$" then stringvar InWords :=" USD ";
Amt := {Command.Doc Total};
if Amt > 10000000 then RmVal := truncate(Amt/10000000);
if Amt = 10000000 then RmVal := 1;
if RmVal = 1 then
InWords := InWords + " " + UpperCase (towords(RmVal,0)) + "million"
else
if RmVal > 1 then InWords := InWords + " " + towords(RmVal,0) + "millions";
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) + "";
Amt := Amt - Rmval * 100000;
if Amt > 0 then InWords := InWords + " " + towords(truncate(Amt),0);
pAmt := (Amt - truncate(Amt)) * 100;

if pAmt > 0 and {Command.DocCur}="$" then
InWords := InWords + " and " + towords(pAmt,0) + " cents" + ""
else
InWords := InWords + " Only";

Thanks