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
+7 -4
View File
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
import { BrowserRouter, Routes, Route, Navigate, Outlet, useNavigate } from 'react-router-dom'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { AccessProvider, useAccess, useCan, useModule } from '@xenia/access'
import { useTranslation } from '@xenia/i18n'
import { parseNumber, useTranslation } from '@xenia/i18n'
import { i18n } from './i18n'
import useAuthStore from './store/authStore'
import useShiftStore from './store/shiftStore'
@@ -120,10 +120,13 @@ function StartShiftScreen({ username, onStart, onLogout }) {
const [error, setError] = useState(null)
async function handleStart() {
// a comma or a dot for the cents (6F.2): a Greek keypad only has the comma
const amount = startingCash.trim() === '' ? null : parseNumber(startingCash, { decimals: 2, allowNegative: false })
if (startingCash.trim() !== '' && amount == null) { setError(t('gate.badAmount')); return }
setStarting(true)
setError(null)
try {
await onStart(startingCash ? parseFloat(startingCash) : null)
await onStart(amount)
} catch (e) {
setError(apiError(e, t('gate.startFailed')))
setStarting(false)
@@ -146,9 +149,9 @@ function StartShiftScreen({ username, onStart, onLogout }) {
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span style={{ color: 'var(--muted)', fontWeight: 700 }}>€</span>
<input
type="number" step="0.01" min="0" placeholder="0.00"
type="text" inputMode="decimal" autoComplete="off" placeholder="0,00"
value={startingCash}
onChange={e => setStartingCash(e.target.value)}
onChange={e => { setStartingCash(e.target.value); setError(null) }}
onKeyDown={e => e.key === 'Enter' && handleStart()}
style={{
flex: 1, background: 'var(--bg3)', border: '1px solid var(--border)',
+9 -7
View File
@@ -3,7 +3,7 @@ import { useCan } from '@xenia/access'
import useWaiterFavoritesStore from '../store/waiterFavoritesStore'
import { assetUrl } from '../config/server'
import { money } from '../i18n'
import { useTranslation } from '@xenia/i18n'
import { parseNumber, useTranslation } from '@xenia/i18n'
// ── Helpers ──────────────────────────────────────────────────────────────────
@@ -723,13 +723,14 @@ function QuantityTab({ unitCfg, qty, setQty }) {
{editingQty ? (
<input
ref={inputRef}
type="number"
type="text"
inputMode="decimal"
autoComplete="off"
value={qtyInput}
onChange={e => setQtyInput(e.target.value)}
onBlur={() => {
const v = parseFloat(qtyInput)
if (!isNaN(v)) setQty(clamp(v))
const v = parseNumber(qtyInput, { decimals: 3, allowNegative: false })
if (v != null) setQty(clamp(v))
setEditingQty(false)
}}
onKeyDown={e => { if (e.key === 'Enter') e.target.blur() }}
@@ -830,8 +831,8 @@ function PriceAdjustTab({ basePrice, priceAdj, setPriceAdj }) {
}
function commitInput() {
const v = parseFloat(rawInput.replace(',', '.'))
if (!isNaN(v) && v >= 0.01) {
const v = parseNumber(rawInput, { decimals: 2, allowNegative: false })
if (v != null && v >= 0.01) {
setPriceAdj(Math.round((v - basePrice) * 100) / 100)
}
setEditing(false)
@@ -853,8 +854,9 @@ function PriceAdjustTab({ basePrice, priceAdj, setPriceAdj }) {
{editing ? (
<input
ref={inputRef}
type="number"
type="text"
inputMode="decimal"
autoComplete="off"
value={rawInput}
onChange={e => setRawInput(e.target.value)}
onBlur={commitInput}
+6 -5
View File
@@ -15,7 +15,7 @@ import { queueOfflineSplit, queueOfflinePayment as queueOfflinePaymentOp } from
import { TransferIcon, MergeIcon, FlagsIcon, WaiterIcon, PrintIcon } from '../components/Icons'
import usePaymentSettingsStore from '../store/paymentSettingsStore'
import useTableViewStore from '../store/tableViewStore'
import { useTranslation } from '@xenia/i18n'
import { parseNumber, useTranslation } from '@xenia/i18n'
import { fade } from '../logic/colour'
import SeatsHint from '../components/SeatsHint'
@@ -143,8 +143,8 @@ function PriceAdjustModal({ item, onConfirm, onClose }) {
}
function commitEdit() {
const parsed = parseFloat(rawInput.replace(',', '.'))
if (!isNaN(parsed)) {
const parsed = parseNumber(rawInput, { decimals: 2, allowNegative: false })
if (parsed != null) {
setAdj(Math.round((parsed - basePrice) * 100) / 100)
}
setEditing(false)
@@ -166,8 +166,9 @@ function PriceAdjustModal({ item, onConfirm, onClose }) {
{editing ? (
<input
ref={inputRef}
type="number"
step="0.01"
type="text"
inputMode="decimal"
autoComplete="off"
value={rawInput}
onChange={e => setRawInput(e.target.value)}
onBlur={commitEdit}