From b31911a9df05c023b58aa0095f56f4ea06dcec94 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Wed, 20 May 2026 08:10:36 +0200 Subject: [PATCH] fix: exclude 2023 data across sales and ads (incomplete year) Filter sales records with year > 2023 and skip ads Excel sheets for year <= 2023. Bump schema version to 4 to invalidate cached 2023 records in IndexedDB. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- services/dataProcessor.ts | 9 +++++---- services/storage.ts | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/services/dataProcessor.ts b/services/dataProcessor.ts index 2a23e44..28ae15b 100644 --- a/services/dataProcessor.ts +++ b/services/dataProcessor.ts @@ -450,9 +450,10 @@ export const processCSV = (fileOrContent: File | string): Promise const data: SalesRecord[] = results.data.map((row: any, index: number) => { return mapRowToRecord(row, index); }) - // Filter: Valid Year >= 2023 AND Allowed Customer AND non-zero units + // Filter: Valid Year > 2023 AND Allowed Customer AND non-zero units // Excluding zero-unit records prevents ad spend or financial adjustments from inflating revenue. - .filter((r: SalesRecord) => r.year >= 2023 && isAllowedCustomer(r.customer) && r.units !== 0); + // 2023 excluded — incomplete data for that year. + .filter((r: SalesRecord) => r.year > 2023 && isAllowedCustomer(r.customer) && r.units !== 0); resolve(data); } catch (err) { @@ -578,8 +579,8 @@ export const processAdsExcel = async (fileOrBuffer: File | ArrayBuffer): Promise // Process ALL sheets (e.g., "2025", "2026") for (const sheetName of workbook.SheetNames) { const year = parseInt(sheetName); - if (isNaN(year) || year < 2020 || year > 2100) { - console.warn(`Skipping sheet "${sheetName}" - not a valid year`); + if (isNaN(year) || year <= 2023 || year > 2100) { + console.warn(`Skipping sheet "${sheetName}" - not a valid year or excluded (<=2023)`); continue; } diff --git a/services/storage.ts b/services/storage.ts index b11d017..100fc32 100644 --- a/services/storage.ts +++ b/services/storage.ts @@ -7,7 +7,7 @@ const ADS_STORE_NAME = 'adsData'; const DB_VERSION = 2; // Increment this when data processing logic changes (e.g., field mapping changes) // This forces cache invalidation and re-processing of CSV data -const DATA_SCHEMA_VERSION = 3; // Updated to clear broken Ads data +const DATA_SCHEMA_VERSION = 4; // Exclude 2023 data (incomplete year) const initDB = (): Promise => { return new Promise((resolve, reject) => {