-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
fix: IOU - On entering amount with decimals, 3rd decimal 0 is added in IOU confirmation page. #44416
fix: IOU - On entering amount with decimals, 3rd decimal 0 is added in IOU confirmation page. #44416
Conversation
…n IOU confirmation page. Signed-off-by: Krishna Gupta <[email protected]>
@rayane-djouah Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Signed-off-by: Krishna Gupta <[email protected]>
Signed-off-by: Krishna Gupta <[email protected]>
@@ -125,7 +125,8 @@ function convertToDisplayString(amountInCents = 0, currency: string = CONST.CURR | |||
|
|||
// We are forcing the number of decimals because we override the default number of decimals in the backend for RSD | |||
// See: https://github.com/Expensify/PHP-Libs/pull/834 | |||
minimumFractionDigits: currency === 'RSD' ? getCurrencyDecimals(currency) : undefined, | |||
minimumFractionDigits: getCurrencyDecimals(currency), |
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.
@rayane-djouah, we also need to set minimumFractionDigits
, passing maximumFractionDigits
without minimumFractionDigits
crashes the app on android native. I believe we can simply use getCurrencyDecimals(currency),
since it returns the correct value for currencies and the max is 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.
Hmm, test is failing, I will check for other solutions tomorrow.
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.
Is there any reason for the crash on Android native? What error are you getting?
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.
@rayane-djouah, no error is shown, the app just closes without providing minimumFractionDigits
.
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.
Can you try to see in Android studios Logcat what error causes the app to crash?
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.
@rayane-djouah, sorry for delay, I tried but couldn't find Android studios Logcat
, I haven't used it till now, can you pls tell me where I can find it?
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.
Select View > Tool Windows > Logcat from the menu bar.
https://developer.android.com/studio/debug/logcat
https://developer.android.com/studio/debug/stacktraces
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 tried debugging the crash, but I saw no error.
Looks like this was faced before here: #43128 (comment)
the default for currency formatting is the larger of minimumFractionDigits and the number of minor unit digits provided by the ISO 4217 currency code list (2 if the list doesn't provide that information)
So it has the same behavior as getCurrencyDecimals
👍 We should be safe to use it instead of undefined
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.
Please apply the same fix here also :
Lines 167 to 184 in 51dd814
/** | |
* Acts the same as `convertAmountToDisplayString` but the result string does not contain currency | |
*/ | |
function convertToDisplayStringWithoutCurrency(amountInCents: number, currency: string = CONST.CURRENCY.USD) { | |
const convertedAmount = convertToFrontendAmountAsInteger(amountInCents); | |
return NumberFormatUtils.formatToParts(BaseLocaleListener.getPreferredLocale(), convertedAmount, { | |
style: 'currency', | |
currency, | |
// We are forcing the number of decimals because we override the default number of decimals in the backend for RSD | |
// See: https://github.com/Expensify/PHP-Libs/pull/834 | |
minimumFractionDigits: currency === 'RSD' ? getCurrencyDecimals(currency) : undefined, | |
}) | |
.filter((x) => x.type !== 'currency') | |
.filter((x) => x.type !== 'literal' || x.value.trim().length !== 0) | |
.map((x) => x.value) | |
.join(''); | |
} |
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.
Please update the test case for BHD to fix the failing test
Signed-off-by: krishna2323 <[email protected]>
@rayane-djouah, applied the fix for |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2024-07-09.at.10.40.13.PM.movAndroid: mWeb ChromeScreen.Recording.2024-07-09.at.10.43.48.PM.moviOS: NativeSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-07-09.at.22.31.21.mp4iOS: mWeb SafariSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-07-09.at.22.27.24.mp4MacOS: Chrome / SafariScreen.Recording.2024-07-09.at.10.23.37.PM.movMacOS: DesktopScreen.Recording.2024-07-09.at.10.44.39.PM.mov |
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.
Looks good!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/thienlnam in version: 9.0.7-3 🚀
|
🚀 Cherry-picked to staging by https://github.com/thienlnam in version: 9.0.7-4 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
🚀 Deployed to production by https://github.com/thienlnam in version: 9.0.7-8 🚀
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.0.8-6 🚀
|
Details
Fixed Issues
$ #43945
PROPOSAL: #43945 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
android_native.mp4
Android: mWeb Chrome
android_chrome.mp4
iOS: Native
ios_native.mp4
iOS: mWeb Safari
ios_safari.mp4
MacOS: Chrome / Safari
web_chrome.mp4
MacOS: Desktop
desktop_app.mp4