fix: preserve negative money signs in analytics
This commit is contained in:
@@ -8,13 +8,14 @@
|
||||
export function parseTL(v) {
|
||||
if (v == null) return null;
|
||||
if (typeof v === 'number') return isFinite(v) ? v : null;
|
||||
const s = String(v).replace(/[^\d.,]/g, '');
|
||||
const text=String(v).trim(), negative=/^-/.test(text);
|
||||
const s = text.replace(/[^\d.,]/g, '');
|
||||
if (!s) return null;
|
||||
const norm = s.includes(',')
|
||||
? s.replace(/\./g, '').replace(',', '.')
|
||||
: /^(?:\d+\.\d{3})+$/.test(s) ? s.replace(/\./g, '') : s;
|
||||
const n = parseFloat(norm);
|
||||
return isFinite(n) ? n : null;
|
||||
return isFinite(n) ? (negative ? -n : n) : null;
|
||||
}
|
||||
|
||||
export function formatTL(n) {
|
||||
|
||||
Reference in New Issue
Block a user