Przeglądaj źródła

fix: make flt value idempotent

version-14
Mohammad Hasnain 3 lat temu
rodzic
commit
4d0b0d35ef
1 zmienionych plików z 7 dodań i 1 usunięć
  1. +7
    -1
      frappe/public/js/frappe/utils/number_format.js

+ 7
- 1
frappe/public/js/frappe/utils/number_format.js Wyświetl plik

@@ -8,7 +8,12 @@ if (!window.frappe) window.frappe = {};
function flt(v, decimals, number_format) { function flt(v, decimals, number_format) {
if (v == null || v == '') return 0; if (v == null || v == '') return 0;


if (typeof v !== "number") {
if (! (typeof v === "number" || String(parseFloat(v)) == v)){
// cases in which this block should not run
// 1. 'v' is already a number
// 2. v is already parsed but in string form
// if (typeof v !== "number") {

v = v + ""; v = v + "";


// strip currency symbol if exists // strip currency symbol if exists
@@ -25,6 +30,7 @@ function flt(v, decimals, number_format) {
v = 0; v = 0;
} }


v = parseFloat(v);
if (decimals != null) if (decimals != null)
return _round(v, decimals); return _round(v, decimals);
return v; return v;


Ładowanie…
Anuluj
Zapisz