on 02-03-2011 7:28 PM
Buenas tardes
Alguien de uds puede apoyarme en como poner el total en letras en una factura hecha en crystal reports, revise el PLD y hace referencia alguna variable, pero en Crystal no he encontrado una forma de hacerlo, alguna sugerencia?
Saludos.
Proba con esta Formula:
if {VRetenciones.doccurr} = 'GS' THEN
stringVar monto :=trim(totext({VRetenciones.impretencion},2,''));
stringVar texto :='';
stringVar ytexto :='';
numberVar long :=length(monto);
stringVar array Cientos := ['CIENTO', 'DOSCIENTOS','TRESCIENTOS', 'CUATROCIENTOS', 'QUINIENTOS',
'SEISCIENTOS','SETECIENTOS', 'OCHOCIENTOS', 'NOVECIENTOS','MIL'];
stringVar array Decenas := ['DIEZ', 'VEINTE', 'TREINTA', 'CUARENTA', 'CINCUENTA', 'SESENTA',
'SETENTA','OCHENTA','NOVENTA',' '];
stringVar array MasDecenas := ['ONCE', 'DOCE', 'TRECE', 'CATORCE', 'QUINCE', 'DIECISEIS',
'DIECISIETE', 'DIECIOCHO', 'DIECINUEVE'];
stringVar array Unidades :=['UN ','DOS', 'TRES','CUATRO','CINCO','SEIS', 'SIETE', 'OCHO',
'NUEVE',' '];
stringvar monto := ReplicateString ('0',15 - length(monto)) + monto;
StringVar ParteDecimal := monto[13]monto[14]monto[15];
StringVar Parte1 := monto[10] + monto[11] + monto[12];
StringVar Parte2 := monto[7] + monto + monto[9];
StringVar Parte3 := monto[4] + monto[5] + monto[6];
StringVar Parte4 := monto[1] + monto + monto[3];
StringVar Letras1 := ' ';
if Parte4 <> '000' then
Letras1 := Letras1 + Cientos[ToNumber(Parte4[1])];
if Parte4 = '1' and Parte4[3] > '0' then
Letras1 := Letras1 + ' ' + MasDecenas[ToNumber(Parte4[3])];
if Parte4 <> '0' and Parte4[2]<>'2' THEN
Letras1 := Letras1 + ' ' + Decenas[ToNumber(Parte4[2])];
if Parte4 <> '0' AND Parte4[2]='2' THEN
Letras1 := Letras1 + ' VEINTI';
if (Parte4 <> '0') and (not(Parte4 = '1' and Parte4[3] > '0')) then
if Letras1 <> ' ' then
if (Parte4[2] <> '0') and (Parte4[2]<>'2') then // si es distinto de veinte y
Letras1 := Letras1 + ' y ' + Unidades[ToNumber(Parte3[3])];
if (Parte4[2] <> '0') and (Parte4[2]='2') then // si es veinte y
Letras1 := Letras1 + Unidades[ToNumber(Parte4[3])];
if Letras1=' ' and Parte4[3]<>'0' and Parte4[1]='0' and Parte4[2]='0' then // si es un mil millones, dos mil millones, etc.
Letras1 := Letras1 + Unidades[ToNumber(Parte3[3])];
if Parte4 <> '000' then
Letras1 := Letras1 + ' MIL MILLONES ';
if Parte3 <> '000' then
Letras1 := Letras1 + Cientos[ToNumber(Parte3[1])];
if Parte3 = '1' and Parte3[3] > '0' then
Letras1 := Letras1 + ' ' + MasDecenas[ToNumber(Parte3[3])];
if Parte3 <> '0' and Parte3[2]<>'2' then
Letras1 := Letras1 + ' ' + Decenas[ToNumber(Parte3[2])];
if Parte3 > '0' and Parte3[2]='2' then
Letras1 := Letras1 + ' VEINTI';
if (Parte3 <> '0') and (not(Parte3 = '1' and Parte3[3] > '0')) then
if Letras1 <> ' ' then
if (Parte3 <> '0') and (Parte3[2]<>'2') then // si es distinto de veinte y
Letras1 := Letras1 + ' y ' + Unidades[ToNumber(Parte3[3])];
if (Parte3 <> '0') and (Parte3[2]='2') then // si es veinte y
Letras1 := Letras1 + Unidades[ToNumber(Parte3[3])];
if Letras1=' ' and Parte3[3]<>'0' and Parte3[1]='0' and Parte3[2]='0' then // si es un millón, dos millones, tres millones
Letras1 := Letras1 + Unidades[ToNumber(Parte3[3])];
If Parte3 = '001' then
Letras1 := Letras1 + ' MILLON '
else
if Parte3 <> '000' then
Letras1 := Letras1 + ' MILLONES ';
if Parte2 <> '000' then
Letras1 := Letras1 + Cientos[ToNumber(Parte2[1])];
if (Parte2 = '1') and (Parte2[3] > '0') then //si es dieci
Letras1 := Letras1 + ' ' + MasDecenas[ToNumber(Parte2[3])];
if (Parte2 = '2') and (Parte2[3] > '0') then //si es veinte y..
Letras1 := Letras1 + ' VEINTI';
if (Parte2 > '2') then //SI ES distinto de veinte y..
Letras1 := Letras1 + ' ' + Decenas[ToNumber(Parte2[2])];
if (Parte2 = '0') and (Parte2 = '1') and (Parte2[3]='0') then //SI DIEZ
Letras1 := Letras1 + ' ' + Decenas[ToNumber(Parte2[2])];
if (Parte2 <> '0') and (not(Parte2 = '1' and Parte2[3] > '0')) then
if Letras1 <> ' ' then
if (Parte2 <> '0') and (Parte2[2]<>'2') and (not(Parte2 = '1' and Parte2[3] > '0')) then // si es distinto de veinte y
Letras1 := Letras1 + ' y ' + Unidades[ToNumber(Parte2[3])]
else if (Parte2 <> '0') and (Parte2[2]='2') then // si es veinte y
Letras1 := Letras1 + Unidades[ToNumber(Parte2[3])];
if(Parte2[1]<>'0') and Parte2[2]='0' and Parte2[3] <> '0'then
Letras1 := Letras1 + ' ' + Unidades[ToNumber(Parte2[3])];
if Parte2 <> '000' then
Letras1 := Letras1 + ' MIL ';
if Parte1 <> '000' then
if Parte1[1] <> '0' then
if Parte1 ='100' then Letras1 := Letras1 + 'CIEN'
else Letras1 := Letras1 + Cientos[ToNumber(Parte1[1])];
if Parte1[2] = '1' and Parte1[3] > '0' then
Letras1 := Letras1 + ' ' + MasDecenas[ToNumber(Parte1[3])];
if Parte1 > '1' and Parte1[2]<>'2' then
Letras1 := Letras1 + ' ' + Decenas[ToNumber(Parte1[2])];
if Parte1 = '1' and Parte1[3]='0' then
Letras1 := Letras1 + ' ' + Decenas[ToNumber(Parte1[2])];
if Parte1 <> '0' and Parte1[2]='2' then
Letras1 := Letras1 + ' VEINTI';
if (Parte1 <> '0') and (not(Parte1 = '1' and Parte1[3] > '0')) then
if Letras1 <> ' ' then
if (Parte1 <> '0') and (Parte1[2]<>'2') and (not(Parte1 = '1' and Parte1[3] > '0')) then // si es distinto de veinte y
If Parte1[3]='1' then
Letras1 := Letras1 + ' y UNO'
Else
Letras1 := Letras1 + ' y ' + Unidades[ToNumber(Parte1[3])];
if (Parte1 <> '0') and Parte1[2]='2' and (Parte1[3]='1')then // si es veintiun
Letras1 := Letras1 + 'UNO';
if (Parte1 <> '0') and (Parte1[2]='2') and (Parte1[3]<>'1') and (Parte1[3]<>'0')then // si es veintidós, veintitrés..
Letras1 := Letras1 + Unidades[ToNumber(Parte1[3])];
if(Parte1[1]<>'0') and Parte1[2]='0' and Parte1[3] <> '0'then
Letras1 := Letras1 + ' ' + Unidades[ToNumber(Parte1[3])];
Letras1 := trim(Letras1) + '.--';
Edited by: Jorge Casaccia on Feb 3, 2011 9:52 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hola darwin puedes dar mas detalles de esta funcion como la aplico yo tengo la misma inquietud soy nuevo usando crystal report. tengo el siguiente campo:
Numero: USD 1,356.98
como debe aparecer en letras: Mil trescientos cincuenta y seis con 98/100 Dolares Americanos
En mis layout de impresion en sap no tengo problemas me salen asi el numero en texto.
Bueno tu apoyo
Gracias,
Jesus Bocanegra
Hola Jesus,
Respondiendo a tu pregunta la funcion ToWords en Crystal no te reconocera las monedas asi que ese valor que de lo devolveria de la siguiente manera:
mil trescientos cincuenta y seis y 98 / 100
Lo que podrias hacer es una Formula que te concatene el valor en letras con la moneda., yo por lo menos lo hago asi incluso en PLD
Saludos
Gracias darwin lo maximo ya me esta empezando agradar el Crystal.
Solo una duda mas para no molestar con este tema como hago la concatenacion yo si lo he hecho en el SAP mismo en un layout.
Pero en crystal como lo hago que tengo que hacer. si me puedes guiar paso a paso por favor. tengo el siguiente campo:
U_MONEDA que arroja estos valores (US$, S/. , EUR )
quiero que en l crystal salga que cuando es
US$ = Dolares Americanos
S/ = Nuevos Soles
EUR = Euros
Saludos
Jesus
Creo que seria una formula como la siguiente.
IF U_MONEDA = 'US$' THEN
ToWords (DocTotal)+ ' Dolares Americanos'
ELSE IF U_MONEDA = 'S/' THEN
ToWords (DocTotal)+ ' Nuevos Soles'
ELSE
ToWords (DocTotal)+ ' Euros'
La pregunta es pq usas un campo de usuario 'U_Moneda' pq no usas el campo Currency que esta en la tabla OCHO de los cheques.
Saludos.
PSD: Cualquier duda en crystal no dudes en consultarme ya tengo varios años trabando con Crystal, y cualquier duda con la que ya te vayas topando a lo mejor yo ya me quebre la cabeza resolviendola antes.
Muchas gracias por sus comentarios, quedo de la siguiente forma en mi caso
IF {OINV.DocCur} = 'MXP' THEN
UpperCase ( ToWords ({OINV.DocTotal}))+ ' PESOS MEXICANOS'
ELSE IF {OINV.DocCur} = 'USD' THEN
UpperCase ( ToWords ({OINV.DocTotalSy})) + ' DÓLARES AMERICANOS'
ELSE IF {OINV.DocCur} = 'EUR' THEN
UpperCase ( ToWords ({OINV.DocTotalSy}))+ ' EUROS'
ELSE IF {OINV.DocCur} = 'CAN' THEN
UpperCase ( ToWords ({OINV.DocTotalSy}))+ ' DÓLARES CANADIENSES'
Saludos.
User | Count |
---|---|
89 | |
7 | |
6 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.