Numbers TO letters

Hello,

On the ticket I have by law to -also- print the total (TICKET TOTAL) in letters (twenty-two instead of 22).

So I have to transform numbers to letters.
I am thinking of using a ticket tag for that purpouse.

Now is there a simple way :slight_smile: to do it ?
I can do it if you guide me for the begining :), like how to extract the units, the tens, the hundreds.


Here are the text values for my localization:

**1,2,3, ...,20**
UNIDADES = { "", "UN ", "DOS ", "TRES ", "CUATRO ", "CINCO ", "SEIS ", "SIETE ", "OCHO ", "NUEVE ", "DIEZ ", "ONCE ", "DOCE ", "TRECE ", "CATORCE ", "QUINCE ", "DIECISEIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE", "VEINTE" };

**20,30, ..., 100**
DECENAS = { "VEINTI", "TREINTA ", "CUARENTA ", "CINCUENTA ", "SESENTA ", "SETENTA ", "OCHENTA ", "NOVENTA ", "CIEN " };

**100, ..., 900**
CENTENAS = { "CIENTO ", "DOSCIENTOS ", "TRESCIENTOS ", "CUATROCIENTOS ", "QUINIENTOS ", "SEISCIENTOS ", "SETECIENTOS ", "OCHOCIENTOS ", "NOVECIENTOS " };

The rules are quite simple:

  • 1 to 20, direct conversion
  • 2x : concatenate attached, e.g. 24 = VEINTICUATRO - That’s why there is no trailing space in the definition of VEINTI.
  • 30 to 99. Concatenate with " Y ", e.g. 49 = CUARENTA Y NUEVE
  • 100 = CIEN
  • 101 to 999, concatenate, e.g. 324 = TRESCIENTOS “24”
1 Like