Skip to content Skip to sidebar Skip to footer

How To Convert Numbers To Word In Indian Currency Format

I have A pdf form With this field 1.Invoice 2.Date 3.Truck No 4.Party Name 5.Party Place 6.City 7.GSTIN 8.Product 9.HSN 10.QTY 11.Rate 12.Amount 13.CGST 14.SGST 15.Total 16.Numb

Solution 1:

I've used it to convert Indian rupees amount in words with paise value. Basically it works fine with typescript if we generate a pipe in angular 7+ or above. For more information about pipes in angular go through the url pipes in angular 7+ or above

convert Indian rupees amount in words with paise

a = [
    '',
    'One ',
    'Two ',
    'Three ',
    'Four ',
    'Five ',
    'Six ',
    'Seven ',
    'Eight ',
    'Nine ',
    'Ten ',
    'Eleven ',
    'Twelve ',
    'Thirteen ',
    'Fourteen ',
    'Fifteen ',
    'Sixteen ',
    'Seventeen ',
    'Eighteen ',
    'Nineteen '];
b = [
    '',
    '',
    'Twenty',
    'Thirty',
    'Forty',
    'Fifty',
    'Sixty',
    'Seventy',
    'Eighty',
    'Ninety'];

transform(value: any): any {
    if (value) {
        let number = parseFloat(value).toFixed(2).split(".")
        let num = parseInt(number[0]);
        let digit = parseInt(number[1]);
        if (num) {
            if ((num.toString()).length > 9)  { return ''; }
            const n = ('000000000' + num).substr(-9).match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/);
            const d = ('00' + digit).substr(-2).match(/^(\d{2})$/);
            if (!n) {return ''; }
            let str = '';
            str += (Number(n[1]) !== 0) ? (this.a[Number(n[1])] || this.b[n[1][0]] + ' ' + this.a[n[1][1]]) + 'Crore ' : '';
            str += (Number(n[2]) !== 0) ? (this.a[Number(n[2])] || this.b[n[2][0]] + ' ' + this.a[n[2][1]]) + 'Lakh ' : '';
            str += (Number(n[3]) !== 0) ? (this.a[Number(n[3])] || this.b[n[3][0]] + ' ' + this.a[n[3][1]]) + 'Thousand ' : '';
            str += (Number(n[4]) !== 0) ? (this.a[Number(n[4])] || this.b[n[4][0]] + ' ' + this.a[n[4][1]]) + 'Hundred ' : '';
            str += (Number(n[5]) !== 0) ? (this.a[Number(n[5])] || this.b[n[5][0]] + ' ' + this.a[n[5][1]]) + 'Rupee ' : '';        
            str += (Number(d[1]) !== 0) ? ((str !== '' ) ? "and " : '') + (this.a[Number(d[1])] || this.b[d[1][0]] + ' ' + this.a[d[1][1]]) + 'Paise Only' : 'Only';
            return str;
        } else {
            return '';
        }
    } else {
        return '';
    }
}

Post a Comment for "How To Convert Numbers To Word In Indian Currency Format"