-
Notifications
You must be signed in to change notification settings - Fork 5
Format amount in Orders #1091
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
base: development
Are you sure you want to change the base?
Format amount in Orders #1091
Conversation
… details, buy_tft & order_card
… amount and add approximation symbol
// User-friendly formatting based on amount size | ||
if (doubleAmount >= 1000) { | ||
// Large amounts: 2 decimal places max with thousand separators (e.g., 1,234.57) | ||
formatted = decimalAmount.toStringAsFixed(2); |
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.
You already have the number as a Decimal or double. But you convert it to a string, then parse it again just to format it.
Use a NumberFormat directly on the already-parsed number.
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.
Edited.
formatted = formatted.replaceAll(RegExp(r'\.$'), ''); | ||
// Remove trailing zeros after decimal point only (if any), but keep approximation symbol if present | ||
if (formatted.contains('.')) { | ||
formatted = formatted.replaceFirst(RegExp(r'(\.\d*?[1-9])0+\u001b'), r'$1\u001b'); |
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.
\u001b
is a Esc character, i don't understand its benefit to the regex.
Changes
Related Issues
Tested Scenarios
Included in transaction_helpers_test