2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

camelify fieldnames in Account

This commit is contained in:
Faris Ansari 2018-04-02 23:24:35 +05:30
parent 56aa6c70af
commit 877e0616d4
3 changed files with 43 additions and 11 deletions

View File

@ -5,7 +5,8 @@ module.exports = {
"isSingle": 0,
"keywordFields": [
"name",
"account_type"
"rootType",
"accountType"
],
"fields": [
{
@ -15,7 +16,7 @@ module.exports = {
"required": 1
},
{
"fieldname": "parent_account",
"fieldname": "parentAccount",
"label": "Parent Account",
"fieldtype": "Link",
"target": "Account",
@ -27,8 +28,8 @@ module.exports = {
}
},
{
"fieldname": "account_type",
"label": "Account Type",
"fieldname": "rootType",
"label": "Root Type",
"fieldtype": "Select",
"options": [
"Asset",
@ -37,6 +38,37 @@ module.exports = {
"Income",
"Expense"
]
},
{
"fieldname": "accountType",
"label": "Account Type",
"fieldtype": "Select",
"options": [
"Accumulated Depreciation",
"Bank",
"Cash",
"Chargeable",
"Cost of Goods Sold",
"Depreciation",
"Equity",
"Expense Account",
"Expenses Included In Valuation",
"Fixed Asset",
"Income Account",
"Payable",
"Receivable",
"Round Off",
"Stock",
"Stock Adjustment",
"Stock Received But Not Billed",
"Tax",
"Temporary"
]
},
{
"fieldname": "isGroup",
"label": "Is Group",
"fieldtype": "Check"
}
],
@ -48,10 +80,10 @@ module.exports = {
listSettings: {
getFields(list) {
return ['name', 'account_type'];
return ['name', 'accountType', 'rootType'];
},
getRowHTML(list, data) {
return `<div class="col-11">${list.getNameHTML(data)} (${data.account_type})</div>`;
return `<div class="col-11">${list.getNameHTML(data)} (${data.rootType})</div>`;
}
}
}

View File

@ -3,11 +3,11 @@ const BaseDocument = require('frappejs/model/document');
module.exports = class Account extends BaseDocument {
async validate() {
if (!this.account_type) {
if (this.parent_account) {
this.account_type = await frappe.db.getValue('Account', this.parent_account, 'account_type');
if (!this.accountType) {
if (this.parentAccount) {
this.accountType = await frappe.db.getValue('Account', this.parentAccount, 'accountType');
} else {
this.account_type = 'Asset';
this.accountType = 'Asset';
}
}
}

View File

@ -8,7 +8,7 @@ async function makeFixtures() {
await frappe.insert({doctype:'Party', name:'Test Customer'})
await frappe.insert({doctype:'Item', name:'Test Item 1', description:'Test Item Description 1', unit:'No', rate: 100})
await frappe.insert({doctype:'Item', name:'Test Item 2', description:'Test Item Description 2', unit:'No', rate: 200})
await frappe.insert({doctype:'Account', name:'GST', parent_account: 'Liabilities'});
await frappe.insert({doctype:'Account', name:'GST', parentAccount: 'Liabilities'});
await frappe.insert({doctype:'Tax', name:'GST',
details: [{account: 'GST', rate:10}]
})