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

refactor(deriv_ui): [DERG-3500] return inputted amount based on the formatter in numpad #624

Conversation

sagar-deriv
Copy link
Contributor

@sagar-deriv sagar-deriv commented Jun 20, 2024

Clickup link: https://app.clickup.com/t/20696747/DERG-2500

This PR contains the following changes:

  • Format the final return amount with the formater of that particular currency.
  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

Pre-launch Checklist (For PR creator)

As a creator of this PR:

  • ✍️ I have included clickup id and package/app_name in the PR title.
  • 👁️ I have gone through the code and removed any temporary changes (commented lines, prints, debug statements etc.).
  • ⚒️ I have fixed any errors/warnings shown by the analyzer/linter.
  • 📝 I have added documentation, comments and logging wherever required.
  • 🧪 I have added necessary tests for these changes.
  • 🔎 I have ensured all existing tests are passing.

Reviewers

@akhil-deriv

Pre-launch Checklist (For Reviewers)

As a reviewer I ensure that:

  • ✴️ This PR follows the standard PR template.
  • 🪩 The information in this PR properly reflects the code changes.
  • 🧪 All the necessary tests for this PR's are passing.

Pre-launch Checklist (For QA)

  • 👌 It passes the acceptance criteria.

Pre-launch Checklist (For Maintainer)

  • [MAINTAINER_NAME] I make sure this PR fulfills its purpose.

@sagar-deriv sagar-deriv changed the title refactor(deriv_ui): return inputted amount based on the formatter in numpad refactor(deriv_ui): [DERG-3500] return inputted amount based on the formatter in numpad Jun 20, 2024
(cherry picked from commit 0e679136c30a00b1e91f6ea06328d8e07d153186)
@sagar-deriv sagar-deriv force-pushed the DERG-2500/allow_only_2_decimals_for_fiat_currencies branch from dad45d2 to 1ff0feb Compare June 20, 2024 15:44
@sagar-deriv sagar-deriv requested review from akhil-deriv and removed request for waqas-younas-deriv June 21, 2024 07:39
@@ -40,6 +40,9 @@ class CurrencyDetail {
bool get isStableCurrency =>
stableCurrencies.contains(currencyType.toUpperCase());

/// This will give the final amount to do processing based on what type of currency it is like fiat or crypto currency.
double get finalAmount => double.parse(formatter.format(amount));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sagar-deriv Can we name it like formattedAmount?

Copy link
Contributor

@aliakbar-deriv aliakbar-deriv Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the doc comments to reflect the updated name.

@@ -54,9 +57,9 @@ class CurrencyDetail {
/// This will give a specific currency formatter based on what type of currency it is like fiat or crypto currency.
NumberFormat get formatter {
if (isFiat || isStableCurrency) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update the getter name isStableCurrency and the list name stableCurrencies? Using crypto instead of stable would be more accurate, as our currency types are fiat and crypto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's better. I will push the changes.

@@ -118,9 +118,9 @@ class ExchangeController extends ChangeNotifier {
/// what user send by default in primaryCurrency when coming to numpad.)
double finalAmount() {
Copy link
Contributor

@aliakbar-deriv aliakbar-deriv Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rename the double finalAmount() { .. method to formattedAmount()?

Copy link
Contributor Author

@sagar-deriv sagar-deriv Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case finalAmount is okay, because this is the final amount returned to the user. I will make the change and push for the other one in the CurrencyDetail class.

@sagar-deriv sagar-deriv force-pushed the DERG-2500/allow_only_2_decimals_for_fiat_currencies branch from 235fe96 to a37bd58 Compare June 24, 2024 14:45
@sagar-deriv sagar-deriv force-pushed the DERG-2500/allow_only_2_decimals_for_fiat_currencies branch from a37bd58 to 217bfa9 Compare June 24, 2024 14:48
@sagar-deriv sagar-deriv merged commit fdf4df1 into deriv-com:master Jun 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants