mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
fixed account_browser
This commit is contained in:
@@ -24,6 +24,9 @@ pscript['onload_Accounts Browser'] = function(wrapper){
|
|||||||
wn.require('lib/js/wn/ui/tree.js');
|
wn.require('lib/js/wn/ui/tree.js');
|
||||||
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
|
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
|
||||||
wrapper.appframe.add_button('New Company', function() { newdoc('Company'); }, 'icon-plus');
|
wrapper.appframe.add_button('New Company', function() { newdoc('Company'); }, 'icon-plus');
|
||||||
|
wrapper.appframe.add_button('Refresh', function() {
|
||||||
|
wrapper.$company_select.change();
|
||||||
|
}, 'icon-refresh');
|
||||||
|
|
||||||
// company-select
|
// company-select
|
||||||
wrapper.$company_select = $('<select class="accbrowser-company-select"></select>')
|
wrapper.$company_select = $('<select class="accbrowser-company-select"></select>')
|
||||||
@@ -73,6 +76,7 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
$(wrapper).find('.tree-area').empty();
|
$(wrapper).find('.tree-area').empty();
|
||||||
var me = this;
|
var me = this;
|
||||||
me.ctype = ctype;
|
me.ctype = ctype;
|
||||||
|
me.company = company;
|
||||||
this.tree = new wn.ui.Tree({
|
this.tree = new wn.ui.Tree({
|
||||||
parent: $(wrapper).find('.tree-area'),
|
parent: $(wrapper).find('.tree-area'),
|
||||||
label: company,
|
label: company,
|
||||||
@@ -105,84 +109,133 @@ erpnext.AccountsChart = Class.extend({
|
|||||||
+encodeURIComponent(data.value)+'">Edit</a>').appendTo(link.toolbar);
|
+encodeURIComponent(data.value)+'">Edit</a>').appendTo(link.toolbar);
|
||||||
|
|
||||||
if(data.expandable) {
|
if(data.expandable) {
|
||||||
link.toolbar.append(' | <a>Add Child</a>');
|
link.toolbar.append(' | <a onclick="erpnext.account_chart.new_node();">Add Child</a>');
|
||||||
} else {
|
} else if(this.ctype=='Account') {
|
||||||
link.toolbar.append(' | <a>View Ledger</a>');
|
link.toolbar.append(' | <a onclick="erpnext.account_chart.show_ledger();">View Ledger</a>');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new_account: function() {
|
show_ledger: function() {
|
||||||
var d = new Dialog(300,400,'Create A New Account');
|
var me = this;
|
||||||
d.make_body([
|
var node = me.selected_node();
|
||||||
['HTML','Heading'],
|
wn.set_route('Report', 'GL Entry', 'General Ledger',
|
||||||
['Data','New Account Name'],
|
this.ctype + '=' + node.data('label'));
|
||||||
['Select','Group or Ledger','Specify whether the new account is a Ledger or Group'],
|
|
||||||
['Select','Account Type','[Optional] Specify the type of this account'],
|
|
||||||
['Data','Tax Rate','Specify the default tax rate'],
|
|
||||||
['Select','Master Type','Specify the master type of this account'],
|
|
||||||
['Button','Create']
|
|
||||||
]);
|
|
||||||
|
|
||||||
add_sel_options(d.widgets['Group or Ledger'], ['Group', 'Ledger'],'Group');
|
|
||||||
add_sel_options(d.widgets['Account Type'], ['', 'Fixed Asset Account','Bank or Cash','Expense Account','Tax','Income Account','Chargeable'], '');
|
|
||||||
add_sel_options(d.widgets['Master Type'], ['NA', 'Supplier','Customer','Employee'],'NA');
|
|
||||||
|
|
||||||
// hide / show account type
|
|
||||||
d.widgets['Group or Ledger'].onchange = function() {
|
|
||||||
if(sel_val(this)=='Ledger')$ds(d.rows['Account Type']);
|
|
||||||
else $dh(d.rows['Account Type']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// hide / show tax rate
|
|
||||||
d.widgets['Account Type'].onchange = function() {
|
|
||||||
if(sel_val(this)=='Tax' || sel_val(this)=='Chargeable')$ds(d.rows['Tax Rate']);
|
|
||||||
else $dh(d.rows['Tax Rate']);
|
|
||||||
}
|
|
||||||
|
|
||||||
d.onshow = function() {
|
|
||||||
$dh(this.rows['Account Type']);
|
|
||||||
$dh(this.rows['Tax Rate']);
|
|
||||||
this.widgets['Group or Ledger'].selectedIndex = 0;
|
|
||||||
this.widgets['Account Type'].selectedIndex = 0;
|
|
||||||
this.widgets['Master Type'].selectedIndex = 0;
|
|
||||||
d.widgets['New Account Name'].value = '';
|
|
||||||
d.widgets['Tax Rate'].value = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
d.widgets['Create'].onclick = function() {
|
|
||||||
if(!d.widgets['New Account Name'].value) {
|
|
||||||
msgprint('Please enter New Account Name'); return;
|
|
||||||
}
|
|
||||||
if(!sel_val(d.widgets['Master Type'])) {
|
|
||||||
msgprint('Please enter master type of this new account'); return;
|
|
||||||
}
|
|
||||||
args = {
|
|
||||||
'account_name' : d.widgets['New Account Name'].value,
|
|
||||||
'parent_account' : pscript.cur_node.rec.name,
|
|
||||||
'group_or_ledger' : sel_val(d.widgets['Group or Ledger']),
|
|
||||||
'company' : sel_val(pscript.ab_company_sel),
|
|
||||||
'account_type' : sel_val(d.widgets['Account Type']),
|
|
||||||
'tax_rate' : d.widgets['Tax Rate'].value,
|
|
||||||
'master_type': sel_val(d.widgets['Master Type'])
|
|
||||||
}
|
|
||||||
$c_obj('GL Control', 'add_ac', docstring(args), function(r,rt) { d.hide(); pscript.group_area.ref_btn.onclick(); });
|
|
||||||
}
|
|
||||||
pscript.new_acc_dialog = d;
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
new_node: function() {
|
||||||
|
if(this.ctype=='Account') {
|
||||||
|
this.new_account();
|
||||||
|
} else {
|
||||||
|
this.new_cost_center();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
selected_node: function() {
|
||||||
|
return this.tree.$w.find('.tree-link.selected');
|
||||||
|
},
|
||||||
|
new_account: function() {
|
||||||
|
var me = this;
|
||||||
|
|
||||||
|
// the dialog
|
||||||
|
var d = new wn.ui.Dialog({
|
||||||
|
title:'New Account',
|
||||||
|
fields: [
|
||||||
|
{fieldtype:'Data', fieldname:'account_name', label:'New Account Name', reqd:true},
|
||||||
|
{fieldtype:'Select', fieldname:'group_or_ledger', label:'Group or Ledger',
|
||||||
|
options:'Group\nLedger'},
|
||||||
|
{fieldtype:'Select', fieldname:'account_type', label:'Account Type',
|
||||||
|
options: ['', 'Fixed Asset Account', 'Bank or Cash', 'Expense Account', 'Tax',
|
||||||
|
'Income Account', 'Chargeable'].join('\n') },
|
||||||
|
{fieldtype:'Float', fieldname:'tax_rate', label:'Tax Rate'},
|
||||||
|
{fieldtype:'Select', fieldname:'master_type', label:'Master Type',
|
||||||
|
options: ['NA', 'Supplier', 'Customer', 'Employee'].join('\n') },
|
||||||
|
{fieldtype:'Button', fieldname:'create_new', label:'Create New' }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
var fd = d.fields_dict;
|
||||||
|
|
||||||
|
// account type if ledger
|
||||||
|
$(fd.group_or_ledger.input).change(function() {
|
||||||
|
if($(this).val()=='Group') {
|
||||||
|
$(fd.account_type.wrapper).toggle(false);
|
||||||
|
$(fd.master_type.wrapper).toggle(false);
|
||||||
|
$(fd.tax_rate.wrapper).toggle(false);
|
||||||
|
} else {
|
||||||
|
$(fd.account_type.wrapper).toggle(true);
|
||||||
|
$(fd.master_type.wrapper).toggle(true);
|
||||||
|
if(fd.account_type.get_value()=='Tax') {
|
||||||
|
$(fd.tax_rate.wrapper).toggle(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// tax rate if tax
|
||||||
|
$(fd.account_type.input).change(function() {
|
||||||
|
if($(this).val()=='Tax') {
|
||||||
|
$(fd.tax_rate.wrapper).toggle(true);
|
||||||
|
} else {
|
||||||
|
$(fd.tax_rate.wrapper).toggle(false);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// create
|
||||||
|
$(fd.create_new.input).click(function() {
|
||||||
|
var btn = this;
|
||||||
|
$(btn).set_working();
|
||||||
|
var v = d.get_values();
|
||||||
|
if(!v) return;
|
||||||
|
|
||||||
|
var node = me.selected_node();
|
||||||
|
v.parent_account = node.data('label');
|
||||||
|
v.company = me.company;
|
||||||
|
|
||||||
|
$c_obj('GL Control', 'add_ac', v,
|
||||||
|
function(r,rt) {
|
||||||
|
$(btn).done_working();
|
||||||
|
d.hide();
|
||||||
|
node.trigger('reload');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// show
|
||||||
|
d.onshow = function() {
|
||||||
|
$(fd.group_or_ledger.input).change();
|
||||||
|
}
|
||||||
|
d.show();
|
||||||
|
},
|
||||||
|
|
||||||
new_cost_center: function(){
|
new_cost_center: function(){
|
||||||
pscript.cc_dialog = new Dialog(300,400,'Create A New Cost Center');
|
var me = this;
|
||||||
pscript.cc_dialog.make_body([
|
// the dialog
|
||||||
['HTML','Heading'],
|
var d = new wn.ui.Dialog({
|
||||||
['Data','New Cost Center Name'],
|
title:'New Cost Center',
|
||||||
['Select','Group or Ledger','Specify whether the new cost center is a Ledger or Group'],
|
fields: [
|
||||||
['Button','Create']
|
{fieldtype:'Data', fieldname:'cost_center_name', label:'New Cost Center Name', reqd:true},
|
||||||
]);
|
{fieldtype:'Select', fieldname:'group_or_ledger', label:'Group or Ledger',
|
||||||
|
options:'Group\nLedger'},
|
||||||
add_sel_options(pscript.cc_dialog.widgets['Group or Ledger'], ['Group','Ledger'], 'Group');
|
{fieldtype:'Button', fieldname:'create_new', label:'Create New' }
|
||||||
|
]
|
||||||
pscript.new_cost_center_dialog = pscript.cc_dialog;
|
})
|
||||||
}
|
|
||||||
|
// create
|
||||||
|
$(d.fields_dict.create_new.input).click(function() {
|
||||||
|
var btn = this;
|
||||||
|
$(btn).set_working();
|
||||||
|
var v = d.get_values();
|
||||||
|
if(!v) return;
|
||||||
|
|
||||||
|
var node = me.selected_node();
|
||||||
|
|
||||||
|
v.parent_cost_center = node.data('label');
|
||||||
|
v.company_name = me.company;
|
||||||
|
|
||||||
|
$c_obj('GL Control', 'add_cc', v,
|
||||||
|
function(r,rt) {
|
||||||
|
$(btn).done_working();
|
||||||
|
d.hide();
|
||||||
|
node.trigger('reload');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -450,8 +450,7 @@ wn.container.change_to('Form - '+dt);wn.views.formview[dt].frm.refresh(dn);});})
|
|||||||
* lib/js/wn/views/reportview.js
|
* lib/js/wn/views/reportview.js
|
||||||
*/
|
*/
|
||||||
wn.views.reportview={show:function(dt,rep_name){wn.require('lib/js/legacy/report.compressed.js');dt=get_label_doctype(dt);if(!_r.rb_con){_r.rb_con=new _r.ReportContainer();}
|
wn.views.reportview={show:function(dt,rep_name){wn.require('lib/js/legacy/report.compressed.js');dt=get_label_doctype(dt);if(!_r.rb_con){_r.rb_con=new _r.ReportContainer();}
|
||||||
_r.rb_con.set_dt(dt,function(rb){if(rep_name){var t=rb.current_loaded;rb.load_criteria(rep_name);if(onload)
|
_r.rb_con.set_dt(dt,function(rb){if(rep_name){var t=rb.current_loaded;rb.load_criteria(rep_name);if((rb.dt)&&(!rb.dt.has_data()||rb.current_loaded!=t))
|
||||||
onload(rb);if((rb.dt)&&(!rb.dt.has_data()||rb.current_loaded!=t))
|
|
||||||
rb.dt.run();}
|
rb.dt.run();}
|
||||||
if(!rb.forbidden){wn.container.change_to('Report Builder');}});}}
|
if(!rb.forbidden){wn.container.change_to('Report Builder');}});}}
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -337,8 +337,7 @@ wn.container.change_to('Form - '+dt);wn.views.formview[dt].frm.refresh(dn);});})
|
|||||||
* lib/js/wn/views/reportview.js
|
* lib/js/wn/views/reportview.js
|
||||||
*/
|
*/
|
||||||
wn.views.reportview={show:function(dt,rep_name){wn.require('lib/js/legacy/report.compressed.js');dt=get_label_doctype(dt);if(!_r.rb_con){_r.rb_con=new _r.ReportContainer();}
|
wn.views.reportview={show:function(dt,rep_name){wn.require('lib/js/legacy/report.compressed.js');dt=get_label_doctype(dt);if(!_r.rb_con){_r.rb_con=new _r.ReportContainer();}
|
||||||
_r.rb_con.set_dt(dt,function(rb){if(rep_name){var t=rb.current_loaded;rb.load_criteria(rep_name);if(onload)
|
_r.rb_con.set_dt(dt,function(rb){if(rep_name){var t=rb.current_loaded;rb.load_criteria(rep_name);if((rb.dt)&&(!rb.dt.has_data()||rb.current_loaded!=t))
|
||||||
onload(rb);if((rb.dt)&&(!rb.dt.has_data()||rb.current_loaded!=t))
|
|
||||||
rb.dt.run();}
|
rb.dt.run();}
|
||||||
if(!rb.forbidden){wn.container.change_to('Report Builder');}});}}
|
if(!rb.forbidden){wn.container.change_to('Report Builder');}});}}
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user