lunes, 27 de enero de 2020
Número a letra
PROCEDURE GF_ConvertAmountToWords(cAmount=0)
//Declaro variables locales
sCurrency is string
sTempString is string = ""
sReturnString is string = ""
IF (IntegerPart(cAmount)) = 1 THEN
sCurrency = "Peso"
ELSE
sCurrency = "Pesos"
END
//Construyo texto - parte entera primero
sTempString = GF_ConvierteEnteroaTexto(IntegerPart(cAmount))
IF sTempString <> "" THEN
sTempString = sTempString +" " + sCurrency + " "
ELSE
sTempString=""
END
sReturnString = sTempString
//Construyo texto - parte decimal
sTempString = NumToString((DecimalPart(cAmount)*100),"02d")
sTempString += "/100 M.N."
sReturnString += sTempString
//Regreso resultado
RESULT sReturnString
************************************************************************
PROCEDURE GF_ConvierteEnteroaTexto(iInteger)
//The best data type to feed in is a WD Integer
//Declare local variables
sTempString is string = ""
sNewString is string = ""
sReturnString is string = ""
bAgregaY is boolean
//Cast incoming integer to currency type for higher accuracy on decimals
cIntegerAsCurrency is currency = iInteger
//Reviso para valor 0
IF cIntegerAsCurrency = 0 THEN
sReturnString = "Cero "
RESULT sReturnString
END
//maximo tamaño
IF cIntegerAsCurrency > Power(10,15) THEN
sReturnString = "***ERROR - Numero muy grande para convertir a letras***"
RESULT sReturnString
END
//Billón
IF cIntegerAsCurrency >= Power(10,12) THEN
sNewString = GF_ConvierteEnteroaTexto(IntegerPart(cIntegerAsCurrency / Power(10,12)))
IF IntegerPart(cIntegerAsCurrency / Power(10,12)) = 1 THEN
sTempString += sNewString + "Billón "
ELSE
sTempString += sNewString + "Billones "
END
cIntegerAsCurrency = cIntegerAsCurrency - (IntegerPart(cIntegerAsCurrency / Power(10,12)) * Power(10,12))
END
//miles de millones
IF cIntegerAsCurrency >= Power(10,9) THEN
sNewString = GF_ConvierteEnteroaTexto(IntegerPart(cIntegerAsCurrency / Power(10,9)))
cIntegerAsCurrency = cIntegerAsCurrency -(IntegerPart(cIntegerAsCurrency / Power(10,9)) * Power(10,9))
sTempString += sNewString + "Mil "
END
//millones
IF cIntegerAsCurrency >= Power(10,6) THEN
sNewString = GF_ConvierteEnteroaTexto(IntegerPart(cIntegerAsCurrency / Power(10,6)))
IF IntegerPart(cIntegerAsCurrency / Power(10,6)) = 1 THEN
sTempString += sNewString + "Millón "
ELSE
sTempString += sNewString + "Millones "
END
cIntegerAsCurrency = cIntegerAsCurrency -(IntegerPart(cIntegerAsCurrency / Power(10,6)) * Power(10,6))
END
//miles
IF cIntegerAsCurrency >= Power(10,3) THEN
sNewString = GF_ConvierteEnteroaTexto(IntegerPart(cIntegerAsCurrency / Power(10,3)))
cIntegerAsCurrency = cIntegerAsCurrency - (IntegerPart(cIntegerAsCurrency / Power(10,3)) * Power(10,3))
sTempString += sNewString + "Mil "
END
//cientos
IF cIntegerAsCurrency >= Power(10,2) THEN
sNewString = GF_ConvierteEnteroaTexto(IntegerPart(cIntegerAsCurrency / Power(10,2)))
SWITCH (IntegerPart(cIntegerAsCurrency / Power(10,2)))
CASE 1: sTempString += "Ciento "
CASE 2: sTempString += "Doscientos "
CASE 3: sTempString += "Trecientos "
CASE 4: sTempString += "Cuatrocientos "
CASE 5: sTempString += "Quinientos "
CASE 6: sTempString += "Seiscientos "
CASE 7: sTempString += "setecientos "
CASE 8: sTempString += "Ochocientos "
CASE 9: sTempString += "Novecientos "
END
cIntegerAsCurrency = cIntegerAsCurrency -(IntegerPart(cIntegerAsCurrency / Power(10,2)) * Power(10,2))
END
//para 30 a 100
IF cIntegerAsCurrency >= 30 THEN
SWITCH (IntegerPart(cIntegerAsCurrency / 10))
CASE 3: sTempString += "Treinta "
CASE 4: sTempString += "Cuarenta "
CASE 5: sTempString += "Cincuenta "
CASE 6: sTempString += "Sesenta "
CASE 7: sTempString += "Setenta "
CASE 8: sTempString += "Ochenta "
CASE 9: sTempString += "Noventa "
END
cIntegerAsCurrency = cIntegerAsCurrency - (IntegerPart(cIntegerAsCurrency / 10) * 10)
bAgregaY = True
ELSE
bAgregaY = False
END
//para 1 a 29
IF cIntegerAsCurrency > 0 AND cIntegerAsCurrency <= 29 THEN
IF bAgregaY = True THEN
sTempString += "y "
END
SWITCH cIntegerAsCurrency
CASE 1: sTempString += " Un "
CASE 2: sTempString += " Dos "
CASE 3: sTempString += "Tres "
CASE 4: sTempString += "Cuatro "
CASE 5: sTempString += "Cinco "
CASE 6: sTempString += "Seis "
CASE 7: sTempString += "Siete "
CASE 8: sTempString += "Ocho "
CASE 9: sTempString += "Nueve "
CASE 10: sTempString += "Diez "
CASE 11: sTempString += "Once "
CASE 12: sTempString += "Doce "
CASE 13: sTempString += "Trece "
CASE 14: sTempString += "Catorce "
CASE 15: sTempString += "Quince "
CASE 16: sTempString += "Dieciseis "
CASE 17: sTempString += "Diecisiete "
CASE 18: sTempString += "Dieciocho "
CASE 19: sTempString += "Diecinueve "
CASE 20: sTempString += "Veinte "
CASE 21: sTempString += "Veintiun "
CASE 22: sTempString += "Veintidos "
CASE 23: sTempString += "Veintitres "
CASE 24: sTempString += "Veinticuatro "
CASE 25: sTempString += "Veinticinco "
CASE 26: sTempString += "Veintiseis "
CASE 27: sTempString += "Veintisiete "
CASE 28: sTempString += "Veintiocho "
CASE 29: sTempString += "Veintinueve "
END
cIntegerAsCurrency = cIntegerAsCurrency - (IntegerPart(cIntegerAsCurrency / 10) * 10)
END
//Paso string con número en letras
sReturnString = sTempString
RESULT sReturnString
Suscribirse a:
Entradas (Atom)
Try catch end
// -------------------------------------------------- // Procedure principal que executa uma query com tratamento de exceção // -----------...
-
Una guía paso a paso para los perplejos: Presione la tecla de Windows Escribe " intl.cpl " y presiona Enter....
-
MyWorksheet is xlsDocument xlsAddWorksheet(MyWorksheet, "R04_C-0451") //MyWorksheet = xlsOpen(sNombreArchivoXLS, xlsWrite) ...
-
Copiado del blog de mi amigo Francisco Carabez En caso de que no se cuenta con la contraseña del HFSQL Control Center: Respalda o copia e...