diff --git a/models/doctype/account/account.js b/models/doctype/account/account.js new file mode 100644 index 00000000..684a89f4 --- /dev/null +++ b/models/doctype/account/account.js @@ -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 `${data.name} (${data.account_type})`; + } + +} + +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}; diff --git a/models/doctype/account/account.json b/models/doctype/account/account.json new file mode 100644 index 00000000..90b70655 --- /dev/null +++ b/models/doctype/account/account.json @@ -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" + ] + } + ] +} \ No newline at end of file