Change
How can change number to text. For example amount in invoice is 5000usd . I will see text too in down invoice. Five thousand dollars
70 replies
-
Also, please delete the line you added at the top of your screenshot.
-
It is seem correct and worked. I think in point have problem
Please see picture
-
For some reason the user defined function is truncating the "0". If the formula is used by itself, not as a function, it works. I'll try to figure it out later tonight. Gotta go to work now.
-
thank you
-
Do you want it as 50/100 or Fifty Cents?
-
I just did both and I changed my field name to Net so you don't have to change anything.
This is the code for Cents Fraction:
let empty := "";
let x := [empty, "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen "];
let y := [empty, empty, "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety "];
"/* ";
" * User defined functions";
" */ ";
function mod(dividend : number,divisor : number) do
dividend - divisor * floor(dividend / divisor)
end;
function numberToWord(num : number,suffix : text) do
if floor(num) != 0 then
if num > 19 then
item(y, floor(num / 10)) + item(x, mod(num, 10)) + suffix
else
item(x, num) + suffix
end
else
empty
end
end;
"/* ";
" * Main program";
" */ ";
"// Number to be converted to words";
let numAmount := Net;
"// Test for number of digits";
if length(format(floor(numAmount), "0")) < 11 then
"// String to store word representation of given number";
let NtW := "";
"// This handles Cents";
if contains(text(numAmount), ".") then
let dpIndex := index(text(numAmount), ".");
NtW := "and " + substr(text(numAmount), dpIndex + 1, 2) + "/100 usd"
end;
"// This handles digits at Ones and Tens place";
NtW := numberToWord(mod(numAmount, 100), "") + NtW;
"// This handles digit at Hundreds place";
NtW := numberToWord(mod(numAmount / 100, 10), "Hundred ") + NtW;
"// This handles digits at One Thousands and Ten Thousands place";
NtW := numberToWord(mod(numAmount / 1000, 100), "Thousand ") + NtW;
"// This handles digit at Hundred Thousands place";
NtW := numberToWord(mod(numAmount / 100000, 10), "Hundred ") + NtW;
"// This handles digits at One Millions and Ten Millions place";
NtW := numberToWord(mod(numAmount / 1000000, 100), "Million ") + NtW;
"// This handles digit at Hundred Millions place";
NtW := numberToWord(mod(numAmount / 100000000, 10), "Hundred ") + NtW;
"// This handles digit at One Billions place";
NtW := numberToWord(mod(numAmount / 1000000000, 10), "Billion ") + NtW;
NtW
else
"Number is too large"
end -
This is the code for Cents Words:
let empty := "";
let x := [empty, "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen "];
let y := [empty, empty, "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety "];
"/* ";
" * User defined functions";
" */ ";
function mod(dividend : number,divisor : number) do
dividend - divisor * floor(dividend / divisor)
end;
function numberToWord(num : number,suffix : text) do
if floor(num) != 0 then
if num > 19 then
item(y, floor(num / 10)) + item(x, mod(num, 10)) + suffix
else
item(x, num) + suffix
end
else
empty
end
end;
"/* ";
" * Main program";
" */ ";
"// Number to be converted to words";
let numAmount := Net;
"// Test for number of digits";
if length(format(floor(numAmount), "0")) < 11 then
"// String to store word representation of given number";
let NtW := "";
"// This handles Cents";
if contains(text(numAmount), ".") then
let dpIndex := index(text(numAmount), ".");
let numCents := number(substr(text(numAmount), dpIndex + 1, 2));
NtW := "and " + numberToWord(mod(numCents, 100), "Cents") + " usd"
end;
"// This handles digits at Ones and Tens place";
NtW := numberToWord(mod(numAmount, 100), "") + NtW;
"// This handles digit at Hundreds place";
NtW := numberToWord(mod(numAmount / 100, 10), "Hundred ") + NtW;
"// This handles digits at One Thousands and Ten Thousands place";
NtW := numberToWord(mod(numAmount / 1000, 100), "Thousand ") + NtW;
"// This handles digit at Hundred Thousands place";
NtW := numberToWord(mod(numAmount / 100000, 10), "Hundred ") + NtW;
"// This handles digits at One Millions and Ten Millions place";
NtW := numberToWord(mod(numAmount / 1000000, 100), "Million ") + NtW;
"// This handles digit at Hundred Millions place";
NtW := numberToWord(mod(numAmount / 100000000, 10), "Hundred ") + NtW;
"// This handles digit at One Billions place";
NtW := numberToWord(mod(numAmount / 1000000000, 10), "Billion ") + NtW;
NtW
else
"Number is too large"
end -
For anyone who is interested in output of the mod() function here is a mockup spreadsheet:
-
yes, it is correct, Ninox is best programs i've ever seen. really thank you.
-
i am testing the formula for all numbers.
-
You’re welcome. I agree Ninox is pretty amazing. It’s going to be interesting to see what areas they focused on when they release the next update.
-
I tested them, there is one problem on 19,175usd. Result is : nine thousand one hundred seventy five. While should be :nineteen not nine.
also i tested on 19000usd and result was correct (nineteen)
-
This should take care of that problem. It also checks for 0 cents so the "and" won't be displayed in that case.
let empty := "";
let x := [empty, "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen "];
let y := [empty, empty, "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety "];
"/* ";
" * User defined functions";
" */ ";
function mod(dividend : number,divisor : number) do
dividend - divisor * floor(dividend / divisor)
end;
function numberToWord(num : number,suffix : text) do
if floor(num) != 0 then
if floor(num) > 19 then
item(y, floor(num / 10)) + item(x, mod(num, 10)) + suffix
else
item(x, num) + suffix
end
else
empty
end
end;
"/* ";
" * Main program";
" */ ";
"// Number to be converted to words";
let numAmount := Net;
"// Test for number of digits";
if length(format(floor(numAmount), "0")) < 11 then
"// String to store word representation of given number";
let NtW := "";
"// This handles Cents";
if contains(text(numAmount), ".") then
let dpIndex := index(text(numAmount), ".");
let numCents := number(substr(text(numAmount), dpIndex + 1, 2));
if numCents > 0 then
NtW := "and " + numberToWord(mod(numCents, 100), "Cents") + " usd"
else
NtW := "usd"
end
end;
"// This handles digits at Ones and Tens place";
NtW := numberToWord(mod(numAmount, 100), "") + NtW;
"// This handles digit at Hundreds place";
NtW := numberToWord(mod(numAmount / 100, 10), "Hundred ") + NtW;
"// This handles digits at One Thousands and Ten Thousands place";
NtW := numberToWord(mod(numAmount / 1000, 100), "Thousand ") + NtW;
"// This handles digit at Hundred Thousands place";
NtW := numberToWord(mod(numAmount / 100000, 10), "Hundred ") + NtW;
"// This handles digits at One Millions and Ten Millions place";
NtW := numberToWord(mod(numAmount / 1000000, 100), "Million ") + NtW;
"// This handles digit at Hundred Millions place";
NtW := numberToWord(mod(numAmount / 100000000, 10), "Hundred ") + NtW;
"// This handles digit at One Billions place";
NtW := numberToWord(mod(numAmount / 1000000000, 10), "Billion ") + NtW;
NtW
else
"Number is too large"
end -
yes, this is correct. thank you.
-
thank for this post it,s wery handy and helpful. jus wondering is it posible to make this formula to spelll number to nearest cent.
ex (Two Thousand Nine Hundred Thirteen Euro and Fifty Seven Cents )
-
The last code post on page 4 does this (next to last post).
-
This code adjusts for Euros and tests for 0.00
let empty := "";
let x := [empty, "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine ", "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen "];
let y := [empty, empty, "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety "];
"/* ";
" * User defined functions";
" */ ";
function mod(dividend : number,divisor : number) do
dividend - divisor * floor(dividend / divisor)
end;
function numberToWord(num : number,suffix : text) do
if floor(num) != 0 then
if floor(num) > 19 then
item(y, floor(num / 10)) + item(x, mod(num, 10)) + suffix
else
item(x, num) + suffix
end
else
empty
end
end;
"/* ";
" * Main program";
" */ ";
"// Number to be converted to words";
let numAmount := Net;
"// Test for number of digits";
if length(format(floor(numAmount), "0")) < 11 then
"// String to store word representation of given number";
let NtW := "";
"// This handles Cents";
if contains(text(numAmount), ".") then
let dpIndex := index(text(numAmount), ".");
let numCents := number(substr(text(numAmount), dpIndex + 1, 2));
if floor(numAmount) > 0 then NtW := "and " end;
if numCents > 0 then
NtW := NtW + numberToWord(mod(numCents, 100), "Cents")
else
if floor(numAmount) > 0 then
NtW := NtW + "no Cents"
else
NtW := ""
end
end
end;
if floor(numAmount) > 0 then NtW := "Euro " + NtW end;
"// This handles digits at Ones and Tens place";
NtW := numberToWord(mod(numAmount, 100), "") + NtW;
"// This handles digit at Hundreds place";
NtW := numberToWord(mod(numAmount / 100, 10), "Hundred ") + NtW;
"// This handles digits at One Thousands and Ten Thousands place";
NtW := numberToWord(mod(numAmount / 1000, 100), "Thousand ") + NtW;
"// This handles digit at Hundred Thousands place";
NtW := numberToWord(mod(numAmount / 100000, 10), "Hundred ") + NtW;
"// This handles digits at One Millions and Ten Millions place";
NtW := numberToWord(mod(numAmount / 1000000, 100), "Million ") + NtW;
"// This handles digit at Hundred Millions place";
NtW := numberToWord(mod(numAmount / 100000000, 10), "Hundred ") + NtW;
"// This handles digit at One Billions place";
NtW := numberToWord(mod(numAmount / 1000000000, 10), "Billion ") + NtW;
NtW
else
"Number is too large"
end -
Good evening.
I have tried this formula unfortunately it only spells the amount without cent can this be an issue because of wrong decimals as at the moment my separation is a , ant formula only understands numbers as cents after . ?
-
Yes, the current code checks for "." as the decimal separator. What symbol do you use for the thousands separator? How many digits to the right of the decimal separator do you use?
-
Also, do you use Euro or Euros for more than 1?
-
Good day,
At the moment i use Euro. I use two decimas. fot thausand seperator i use "," but i supose that ninox takes that from macbook setings. i changed the seperator sign in formula and it works well now. just wondering is is posible to show thausiand hundres etc in words and cents in numbers ex (Two thausiand eight huntret thirty euro and 57 cent ). as in my countrys ammount in words should be in this order.
-
Hello,
Would you please post the formula you use to produce the number with comma decimal separator. I tried to do it with the format() function and it's not working.
-
Can't see the forest for the trees department... Since Ninox does not store numbers with a "," as a decimal separator, you would be converting from a number that already exists in your database, right? You could just use that number in the Number to Words code. If it is the result of a calculation, you can just change:
let numAmount := Net;
to: let numAmount := yourCalculation
-
@slowwagon
For "Total to Words" I'm using -> let numAmount := 'Invoice Total';
For "Total to Words cents" I'm using -> let numAmount := Subtotal + 'Tax Amount' - 'Discount €' + Shipping;
Thanks for sharing!
Nick
-
Hi Nick,
I'm happy to contribute. Do the non-English versions of Ninox allow the storage of numbers using "," as the decimal separator? If so, what is the thousands, or grouping, separator? If the grouping separator is not the same as the decimal separator, it should be an easy fix. Otherwise, I'll need to figure out a different way to separate integers from decimals.
The most recent version of the code is posted on page 5 and it does not display cents as a fraction. Also, what is more common Euro or Euros for plural? I did search on that topic and there does not appear to be a consensus in that regard. I'll be driving most of the day so I won't be able to respond until later.
Sean
Content aside
-
2
Likes
- 4 mths agoLast active
- 70Replies
- 16594Views
-
1
Following