feat(shopping): formatQuantity-Utility
Some checks failed
Build & Publish Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
hsiegeln
2026-04-21 23:16:23 +02:00
parent 2c61d82935
commit 76864a6034
2 changed files with 35 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
export function formatQuantity(q: number | null): string {
if (q === null || q === undefined) return '';
const rounded = Math.round(q);
if (Math.abs(q - rounded) < 0.01) return String(rounded);
// auf max. 2 Nachkommastellen, trailing Nullen raus
return q.toFixed(2).replace(/\.?0+$/, '');
}