Skip to content

Store the ticket billing country as an ISO code - #281

Draft
claude[bot] wants to merge 1 commit into
mainfrom
billing-country-iso
Draft

claude[bot] wants to merge 1 commit into
mainfrom
billing-country-iso

Conversation

@claude

@claude claude Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Requested by Richard Hartmann · Slack thread

Before: The ticket checkout asked for the billing country as free text, so ticket_orders.billing_country holds whatever was typed ("Deutschland", "DE", "Germany", "Österreich", or nothing). E-invoices (ZUGFeRD / EN 16931) need the buyer's country as an ISO 3166-1 alpha-2 code, which can't be derived reliably from that.

After: The checkout offers a country select (EU/EEA, Switzerland, UK, US; German names; default Deutschland) and stores the ISO code, e.g. DE. The API rejects anything that isn't a listed code. Required-ness is unchanged: mandatory for company purchases, optional for the private address. The invoice PDF prints a code as its German name ("Deutschland"); older orders with free text print exactly as before. This prepares e-invoicing (ZUGFeRD); existing orders need no migration because the normalizer maps their free text to a code when the e-invoice is built.

How: a new shared-code/helpers/billingCountry.ts holds the country list plus normalizeBillingCountry (free text or code → code, unknown/empty → undefined), getBillingCountryName and formatBillingCountry. The Nuxt app (select, review step, zod schema) and the Directus bundle (invoice PDF) both import it, so nothing is duplicated. The checkout store also normalizes country values saved in localStorage before this change, so a returning buyer with "Deutschland" in their draft sees DE selected; an unknown value is cleared and has to be picked again. No Directus schema change.

Tests: nuxt-app/test/billingCountry.test.ts covers the normalizer and renderer, the list (unique codes, matches Intl.DisplayNames('de'), sorted) and the schema rules. invoice-billing-country.test.ts in the bundle renders a PDF and checks the printed country line. Checked: nuxt-app prettier:check, lint, typecheck:ratchet (steady at baseline) and test; bundle prettier:check, lint, test and build.


Generated by Claude Code

The checkout's free-text country field becomes a select (EU/EEA, CH, GB,
US; default DE) and the API accepts only listed codes. A shared helper
maps legacy free text ("Deutschland", "Germany", ...) to codes and renders
a code as its German name, which the invoice PDF now uses. Legacy values
still print as entered. Prepares e-invoices (ZUGFeRD), which need the
buyer's country code.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FBHiR6NFRe6QR5SBjSv4nw
@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
programmierbar-website Ready Ready Preview Oct 20, 2026 3:07pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview — 6a699906 Deployed Oct 20, 2026 by vercel[bot]
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