Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
f52822022e
commit
0498fbe62e
@@ -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("*");
|
||||
|
||||
Reference in New Issue
Block a user