Skip to content

Commit

Permalink
camelify fieldnames in Account
Browse files Browse the repository at this point in the history
  • Loading branch information
netchampfaris committed Apr 2, 2018
1 parent 56aa6c7 commit 877e061
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
44 changes: 38 additions & 6 deletions models/doctype/Account/Account.js
Expand Up @@ -5,7 +5,8 @@ module.exports = {
"isSingle": 0,
"keywordFields": [
"name",
"account_type"
"rootType",
"accountType"
],
"fields": [
{
Expand All @@ -15,7 +16,7 @@ module.exports = {
"required": 1
},
{
"fieldname": "parent_account",
"fieldname": "parentAccount",
"label": "Parent Account",
"fieldtype": "Link",
"target": "Account",
Expand All @@ -27,8 +28,8 @@ module.exports = {
}
},
{
"fieldname": "account_type",
"label": "Account Type",
"fieldname": "rootType",
"label": "Root Type",
"fieldtype": "Select",
"options": [
"Asset",
Expand All @@ -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"
}
],

Expand All @@ -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>`;
}
}
}
8 changes: 4 additions & 4 deletions models/doctype/Account/AccountDocument.js
Expand Up @@ -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';
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testInvoice.js
Expand Up @@ -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}]
})
Expand Down

0 comments on commit 877e061

Please sign in to comment.