NumtoWord (in a payment receipt)

NumtoWord (in a payment receipt)

Postby Silvio.Falconi » Sun May 10, 2020 4:24 pm

I made :

FWNumFormat( "E", .t. ) // European format
FW_N2WSETUP( 6 ) //Italian


...


oPrn:cmSay( 3.2,8.6,FW_NUMTOWORDS(nImporto,"Euro", "centesimi" ), oFnt3 )

and I have this
Image

the problems is ( on italian language )
1. although I specified "euro" and not "euros" the function continues to print "Euros"
2. the word "cents" should be placed at the end and not after the "e" and before the cents value
3. In Italian the cents must be printed with a slash "/" instead of the "e"
4. there must be no spaces between words , or there must be an option to separate words sample lSeparation

so the sentence should be printed like this:

Euro trecentocinquantacinque/67
or
Euro trecentocinquantacinque/67 centesimi

at this url https://www.blia.it/cifralettere/ there is a test that transcribes the amounts in Italian

To write the amount in letters, the cents must be written in numbers after a bar.

Example:

- 150 euro e 25 cent are written centocinquanta/25 (150.25)

- 150 euro are written centocinquanta/00 ( 150.00)

Other notations such as:

- centoventicinque/13 centesimi (125.13)
- centoventicinque e tredici centesimi (125.13)
- centoventicinque e 13 centesimi (125.13)
- centoventicinque e tredici cent (125.13)
- centocinquanta no cent ( 150.00)




on Jun 06, 2017 on this topic http://forums.fivetechsupport.com/viewtopic.php?f=3&t=34164&hilit=numtowords#p202527

I allready explained the errors for Italian language

it probably hasn't been fixed yet
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: NumtoWord (in a payment receipt)

Postby nageswaragunupudi » Mon May 11, 2020 5:39 am

Not corrected yet.
I will consult you later on this.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10659
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: NumtoWord (in a payment receipt)

Postby MaxP » Mon May 11, 2020 8:53 am

Hi Silvio,

this is a function Gl_NumToE( nNum ) to get a italian word from a number

Code: Select all  Expand view  RUN
#include "FiveWin.ch"


FUNCTION MAIN()
        LOCAL   nNum1 := 12345.67, nNum2 := 1234567.89

        MsgStop( Gl_NumToE( nNum1 ) )
        MsgStop( Gl_NumToE( nNum2 ) )
RETURN NIL

/***************************************************************/

FUNCTION Gl_NumToE( nNum )
        LOCAL   cBuf := Gl_NumToL( INT( nNum ) ), cDec

        IF EMPTY( cBuf )
                cBuf := "Zero"
        ENDIF

        cDec := RIGHT( STR( nNum - INT( nNum ), 16, 5 ), 5 )
        IF RIGHT( cDec, 1 ) == "0"
                cDec := LEFT( cDec, 4 )
        ENDIF
        IF RIGHT( cDec, 1 ) == "0"
                cDec := LEFT( cDec, 3 )
        ENDIF
        IF RIGHT( cDec, 1 ) == "0"
                cDec := LEFT( cDec, 2 )
        ENDIF
RETURN cBuf + " / " + cDec

FUNCTION Gl_NumToL( nNum )
        LOCAL   cBuf := "", lNeg := .F., nLen, cStr := ""

        cBuf := ALLTRIM( STR( nNum ) )
        IF LEFT( cBuf, 1 ) == "-"
                cBuf := RIGHT( cBuf, LEN( cBuf ) - 1 )
                lNeg := .T.
        ENDIF

        IF VAL( cBuf ) == 1
                Vett1( 1, @cStr )
        ELSE
                IF ( nLen := LEN( cBuf ) ) < 9
                        cBuf := SPACE( 9 - nLen ) + cBuf
                ENDIF
                Tr__num( SUBSTR( cBuf, 1, 3 ), @cStr, 1 )
                Tr__num( SUBSTR( cBuf, 4, 3 ), @cStr, 2 )
                Tr__num( SUBSTR( cBuf, 7, 3 ), @cStr, 3 )
        ENDIF

        cStr := UPPER( LEFT( cStr, 1 ) ) + RIGHT( cStr, LEN( cStr ) - 1 )

        IF lNeg
                cStr := "Meno " + cStr
        ENDIF
RETURN cStr

STATIC FUNCTION Tr__num( cStr, cBuf, nType )
        LOCAL   cTmp, nVal, nNum

        cTmp := cStr
        IF ( nNum := VAL( cTmp ) ) > 0
                IF .NOT. LEFT( cStr, 1 ) == '0' .AND. .NOT. LEFT( cStr, 1 ) == ' '
                        IF .NOT. LEFT( cStr, 1 ) == '1'
                                Vett1( ASC( LEFT( cStr, 1 ) ) - 48, @cBuf )
                        ENDIF
                        cBuf += "cento"
                ENDIF
                cTmp := SUBSTR( cStr, 2, 2 )
                nVal := VAL( cTmp )
                IF nVal > 0
                        IF nVal < 20
                                IF nType == 1 .OR. nNum > 1
                                        Vett1( nVal, @cBuf )
                                ENDIF
                        ELSE
                                IF SUBSTR( cStr, 3, 1 ) == '0'
                                        Vett2( SUBSTR( cStr, 2, 1 ), @cbuf )
                                ELSE
                                        IF SUBSTR( cStr, 3, 1 ) == '1'
                                                Vett2( SUBSTR( cStr, 2, 1 ), @cbuf )
                                                Coll( @cBuf, "uno" )
                                        ELSE
                                                IF SUBSTR( cStr, 3, 1 ) == '8'
                                                        Vett2( SUBSTR( cStr, 2, 1 ), @cbuf )
                                                        Coll( @cBuf, "otto" )
                                                ELSE
                                                        Vett2( SUBSTR( cStr, 2, 1 ), @cbuf )
                                                        Vett1( ASC( SUBSTR( cStr, 3, 1 ) ) - 48, @cBuf )
                                                ENDIF
                                        ENDIF
                                ENDIF
                        ENDIF
                ENDIF
                IF nType <> 3
                        IF ( nVal := LEN( cBuf ) ) > 2
                                IF RIGHT( cBuf, 3 ) == "uno"
                                        cBuf := LEFT( cBuf, nVal - 1 )
                                ENDIF
                        ENDIF
                        IF nNum > 1
                                cBuf += IIF( nType == 1, "milioni", "mila" )
                        ELSE
                                cBuf += IIF( nType == 1, "milione", "mille" )
                        ENDIF
                ENDIF
        ENDIF
RETURN NIL

STATIC FUNCTION Vett1( nNum, cCifra )
        LOCAL   cBuf

        DO CASE
                CASE nNum == 1
                        cBuf := "uno"

                CASE nNum == 2
                        cBuf := "due"

                CASE nNum == 3
                        cBuf := "tre"

                CASE nNum == 4
                        cBuf := "quattro"

                CASE nNum == 5
                        cBuf := "cinque"

                CASE nNum == 6
                        cBuf := "sei"

                CASE nNum == 7
                        cBuf := "sette"

                CASE nNum == 8
                        cBuf := "otto"

                CASE nNum == 9
                        cBuf := "nove"

                CASE nNum == 10
                        cBuf := "dieci"

                CASE nNum == 11
                        cBuf := "undici"

                CASE nNum == 12
                        cBuf := "dodici"

                CASE nNum == 13
                        cBuf := "tredici"

                CASE nNum == 14
                        cBuf := "quattordici"

                CASE nNum == 15
                        cBuf := "quindici"

                CASE nNum == 16
                        cBuf := "sedici"

                CASE nNum == 17
                        cBuf := "diciassette"

                CASE nNum == 18
                        cBuf := "diciotto"

                CASE nNum == 19
                        cBuf := "diciannove"
        ENDCASE

        Coll( @cCifra, cBuf )
RETURN NIL

STATIC FUNCTION Vett2( cCar, cCifra )
        LOCAL   cBuf

        DO CASE
                CASE cCar == '2'
                        cBuf := "venti"

                CASE cCar == '3'
                        cBuf := "trenta"

                CASE cCar == '4'
                        cBuf := "quaranta"

                CASE cCar == '5'
                        cBuf := "cinquanta"

                CASE cCar == '6'
                        cBuf := "sessanta"

                CASE cCar == '7'
                        cBuf := "settanta"

                CASE cCar == '8'
                        cBuf := "ottanta"

                CASE cCar == '9'
                        cBuf := "novanta"

        ENDCASE

        Coll( @cCifra, cBuf )
RETURN NIL

STATIC FUNCTION Coll( cCifra, cBuf )
        LOCAL   nLen, cCar1, cCar2

        IF ( nLen := LEN( cCifra ) ) > 0
                cCar1 := RIGHT( cCifra, 1 )
                cCar2 := LEFT( cBuf, 1 )

                IF ( cCar1 == 'a' .OR. cCar1 == 'e' .OR. ;
                 cCar1 == 'i' .OR. cCar1 == 'u' .OR. cCar1 == 'o' ) .AND. ;
                  ( cCar2 == 'a' .OR. cCar2 == 'e' .OR. ;
                   cCar2 == 'i' .OR. cCar2 == 'u' .OR. cCar2 == 'o' )
                        cCifra := LEFT( cCifra, nLen - 1 )
                endif
        ENDIF
        cCifra += cBuf
RETURN NIL


Regards
Massimo
User avatar
MaxP
 
Posts: 88
Joined: Thu Jul 12, 2007 2:02 pm

Re: NumtoWord (in a payment receipt)

Postby Silvio.Falconi » Mon May 11, 2020 4:31 pm

grazie massimo. Provato e funziona bene era proprio quello che in italia serve
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 65 guests