Format amount in Orders#1091
Draft
zaelgohary wants to merge 3 commits intodevelopmentfrom
Draft
Conversation
… details, buy_tft & order_card
… amount and add approximation symbol
AlaaElattar
reviewed
Jun 22, 2025
| // 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); |
Contributor
There was a problem hiding this comment.
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.
AlaaElattar
reviewed
Jun 23, 2025
| 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'); |
Contributor
There was a problem hiding this comment.
\u001b is a Esc character, i don't understand its benefit to the regex.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Related Issues
Tested Scenarios
Included in transaction_helpers_test