Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
47635ae1ed
commit
d2c9712737
@@ -582,6 +582,11 @@ function ImportPage() {
|
||||
const mapped: Row[] = [];
|
||||
let skipped = 0;
|
||||
const errors: string[] = [];
|
||||
const skipReasons: Record<string, number> = {};
|
||||
const bumpSkip = (reason: string) => {
|
||||
skipped++;
|
||||
skipReasons[reason] = (skipReasons[reason] ?? 0) + 1;
|
||||
};
|
||||
|
||||
for (const raw of rawRows) {
|
||||
const row: Row = {};
|
||||
@@ -598,7 +603,19 @@ function ImportPage() {
|
||||
|
||||
// transform
|
||||
const transformed = cfg.transform ? cfg.transform(row, ctx) : row;
|
||||
if (!transformed) { skipped++; continue; }
|
||||
if (!transformed) {
|
||||
// Diagnose common transform-rejection reasons for clearer feedback
|
||||
if (cfg.table === "homeowners" && !row.client_id && !row._clientext && !row._clientname) {
|
||||
bumpSkip("no client match (missing companyid/company)");
|
||||
} else if (cfg.table === "homeowners" && (row._clientext || row._clientname) && !row.client_id) {
|
||||
bumpSkip("client not found in existing clients (import companies first)");
|
||||
} else if ((cfg.table === "cases" || cfg.table === "invoices") && !row.client_id) {
|
||||
bumpSkip("client not found");
|
||||
} else {
|
||||
bumpSkip("rejected by transform");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// archived → archived_at (only on tables that support it)
|
||||
if ("_archived" in transformed) {
|
||||
@@ -611,7 +628,7 @@ function ImportPage() {
|
||||
|
||||
// required check
|
||||
const missing = cfg.required.find((k) => !transformed[k] && transformed[k] !== 0);
|
||||
if (missing) { skipped++; continue; }
|
||||
if (missing) { bumpSkip(`missing required: ${missing}`); continue; }
|
||||
|
||||
// attach created_by where not present
|
||||
if (!transformed.created_by && !["time_entries", "expenses", "comments"].includes(cfg.table)) {
|
||||
|
||||
Reference in New Issue
Block a user