started rewrite of accounts browser
This commit is contained in:
parent
d76146372e
commit
850c928a02
@ -203,6 +203,10 @@ div.std-footer-item {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.layout-wrapper-appframe {
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
.layout-wrapper-background {
|
.layout-wrapper-background {
|
||||||
background-color: #fafafa !important;
|
background-color: #fafafa !important;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
|
|||||||
@ -203,6 +203,10 @@ div.std-footer-item {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.layout-wrapper-appframe {
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
.layout-wrapper-background {
|
.layout-wrapper-background {
|
||||||
background-color: #fafafa !important;
|
background-color: #fafafa !important;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
|
|||||||
@ -35,12 +35,6 @@ class DocType:
|
|||||||
self.doc, self.doclist = d, dl
|
self.doc, self.doclist = d, dl
|
||||||
self.entries = []
|
self.entries = []
|
||||||
|
|
||||||
# Get Company List
|
|
||||||
# ----------------
|
|
||||||
def get_companies(self,arg=''):
|
|
||||||
ret = webnotes.conn.sql("select name, abbr from tabCompany where docstatus != 2")
|
|
||||||
return {'cl':[r[0] for r in ret]}
|
|
||||||
|
|
||||||
def get_company_currency(self,arg=''):
|
def get_company_currency(self,arg=''):
|
||||||
dcc = TransactionBase().get_company_currency(arg)
|
dcc = TransactionBase().get_company_currency(arg)
|
||||||
return dcc
|
return dcc
|
||||||
|
|||||||
@ -1,9 +1,20 @@
|
|||||||
h1 { padding: 8px 0px; margin: 0px; }
|
select.accbrowser-company-select {
|
||||||
#ledger_area { padding: 16px;}
|
width: 200px;
|
||||||
.ac_head { display: none; }
|
margin-top: 2px;
|
||||||
.ac_head div { padding: 2px; }
|
margin-left: 10px;
|
||||||
.ac_ledger { display: none; padding: 8px; margin-top: 8px; border-top: 1px solid #DDD; }
|
}
|
||||||
.ac_balance { margin-left: 4px; font-size: 16px; font-weight: bold; background-color: #FFFAB0; }
|
|
||||||
|
|
||||||
.ac_page_sel_tab { width:90%; background-color: #EEE; margin-bottom: 8px }
|
span.accbrowser-node-toolbar {
|
||||||
.ac_page_sel_tab td { vertical-align: middle; padding: 3px; }
|
padding: 2px;
|
||||||
|
margin-left: 15px;
|
||||||
|
border-radius: 3px;
|
||||||
|
-moz-border-radius: 3px;
|
||||||
|
-webkit-border-radius: 3px;
|
||||||
|
border-radius: 3px;
|
||||||
|
background-color: #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tree-area a.selected {
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,7 +1,12 @@
|
|||||||
<div class="layout-wrapper layout-wrapper-appframe">
|
<div class="layout-wrapper layout-wrapper-background">
|
||||||
<div class="appframe-area"></div>
|
<div class="appframe-area"></div>
|
||||||
<div style="padding: 15px;">
|
<div class="layout-main-section">
|
||||||
<div id="ab_header"></div>
|
<div class="tree-area"></div>
|
||||||
<div id="ab_body" style="margin: 16px;"></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="layout-side-section">
|
||||||
|
<div class="help">1. To add child nodes, explore tree and click on the node under which you want to add more nodes.<br><br>
|
||||||
|
2. Please do NOT create accounts (ledgers) for Customers and Suppliers. They are created directly from the Customer / Supplier masters.<br>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="clear"></div>
|
||||||
</div>
|
</div>
|
||||||
@ -14,37 +14,183 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
pscript['onshow_Accounts Browser'] = function(wrapper){
|
// tree of chart of accounts / cost centers
|
||||||
wn.require('lib/js/legacy/widgets/tree.js');
|
// multiple companies
|
||||||
|
// add node
|
||||||
|
// edit node
|
||||||
|
// see ledger
|
||||||
|
|
||||||
|
pscript['onload_Accounts Browser'] = function(wrapper){
|
||||||
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');
|
||||||
|
|
||||||
var route = decodeURIComponent(location.hash);
|
// company-select
|
||||||
if(route.indexOf('/')!=-1) {
|
wrapper.$company_select = $('<select class="accbrowser-company-select"></select>')
|
||||||
var chart_type = route.split('/')[1];
|
.change(function() {
|
||||||
pscript.make_chart(chart_type);
|
var ctype = wn.get_route()[1] || 'Account';
|
||||||
return;
|
erpnext.account_chart = new erpnext.AccountsChart(ctype, $(this).val(), wrapper);
|
||||||
|
})
|
||||||
|
.appendTo(wrapper.appframe.$w.find('.appframe-toolbar'));
|
||||||
|
|
||||||
|
// default company
|
||||||
|
if(sys_defaults.company) {
|
||||||
|
$('<option>')
|
||||||
|
.html(sys_defaults.company)
|
||||||
|
.attr('value', sys_defaults.company)
|
||||||
|
.appendTo(wrapper.$company_select);
|
||||||
|
|
||||||
|
wrapper.$company_select
|
||||||
|
.val(sys_defaults.company).change();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the user directly loads the page, ask to select the chart
|
// load up companies
|
||||||
var parent = $i('ab_body');
|
wn.call({
|
||||||
parent.innerHTML = 'Please select your chart: '
|
method:'accounts.page.accounts_browser.accounts_browser.get_companies',
|
||||||
var sel = $a(parent,'select');
|
callback: function(r) {
|
||||||
add_sel_options(sel, ['Account', 'Cost Center'], 'Account');
|
wrapper.$company_select.empty();
|
||||||
var btn = $btn(parent, 'Go', function() { pscript.make_chart(sel_val(sel)); }, {marginTop:'8px'});
|
$.each(r.message, function(i, v) {
|
||||||
|
$('<option>').html(v).attr('value', v).appendTo(wrapper.$company_select);
|
||||||
|
});
|
||||||
|
wrapper.$company_select.val(sys_defaults.company || r[0]);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pscript.make_chart = function(b) {
|
pscript['onshow_Accounts Browser'] = function(wrapper){
|
||||||
pscript.chart_type = b;
|
//wn.require('lib/js/wn/ui/tree.js');
|
||||||
$i('ab_header').innerHTML ='';
|
|
||||||
$i('ab_body').innerHTML ='';
|
|
||||||
|
|
||||||
//===============comment area========================================
|
// set route
|
||||||
var comment = $a($i('ab_body'),'div','comment',{marginBottom:"8px"});
|
var ctype = wn.get_route()[1] || 'Account';
|
||||||
comment.innerHTML = "Note: Explore and click on the tree node to add a new child";
|
wrapper.appframe.$titlebar.find('.appframe-title').html('Chart of '+ctype+'s');
|
||||||
|
|
||||||
var select_area = $a('ab_body', 'div', '', {margin:'8px 0px'});
|
if(erpnext.account_chart && erpnext.account_chart.ctype != ctype) {
|
||||||
|
wrapper.$company_select.change();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
erpnext.AccountsChart = Class.extend({
|
||||||
|
init: function(ctype, company, wrapper) {
|
||||||
|
$(wrapper).find('.tree-area').empty();
|
||||||
|
var me = this;
|
||||||
|
me.ctype = ctype;
|
||||||
|
this.tree = new wn.ui.Tree({
|
||||||
|
parent: $(wrapper).find('.tree-area'),
|
||||||
|
label: company,
|
||||||
|
args: {ctype: ctype},
|
||||||
|
method: 'accounts.page.accounts_browser.accounts_browser.get_children',
|
||||||
|
click: function(link) {
|
||||||
|
if(me.cur_toolbar)
|
||||||
|
$(me.cur_toolbar).toggle(false);
|
||||||
|
|
||||||
|
if(!link.toolbar)
|
||||||
|
me.make_link_toolbar(link);
|
||||||
|
|
||||||
|
if(link.toolbar) {
|
||||||
|
me.cur_toolbar = link.toolbar;
|
||||||
|
$(me.cur_toolbar).toggle(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.tree.rootnode.$a.click();
|
||||||
|
},
|
||||||
|
make_link_toolbar: function(link) {
|
||||||
|
var data = $(link).data('node-data');
|
||||||
|
if(!data) return;
|
||||||
|
|
||||||
|
link.toolbar = $('<span class="accbrowser-node-toolbar"></span>').insertAfter(link);
|
||||||
|
|
||||||
|
// edit
|
||||||
|
$('<a href="#!Form/'+encodeURIComponent(this.ctype)+'/'
|
||||||
|
+encodeURIComponent(data.value)+'">Edit</a>').appendTo(link.toolbar);
|
||||||
|
|
||||||
|
if(data.expandable) {
|
||||||
|
link.toolbar.append(' | <a>Add Child</a>');
|
||||||
|
} else {
|
||||||
|
link.toolbar.append(' | <a>View Ledger</a>');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new_account: function() {
|
||||||
|
var d = new Dialog(300,400,'Create A New Account');
|
||||||
|
d.make_body([
|
||||||
|
['HTML','Heading'],
|
||||||
|
['Data','New Account Name'],
|
||||||
|
['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_cost_center: function(){
|
||||||
|
pscript.cc_dialog = new Dialog(300,400,'Create A New Cost Center');
|
||||||
|
pscript.cc_dialog.make_body([
|
||||||
|
['HTML','Heading'],
|
||||||
|
['Data','New Cost Center Name'],
|
||||||
|
['Select','Group or Ledger','Specify whether the new cost center is a Ledger or Group'],
|
||||||
|
['Button','Create']
|
||||||
|
]);
|
||||||
|
|
||||||
|
add_sel_options(pscript.cc_dialog.widgets['Group or Ledger'], ['Group','Ledger'], 'Group');
|
||||||
|
|
||||||
|
pscript.new_cost_center_dialog = pscript.cc_dialog;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
pscript.make_chart = function(b, wrapper) {
|
||||||
|
pscript.ctype = b;
|
||||||
|
$(wrapper).find('.tree-area').empty()
|
||||||
|
$(wrapper).find('.layout-sidesection').empty()
|
||||||
|
|
||||||
//================== table body======================================
|
//================== table body======================================
|
||||||
var ac_main_grid = make_table($i('ab_body'),1,2,'100%',['60%','40%'],{border:"0px", padding:"4px",tableLayout: "fixed", borderCollapse: "collapse"});
|
var ac_main_grid = make_table($i('ab_body'),1,2,'100%',['60%','40%'],{border:"0px", padding:"4px",tableLayout: "fixed", borderCollapse: "collapse"});
|
||||||
@ -55,7 +201,7 @@ pscript.make_chart = function(b) {
|
|||||||
pscript.acc_period_bal = $a($td(ac_main_grid,0,1),'div');
|
pscript.acc_period_bal = $a($td(ac_main_grid,0,1),'div');
|
||||||
|
|
||||||
//=====================footer area ==================================
|
//=====================footer area ==================================
|
||||||
if (pscript.chart_type == 'Account') {
|
if (pscript.ctype == 'Account') {
|
||||||
var footer = $a($i('ab_body'),'div','',{backgroundColor: "#FFD", padding: "8px", color: "#444", fontSize: "12px", marginTop: "14px"});
|
var footer = $a($i('ab_body'),'div','',{backgroundColor: "#FFD", padding: "8px", color: "#444", fontSize: "12px", marginTop: "14px"});
|
||||||
|
|
||||||
var help1 = $a(footer,'span');
|
var help1 = $a(footer,'span');
|
||||||
@ -65,12 +211,7 @@ pscript.make_chart = function(b) {
|
|||||||
|
|
||||||
// header and toolbar
|
// header and toolbar
|
||||||
// ------------------
|
// ------------------
|
||||||
|
wrapper.appframe.$titlebar.find('.appframe-title').html('Chart of '+pscript.ctype+'s');
|
||||||
var h1 = 'Chart of '+pscript.chart_type+'s';
|
|
||||||
if(pscript.chart_type == 'Account') var d = 'accounting';
|
|
||||||
else var d = 'cost center';
|
|
||||||
var desc = 'Manage multiple companies and the '+d+' structures of each company.';
|
|
||||||
$i('ab_body').page_head = new PageHeader('ab_header',h1,desc);
|
|
||||||
|
|
||||||
// select company
|
// select company
|
||||||
// --------------
|
// --------------
|
||||||
@ -115,8 +256,8 @@ pscript.make_chart = function(b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pscript.make_ac_tree = function() {
|
pscript.make_ac_tree = function() {
|
||||||
//var type= sel_val($i('chart_type'))
|
//var type= sel_val($i('ctype'))
|
||||||
var type= pscript.chart_type;
|
var type= pscript.ctype;
|
||||||
var tree = new Tree(pscript.account_tree, '90%');
|
var tree = new Tree(pscript.account_tree, '90%');
|
||||||
pscript.ac_tree = tree;
|
pscript.ac_tree = tree;
|
||||||
|
|
||||||
@ -171,9 +312,9 @@ pscript.make_ac_tree = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type=='Account'){
|
if (type=='Account'){
|
||||||
var arg = [node.rec.name, node.rec.account_name, sel_val(pscript.ab_company_sel), pscript.chart_type];
|
var arg = [node.rec.name, node.rec.account_name, sel_val(pscript.ab_company_sel), pscript.ctype];
|
||||||
} else{
|
} else{
|
||||||
var arg = [node.rec.name, node.rec.cost_center_name,sel_val(pscript.ab_company_sel), pscript.chart_type];
|
var arg = [node.rec.name, node.rec.cost_center_name,sel_val(pscript.ab_company_sel), pscript.ctype];
|
||||||
}
|
}
|
||||||
|
|
||||||
$c_obj('GL Control','get_cl',arg.join(','),callback);
|
$c_obj('GL Control','get_cl',arg.join(','),callback);
|
||||||
@ -338,10 +479,6 @@ pscript.make_ledger_area = function() {
|
|||||||
pscript.gl_rep.innerHTML = '<img src="lib/images/icons/report.png" style="margin-right: 8px"><span class="link_type">Open Ledger</span>';
|
pscript.gl_rep.innerHTML = '<img src="lib/images/icons/report.png" style="margin-right: 8px"><span class="link_type">Open Ledger</span>';
|
||||||
pscript.gl_rep.onclick = function(){ pscript.make_report('gl'); }
|
pscript.gl_rep.onclick = function(){ pscript.make_report('gl'); }
|
||||||
|
|
||||||
//Budget report link
|
|
||||||
/*pscript.cc_rep = $a(pscript.ledger_area, 'div','', {fontSize: '14px',marginBottom: '8px', fontWeight: 'bold'});
|
|
||||||
pscript.cc_rep.innerHTML = '<img src="images/icons/report.png" style="margin-right: 8px"><span class="link_type">Budget vs Actual Analysis Report</span>';
|
|
||||||
pscript.cc_rep.onclick = function(){ pscript.make_report('budget'); }*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pscript.make_report = function(flag){
|
pscript.make_report = function(flag){
|
||||||
@ -352,12 +489,6 @@ pscript.make_report = function(flag){
|
|||||||
}
|
}
|
||||||
loadreport('GL Entry','General Ledger',callback);
|
loadreport('GL Entry','General Ledger',callback);
|
||||||
}
|
}
|
||||||
/*else {
|
|
||||||
loadreport('Budget Detail','Periodical Budget Report',function(f){
|
|
||||||
f.set_filter('Cost Center','ID',pscript.cur_node.rec.name);
|
|
||||||
f.dt.run();
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New Account
|
// New Account
|
||||||
@ -435,3 +566,4 @@ pscript.make_new_cost_center_dialog = function(){
|
|||||||
|
|
||||||
pscript.new_cost_center_dialog = pscript.cc_dialog;
|
pscript.new_cost_center_dialog = pscript.cc_dialog;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
31
erpnext/accounts/page/accounts_browser/accounts_browser.py
Normal file
31
erpnext/accounts/page/accounts_browser/accounts_browser.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import webnotes
|
||||||
|
|
||||||
|
@webnotes.whitelist()
|
||||||
|
def get_companies():
|
||||||
|
return [r[0] for r in webnotes.conn.sql("""select name from tabCompany where docstatus!=2""")]
|
||||||
|
|
||||||
|
@webnotes.whitelist()
|
||||||
|
def get_children():
|
||||||
|
args = webnotes.form_dict
|
||||||
|
ctype = args['ctype']
|
||||||
|
company_field = ctype=='Account' and 'company' or 'company_name'
|
||||||
|
|
||||||
|
# root
|
||||||
|
if args['parent'] in get_companies():
|
||||||
|
return webnotes.conn.sql("""select
|
||||||
|
name as value, if(group_or_ledger='Group', 1, 0) as expandable
|
||||||
|
from `tab%s`
|
||||||
|
where ifnull(parent_%s,'') = ''
|
||||||
|
and %s = %s
|
||||||
|
and docstatus<2
|
||||||
|
order by name""" % (ctype, ctype.lower().replace(' ','_'), company_field, '%s'),
|
||||||
|
args['parent'], as_dict=1)
|
||||||
|
|
||||||
|
# other
|
||||||
|
return webnotes.conn.sql("""select
|
||||||
|
name as value, if(group_or_ledger='Group', 1, 0) as expandable
|
||||||
|
from `tab%s`
|
||||||
|
where ifnull(parent_%s,'') = %s
|
||||||
|
and docstatus<2
|
||||||
|
order by name""" % (ctype, ctype.lower().replace(' ','_'), '%s'),
|
||||||
|
args['parent'], as_dict=1)
|
||||||
@ -1 +1 @@
|
|||||||
1683
|
1687
|
||||||
Loading…
x
Reference in New Issue
Block a user