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

fix(common): fix currencyCode in CurrencyPipe #40505

Closed
wants to merge 1 commit into from
Closed

fix(common): fix currencyCode in CurrencyPipe #40505

wants to merge 1 commit into from

Conversation

vmohir
Copy link
Contributor

@vmohir vmohir commented Jan 21, 2021

When providing DEFAULT_CURRENCY_CODE, it's expected that the CurrenyPipe would pass it as currencyCode to formatCurrency function.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Currently providing the DEFAULT_CURRENCY_CODE changes the symbol that's being displayed but it's not used inside the formatCurrency function for getting the minFrac (link to source code), therefore the default value (USD) is being used. So as an example, despite providing { provide: DEFAULT_CURRENCY_CODE, useValue: 'IRR' }, the code {{ 1000 | currency }} will result in 1,000.00 but it should be 1,000 based on this line

What is the new behavior?

With this change, the provided value for DEFAULT_CURRENCY_CODE will be passed as currencyCode to formatCurrency function.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@google-cla google-cla bot added the cla: yes label Jan 21, 2021
@pullapprove pullapprove bot requested a review from mhevery January 21, 2021 13:24
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Thanks for this PR - this fix looks sound.
Could you please provide a unit test for this functionality by adding an it clause to the describe block at

describe('CurrencyPipe', () => {

@petebacondarwin petebacondarwin added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: review The PR is still awaiting reviews from at least one requested reviewer area: common Issues related to APIs in the @angular/common package area: i18n target: patch This PR is targeted for the next patch release labels Jan 21, 2021
@ngbot ngbot bot added this to the Backlog milestone Jan 21, 2021
@vmohir vmohir changed the title fix(currencyPipe): set currencyCode from injected value fix(common): fix currencyCode in CurrencyPipe Jan 21, 2021
@vmohir
Copy link
Contributor Author

vmohir commented Jan 21, 2021

Done.
@petebacondarwin

Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Thanks for adding the test.

packages/common/test/pipes/number_pipe_spec.ts Outdated Show resolved Hide resolved
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Thanks @gvmohzibat - we are getting there. Just a couple more tweaks.

packages/common/test/pipes/number_pipe_spec.ts Outdated Show resolved Hide resolved
@mhevery mhevery added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 4, 2021
@mhevery
Copy link
Contributor

mhevery commented Mar 4, 2021

presubmit

@AndrewKushnir AndrewKushnir added the action: presubmit The PR is in need of a google3 presubmit label Mar 6, 2021
@google-cla
Copy link

google-cla bot commented Mar 6, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@petebacondarwin
Copy link
Member

@googlebot I consent.

@AndrewKushnir
Copy link
Contributor

Global Presubmit (internal-only link).

@AndrewKushnir
Copy link
Contributor

Quick update after running tests in Google's codebase: this change is causing some internal tests to fail and more investigation is needed, so I'm adding the "blocked" label for now. We'll perform further investigation and keep this thread updated. Thank you.

@google-cla google-cla bot added the cla: yes label May 31, 2021
@vmohir
Copy link
Contributor Author

vmohir commented May 31, 2021

I'm not sure if I correctly rebased it. But I think it's good.

@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer action: presubmit The PR is in need of a google3 presubmit and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels May 31, 2021
Copy link
Contributor

@jessicajaniuk jessicajaniuk left a comment

Choose a reason for hiding this comment

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

LGTM 🍪

@AndrewKushnir
Copy link
Contributor

AndrewKushnir commented Jun 1, 2021

Presubmit #2 + Global presubmit.

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker and removed action: presubmit The PR is in need of a google3 presubmit action: review The PR is still awaiting reviews from at least one requested reviewer action: merge The PR is ready for merge by the caretaker labels Jun 2, 2021
currencyCode should be initialized with the injected default currency code
@AndrewKushnir AndrewKushnir added the action: merge The PR is ready for merge by the caretaker label Jun 2, 2021
jessicajaniuk pushed a commit that referenced this pull request Jun 3, 2021
currencyCode should be initialized with the injected default currency code

PR Close #40505
@vmohir vmohir deleted the patch-1 branch June 22, 2021 10:13
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: common Issues related to APIs in the @angular/common package area: i18n cla: yes target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants