mirror of
https://github.com/frappe/books.git
synced 2024-11-09 23:30:56 +00:00
add new model, account
This commit is contained in:
parent
55e4a350e3
commit
fed69e1a3a
26
models/doctype/account/account.js
Normal file
26
models/doctype/account/account.js
Normal file
@ -0,0 +1,26 @@
|
||||
const frappe = require('frappejs');
|
||||
|
||||
class account_meta extends frappe.meta.Meta {
|
||||
setup_meta() {
|
||||
Object.assign(this, require('./account.json'));
|
||||
this.list_options.fields = ['name', 'account_type'];
|
||||
}
|
||||
|
||||
get_row_html(data) {
|
||||
return `<a href="#edit/account/${data.name}">${data.name} (${data.account_type})</a>`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class account extends frappe.document.Document {
|
||||
setup() {
|
||||
this.add_handler('validate');
|
||||
}
|
||||
validate() {
|
||||
if (!this.account_type) {
|
||||
this.status = 'Asset';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {account:account, account_meta:account_meta};
|
29
models/doctype/account/account.json
Normal file
29
models/doctype/account/account.json
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "Account",
|
||||
"doctype": "DocType",
|
||||
"issingle": 0,
|
||||
"keyword_fields": [
|
||||
"name",
|
||||
"account_type"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"fieldname": "name",
|
||||
"label": "Account Name",
|
||||
"fieldtype": "Data",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "account_type",
|
||||
"label": "Account Type",
|
||||
"fieldtype": "Select",
|
||||
"options": [
|
||||
"Asset",
|
||||
"Liability",
|
||||
"Equity",
|
||||
"Income",
|
||||
"Expense"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user