refactor(shopping): redundanten kg-Check in consolidate() entfernt + Boundary-Test
Some checks failed
Build & Publish Docker Image / build-and-push (push) Has been cancelled
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:
@@ -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' };
|
||||
|
||||
Reference in New Issue
Block a user