Is_pl_account and debit_or_credit field removed and added report_type field in account

This commit is contained in:
Nabin Hait 2014-03-21 11:14:49 +05:30
parent b5e6d7e171
commit 0c21e2afef
45 changed files with 244 additions and 627 deletions

View File

@ -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') {

View File

@ -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

View File

@ -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
},
{

View File

@ -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'],
]
}
});

View File

@ -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"""

View File

@ -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]

View File

@ -1 +0,0 @@
Backend scripts for Financial Statements (to be deprecated)

View File

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

View File

@ -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

View File

@ -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"
}
]

View File

@ -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]
]
}
});

View File

@ -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"
}

View File

@ -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

View File

@ -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"
}

View File

@ -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
}

View File

@ -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

View File

@ -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
}
}

View File

@ -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'
}

View File

@ -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

View File

@ -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
}
}

View File

@ -1 +0,0 @@
Generate provisional Balance Sheet and Profit and Loss statements.

View File

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

View File

@ -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('<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;">'+frappe._('Please select options and click on Create')+'</div>\
</div>').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<nl.length;i++) {
tab.insertRow(i);
tab.rows[i].style.height = '20px';
// heads
var per = tab.rows[i].insertCell(0);
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 = format_currency(nl[i][j], erpnext.get_currency(company)).bold();
else
per.innerHTML = format_currency(nl[i][j], erpnext.get_currency(company))
} 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

@ -1,36 +0,0 @@
[
{
"creation": "2013-01-27 16:30:52",
"docstatus": 0,
"modified": "2013-08-14 12:47:45",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"doctype": "Page",
"icon": "icon-money",
"module": "Accounts",
"name": "__common__",
"page_name": "Financial Statements",
"standard": "Yes"
},
{
"doctype": "Page Role",
"name": "__common__",
"parent": "Financial Statements",
"parentfield": "roles",
"parenttype": "Page"
},
{
"doctype": "Page",
"name": "Financial Statements"
},
{
"doctype": "Page Role",
"role": "Accounts Manager"
},
{
"doctype": "Page Role",
"role": "Analytics"
}
]

View File

@ -20,8 +20,7 @@ frappe.query_reports["Accounts Payable"] = {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"root_type": "Liability",
"report_type": "Balance Sheet",
"company": company,
"master_type": "Supplier"
}

View File

@ -20,8 +20,7 @@ frappe.query_reports["Accounts Receivable"] = {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"root_type": "Asset",
"report_type": "Balance Sheet",
"company": company,
"master_type": "Customer"
}

View File

@ -24,10 +24,10 @@ frappe.query_reports["Bank Clearance Summary"] = {
"get_query": function() {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"account_type": "Bank or Cash"
}
"filters": [
['Account', 'account_type', 'in', 'Bank, Cash'],
['Account', 'group_or_ledger', '=', 'Ledger'],
]
}
}
},

View File

@ -12,10 +12,10 @@ frappe.query_reports["Bank Reconciliation Statement"] = {
"get_query": function() {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"account_type": "Bank or Cash"
}
"filters": [
['Account', 'account_type', 'in', 'Bank, Cash'],
['Account', 'group_or_ledger', '=', 'Ledger'],
]
}
}
},

View File

@ -32,8 +32,7 @@ frappe.query_reports["Item-wise Purchase Register"] = {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"root_type": "Liability",
"report_type": "Balance Sheet",
"company": company,
"master_type": "Supplier"
}

View File

@ -26,8 +26,7 @@ frappe.query_reports["Item-wise Sales Register"] = frappe.query_reports["Sales R
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"root_type": "Asset",
"report_type": "Balance Sheet",
"company": company,
"master_type": "Customer"
}

View File

@ -31,7 +31,7 @@ frappe.query_reports["Payment Period Based On Invoice Date"] = {
return {
query: "accounts.utils.get_account_list",
filters: {
is_pl_account: "No",
"report_type": "Balance Sheet",
company: frappe.query_report.filters_by_name.company.get_value()
}
}

View File

@ -26,8 +26,7 @@ frappe.query_reports["Purchase Register"] = {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"root_type": "Liability",
"report_type": "Balance Sheet",
"company": company,
"master_type": "Supplier"
}

View File

@ -26,8 +26,7 @@ frappe.query_reports["Sales Register"] = {
return {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"root_type": "Asset",
"report_type": "Balance Sheet",
"company": company,
"master_type": "Customer"
}

View File

@ -285,8 +285,7 @@ def get_stock_and_account_difference(account_list=None, posting_date=None):
def validate_expense_against_budget(args):
args = frappe._dict(args)
if frappe.db.get_value("Account", {"name": args.account, "is_pl_account": "Yes",
"root_type": "Expense"}):
if frappe.db.get_value("Account", {"name": args.account, "report_type": "Profit and Loss"}):
budget = frappe.db.sql("""
select bd.budget_allocated, cc.distribution_id
from `tabCost Center` cc, `tabBudget Detail` bd

View File

@ -106,17 +106,24 @@ def supplier_query(doctype, txt, searchfield, start, page_len, filters):
'page_len': page_len})
def tax_account_query(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql("""select name, parent_account from tabAccount
tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount
where tabAccount.docstatus!=2
and (account_type in (%s) or root_type = %s)
and account_type in (%s)
and group_or_ledger = 'Ledger'
and company = %s
and `%s` LIKE %s
limit %s, %s""" %
(", ".join(['%s']*len(filters.get("account_type"))),
"%s", "%s", searchfield, "%s", "%s", "%s"),
tuple(filters.get("account_type") + [filters.get("root_type"),
filters.get("company"), "%%%s%%" % txt, start, page_len]))
(", ".join(['%s']*len(filters.get("account_type"))), "%s", searchfield, "%s", "%s", "%s"),
tuple(filters.get("account_type") + [filters.get("company"), "%%%s%%" % txt,
start, page_len]))
if not tax_accounts:
tax_accounts = frappe.db.sql("""select name, parent_account from tabAccount
where tabAccount.docstatus!=2 and group_or_ledger = 'Ledger'
and company = %s and `%s` LIKE %s limit %s, %s"""
% ("%s", searchfield, "%s", "%s", "%s"),
(filters.get("company"), "%%%s%%" % txt, start, page_len))
return tax_accounts
def item_query(doctype, txt, searchfield, start, page_len, filters):
from frappe.utils import nowdate

View File

@ -79,11 +79,11 @@ cur_frm.cscript.abbr = function(doc){
cur_frm.fields_dict.default_bank_account.get_query = function(doc) {
return{
filters:{
'company': doc.name,
'group_or_ledger': "Ledger",
'account_type': "Bank or Cash"
}
filters: [
['Account', 'account_type', 'in', 'Bank, Cash'],
['Account', 'group_or_ledger', '=', 'Ledger'],
['Account', 'company', '=', doc.name]
]
}
}
@ -114,8 +114,7 @@ cur_frm.fields_dict.default_expense_account.get_query = function(doc) {
filters:{
'company': doc.name,
'group_or_ledger': "Ledger",
'is_pl_account': "Yes",
'root_type': "Expense"
"report_type": "Profit and Loss"
}
}
}
@ -125,8 +124,7 @@ cur_frm.fields_dict.default_income_account.get_query = function(doc) {
filters:{
'company': doc.name,
'group_or_ledger': "Ledger",
'is_pl_account': "Yes",
'root_type': "Income"
"report_type": "Profit and Loss"
}
}
}
@ -144,8 +142,7 @@ if (sys_defaults.auto_accounting_for_stock) {
cur_frm.fields_dict["stock_adjustment_account"].get_query = function(doc) {
return {
"filters": {
"is_pl_account": "Yes",
"root_type": "Expense",
"report_type": "Profit and Loss",
"company": doc.name,
'group_or_ledger': "Ledger"
}
@ -158,8 +155,7 @@ if (sys_defaults.auto_accounting_for_stock) {
cur_frm.fields_dict["stock_received_but_not_billed"].get_query = function(doc) {
return {
"filters": {
"is_pl_account": "No",
"root_type": "Liability",
"report_type": "Balance Sheet",
"company": doc.name,
'group_or_ledger': "Ledger"
}

View File

@ -57,21 +57,14 @@ class DocType:
def create_default_warehouses(self):
for whname in ("Stores", "Work In Progress", "Finished Goods"):
if not frappe.db.exists("Warehouse", whname + " - " + self.doc.abbr):
if not frappe.db.exists("Account", "Stock Assets - " + self.doc.abbr):
frappe.bean({
"doctype": "Account",
"account_name": "Stock Assets",
"company": self.doc.name,
"group_or_ledger": "Group",
"root_type": "Asset",
"is_pl_account": "No"
}).insert()
stock_group = frappe.db.get_value("Account", {"account_type": "Stock",
"group_or_ledger": "Group"})
if stock_group:
frappe.bean({
"doctype":"Warehouse",
"warehouse_name": whname,
"company": self.doc.name,
"create_account_under": "Stock Assets - " + self.doc.abbr
"create_account_under": stock_group
}).insert()
def create_default_web_page(self):
@ -133,15 +126,16 @@ class DocType:
def set_default_accounts(self):
def _set_default_accounts(accounts):
for a in accounts:
account_name = accounts[a] + " - " + self.doc.abbr
if not self.doc.fields.get(a) and frappe.db.exists("Account", account_name):
frappe.db.set(self.doc, a, account_name)
for field, account_type in accounts.items():
account = frappe.db.get_value("Account", {"account_type": account_type,
"group_or_ledger": "Ledger", "company": self.doc.name})
if account and not self.doc.fields.get(field):
frappe.db.set(self.doc, field, account)
_set_default_accounts({
"receivables_group": "Accounts Receivable",
"payables_group": "Accounts Payable",
"default_cash_account": "Cash"
"default_cash_account": "Cash",
"default_bank_account": "Bank"
})
if cint(frappe.db.get_value("Accounts Settings", None, "auto_accounting_for_stock")):
@ -213,117 +207,125 @@ class DocType:
frappe.defaults.clear_cache()
def create_standard_accounts(self):
self.fld_dict = {'account_name':0,'parent_account':1,'group_or_ledger':2,'is_pl_account':3,'account_type':4,'root_type':5,'company':6,'tax_rate':7}
self.fld_dict = {
'account_name': 0,
'parent_account': 1,
'group_or_ledger': 2,
'account_type': 3,
'report_type': 4,
'company': 5,
'tax_rate': 6
}
acc_list_common = [
['Application of Funds (Assets)','','Group','No','','Asset',self.doc.name,''],
['Current Assets','Application of Funds (Assets)','Group','No','','Asset',self.doc.name,''],
['Accounts Receivable','Current Assets','Group','No','','Asset',self.doc.name,''],
['Bank Accounts','Current Assets','Group','No','Bank or Cash','Asset',self.doc.name,''],
['Cash In Hand','Current Assets','Group','No','Bank or Cash','Asset',self.doc.name,''],
['Cash','Cash In Hand','Ledger','No','Bank or Cash','Asset',self.doc.name,''],
['Loans and Advances (Assets)','Current Assets','Group','No','','Asset',self.doc.name,''],
['Securities and Deposits','Current Assets','Group','No','','Asset',self.doc.name,''],
['Earnest Money','Securities and Deposits','Ledger','No','','Asset',self.doc.name,''],
['Stock Assets','Current Assets','Group','No','','Asset',self.doc.name,''],
['Tax Assets','Current Assets','Group','No','','Asset',self.doc.name,''],
['Fixed Assets','Application of Funds (Assets)','Group','No','','Asset',self.doc.name,''],
['Capital Equipments','Fixed Assets','Ledger','No','Fixed Asset','Asset',self.doc.name,''],
['Computers','Fixed Assets','Ledger','No','Fixed Asset','Asset',self.doc.name,''],
['Furniture and Fixture','Fixed Assets','Ledger','No','Fixed Asset','Asset',self.doc.name,''],
['Office Equipments','Fixed Assets','Ledger','No','Fixed Asset','Asset',self.doc.name,''],
['Plant and Machinery','Fixed Assets','Ledger','No','Fixed Asset','Asset',self.doc.name,''],
['Investments','Application of Funds (Assets)','Group','No','','Asset',self.doc.name,''],
['Temporary Accounts (Assets)','Application of Funds (Assets)','Group','No','','Asset',self.doc.name,''],
['Temporary Account (Assets)','Temporary Accounts (Assets)','Ledger','No','','Asset',self.doc.name,''],
['Expenses','','Group','Yes','Expense Account','Expense',self.doc.name,''],
['Direct Expenses','Expenses','Group','Yes','Expense Account','Expense',self.doc.name,''],
['Stock Expenses','Direct Expenses','Group','Yes','Expense Account','Expense',self.doc.name,''],
['Cost of Goods Sold','Stock Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Stock Adjustment','Stock Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Expenses Included In Valuation', "Stock Expenses", 'Ledger', 'Yes', 'Expense Account', 'Expense', self.doc.name, ''],
['Indirect Expenses','Expenses','Group','Yes','Expense Account','Expense',self.doc.name,''],
['Advertising and Publicity','Indirect Expenses','Ledger','Yes','Chargeable','Expense',self.doc.name,''],
['Bad Debts Written Off','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Bank Charges','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Books and Periodicals','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Charity and Donations','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Commission on Sales','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Conveyance Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Customer Entertainment Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Depreciation Account','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Freight and Forwarding Charges','Indirect Expenses','Ledger','Yes','Chargeable','Expense',self.doc.name,''],
['Legal Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Miscellaneous Expenses','Indirect Expenses','Ledger','Yes','Chargeable','Expense',self.doc.name,''],
['Office Maintenance Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Office Rent','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Postal Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Print and Stationary','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Rounded Off','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Salary','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Sales Promotion Expenses','Indirect Expenses','Ledger','Yes','Chargeable','Expense',self.doc.name,''],
['Service Charges Paid','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Staff Welfare Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Telephone Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Travelling Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Water and Electricity Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Expense',self.doc.name,''],
['Income','','Group','Yes','','Income',self.doc.name,''],
['Direct Income','Income','Group','Yes','Income Account','Income',self.doc.name,''],
['Sales','Direct Income','Ledger','Yes','Income Account','Income',self.doc.name,''],
['Service','Direct Income','Ledger','Yes','Income Account','Income',self.doc.name,''],
['Indirect Income','Income','Group','Yes','Income Account','Income',self.doc.name,''],
['Source of Funds (Liabilities)','','Group','No','','Liability',self.doc.name,''],
['Capital Account','Source of Funds (Liabilities)','Group','No','','Liability',self.doc.name,''],
['Reserves and Surplus','Capital Account','Ledger','No','','Liability',self.doc.name,''],
['Shareholders Funds','Capital Account','Ledger','No','','Liability',self.doc.name,''],
['Current Liabilities','Source of Funds (Liabilities)','Group','No','','Liability',self.doc.name,''],
['Accounts Payable','Current Liabilities','Group','No','','Liability',self.doc.name,''],
['Stock Liabilities','Current Liabilities','Group','No','','Liability',self.doc.name,''],
['Stock Received But Not Billed', 'Stock Liabilities', 'Ledger',
'No', '', 'Liability', self.doc.name, ''],
['Duties and Taxes','Current Liabilities','Group','No','','Liability',self.doc.name,''],
['Loans (Liabilities)','Current Liabilities','Group','No','','Liability',self.doc.name,''],
['Secured Loans','Loans (Liabilities)','Group','No','','Liability',self.doc.name,''],
['Unsecured Loans','Loans (Liabilities)','Group','No','','Liability',self.doc.name,''],
['Bank Overdraft Account','Loans (Liabilities)','Group','No','','Liability',self.doc.name,''],
['Temporary Accounts (Liabilities)','Source of Funds (Liabilities)','Group','No','','Liability',self.doc.name,''],
['Temporary Account (Liabilities)','Temporary Accounts (Liabilities)','Ledger','No','','Liability',self.doc.name,'']
['Application of Funds (Assets)','','Group','','Balance Sheet',self.doc.name,''],
['Current Assets','Application of Funds (Assets)','Group','','Balance Sheet',self.doc.name,''],
['Accounts Receivable','Current Assets','Group','','Balance Sheet',self.doc.name,''],
['Bank Accounts','Current Assets','Group','Bank','Balance Sheet',self.doc.name,''],
['Cash In Hand','Current Assets','Group','Cash','Balance Sheet',self.doc.name,''],
['Cash','Cash In Hand','Ledger','Cash','Balance Sheet',self.doc.name,''],
['Loans and Advances (Assets)','Current Assets','Group','','Balance Sheet',self.doc.name,''],
['Securities and Deposits','Current Assets','Group','','Balance Sheet',self.doc.name,''],
['Earnest Money','Securities and Deposits','Ledger','','Balance Sheet',self.doc.name,''],
['Stock Assets','Current Assets','Group','','Balance Sheet',self.doc.name,''],
['Tax Assets','Current Assets','Group','','Balance Sheet',self.doc.name,''],
['Fixed Assets','Application of Funds (Assets)','Group','','Balance Sheet',self.doc.name,''],
['Capital Equipments','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.doc.name,''],
['Computers','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.doc.name,''],
['Furniture and Fixture','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.doc.name,''],
['Office Equipments','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.doc.name,''],
['Plant and Machinery','Fixed Assets','Ledger','Fixed Asset','Balance Sheet',self.doc.name,''],
['Investments','Application of Funds (Assets)','Group','','Balance Sheet',self.doc.name,''],
['Temporary Accounts (Assets)','Application of Funds (Assets)','Group','','Balance Sheet',self.doc.name,''],
['Temporary Account (Assets)','Temporary Accounts (Assets)','Ledger','','Balance Sheet',self.doc.name,''],
['Expenses','','Group','Expense Account','Profit and Loss',self.doc.name,''],
['Direct Expenses','Expenses','Group','Expense Account','Profit and Loss',self.doc.name,''],
['Stock Expenses','Direct Expenses','Group','Expense Account','Profit and Loss',self.doc.name,''],
['Cost of Goods Sold','Stock Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Stock Adjustment','Stock Expenses','Ledger','Stock Adjustment','Profit and Loss',self.doc.name,''],
['Expenses Included In Valuation', "Stock Expenses", 'Ledger', 'Expenses Included In Valuation', 'Profit and Loss', self.doc.name, ''],
['Indirect Expenses','Expenses','Group','Expense Account','Profit and Loss',self.doc.name,''],
['Advertising and Publicity','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.doc.name,''],
['Bad Debts Written Off','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Bank Charges','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Books and Periodicals','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Charity and Donations','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Commission on Sales','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Conveyance Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Customer Entertainment Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Depreciation Account','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Freight and Forwarding Charges','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.doc.name,''],
['Legal Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Miscellaneous Expenses','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.doc.name,''],
['Office Maintenance Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Office Rent','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Postal Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Print and Stationary','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Rounded Off','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Salary','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Sales Promotion Expenses','Indirect Expenses','Ledger','Chargeable','Profit and Loss',self.doc.name,''],
['Service Charges Paid','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Staff Welfare Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Telephone Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Travelling Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Water and Electricity Expenses','Indirect Expenses','Ledger','Expense Account','Profit and Loss',self.doc.name,''],
['Income','','Group','','Profit and Loss',self.doc.name,''],
['Direct Income','Income','Group','Income Account','Profit and Loss',self.doc.name,''],
['Sales','Direct Income','Ledger','Income Account','Profit and Loss',self.doc.name,''],
['Service','Direct Income','Ledger','Income Account','Profit and Loss',self.doc.name,''],
['Indirect Income','Profit and Loss','Group','Income Account','Profit and Loss',self.doc.name,''],
['Source of Funds (Liabilities)','','Group','','Balance Sheet',self.doc.name,''],
['Capital Account','Source of Funds (Liabilities)','Group','','Balance Sheet',self.doc.name,''],
['Reserves and Surplus','Capital Account','Ledger','','Balance Sheet',self.doc.name,''],
['Shareholders Funds','Capital Account','Ledger','','Balance Sheet',self.doc.name,''],
['Current Liabilities','Source of Funds (Liabilities)','Group','','Balance Sheet',self.doc.name,''],
['Accounts Payable','Current Liabilities','Group','','Balance Sheet',self.doc.name,''],
['Stock Liabilities','Current Liabilities','Group','','Balance Sheet',self.doc.name,''],
['Stock Received But Not Billed', 'Stock Liabilities', 'Ledger', 'Stock Received But Not Billed', 'Balance Sheet', self.doc.name, ''],
['Duties and Taxes','Current Liabilities','Group','','Balance Sheet',self.doc.name,''],
['Loans (Liabilities)','Current Liabilities','Group','','Balance Sheet',self.doc.name,''],
['Secured Loans','Loans (Liabilities)','Group','','Balance Sheet',self.doc.name,''],
['Unsecured Loans','Loans (Liabilities)','Group','','Balance Sheet',self.doc.name,''],
['Bank Overdraft Account','Loans (Liabilities)','Group','','Balance Sheet',self.doc.name,''],
['Temporary Accounts (Liabilities)','Source of Funds (Liabilities)','Group','','Balance Sheet',self.doc.name,''],
['Temporary Account (Liabilities)','Temporary Accounts (Liabilities)','Ledger','','Balance Sheet',self.doc.name,'']
]
acc_list_india = [
['CENVAT Capital Goods','Tax Assets','Ledger','No','Chargeable','Asset',self.doc.name,''],
['CENVAT','Tax Assets','Ledger','No','Chargeable','Asset',self.doc.name,''],
['CENVAT Service Tax','Tax Assets','Ledger','No','Chargeable','Asset',self.doc.name,''],
['CENVAT Service Tax Cess 1','Tax Assets','Ledger','No','Chargeable','Asset',self.doc.name,''],
['CENVAT Service Tax Cess 2','Tax Assets','Ledger','No','Chargeable','Asset',self.doc.name,''],
['CENVAT Edu Cess','Tax Assets','Ledger','No','Chargeable','Asset',self.doc.name,''],
['CENVAT SHE Cess','Tax Assets','Ledger','No','Chargeable','Asset',self.doc.name,''],
['Excise Duty 4','Tax Assets','Ledger','No','Tax','Asset',self.doc.name,'4.00'],
['Excise Duty 8','Tax Assets','Ledger','No','Tax','Asset',self.doc.name,'8.00'],
['Excise Duty 10','Tax Assets','Ledger','No','Tax','Asset',self.doc.name,'10.00'],
['Excise Duty 14','Tax Assets','Ledger','No','Tax','Asset',self.doc.name,'14.00'],
['Excise Duty Edu Cess 2','Tax Assets','Ledger','No','Tax','Asset',self.doc.name,'2.00'],
['Excise Duty SHE Cess 1','Tax Assets','Ledger','No','Tax','Asset',self.doc.name,'1.00'],
['P L A','Tax Assets','Ledger','No','Chargeable','Asset',self.doc.name,''],
['P L A - Cess Portion','Tax Assets','Ledger','No','Chargeable','Asset',self.doc.name,''],
['Edu. Cess on Excise','Duties and Taxes','Ledger','No','Tax','Liability',self.doc.name,'2.00'],
['Edu. Cess on Service Tax','Duties and Taxes','Ledger','No','Tax','Liability',self.doc.name,'2.00'],
['Edu. Cess on TDS','Duties and Taxes','Ledger','No','Tax','Liability',self.doc.name,'2.00'],
['Excise Duty @ 4','Duties and Taxes','Ledger','No','Tax','Liability',self.doc.name,'4.00'],
['Excise Duty @ 8','Duties and Taxes','Ledger','No','Tax','Liability',self.doc.name,'8.00'],
['Excise Duty @ 10','Duties and Taxes','Ledger','No','Tax','Liability',self.doc.name,'10.00'],
['Excise Duty @ 14','Duties and Taxes','Ledger','No','Tax','Liability',self.doc.name,'14.00'],
['Service Tax','Duties and Taxes','Ledger','No','Tax','Liability',self.doc.name,'10.3'],
['SHE Cess on Excise','Duties and Taxes','Ledger','No','Tax','Liability',self.doc.name,'1.00'],
['SHE Cess on Service Tax','Duties and Taxes','Ledger','No','Tax','Liability',self.doc.name,'1.00'],
['SHE Cess on TDS','Duties and Taxes','Ledger','No','Tax','Liability',self.doc.name,'1.00'],
['Professional Tax','Duties and Taxes','Ledger','No','Chargeable','Liability',self.doc.name,''],
['VAT','Duties and Taxes','Ledger','No','Chargeable','Liability',self.doc.name,''],
['TDS (Advertisement)','Duties and Taxes','Ledger','No','Chargeable','Liability',self.doc.name,''],
['TDS (Commission)','Duties and Taxes','Ledger','No','Chargeable','Liability',self.doc.name,''],
['TDS (Contractor)','Duties and Taxes','Ledger','No','Chargeable','Liability',self.doc.name,''],
['TDS (Interest)','Duties and Taxes','Ledger','No','Chargeable','Liability',self.doc.name,''],
['TDS (Rent)','Duties and Taxes','Ledger','No','Chargeable','Liability',self.doc.name,''],
['TDS (Salary)','Duties and Taxes','Ledger','No','Chargeable','Liability',self.doc.name,'']
['CENVAT Capital Goods','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['CENVAT','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['CENVAT Service Tax','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['CENVAT Service Tax Cess 1','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['CENVAT Service Tax Cess 2','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['CENVAT Edu Cess','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['CENVAT SHE Cess','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['Excise Duty 4','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'4.00'],
['Excise Duty 8','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'8.00'],
['Excise Duty 10','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'10.00'],
['Excise Duty 14','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'14.00'],
['Excise Duty Edu Cess 2','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'2.00'],
['Excise Duty SHE Cess 1','Tax Assets','Ledger','Tax','Balance Sheet',self.doc.name,'1.00'],
['P L A','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['P L A - Cess Portion','Tax Assets','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['Edu. Cess on Excise','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'2.00'],
['Edu. Cess on Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'2.00'],
['Edu. Cess on TDS','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'2.00'],
['Excise Duty @ 4','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'4.00'],
['Excise Duty @ 8','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'8.00'],
['Excise Duty @ 10','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'10.00'],
['Excise Duty @ 14','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'14.00'],
['Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'10.3'],
['SHE Cess on Excise','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'1.00'],
['SHE Cess on Service Tax','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'1.00'],
['SHE Cess on TDS','Duties and Taxes','Ledger','Tax','Balance Sheet',self.doc.name,'1.00'],
['Professional Tax','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['VAT','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['TDS (Advertisement)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['TDS (Commission)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['TDS (Contractor)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['TDS (Interest)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['TDS (Rent)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,''],
['TDS (Salary)','Duties and Taxes','Ledger','Chargeable','Balance Sheet',self.doc.name,'']
]
# load common account heads
for d in acc_list_common:

View File

@ -9,7 +9,7 @@ import unittest
class TestCompany(unittest.TestCase):
def test_coa(self):
for country, chart_name in frappe.db.sql("""select country, chart_name
from `tabChart of Accounts` order by country""", as_list=1):
from `tabChart of Accounts` where country="India" order by country""", as_list=1):
print "Country: ", country
print "Chart Name: ", chart_name

View File

@ -158,9 +158,9 @@ class DocType(DocListController):
self.meta.get_label("income_year_to_date"))
def get_bank_balance(self):
# account is of type "Bank or Cash"
# account is of type "Bank" or "Cash"
accounts = dict([[a["name"], [a["account_name"], 0]] for a in self.get_accounts()
if a["account_type"]=="Bank or Cash"])
if a["account_type"] in ["Bank", "Cash"]])
ackeys = accounts.keys()
for gle in self.get_gl_entries(None, self.to_date):
@ -211,9 +211,9 @@ class DocType(DocListController):
accounts = [a["name"] for a in self.get_accounts()
if a["master_type"]==party_type]
# account is "Bank or Cash"
# account is "Bank" or "Cash"
bc_accounts = [esc(a["name"], "()|") for a in self.get_accounts()
if a["account_type"]=="Bank or Cash"]
if a["account_type"] in ["Bank", "Cash"]]
bc_regex = re.compile("""(%s)""" % "|".join(bc_accounts))
total = 0

View File

@ -2,7 +2,7 @@
{
"creation": "2013-02-21 14:15:31",
"docstatus": 0,
"modified": "2014-01-20 17:48:39",
"modified": "2014-03-19 11:39:27",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -119,7 +119,7 @@
"label": "Income Year to Date"
},
{
"description": "Balances of Accounts of type \"Bank or Cash\"",
"description": "Balances of Accounts of type \"Bank\" or \"Cash\"",
"doctype": "DocField",
"fieldname": "bank_balance",
"fieldtype": "Check",

View File

@ -113,6 +113,7 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
frappe.datetime.add_days(frappe.datetime.add_months(
frappe.datetime.user_to_obj(slide.get_input("fy_start_date").val()), 12), -1);
slide.get_input("fy_end_date").val(frappe.datetime.obj_to_user(year_end_date));
});
}
},
@ -128,6 +129,8 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
options: "", fieldtype: 'Select'},
{fieldname:'timezone', label: frappe._('Time Zone'), reqd:1,
options: "", fieldtype: 'Select'},
{fieldname:'chart_of_accounts', label: frappe._('Chart of Accounts'),
options: "", fieldtype: 'Select'}
],
help: frappe._('Select your home country and check the timezone and currency.'),
onload: function(slide, form) {
@ -158,6 +161,17 @@ frappe.pages['setup-wizard'].onload = function(wrapper) {
}
// add all timezones at the end, so that user has the option to change it to any timezone
$timezone.add_options([""].concat(erpnext.all_timezones));
// get country specific chart of accounts
frappe.call({
method: "erpnext.accounts.doctype.chart_of_accounts.chart_of_accounts.get_charts_for_country",
args: {"country": country},
callback: function(r) {
if(r.message)
slide.get_input("chart_of_accounts").empty()
.add_options([""].concat(r.message));
}
})
});
}
},

View File

@ -80,7 +80,7 @@ def create_fiscal_year_and_company(args):
'year_end_date': args.get('fy_end_date'),
}]).insert()
print args
# Company
frappe.bean([{
"doctype":"Company",
@ -88,7 +88,8 @@ def create_fiscal_year_and_company(args):
'company_name':args.get('company_name'),
'abbr':args.get('company_abbr'),
'default_currency':args.get('currency'),
'country': args.get('country')
'country': args.get('country'),
'chart_of_accounts': args.get(('chart_of_accounts')),
}]).insert()
args["curr_fiscal_year"] = curr_fiscal_year
@ -229,7 +230,7 @@ def create_taxes(args):
"parent_account": "Duties and Taxes - " + args.get("company_abbr"),
"account_name": args.get("tax_" + str(i)),
"group_or_ledger": "Ledger",
"is_pl_account": "No",
"report_type": "Balance Sheet",
"account_type": "Tax",
"tax_rate": args.get("tax_rate_" + str(i))
}).insert()

View File

@ -217,8 +217,7 @@ if (sys_defaults.auto_accounting_for_stock) {
cur_frm.fields_dict['delivery_note_details'].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"
}

View File

@ -55,8 +55,8 @@ cur_frm.fields_dict['default_bom'].get_query = function(doc) {
cur_frm.fields_dict['expense_account'].get_query = function(doc) {
return {
filters: {
'root_type': "Expense",
'group_or_ledger': "Ledger"
"report_type": "Profit and Loss",
"group_or_ledger": "Ledger"
}
}
}
@ -66,7 +66,7 @@ cur_frm.fields_dict['expense_account'].get_query = function(doc) {
cur_frm.fields_dict['income_account'].get_query = function(doc) {
return {
filters: {
'root_type': "Income",
"report_type": "Profit and Loss",
'group_or_ledger': "Ledger",
'account_type': "Income Account"
}

View File

@ -291,7 +291,7 @@ class DocType(StockController):
msgprint(_("Please enter Expense Account"), raise_exception=1)
elif not frappe.db.sql("""select * from `tabStock Ledger Entry`"""):
if frappe.db.get_value("Account", self.doc.expense_account,
"is_pl_account") == "Yes":
"report_type") == "Profit and Loss":
msgprint(_("""Expense Account can not be a PL Account, as this stock \
reconciliation is an opening entry. \
Please select 'Temporary Account (Liabilities)' or relevant account"""),