AnsweredAssumed Answered

Help: number to text (with a twist)

Question asked by DenisPlesnar on Sep 4, 2013
Latest reply on Sep 24, 2013 by DenisPlesnar

Title

Help: number to text (with a twist)

Post

     Hi,

     First, as a short introduction: I'm from Croatia, and I've been using FileMaker for years, mostly customising ready-made templates and solutions, but I managed to make several relatively complicated solutions which I use regularly - one of those is an invoicing solution.

     Recently our local regulations have changed, and now we also need to state the invoice amount in text :(
     So, I'm looking for a "number to text" solution - but for Croatian language, which means that I need to adjust and change the available solution, here:

http://help.filemaker.com/app/answers/detail/a_id/2860/~/converting-numbers-to-words-or-numbers-to-text

     This solution works fine for English language, but, unfortunately, Croatian is a bit more complicated, since different numbers have different endings.

     My problem is that I need different endings for different parts of numbers, for Croatian currency (dollar="kuna", and cent="lipa"):

endings for thousands:

     1 - tisucA (e.g. 31.000 = "thirty one tisucA")

     2, 3, 4 - tisucE (e.g. 22.000 = "twenty two tisucE")

     5, 6, 7, 8, 9 - tisucA (e.g. 45.000 = "forty five tisucA"

     range from 11.000 to 19.000 is always "tisucA", e.g. 19.000 = "nineteen tisuca"

endings for single digits:

     1 - kunA ( e.g. 1 = one kuna)

     2,3,4 - kunE (e.g. 23 = twenty three kune)

     5,6,7,8,9 - kunA (e.g. 25 = twenty five kuna)

     but, for the range from 10 to 20 (i.e. 11-19), the ending is always "kunA", e.g. 13 = "thirteen kuna"

     I have already solved the "cents" portion (which in Croatian is "lipa"), as follows:

("TxtPrih_BRU" is the number (amount) field converted to text - in order to use text functions..., formatted as "1234,56" or "1235,00" , where comma is the decimal point, and the function part below operates on the two decimals after the comma)

     ....

&
If(Mod(Int(TxtPrih_BRU*10); 10) = 1;
Choose(Mod(Int(TxtPrih_BRU*100); 10); "deset"; "jedanaest"; "dvanaest"; "trinaest"; "četrnaest"; "petnaest"; "šesnaest"; "sedamnaest"; "osamnaest"; "devetnaest");
Choose(Mod(Int(TxtPrih_BRU*10); 10); ""; ""; "dvadeset"; "trideset"; "četrdeset"; "pedeset"; "šezdeset"; "sedamdeset"; "osamdeset"; "devedeset")
&
Choose(Mod(Int(TxtPrih_BRU*100); 10); "nula"; "jedna"; "dvije"; "tri"; "četiri"; "pet"; "šest"; "sedam"; "osam"; "devet"))
&
Case(Right(GetAsText(TxtPrih_BRU); 1) = "0"; " lipa";Right(GetAsText(TxtPrih_BRU); 1) = "2"; " lipe"; Right(GetAsText(TxtPrih_BRU); 1) = "3"; " lipe"; Right(GetAsText(TxtPrih_BRU); 1) = "4"; " lipe"; " lipa")

     That was relatively easy - but now I'm stuck on "dollars" ("kuna") part, and the thousands part (tisuća/tisuće/tisuća  as explained above).

     I hope I've explained the problem, and also hope that someone can shed some light on how best to approach this problem...

     TIA,

     Denis

Outcomes