diff --git a/server/src/routes/admin.ts b/server/src/routes/admin.ts index ab1430b..d6b52e7 100644 --- a/server/src/routes/admin.ts +++ b/server/src/routes/admin.ts @@ -569,6 +569,14 @@ export function registerAdminRoutes(app: FastifyInstance, db: DB) { function csvCell(v: unknown): string { if (v === null || v === undefined) return ''; + // Numbers (e.g. a negative total_cents from a net-Pfand-refund + // transaction) skip both the formula-injection guard and the quote + // escaping below — the guard exists for free-text columns that could + // contain a formula-injection payload; a real negative number should + // stay a real number, not get coerced into text a spreadsheet can no + // longer SUM(). Numbers also never contain `,`/`"`/`\n`, so escaping is + // moot for them anyway. + if (typeof v === 'number') return String(v); let s = String(v); // Neutralise spreadsheet formula injection: a cell starting with one of // these characters is interpreted as a formula by Excel/LibreOffice when