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>
22 lines
927 B
JavaScript
22 lines
927 B
JavaScript
import assert from 'node:assert/strict'
|
|
import { test } from 'node:test'
|
|
import { readDecimal } from '../src/components/decimal.js'
|
|
|
|
test('money typed with a comma or a dot (6F.2)', () => {
|
|
assert.equal(readDecimal('12,50', { decimals: 2 }), 12.5)
|
|
assert.equal(readDecimal('12.50', { decimals: 2 }), 12.5)
|
|
assert.equal(readDecimal('1.234,50', { decimals: 2 }), 1234.5)
|
|
assert.equal(readDecimal('0,05', { decimals: 2 }), 0.05)
|
|
assert.equal(readDecimal('€ 7,3', { decimals: 2 }), 7.3)
|
|
assert.equal(readDecimal('0,125', { decimals: 3 }), 0.125)
|
|
})
|
|
|
|
test('empty is null, nonsense is NaN, negatives only when allowed', () => {
|
|
assert.equal(readDecimal(''), null)
|
|
assert.equal(readDecimal(' '), null)
|
|
assert.ok(Number.isNaN(readDecimal('abc')))
|
|
assert.ok(Number.isNaN(readDecimal('12,5,0')))
|
|
assert.ok(Number.isNaN(readDecimal('-2,5')))
|
|
assert.equal(readDecimal('-2,5', { allowNegative: true }), -2.5)
|
|
})
|