2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00

fix: Set default precision for Float fields

This commit is contained in:
Faris Ansari 2019-12-02 17:48:11 +05:30
parent 2839240436
commit 254b810fd0

View File

@ -25,6 +25,11 @@ module.exports = class BaseMeta extends BaseDocument {
setValues(data) { setValues(data) {
Object.assign(this, data); Object.assign(this, data);
this.processFields();
}
processFields() {
// add name field
if (!this.fields.find(df => df.fieldname === 'name') && !this.isSingle) { if (!this.fields.find(df => df.fieldname === 'name') && !this.isSingle) {
this.fields = [ this.fields = [
{ {
@ -36,6 +41,14 @@ module.exports = class BaseMeta extends BaseDocument {
} }
].concat(this.fields); ].concat(this.fields);
} }
// attach default precision to Float and Currency
this.fields = this.fields.map(df => {
if (['Float', 'Currency'].includes(df.fieldtype)) {
df.precision = df.precision || frappe.SystemSettings.floatPrecision;
}
return df;
});
} }
hasField(fieldname) { hasField(fieldname) {