Skip to content

Conversation

Manas23601
Copy link

@Manas23601 Manas23601 commented May 29, 2025

What does this PR change?

  • It adds a new text box and a button to apply conversion rate changes. Alternatively, one could call an exchange-rate API to do the conversion and update the allocations.
  • The rate parameter can accept floating point integers up to the 1/100000th position. No negative numbers are allowed.
  • DEFAULT_CURRENCY constant that can be set as any currency during deployment.

Code Workflow

The changes are as follows.

  • New rate parameter to the search query.
  • A side-effect that reads the value from the route updates an internal variable conversionRate. This variable, when changed calls another side effect, that calls the function applyConversionRate to multiply all the allocation resource values in allocationData with the conversion rate.
  • Another side effect is invoked when allocationData is changed calling setTotalData to update the TotalCost row.

Does this PR relate to any other PRs?

I got this with the new changes locally

image

I was expecting as is like the deployed demo

image

Note: The allocation item names do not match. "folding-at-home" is unfound

How will this PR impact users?

  • It will allow users to set the DEFAULT_CURRENCY as part of the setup during the build & deployment. Every time, a request is made without a currency parameter, it will use the DEFAULT_CURRENCY. The codebase ships with "USD" as default.

Does this PR address any GitHub or Zendesk issues?

How was this PR tested?

  • Locally
$ BASE_URL=https://demo.infra.opencost.io/model npx parcel serve src/index.html --no-cache

I set the default currency to "AED" in this deployment

image

Apply Rate Text Box and Button

image

Apply Rate in Action

image

Does this PR require changes to documentation?

  • Yes, Need to mention where DEFAULT_CURRENCY field can be set, which is in src/constants/defaults.js

Have you labeled this PR and its corresponding Issue as "next release" if it should be part of the next OpenCost release? If not, why not?

  • This is an enhancement. I'm not sure if this was part of the next release cycle.

@netlify
Copy link

netlify bot commented May 29, 2025

Deploy Preview for opencost-ui ready!

Name Link
🔨 Latest commit 157c760
🔍 Latest deploy log https://app.netlify.com/projects/opencost-ui/deploys/689cf6bac216b00008419676
😎 Deploy Preview https://deploy-preview-87--opencost-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Manas23601 Manas23601 changed the title Adding default_currency varible to use when no location parameter is … Adding default_currency variable in UI May 29, 2025
@Manas23601
Copy link
Author

@ameijer, can you review this?

@Manas23601
Copy link
Author

Ready for review

Manas23601 and others added 22 commits August 14, 2025 02:01
Signed-off-by: Manas Sivakumar <[email protected]>
for default currency it would start as 1.0

Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Ishaan Mittal <[email protected]>

Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Ishaan Mittal <[email protected]>

Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Alex Meijer <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Alex Meijer <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Alex Meijer <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Bumps [tspascoal/get-user-teams-membership](https://github.com/tspascoal/get-user-teams-membership) from 2 to 3.
- [Release notes](https://github.com/tspascoal/get-user-teams-membership/releases)
- [Commits](tspascoal/get-user-teams-membership@v2...v3)

---
updated-dependencies:
- dependency-name: tspascoal/get-user-teams-membership
  dependency-version: '3'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Bumps [@date-io/core](https://github.com/dmtrKovalenko/date-io) from 1.3.13 to 3.2.0.
- [Release notes](https://github.com/dmtrKovalenko/date-io/releases)
- [Commits](dmtrKovalenko/date-io@v1.3.13...v3.2.0)

---
updated-dependencies:
- dependency-name: "@date-io/core"
  dependency-version: 3.2.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
dependabot bot and others added 6 commits August 14, 2025 02:01
Bumps [@babel/core](https://github.com/babel/babel/tree/HEAD/packages/babel-core) from 7.26.8 to 7.28.0.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.28.0/packages/babel-core)

---
updated-dependencies:
- dependency-name: "@babel/core"
  dependency-version: 7.28.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Andreas Resch <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: VANSH SHARMA <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Christian Petersen <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
Signed-off-by: Manas Sivakumar <[email protected]>
@ameijer
Copy link
Member

ameijer commented Oct 2, 2025

@Manas23601 would you consider doing this calculation on the backend? we merged a bunch of currency conversion stuff in there

@Manas23601
Copy link
Author

Sure, I can do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants