diff --git a/frappe/model/naming.js b/frappe/model/naming.js index 86fd62d0..09b0c9d2 100644 --- a/frappe/model/naming.js +++ b/frappe/model/naming.js @@ -35,8 +35,6 @@ module.exports = { return; } - // if(doc.meta) - // Legacy, using doc settings for number series if (doc.meta.settings) { const numberSeries = (await doc.getSettings()).numberSeries; diff --git a/frappe/models/doctype/NumberSeries/NumberSeriesDocument.js b/frappe/models/doctype/NumberSeries/NumberSeriesDocument.js index 4effd328..34118845 100644 --- a/frappe/models/doctype/NumberSeries/NumberSeriesDocument.js +++ b/frappe/models/doctype/NumberSeries/NumberSeriesDocument.js @@ -14,7 +14,7 @@ module.exports = class NumberSeries extends BaseDocument { const exists = await this.checkIfCurrentExists(doctype); if (!exists) { - return this.current; + return this.getPaddedName(this.current); } this.current++; diff --git a/package.json b/package.json index 8984c19d..1e60c0be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "frappe-books", - "version": "0.3.2-beta.0", + "version": "0.4.0-beta.0", "description": "Simple book-keeping app for everyone", "author": { "name": "Frappe Technologies Pvt. Ltd.", diff --git a/src/utils.js b/src/utils.js index dd88f129..638fec3c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -549,10 +549,5 @@ export function invertMap(map) { } export function getPaddedName(prefix, next, padZeros) { - const padding = padZeros ?? 4; - - const l = next.toString().length; - const z = '0'.repeat(Math.max(0, padding - l)); - - return prefix + z + next; + return prefix + next.toString().padStart(padZeros ?? 4, '0'); }