value : $unit; return StockQuantity::format($milli).($unitKey === null ? '' : "\u{00A0}".__('inventory.units.'.$unitKey)); } public function money(int $cents): string { return ($cents < 0 ? '-' : '').Money::fromCents(abs($cents))->format(); } /** * A unit cost in hundredths of a cent, e.g. "0,0123 €" or "12,50 €". */ public function unitCost(int $hundredths): string { $euros = number_format($hundredths / 10_000, 4, ',', "\u{00A0}"); $euros = preg_replace('/(,\d\d)00$/', '$1', $euros) ?? $euros; $euros = preg_replace('/(,\d\d\d)0$/', '$1', $euros) ?? $euros; return $euros."\u{00A0}€"; } /** * "24.11.2026" for "2026-11-24"; "24.11.2026 klo 14.05" for "2026-11-24 14:05". */ public function dateLabel(string $value): string { return strlen($value) > 10 ? CarbonImmutable::createFromFormat('Y-m-d H:i', $value)->format('j.n.Y \k\l\o H.i') : CarbonImmutable::createFromFormat('!Y-m-d', $value)->format('j.n.Y'); } }