fix(dkv): fix Kennzeichen matching and NaN/invalid km values in Excel export
Three issues fixed:
1. Kennzeichen normalization: DKV PDF extracts plates without hyphens
("GP JL 740E" vs CSV-imported "GP-JL 740E"). Added _normalizeKennzeichen()
which strips hyphens, spaces, and dots before lookup — resolves vehicle
master match failure that caused Marke/Modell/Fahrer to appear empty.
2. Empty-string NaN: parser used ?? '0' which doesn't catch empty strings,
causing parseDE('') = NaN. Changed to || '0' for km, menge, and totals.
3. Invalid km values: EV charging rows from DKV have misaligned columns —
km position contains a decimal price (e.g. 18.64 EUR or kWh). Added
sanity check: non-integer km values are written as null (empty cell)
instead of a misleading decimal. ExportRow.kilometerstand is now number|null.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -207,13 +207,14 @@ export class DkvParserService {
|
||||
return dates.map((date, i) => ({
|
||||
lieferdatum: date,
|
||||
ort: orts[i] ?? '',
|
||||
// German number format: "19.234,56" → 19234.56 (strip dots, replace comma)
|
||||
kilometerstand: parseDE(kms[i] ?? '0'),
|
||||
// German number format: "19.234,56" → 19234.56 (strip dots, replace comma).
|
||||
// Use || '0' (not ??) so empty strings also fall back to '0' (avoids NaN).
|
||||
kilometerstand: parseDE(kms[i] || '0'),
|
||||
produkt: products[i] ?? '',
|
||||
menge: parseDE(quantities[i] ?? '0'),
|
||||
menge: parseDE(quantities[i] || '0'),
|
||||
einheit: units[i] ?? '',
|
||||
netto: parseDE(totals_netto[i] ?? '0'),
|
||||
brutto: parseDE(totals_brutto[i] ?? '0'),
|
||||
netto: parseDE(totals_netto[i] || '0'),
|
||||
brutto: parseDE(totals_brutto[i] || '0'),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user