diff --git a/models/doctype/Account/Account.js b/models/doctype/Account/Account.js index 62d60d6a..b601c988 100644 --- a/models/doctype/Account/Account.js +++ b/models/doctype/Account/Account.js @@ -19,14 +19,7 @@ module.exports = { fieldname: 'rootType', label: 'Root Type', fieldtype: 'Select', - options: [ - 'Select...', - 'Asset', - 'Liability', - 'Equity', - 'Income', - 'Expense' - ], + options: ['', 'Asset', 'Liability', 'Equity', 'Income', 'Expense'], required: 1 }, { @@ -46,7 +39,6 @@ module.exports = { fieldname: 'accountType', label: 'Account Type', fieldtype: 'Select', - required: 1, options: [ '', 'Accumulated Depreciation', diff --git a/models/doctype/Account/AccountDocument.js b/models/doctype/Account/AccountDocument.js index 527113dd..b47bf487 100644 --- a/models/doctype/Account/AccountDocument.js +++ b/models/doctype/Account/AccountDocument.js @@ -2,13 +2,13 @@ const frappe = require('frappejs'); const BaseDocument = require('frappejs/model/document'); module.exports = class Account extends BaseDocument { - async validate() { - if (!this.accountType) { - if (this.parentAccount) { - this.accountType = await frappe.db.getValue('Account', this.parentAccount, 'accountType'); - } else { - this.accountType = 'Asset'; - } - } + async validate() { + if (!this.accountType && this.parentAccount) { + this.accountType = await frappe.db.getValue( + 'Account', + this.parentAccount, + 'accountType' + ); } -} \ No newline at end of file + } +}; diff --git a/src/pages/ChartOfAccounts.vue b/src/pages/ChartOfAccounts.vue index 20fdf7be..e82bdb68 100644 --- a/src/pages/ChartOfAccounts.vue +++ b/src/pages/ChartOfAccounts.vue @@ -242,11 +242,9 @@ export default { input.focus(); }); }, - cancelAddingAccount(parentAccount, key) { - let otherKey = - key === 'addingAccount' ? 'addingGroupAccount' : 'addingAccount'; - parentAccount[key] = 0; - parentAccount[otherKey] = 0; + cancelAddingAccount(parentAccount) { + parentAccount.addingAccount = 0; + parentAccount.addingGroupAccount = 0; this.accounts = this.accounts.slice(); }, async createNewAccount(accountName, parentAccount, isGroup) { @@ -255,16 +253,15 @@ export default { accountName = accountName.trim(); let account = await frappe.getNewDoc('Account'); - let { name, rootType, accountType } = parentAccount; - await account.set({ - name: accountName, - parentAccount: name, - rootType, - accountType, - isGroup - }); - try { + let { name, rootType, accountType } = parentAccount; + await account.set({ + name: accountName, + parentAccount: name, + rootType, + accountType, + isGroup + }); await account.insert(); // turn off editing