[cleanup] [accounts] delete gl entries on cancellation of accounting transactions

This commit is contained in:
Nabin Hait
2013-08-21 17:47:11 +05:30
parent 4af17a88b0
commit 9b09c95d83
19 changed files with 156 additions and 180 deletions

View File

@@ -98,9 +98,7 @@ class DocType:
# Check if any previous balance exists
def check_gle_exists(self):
exists = sql("""select name from `tabGL Entry` where account = %s
and ifnull(is_cancelled, 'No') = 'No'""", self.doc.name)
return exists and exists[0][0] or ''
return webnotes.conn.get_value("GL Entry", {"account": self.doc.name})
def check_if_child_exists(self):
return sql("""select name from `tabAccount` where parent_account = %s
@@ -173,10 +171,6 @@ class DocType:
self.validate_trash()
self.update_nsm_model()
# delete all cancelled gl entry of this account
sql("""delete from `tabGL Entry` where account = %s and
ifnull(is_cancelled, 'No') = 'Yes'""", self.doc.name)
def on_rename(self, new, old, merge=False):
company_abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
parts = new.split(" - ")

View File

@@ -19,6 +19,8 @@ def make_test_records(verbose):
["_Test Account Tax Assets", "Current Assets - _TC", "Group"],
["_Test Account VAT", "_Test Account Tax Assets - _TC", "Ledger"],
["_Test Account Service Tax", "_Test Account Tax Assets - _TC", "Ledger"],
["_Test Account Reserves and Surplus", "Current Liabilities - _TC", "Ledger"],
["_Test Account Cost for Goods Sold", "Expenses - _TC", "Ledger"],
["_Test Account Excise Duty", "_Test Account Tax Assets - _TC", "Ledger"],