Decimal Amount into Text Words

Ever wonder how Acumatica converts that amount on a check into words? Acumatica provides a simple to use attribute called ToWordsAttribute for the conversion.

[PXUIField(DisplayName = "Cost in Words")]
public virtual string CostWords { get; set; }
public abstract class costWords : PX.Data.BQL.BqlString.Field { }

Behind the scenes, Acumatica defines the individual word elements in string arrays and then parses each numeric position into its word equivalent.

string[] less10 = new string[] {
string[] less20 = new string[] {
string[] less100 = new string[] {
string[] great100 = new string[] {
string is100 = "Hundred";
string space = " ";

The attribute parses the value to be presented via a FieldSelecting event defined within the attribute itself. The event handler uses Math functions to parse the number into a StringBuilder object, looking up the words from the arrays shown above. When the whole number portion has been parsed, the “cents” are returned as the common fractional format over 100.

The result returned by the attribute is a number such as 1,346.78 being converted into One Thousand Three Hundred Forty Six and 78/100. While this is commonly used for printing checks, you may find yourself in need of such a service elsewhere. And now you know. Happy coding!

Leave a Reply