RE:Traduccion de Numeros a letras
Publicado por
Rodrigo (1 intervención) el 13/11/2008 14:32:28
Hola,
Te adjunto la formula en Crystal, usa el campo @totTot como importe.
Saludos !!
StringVar Cadenaglobal:="";
StringVar Valor:="S";
cadenaGlobal:=ToText({@totTot});
cadenaGlobal:=Trim(cadenaGlobal);
StringVar Resultado:="";
StringVar Decimales:= Right (cadenaGlobal,2 );
StringVar Unidades:= Right (cadenaGlobal,4 );
StringVar Decenas:=Right (cadenaGlobal,5 );
StringVar Centenas:=Right(cadenaGlobal,6);
StringVar Umillar:=Right (cadenaGlobal,8 );
StringVar Dmilllar:=Right(cadenaGlobal,9);
StringVar Cmilllar:=Right(CadenaGlobal,10);
StringVar milllares:=cadenaGlobal[2 to 2];
if abs({@totTot}) < 1 then
"0 Pesos "+Decimales+" /100 M.N."
else
if Left(Cmilllar,1)="9" then
resultado:=resultado+"Novecientos ";
if Left(Cmilllar,1)="8" then
resultado:=resultado+"Ochocientos ";
if Left(Cmilllar,1)="7" then
resultado:=resultado+"Setecientos ";
if Left(Cmilllar,1)="6" then
resultado:=resultado+"Seiscientos ";
if Left(Cmilllar,1)="5" then
resultado:=resultado+"Quinientos ";
if Left(Cmilllar,1)="4" then
resultado:=resultado+"Cuatrocientos ";
if Left(Cmilllar,1)="3" then
resultado:=resultado+"Trescientos ";
if Left(Cmilllar,1)="2" then
resultado:=resultado+"Doscientos ";
if Left(Cmilllar,1)="1" then
resultado:=resultado+"Cien(to) ";
if Left(Dmilllar,1)="9" then
resultado:=resultado+"Noventa ";
if Left(Dmilllar,1)="8" then
resultado:=resultado+"Ochenta ";
if Left(Dmilllar,1)="7" then
resultado:=resultado+"Setenta ";
if Left(Dmilllar,1)="6" then
resultado:=resultado+"Sesenta ";
if Left(Dmilllar,1)="5" then
resultado:=resultado+"Cincuenta ";
if Left(Dmilllar,1)="4" then
resultado:=resultado+"Cuarenta ";
if Left(Dmilllar,1)="3" then
resultado:=resultado+"Treinta ";
if Left(Dmilllar,1)="2" then
resultado:=resultado+"Veinti ";
if Left(Dmilllar,1)="1" then
resultado:=resultado+"Diez ";
if Left(Dmilllar,1) <> "0" and {@totTot} > 100000 then
resultado:=resultado+" y ";
if Left(Umillar,1)="9" then
resultado:=resultado+"Nueve ";
if Left(Umillar,1)="8" then
resultado:=resultado+"Ocho ";
if Left(Umillar,1)="7" then
resultado:=resultado+"Siete ";
if Left(Umillar,1)="6" then
resultado:=resultado+"Seis ";
if Left(Umillar,1)="5" then
resultado:=resultado+"Cinco ";
if Left(Umillar,1)="4" then
resultado:=resultado+"Cuatro ";
if Left(Umillar,1)="3" then
resultado:=resultado+"Tres ";
if Left(Umillar,1)="2" then
resultado:=resultado+"Dos ";
if Left(Umillar,1)="1" then
resultado:=resultado+"Un ";
if abs({@totTot}) >= 1000 and valor <> "N"then
resultado:=resultado+" Mil "; valor:="N";
if Left(Centenas,1)="9" then
resultado:=resultado+"Novecientos ";
if Left(Centenas,1)="8" then
resultado:=resultado+"Ochocientos ";
if Left(Centenas,1)="7" then
resultado:=resultado+"Setecientos ";
if Left(Centenas,1)="6" then
resultado:=resultado+"Seiscientos ";
if Left(Centenas,1)="5" then
resultado:=resultado+"Quinientos ";
if Left(Centenas,1)="4" then
resultado:=resultado+"Cuatrocientos ";
if Left(Centenas,1)="3" then
resultado:=resultado+"Trescientos ";
if Left(Centenas,1)="2" then
resultado:=resultado+"Doscientos ";
if Left(Centenas,1)="1" then
resultado:=resultado+"Cien(to) ";
if abs({@totTot}) >= 100000 then
resultado:=resultado+" Mil ";
if Left(decenas,1)="9" then
resultado:=resultado+"Noventa ";
if Left(decenas,1)="8" then
resultado:=resultado+"Ochenta ";
if Left(decenas,1)="7" then
resultado:=resultado+"Setenta ";
if Left(decenas,1)="6" then
resultado:=resultado+"Sesenta ";
if Left(decenas,1)="5" then
resultado:=resultado+"Cincuenta ";
if Left(decenas,1)="4" then
resultado:=resultado+"Cuarenta ";
if Left(decenas,1)="3" then
resultado:=resultado+"Treinta ";
if Left(decenas,1)="2" then
resultado:=resultado+"Veinte(i) ";
if Left(decenas,1)="1" then
resultado:=resultado+"Diez ";
if Left(decenas,1) <> "0" and Left(unidades,1) <> "0"then
resultado:=resultado+" y ";
if Left(Unidades,1)="9" then
resultado:=resultado+"Nueve ";
if Left(Unidades,1)="8" then
resultado:=resultado+"Ocho ";
if Left(Unidades,1)="7" then
resultado:=resultado+"Siete ";
if Left(Unidades,1)="6" then
resultado:=resultado+"Seis ";
if Left(Unidades,1)="5" then
resultado:=resultado+"Cinco ";
if Left(Unidades,1)="4" then
resultado:=resultado+"Cuatro ";
if Left(Unidades,1)="3" then
resultado:=resultado+"Tres ";
if Left(Unidades,1)="2" then
resultado:=resultado+"Dos ";
if Left(Unidades,1)="1" then
resultado:=resultado+"Un ";
if abs({@totTot}) < 100000 and abs({@totTot}) > 1000 and valor <> "N" then
resultado:=resultado+" Mil ";
Resultado+" Pesos "+Decimales+" /100 M.N."