mirror of
https://github.com/frappe/books.git
synced 2024-12-26 12:28:12 +00:00
fix: Set default precision for Float fields
This commit is contained in:
parent
2839240436
commit
254b810fd0
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user