Browse Source

In currency if no value after decimal, default precion set to 2 (#3480)

* In currency if no value after decimal, default precion set to 2

* Update formatters.js
version-14
KanchanChauhan 8 years ago
committed by Rushabh Mehta
parent
commit
2c3037a094
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      frappe/public/js/frappe/form/formatters.js

+ 11
- 0
frappe/public/js/frappe/form/formatters.js View File

@@ -53,6 +53,17 @@ frappe.form.formatters = {
Currency: function(value, docfield, options, doc) {
var currency = frappe.meta.get_field_currency(docfield, doc);
var precision = docfield.precision || cint(frappe.boot.sysdefaults.currency_precision) || 2;
if (precision > 2) {
let parts = cstr(value).split('.');
let decimals = parts.length > 1 ? parts[1] : '';
if (decimals.length < 3) {
// min precision 2
precision = 2;
} else if (decimals.length < precision) {
// or min decimals
precision = decimals.length;
}
}
return frappe.form.formatters._right((value==null || value==="")
? "" : format_currency(value, currency, precision), options);
},


Loading…
Cancel
Save