2
0
mirror of https://github.com/frappe/books.git synced 2025-01-23 07:08:36 +00:00

added integer control

This commit is contained in:
Rushabh Mehta 2018-02-12 17:54:53 +05:30
parent 92355be627
commit 55dca13824
3 changed files with 15 additions and 2 deletions

View File

@ -4,6 +4,7 @@ const control_classes = {
Select: require('./select'), Select: require('./select'),
Link: require('./link'), Link: require('./link'),
Float: require('./float'), Float: require('./float'),
Int: require('./int'),
Currency: require('./currency'), Currency: require('./currency'),
Password: require('./password'), Password: require('./password'),
Table: require('./table') Table: require('./table')

View File

@ -0,0 +1,10 @@
const FloatControl = require('./float');
class IntControl extends FloatControl {
parse(value) {
value = parseInt(value);
return value===NaN ? 0 : value;
}
};
module.exports = IntControl;

View File

@ -54,6 +54,10 @@ module.exports = class BaseDocument {
} }
async setName() { async setName() {
if (this.name) {
return;
}
// name === doctype for Single // name === doctype for Single
if (this.meta.isSingle) { if (this.meta.isSingle) {
this.name = this.meta.name; this.name = this.meta.name;
@ -62,10 +66,8 @@ module.exports = class BaseDocument {
if (this.meta.settings) { if (this.meta.settings) {
const number_series = (await this.getSettings()).number_series; const number_series = (await this.getSettings()).number_series;
console.log(1, number_series);
if(number_series) { if(number_series) {
this.name = await frappe.model.getSeriesNext(number_series); this.name = await frappe.model.getSeriesNext(number_series);
console.log(2, this.name);
} }
} }