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

57 lines
1.5 KiB
JavaScript
Raw Normal View History

2018-02-07 16:44:59 +00:00
const frappe = require('frappejs');
2018-01-12 12:25:07 +00:00
module.exports = {
2018-02-12 12:01:31 +00:00
async getSeriesNext(prefix) {
2018-02-07 16:44:59 +00:00
let series;
try {
series = await frappe.getDoc('NumberSeries', prefix);
2018-02-07 16:44:59 +00:00
} catch (e) {
if (!e.status_code || e.status_code !== 404) {
throw e;
}
series = frappe.newDoc({doctype: 'NumberSeries', name: prefix, current: 0});
2018-02-07 16:44:59 +00:00
await series.insert();
}
let next = await series.next()
return prefix + next;
},
2018-01-31 13:04:46 +00:00
common_fields: [
2018-01-12 12:25:07 +00:00
{
2018-02-09 12:55:55 +00:00
fieldname: 'name', fieldtype: 'Data', required: 1
2018-01-31 12:56:21 +00:00
}
2018-01-31 13:04:46 +00:00
],
2018-01-31 12:56:21 +00:00
parent_fields: [
2018-01-12 12:25:07 +00:00
{
2018-02-20 14:11:44 +00:00
fieldname: 'owner', fieldtype: 'Data', required: 1
2018-01-12 12:25:07 +00:00
},
{
2018-02-20 14:11:44 +00:00
fieldname: 'modifieldBy', fieldtype: 'Data', required: 1
2018-01-12 12:25:07 +00:00
},
{
2018-02-09 12:55:55 +00:00
fieldname: 'creation', fieldtype: 'Datetime', required: 1
2018-01-12 12:25:07 +00:00
},
{
2018-02-09 12:55:55 +00:00
fieldname: 'modified', fieldtype: 'Datetime', required: 1
2018-01-12 12:25:07 +00:00
},
{
fieldname: 'keywords', fieldtype: 'Text'
},
{
2018-02-09 12:55:55 +00:00
fieldname: 'docstatus', fieldtype: 'Int', required: 1, default: 0
2018-01-12 12:25:07 +00:00
}
],
child_fields: [
{
2018-02-09 12:55:55 +00:00
fieldname: 'idx', fieldtype: 'Int', required: 1
2018-01-12 12:25:07 +00:00
},
{
2018-02-09 12:55:55 +00:00
fieldname: 'parent', fieldtype: 'Data', required: 1
2018-01-12 12:25:07 +00:00
},
{
2018-02-20 14:11:44 +00:00
fieldname: 'parenttype', fieldtype: 'Data', required: 1
2018-01-12 12:25:07 +00:00
},
{
2018-02-09 12:55:55 +00:00
fieldname: 'parentfield', fieldtype: 'Data', required: 1
2018-01-12 12:25:07 +00:00
}
]
};