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) <noreply@anthropic.com>
This commit is contained in:
Christian Vidal Wolf
2026-05-20 08:10:36 +02:00
co-authored by Claude Sonnet 4.6
parent 6426b641c1
commit b31911a9df
2 changed files with 6 additions and 5 deletions
+5 -4
View File
@@ -450,9 +450,10 @@ export const processCSV = (fileOrContent: File | string): Promise<SalesRecord[]>
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;
}
+1 -1
View File
@@ -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<IDBDatabase> => {
return new Promise((resolve, reject) => {