moved directory structure

This commit is contained in:
Rushabh Mehta
2012-09-24 19:13:42 +05:30
parent e47a6779e9
commit 2fa2f7178d
1637 changed files with 47 additions and 11450 deletions

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,29 @@
select.accbrowser-company-select {
width: 200px;
margin-top: 2px;
margin-left: 10px;
}
span.tree-node-toolbar {
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;
}
span.balance-area {
float: right;
height: 13px;
}
span.balance-bold {
font-weight: bold;
}

View File

@@ -0,0 +1,12 @@
<div class="layout-wrapper layout-wrapper-background">
<div class="appframe-area"></div>
<div class="layout-main-section">
<div class="tree-area"></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>

View File

@@ -0,0 +1,256 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// tree of chart of accounts / cost centers
// multiple companies
// add node
// edit node
// see ledger
pscript['onload_Accounts Browser'] = function(wrapper){
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
if (wn.boot.profile.can_create.indexOf("Company") !== -1) {
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
wrapper.$company_select = $('<select class="accbrowser-company-select"></select>')
.change(function() {
var ctype = wn.get_route()[1] || 'Account';
erpnext.account_chart = new erpnext.AccountsChart(ctype, $(this).val(), wrapper);
})
.appendTo(wrapper.appframe.$w.find('.appframe-toolbar'));
// load up companies
wn.call({
method:'accounts.page.accounts_browser.accounts_browser.get_companies',
callback: function(r) {
wrapper.$company_select.empty();
$.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]).change();
}
});
}
pscript['onshow_Accounts Browser'] = function(wrapper){
// set route
var ctype = wn.get_route()[1] || 'Account';
wrapper.appframe.clear_breadcrumbs();
wrapper.appframe.add_breadcrumb('Chart of '+ctype+'s');
document.title = 'Chart of '+ctype+'s';
wrapper.appframe.add_breadcrumb(' in <a href="#!accounts-home">Accounts</a>');
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;
me.company = company;
this.tree = new wn.ui.Tree({
parent: $(wrapper).find('.tree-area'),
label: company,
args: {ctype: ctype, comp: company},
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);
}
// bold
$('.balance-bold').removeClass('balance-bold'); // deselect
$(link).parent().find('.balance-area:first').addClass('balance-bold'); // select
},
onrender: function(treenode) {
if (ctype == 'Account') {
var bal = treenode.data && treenode.data.balance.split(' ') || ['',''];
if (bal && flt(bal[1])) {
treenode.parent.append('<span class="balance-area">\
<span style="color: #aaa">'+ bal[0] + '</span> '
+ fmt_money(bal[1]) + '</span>');
}
}
}
});
this.tree.rootnode.$a.click();
},
make_link_toolbar: function(link) {
var data = $(link).data('node-data');
if(!data) return;
link.toolbar = $('<span class="tree-node-toolbar"></span>').insertAfter(link);
var node_links = [];
// edit
if (wn.boot.profile.can_read.indexOf(this.ctype) !== -1) {
node_links.push('<a href="#!Form/'+encodeURIComponent(this.ctype)+'/'
+encodeURIComponent(data.value)+'">Edit</a>');
}
if (data.expandable) {
if (wn.boot.profile.can_create.indexOf(this.ctype) !== -1 ||
wn.boot.profile.in_create.indexOf(this.ctype) !== -1) {
node_links.push('<a onclick="erpnext.account_chart.new_node();">Add Child</a>');
}
} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">View Ledger</a>');
}
link.toolbar.append(node_links.join(" | "));
},
show_ledger: function() {
var me = this;
var node = me.selected_node();
wn.set_route('Report', 'GL Entry', 'General Ledger',
this.ctype + '=' + node.data('label'));
},
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', description:'Further accounts can be made under Groups,\
but entries can be made against Ledger'},
{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:'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.tax_rate.wrapper).toggle(false);
} else {
$(fd.account_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.master_type = '';
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(){
var me = this;
// the dialog
var d = new wn.ui.Dialog({
title:'New Cost Center',
fields: [
{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', description:'Further accounts can be made under Groups,\
but entries can be made against Ledger'},
{fieldtype:'Button', fieldname:'create_new', label:'Create New' }
]
});
// 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();
}
});

View File

@@ -0,0 +1,64 @@
from __future__ import unicode_literals
import webnotes
from webnotes.utils import get_defaults, cstr
@webnotes.whitelist()
def get_companies():
"""get a list of companies based on permission"""
# check if match permission exists
res = webnotes.conn.sql("""select role, `match` from `tabDocPerm`
where parent='Account' and permlevel=0 and `read`=1""", as_dict=1)
match = any((r["match"] for r in res
if r["role"] in webnotes.user.roles and r["match"]=="company"))
# if match == company is specified and companies are specified in user defaults
if match and webnotes.user.get_defaults().get("company"):
return webnotes.user.get_defaults().get("company")
else:
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, company = args['ctype'], args['comp']
company_field = ctype=='Account' and 'company' or 'company_name'
# root
if args['parent'] == company:
acc = 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)
else:
# other
acc = 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)
if ctype == 'Account':
currency = webnotes.conn.sql("select default_currency from `tabCompany` where name = %s", company)[0][0]
for each in acc:
bal = webnotes.conn.sql("select balance from `tabAccount Balance` \
where account = %s and period = %s", (each.get('value'), get_defaults('fiscal_year')))
bal = bal and bal[0][0] or 0
each['balance'] = currency + ' ' + cstr(bal)
return acc
@webnotes.whitelist()
def get_account_balance():
args = webnotes.form_dict
acc = args['acc']
return 'Rs. 100'

View File

@@ -0,0 +1,44 @@
# Page, Accounts Browser
[
# These values are common in all dictionaries
{
'creation': '2010-12-14 10:23:28',
'docstatus': 0,
'modified': '2010-12-29 12:57:23',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all Page
{
'doctype': 'Page',
'module': 'Accounts',
'name': '__common__',
'page_name': 'Accounts Browser',
'show_in_menu': 0,
'standard': 'Yes'
},
# These values are common for all Page Role
{
'doctype': 'Page Role',
'idx': 1,
'name': '__common__',
'parent': 'Accounts Browser',
'parentfield': 'roles',
'parenttype': 'Page',
'role': 'Accounts User'
},
# Page, Accounts Browser
{
'doctype': 'Page',
'name': 'Accounts Browser'
},
# Page Role
{
'doctype': 'Page Role'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,160 @@
<div class="layout-wrapper layout-wrapper-background">
<div class="appframe-area"></div>
<div class="layout-main-section">
<div style="width: 48%; float: left;">
<h4><a href="#!List/Journal Voucher">Journal Voucher</a></h4>
<p class="help">General Ledger Entries</p>
<br>
<h4><a href="#!List/Sales Invoice">Sales Invoice</a></h4>
<p class="help">Bills raised to Customers</p>
<br>
<h4><a href="#!List/Purchase Invoice">Purchase Invoice</a></h4>
<p class="help">Bills raised by Suppliers</p>
</div>
<div style="width: 48%; float: right;">
<h4><a href="#!Accounts Browser/Account">Chart of Accounts</a></h4>
<p class="help">Structure of books of accounts</p>
<br>
<h4><a href="#!Accounts Browser/Cost Center">Chart of Cost Centers</a></h4>
<p class="help">Structure cost centers</p>
<br>
<h4><a href="#general-ledger" data-role="Analytics">General Ledger</a>
<span style="background-color: #fed; font-weight: normal; font-size: 80%">beta</span>
</h4>
<p class="help">General Ledger Report</p>
<br>
<h4><a href="#trial-balance" data-role="Analytics">Trial Balance</a>
<span style="background-color: #fed; font-weight: normal; font-size: 80%">beta</span>
</h4>
<p class="help">Tree view of all Account balances</p>
<br>
<h4><a href="#financial-analytics" data-role="Analytics">Financial Analytics</a>
<span style="background-color: #fed; font-weight: normal; font-size: 80%">beta</span>
</h4>
<p class="help">Visual representation of financial trends</p>
</div>
<div style="clear: both"></div>
<hr>
<h3>Reports</h3>
<div class="reports-list"></div>
</div>
<div class="layout-side-section">
<div class="psidebar">
<div class="section">
<div class="section-head">Tools</div>
<div class="section-body">
<div class="section-item">
<a class="section-link"
title="Update system bank entries (JV) with actual bank trasaction"
href="#!Form/Bank Reconciliation/Bank Reconciliation">Bank Reconciliation</a>
</div>
<div class="section-item">
<a class="section-link"
title="Cancel off untracked Payments (JV) against Invoices"
href="#!Form/Payment to Invoice Matching Tool/Payment to Invoice Matching Tool">Payment Reconciliation</a>
</div>
<div class="section-item">
<a class="section-link"
title="Clear your P/L account and balance your Balance Sheets"
href="#!List/Period Closing Voucher">Close Period Entry</a>
</div>
<div class="section-item">
<a class="section-link"
title="Export multiple Account Ledgers (GL) to spreadsheet (csv)"
href="#!Form/Multi Ledger Report/Multi Ledger Report">Export Multiple Ledgers (GL)</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Helper for managing return of goods (sales or purchase)"
href="#!Form/Sales and Purchase Return Tool/Sales and Purchase Return Tool">Sales or Purchase Returns</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Analyze Sales and Purchase trends and slice them based on item, customer, groups etc"
href="#!Report/Profile/Trend Analyzer">Trend Analyzer</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Check your Balance Sheet and Profit & Loss Statement"
href="#!Financial Statements">Financial Statements</a>
</div>
</div>
</div>
<div class="section">
<div class="section-head">Setup</div>
<div class="section-body">
<div class="section-item">
<a class="section-link"
title = "Tax and charges structure master on sales transactions"
href="#!List/Sales Taxes and Charges Master">Sales Taxes and Charges Master</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Tax and charges structure master on purchase transactions"
href="#!List/Purchase Taxes and Charges Master">Purchase Taxes and Charges Master</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Defaults for Point of Sale (Retail) type of Invoices"
href="#!List/POS Setting">Point of Sale (PoS) Setting</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Seasonal distributions for budgets"
href="#!List/Budget Distribution">Budget Distribution</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Terms of contract template"
href="#!List/Terms and Conditions">Terms and Conditions Template</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Mode of Payment master"
href="#!List/Mode of Payment">Mode of Payment</a>
</div>
</div>
</div>
<div class="section india-specific">
<div class="section-head">Tax Deduction (India)</div>
<div class="section-body">
<div class="section-item">
<a class="section-link"
title = "Tax Deduction at Source (TDS) payments to be made to the goverment"
href="#!List/TDS Payment">TDS Payments</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Update with acknowledgement recd from the government"
href="#!List/TDS Return Acknowledgement">TDS Return Acknowledgement</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Tax deduction (TDS) categories"
href="#!List/TDS Category">TDS Category</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Tax deduction (TDS) rates for different periods"
href="#!List/TDS Rate Chart">TDS Rate Chart</a>
</div>
<div class="section-item">
<a class="section-link"
title = "Challan given to employees/suppliers whose tax (TDS) has been deducted"
href="#!List/Form 16A">Form 16A</a>
</div>
<div class="section-item">
<a class="section-link"
title = "C-Forms received from customers"
href="#!List/C-Form">C-Form</a>
</div>
</div>
</div>
</div>
</div>
<div style="clear: both;"></div>
</div>

View File

@@ -0,0 +1,32 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pscript['onload_accounts-home'] = function(wrapper) {
erpnext.module_page.setup_page('Accounts', wrapper);
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'), 'Accounts');
if(wn.control_panel.country!='India') {
$('.india-specific').toggle(false);
}
if(wn.boot.profile.roles.indexOf('Accounts Manager')==-1 && wn.boot.profile.roles.indexOf('Accounts User')==-1) {
$('[href*="Accounts Browser"]').each(function() {
var txt = $(this).text();
$(this).parent().css('color', '#999').html(txt);
});
}
}

View File

@@ -0,0 +1,28 @@
# Page, accounts-home
[
# These values are common in all dictionaries
{
'creation': '2012-02-21 13:23:08',
'docstatus': 0,
'modified': '2012-02-21 13:23:08',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Page
{
'doctype': 'Page',
'module': u'Accounts',
'name': '__common__',
'page_name': u'accounts-home',
'standard': u'Yes',
'title': u'Accounts Home'
},
# Page, accounts-home
{
'doctype': 'Page',
'name': u'accounts-home'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,191 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.require("app/js/account_tree_grid.js");
wn.pages['financial-analytics'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: 'Financial Analytics',
single_column: true
});
erpnext.trial_balance = new erpnext.FinancialAnalytics(wrapper, 'Financial Analytics');
}
erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({
filters: [
{fieldtype:"Select", label: "PL or BS", options:["Profit and Loss", "Balance Sheet"],
filter: function(val, item, opts, me) {
if(item._show) return true;
// pl or bs
var out = (val!='Balance Sheet') ? item.is_pl_account=='Yes' : item.is_pl_account!='Yes';
if(!out) return false;
return me.apply_zero_filter(val, item, opts, me);
}},
{fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
filter: function(val, item, opts) {
return item.company == val || val == opts.default_value || item._show;
}},
{fieldtype:"Select", label: "Fiscal Year", link:"Fiscal Year",
default_value: "Select Fiscal Year..."},
{fieldtype:"Date", label: "From Date"},
{fieldtype:"Label", label: "To"},
{fieldtype:"Date", label: "To Date"},
{fieldtype:"Select", label: "Range",
options:["Daily", "Weekly", "Monthly", "Quarterly", "Yearly"]},
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: "Reset Filters"}
],
setup_columns: function() {
var std_columns = [
{id: "check", name: "Plot", field: "check", width: 30,
formatter: this.check_formatter},
{id: "name", name: "Account", field: "name", width: 300,
formatter: this.tree_formatter},
{id: "opening", name: "Opening", field: "opening", hidden: true,
formatter: this.currency_formatter}
];
this.make_date_range_columns();
this.columns = std_columns.concat(this.columns);
},
setup_filters: function() {
var me = this;
this._super();
this.filter_inputs.pl_or_bs.change(function() {
me.filter_inputs.refresh.click();
}).add_options($.map(wn.report_dump.data["Cost Center"], function(v) {return v.name;}));
this.setup_plot_check();
},
init_filter_values: function() {
this._super();
this.filter_inputs.range.val('Weekly');
},
prepare_balances: function() {
var me = this;
// setup cost center map
if(!this.cost_center_by_name) {
this.cost_center_by_name = this.make_name_map(wn.report_dump.data["Cost Center"]);
}
var cost_center = inList(["Balance Sheet", "Profit and Loss"], this.pl_or_bs)
? null : this.cost_center_by_name[this.pl_or_bs];
$.each(wn.report_dump.data['GL Entry'], function(i, gl) {
var filter_by_cost_center = (function() {
if(cost_center) {
if(gl.cost_center) {
var gl_cost_center = me.cost_center_by_name[gl.cost_center];
return gl_cost_center.lft >= cost_center.lft && gl_cost_center.rgt <= cost_center.rgt;
} else {
return false;
}
} else {
return true;
}
})();
if(filter_by_cost_center) {
var posting_date = dateutil.str_to_obj(gl.posting_date);
var account = me.item_by_name[gl.account];
var col = me.column_map[gl.posting_date];
if(col) {
if(gl.voucher_type=='Period Closing Voucher') {
// period closing voucher not to be added
// to profit and loss accounts (else will become zero!!)
if(account.is_pl_account!='Yes')
me.add_balance(col.field, account, gl);
} else {
me.add_balance(col.field, account, gl);
}
} else if(account.is_pl_account!='Yes'
&& (posting_date < dateutil.str_to_obj(me.from_date))) {
me.add_balance('opening', account, gl);
}
}
});
// make balances as cumulative
if(me.pl_or_bs=='Balance Sheet') {
$.each(me.data, function(i, ac) {
if((ac.rgt - ac.lft)==1 && ac.is_pl_account!='Yes') {
var opening = flt(ac.opening);
//if(opening) throw opening;
$.each(me.columns, function(i, col) {
if(col.formatter==me.currency_formatter) {
ac[col.field] = opening + flt(ac[col.field]);
opening = ac[col.field];
}
});
}
})
}
this.update_groups();
this.accounts_initialized = true;
},
add_balance: function(field, account, gl) {
account[field] = flt(account[field]) +
((account.debit_or_credit == "Debit" ? 1 : -1) * (flt(gl.debit) - flt(gl.credit)))
},
init_account: function(d) {
// set 0 values for all columns
this.reset_item_values(d);
// check for default graphs
if(!this.accounts_initialized && !d.parent_account) {
d.checked = true;
}
},
get_plot_data: function() {
var data = [];
var me = this;
var pl_or_bs = this.pl_or_bs;
$.each(this.data, function(i, account) {
var show = pl_or_bs != "Balance Sheet" ? account.is_pl_account=="Yes" : account.is_pl_account!="Yes";
if (show && account.checked && me.apply_filter(account, "company")) {
data.push({
label: account.name,
data: $.map(me.columns, function(col, idx) {
if(col.formatter==me.currency_formatter && !col.hidden) {
if (pl_or_bs != "Balance Sheet") {
return [[dateutil.str_to_obj(col.id).getTime(), account[col.field]],
[dateutil.user_to_obj(col.name).getTime(), account[col.field]]];
} else {
return [[dateutil.user_to_obj(col.name).getTime(), account[col.field]]];
}
}
}),
points: {show: true},
lines: {show: true, fill: true},
});
if(pl_or_bs == "Balance Sheet") {
// prepend opening for balance sheet accounts
data[data.length-1].data = [[dateutil.str_to_obj(me.from_date).getTime(),
account.opening]].concat(data[data.length-1].data);
}
}
});
return data;
}
})

View File

@@ -0,0 +1,28 @@
# Page, financial-analytics
[
# These values are common in all dictionaries
{
u'creation': '2012-09-17 13:46:47',
u'docstatus': 0,
u'modified': '2012-09-17 13:46:47',
u'modified_by': u'Administrator',
u'owner': u'Administrator'
},
# These values are common for all Page
{
u'doctype': u'Page',
'module': u'Accounts',
u'name': u'__common__',
'page_name': u'financial-analytics',
'standard': u'Yes',
'title': u'Financial Analytics'
},
# Page, financial-analytics
{
u'doctype': u'Page',
u'name': u'financial-analytics'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,31 @@
<div class="layout_wrapper">
<div id="fs_header"></div>
<!-- table.statement td { vertical-align: middle; } table.statement td select { width: 100px; } table.stmt_table { table-layout: fixed; border-collapse: collapse; } table.stmt_table td { vertical-align: middle; padding: 2px; } td.stmt_level0 { font-weight: bold; font-size: 14px; border-bottom: 1px solid #AAA; } td.stmt_level1 { font-weight: bold; font-size: 12px; } td.stmt_level2 { font-size: 11px; } td.stmt_level3 { font-size: 11px; } td.stmt_level4 { font-size: 12px; font-weight: bold; border-bottom: 1px solid #000; } td.stmt_level5 { color: BLUE; font-size: 11px; } --> <!--
<div style="border: 1px solid #cccccc; padding: 4px; margin-top: 8px; background-color: #eeeeee; width: 98%;">
<table class="statement" border="0" cellspacing="2px">
<tbody>
<tr>
<td>Statement:</td>
<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="stmt_type"></select></td>
<td>Company:</td>
<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="stmt_company"></select></td>
<td>Period Type:</td>
<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="stmt_period"></select></td>
<td>Fiscal Year:</td>
<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="stmt_fiscal_year"></select></td>
<td style="padding-right: 8px;" mce_style="padding-right: 8px;">
<div id="stmt_new"></div>
</td>
</tr>
</tbody>
</table>
</div>
--> <!--
<div style="margin:10px 0px 10px 0px" mce_style="margin:10px 0px 10px 0px"><button class="button" onclick="pscript.print_statement();">Print</button></div>
-->
<div id="print_html">
<div id="stmt_title1" style="margin:16px 0px 4px 0px; font-size: 16px; font-weight: bold; color: #888;"></div>
<div id="stmt_title2" style="margin:0px 0px 8px 0px; font-size: 16px; font-weight: bold;"></div>
<div id="stmt_tree" style="margin: 0px 0px 16px; overflow: auto; display: none; width: 100%;"></div>
</div>
</div>

View File

@@ -0,0 +1,163 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pscript['onload_Financial Statements'] = function() {
// header and toolbar
var h = new PageHeader('fs_header','Financial Statements','Profit & Loss and Balance Sheet Builder across multiple years');
//$y(h.toolbar_area,{padding:'8px'});
var dv = $a(h.toolbar_area,'div','',{margin:'4px 0px'});
var t = make_table(dv,1,4,'640px', [], {padding:'4px', width:'160px'});
var sel = $a($td(t,0,0),'select','',{width:'160px'});
sel.id = 'stmt_type';
var sel = $a($td(t,0,1),'select','',{width:'160px'});
sel.id = 'stmt_company';
var sel = $a($td(t,0,2),'select','',{width:'160px'});
sel.id = 'stmt_period';
var sel = $a($td(t,0,3),'select','',{width:'160px'});
sel.id = 'stmt_fiscal_year';
h.add_button('Create',function(){ pscript.stmt_new(); },0,'ui-icon-document');
h.add_button('Print', function(){ _p.go($i('print_html').innerHTML); }, 0, 'ui-icon-print');
/*
var btn = $a($td(t,1,0),'button');
btn.onclick = function(){ pscript.stmt_new(); }
btn.innerHTML = 'Create';
var btn = $a($td(t,1,1),'button');
btn.onclick = function(){ alert('print'); }
btn.innerHTML = 'Print';
//Button to create new
var btn = $a('stmt_new', 'button');
btn.onclick = function() { pscript.stmt_new(); }
btn.innerHTML = 'Create';*/
// select for statement
add_sel_options($i('stmt_type'), ['Select Statement...','Balance Sheet','Profit & Loss']);
// select for companies
add_sel_options($i('stmt_company'), ['Loading Companies...']);
// load companies
$c_obj('MIS Control','get_comp','', function(r,rt) {
// company
empty_select($i('stmt_company'));
add_sel_options($i('stmt_company'), add_lists(['Select Company...'], r.message.company), 'Select Company...');
// period
empty_select($i('stmt_period'));
//add_sel_options($i('stmt_period'), add_lists(['Select Period...'], r.message.period), 'Select period...');
add_sel_options($i('stmt_period'), add_lists(['Select Period...'], ['Annual', 'Quarterly', 'Monthly']), 'Select period...');
// fiscal-year
empty_select($i('stmt_fiscal_year'));
add_sel_options($i('stmt_fiscal_year'), add_lists(['Select Year...'], r.message.fiscal_year), 'Select fiscal year...');
});
}
pscript.stmt_new = function(stmt,company_name,level,period,year) {
$i('stmt_tree').innerHTML = 'Refreshing....';
$i('stmt_tree').style.display = 'block';
var arg = {
statement:sel_val($i('stmt_type'))
,company:sel_val($i('stmt_company'))
,period:sel_val($i('stmt_period'))
,year:sel_val($i('stmt_fiscal_year'))
}
$c_obj('MIS Control', 'get_statement', docstring(arg), function(r,rt) {
var nl = r.message;
var t = $i('stmt_tree');
var stmt_type = sel_val($i('stmt_type'));
t.innerHTML = '';
var tab = $a($a(t, 'div'),'table','stmt_table');
tab.style.tableLayout = 'fixed';
tab.style.width = '100%';
$i('stmt_title1').innerHTML = sel_val($i('stmt_company'));
$i('stmt_title2').innerHTML = sel_val($i('stmt_type')) + ' - ' + sel_val($i('stmt_fiscal_year'));
for(i=0;i<nl.length;i++) {
tab.insertRow(i);
tab.rows[i].style.height = '20px';
// heads
var per = tab.rows[i].insertCell(0);
// var acc_width = (sel_val($i('stmt_period'))=='Monthly')? 12 : 20;
// per.style.width = acc_width+'%';
per.style.width = '150px';
per.innerHTML = pscript.space_reqd(nl[i][0])+cstr(nl[i][1]);
per.className = 'stmt_level' + nl[i][0];
// Make Title Bold
if(nl[i][0] == 0 || nl[i][0] == 1 || nl[i][0] == 4){
per.innerHTML = (pscript.space_reqd(nl[i][0])+cstr(nl[i][1])+'').bold();
per.style.fontSize = '12px';
}
for(j=2;j<nl[i].length;j++){
var per = tab.rows[i].insertCell(j-1);
// per.style.width = (100-acc_width)/(nl[i].length-2) +'%';
per.style.width = '150px';
per.style.textAlign = "right";
per.className = 'stmt_level' + nl[i][0];
if (i==0) {
per.style.fontSize = '14px';
per.style.textAlign = "right";
}
if (nl[i][0]==5) {
if(flt(nl[i][j])<0.0) per.style.color = "RED";
else per.style.color = "GREEN";
}
if(nl[i][0] != 0){
if(nl[i][j]) {
if (i==0) per.innerHTML = (nl[i][j]+'').bold();
else if(nl[i][0] == 1 || nl[i][0] == 4) per.innerHTML = (cstr(fmt_money(nl[i][j]))+'').bold();
else per.innerHTML = fmt_money(nl[i][j])
} else
per.innerHTML = '-';
}
}
}
});
$i('stmt_tree').style.display = 'block';
}
//printing statement
pscript.print_statement = function(){
print_go($i('print_html').innerHTML);
}
//determine space to be given
pscript.space_reqd = function(val){
if(val == 1) return ' ';
else if(val == 2) return ' ';
else if(val == 3) return ' ';
else return '';
}

View File

@@ -0,0 +1,58 @@
# Page, Financial Statements
[
# These values are common in all dictionaries
{
'creation': '2010-10-12 15:19:32',
'docstatus': 0,
'modified': '2011-01-03 17:32:30',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all Page
{
'doctype': 'Page',
'module': 'Accounts',
'name': '__common__',
'page_name': 'Financial Statements',
'show_in_menu': 0,
'standard': 'Yes'
},
# These values are common for all Page Role
{
'doctype': 'Page Role',
'name': '__common__',
'parent': 'Financial Statements',
'parentfield': 'roles',
'parenttype': 'Page'
},
# Page, Financial Statements
{
'doctype': 'Page',
'name': 'Financial Statements'
},
# Page Role
{
'doctype': 'Page Role',
'idx': 1,
'role': 'Accounts User'
},
# Page Role
{
'doctype': 'Page Role',
'idx': 2,
'role': 'Administrator'
},
# Page Role
{
'doctype': 'Page Role',
'idx': 3,
'role': 'Accounts Manager'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,199 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.pages['general-ledger'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: 'General Ledger',
single_column: true
});
erpnext.general_ledger = new wn.views.GridReport({
title: "General Ledger",
page: wrapper,
parent: $(wrapper).find('.layout-main'),
appframe: wrapper.appframe,
doctypes: ["Company", "Account", "GL Entry", "Cost Center"],
setup_columns: function() {
this.columns = [
{id: "posting_date", name: "Posting Date", field: "posting_date", width: 100,
formatter: this.date_formatter},
{id: "account", name: "Account", field: "account", width: 240,
link_formatter: {
filter_input: "account",
open_btn: true,
}},
{id: "debit", name: "Debit", field: "debit", width: 100,
formatter: this.currency_formatter},
{id: "credit", name: "Credit", field: "credit", width: 100,
formatter: this.currency_formatter},
{id: "voucher_type", name: "Voucher Type", field: "voucher_type", width: 120},
{id: "voucher_no", name: "Voucher No", field: "voucher_no", width: 160,
link_formatter: {
filter_input: "voucher_no",
open_btn: true,
doctype: "dataContext.voucher_type"
}},
{id: "remarks", name: "Remarks", field: "remarks", width: 200,
formatter: this.text_formatter},
];
},
filters: [
{fieldtype:"Select", label: "Company", link:"Company", default_value: "Select Company...",
filter: function(val, item, opts) {
return item.company == val || val == opts.default_value;
}},
{fieldtype:"Select", label: "Account", link:"Account", default_value: "Select Account...",
filter: function(val, item, opts, me) {
if(val == opts.default_value) {
return true;
} else {
// true if GL Entry belongs to selected
// account ledger or group
return me.is_child_account(val, item.account);
}
}},
{fieldtype:"Data", label: "Voucher No",
filter: function(val, item, opts) {
if(!val) return true;
return (item.voucher_no && item.voucher_no.indexOf(val)!=-1);
}},
{fieldtype:"Date", label: "From Date", filter: function(val, item) {
return dateutil.str_to_obj(val) <= dateutil.str_to_obj(item.posting_date);
}},
{fieldtype:"Label", label: "To"},
{fieldtype:"Date", label: "To Date", filter: function(val, item) {
return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date);
}},
{fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
{fieldtype:"Button", label: "Reset Filters"}
],
is_child_account: function(account, item_account) {
account = this.account_by_name[account];
item_account = this.account_by_name[item_account];
return (item_account.lft >= account.lft && item_account.rgt <= account.rgt)
},
prepare_data: function() {
// add Opening, Closing, Totals rows
// if filtered by account and / or voucher
var data = wn.report_dump.data["GL Entry"];
var out = [];
if(!this.account_by_name)
this.account_by_name = this.make_name_map(wn.report_dump.data["Account"]);
var me = this;
var from_date = dateutil.str_to_obj(this.from_date);
var to_date = dateutil.str_to_obj(this.to_date);
if(to_date < from_date) {
msgprint("From Date must be before To Date");
return;
}
var opening = {
account: "Opening", debit: 0.0, credit: 0.0,
id:"_opening", _show: true, _style: "font-weight: bold"
}
var totals = {
account: "Totals", debit: 0.0, credit: 0.0,
id:"_totals", _show: true, _style: "font-weight: bold"
}
$.each(data, function(i, item) {
if((!me.is_default("account") ? me.is_child_account(me.account, item.account) : true) &&
(me.voucher_no ? item.voucher_no==me.voucher_no : true)) {
var date = dateutil.str_to_obj(item.posting_date);
if(date < from_date) {
opening.debit += item.debit;
opening.credit += item.credit;
} else if(date <= to_date) {
totals.debit += item.debit;
totals.credit += item.credit;
}
if(me.apply_filters(item)) {
out.push(item);
}
}
})
var closing = {
account: "Closing (Opening + Totals)", debit: opening.debit + totals.debit,
credit: opening.credit + totals.credit,
id:"_closing", _show: true, _style: "font-weight: bold"
}
if(!me.is_default("account")) {
if(me.account_by_name[me.account].debit_or_credit == "Debit") {
opening.debit -= opening.credit; opening.credit = 0;
closing.debit -= closing.credit; closing.credit = 0;
} else {
opening.credit -= opening.debit; opening.debit = 0;
closing.credit -= closing.debit; closing.debit = 0;
}
var out = [opening].concat(out).concat([totals, closing]);
} else {
var out = out.concat([totals]);
}
this.data = out;
},
get_plot_data: function() {
var data = [];
var me = this;
if(me.is_default("account") || me.voucher_no) return false;
var debit_or_credit = me.account_by_name[me.account].debit_or_credit;
var balance = debit_or_credit=="Debit" ? me.data[0].debit : me.data[0].credit;
data.push({
label: me.account,
data: [[dateutil.str_to_obj(me.from_date).getTime(), balance]]
.concat($.map(me.data, function(col, idx) {
if (col.posting_date) {
var diff = (debit_or_credit == "Debit" ? 1 : -1) * (flt(col.debit) - flt(col.credit));
balance += diff;
return [[dateutil.str_to_obj(col.posting_date).getTime(), balance - diff],
[dateutil.str_to_obj(col.posting_date).getTime(), balance]]
}
return null;
})).concat([
// closing
[dateutil.str_to_obj(me.to_date).getTime(), balance]
]),
points: {show: true},
lines: {show: true, fill: true},
});
return data;
},
get_plot_options: function() {
return {
grid: { hoverable: true, clickable: true },
xaxis: { mode: "time",
min: dateutil.str_to_obj(this.from_date).getTime(),
max: dateutil.str_to_obj(this.to_date).getTime() }
}
},
});
}

View File

@@ -0,0 +1,28 @@
# Page, general-ledger
[
# These values are common in all dictionaries
{
'creation': '2012-09-13 13:50:13',
'docstatus': 0,
'modified': '2012-09-13 13:50:13',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all Page
{
'doctype': 'Page',
'module': u'Accounts',
'name': '__common__',
'page_name': u'general-ledger',
'standard': u'Yes',
'title': u'General Ledger'
},
# Page, general-ledger
{
'doctype': 'Page',
'name': u'general-ledger'
}
]

View File

@@ -0,0 +1 @@
from __future__ import unicode_literals

View File

@@ -0,0 +1,26 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.require("app/js/account_tree_grid.js");
wn.pages['trial-balance'].onload = function(wrapper) {
wn.ui.make_app_page({
parent: wrapper,
title: 'Trial Balance',
single_column: true
});
erpnext.trial_balance = new erpnext.AccountTreeGrid(wrapper, 'Trial Balance');
}

View File

@@ -0,0 +1,28 @@
# Page, trial-balance
[
# These values are common in all dictionaries
{
u'creation': '2012-09-17 13:47:16',
u'docstatus': 0,
u'modified': '2012-09-17 13:47:16',
u'modified_by': u'Administrator',
u'owner': u'Administrator'
},
# These values are common for all Page
{
u'doctype': u'Page',
'module': u'Accounts',
u'name': u'__common__',
'page_name': u'trial-balance',
'standard': u'Yes',
'title': u'Trial Balance'
},
# Page, trial-balance
{
u'doctype': u'Page',
u'name': u'trial-balance'
}
]