feat(manager,waiter): money and weights typed with a comma or a dot everywhere

Owner 2026-11-23 (plan 6F.2): new DecimalInput / MoneyInput in @xenia/ui (keeps what is typed,
reports a number, null when empty, NaN when not a number) on parseNumber. The waiter app's starting
cash, weighed quantity and typed prices were type=number + parseFloat (a Greek keypad's comma was
dropped: 12,50 became 12 or nothing); now text fields read with parseNumber, and a wrong starting
cash shows a message. The manager's price rules, deals and order-total condition use the new
fields; every Number(x.replace(',', '.')) now reads through parseNumber (1.234,50 too). Guard test
packages/i18n/tests/typed-numbers.test.mjs refuses parseFloat, .replace(',', '.') and decimal
type=number fields in the apps. e2e: shift close with 20,50, waiter starting cash 25,50.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 07:08:54 +02:00
co-authored by Claude Opus 5.5
parent e708202f3a
commit e3f4f3eeee
27 changed files with 216 additions and 46 deletions
@@ -1,4 +1,5 @@
// The staff page as plain data (plan step 6.11), tested in tests/staff.test.mjs.
import { parseNumber } from '@xenia/i18n/number'
/** The roles in the order the page lists them (backend roles.py); names are i18n `roles.*`. */
export const ROLES = ['owner', 'store_manager', 'staff_manager', 'chef', 'assistant_chef', 'barista', 'barman', 'waiter', 'assistant_waiter', 'custom']
@@ -58,8 +59,9 @@ export function staffProblems(form, isNew) {
if (!form.full_name.trim()) out.push('full_name')
if (!form.nickname.trim()) out.push('nickname')
if (!/^[^\s]{2,}$/.test(form.username.trim())) out.push('username')
const rate = String(form.hourly_rate).trim().replace(',', '.')
if (rate && !(Number(rate) >= 0)) out.push('hourly_rate')
const rate = String(form.hourly_rate ?? '').trim()
const rateValue = rate ? parseNumber(rate) : null
if (rate && !(rateValue != null && rateValue >= 0)) out.push('hourly_rate')
if (isNew && !validPin(form.pin)) out.push('pin')
if (isNew && form.password && !validPassword(form.password)) out.push('password')
return out
@@ -68,11 +70,11 @@ export function staffProblems(form, isNew) {
/** POST /api/waiters/ (new) or PUT /api/waiters/{id} (edit). */
export function staffBody(form, isNew) {
const text = v => (v ?? '').trim() || null
const rate = String(form.hourly_rate).trim().replace(',', '.')
const rate = String(form.hourly_rate ?? '').trim()
const body = {
full_name: form.full_name.trim(), nickname: form.nickname.trim(), username: form.username.trim(), role: form.role,
mobile_phone: text(form.mobile_phone), email: text(form.email), note: text(form.note),
hourly_rate: rate ? Number(rate) : null, language: form.language || '',
hourly_rate: rate ? parseNumber(rate, { decimals: 2 }) : null, language: form.language || '',
}
if (isNew) {
body.pin = form.pin