Friday, September 8

Dynamics AX X++ Code - Amount To Word Conversion in X++ Code

There are many ways to convert REAL into string words but below code snippet is simple and easy to modify according to your business logic. This code will first round off you amount then convert it into Word. Hope you will find it useful.


For any recommendation and suggestion relate code kindly feel free and comment below if your answer is more accurate and better than mine.

public str AmountToWords(real _amount)
{

    int             amount;
    str             amount2Words;

    amount       = real2int(round(_amount , 1));
    amount2Words = Global::numeralsToTxt(amount);
    amount2Words = subStr(amount2Words,5,strLen(amount2Words)-4);
    amount2Words = subStr(amount2Words,strLen(amount2Words)-10,-strLen(amount2Words));
    amount2Words = '(Amount:' +' '+  str2Capital(amount2Words) + ' only)';
    
    return amount2Words;
}

No comments:

Post a Comment

Popular Posts