¿Cómo convertir números a texto en español?

¿Cómo convertir números a texto en español?

Ejemplo: convertir $500.000.- (escribo desde Chile donde utilizamos ese símbolo para el peso, y las cantidadades se separan de a miles por punto y no por coma).

Lo que tengo hasta el momento es lo siguiente, pero me funciona para transformar números del tipo 2345000 pero me falta agregar algo para que pueda utilizar la variable "cientos"... ¿me ayudan?

***tengo lo siguiente:

id = 5614234000022003000; /////este es un ejemplo
rec = zoho.crm.getRecordById("MODULO",id);
monto = rec.get("MONTO");
info monto;
th = {"","mil","millones","billón","trillón"};
// uncomment this line for English Number System
// th = {"","thousand","million", "milliard","billion"};
dg = {"cero","uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"};
tn = {"diez","once","doce","trece","catorce","quince","dieciséis","diecisiete","dieciocho","diecinueve"};
tw = {"veinte","treinta","cuarenta","cincuenta","sesenta","setenta","ochenta","noventa"};
tz = {"cien","doscientos","trescientos","cuatrocientos","quinientos","seiscientos","setecientos","ochocientos","novecientos"};
val_s = monto;
x = val_s.length();
info x;
if(x > 15)
{
info "too big";
}
else
{
s = val_s.replaceAll("(?)",",",false).removeFirstOccurence(",").removeLastOccurence(",").toList();
str = "";
sk = 1;
bypass = false;
for each index i in s
{
cur = s.get(i).toLong();
if(!bypass)
{
if((x - i) % 3 == 2)
{
if(cur == 1)
{
next = s.get(i + 1).toLong();
str = str + tn.get(next) + " ";
bypass = true;
sk = 1;
}
else if(cur != 0)
{
str = str + tw.get(cur - 2) + " ";
sk = 1;
}
}
else if(cur != 0)
{
str = str + dg.get(cur) + " ";
if((x - i) % 3 == 0)
{
str = str + "cientos ";
sk = 1;
}
}
}
else
{
bypass = false;
}
if((x - i) % 3 == 1)
{
if(sk != 0)
{
str = str + th.get(floor((x - i - 1) / 3)) + " ";
sk = 0;
}
}
}
info str;
}

    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方