fix(dataProcessor): parse DD/M/YY dates from column C in sell-out CSV

Add support for European day-first date format (e.g. "23/2/26" = 23 Feb 2026)
in the sell-out CSV pipeline so months and years are correctly extracted from
column C of Amazon Sell Out 2023-2025.csv.

- normalizeMonth: detect DD/MM/YY when first part > 12, return "Mon-YY"
- mapRowToRecord: add 'C', 'Date', 'Fecha', 'DATA' to month column aliases
- validateSellOutHeaders: accept date columns as substitute for YEAR + MONTH

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Vidal Wolf
2026-03-03 13:07:59 +01:00
co-authored by Claude Sonnet 4.6
parent ad1695d360
commit 2eed94b94b
10 changed files with 112 additions and 747 deletions
+30 -1
View File
@@ -1,4 +1,5 @@
import path from 'path';
import fs from 'fs';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
@@ -53,7 +54,35 @@ export default defineConfig(({ mode }) => {
}
}
},
plugins: [react()],
// To support fetching local 'BSR.xlsx' in Vite dev mode, we configure a custom middleware
// since we use a local file instead of a dropbox link for BSR:
plugins: [
react(),
{
name: 'serve-local-bsr',
configureServer(server) {
server.middlewares.use('/api/fetch-bsr', (req, res, next) => {
const filePath = path.join(process.cwd(), 'BSR.xlsx');
try {
if (fs.existsSync(filePath)) {
res.setHeader('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
res.setHeader('Content-Disposition', 'attachment; filename="BSR.xlsx"');
res.setHeader('Cache-Control', 'public, max-age=3600');
const fileStream = fs.createReadStream(filePath);
fileStream.pipe(res);
} else {
res.statusCode = 404;
res.end(JSON.stringify({ error: 'BSR data file not found' }));
}
} catch (err) {
res.statusCode = 500;
res.end(JSON.stringify({ error: 'Failed' }));
}
});
}
}
],
define: {
// loadEnv reads .env files; process.env has Vercel/system env vars at build time
'process.env.API_KEY': JSON.stringify(