Removed debit_or_credit field

This commit is contained in:
Nabin Hait 2014-03-03 18:40:24 +05:30
parent 133490a0c5
commit 49a6f0754e
33 changed files with 194 additions and 263 deletions

View File

@ -1,14 +1,6 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
// Onload
// -----------------------------------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
// Refresh
// -----------------------------------------
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.__islocal) {
msgprint(frappe._("Please create new account from Chart of Accounts."));
@ -22,8 +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', 'debit_or_credit', 'group_or_ledger',
'is_pl_account', 'company'], false);
cur_frm.toggle_enable(['account_name', 'group_or_ledger', 'is_pl_account', 'company'], false);
if(doc.group_or_ledger=='Ledger') {
frappe.model.with_doc("Accounts Settings", "Accounts Settings", function (name) {
@ -61,14 +52,8 @@ cur_frm.cscript.master_type = function(doc, cdt, cdn) {
in_list(['Customer', 'Supplier'], doc.master_type));
}
// Fetch parent details
// -----------------------------------------
cur_frm.add_fetch('parent_account', 'debit_or_credit', 'debit_or_credit');
cur_frm.add_fetch('parent_account', 'is_pl_account', 'is_pl_account');
// Hide tax rate based on account type
// -----------------------------------------
cur_frm.cscript.account_type = function(doc, cdt, cdn) {
if(doc.group_or_ledger=='Ledger') {
cur_frm.toggle_display(['tax_rate'], doc.account_type == 'Tax');
@ -78,8 +63,6 @@ cur_frm.cscript.account_type = function(doc, cdt, cdn) {
}
}
// Hide/unhide group or ledger
// -----------------------------------------
cur_frm.cscript.add_toolbar_buttons = function(doc) {
cur_frm.appframe.add_button(frappe._('Chart of Accounts'),
function() { frappe.set_route("Accounts Browser", "Account"); }, 'icon-sitemap')
@ -102,8 +85,7 @@ cur_frm.cscript.add_toolbar_buttons = function(doc) {
}, "icon-table");
}
}
// Convert group to ledger
// -----------------------------------------
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
return $c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) {
if(r.message == 1) {
@ -112,8 +94,6 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
});
}
// Convert ledger to group
// -----------------------------------------
cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
return $c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) {
if(r.message == 1) {

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, is_pl_account, debit_or_credit
par = frappe.db.sql("""select name, group_or_ledger, is_pl_account
from tabAccount where name =%s""", self.doc.parent_account)
if not par:
throw(_("Parent account does not exists"))
@ -56,19 +56,9 @@ class DocType:
throw(_("You can not assign itself as parent account"))
elif par[0][1] != 'Group':
throw(_("Parent account can not be a ledger"))
elif self.doc.debit_or_credit and par[0][3] != self.doc.debit_or_credit:
throw("{msg} {debit_or_credit} {under} {account} {acc}".format(**{
"msg": _("You cannot move a"),
"debit_or_credit": self.doc.debit_or_credit,
"under": _("account under"),
"account": par[0][3],
"acc": _("account")
}))
if not self.doc.is_pl_account:
self.doc.is_pl_account = par[0][2]
if not self.doc.debit_or_credit:
self.doc.debit_or_credit = par[0][3]
def validate_duplicate_account(self):
if self.doc.fields.get('__islocal') or not self.doc.name:
@ -131,8 +121,6 @@ class DocType:
and docstatus != 2""", self.doc.name)
def validate_mandatory(self):
if not self.doc.debit_or_credit:
throw(_("Debit or Credit field is mandatory"))
if not self.doc.is_pl_account:
throw(_("Is PL Account field is mandatory"))
@ -215,9 +203,9 @@ class DocType:
throw(_("Account ") + new +_(" does not exists"))
val = list(frappe.db.get_value("Account", new_account,
["group_or_ledger", "debit_or_credit", "is_pl_account", "company"]))
["group_or_ledger", "is_pl_account", "company"]))
if val != [self.doc.group_or_ledger, self.doc.debit_or_credit, self.doc.is_pl_account, self.doc.company]:
if val != [self.doc.group_or_ledger, self.doc.is_pl_account, 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"""))

View File

@ -2,7 +2,7 @@
{
"creation": "2013-01-30 12:49:46",
"docstatus": 0,
"modified": "2014-01-20 17:48:20",
"modified": "2014-03-03 17:21:07",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -16,7 +16,7 @@
"in_create": 1,
"module": "Accounts",
"name": "__common__",
"search_fields": "debit_or_credit, group_or_ledger"
"search_fields": "group_or_ledger"
},
{
"doctype": "DocField",
@ -93,17 +93,6 @@
"reqd": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "debit_or_credit",
"fieldtype": "Data",
"in_filter": 1,
"label": "Debit or Credit",
"oldfieldname": "debit_or_credit",
"oldfieldtype": "Data",
"read_only": 1,
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "is_pl_account",
@ -146,6 +135,13 @@
"options": "Account",
"search_index": 1
},
{
"doctype": "DocField",
"fieldname": "root_type",
"fieldtype": "Select",
"label": "Root Type",
"options": "\nAsset\nLiability\nExpense\nIncome\nEquity"
},
{
"description": "Setting Account Type helps in selecting this Account in transactions.",
"doctype": "DocField",

View File

@ -15,7 +15,6 @@ erpnext.accounts.CostCenterController = frappe.ui.form.Controller.extend({
filters:[
['Account', 'company', '=', me.frm.doc.company],
['Account', 'is_pl_account', '=', 'Yes'],
['Account', 'debit_or_credit', '=', 'Debit'],
['Account', 'group_or_ledger', '!=', 'Group'],
]
}

View File

@ -15,8 +15,10 @@ class DocType:
self.doclist = doclist
def set_account_type(self):
self.doc.account_type = self.doc.account and \
frappe.db.get_value("Account", self.doc.account, "debit_or_credit").lower() or ""
self.doc.account_type = ""
if self.doc.account:
root_type = frappe.db.get_value("Account", self.doc.account, "root_type")
self.doc.account_type = "debit" if root_type in ["Asset", "Income"] else "credit"
def get_voucher_details(self):
total_amount = frappe.db.sql("""select sum(%s) from `tabGL Entry`

View File

@ -13,8 +13,8 @@ cur_frm.fields_dict['closing_account_head'].get_query = function(doc, cdt, cdn)
return{
filters:{
'is_pl_account': "No",
"debit_or_credit": "Credit",
"company": doc.company,
"root_type": "Liability",
"freeze_account": "No",
"group_or_ledger": "Ledger"
}

View File

@ -3,8 +3,8 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import cstr, flt, getdate
from frappe import msgprint, _
from frappe.utils import cstr, flt
from frappe import _
from erpnext.controllers.accounts_controller import AccountsController
class DocType(AccountsController):
@ -25,10 +25,8 @@ class DocType(AccountsController):
where voucher_type = 'Period Closing Voucher' and voucher_no=%s""", self.doc.name)
def validate_account_head(self):
debit_or_credit, is_pl_account = frappe.db.get_value("Account",
self.doc.closing_account_head, ["debit_or_credit", "is_pl_account"])
if debit_or_credit != 'Credit' or is_pl_account != 'No':
if frappe.db.get_value("Account", self.doc.closing_account_head, "root_type") \
!= "Liability":
frappe.throw(_("Account") + ": " + self.doc.closing_account_head +
_("must be a Liability account"))
@ -48,16 +46,14 @@ class DocType(AccountsController):
select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0))
from `tabGL Entry` t1, tabAccount t2
where t1.account = t2.name and t1.posting_date between %s and %s
and t2.debit_or_credit = 'Credit' and t2.is_pl_account = 'Yes'
and t2.docstatus < 2 and t2.company = %s""",
and t2.root_type = 'Income' and t2.docstatus < 2 and t2.company = %s""",
(self.year_start_date, self.doc.posting_date, self.doc.company))
expense_bal = frappe.db.sql("""
select sum(ifnull(t1.debit,0))-sum(ifnull(t1.credit,0))
from `tabGL Entry` t1, tabAccount t2
where t1.account = t2.name and t1.posting_date between %s and %s
and t2.debit_or_credit = 'Debit' and t2.is_pl_account = 'Yes'
and t2.docstatus < 2 and t2.company=%s""",
and t2.root_type = 'Expense' and t2.docstatus < 2 and t2.company=%s""",
(self.year_start_date, self.doc.posting_date, self.doc.company))
income_bal = income_bal and income_bal[0][0] or 0

View File

@ -16,7 +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:{
'debit_or_credit': "Debit",
'root_type': "Asset",
'is_pl_account': "No",
'group_or_ledger': "Ledger",
'company': doc.company
@ -29,7 +29,6 @@ cur_frm.fields_dict['cash_bank_account'].get_query = function(doc,cdt,cdn) {
cur_frm.fields_dict['income_account'].get_query = function(doc,cdt,cdn) {
return{
filters:{
'debit_or_credit': "Credit",
'group_or_ledger': "Ledger",
'company': doc.company,
'account_type': "Income Account"
@ -56,7 +55,7 @@ cur_frm.fields_dict["expense_account"].get_query = function(doc) {
return {
filters: {
"is_pl_account": "Yes",
"debit_or_credit": "Debit",
"root_type": "Expense",
"company": doc.company,
"group_or_ledger": "Ledger"
}

View File

@ -158,7 +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:{
'debit_or_credit': 'Credit',
'root_type': 'Liability',
'is_pl_account': 'No',
'group_or_ledger': 'Ledger',
'company': doc.company

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals
import frappe
from frappe.utils import add_days, cint, cstr, flt, formatdate
from frappe.utils import cint, cstr, flt, formatdate
from frappe.model.bean import getlist
from frappe.model.code import get_obj
from frappe import msgprint, _
@ -109,17 +109,8 @@ class DocType(BuyingController):
self.doc.remarks = "No Remarks"
def validate_credit_acc(self):
acc = frappe.db.sql("select debit_or_credit, is_pl_account from tabAccount where name = %s",
self.doc.credit_to)
if not acc:
msgprint("Account: "+ self.doc.credit_to + "does not exist")
raise Exception
elif acc[0][0] and acc[0][0] != 'Credit':
msgprint("Account: "+ self.doc.credit_to + "is not a credit account")
raise Exception
elif acc[0][1] and acc[0][1] != 'No':
msgprint("Account: "+ self.doc.credit_to + "is a pl account")
raise Exception
if frappe.db.get_value("Account", self.doc.debit_to, "root_type") != "Liability":
frappe.throw(_("Account must be an liability account"))
# Validate Acc Head of Supplier and Credit To Account entered
# ------------------------------------------------------------
@ -433,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.debit_or_credit="Debit"
where (tabAccount.root_type in ("Asset", "Expense")
or tabAccount.account_type = "Expense Account")
and tabAccount.group_or_ledger="Ledger"
and tabAccount.docstatus!=2

View File

@ -138,7 +138,7 @@ cur_frm.set_query("account_head", "other_charges", function(doc) {
query: "erpnext.controllers.queries.tax_account_query",
filters: {
"account_type": ["Tax", "Chargeable", "Expense Account"],
"debit_or_credit": "Debit",
"root_type": "Expense",
"company": doc.company
}
}

View File

@ -289,7 +289,7 @@ cur_frm.cscript.make_bank_voucher = function() {
cur_frm.fields_dict.debit_to.get_query = function(doc) {
return{
filters: {
'debit_or_credit': 'Debit',
'root_type': 'Asset',
'is_pl_account': 'No',
'group_or_ledger': 'Ledger',
'company': doc.company
@ -300,7 +300,7 @@ cur_frm.fields_dict.debit_to.get_query = function(doc) {
cur_frm.fields_dict.cash_bank_account.get_query = function(doc) {
return{
filters: {
'debit_or_credit': 'Debit',
'root_type': 'Asset',
'is_pl_account': 'No',
'group_or_ledger': 'Ledger',
'company': doc.company
@ -311,7 +311,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:{
'debit_or_credit': 'Debit',
'root_type': 'Expense',
'is_pl_account': 'Yes',
'group_or_ledger': 'Ledger',
'company': doc.company
@ -354,7 +354,7 @@ if (sys_defaults.auto_accounting_for_stock) {
return {
filters: {
'is_pl_account': 'Yes',
'debit_or_credit': 'Debit',
'root_type': 'Expense',
'company': doc.company,
'group_or_ledger': 'Ledger'
}

View File

@ -257,17 +257,8 @@ class DocType(SellingController):
def validate_debit_acc(self):
acc = frappe.db.sql("select debit_or_credit, is_pl_account from tabAccount where name = %s and docstatus != 2", self.doc.debit_to)
if not acc:
msgprint("Account: "+ self.doc.debit_to + " does not exist")
raise Exception
elif acc[0][0] and acc[0][0] != 'Debit':
msgprint("Account: "+ self.doc.debit_to + " is not a debit account")
raise Exception
elif acc[0][1] and acc[0][1] != 'No':
msgprint("Account: "+ self.doc.debit_to + " is a pl account")
raise Exception
if frappe.db.get_value("Account", self.doc.debit_to, "root_type") != "Asset":
frappe.throw(_("Account must be an asset account"))
def validate_fixed_asset_account(self):
"""Validate Fixed Asset Account and whether Income Account Entered Exists"""
@ -796,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.debit_or_credit="Credit"
where (tabAccount.root_type in ("Liability", "Income")
or tabAccount.account_type = "Income Account")
and tabAccount.group_or_ledger="Ledger"
and tabAccount.docstatus!=2

View File

@ -137,7 +137,7 @@ 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"],
"debit_or_credit": "Credit",
"root_type": "Income",
"company": doc.company
}
}

View File

@ -21,7 +21,7 @@ frappe.query_reports["Accounts Payable"] = {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Credit",
"root_type": "Liability",
"company": company,
"master_type": "Supplier"
}

View File

@ -21,7 +21,7 @@ frappe.query_reports["Accounts Receivable"] = {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Debit",
"root_type": "Asset",
"company": company,
"master_type": "Customer"
}

View File

@ -8,8 +8,6 @@ from frappe.utils import flt
def execute(filters=None):
if not filters: filters = {}
debit_or_credit = frappe.db.get_value("Account", filters["account"], "debit_or_credit")
columns = get_columns()
data = get_entries(filters)
@ -21,15 +19,12 @@ def execute(filters=None):
total_debit += flt(d[4])
total_credit += flt(d[5])
if debit_or_credit == 'Debit':
bank_bal = flt(balance_as_per_company) - flt(total_debit) + flt(total_credit)
else:
bank_bal = flt(balance_as_per_company) + flt(total_debit) - flt(total_credit)
bank_bal = flt(balance_as_per_company) + flt(total_debit) - flt(total_credit)
data += [
get_balance_row("Balance as per company books", balance_as_per_company, debit_or_credit),
get_balance_row("Balance as per company books", balance_as_per_company),
["", "", "", "Amounts not reflected in bank", total_debit, total_credit],
get_balance_row("Balance as per bank", bank_bal, debit_or_credit)
get_balance_row("Balance as per bank", bank_bal)
]
return columns, data
@ -52,8 +47,8 @@ def get_entries(filters):
return entries
def get_balance_row(label, amount, debit_or_credit):
if debit_or_credit == "Debit":
def get_balance_row(label, amount):
if amount > 0:
return ["", "", "", label, amount, 0]
else:
return ["", "", "", label, 0, amount]

View File

@ -8,8 +8,7 @@ from frappe import _
def execute(filters=None):
account_details = {}
for acc in frappe.db.sql("""select name, debit_or_credit, group_or_ledger
from tabAccount""", as_dict=1):
for acc in frappe.db.sql("""select name, group_or_ledger from tabAccount""", as_dict=1):
account_details.setdefault(acc.name, acc)
validate_filters(filters, account_details)
@ -88,15 +87,13 @@ def get_data_with_opening_closing(filters, account_details, gl_entries):
# Opening for filtered account
if filters.get("account"):
data += [get_balance_row("Opening", account_details[filters.account].debit_or_credit,
opening), {}]
data += [get_balance_row("Opening", opening), {}]
for acc, acc_dict in gle_map.items():
if acc_dict.entries:
# Opening for individual ledger, if grouped by account
if filters.get("group_by_account"):
data.append(get_balance_row("Opening", account_details[acc].debit_or_credit,
acc_dict.opening))
data.append(get_balance_row("Opening", acc_dict.opening))
data += acc_dict.entries
@ -105,8 +102,7 @@ def get_data_with_opening_closing(filters, account_details, gl_entries):
data += [{"account": "Totals", "debit": acc_dict.total_debit,
"credit": acc_dict.total_credit},
get_balance_row("Closing (Opening + Totals)",
account_details[acc].debit_or_credit, (acc_dict.opening
+ acc_dict.total_debit - acc_dict.total_credit)), {}]
(acc_dict.opening + acc_dict.total_debit - acc_dict.total_credit)), {}]
# Total debit and credit between from and to date
if total_debit or total_credit:
@ -115,7 +111,6 @@ def get_data_with_opening_closing(filters, account_details, gl_entries):
# Closing for filtered account
if filters.get("account"):
data.append(get_balance_row("Closing (Opening + Totals)",
account_details[filters.account].debit_or_credit,
(opening + total_debit - total_credit)))
return data
@ -151,11 +146,11 @@ def get_accountwise_gle(filters, gl_entries, gle_map):
return opening, total_debit, total_credit, gle_map
def get_balance_row(label, debit_or_credit, balance):
def get_balance_row(label, balance):
return {
"account": label,
"debit": balance if debit_or_credit=="Debit" else 0,
"credit": -1*balance if debit_or_credit=="Credit" else 0,
"debit": balance if balance > 0 else 0,
"credit": -1*balance if balance < 0 else 0,
}
def get_result_as_list(data):

View File

@ -33,7 +33,7 @@ frappe.query_reports["Item-wise Purchase Register"] = {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Credit",
"root_type": "Liability",
"company": company,
"master_type": "Supplier"
}

View File

@ -27,7 +27,7 @@ frappe.query_reports["Item-wise Sales Register"] = frappe.query_reports["Sales R
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Debit",
"root_type": "Asset",
"company": company,
"master_type": "Customer"
}

View File

@ -27,7 +27,7 @@ frappe.query_reports["Purchase Register"] = {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Credit",
"root_type": "Liability",
"company": company,
"master_type": "Supplier"
}

View File

@ -27,7 +27,7 @@ frappe.query_reports["Sales Register"] = {
"query": "accounts.utils.get_account_list",
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Debit",
"root_type": "Asset",
"company": company,
"master_type": "Customer"
}

View File

@ -74,7 +74,7 @@ def get_balance_on(account=None, date=None):
return 0.0
acc = frappe.db.get_value('Account', account, \
['lft', 'rgt', 'debit_or_credit', 'is_pl_account', 'group_or_ledger'], as_dict=1)
['lft', 'rgt', 'is_pl_account', 'group_or_ledger'], as_dict=1)
# for pl accounts, get balance within a fiscal year
if acc.is_pl_account == 'Yes':
@ -95,10 +95,6 @@ def get_balance_on(account=None, date=None):
FROM `tabGL Entry` gle
WHERE %s""" % " and ".join(cond))[0][0]
# if credit account, it should calculate credit - debit
if bal and acc.debit_or_credit == 'Credit':
bal = -bal
# if bal is None, return 0
return flt(bal)
@ -290,7 +286,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",
"debit_or_credit": "Debit"}):
"root_type": "Expense"}):
budget = frappe.db.sql("""
select bd.budget_allocated, cc.distribution_id
from `tabCost Center` cc, `tabBudget Detail` bd

View File

@ -106,18 +106,16 @@ 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, debit_or_credit
from tabAccount
return frappe.db.sql("""select name, parent_account from tabAccount
where tabAccount.docstatus!=2
and (account_type in (%s) or
(ifnull(is_pl_account, 'No') = 'Yes' and debit_or_credit = %s) )
and (account_type in (%s) or root_type = %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("debit_or_credit"),
tuple(filters.get("account_type") + [filters.get("root_type"),
filters.get("company"), "%%%s%%" % txt, start, page_len]))
def item_query(doctype, txt, searchfield, start, page_len, filters):

View File

@ -106,7 +106,7 @@ cur_frm.fields_dict.default_expense_account.get_query = function(doc) {
'company': doc.name,
'group_or_ledger': "Ledger",
'is_pl_account': "Yes",
'debit_or_credit': "Debit"
'root_type': "Expense"
}
}
}
@ -117,7 +117,7 @@ cur_frm.fields_dict.default_income_account.get_query = function(doc) {
'company': doc.name,
'group_or_ledger': "Ledger",
'is_pl_account': "Yes",
'debit_or_credit': "Credit"
'root_type': "Income"
}
}
}
@ -136,7 +136,7 @@ if (sys_defaults.auto_accounting_for_stock) {
return {
"filters": {
"is_pl_account": "Yes",
"debit_or_credit": "Debit",
"root_type": "Expense",
"company": doc.name,
'group_or_ledger': "Ledger"
}
@ -150,7 +150,7 @@ if (sys_defaults.auto_accounting_for_stock) {
return {
"filters": {
"is_pl_account": "No",
"debit_or_credit": "Credit",
"root_type": "Liability",
"company": doc.name,
'group_or_ledger': "Ledger"
}

View File

@ -101,117 +101,117 @@ class DocType:
style_settings.save()
def create_default_accounts(self):
self.fld_dict = {'account_name':0,'parent_account':1,'group_or_ledger':2,'is_pl_account':3,'account_type':4,'debit_or_credit':5,'company':6,'tax_rate':7}
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}
acc_list_common = [
['Application of Funds (Assets)','','Group','No','','Debit',self.doc.name,''],
['Current Assets','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
['Accounts Receivable','Current Assets','Group','No','','Debit',self.doc.name,''],
['Bank Accounts','Current Assets','Group','No','Bank or Cash','Debit',self.doc.name,''],
['Cash In Hand','Current Assets','Group','No','Bank or Cash','Debit',self.doc.name,''],
['Cash','Cash In Hand','Ledger','No','Bank or Cash','Debit',self.doc.name,''],
['Loans and Advances (Assets)','Current Assets','Group','No','','Debit',self.doc.name,''],
['Securities and Deposits','Current Assets','Group','No','','Debit',self.doc.name,''],
['Earnest Money','Securities and Deposits','Ledger','No','','Debit',self.doc.name,''],
['Stock Assets','Current Assets','Group','No','','Debit',self.doc.name,''],
['Tax Assets','Current Assets','Group','No','','Debit',self.doc.name,''],
['Fixed Assets','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
['Capital Equipments','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
['Computers','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
['Furniture and Fixture','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
['Office Equipments','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
['Plant and Machinery','Fixed Assets','Ledger','No','Fixed Asset Account','Debit',self.doc.name,''],
['Investments','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
['Temporary Accounts (Assets)','Application of Funds (Assets)','Group','No','','Debit',self.doc.name,''],
['Temporary Account (Assets)','Temporary Accounts (Assets)','Ledger','No','','Debit',self.doc.name,''],
['Expenses','','Group','Yes','Expense Account','Debit',self.doc.name,''],
['Direct Expenses','Expenses','Group','Yes','Expense Account','Debit',self.doc.name,''],
['Stock Expenses','Direct Expenses','Group','Yes','Expense Account','Debit',self.doc.name,''],
['Cost of Goods Sold','Stock Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Stock Adjustment','Stock Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Expenses Included In Valuation', "Stock Expenses", 'Ledger', 'Yes', 'Expense Account', 'Debit', self.doc.name, ''],
['Indirect Expenses','Expenses','Group','Yes','Expense Account','Debit',self.doc.name,''],
['Advertising and Publicity','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
['Bad Debts Written Off','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Bank Charges','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Books and Periodicals','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Charity and Donations','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Commission on Sales','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Conveyance Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Customer Entertainment Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Depreciation Account','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Freight and Forwarding Charges','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
['Legal Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Miscellaneous Expenses','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
['Office Maintenance Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Office Rent','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Postal Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Print and Stationary','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Rounded Off','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Salary','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Sales Promotion Expenses','Indirect Expenses','Ledger','Yes','Chargeable','Debit',self.doc.name,''],
['Service Charges Paid','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Staff Welfare Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Telephone Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Travelling Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Water and Electricity Expenses','Indirect Expenses','Ledger','Yes','Expense Account','Debit',self.doc.name,''],
['Income','','Group','Yes','','Credit',self.doc.name,''],
['Direct Income','Income','Group','Yes','Income Account','Credit',self.doc.name,''],
['Sales','Direct Income','Ledger','Yes','Income Account','Credit',self.doc.name,''],
['Service','Direct Income','Ledger','Yes','Income Account','Credit',self.doc.name,''],
['Indirect Income','Income','Group','Yes','Income Account','Credit',self.doc.name,''],
['Source of Funds (Liabilities)','','Group','No','','Credit',self.doc.name,''],
['Capital Account','Source of Funds (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Reserves and Surplus','Capital Account','Ledger','No','','Credit',self.doc.name,''],
['Shareholders Funds','Capital Account','Ledger','No','','Credit',self.doc.name,''],
['Current Liabilities','Source of Funds (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Accounts Payable','Current Liabilities','Group','No','','Credit',self.doc.name,''],
['Stock Liabilities','Current Liabilities','Group','No','','Credit',self.doc.name,''],
['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 Account','Asset',self.doc.name,''],
['Computers','Fixed Assets','Ledger','No','Fixed Asset Account','Asset',self.doc.name,''],
['Furniture and Fixture','Fixed Assets','Ledger','No','Fixed Asset Account','Asset',self.doc.name,''],
['Office Equipments','Fixed Assets','Ledger','No','Fixed Asset Account','Asset',self.doc.name,''],
['Plant and Machinery','Fixed Assets','Ledger','No','Fixed Asset Account','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', '', 'Credit', self.doc.name, ''],
['Duties and Taxes','Current Liabilities','Group','No','','Credit',self.doc.name,''],
['Loans (Liabilities)','Current Liabilities','Group','No','','Credit',self.doc.name,''],
['Secured Loans','Loans (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Unsecured Loans','Loans (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Bank Overdraft Account','Loans (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Temporary Accounts (Liabilities)','Source of Funds (Liabilities)','Group','No','','Credit',self.doc.name,''],
['Temporary Account (Liabilities)','Temporary Accounts (Liabilities)','Ledger','No','','Credit',self.doc.name,'']
'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,'']
]
acc_list_india = [
['CENVAT Capital Goods','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['CENVAT','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['CENVAT Service Tax','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['CENVAT Service Tax Cess 1','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['CENVAT Service Tax Cess 2','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['CENVAT Edu Cess','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['CENVAT SHE Cess','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['Excise Duty 4','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'4.00'],
['Excise Duty 8','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'8.00'],
['Excise Duty 10','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'10.00'],
['Excise Duty 14','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'14.00'],
['Excise Duty Edu Cess 2','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'2.00'],
['Excise Duty SHE Cess 1','Tax Assets','Ledger','No','Tax','Debit',self.doc.name,'1.00'],
['P L A','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['P L A - Cess Portion','Tax Assets','Ledger','No','Chargeable','Debit',self.doc.name,''],
['Edu. Cess on Excise','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'2.00'],
['Edu. Cess on Service Tax','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'2.00'],
['Edu. Cess on TDS','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'2.00'],
['Excise Duty @ 4','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'4.00'],
['Excise Duty @ 8','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'8.00'],
['Excise Duty @ 10','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'10.00'],
['Excise Duty @ 14','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'14.00'],
['Service Tax','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'10.3'],
['SHE Cess on Excise','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'1.00'],
['SHE Cess on Service Tax','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'1.00'],
['SHE Cess on TDS','Duties and Taxes','Ledger','No','Tax','Credit',self.doc.name,'1.00'],
['Professional Tax','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
['VAT','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
['TDS (Advertisement)','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
['TDS (Commission)','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
['TDS (Contractor)','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
['TDS (Interest)','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
['TDS (Rent)','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,''],
['TDS (Salary)','Duties and Taxes','Ledger','No','Chargeable','Credit',self.doc.name,'']
['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,'']
]
# load common account heads
for d in acc_list_common:

View File

@ -177,8 +177,7 @@ class DocType(DocListController):
def get_income(self, from_date=None, label=None):
# account is PL Account and Credit type account
accounts = [a["name"] for a in self.get_accounts()
if a["is_pl_account"]=="Yes" and a["debit_or_credit"]=="Credit"]
accounts = [a["name"] for a in self.get_accounts() if a["root_type"]=="Income"]
income = 0
for gle in self.get_gl_entries(from_date or self.from_date, self.to_date):
@ -190,8 +189,7 @@ class DocType(DocListController):
def get_expenses_booked(self):
# account is PL Account and Debit type account
accounts = [a["name"] for a in self.get_accounts()
if a["is_pl_account"]=="Yes" and a["debit_or_credit"]=="Debit"]
accounts = [a["name"] for a in self.get_accounts() if a["root_type"]=="Expense"]
expense = 0
for gle in self.get_gl_entries(self.from_date, self.to_date):
@ -392,7 +390,7 @@ class DocType(DocListController):
def get_accounts(self):
if not hasattr(self, "accounts"):
self.accounts = frappe.db.sql("""select name, is_pl_account,
debit_or_credit, account_type, account_name, master_type
root_type, account_type, account_name, master_type
from `tabAccount` where company=%s and docstatus < 2
and group_or_ledger = "Ledger" order by lft""",
(self.doc.company,), as_dict=1)

View File

@ -18,7 +18,7 @@ data_map = {
# Accounts
"Account": {
"columns": ["name", "parent_account", "lft", "rgt", "debit_or_credit",
"columns": ["name", "parent_account", "lft", "rgt", "root_type",
"is_pl_account", "company", "group_or_ledger"],
"conditions": ["docstatus < 2"],
"order_by": "lft",

View File

@ -218,7 +218,7 @@ if (sys_defaults.auto_accounting_for_stock) {
return {
filters: {
"is_pl_account": "Yes",
"debit_or_credit": "Debit",
"root_type": "Expense",
"company": doc.company,
"group_or_ledger": "Ledger"
}

View File

@ -55,7 +55,7 @@ cur_frm.fields_dict['default_bom'].get_query = function(doc) {
cur_frm.fields_dict['expense_account'].get_query = function(doc) {
return {
filters: {
'debit_or_credit': "Debit",
'root_type': "Expense",
'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: {
'debit_or_credit': "Credit",
'root_type': "Income",
'group_or_ledger': "Ledger",
'account_type': "Income Account"
}

View File

@ -25,8 +25,6 @@ erpnext.stock.LandedCostWizard = erpnext.stock.StockController.extend({
filters:[
['Account', 'group_or_ledger', '=', 'Ledger'],
['Account', 'account_type', 'in', 'Tax, Chargeable'],
['Account', 'is_pl_account', '=', 'Yes'],
['Account', 'debit_or_credit', '=', 'Debit'],
['Account', 'company', '=', me.frm.doc.company]
]
}

View File

@ -8,6 +8,16 @@ cur_frm.cscript.fname = "indent_details";
{% include 'utilities/doctype/sms_control/sms_control.js' %}
erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.extend({
onload: function(doc) {
this._super();
this.frm.set_query("item_code", this.frm.cscript.fname, function() {
return {
query: "erpnext.controllers.queries.item_query",
filters: {'is_stock_item': 'Yes'}
}
});
},
refresh: function(doc) {
this._super();

View File

@ -9,7 +9,6 @@ cur_frm.set_query("create_account_under", function() {
return {
filters: {
"company": cur_frm.doc.company,
"debit_or_credit": "Debit",
'group_or_ledger': "Group"
}
}