Why is an English post about Moroccan invoices? Because the problem is not only Moroccan. Any invoice in French (France, Belgium, Switzerland, Morocco, Tunisia, Senegal and more) can be asked to carry "le montant en lettres": the total written out in words under the numbers. It is a rule many developers meet only when a client in one of those markets asks for it, and English-language libraries do not cover French spelling. I work in Morocco, so my examples use dirhams, but the same code works with euros or any other currency by changing the currency name.
Here is the line you need to produce: "Arrêtée la présente facture à la somme de mille deux cent cinquante dirhams et cinquante centimes".
What you get: the five French spelling rules that cause most bugs, a dependency-free TypeScript function (0 to 999 999 999.99), and a short list of tests to write.
Where this shows up in practice
LMOUKAWIL is a Moroccan platform for auto-entrepreneur invoicing.…