2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00
books/model/index.js
2018-02-20 19:41:44 +05:30

57 lines
1.5 KiB
JavaScript

const frappe = require('frappejs');
module.exports = {
async getSeriesNext(prefix) {
let series;
try {
series = await frappe.getDoc('NumberSeries', prefix);
} catch (e) {
if (!e.status_code || e.status_code !== 404) {
throw e;
}
series = frappe.newDoc({doctype: 'NumberSeries', name: prefix, current: 0});
await series.insert();
}
let next = await series.next()
return prefix + next;
},
common_fields: [
{
fieldname: 'name', fieldtype: 'Data', required: 1
}
],
parent_fields: [
{
fieldname: 'owner', fieldtype: 'Data', required: 1
},
{
fieldname: 'modifieldBy', fieldtype: 'Data', required: 1
},
{
fieldname: 'creation', fieldtype: 'Datetime', required: 1
},
{
fieldname: 'modified', fieldtype: 'Datetime', required: 1
},
{
fieldname: 'keywords', fieldtype: 'Text'
},
{
fieldname: 'docstatus', fieldtype: 'Int', required: 1, default: 0
}
],
child_fields: [
{
fieldname: 'idx', fieldtype: 'Int', required: 1
},
{
fieldname: 'parent', fieldtype: 'Data', required: 1
},
{
fieldname: 'parenttype', fieldtype: 'Data', required: 1
},
{
fieldname: 'parentfield', fieldtype: 'Data', required: 1
}
]
};