*-----------------------------------
* Convertion Pmnt en lettres
* DRIDBA 29/06/2003
* ------------------------------------
Param Pmnt,Pdevise,PL1,PL2,PNl,c1
* Pmnt= montant à traduire
* devise
* PL1 = logueur lignes à produir
* PN1 = nombre de lignes à retourner : 1 ou 2
* cl = caractère de complément
DECLARE TU[19],TD[9]
TU[1]="UN"
TU[2]="DEUX"
TU[3]="TROIS"
TU[4]="QUATRE"
TU[5]="CINQ"
TU[6]="SIX"
TU[7]="SEPT"
TU[8]="HUIT"
TU[9]="NEUF"
TU[10]="DIX"
TU[11]="ONZE"
TU[12]="DOUZE"
TU[13]="TREIZE"
TU[14]="QUATORZE"
TU[15]="QUINZE"
TU[16]="SEIZE"
TU[17]="DIX SEPT"
TU[18]="DIX HUIT"
TU[19]="DIX NEUF"
*
TD[1]="DIX"
TD[2]="VINGT"
TD[3]="TRENTE"
TD[4]="QUARANTE"
TD[5]="CINQUANTE"
TD[6]="SOIXANTE"
TD[7]="SOIXANTE"
TD[8]="QUATRE VING"
TD[9]="QUATRE VING"
*
Xmnt=alltrim(Convert())
Ml_mnt=len(Xmnt)
XMnt1=spac(PL1)
Xmnt2=spac(PL2)
*
IF Ml_mnt < PL1
Xmnt1=Xmnt+" "+repl(m.c1,PL1-Ml_mnt)
Xmnt2=repl(m.c1,PL2)
ELSE
IF subs(Xmnt,PL1,1)=" "
Xmnt1=left(Xmnt,PL1)
Ml=Ml_mnt-PL1
ELSE
i=PL1
do while subs(Xmnt,i,1)# " "
i=i-1
enddo
Xmnt1=subs(Xmnt,1,i-1)
Xmnt1=XMnt1+" "+repl(m.c1,PL1-i+1)
Ml=Ml_mnt-i
ENDIF
IF Ml < PL2
Xmnt2=right(Xmnt,Ml)+" "+repl(m.c1,PL2-Ml)
ELSE
Xmnt2=right(Xmnt,Ml)
ENDIF
ENDIF
Xmnt=iif(PNl=1,Xmnt1,Xmnt2) && ligne à retourner
RETURN Xmnt
*------------------------
FUNCTION CONVERT
Priv Xmnt
Xmnt=""
DO CASE
CASE PMNT = 0
Xmnt="ZERO "+Pdevise+" 0 CTS"
CASE PMNT < 1
Xmnt=str(Pmnt*100,2)+" CTS"
OTHER
MILLIARDS=INT(Pmnt/1000000000)
reste=MOD(Pmnt,1000000000)
MILLIONS=INT(reste/1000000)
reste=MOD(reste,1000000)
MILLES=INT(Reste/1000)
reste=MOD(reste,1000)
CENTS=INT(reste/100)
reste=MOD(reste,100)
DIX=INT(reste)
CTS=(reste-dix)*100
IF Milliards > 0
Xmnt=Milliards(Milliards)
ENDIF
IF Millions > 0
Xmnt=Xmnt+Millions(Millions)
ENDIF
IF Milles > 0
Xmnt=Xmnt+MILLES(Milles)
ENDIF
IF CENTS > 0
Xmnt=Xmnt+CENTS(cents,dix)
ENDIF
IF DIX > 0
Xmnt=Xmnt+DIX(Dix)
ENDIF
*SET STEP ON
Xmnt=ALLTRIM(Xmnt)+" "+ALLTRIM(Pdevise)+" "+IIF(cts=0,"",str(cts,2)+" CTS ")
ENDCASE
RETURN Xmnt
*------------------------
FUNCTION MILLIARDS
Param Mnt
Priv Mnt,Xmnt,milles,cents,dix,unit
Xmnt=" "
IF Mnt < 20
Xmnt=TU[mnt]+IIF(mnt=1," MILLIARD "," MILLIARDS ")
ELSE
MILLES=INT(Mnt/1000)
reste=MOD(Mnt,1000)
CENTS=INT(reste/100)
DIX=MOD(reste,100)
IF Milles > 0
Xmnt=MILLES(Milles)+" "
ENDIF
IF CENTS > 0
Xmnt=Xmnt+CENTS(cents,dix)
ENDIF
IF DIX > 0
Xmnt=Xmnt+DIX(Dix)
ENDIF
Xmnt=Xmnt+" MILLIARDS "
ENDIF
RETURN Xmnt
*------------------------
FUNCTION MILLIONS
Param Mnt
Priv Xmnt,milles,cents,dix,unit
Xmnt=" "
IF Mnt < 20
Xmnt=TU[mnt]+IIF(mnt=1," MILLION "," MILLIONS ")
ELSE
CENTS=INT(Mnt/100)
DIX=MOD(Mnt,100)
IF CENTS > 0
Xmnt=CENTS(cents,dix)
ENDIF
IF DIX > 0
Xmnt=Xmnt+DIX(Dix)
ENDIF
Xmnt=Xmnt+" MILLIONS "
ENDIF
RETURN Xmnt
*------------------------
FUNCTION MILLES
Param Mnt
Priv Mnt,Xmnt,cents,dix,unit
Xmnt=" "
IF Mnt < 20
Xmnt=IIF(mnt=1,"MILLE ",TU[mnt]+" MILLE ")
ELSE
CENTS=INT(Mnt/100)
DIX=MOD(Mnt,100)
IF CENTS > 0
Xmnt=Xmnt+CENTS(cents,dix)
ENDIF
IF DIX > 0
Xmnt=Xmnt+DIX(Dix)
ENDIF
Xmnt=Xmnt+" MILLE "
ENDIF
RETURN Xmnt
*------------------------
FUNCTION CENTS
Param Mnt,Preste
Priv Xmnt
Xmnt=IIF(mnt=1,"CENT ",IIF(Preste=0,TU[mnt]+" CENT ",TU[mnt]+" CENTS "))
RETURN Xmnt
*------------------------
FUNCTION DIX
Param Mnt
Priv Mnt,Xmnt
* traduire de 20 … 99
* Mdix est forcement >= 2, Munit = 0 … 9
Mdix=INT(mnt/10)
Munit=mod(mnt,10)
Xmnt=""
IF Mnt >= 20
Xmnt=TD[Mdix] && vingt, trente, ....
IF Munit > 0 .or. Mdix = 7 .or. Mdix = 9
IF Munit=1 .and. Mdix > 0
Xmnt=Xmnt+" ET"
ENDIF
IF Mdix=7 .or. Mdix=9
Munit = Munit+10
ENDIF
Xmnt=Xmnt+" "+TU[Munit]+" "
ENDIF
ELSE
Xmnt=TU[Mnt]+" "
ENDIF
RETURN Xmnt
|