-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Enable Defining A Custom Thousand Separator Format #30
Enable Defining A Custom Thousand Separator Format #30
Conversation
When a date is surrounded by space, the date library fails to parse it This commit is to trim the date field before parsing date fields.
Java Script parseFloat method ignores comma when parsing a string number For some locales, the amount is written in format 1,234.56 The above will not parse correctly unless ynab-buddy was instructed with the correct separator format
…o nielsmaerten-main
…rge branch 'nielsmaerten-main' into feature/allow-custom-thousand-separator-for-amounts
Codecov Report
@@ Coverage Diff @@
## main #30 +/- ##
==========================================
+ Coverage 94.39% 94.57% +0.17%
==========================================
Files 10 10
Lines 857 884 +27
Branches 63 66 +3
==========================================
+ Hits 809 836 +27
Misses 46 46
Partials 2 2
Continue to review full report at Codecov.
|
Thanks for spotting this! I'll take a closer look at this later, but so far I've added another test in branch fix/parse-amounts. For backwards compatibility, we'll have to use the 'old' way of parsing when neither decimal nor thousand separators are defined though. |
Glad that it worked with all the new tests! And, of course, thanks for this great and useful repo ;) |
- Add a test that tries parsing amounts in a bunch of different formats - Clean up code style a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ahmedmsvb
I made a few minor changes:
- additional test to assert correct parsing of a bunch of different formats
- added the separator options to the default config file
- fallback to the original behavior if no separator is defined. this will allow existing users to upgrade without having to change their config file
- strip out non-number characters (eg "€ 1234.56" => "1234.56")
Looks more robust now. The decimals fallback is a good idea as long as it is mentioned in the docs |
Updated the docs: it now says leaving out the decimal separator isn't recommended. But that if you do skip it, the tool will try to "auto-detect" the separator. (Went with "auto-detect" bc I don't want the docs to be too technical). Since the settings for decimal and thousands separators will now appear in the default config file (the one that gets created when ynab-buddy runs for the first time), we can already be pretty sure people will fill in this value. |
Java Script parseFloat method ignores comma when parsing a string number
For some locales, the amount is written in format 1,234.56
The above will not parse correctly unless ynab-buddy was instructed with the correct separator format