mirror of
https://github.com/frappe/books.git
synced 2024-11-13 00:46:28 +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 Observable = require('./utils/observable');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const { getMoneyMaker } = require('pesa');
|
const { getMoneyMaker } = require('pesa');
|
||||||
|
const { DEFAULT_INTERNAL_PRECISION } = require('./utils/consts');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
initializeAndRegister(customModels = {}, force = false) {
|
initializeAndRegister(customModels = {}, force = false) {
|
||||||
@ -42,7 +43,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof precision === 'undefined') {
|
if (typeof precision === 'undefined') {
|
||||||
precision = 11;
|
precision = DEFAULT_INTERNAL_PRECISION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof precision.value === 'string') {
|
if (typeof precision.value === 'string') {
|
||||||
|
@ -2,6 +2,7 @@ const frappe = require('frappejs');
|
|||||||
const Observable = require('frappejs/utils/observable');
|
const Observable = require('frappejs/utils/observable');
|
||||||
const naming = require('./naming');
|
const naming = require('./naming');
|
||||||
const { round } = require('frappejs/utils/numberFormat');
|
const { round } = require('frappejs/utils/numberFormat');
|
||||||
|
const { DEFAULT_INTERNAL_PRECISION } = require('../utils/consts');
|
||||||
|
|
||||||
module.exports = class BaseDocument extends Observable {
|
module.exports = class BaseDocument extends Observable {
|
||||||
constructor(data) {
|
constructor(data) {
|
||||||
@ -673,10 +674,8 @@ 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.internalPrecision;
|
const precision =
|
||||||
let defaultPrecision = systemPrecision != null ? systemPrecision : 2;
|
frappe.SystemSettings.internalPrecision ?? DEFAULT_INTERNAL_PRECISION;
|
||||||
let precision =
|
|
||||||
df && df.precision != null ? df.precision : defaultPrecision;
|
|
||||||
return round(value, precision);
|
return round(value, precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,13 +48,6 @@ module.exports = class BaseMeta extends BaseDocument {
|
|||||||
df.required = 1;
|
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;
|
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