refactor(shopping): redundanten kg-Check in consolidate() entfernt + Boundary-Test
Some checks failed
Build & Publish Docker Image / build-and-push (push) Has been cancelled

Weight-Branch prueft nicht mehr doppelt auf unitFamily; stil-parity mit Volume-Branch.
Boundary-Test fuer exakt 1000 g ergaenzt (15/15 Tests gruen).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-22 16:53:29 +02:00
parent c6a549699a
commit b85f869c09
2 changed files with 8 additions and 1 deletions

View File

@@ -43,7 +43,7 @@ export function consolidate(rows: QuantityInUnit[]): QuantityInUnit {
if (allNull) return { quantity: null, unit: firstUnit };
const grams = rows.reduce((sum, r) => {
const q = r.quantity ?? 0;
return sum + (unitFamily(r.unit) === 'weight' && r.unit?.toLowerCase().trim() === 'kg' ? q * 1000 : q);
return sum + (r.unit?.toLowerCase().trim() === 'kg' ? q * 1000 : q);
}, 0);
if (grams >= 1000) return { quantity: round2(grams / 1000), unit: 'kg' };
return { quantity: round2(grams), unit: 'g' };