mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 16:15:25 +02:00
feat(matrix): support new matrix layout with 4 added columns
- Update default column indices to July 2026 layout (EmpCO_Compliant, Comments, Categorisation Code, Ingredients added; PM Classification removed; downstream columns shifted) - Seed internal Categorisation Code from the new Excel column while keeping app-side edits as the source of truth - Guard legacy CPNP index-77 fallbacks: only trusted when the current layout still holds CPNP there (new layout stores Item To Root Units) - Use resolved column index for forced zero stock instead of static one Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
633f523fc8
commit
0d50fce790
+8
-4
@@ -299,7 +299,7 @@ export async function getHistory(): Promise<HistoryEntry[]> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getHistoryDataForMerge(): Promise<Record<string, ExcelRow>> {
|
||||
export async function getHistoryDataForMerge(includeLegacyCpnpIndex = true): Promise<Record<string, ExcelRow>> {
|
||||
try {
|
||||
const PAGE_SIZE = 1000;
|
||||
const entries: HistoryEntry[] = [];
|
||||
@@ -348,15 +348,19 @@ export async function getHistoryDataForMerge(): Promise<Record<string, ExcelRow>
|
||||
|
||||
// CPNP values were saved through multiple code paths over time.
|
||||
// Preserve the latest non-empty value even when a given history row
|
||||
// does not surface it as a changed index.
|
||||
// does not surface it as a changed index. Index 77 is only a CPNP
|
||||
// location in the pre-July-2026 layout (includeLegacyCpnpIndex);
|
||||
// in the new layout it holds "Item To Root Units".
|
||||
const latestCpnp =
|
||||
entry.new_data?.[COLUMNS.CPNP_NO] ??
|
||||
entry.new_data?.[LEGACY_CPNP_INDEX] ??
|
||||
(includeLegacyCpnpIndex ? entry.new_data?.[LEGACY_CPNP_INDEX] : undefined) ??
|
||||
entry.old_data?.[COLUMNS.CPNP_NO];
|
||||
const fallbackCpnp =
|
||||
latestCpnp !== undefined && latestCpnp !== null && latestCpnp !== ''
|
||||
? latestCpnp
|
||||
: entry.old_data?.[LEGACY_CPNP_INDEX];
|
||||
: includeLegacyCpnpIndex
|
||||
? entry.old_data?.[LEGACY_CPNP_INDEX]
|
||||
: undefined;
|
||||
|
||||
if (fallbackCpnp !== undefined && fallbackCpnp !== null && fallbackCpnp !== '') {
|
||||
target[COLUMNS.CPNP_NO] = fallbackCpnp;
|
||||
|
||||
Reference in New Issue
Block a user