From b3131f7710cadcb85df9922b454a414408d6899d Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 25 May 2026 12:15:48 +0200 Subject: [PATCH] Phase6: Customer Billing details --- src/app/[locale]/settings/billing/page.tsx | 9 ++++- src/components/settings/billing-form.tsx | 44 +++++++++++++++------- src/messages/de.json | 4 +- src/messages/en.json | 4 +- src/messages/fr.json | 4 +- src/messages/it.json | 4 +- 6 files changed, 50 insertions(+), 19 deletions(-) diff --git a/src/app/[locale]/settings/billing/page.tsx b/src/app/[locale]/settings/billing/page.tsx index 6f01987..62e0462 100644 --- a/src/app/[locale]/settings/billing/page.tsx +++ b/src/app/[locale]/settings/billing/page.tsx @@ -33,10 +33,15 @@ export default async function BillingSettingsPage() {

{t("title")}

-

{t("subtitle")}

+

+ {user.isPersonal ? t("subtitlePersonal") : t("subtitle")} +

- +
); diff --git a/src/components/settings/billing-form.tsx b/src/components/settings/billing-form.tsx index dccd1d7..821fa34 100644 --- a/src/components/settings/billing-form.tsx +++ b/src/components/settings/billing-form.tsx @@ -8,6 +8,16 @@ import type { OrgBilling } from "@/types"; interface Props { initial: OrgBilling | null; + /** + * Personal-account (individual customer) flag from the session. + * Individuals get a "Full name" field instead of "Company name", + * and the VAT input is hidden entirely — they don't have one and + * showing the field would only confuse. The underlying column is + * still `company_name` in the DB and the invoice PDF; for an + * individual that field carries their full name, which is + * exactly what should print on the invoice. + */ + isPersonal: boolean; } /** @@ -22,7 +32,7 @@ interface Props { * On success we router.refresh() the page so the server component * re-fetches and any "create now" -> "edit" wording flips. */ -export function BillingSettingsForm({ initial }: Props) { +export function BillingSettingsForm({ initial, isPersonal }: Props) { const t = useTranslations("settingsBilling"); const router = useRouter(); const [form, setForm] = useState({ @@ -78,7 +88,10 @@ export function BillingSettingsForm({ initial }: Props) { postalCode: form.postalCode.trim(), city: form.city.trim(), country: form.country.trim().toUpperCase(), - vatNumber: form.vatNumber.trim() || null, + // Personal accounts never have a VAT number — force null + // regardless of stale state, in case a value was stored + // before the account got flagged as personal. + vatNumber: isPersonal ? null : form.vatNumber.trim() || null, billingEmail: form.billingEmail.trim(), notes: form.notes.trim() || null, }), @@ -99,7 +112,10 @@ export function BillingSettingsForm({ initial }: Props) { return (
- +
- - - + {!isPersonal && ( + + + + )}