fix(dkv): extract invoice number/date from PDF, rename export files to RG-DKV format
- Parser now extracts Rechnungsnummer (DD/DDDDDDDDD/DDD) and Rechnungsdatum
from PDF text, so filename doesn't rely on email subject
- Export filename changed from DKV_YYYY-MM_... to RG-DKV-{nr}-{YYMMDD}.xlsx
e.g. RG-DKV-26-650869002-002-260331.xlsx
- Subject fallback now also matches slash-separated invoice numbers (26/NNN/NNN)
- writeAndPrune simplified to accept baseName instead of separate fields
- Validation regex and prune prefix updated to match new RG-DKV- pattern
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,7 @@ const MAX_EXPORT_FILES = 10;
|
||||
/**
|
||||
* Glob pattern for DKV export files — used for prune selection.
|
||||
*/
|
||||
const DKV_FILE_PREFIX = 'DKV_';
|
||||
const DKV_FILE_PREFIX = 'RG-DKV-';
|
||||
const DKV_FILE_SUFFIX = '.xlsx';
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ export class DkvExportService {
|
||||
* @param invoiceMonth - Month string "YYYY-MM", e.g. "2026-04"
|
||||
* @returns The filename that was written (relative to user-files/)
|
||||
*/
|
||||
writeAndPrune(buffer: Buffer, rechnungsnummer: string, invoiceMonth: string): string {
|
||||
writeAndPrune(buffer: Buffer, baseName: string): string {
|
||||
// Ensure the directory exists
|
||||
if (!fs.existsSync(this.userFilesDir)) {
|
||||
fs.mkdirSync(this.userFilesDir, { recursive: true });
|
||||
@@ -136,7 +136,7 @@ export class DkvExportService {
|
||||
}
|
||||
|
||||
// Build filename server-side — NEVER from request input (T-07-09 path-traversal mitigation)
|
||||
const filename = `DKV_${invoiceMonth}_${rechnungsnummer}.xlsx`;
|
||||
const filename = `${baseName}.xlsx`;
|
||||
const filePath = path.join(this.userFilesDir, filename);
|
||||
|
||||
// Write the file
|
||||
|
||||
Reference in New Issue
Block a user