restore legacy cpnp history index

This commit is contained in:
Christian Vidal Wolf
2026-05-20 15:12:36 +02:00
parent 528d859742
commit d40bc9fa9c
2 changed files with 20 additions and 2 deletions
+12
View File
@@ -56,6 +56,7 @@ const FORCED_ZERO_STOCK_SKUS = new Set([
]);
const BC_SYNC_QUEUE_STORAGE_KEY = 'craze_bc_sync_queue';
const LEGACY_CPNP_INDEX = 77;
type BcSyncStatus = 'queued' | 'previewed' | 'preview_only' | 'syncing' | 'synced' | 'failed';
@@ -413,6 +414,17 @@ export default function App() {
}
});
// Older cosmetic edits stored CPNP in index 77 before the dedicated
// internal CPNP column was stabilized at index 107.
const legacyCpnp =
hist?.[COLUMNS.CPNP_NO] ??
synced?.data?.[COLUMNS.CPNP_NO] ??
hist?.[LEGACY_CPNP_INDEX] ??
synced?.data?.[LEGACY_CPNP_INDEX];
if (legacyCpnp !== undefined && legacyCpnp !== null && String(legacyCpnp).trim() !== '') {
finalRow[COLUMNS.CPNP_NO] = legacyCpnp;
}
// When a row is still in an edited/pending state, restore editable business fields too.
// This includes historical CPNP edits that were persisted directly in products.
if (synced?.status === 'pending' || synced?.status === 'edited') {