From 7d305d09e945cecd59aff74be3cf72c82f91db01 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 22:28:42 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/routes/settings.import.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/routes/settings.import.tsx b/src/routes/settings.import.tsx index 224ab6e..9b013e3 100644 --- a/src/routes/settings.import.tsx +++ b/src/routes/settings.import.tsx @@ -1374,10 +1374,24 @@ function ImportPage() { // Inserts must have a non-null client_id; fall back to placeholder // ONLY for genuinely new invoices that never matched anything. - let placeholderClient: string | null = null; const insertsNeedingClient = toInsertInv.filter((r) => !r.client_id); if (insertsNeedingClient.length > 0) { - placeholderClient = await ensureArchivedClient("Imported (no client)", "imported-no-client"); + const { data: ph } = await supabase + .from("clients") + .upsert( + { + name: "Imported (no client)", + external_id: "imported-no-client", + client_type: "hoa", + archived_at: new Date().toISOString(), + notes: "Auto-created from invoice import (no matching client).", + created_by: user.id, + } as any, + { onConflict: "external_id" }, + ) + .select("id") + .single(); + const placeholderClient = (ph?.id as string | undefined) ?? null; if (placeholderClient) { for (const r of insertsNeedingClient) r.client_id = placeholderClient; }