diff --git a/erpnext/accounts/doctype/account/test_account.py b/erpnext/accounts/doctype/account/test_account.py index 79b249fd1af1a848de2fd6b007278873ac8c7da9..cd10f646d10c76203bd8abf7dc22c1861d5cd60b 100644 --- a/erpnext/accounts/doctype/account/test_account.py +++ b/erpnext/accounts/doctype/account/test_account.py @@ -4,6 +4,7 @@ import frappe from frappe.test_runner import make_test_records from frappe.tests.utils import FrappeTestCase +from frappe.utils import nowdate from erpnext.accounts.doctype.account.account import ( InvalidAccountMergeError, @@ -321,6 +322,19 @@ class TestAccount(FrappeTestCase): acc.account_currency = "USD" self.assertRaises(frappe.ValidationError, acc.save) + def test_account_balance(self): + from erpnext.accounts.utils import get_balance_on + + if not frappe.db.exists("Account", "Test Percent Account %5 - _TC"): + acc = frappe.new_doc("Account") + acc.account_name = "Test Percent Account %5" + acc.parent_account = "Tax Assets - _TC" + acc.company = "_Test Company" + acc.insert() + + balance = get_balance_on(account="Test Percent Account %5 - _TC", date=nowdate()) + self.assertEqual(balance, 0) + def _make_test_records(verbose=None): from frappe.test_runner import make_test_objects diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index fbb4917c4ce71e85e0c0df80938acf0a06fef604..58c2d3073b04eb05a359d58347da2787895e04bc 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -243,7 +243,7 @@ def get_balance_on( ) else: - cond.append("""gle.cost_center = %s """ % (frappe.db.escape(cost_center, percent=False),)) + cond.append("""gle.cost_center = %s """ % (frappe.db.escape(cost_center),)) if account: if not (frappe.flags.ignore_account_permission or ignore_account_permission): @@ -264,7 +264,7 @@ def get_balance_on( if acc.account_currency == frappe.get_cached_value("Company", acc.company, "default_currency"): in_account_currency = False else: - cond.append("""gle.account = %s """ % (frappe.db.escape(account, percent=False),)) + cond.append("""gle.account = %s """ % (frappe.db.escape(account),)) if account_type: accounts = frappe.db.get_all( @@ -284,11 +284,11 @@ def get_balance_on( if party_type and party: cond.append( """gle.party_type = %s and gle.party = %s """ - % (frappe.db.escape(party_type), frappe.db.escape(party, percent=False)) + % (frappe.db.escape(party_type), frappe.db.escape(party)) ) if company: - cond.append("""gle.company = %s """ % (frappe.db.escape(company, percent=False))) + cond.append("""gle.company = %s """ % (frappe.db.escape(company))) if account or (party_type and party) or account_type: precision = get_currency_precision() @@ -354,7 +354,7 @@ def get_count_on(account, fieldname, date): % (acc.lft, acc.rgt) ) else: - cond.append("""gle.account = %s """ % (frappe.db.escape(account, percent=False),)) + cond.append("""gle.account = %s """ % (frappe.db.escape(account),)) entries = frappe.db.sql( """