Fixes in general ledger report

This commit is contained in:
Nabin Hait 2013-12-24 11:58:05 +05:30
parent a3d058938e
commit 6a2edee914
2 changed files with 9 additions and 7 deletions

View File

@ -9,8 +9,9 @@ from accounts.utils import get_balance_on
def execute(filters=None): def execute(filters=None):
account_details = webnotes.conn.get_value("Account", filters["account"], account_details = webnotes.conn.get_value("Account", filters["account"],
["debit_or_credit", "group_or_ledger"], as_dict=True) ["debit_or_credit", "group_or_ledger"], as_dict=True) if filters.get("account") else None
validate_filters(filters, account_details.group_or_ledger) validate_filters(filters, account_details)
columns = get_columns() columns = get_columns()
data = [] data = []
if filters.get("group_by"): if filters.get("group_by"):
@ -20,14 +21,15 @@ def execute(filters=None):
if data: if data:
data.append(get_total_row(data)) data.append(get_total_row(data))
if filters.get("account"): if account_details:
data = [get_opening_balance_row(filters, account_details.debit_or_credit)] + data + \ data = [get_opening_balance_row(filters, account_details.debit_or_credit)] + data + \
[get_closing_balance_row(filters, account_details.debit_or_credit)] [get_closing_balance_row(filters, account_details.debit_or_credit)]
return columns, data return columns, data
def validate_filters(filters, group_or_ledger): def validate_filters(filters, account_details):
if group_or_ledger == "Ledger" and filters.get("group_by") == "Group by Account": if account_details and account_details.group_or_ledger == "Ledger" \
and filters.get("group_by") == "Group by Account":
webnotes.throw(_("Can not filter based on Account, if grouped by Account")) webnotes.throw(_("Can not filter based on Account, if grouped by Account"))
if filters.get("voucher_no") and filters.get("group_by") == "Group by Voucher": if filters.get("voucher_no") and filters.get("group_by") == "Group by Voucher":

View File

@ -2,7 +2,7 @@
{ {
"creation": "2012-12-20 12:50:49", "creation": "2012-12-20 12:50:49",
"docstatus": 0, "docstatus": 0,
"modified": "2013-11-03 14:20:18", "modified": "2013-12-24 11:40:19",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -90,7 +90,7 @@
"doctype": "DocField", "doctype": "DocField",
"fieldname": "fs_packing_details", "fieldname": "fs_packing_details",
"fieldtype": "Check", "fieldtype": "Check",
"label": "Packing Detials" "label": "Packing Details"
}, },
{ {
"description": "To get Item Group in details table", "description": "To get Item Group in details table",