+
Skip to content

fix: corrected the validation condition #6556

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

Conversation

shwetha263
Copy link
Contributor

if the amount was zero then node.amount would return false, hence changed the check to check for undefined.

Resolves #6507
Impact: minor
Type: bugfix

Issue

Conditional check was incorrect for the resolver. if the amount is 0 then the condition was resolved to false. iif the amount is undefined the condition has to be evaluated to false else for "0" amount also the condition must be evaluated as true.

Solution

Checking if the amount is not undefined and not empty.

Breaking changes

None

Testing

Tested the condition.

More detail for what each of these sections should include are available in our Contributing Docs. This project uses semantic-release, please use their commit message format..

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2022

🦋 Changeset detected

Latest commit: 83b158a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
reaction Patch
@reactioncommerce/api-plugin-surcharges Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@shwetha263 shwetha263 force-pushed the issue-6507-Surcharge-resolver-treats-amount-zero-als-falsy-value branch from d44f7a0 to fd38512 Compare October 13, 2022 17:54
@brent-hoover
Copy link
Collaborator

@shwetha263 Thanks for the fix. When we fix an issue like this I would really like to see a test covering it.

vanpho93
vanpho93 previously approved these changes Oct 14, 2022
@shwetha263 shwetha263 force-pushed the issue-6507-Surcharge-resolver-treats-amount-zero-als-falsy-value branch from a3e83d8 to 41a379b Compare October 14, 2022 07:36
@shwetha263
Copy link
Contributor Author

@vanpho93 @zenweasel : I added test case for create surcharges with amount 0 and undefined.
Let me know if this is ok .

@brent-hoover
Copy link
Collaborator

brent-hoover commented Oct 14, 2022

@shwetha263 Great, thanks so much. Please remember to add a changeset as well to bump the package version. https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md

@brent-hoover
Copy link
Collaborator

@shwetha263 also linting is failing now

@shwetha263 shwetha263 force-pushed the issue-6507-Surcharge-resolver-treats-amount-zero-als-falsy-value branch from 41a379b to 6147364 Compare October 14, 2022 07:43
@shwetha263
Copy link
Contributor Author

@shwetha263 also linting is failing now
@zenweasel
Have fixed it

brent-hoover
brent-hoover previously approved these changes Oct 14, 2022
@brent-hoover
Copy link
Collaborator

@shwetha263 Changeset being the last thing we need to bump the package https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md

@shwetha263
Copy link
Contributor Author

shwetha263 commented Oct 14, 2022

@shwetha263 Changeset being the last thing we need to bump the package
@zenweasel
https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md

Added the changeset with the summary. Let me know if i need to add more details.

Comment on lines 2 to 3
"reaction": major
"@reactioncommerce/api-plugin-surcharges": major
Copy link
Member

Choose a reason for hiding this comment

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

@zenweasel
Do you think these are correct bumps?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, a bug fix would just be a patch change.

@shwetha263 shwetha263 force-pushed the issue-6507-Surcharge-resolver-treats-amount-zero-als-falsy-value branch from bee49fb to a515479 Compare October 14, 2022 11:09
@brent-hoover
Copy link
Collaborator

@shwetha263 Thanks so much for this. Can you correct the changeset to just be a patch change? The semver standard would define a backwards compatible bug fix as just a patch change. Thanks again

@shwetha263 shwetha263 force-pushed the issue-6507-Surcharge-resolver-treats-amount-zero-als-falsy-value branch from a515479 to 0064f15 Compare October 14, 2022 12:54
@shwetha263
Copy link
Contributor Author

Hi @zenweasel
I have updated the change set.

if the amount was zero then node.amount would return false,
hence changed the check to check for undefined.

Signed-off-by: Shwetha Shashidhara <shwethaks263@gmail.com>
Test case added while creating the surcharge with amount 0 and undefined

Signed-off-by: Shwetha Shashidhara <shwethaks263@gmail.com>
Signed-off-by: Shwetha Shashidhara <shwethaks263@gmail.com>
Signed-off-by: Shwetha Shashidhara <shwethaks263@gmail.com>
Signed-off-by: Shwetha Shashidhara <shwethaks263@gmail.com>
Signed-off-by: Shwetha Shashidhara <shwethaks263@gmail.com>
Signed-off-by: Shwetha Shashidhara <shwethaks263@gmail.com>
@shwetha263 shwetha263 force-pushed the issue-6507-Surcharge-resolver-treats-amount-zero-als-falsy-value branch from 0064f15 to 83b158a Compare October 14, 2022 12:56
@brent-hoover brent-hoover merged commit 9273ec4 into reactioncommerce:trunk Oct 14, 2022
@github-actions github-actions bot mentioned this pull request Oct 14, 2022
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.

Surcharge resolver treats amount zero als falsy value
3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载