2
0
mirror of https://github.com/frappe/books.git synced 2025-01-24 23:58:27 +00:00
books/model/index.js

57 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-02-07 22:14:59 +05:30
const frappe = require('frappejs');
2018-01-12 17:55:07 +05:30
module.exports = {
2018-02-12 17:31:31 +05:30
async getSeriesNext(prefix) {
2018-02-07 22:14:59 +05:30
let series;
try {
2018-02-08 17:58:51 +05:30
series = await frappe.getDoc('Number Series', prefix);
2018-02-07 22:14:59 +05:30
} catch (e) {
if (!e.status_code || e.status_code !== 404) {
throw e;
}
2018-02-08 17:58:51 +05:30
series = frappe.newDoc({doctype: 'Number Series', name: prefix, current: 0});
2018-02-07 22:14:59 +05:30
await series.insert();
}
let next = await series.next()
return prefix + next;
},
2018-01-31 18:34:46 +05:30
common_fields: [
2018-01-12 17:55:07 +05:30
{
2018-02-09 18:25:55 +05:30
fieldname: 'name', fieldtype: 'Data', required: 1
2018-01-31 18:26:21 +05:30
}
2018-01-31 18:34:46 +05:30
],
2018-01-31 18:26:21 +05:30
parent_fields: [
2018-01-12 17:55:07 +05:30
{
2018-02-09 18:25:55 +05:30
fieldname: 'owner', fieldtype: 'Link', required: 1, options: 'User'
2018-01-12 17:55:07 +05:30
},
{
2018-02-09 18:25:55 +05:30
fieldname: 'modified_by', fieldtype: 'Link', required: 1, options: 'User'
2018-01-12 17:55:07 +05:30
},
{
2018-02-09 18:25:55 +05:30
fieldname: 'creation', fieldtype: 'Datetime', required: 1
2018-01-12 17:55:07 +05:30
},
{
2018-02-09 18:25:55 +05:30
fieldname: 'modified', fieldtype: 'Datetime', required: 1
2018-01-12 17:55:07 +05:30
},
{
fieldname: 'keywords', fieldtype: 'Text'
},
{
2018-02-09 18:25:55 +05:30
fieldname: 'docstatus', fieldtype: 'Int', required: 1, default: 0
2018-01-12 17:55:07 +05:30
}
],
child_fields: [
{
2018-02-09 18:25:55 +05:30
fieldname: 'idx', fieldtype: 'Int', required: 1
2018-01-12 17:55:07 +05:30
},
{
2018-02-09 18:25:55 +05:30
fieldname: 'parent', fieldtype: 'Data', required: 1
2018-01-12 17:55:07 +05:30
},
{
2018-02-09 18:25:55 +05:30
fieldname: 'parenttype', fieldtype: 'Link', required: 1, options: 'DocType'
2018-01-12 17:55:07 +05:30
},
{
2018-02-09 18:25:55 +05:30
fieldname: 'parentfield', fieldtype: 'Data', required: 1
2018-01-12 17:55:07 +05:30
}
]
};