Skip to content

Add shipping cost calculation - #2

Open
marginsystems wants to merge 1 commit into
mainfrom
shipping
Open

marginsystems wants to merge 1 commit into
mainfrom
shipping

Conversation

@marginsystems

Copy link
Copy Markdown
Contributor

Orders of $50 or more ship free, as the checkout page promises. Smaller orders pay a $4.99 base rate plus $1.50 per started kilogram.

@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: 2 issues to fix at 1f08d9d · 2/2 files reviewed

Actionable comments posted: 2

🤖 Prompt for AI agents (2 findings)
Pull request mergestorm/sample-app#2: https://github.com/mergestorm/sample-app/pull/2 (head branch `shipping`)

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/shipping.js` (line 6, Important):
   The description promises free shipping for orders of $50 or more, but the strict `>` charges shipping on an order of exactly 5000 cents. Any caller that passes a $50.00 subtotal gets the $4.99 base rate. Use `>=`, and add a test at exactly 5000.

2. In `@src/shipping.js` (line 9, Important):
   The spec charges $1.50 per started kilogram, but floor only counts completed kilograms. A 2,500 g parcel is charged for 2 kg instead of 3, and any weight under 1,000 g adds nothing per-kg. Use `Math.ceil` so partial kilograms are charged. The existing 2,000 g test still passes under either rounding, so it does not catch this.

Auto land this PR in Mergestorm


Mergestorm: 30 free reviews a month

Comment thread src/shipping.js
export const PER_KG_RATE = 150;

export function shippingCost(subtotalCents, weightGrams) {
if (subtotalCents > FREE_SHIPPING_THRESHOLD) {

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

if (subtotalCents > FREE_SHIPPING_THRESHOLD)

The description promises free shipping for orders of $50 or more, but the strict > charges shipping on an order of exactly 5000 cents. Any caller that passes a $50.00 subtotal gets the $4.99 base rate. Use >=, and add a test at exactly 5000.

🤖 Prompt for AI agents
Pull request mergestorm/sample-app#2: https://github.com/mergestorm/sample-app/pull/2 (head branch `shipping`)

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/shipping.js` (line 6, Important):
The description promises free shipping for orders of $50 or more, but the strict `>` charges shipping on an order of exactly 5000 cents. Any caller that passes a $50.00 subtotal gets the $4.99 base rate. Use `>=`, and add a test at exactly 5000.

Comment thread src/shipping.js
if (subtotalCents > FREE_SHIPPING_THRESHOLD) {
return 0;
}
const kilograms = Math.floor(weightGrams / 1000);

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.floor(weightGrams / 1000)

The spec charges $1.50 per started kilogram, but floor only counts completed kilograms. A 2,500 g parcel is charged for 2 kg instead of 3, and any weight under 1,000 g adds nothing per-kg. Use Math.ceil so partial kilograms are charged. The existing 2,000 g test still passes under either rounding, so it does not catch this.

🤖 Prompt for AI agents
Pull request mergestorm/sample-app#2: https://github.com/mergestorm/sample-app/pull/2 (head branch `shipping`)

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/shipping.js` (line 9, Important):
The spec charges $1.50 per started kilogram, but floor only counts completed kilograms. A 2,500 g parcel is charged for 2 kg instead of 3, and any weight under 1,000 g adds nothing per-kg. Use `Math.ceil` so partial kilograms are charged. The existing 2,000 g test still passes under either rounding, so it does not catch this.

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