fix: prevent CPNP_NO from being overridden by dynamic column detection

CPNP_NO must stay hardcoded at index 107. Removed it from COLUMN_PATTERNS
and added guard to skip empty patterns in resolveColumnIndices.

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
Christian Vidal Wolf
2026-05-12 12:19:09 +02:00
co-authored by claude-flow
parent 889e98b0ca
commit 1b4918a385
2 changed files with 7 additions and 8 deletions
+3 -2
View File
@@ -82,7 +82,7 @@ export const COLUMN_PATTERNS: Record<keyof typeof COLUMNS, string[]> = {
ITEM_TO_LOGISTIC: ['item', 'logistic'],
ANNA_CHECK: ['anna', 'check'],
ANNA_NOTE: ['anna', 'note'],
CPNP_NO: ['cpnp'],
CPNP_NO: [],
// Virtual/Extra columns stay hardcoded and are NOT auto-detected from headers
// to prevent internal data from being shifted or overwritten by Excel column shifts.
};
@@ -92,7 +92,8 @@ export function resolveColumnIndices(headers: string[]): typeof COLUMNS {
const h = headers.map(val => String(val || '').toLowerCase());
Object.entries(COLUMN_PATTERNS).forEach(([key, patterns]) => {
const idx = h.findIndex(headerText =>
if (patterns.length === 0) return;
const idx = h.findIndex(headerText =>
patterns.every(p => headerText.includes(p.toLowerCase()))
);
if (idx >= 0) {