Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Add overload to Number.ToWords() to not include "AND" #919

Closed
RubberChickenParadise opened this issue Apr 3, 2020 · 3 comments · Fixed by #985
Closed

[Request] Add overload to Number.ToWords() to not include "AND" #919

RubberChickenParadise opened this issue Apr 3, 2020 · 3 comments · Fixed by #985

Comments

@RubberChickenParadise
Copy link

I am working on an accounting application and need to print checks. Humanizer is the best library I have found but there is a small issue. When writing a check amount the value of 3051.82 should be "Three Thousand Fifty One and 82/100". currently I am using the following to build the value

$"{((int) Math.Floor(amount)).ToWords().ToUpper()} AND {((amount- Math.Floor(amount)) * 100).ToString("00")}/100";

However I need to add .Replace(" AND", "") becoming $"{((int) Math.Floor(amount)).ToWords().ToUpper().Replace(" AND", "")} AND {((amount- Math.Floor(amount)) * 100).ToString("00")}/100";

Having an overload that could control the additional AND in the string would be more reliable than using a replace after the fact.

I looked through the issues and haven't seen this addressed in the past.

@mr-aboutin
Copy link
Contributor

If I understant correctly, the convertion outpu from a number like 3051 return a string in the default english formater that write :Three Thousand and Fifty One while you want Three Thousand Fifty One by using an overload, is that correct?

@RubberChickenParadise
Copy link
Author

If I understant correctly, the convertion outpu from a number like 3051 return a string in the default english formater that write :Three Thousand and Fifty One while you want Three Thousand Fifty One by using an overload, is that correct?

Correct. Checks are normally written with the “and” between dollars and cents. So a check for $3051.87 would be translated as “three thousand fifty one and 87/100”.

Since I am not sure on conventions in other countries the overload to not include the “and” is the most universal way, then users could do what ever with the “three thousand fifty one”.

My thoughts were with an overload this could be applicable to all the languages that use similar constructs with a junction word along with the number words. Then languages with out the junction would just return the same output.

@mr-aboutin
Copy link
Contributor

I will see what I can do but and overload would actually be a good idea for this. I'll try to work on this during the week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants