Skip to content

Add sales tax calculation - #3

Open
marginsystems wants to merge 1 commit into
mg-stack-1from
tax
Open

marginsystems wants to merge 1 commit into
mg-stack-1from
tax

Conversation

@marginsystems

Copy link
Copy Markdown
Contributor

Sales tax in integer cents, rounded to the nearest cent. First layer of a two-PR change; the order summary builds on it.

@mergestorm-surge
mergestorm-surge Bot changed the base branch from main to mg-stack-1 November 24, 2026 11:23

@mergestorm-vortex mergestorm-vortex Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Auto land this PR in Mergestorm


Mergestorm: 30 free reviews a month

Comment thread src/tax.js
@@ -0,0 +1,3 @@
export function salesTax(amountCents, ratePercent) {
return Math.round((amountCents * ratePercent) / 100);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 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.

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.

1 participant