format-quantity.ts 424 B

12345678910
  1. /**
  2. * Render a part quantity with its unit of measure ("2.5 l", "4 pcs").
  3. *
  4. * The unit is a per-line snapshot taken from the inventory part at pick time;
  5. * lines without one (free text, legacy rows) render the bare number, which is
  6. * exactly what they did before units existed.
  7. */
  8. export function formatQuantity(quantity: number, unit?: string | null): string {
  9. return unit ? `${quantity} ${unit}` : `${quantity}`
  10. }