소스 검색

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 년 전
committed by Rushabh Mehta
부모
커밋
2c3037a094
1개의 변경된 파일11개의 추가작업 그리고 0개의 파일을 삭제
  1. +11
    -0
      frappe/public/js/frappe/form/formatters.js

+ 11
- 0
frappe/public/js/frappe/form/formatters.js 파일 보기

@@ -53,6 +53,17 @@ frappe.form.formatters = {
Currency: function(value, docfield, options, doc) { Currency: function(value, docfield, options, doc) {
var currency = frappe.meta.get_field_currency(docfield, doc); var currency = frappe.meta.get_field_currency(docfield, doc);
var precision = docfield.precision || cint(frappe.boot.sysdefaults.currency_precision) || 2; 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==="") return frappe.form.formatters._right((value==null || value==="")
? "" : format_currency(value, currency, precision), options); ? "" : format_currency(value, currency, precision), options);
}, },


불러오는 중...
취소
저장