2
0
mirror of https://github.com/frappe/books.git synced 2024-12-31 22:11:48 +00:00

fix: Incorrect accountType bug

- Set accountType as non mandatory
- accountType can be set from parent, but it is not required
This commit is contained in:
Faris Ansari 2019-12-26 23:38:17 +05:30
parent 1e44cc9fae
commit de19af85c4
3 changed files with 21 additions and 32 deletions

View File

@ -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',

View File

@ -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'
);
}
}
}
};

View File

@ -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