-
Notifications
You must be signed in to change notification settings - Fork 72
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
Feat: accounting notation for fmt_number()
, fmt_percent()
, fmt_integer()
and fmt_currency()
#513
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #513 +/- ##
==========================================
+ Coverage 88.91% 88.93% +0.02%
==========================================
Files 44 44
Lines 5212 5222 +10
==========================================
+ Hits 4634 4644 +10
Misses 578 578 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
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.
I left one suggestion for a minor tweak to the docstring language, but feel free to take or leave it! (not the language is repeated in several places)
@@ -108,6 +109,9 @@ def val_fmt_number( | |||
The `use_seps` option allows for the use of digit group separators. The type of digit group | |||
separator is set by `sep_mark` and overridden if a locale ID is provided to `locale`. This | |||
setting is `True` by default. | |||
accounting | |||
An option to use accounting style for values. Normally, negative values will be shown with a |
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.
WDYT of changing these docstrings to something like "Whether to use accounting style, which wraps negative numbers in parentheses instead of using a minus sign."
<tr> | ||
<td class="gt_row gt_right">−1.20</td> | ||
<td class="gt_row gt_right">−5.23%</td> | ||
<td class="gt_row gt_right">2,323</td> |
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.
It seems like this is not testing that fmt_integer uses accounting format on negative numbers
This introduces the
accounting=
arg tofmt_number()
,fmt_percent()
,fmt_integer()
andfmt_currency()
, allowing for accounting notation (e.g.,"-343.27"
->"(343.27)"
. This new functionality also extends to the same formatters in thevals
module.Here is an example table demonstrating usage:
Fixes: #278