mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 10:55:24 +02:00
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:
co-authored by
Claude Sonnet 4.6
parent
6426b641c1
commit
b31911a9df
@@ -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
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user