Repository navigation
Add sales tax calculation - #3
Open
marginsystems wants to merge 1 commit into
Open
marginsystems wants to merge 1 commit into
marginsystems wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Vortex: 1 issue to fix at 0112636 · 2/2 files reviewed
Actionable comment posted: 1
- 🟠 Important · `Math.round((amountCents * ratePercent) / 100)` ·
src/tax.js:2
🤖 Prompt for AI agents (1 finding)
Pull request mergestorm/sample-app#3: https://github.com/mergestorm/sample-app/pull/3 (head branch `tax`)
Verify each finding against current code. Fix only still-valid concrete bugs, skip the
rest with a brief reason, keep changes minimal, and validate. Skip Decision required,
policy forks, and "consider X" alternatives. Do not add new features, refactors, or
architecture beyond the fix; prefer the smallest diff.
Findings to address:
1. In `@src/tax.js` (line 2, Important):
Math.round breaks ties toward +Infinity, so a negative half-cent tax rounds toward zero: salesTax(-1, 50) returns -0 and salesTax(-3, 50) returns -1, while the positive case salesTax(1, 50) returns 1. This only matters if negative amounts (refunds or reversals) are passed in; if the order summary will handle them, pick an explicit half-away-from-zero rule and apply it to the sign separately.
| @@ -0,0 +1,3 @@ | |||
| export function salesTax(amountCents, ratePercent) { | |||
| return Math.round((amountCents * ratePercent) / 100); | |||
There was a problem hiding this comment.
🟠 Important
Math.round((amountCents * ratePercent) / 100)
Math.round breaks ties toward +Infinity, so a negative half-cent tax rounds toward zero: salesTax(-1, 50) returns -0 and salesTax(-3, 50) returns -1, while the positive case salesTax(1, 50) returns 1. This only matters if negative amounts (refunds or reversals) are passed in; if the order summary will handle them, pick an explicit half-away-from-zero rule and apply it to the sign separately.
🤖 Prompt for AI agents
Pull request mergestorm/sample-app#3: https://github.com/mergestorm/sample-app/pull/3 (head branch `tax`)
Verify each finding against current code. Fix only still-valid concrete bugs, skip the
rest with a brief reason, keep changes minimal, and validate. Skip Decision required,
policy forks, and "consider X" alternatives. Do not add new features, refactors, or
architecture beyond the fix; prefer the smallest diff.
In `@src/tax.js` (line 2, Important):
Math.round breaks ties toward +Infinity, so a negative half-cent tax rounds toward zero: salesTax(-1, 50) returns -0 and salesTax(-3, 50) returns -1, while the positive case salesTax(1, 50) returns 1. This only matters if negative amounts (refunds or reversals) are passed in; if the order summary will handle them, pick an explicit half-away-from-zero rule and apply it to the sign separately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sales tax in integer cents, rounded to the nearest cent. First layer of a two-PR change; the order summary builds on it.