Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-04-20 10:19:02 +03:00
parent 8462df878f
commit 18c9a99a57
2 changed files with 49 additions and 11 deletions

View File

@@ -702,10 +702,26 @@ function round2 (value) {
}
function parseNumber (val) {
const normalized = String(val ?? '')
.replace(/\s/g, '')
.replace(/\./g, '')
.replace(',', '.')
if (typeof val === 'number') return Number.isFinite(val) ? val : 0
const text = String(val ?? '').trim().replace(/\s/g, '')
if (!text) return 0
const lastComma = text.lastIndexOf(',')
const lastDot = text.lastIndexOf('.')
let normalized = text
if (lastComma >= 0 && lastDot >= 0) {
if (lastComma > lastDot) {
normalized = text.replace(/\./g, '').replace(',', '.')
} else {
normalized = text.replace(/,/g, '')
}
} else if (lastComma >= 0) {
normalized = text.replace(/\./g, '').replace(',', '.')
} else {
normalized = text.replace(/,/g, '')
}
const n = Number(normalized)
return Number.isFinite(n) ? n : 0
}
@@ -713,11 +729,7 @@ function parseNumber (val) {
function parseNullableNumber (val) {
const text = String(val ?? '').trim()
if (!text) return null
const normalized = text
.replace(/\s/g, '')
.replace(/\./g, '')
.replace(',', '.')
const n = Number(normalized)
const n = parseNumber(text)
return Number.isFinite(n) ? n : null
}