Skip to content
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

Wrong scale for RUB currency #6519

Open
dtaipov opened this issue Oct 27, 2017 · 6 comments
Open

Wrong scale for RUB currency #6519

dtaipov opened this issue Oct 27, 2017 · 6 comments
Labels
bug For issues that describe a defect or regression in the released software good first issue For issues that a new contributor could likely submit a pull request for without needing much help help wanted For issues that have a clear solution described and are not currently prioritized core team work

Comments

@dtaipov
Copy link

dtaipov commented Oct 27, 2017

Prices in Russian rubles appears 100 times as much as their correct values.
For example, a price "$12.99 - $29.99" shows up in rubles like "75490 - 1 74284 руб."
Correct values should be "754,90 - 1 742,84 руб."

Reproduces on the main page and the product details pages.

Fixed this in local database by removing "scale: 0" property from meteor.Shops.currencies.RUB
with query: db.Shops.updateMany({}, {$unset: {"currencies.RUB.scale": ""}})

Versions:
Node: 6.11.0
NPM: 3.10.10
Meteor Node: 4.8.4
Meteor NPM: 4.6.1
Reaction CLI: 0.19.0
Reaction: 1.5.4
Reaction branch: master

@trojanh
Copy link
Contributor

trojanh commented Nov 23, 2019

@aldeed since we have deprecated currencies field in Shop, Can we close this as well?
ref: shop/simpleSchemas.js#L694

@aldeed
Copy link
Contributor

aldeed commented Nov 26, 2019

@trojanh The issue appears to still exist in the new api-utils package. It should be fixed there.

https://github.com/reactioncommerce/api-utils/blob/trunk/lib/CurrencyDefinitions.js#L365

@aldeed aldeed transferred this issue from reactioncommerce/reaction Nov 27, 2019
@aldeed aldeed added bug For issues that describe a defect or regression in the released software good first issue For issues that a new contributor could likely submit a pull request for without needing much help help wanted For issues that have a clear solution described and are not currently prioritized core team work labels May 1, 2020
@Manizuca
Copy link

The same thing happens with CLP (chilean peso), but in this case i cant remove scale = 0 since we don't use decimal places with money.
Do someone know the reason why price is multiplied by 100 when scale is 0?
https://github.com/reactioncommerce/api-utils/blob/5b32c0066cc93eb28155caa4507704d735694666/lib/formatMoney.js#L23

The same thing happens in reaction-admin (imports/utils/formatMoney.js#L23) and the component-library (package/src/utils/formatMoney.js#L23)

@rafeyshah
Copy link

Hi @dtaipov! :) Is there anyone assigned to this issue?

@gaurav21687
Copy link

Hey, i wanted to contribute to this issue.

@timepassers
Copy link

Hi @aldeed and team,

I’d like to work on this issue. Here’s my proposed approach:

Understand the problem:
Review the existing implementation of currency scaling in the relevant files, such as api-utils, reaction-admin, and component-library. Identify why scale: 0 leads to incorrect multiplication by 100 for RUB.

Analyze the fix:
Verify the previously mentioned solution (removing scale: 0 for RUB) and ensure it aligns with the intended behavior for other currencies. Update the logic in the formatMoney function or related utilities to handle edge cases like this appropriately.

Apply the fix:
Modify the code to ensure RUB prices display correctly with two decimal places (e.g., 754,90 руб. instead of 75490 руб.) without affecting other currencies.

Test thoroughly:
Add or update unit tests to verify that all currencies, including RUB and edge cases like CLP (Chilean Peso), are handled correctly. Perform manual testing if necessary.

Submit a pull request:
Document the changes in the pull request and reference this issue for context.

Please assign this issue to me. Let me know if there are any specific guidelines or preferred solutions to consider.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug For issues that describe a defect or regression in the released software good first issue For issues that a new contributor could likely submit a pull request for without needing much help help wanted For issues that have a clear solution described and are not currently prioritized core team work
Projects
None yet
Development

No branches or pull requests

7 participants