fix(import): stop parsing line items at T&C section
Row 26 ("INSTRUCTIONS TO VENDORS") had an empty col-1 so the loop
continued into the numbered T&C rows (27-33), which all have text in
col-1 and were mistakenly added as line items.
Two guards added:
1. Break immediately when col-0 contains "INSTRUCTION" (catches the
section header even though col-1 is empty).
2. Skip any row where both qty and unitPrice are 0 (belt-and-suspenders
for T&C rows that might slip through in other PO layouts).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
96314d89f8
commit
4a848f50cf
1 changed files with 10 additions and 1 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue