From 0c21e2afefbb017f219f0a3fcdfa5c99595e8fe9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 21 Mar 2014 11:14:49 +0530 Subject: [PATCH] Is_pl_account and debit_or_credit field removed and added report_type field in account --- erpnext/accounts/doctype/account/account.js | 4 +- erpnext/accounts/doctype/account/account.py | 16 +- erpnext/accounts/doctype/account/account.txt | 22 +- .../doctype/cost_center/cost_center.js | 4 +- erpnext/accounts/doctype/gl_entry/gl_entry.py | 11 +- .../journal_voucher/journal_voucher.py | 4 +- .../accounts/doctype/mis_control/README.md | 1 - .../accounts/doctype/mis_control/__init__.py | 1 - .../doctype/mis_control/mis_control.py | 167 ------------ .../doctype/mis_control/mis_control.txt | 19 -- .../mode_of_payment/mode_of_payment.js | 10 +- .../period_closing_voucher.js | 3 +- .../period_closing_voucher.py | 6 +- .../doctype/pos_setting/pos_setting.js | 6 +- .../purchase_invoice/purchase_invoice.js | 3 +- .../purchase_invoice/purchase_invoice.py | 6 +- .../purchase_taxes_and_charges_master.js | 1 - .../doctype/sales_invoice/sales_invoice.js | 12 +- .../doctype/sales_invoice/sales_invoice.py | 6 +- .../sales_taxes_and_charges_master.js | 1 - .../page/financial_statements/README.md | 1 - .../page/financial_statements/__init__.py | 1 - .../financial_statements.js | 148 ---------- .../financial_statements.txt | 36 --- .../accounts_payable/accounts_payable.js | 3 +- .../accounts_receivable.js | 3 +- .../bank_clearance_summary.js | 8 +- .../bank_reconciliation_statement.js | 8 +- .../item_wise_purchase_register.js | 3 +- .../item_wise_sales_register.js | 3 +- .../payment_period_based_on_invoice_date.js | 2 +- .../purchase_register/purchase_register.js | 3 +- .../report/sales_register/sales_register.js | 3 +- erpnext/accounts/utils.py | 3 +- erpnext/controllers/queries.py | 19 +- erpnext/setup/doctype/company/company.js | 22 +- erpnext/setup/doctype/company/company.py | 256 +++++++++--------- erpnext/setup/doctype/company/test_company.py | 2 +- .../doctype/email_digest/email_digest.py | 8 +- .../doctype/email_digest/email_digest.txt | 4 +- .../setup/page/setup_wizard/setup_wizard.js | 14 + .../setup/page/setup_wizard/setup_wizard.py | 7 +- .../doctype/delivery_note/delivery_note.js | 3 +- erpnext/stock/doctype/item/item.js | 6 +- .../stock_reconciliation.py | 2 +- 45 files changed, 244 insertions(+), 627 deletions(-) delete mode 100644 erpnext/accounts/doctype/mis_control/README.md delete mode 100644 erpnext/accounts/doctype/mis_control/__init__.py delete mode 100644 erpnext/accounts/doctype/mis_control/mis_control.py delete mode 100644 erpnext/accounts/doctype/mis_control/mis_control.txt delete mode 100644 erpnext/accounts/page/financial_statements/README.md delete mode 100644 erpnext/accounts/page/financial_statements/__init__.py delete mode 100644 erpnext/accounts/page/financial_statements/financial_statements.js delete mode 100644 erpnext/accounts/page/financial_statements/financial_statements.txt diff --git a/erpnext/accounts/doctype/account/account.js b/erpnext/accounts/doctype/account/account.js index a77bce5217..2577ccf88b 100644 --- a/erpnext/accounts/doctype/account/account.js +++ b/erpnext/accounts/doctype/account/account.js @@ -14,7 +14,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { 'credit_days', 'credit_limit', 'tax_rate'], doc.group_or_ledger=='Ledger') // disable fields - cur_frm.toggle_enable(['account_name', 'group_or_ledger', 'is_pl_account', 'company'], false); + cur_frm.toggle_enable(['account_name', 'group_or_ledger', 'company'], false); if(doc.group_or_ledger=='Ledger') { frappe.model.with_doc("Accounts Settings", "Accounts Settings", function (name) { @@ -52,7 +52,7 @@ cur_frm.cscript.master_type = function(doc, cdt, cdn) { in_list(['Customer', 'Supplier'], doc.master_type)); } -cur_frm.add_fetch('parent_account', 'is_pl_account', 'is_pl_account'); +cur_frm.add_fetch('parent_account', 'report_type', 'report_type'); cur_frm.cscript.account_type = function(doc, cdt, cdn) { if(doc.group_or_ledger=='Ledger') { diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py index 7ba57ab270..4c3e4d1682 100644 --- a/erpnext/accounts/doctype/account/account.py +++ b/erpnext/accounts/doctype/account/account.py @@ -48,7 +48,7 @@ class DocType: def validate_parent(self): """Fetch Parent Details and validation for account not to be created under ledger""" if self.doc.parent_account: - par = frappe.db.sql("""select name, group_or_ledger, root_type + par = frappe.db.sql("""select name, group_or_ledger, report_type from tabAccount where name =%s""", self.doc.parent_account, as_dict=1) if not par: throw(_("Parent account does not exists")) @@ -57,8 +57,8 @@ class DocType: elif par[0]["group_or_ledger"] != 'Group': throw(_("Parent account can not be a ledger")) - if par[0]["root_type"]: - self.doc.root_type = par[0]["root_type"] + if par[0]["report_type"]: + self.doc.report_type = par[0]["report_type"] def validate_duplicate_account(self): if self.doc.fields.get('__islocal') or not self.doc.name: @@ -121,8 +121,8 @@ class DocType: and docstatus != 2""", self.doc.name) def validate_mandatory(self): - if not self.doc.is_pl_account: - throw(_("Is PL Account field is mandatory")) + if not self.doc.report_type: + throw(_("Report Type is mandatory")) def validate_warehouse_account(self): if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")): @@ -203,12 +203,12 @@ class DocType: throw(_("Account ") + new +_(" does not exists")) val = list(frappe.db.get_value("Account", new_account, - ["group_or_ledger", "is_pl_account", "company"])) + ["group_or_ledger", "report_type", "company"])) - if val != [self.doc.group_or_ledger, self.doc.is_pl_account, self.doc.company]: + if val != [self.doc.group_or_ledger, self.doc.report_type, self.doc.company]: throw(_("""Merging is only possible if following \ properties are same in both records. - Group or Ledger, Debit or Credit, Is PL Account""")) + Group or Ledger, Report Type, Company""")) return new_account diff --git a/erpnext/accounts/doctype/account/account.txt b/erpnext/accounts/doctype/account/account.txt index 7c31998d17..17d77f936a 100644 --- a/erpnext/accounts/doctype/account/account.txt +++ b/erpnext/accounts/doctype/account/account.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-30 12:49:46", "docstatus": 0, - "modified": "2014-03-07 16:26:42", + "modified": "2014-03-19 12:07:27", "modified_by": "Administrator", "owner": "Administrator" }, @@ -93,18 +93,6 @@ "reqd": 1, "search_index": 1 }, - { - "doctype": "DocField", - "fieldname": "is_pl_account", - "fieldtype": "Select", - "in_filter": 1, - "label": "Is PL Account", - "oldfieldname": "is_pl_account", - "oldfieldtype": "Select", - "options": "Yes\nNo", - "read_only": 1, - "search_index": 1 - }, { "doctype": "DocField", "fieldname": "company", @@ -137,10 +125,10 @@ }, { "doctype": "DocField", - "fieldname": "root_type", + "fieldname": "report_type", "fieldtype": "Select", - "label": "Root Type", - "options": "\nAsset\nLiability\nExpense\nIncome" + "label": "Report Type", + "options": "\nBalance Sheet\nProfit and Loss" }, { "description": "Setting Account Type helps in selecting this Account in transactions.", @@ -151,7 +139,7 @@ "label": "Account Type", "oldfieldname": "account_type", "oldfieldtype": "Select", - "options": "Bank or Cash\nTax\nChargeable\nWarehouse\nReceivable\nPayable\nEquity\nFixed Asset\nCost of Goods Sold\nExpense Account\nIncome Account", + "options": "Bank\nCash\nTax\nChargeable\nWarehouse\nReceivable\nPayable\nEquity\nFixed Asset\nCost of Goods Sold\nExpense Account\nIncome Account\nStock Received But Not Billed\nExpenses Included In Valuation\nStock Adjustment", "search_index": 0 }, { diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js index d271ab3a3e..5c8be10a3f 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.js +++ b/erpnext/accounts/doctype/cost_center/cost_center.js @@ -14,8 +14,8 @@ erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({ return { filters:[ ['Account', 'company', '=', me.frm.doc.company], - ['Account', 'is_pl_account', '=', 'Yes'], - ['Account', 'group_or_ledger', '!=', 'Group'], + ['Account', 'report_type', '=', 'Profit and Loss'], + ['Account', 'group_or_ledger', '=', 'Ledger'], ] } }); diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index 141cbebdf3..8bac6369e8 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -42,10 +42,10 @@ class DocType: self.doc.account) def pl_must_have_cost_center(self): - if frappe.db.get_value("Account", self.doc.account, "is_pl_account") == "Yes": + if frappe.db.get_value("Account", self.doc.account, "report_type") == "Profit and Loss": if not self.doc.cost_center and self.doc.voucher_type != 'Period Closing Voucher': - frappe.throw(_("Cost Center must be specified for PL Account: ") + - self.doc.account) + frappe.throw(_("Cost Center must be specified for Profit and Loss type account: ") + + self.doc.account) elif self.doc.cost_center: self.doc.cost_center = None @@ -55,8 +55,9 @@ class DocType: def check_pl_account(self): if self.doc.is_opening=='Yes' and \ - frappe.db.get_value("Account", self.doc.account, "is_pl_account") == "Yes": - frappe.throw(_("For opening balance entry account can not be a PL account")) + frappe.db.get_value("Account", self.doc.account, "report_type")=="Profit and Loss": + frappe.throw(_("For opening balance entry, account can not be \ + a Profit and Loss type account")) def validate_account_details(self, adv_adj): """Account must be ledger, active and not freezed""" diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py index f4e886b499..57c14b00d6 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py @@ -175,7 +175,7 @@ class DocType(AccountsController): ' - '.join(d.account.split(' - ')[:-1]), master_type == 'Customer' and 'customer_name' or 'supplier_name') - if account_type == 'Bank or Cash': + if account_type in ['Bank', 'Cash']: company_currency = get_company_currency(self.doc.company) amt = flt(d.debit) and d.debit or d.credit self.doc.total_amount = company_currency + ' ' + cstr(amt) @@ -413,7 +413,7 @@ def get_opening_accounts(company): """get all balance sheet accounts for opening entry""" from erpnext.accounts.utils import get_balance_on accounts = frappe.db.sql_list("""select name from tabAccount - where group_or_ledger='Ledger' and is_pl_account='No' and company=%s""", company) + where group_or_ledger='Ledger' and report_type='Profit and Loss' and company=%s""", company) return [{"account": a, "balance": get_balance_on(a)} for a in accounts] diff --git a/erpnext/accounts/doctype/mis_control/README.md b/erpnext/accounts/doctype/mis_control/README.md deleted file mode 100644 index 65c851f277..0000000000 --- a/erpnext/accounts/doctype/mis_control/README.md +++ /dev/null @@ -1 +0,0 @@ -Backend scripts for Financial Statements (to be deprecated) \ No newline at end of file diff --git a/erpnext/accounts/doctype/mis_control/__init__.py b/erpnext/accounts/doctype/mis_control/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/erpnext/accounts/doctype/mis_control/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/erpnext/accounts/doctype/mis_control/mis_control.py b/erpnext/accounts/doctype/mis_control/mis_control.py deleted file mode 100644 index 7109dfbfa2..0000000000 --- a/erpnext/accounts/doctype/mis_control/mis_control.py +++ /dev/null @@ -1,167 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import frappe -from frappe.utils import flt, get_first_day, get_last_day, has_common -import frappe.defaults -from erpnext.accounts.utils import get_balance_on - -class DocType: - def __init__(self, doc, doclist): - self.doc = doc - self.doclist = doclist - self.account_list = [] - - self.period_list = [] - self.period_start_date = {} - self.period_end_date = {} - - self.fs_list = [] - self.root_bal = [] - self.flag = 0 - - # Get defaults on load of MIS, MIS - Comparison Report and Financial statements - def get_comp(self): - ret = {} - type = [] - - ret['period'] = ['Annual','Half Yearly','Quarterly','Monthly'] - - from erpnext.accounts.page.accounts_browser.accounts_browser import get_companies - ret['company'] = get_companies() - - #--- to get fiscal year and start_date of that fiscal year ----- - res = frappe.db.sql("select name, year_start_date from `tabFiscal Year`") - ret['fiscal_year'] = [r[0] for r in res] - ret['start_dates'] = {} - for r in res: - ret['start_dates'][r[0]] = str(r[1]) - - #--- from month and to month (for MIS - Comparison Report) ------- - month_list = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] - fiscal_start_month = frappe.db.sql("select MONTH(year_start_date) from `tabFiscal Year` where name = %s",(frappe.defaults.get_global_default("fiscal_year"))) - fiscal_start_month = fiscal_start_month and fiscal_start_month[0][0] or 1 - mon = [''] - for i in range(fiscal_start_month,13): mon.append(month_list[i-1]) - for i in range(0,fiscal_start_month-1): mon.append(month_list[i]) - ret['month'] = mon - - # get MIS Type on basis of roles of session user - self.roles = frappe.user.get_roles() - if has_common(self.roles, ['Sales Manager']): - type.append('Sales') - if has_common(self.roles, ['Purchase Manager']): - type.append('Purchase') - ret['type'] = type - return ret - - - def get_statement(self, arg): - self.return_data = [] - - # define periods - arg = eval(arg) - pl = '' - - self.define_periods(arg['year'], arg['period']) - self.return_data.append([4,'']+self.period_list) - - - if arg['statement'] == 'Balance Sheet': pl = 'No' - if arg['statement'] == 'Profit & Loss': pl = 'Yes' - self.get_children('',0,pl,arg['company'], arg['year']) - - return self.return_data - - def get_children(self, parent_account, level, pl, company, fy): - cl = frappe.db.sql("select distinct account_name, name, root_type, lft, rgt from `tabAccount` where ifnull(parent_account, '') = %s and ifnull(is_pl_account, 'No')=%s and company=%s and docstatus != 2 order by name asc", (parent_account, pl, company)) - level0_diff = [0 for p in self.period_list] - if pl=='Yes' and level==0: # switch for income & expenses - cl = [c for c in cl] - cl.reverse() - if cl: - for c in cl: - bal_list = self.get_period_balance(c[1], pl, c[2]) - if level==0: # top level - put balances as totals - self.return_data.append([level, c[0]] + ['' for b in bal_list]) - totals = bal_list - for i in range(len(totals)): # make totals - if c[2] in ["Asset", "Expense"]: - level0_diff[i] -= flt(totals[i]) - else: - level0_diff[i] += flt(totals[i]) - else: - self.return_data.append([level, c[0]]+bal_list) - - if level < 2: - self.get_children(c[1], level+1, pl, company, fy) - - # make totals - for top level - if level==0: - # add rows for profit / loss in B/S - if pl=='No': - if c[2] == "Asset": - self.return_data.append([4, 'Total '+c[0]] + totals) - else: - self.return_data.append([1, 'Total Liabilities'] + totals) - level0_diff = [-i for i in level0_diff] # convert to debit - self.return_data.append([5, 'Profit/Loss (Provisional)'] + level0_diff) - for i in range(len(totals)): # make totals - level0_diff[i] = flt(totals[i]) + level0_diff[i] - - # add rows for profit / loss in P/L - else: - if c[2]=='Expense': - self.return_data.append([1, 'Total Expenses'] + totals) - self.return_data.append([5, 'Profit/Loss (Provisional)'] + level0_diff) - for i in range(len(totals)): # make totals - level0_diff[i] = flt(totals[i]) + level0_diff[i] - else: - self.return_data.append([4, 'Total '+c[0]] + totals) - - def define_periods(self, year, period): - ysd = frappe.db.sql("select year_start_date from `tabFiscal Year` where name=%s", year) - ysd = ysd and ysd[0][0] or '' - - self.ysd = ysd - - # year - if period == 'Annual': - pn = 'FY'+year - self.period_list.append(pn) - self.period_start_date[pn] = ysd - self.period_end_date[pn] = get_last_day(get_first_day(ysd,0,11)) - - # quarter - if period == 'Quarterly': - for i in range(4): - pn = 'Q'+str(i+1) - self.period_list.append(pn) - self.period_start_date[pn] = get_first_day(ysd,0,i*3) - self.period_end_date[pn] = get_last_day(get_first_day(ysd,0,((i+1)*3)-1)) - - # month - if period == 'Monthly': - mlist = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] - for i in range(12): - fd = get_first_day(ysd,0,i) - pn = mlist[fd.month-1] - self.period_list.append(pn) - - self.period_start_date[pn] = fd - self.period_end_date[pn] = get_last_day(fd) - - def get_period_balance(self, acc, pl, root_type): - ret, i = [], 0 - for p in self.period_list: - period_end_date = self.period_end_date[p].strftime('%Y-%m-%d') - bal = get_balance_on(acc, period_end_date) - if root_type not in ["Asset", "Expense"]: - bal = -bal - - if pl=='Yes': - bal = bal - sum(ret) - - ret.append(bal) - return ret \ No newline at end of file diff --git a/erpnext/accounts/doctype/mis_control/mis_control.txt b/erpnext/accounts/doctype/mis_control/mis_control.txt deleted file mode 100644 index 28a0df4d72..0000000000 --- a/erpnext/accounts/doctype/mis_control/mis_control.txt +++ /dev/null @@ -1,19 +0,0 @@ -[ - { - "creation": "2012-03-27 14:35:49", - "docstatus": 0, - "modified": "2013-12-20 19:23:21", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "DocType", - "issingle": 1, - "module": "Accounts", - "name": "__common__" - }, - { - "doctype": "DocType", - "name": "MIS Control" - } -] \ No newline at end of file diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.js b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.js index f2b2ead630..a86da0eaba 100644 --- a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.js +++ b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.js @@ -3,10 +3,10 @@ cur_frm.set_query("default_account", function(doc) { return{ - filters: { - 'account_type': "Bank or Cash", - "group_or_ledger": "Ledger", - 'company': doc.company - } + filters: [ + ['Account', 'account_type', 'in', 'Bank, Cash'], + ['Account', 'group_or_ledger', '=', 'Ledger'], + ['Account', 'company', '=', doc.company] + ] } }); \ No newline at end of file diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js index 1d28f69b14..162e85719b 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.js @@ -12,9 +12,8 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { cur_frm.fields_dict['closing_account_head'].get_query = function(doc, cdt, cdn) { return{ filters:{ - 'is_pl_account': "No", "company": doc.company, - "root_type": "Liability", + "report_type": "Balance Sheet", "freeze_account": "No", "group_or_ledger": "Ledger" } diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py index b336716fa1..022e9d4b75 100644 --- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py +++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py @@ -25,8 +25,8 @@ class DocType(AccountsController): where voucher_type = 'Period Closing Voucher' and voucher_no=%s""", self.doc.name) def validate_account_head(self): - if frappe.db.get_value("Account", self.doc.closing_account_head, "root_type") \ - != "Liability": + if frappe.db.get_value("Account", self.doc.closing_account_head, "report_type") \ + != "Balance Sheet": frappe.throw(_("Account") + ": " + self.doc.closing_account_head + _("must be a Liability account")) @@ -67,7 +67,7 @@ class DocType(AccountsController): return frappe.db.sql(""" select t1.account, sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0)) as balance from `tabGL Entry` t1, `tabAccount` t2 - where t1.account = t2.name and ifnull(t2.is_pl_account, 'No') = 'Yes' + where t1.account = t2.name and ifnull(t2.report_type, '') = 'Profit and Loss' and t2.docstatus < 2 and t2.company = %s and t1.posting_date between %s and %s group by t1.account diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.js b/erpnext/accounts/doctype/pos_setting/pos_setting.js index ea08fd2420..debfcd9d1a 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.js +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.js @@ -16,8 +16,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){ cur_frm.fields_dict['cash_bank_account'].get_query = function(doc,cdt,cdn) { return{ filters:{ - 'root_type': "Asset", - 'is_pl_account': "No", + 'report_type': "Balance Sheet", 'group_or_ledger': "Ledger", 'company': doc.company } @@ -54,8 +53,7 @@ cur_frm.fields_dict['cost_center'].get_query = function(doc,cdt,cdn) { cur_frm.fields_dict["expense_account"].get_query = function(doc) { return { filters: { - "is_pl_account": "Yes", - "root_type": "Expense", + "report_type": "Profit and Loss", "company": doc.company, "group_or_ledger": "Ledger" } diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index f4a0da1a59..be1f3b2362 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -158,8 +158,7 @@ cur_frm.fields_dict['entries'].grid.get_field("item_code").get_query = function( cur_frm.fields_dict['credit_to'].get_query = function(doc) { return{ filters:{ - 'root_type': 'Liability', - 'is_pl_account': 'No', + 'report_type': 'Balance Sheet', 'group_or_ledger': 'Ledger', 'company': doc.company } diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 0b255b60cb..f94dd81e3f 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -109,8 +109,8 @@ class DocType(BuyingController): self.doc.remarks = "No Remarks" def validate_credit_acc(self): - if frappe.db.get_value("Account", self.doc.debit_to, "root_type") != "Liability": - frappe.throw(_("Account must be an liability account")) + if frappe.db.get_value("Account", self.doc.debit_to, "report_type") != "Balance Sheet": + frappe.throw(_("Account must be a balance sheet account")) # Validate Acc Head of Supplier and Credit To Account entered # ------------------------------------------------------------ @@ -424,7 +424,7 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters): # but can also be a Liability account with account_type='Expense Account' in special circumstances. # Hence the first condition is an "OR" return frappe.db.sql("""select tabAccount.name from `tabAccount` - where (tabAccount.root_type in ("Asset", "Expense") + where (tabAccount.report_type = "Profit and Loss" or tabAccount.account_type = "Expense Account") and tabAccount.group_or_ledger="Ledger" and tabAccount.docstatus!=2 diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js index aa4ec27bc7..2027a7b33a 100644 --- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js +++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js @@ -138,7 +138,6 @@ cur_frm.set_query("account_head", "other_charges", function(doc) { query: "erpnext.controllers.queries.tax_account_query", filters: { "account_type": ["Tax", "Chargeable", "Expense Account"], - "root_type": "Expense", "company": doc.company } } diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 1ae53416a0..42cf8239b2 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -292,8 +292,7 @@ cur_frm.cscript.make_bank_voucher = function() { cur_frm.fields_dict.debit_to.get_query = function(doc) { return{ filters: { - 'root_type': 'Asset', - 'is_pl_account': 'No', + 'report_type': 'Balance Sheet', 'group_or_ledger': 'Ledger', 'company': doc.company } @@ -303,8 +302,7 @@ cur_frm.fields_dict.debit_to.get_query = function(doc) { cur_frm.fields_dict.cash_bank_account.get_query = function(doc) { return{ filters: { - 'root_type': 'Asset', - 'is_pl_account': 'No', + 'report_type': 'Balance Sheet', 'group_or_ledger': 'Ledger', 'company': doc.company } @@ -314,8 +312,7 @@ cur_frm.fields_dict.cash_bank_account.get_query = function(doc) { cur_frm.fields_dict.write_off_account.get_query = function(doc) { return{ filters:{ - 'root_type': 'Expense', - 'is_pl_account': 'Yes', + 'report_type': 'Profit and Loss', 'group_or_ledger': 'Ledger', 'company': doc.company } @@ -356,8 +353,7 @@ if (sys_defaults.auto_accounting_for_stock) { cur_frm.fields_dict['entries'].grid.get_field('expense_account').get_query = function(doc) { return { filters: { - 'is_pl_account': 'Yes', - 'root_type': 'Expense', + 'report_type': 'Profit and Loss', 'company': doc.company, 'group_or_ledger': 'Ledger' } diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 12334fab2b..a3302c7558 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -257,8 +257,8 @@ class DocType(SellingController): def validate_debit_acc(self): - if frappe.db.get_value("Account", self.doc.debit_to, "root_type") != "Asset": - frappe.throw(_("Account must be an asset account")) + if frappe.db.get_value("Account", self.doc.debit_to, "report_type") != "Balance Sheet": + frappe.throw(_("Account must be a balance sheet account")) def validate_fixed_asset_account(self): """Validate Fixed Asset and whether Income Account Entered Exists""" @@ -787,7 +787,7 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters): # but can also be a Asset account with account_type='Income Account' in special circumstances. # Hence the first condition is an "OR" return frappe.db.sql("""select tabAccount.name from `tabAccount` - where (tabAccount.root_type in ("Liability", "Income") + where (tabAccount.report_type = "Profit and Loss" or tabAccount.account_type = "Income Account") and tabAccount.group_or_ledger="Ledger" and tabAccount.docstatus!=2 diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js index c5e96894fa..6f35f4af88 100644 --- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js +++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.js @@ -137,7 +137,6 @@ cur_frm.fields_dict['other_charges'].grid.get_field("account_head").get_query = query: "erpnext.controllers.queries.tax_account_query", filters: { "account_type": ["Tax", "Chargeable", "Income Account"], - "root_type": "Income", "company": doc.company } } diff --git a/erpnext/accounts/page/financial_statements/README.md b/erpnext/accounts/page/financial_statements/README.md deleted file mode 100644 index 1493ac909b..0000000000 --- a/erpnext/accounts/page/financial_statements/README.md +++ /dev/null @@ -1 +0,0 @@ -Generate provisional Balance Sheet and Profit and Loss statements. \ No newline at end of file diff --git a/erpnext/accounts/page/financial_statements/__init__.py b/erpnext/accounts/page/financial_statements/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/erpnext/accounts/page/financial_statements/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/erpnext/accounts/page/financial_statements/financial_statements.js b/erpnext/accounts/page/financial_statements/financial_statements.js deleted file mode 100644 index 82cebd2924..0000000000 --- a/erpnext/accounts/page/financial_statements/financial_statements.js +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - -erpnext.fs = {} - -pscript['onload_Financial Statements'] = function(wrapper) { - frappe.ui.make_app_page({ - parent: wrapper, - "title": frappe._("Financial Statements"), - "single_column": true, - }); - - erpnext.fs.stmt_type = wrapper.appframe.add_field({ - fieldtype:"Select", - fieldname:"stmt_type", - options: ['Select Statement...','Balance Sheet','Profit & Loss'] - }) - - erpnext.fs.stmt_company = wrapper.appframe.add_field({ - fieldtype:"Select", - fieldname:"stmt_company", - options: ['Loading Companies...'] - }) - - erpnext.fs.stmt_period = wrapper.appframe.add_field({ - fieldtype:"Select", - fieldname:"stmt_period", - options: ['Select Period...', 'Annual', 'Quarterly', 'Monthly'] - }) - - erpnext.fs.stmt_fiscal_year = wrapper.appframe.add_field({ - fieldtype:"Select", - fieldname:"stmt_fiscal_year", - options: ['Loading...'] - }) - - wrapper.appframe.add_button(frappe._("Create"), function() { - pscript.stmt_new(); - }, "icon-refresh") - - wrapper.appframe.add_button(frappe._("Print"), function() { - _p.go($i('print_html').innerHTML); - }, "icon-print") - - $(wrapper).find(".layout-main").html('').css({"min-height": "400px"}); - - // load companies - return $c_obj('MIS Control','get_comp','', function(r,rt) { - // company - erpnext.fs.stmt_company.$input.empty() - .add_options(['Select Company...'].concat(r.message.company)); - erpnext.fs.stmt_fiscal_year.$input.empty() - .add_options(['Select Year...'].concat(r.message.fiscal_year)); - }); - -} - -pscript.stmt_new = function(stmt,company_name,level,period,year) { - - $i('stmt_tree').innerHTML = frappe._('Refreshing....'); - $i('stmt_tree').style.display = 'block'; - - var company =erpnext.fs.stmt_company.get_value(); - - var arg = { - statement: erpnext.fs.stmt_type.get_value(), - company: company, - period: erpnext.fs.stmt_period.get_value(), - year: erpnext.fs.stmt_fiscal_year.get_value() - } - - return $c_obj('MIS Control', 'get_statement', docstring(arg), function(r,rt) { - var nl = r.message; - var t = $i('stmt_tree'); - var stmt_type = erpnext.fs.stmt_type.get_value(); - t.innerHTML = ''; - var tab = $a($a(t, 'div'),'table','stmt_table'); - tab.style.tableLayout = 'fixed'; - tab.style.width = '100%'; - - $i('stmt_title1').innerHTML = erpnext.fs.stmt_company.get_value() - $i('stmt_title2').innerHTML = erpnext.fs.stmt_type.get_value() - + ' - ' + erpnext.fs.stmt_fiscal_year.get_value(); - for(i=0;i