Skip to content

feat(core): name tax rows by their rate - #134

Open
moset15 wants to merge 1 commit into
emdashCommerce:mainfrom
FIKANOVA:feat/tax-rows-named-by-rate
Open

moset15 wants to merge 1 commit into
emdashCommerce:mainfrom
FIKANOVA:feat/tax-rows-named-by-rate

Conversation

@moset15

@moset15 moset15 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What and why

The cart page, the checkout summary and the order receipt show a single "Tax" row, even though the cart and order already carry taxLines with each rate's name and percentage. A shop charging VAT can't show "VAT" to its customers.

Part of the roadmap in #108.

Behaviour

  • Before: one "Tax" row with the total.
  • After: one row per tax line, labelled with the rate: "VAT 16%", "County levy 2%".
  • A rate whose name already states its percentage ("GB 20%") is left alone. An empty name reads "Tax".
  • The flat rate's tax line is now labelled "Tax" instead of the US term "Sales tax", so it shows as "Tax 16%".
  • A total with no tax lines (an older cart or order) still shows one "Tax" row, and zero tax shows no row, as before.
  • Two rates with the same name get separate rows (unique React keys).

Changes

  • New astro/tax-rows.ts: taxLineLabel and taxRows, shared by both islands and the receipt.
  • CartPageIsland.tsx, CheckoutSidebarIsland.tsx: render taxRows(cart.taxLines, cart.taxTotal).
  • emails/receipt.ts: the same rows in the HTML and text versions.
  • cart/calculate.ts: the flat rate's line label "Sales tax" → "Tax".
  • Changeset: minor for core.

No route changes. Orders already placed keep the label stored on their tax lines.

Tests

packages/core/test/tax-rows.test.ts:

  • through the real cart/contact route with flat tax at 16%: the cart it returns gives one "Tax 16%" row for KES 240.00;
  • recalculate with flat tax gives "Tax 16%";
  • labels: "VAT 16%", "Levy 1.5%", a name with "%" left alone, an empty name as "Tax";
  • one row per line; a total without lines as one "Tax" row; nothing for zero tax;
  • the receipt names the rate in both HTML and text, with no bare "Tax" row;
  • both islands render their rows from cart.taxLines.

The integration tests fail without the change. Full suite: core 373 (364 before), paystack 105, lite 144, registry-setup 5, all passing. tsc --noEmit and Biome are clean on the new and changed lines; bun.lock is unchanged.

Review points

  • The "Sales tax" → "Tax" rename: that label was never shown to customers before this PR (every surface printed "Tax"), so this is the first time it's visible. "Tax 16%" reads correctly for VAT and GST shops as well as US sales tax. Easy to drop if you'd rather keep "Sales tax".
  • Rounding: the percentage shows at most two decimal places ("1.5%", not "1.50%").
  • Stripe Tax mode returns no core tax lines, so those carts show what they showed before.

Merge order with the shipping-options and coupon box PRs: all three edit the checkout summary island on neighbouring lines. Each merges cleanly on its own; whichever goes in first, I'll rebase the others straight away.

@cavewebs

cavewebs commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for this. It now conflicts with main in CheckoutSidebarIsland.tsx after #132 landed, could you rebase onto main? I'll merge it once CI is green.

The cart page, checkout summary and order receipt showed a single "Tax"
row, so a rate's own name ("VAT") never reached the customer. They now
show one row per tax line, labelled with the rate ("VAT 16%"). The flat
rate's line is labelled "Tax" rather than the US "Sales tax", so it
reads "Tax 16%". A total with no tax lines still shows as "Tax", and
rows get unique React keys when two rates share a name.

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

moset15 commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main after #132; the summary keeps #132's shipping row and names the tax rows by rate. #133 and #134 change the same lines of the order summary, so whichever lands second I'll rebase straight away.

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.

2 participants