[fix] Get Balance only if account or party mentioned

This commit is contained in:
Nabin Hait
2015-08-17 11:27:00 +05:30
parent 862c36832a
commit dc76823a81

View File

@@ -101,13 +101,14 @@ def get_balance_on(account=None, date=None, party_type=None, party=None):
cond.append("""gle.party_type = "%s" and gle.party = "%s" """ % cond.append("""gle.party_type = "%s" and gle.party = "%s" """ %
(party_type.replace('"', '\\"'), party.replace('"', '\\"'))) (party_type.replace('"', '\\"'), party.replace('"', '\\"')))
bal = frappe.db.sql(""" if account or (party_type and party):
SELECT sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) bal = frappe.db.sql("""
FROM `tabGL Entry` gle SELECT sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
WHERE %s""" % " and ".join(cond))[0][0] FROM `tabGL Entry` gle
WHERE %s""" % " and ".join(cond))[0][0]
# if bal is None, return 0 # if bal is None, return 0
return flt(bal) return flt(bal)
@frappe.whitelist() @frappe.whitelist()
def add_ac(args=None): def add_ac(args=None):