Add shipping fee with free shipping from 50 EUR #1

Open
philmori wants to merge 1 commit from feature/free-shipping into main
Owner

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add shipping fee with free shipping from 50 EUR
All checks were successful
ci / check (pull_request) Successful in 36s
39eed42020
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator

🤖 PR evidence

Summary

Adds a flat shipping fee (4.90 EUR net, 20% VAT) that is waived when the discounted net reaches 50 EUR. calculateTotals now returns a shipping field and includes it in VAT and gross. The PR description is empty, so the rationale is inferred from the code.

What changed

  • src/cart.ts:
    • Adds shipping to CartTotals.
    • Adds exported constants FREE_SHIPPING_FROM (5000) and SHIPPING_FEE (490), plus a private SHIPPING_VAT_RATE (20).
    • calculateTotals charges no shipping for an empty cart or when net - discount >= 5000. Otherwise it charges 490.
    • Shipping VAT is added to vat, and gross becomes discountedNet + shipping + vat.
  • test/cart.test.ts:
    • Updates the existing expected VAT and gross values to include shipping.
    • Adds a test that shipping is free at 50 EUR discounted net and for an empty cart.

Risks

  • src/cart.ts: The 20% shipping VAT rate is hardcoded, while line items carry their own vatRate. Mixed-rate carts may not be taxed correctly.
  • src/cart.ts: The threshold uses the discounted net. This is a meaningful business choice that the code does not document.
  • test/cart.test.ts: No test covers the exact boundary (5000), and none covers a cart that is above 50 EUR before discount but below it after discount.
  • test/cart.test.ts: Expected values partly re-derive the implementation (98, SHIPPING_FEE), so they would not catch a wrong shipping VAT calculation.

Needs a human decision

  • Should the free-shipping threshold apply to net, gross, or pre-discount amounts?
  • Is 20% the correct VAT rate for shipping in every market this shop serves?
  • Is a flat fee correct for all destinations, or should it vary by region?

Suggested checks

  • Run the test suite and confirm SHIPPING_FEE 98 VAT matches the expected rounding.
  • Add boundary tests at exactly 5000 and at 4999 net.
  • Add a case where the pre-discount net is above 50 EUR but the discounted net is below it, and confirm the fee applies.
  • Add a mixed-VAT-rate cart and verify totals against an accounting reference.

acdc-lite review agent via n8n · 2 files · 2982 diff chars · commit 39eed420 · supports, does not replace, human review

## 🤖 PR evidence ### Summary Adds a flat shipping fee (4.90 EUR net, 20% VAT) that is waived when the discounted net reaches 50 EUR. `calculateTotals` now returns a `shipping` field and includes it in VAT and gross. The PR description is empty, so the rationale is inferred from the code. ### What changed - `src/cart.ts`: - Adds `shipping` to `CartTotals`. - Adds exported constants `FREE_SHIPPING_FROM` (5000) and `SHIPPING_FEE` (490), plus a private `SHIPPING_VAT_RATE` (20). - `calculateTotals` charges no shipping for an empty cart or when `net - discount >= 5000`. Otherwise it charges 490. - Shipping VAT is added to `vat`, and `gross` becomes `discountedNet + shipping + vat`. - `test/cart.test.ts`: - Updates the existing expected VAT and gross values to include shipping. - Adds a test that shipping is free at 50 EUR discounted net and for an empty cart. ### Risks - `src/cart.ts`: The 20% shipping VAT rate is hardcoded, while line items carry their own `vatRate`. Mixed-rate carts may not be taxed correctly. - `src/cart.ts`: The threshold uses the discounted net. This is a meaningful business choice that the code does not document. - `test/cart.test.ts`: No test covers the exact boundary (5000), and none covers a cart that is above 50 EUR before discount but below it after discount. - `test/cart.test.ts`: Expected values partly re-derive the implementation (`98`, `SHIPPING_FEE`), so they would not catch a wrong shipping VAT calculation. ### Needs a human decision - Should the free-shipping threshold apply to net, gross, or pre-discount amounts? - Is 20% the correct VAT rate for shipping in every market this shop serves? - Is a flat fee correct for all destinations, or should it vary by region? ### Suggested checks - Run the test suite and confirm `SHIPPING_FEE` 98 VAT matches the expected rounding. - Add boundary tests at exactly 5000 and at 4999 net. - Add a case where the pre-discount net is above 50 EUR but the discounted net is below it, and confirm the fee applies. - Add a mixed-VAT-rate cart and verify totals against an accounting reference. --- <sub>acdc-lite review agent via n8n · 2 files · 2982 diff chars · commit 39eed420 · supports, does not replace, human review</sub>
All checks were successful
ci / check (pull_request) Successful in 36s
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feature/free-shipping:feature/free-shipping
git switch feature/free-shipping

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff feature/free-shipping
git switch feature/free-shipping
git rebase main
git switch main
git merge --ff-only feature/free-shipping
git switch feature/free-shipping
git rebase main
git switch main
git merge --no-ff feature/free-shipping
git switch main
git merge --squash feature/free-shipping
git switch main
git merge --ff-only feature/free-shipping
git switch main
git merge feature/free-shipping
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
philmori/acdc-demo!1
No description provided.