mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
fix: don't set precision on df, should be global
This commit is contained in:
parent
8bf257c685
commit
23189aaf93
3
index.js
3
index.js
@ -1,6 +1,7 @@
|
||||
const Observable = require('./utils/observable');
|
||||
const utils = require('./utils');
|
||||
const { getMoneyMaker } = require('pesa');
|
||||
const { DEFAULT_INTERNAL_PRECISION } = require('./utils/consts');
|
||||
|
||||
module.exports = {
|
||||
initializeAndRegister(customModels = {}, force = false) {
|
||||
@ -42,7 +43,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
if (typeof precision === 'undefined') {
|
||||
precision = 11;
|
||||
precision = DEFAULT_INTERNAL_PRECISION;
|
||||
}
|
||||
|
||||
if (typeof precision.value === 'string') {
|
||||
|
@ -2,6 +2,7 @@ const frappe = require('frappejs');
|
||||
const Observable = require('frappejs/utils/observable');
|
||||
const naming = require('./naming');
|
||||
const { round } = require('frappejs/utils/numberFormat');
|
||||
const { DEFAULT_INTERNAL_PRECISION } = require('../utils/consts');
|
||||
|
||||
module.exports = class BaseDocument extends Observable {
|
||||
constructor(data) {
|
||||
@ -673,10 +674,8 @@ module.exports = class BaseDocument extends Observable {
|
||||
if (typeof df === 'string') {
|
||||
df = this.meta.getField(df);
|
||||
}
|
||||
let systemPrecision = frappe.SystemSettings.internalPrecision;
|
||||
let defaultPrecision = systemPrecision != null ? systemPrecision : 2;
|
||||
let precision =
|
||||
df && df.precision != null ? df.precision : defaultPrecision;
|
||||
const precision =
|
||||
frappe.SystemSettings.internalPrecision ?? DEFAULT_INTERNAL_PRECISION;
|
||||
return round(value, precision);
|
||||
}
|
||||
|
||||
|
@ -48,13 +48,6 @@ module.exports = class BaseMeta extends BaseDocument {
|
||||
df.required = 1;
|
||||
}
|
||||
|
||||
// attach default precision to Float and Currency
|
||||
if (['Float', 'Currency'].includes(df.fieldtype)) {
|
||||
let defaultPrecision = frappe.SystemSettings
|
||||
? frappe.SystemSettings.internalPrecision
|
||||
: 2;
|
||||
df.precision = df.precision || defaultPrecision;
|
||||
}
|
||||
return df;
|
||||
});
|
||||
}
|
||||
|
1
utils/consts.js
Normal file
1
utils/consts.js
Normal file
@ -0,0 +1 @@
|
||||
export const DEFAULT_INTERNAL_PRECISION = 11;
|
Loading…
Reference in New Issue
Block a user