Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-19 22:28:26 +00:00
co-authored by renee-png
parent f52822022e
commit 0498fbe62e
+10
View File
@@ -1372,6 +1372,16 @@ 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");
if (placeholderClient) {
for (const r of insertsNeedingClient) r.client_id = placeholderClient;
}
}
for (let k = 0; k < toInsertInv.length; k += chunkSize) {
const slice = toInsertInv.slice(k, k + chunkSize);
const { data, error } = await supabase.from("invoices").insert(slice as any).select("*");