2
0
mirror of https://github.com/frappe/books.git synced 2025-02-04 13:08:29 +00:00

fix: deprecate floatPrecision add displayPrecision

This commit is contained in:
18alantom 2021-12-23 13:50:44 +05:30
parent 3610f79732
commit 8bf257c685
3 changed files with 17 additions and 8 deletions

View File

@ -673,7 +673,7 @@ module.exports = class BaseDocument extends Observable {
if (typeof df === 'string') { if (typeof df === 'string') {
df = this.meta.getField(df); df = this.meta.getField(df);
} }
let systemPrecision = frappe.SystemSettings.floatPrecision; let systemPrecision = frappe.SystemSettings.internalPrecision;
let defaultPrecision = systemPrecision != null ? systemPrecision : 2; let defaultPrecision = systemPrecision != null ? systemPrecision : 2;
let precision = let precision =
df && df.precision != null ? df.precision : defaultPrecision; df && df.precision != null ? df.precision : defaultPrecision;

View File

@ -51,7 +51,7 @@ module.exports = class BaseMeta extends BaseDocument {
// attach default precision to Float and Currency // attach default precision to Float and Currency
if (['Float', 'Currency'].includes(df.fieldtype)) { if (['Float', 'Currency'].includes(df.fieldtype)) {
let defaultPrecision = frappe.SystemSettings let defaultPrecision = frappe.SystemSettings
? frappe.SystemSettings.floatPrecision ? frappe.SystemSettings.internalPrecision
: 2; : 2;
df.precision = df.precision || defaultPrecision; df.precision = df.precision || defaultPrecision;
} }

View File

@ -40,12 +40,21 @@ module.exports = {
description: _('Sets the app-wide date display format.'), description: _('Sets the app-wide date display format.'),
}, },
{ {
fieldname: 'floatPrecision', fieldname: 'displayPrecision',
label: 'Precision', label: 'Display Precision',
fieldtype: 'Select', fieldtype: 'Int',
options: ['2', '3', '4', '5'], default: 2,
default: '2',
required: 1, required: 1,
minValue: 0,
maxValue: 9,
validate(value, doc) {
if (value >= 0 && value <= 9) {
return;
}
throw new frappe.errors.ValidationError(
_('Display Precision should have a value between 0 and 9.')
);
},
description: _('Sets how many digits are shown after the decimal point.'), description: _('Sets how many digits are shown after the decimal point.'),
}, },
{ {
@ -78,7 +87,7 @@ module.exports = {
], ],
quickEditFields: [ quickEditFields: [
'dateFormat', 'dateFormat',
'floatPrecision', 'displayPrecision',
'hideGetStarted', 'hideGetStarted',
'autoUpdate', 'autoUpdate',
], ],