Permalink
Browse files

added flot for graphs in report_grid

  • Loading branch information...
1 parent f16b28b commit 4156523175b9f4b4b8c23af6152b59944c35a24a @rmehta rmehta committed Sep 17, 2012
Showing with 667 additions and 491 deletions.
  1. +0 −9 build.json
  2. +0 −272 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.js
  3. +0 −49 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.py
  4. +0 −28 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.txt
  5. 0 erpnext/accounts/page/{chart_of_accounts → financial_analytics}/__init__.py
  6. +226 −0 erpnext/accounts/page/financial_analytics/financial_analytics.js
  7. +28 −0 erpnext/accounts/page/financial_analytics/financial_analytics.txt
  8. +30 −16 erpnext/accounts/page/general_ledger/general_ledger.js
  9. 0 erpnext/accounts/page/{chart_of_accounts/chart_of_accounts.html → trial_balance/__init__.py}
  10. +27 −0 erpnext/accounts/page/trial_balance/trial_balance.js
  11. +28 −0 erpnext/accounts/page/trial_balance/trial_balance.txt
  12. +1 −1 erpnext/projects/page/projects/projects.js
  13. +2 −2 erpnext/startup/event_handlers.py
  14. +5 −0 erpnext/startup/report_data_map.py
  15. +1 −1 erpnext/startup/startup.js
  16. +1 −1 erpnext/utilities/page/questions/questions.js
  17. +13 −11 public/js/all-app.js
  18. +4 −4 public/js/all-web.js
  19. 0 erpnext/accounts/page/chart_of_accounts/chart_of_accounts.css → public/js/app/account_tree_grid.css
  20. +259 −0 public/js/app/account_tree_grid.js
  21. 0 {erpnext/startup/js → public/js/app}/complete_setup.js
  22. 0 {erpnext/projects → public/js/app}/gantt_task.js
  23. 0 {erpnext/utilities/page/kb_common → public/js/app}/kb_common.js
  24. +0 −10 public/js/complete_setup.js
  25. +0 −10 public/js/gantt_task.js
  26. +0 −30 public/js/kb_common.js
  27. +0 −4 public/js/listing.js
  28. +0 −41 public/js/print_query.js
  29. +42 −2 public/js/report-legacy.js
View
@@ -17,13 +17,4 @@
"erpnext/startup/js/feature_setup.js",
"conf.js"
],
- "public/js/kb_common.js": [
- "erpnext/utilities/page/kb_common/kb_common.js",
- ],
- "public/js/complete_setup.js": [
- "erpnext/startup/js/complete_setup.js",
- ],
- "public/js/gantt_task.js": [
- "erpnext/projects/gantt_task.js",
- ]
}
@@ -1,272 +0,0 @@
-// 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/>.
-
-/* todo
- - load / display chart of accounts
- - settings for company, start date, end data
- - load balances
- - open ledger on link
-*/
-
-wn.pages['chart-of-accounts'].onload = function(wrapper) {
- wn.ui.make_app_page({
- parent: wrapper,
- title: 'Chart of Accounts',
- single_column: true
- });
-
- erpnext.coa = new wn.views.GridReport({
- title: "Chart of Accounts",
- parent: $(wrapper).find('.layout-main'),
- appframe: wrapper.appframe,
- doctypes: ["Company", "Fiscal Year", "Account", "GL Entry"],
- setup: function() {
- this.setup_filters();
- this.setup_columns();
- },
- setup_columns: function() {
- this.columns = [
- {id: "name", name: "Account", field: "name", width: 300, cssClass: "cell-title",
- formatter: this.account_formatter},
- {id: "opening_debit", name: "Opening (Dr)", field: "opening_debit", width: 100,
- formatter: this.currency_formatter},
- {id: "opening_credit", name: "Opening (Cr)", field: "opening_credit", width: 100,
- formatter: this.currency_formatter},
- {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: "closing_debit", name: "Closing (Dr)", field: "closing_debit", width: 100,
- formatter: this.currency_formatter},
- {id: "closing_credit", name: "Closing (Cr)", field: "closing_credit", width: 100,
- formatter: this.currency_formatter}
- ];
-
- },
- filters: [
- {fieldtype:"Select", label: "Company", options:"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", options:"Fiscal Year",
- default_value: "Select Fiscal Year..."},
- {fieldtype:"Date", label: "From Date"},
- {fieldtype:"Label", label: "To"},
- {fieldtype:"Date", label: "To Date"},
- {fieldtype:"Button", label: "Refresh", icon:"icon-refresh icon-white", cssClass:"btn-info"},
- {fieldtype:"Button", label: "Reset Filters"}
- ],
- setup_filters: function() {
- var me = this;
- // default filters
- this.init_filter_values();
- this.filter_inputs.refresh.click(function() { me.set_route(); })
- this.filter_inputs.reset_filters.click(function() { me.init_filter_values(); me.set_route(); });
- this.filter_inputs.fiscal_year.change(function() {
- var fy = $(this).val();
- $.each(wn.report_dump.data["Fiscal Year"], function(i, v) {
- if (v.name==fy) {
- me.filter_inputs.from_date.val(dateutil.str_to_user(v.year_start_date));
- me.filter_inputs.to_date.val(dateutil.str_to_user(v.year_end_date));
- }
- });
- me.set_route();
- });
- },
- init_filter_values: function() {
- this.filter_inputs.company.val(sys_defaults.company);
- this.filter_inputs.fiscal_year.val(sys_defaults.fiscal_year);
- this.filter_inputs.from_date.val(dateutil.str_to_user(sys_defaults.year_start_date));
- this.filter_inputs.to_date.val(dateutil.str_to_user(sys_defaults.year_end_date));
- },
- prepare_data: function() {
- var data = [];
- var parent_map = {};
- var data_by_name = {};
- $.each(wn.report_dump.data["Account"], function(i, v) {
- var d = $.extend(copy_dict(v), {
- "opening_debit": 0,
- "opening_credit": 0,
- "debit": 0,
- "credit": 0,
- "closing_debit": 0,
- "closing_credit": 0
- });
-
- data.push(d);
- data_by_name[d.name] = d;
- if(d.parent_account) {
- parent_map[d.name] = d.parent_account;
- }
- });
- this.set_indent(data, parent_map);
- this.accounts = data;
- this.parent_map = parent_map;
- this.accounts_by_name = data_by_name;
- this.prepare_balances();
- this.prepare_data_view(this.accounts);
- },
- prepare_balances: function() {
- var gl = wn.report_dump.data['GL Entry'];
- var me = this;
-
- this.opening_date = dateutil.user_to_obj(this.filter_inputs.from_date.val());
- this.closing_date = dateutil.user_to_obj(this.filter_inputs.to_date.val());
- this.set_fiscal_year();
- if (!this.fiscal_year) return;
-
- $.each(this.accounts, function(i, v) {
- v.opening_debit = v.opening_credit = v.debit
- = v.credit = v.closing_debit = v.closing_credit = 0;
- });
-
- $.each(gl, function(i, v) {
- var posting_date = dateutil.str_to_obj(v.posting_date);
- var account = me.accounts_by_name[v.account];
- me.update_balances(account, posting_date, v)
- });
-
- this.update_groups();
- },
- update_balances: function(account, posting_date, v) {
- // opening
- if (posting_date < this.opening_date || v.is_opening === "Yes") {
- if (account.is_pl_account === "Yes" &&
- posting_date <= dateutil.str_to_obj(this.fiscal_year[1])) {
- // balance of previous fiscal_year should
- // not be part of opening of pl account balance
- } else {
- if(account.debit_or_credit=='Debit') {
- account.opening_debit += (v.debit - v.credit);
- } else {
- account.opening_credit += (v.credit - v.debit);
- }
- }
- } else if (this.opening_date <= posting_date && posting_date <= this.closing_date) {
- // in between
- account.debit += v.debit;
- account.credit += v.credit;
- }
- // closing
- if(account.debit_or_credit=='Debit') {
- account.closing_debit = account.opening_debit + account.debit - account.credit;
- } else {
- account.closing_credit = account.opening_credit - account.debit + account.credit;
- }
- },
- update_groups: function() {
- // update groups
- var me= this;
- $.each(this.accounts, function(i, account) {
- // update groups
- var parent = me.parent_map[account.name];
- while(parent) {
- parent_account = me.accounts_by_name[parent];
- parent_account.opening_debit += account.opening_debit;
- parent_account.opening_credit += account.opening_credit;
- parent_account.debit += account.debit;
- parent_account.credit += account.credit;
- parent_account.closing_debit += account.closing_debit;
- parent_account.closing_credit += account.closing_credit;
- parent = me.parent_map[parent];
- }
- });
- },
-
- set_fiscal_year: function() {
- if (this.opening_date > this.closing_date) {
- msgprint("Opening Date should be before Closing Date");
- return;
- }
-
- this.fiscal_year = null;
- var me = this;
- $.each(wn.report_dump.data["Fiscal Year"], function(i, v) {
- if (me.opening_date >= dateutil.str_to_obj(v.year_start_date) &&
- me.closing_date <= dateutil.str_to_obj(v.year_end_date)) {
- me.fiscal_year = v;
- }
- });
-
- if (!this.fiscal_year) {
- msgprint("Opening Date and Closing Date should be within same Fiscal Year");
- return;
- }
- },
- set_indent: function(data, parent_map) {
- $.each(data, function(i, d) {
- var indent = 0;
- var parent = parent_map[d.name];
- if(parent) {
- while(parent) {
- indent++;
- parent = parent_map[parent];
- }
- }
- d.indent = indent;
- });
- },
- account_formatter: function (row, cell, value, columnDef, dataContext) {
- value = value.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
- var data = erpnext.coa.accounts;
- var spacer = "<span style='display:inline-block;height:1px;width:" +
- (15 * dataContext["indent"]) + "px'></span>";
- var idx = erpnext.coa.dataView.getIdxById(dataContext.id);
- if (data[idx + 1] && data[idx + 1].indent > data[idx].indent) {
- if (dataContext._collapsed) {
- return spacer + " <span class='toggle expand'></span>&nbsp;" + value;
- } else {
- return spacer + " <span class='toggle collapse'></span>&nbsp;" + value;
- }
- } else {
- return spacer + " <span class='toggle'></span>&nbsp;" + value;
- }
- },
- add_grid_events: function() {
- var me = this;
- this.grid.onClick.subscribe(function (e, args) {
- if ($(e.target).hasClass("toggle")) {
- var item = me.dataView.getItem(args.row);
- if (item) {
- if (!item._collapsed) {
- item._collapsed = true;
- } else {
- item._collapsed = false;
- }
-
- me.dataView.updateItem(item.id, item);
- }
- e.stopImmediatePropagation();
- }
- });
- },
- custom_dataview_filter: function(item) {
- if (item.parent_account) {
- var parent = item.parent_account;
- while (parent) {
- if (erpnext.coa.accounts_by_name[parent]._collapsed) {
- return false;
- }
- parent = erpnext.coa.parent_map[parent];
- }
- }
- return true;
- }
- });
-}
-
-erpnext.ChartOfAccounts = Class.extend({
-});
@@ -1,49 +0,0 @@
-import webnotes
-
-@webnotes.whitelist()
-def get_chart():
- company = webnotes.form_dict.get('company')
- res = {}
- res["chart"] = webnotes.conn.sql("""select name, parent_account,
- if(debit_or_credit="Debit", "D", ""),
- if(is_pl_account="Yes", "Y", "") from
- tabAccount where company=%s and docstatus < 2 order by lft""", (company, ))
-
- res["gl"] = webnotes.conn.sql("""select posting_date, account, ifnull(debit, 0),
- ifnull(credit, 0), ifnull(is_opening, 'No')
- from `tabGL Entry` where company=%s and ifnull(is_cancelled, "No") = "No"
- order by posting_date""", (company, ), as_list=1)
-
- idx_map = {}
- for i in xrange(len(res["chart"])):
- idx_map[res["chart"][i][0]] = i
-
- for d in res["gl"]:
- d[1] = idx_map[d[1]]
-
- return res
-
-@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
- res = {}
- if match and webnotes.user.get_defaults().get("company"):
- res["companies"] = webnotes.user.get_defaults().get("company")
- else:
- res["companies"] = [r[0] for r in webnotes.conn.sql("""select name from tabCompany
- where docstatus!=2""")]
-
- res["fiscal_years"] = webnotes.conn.sql("""select name, year_start_date,
- adddate(year_start_date, interval 1 year)
- from `tabFiscal Year` where docstatus!=2
- order by year_start_date asc""")
- return res
@@ -1,28 +0,0 @@
-# Page, chart-of-accounts
-[
-
- # These values are common in all dictionaries
- {
- 'creation': '2012-09-12 14:43:52',
- 'docstatus': 0,
- 'modified': '2012-09-12 14:43:53',
- 'modified_by': u'Administrator',
- 'owner': u'Administrator'
- },
-
- # These values are common for all Page
- {
- 'doctype': 'Page',
- 'module': u'Accounts',
- 'name': '__common__',
- 'page_name': u'Chart of Accounts',
- 'standard': u'Yes',
- 'title': u'Chart of Accounts'
- },
-
- # Page, chart-of-accounts
- {
- 'doctype': 'Page',
- 'name': u'chart-of-accounts'
- }
-]
Oops, something went wrong.

0 comments on commit 4156523

Please sign in to comment.