Skip to content

Commit

Permalink
fix: respect null as number value (#25639)
Browse files Browse the repository at this point in the history
Null is the intentional absence of a value. It represents a variable that has been explicitly set to have no value.

(cherry picked from commit 8b0c202)

Co-authored-by: barredterra <14891507+barredterra@users.noreply.github.com>
  • Loading branch information
mergify[bot] and barredterra committed Mar 25, 2024
1 parent b2260c1 commit 5b64ac9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions frappe/public/js/frappe/form/formatters.js
Expand Up @@ -49,6 +49,10 @@ frappe.form.formatters = {
return __(frappe.form.formatters["Data"](value, df));
},
Float: function (value, docfield, options, doc) {
if (value === null) {
return "";
}

// don't allow 0 precision for Floats, hence or'ing with null
var precision =
docfield.precision ||
Expand All @@ -73,12 +77,20 @@ frappe.form.formatters = {
}
},
Int: function (value, docfield, options) {
if (value === null) {
return "";
}

if (cstr(docfield.options).trim() === "File Size") {
return frappe.form.formatters.FileSize(value);
}
return frappe.form.formatters._right(value == null ? "" : cint(value), options);
},
Percent: function (value, docfield, options) {
if (value === null) {
return "";
}

const precision =
docfield.precision ||
cint(frappe.boot.sysdefaults && frappe.boot.sysdefaults.float_precision) ||
Expand All @@ -105,6 +117,10 @@ frappe.form.formatters = {
</div>`;
},
Currency: function (value, docfield, options, doc) {
if (value === null) {
return "";
}

var currency = frappe.meta.get_field_currency(docfield, doc);

let precision;
Expand Down

0 comments on commit 5b64ac9

Please sign in to comment.