Hello Friends,
Recently i have developed one small function which convert any amount in Indian Amount Format Style (Digit grouing of amount as Crore, Lakh and Thousand)
For example:
Amount: 999,999.23 will show as 9,99,999.23
Use below CAL Function which take input as Decimal Value and Return amount in INR Format:
procedure GetIndianFormat_gFnc(Amount_iDec: Decimal) RtnValue: Text[50]
var
AddMinuSIng_lBln: Boolean;
i: Integer;
FromAmt_lDec: Decimal;
ToAmt_lDec: Decimal;
begin
if Amount_iDec < 0 then
AddMinuSIng_lBln := true;
Amount_iDec := Abs(ROUND(Amount_iDec, 0.01));
if Amount_iDec <= 99999.99 then begin // 1 Lakh
if AddMinuSIng_lBln then
RtnValue := '-' + Format(Amount_iDec, 0,
'<Precision,2><sign><Integer Thousand><Decimals,3>')
else
RtnValue := Format(Amount_iDec, 0,
'<Precision,2><sign><Integer Thousand><Decimals,3>');
exit(RtnValue);
end;
if Amount_iDec <= 9999999.99 then begin
for i := 1 to 99 do begin
FromAmt_lDec := i * 100000;
ToAmt_lDec := FromAmt_lDec + 99999.99;
if (Amount_iDec >= FromAmt_lDec) and (Amount_iDec <= ToAmt_lDec) then begin
Amount_iDec := Amount_iDec - FromAmt_lDec;
if AddMinuSIng_lBln then
RtnValue := '-' + Format(i) + ',' + Format(Amount_iDec, 0,
'<Precision,2><sign><Integer Thousand><Decimals,3>')
else
RtnValue := Format(i) + ',' + Format(Amount_iDec, 0,
'<Precision,2><sign><Integer Thousand><Decimals,3>');
exit(RtnValue);
end;
end;
end;
if Amount_iDec > 9999999.99 then begin
for i := 1 to 99 do begin
FromAmt_lDec := i * 10000000;
ToAmt_lDec := FromAmt_lDec + 9999999.99;
if (Amount_iDec >= FromAmt_lDec) and (Amount_iDec <= ToAmt_lDec) then begin
Amount_iDec := Amount_iDec - FromAmt_lDec;
if AddMinuSIng_lBln then
RtnValue := '-' + Format(i) + ',' + GetIndianFormat_gFnc(Amount_iDec)
else
RtnValue := Format(i) + ',' + GetIndianFormat_gFnc(Amount_iDec);
exit(RtnValue);
end;
end;
end;
Error('Input Value %1 Invalid', Amount_iDec);
end;
No comments:
Post a Comment