diff --git a/App/pelagia-portal/app/api/po/import/route.ts b/App/pelagia-portal/app/api/po/import/route.ts index fc14e3d..eed6320 100644 --- a/App/pelagia-portal/app/api/po/import/route.ts +++ b/App/pelagia-portal/app/api/po/import/route.ts @@ -71,14 +71,23 @@ function parseSheet(sheet: XLSX.WorkSheet): ParsedImport { for (let r = 15; r <= 100; r++) { const sn = cellStr(sheet, r, 0); const desc = cellStr(sheet, r, 1); + + // "INSTRUCTIONS TO VENDORS" in col 0 signals the T&C section — stop here + if (sn.toUpperCase().includes("INSTRUCTION")) break; + if (!desc && !sn) continue; if (!desc) continue; - // Stop at summary rows + + // Stop at summary/total rows in description column if (desc.toLowerCase().includes("total") || desc.toLowerCase().includes("grand")) break; const unitRaw = cellStr(sheet, r, 3); const qty = cellNum(sheet, r, 4); const unitPrice = cellNum(sheet, r, 5); + + // Skip rows with no quantity and no unit price — these are T&C text rows + if (qty === 0 && unitPrice === 0) continue; + const gstRaw = cellNum(sheet, r, 7); const gstRate = gstRaw > 1 ? gstRaw / 100 : gstRaw;