You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
IOU - Allow only 2 decimal points in amount selector #6286
So looking through the code, I got this method called Mobile_GetConstants, sending the parameter currencyList, will return all the accepted currencies from Expensify.
That will have a JSON array with the name, symbol and some other properties. Some of them has a decimal: 0 property.
I guess we could add the decimals for all of the accepted currencies, with the amount of decimals accepted, and treat that on the frontend to deal with the information received from the backend. That way, if we add another currency with 5 decimal cases, we don't need to change anything in the app.
So, I'm working at the App for this. The logic implementation is almost done, but I just saw that we convert the value to an integer before sending it to the backend.
That means that the backend probably doesn't know where the decimal point is, and that could possibly break old.E.
I'll finish implementing it on new.E and check what happens in old.E.
Ok, now I'm seeing that we actually use * 100 or / 100 in multiple places when dealing with amount.
I think that the best case scenario for us would be to deal correctly with the decimal places for all currencies, but that would be a change in several places in our app code today, including venmo and paypal integrations. The development is not so extensive, but I think this would take a while for testing.
Yep. Looks like this would need changes in our integrations servers, and probably more places that I don't know the context yet.
Thinking about the ROI, since most of our customers are using currencies with only 2 decimal cases, I guess we could keep it with only 2 decimals for now and do a plan to change that in the future based on our expansion to other countries with that necessity.
Activity
MelvinBot commentedon Nov 12, 2021
Triggered auto assignment to @danieldoglas (
Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.rushatgabhane commentedon Nov 13, 2021
Proposal
In IOUAmountPage
Change regex to
/^\d+(,\d+)*(\.\d{0, 2})?$/And
toFixed(3)->toFixed(2)App/src/pages/iou/steps/IOUAmountPage.js
Lines 121 to 122 in 6701446
MelvinBot commentedon Nov 16, 2021
@danieldoglas Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
danieldoglas commentedon Nov 17, 2021
Will be working on this today
danieldoglas commentedon Nov 17, 2021
I don't think we can just change this to two decimal cases.
Jamaican and Kuwaiti Dinar, for example, as 3 decimal cases. @rushatgabhane @isagoico, do you guys think we need to treat them by each currency?
rushatgabhane commentedon Nov 17, 2021
Isn't the 3rd decimal ignored in the backend?
Yes, I agree.
danieldoglas commentedon Nov 19, 2021
Ok.
So looking through the code, I got this method called
Mobile_GetConstants, sending the parametercurrencyList, will return all the accepted currencies from Expensify.That will have a JSON array with the name, symbol and some other properties. Some of them has a
decimal: 0property.I guess we could add the decimals for all of the accepted currencies, with the amount of decimals accepted, and treat that on the frontend to deal with the information received from the backend. That way, if we add another currency with 5 decimal cases, we don't need to change anything in the app.
@rushatgabhane are you OK with that solution?
cc: @johnmlee101
rushatgabhane commentedon Nov 19, 2021
Yeah the array of currencies is known and kinda constant. So adding
decimalproperty to all is fine. Looks great 👍danieldoglas commentedon Nov 22, 2021
Working on it.
danieldoglas commentedon Nov 23, 2021
So, I'm working at the App for this. The logic implementation is almost done, but I just saw that we convert the value to an integer before sending it to the backend.
That means that the backend probably doesn't know where the decimal point is, and that could possibly break old.E.
I'll finish implementing it on new.E and check what happens in old.E.
danieldoglas commentedon Nov 23, 2021
Ok, now I'm seeing that we actually use
* 100or/ 100in multiple places when dealing with amount.I think that the best case scenario for us would be to deal correctly with the decimal places for all currencies, but that would be a change in several places in our app code today, including venmo and paypal integrations. The development is not so extensive, but I think this would take a while for testing.
Do you think the ROI is worth it @rushatgabhane?
cc: @johnmlee101
danieldoglas commentedon Nov 24, 2021
Yep. Looks like this would need changes in our integrations servers, and probably more places that I don't know the context yet.
Thinking about the ROI, since most of our customers are using currencies with only 2 decimal cases, I guess we could keep it with only 2 decimals for now and do a plan to change that in the future based on our expansion to other countries with that necessity.
danieldoglas commentedon Nov 25, 2021
I'll follow my gut here and keep it simple for now. I'll cancel my PR to libs for now too.