fixed issue in reseting in opening balance, clear bal only that company
diff --git a/accounts/doctype/fiscal_year/fiscal_year.py b/accounts/doctype/fiscal_year/fiscal_year.py
index 48d7d91..74b90cc 100644
--- a/accounts/doctype/fiscal_year/fiscal_year.py
+++ b/accounts/doctype/fiscal_year/fiscal_year.py
@@ -21,34 +21,32 @@
def __init__(self, d, dl):
self.doc, self.doclist = d,dl
- def repost(self, account = ''):
+ def repost(self):
if not self.doc.company:
msgprint("Please select company", raise_exception=1)
if not in_transaction:
sql("start transaction")
- self.clear_account_balances(account)
- self.create_account_balances(account)
- self.update_opening(account)
- self.post_entries(account)
+ self.clear_account_balances()
+ self.create_account_balances()
+ self.update_opening()
+ self.post_entries()
sql("commit")
- msg_cond = account and " and account: " + account or ""
- msgprint("Account balance reposted for fiscal year: " + self.doc.name + msg_cond)
+ msgprint("Account balance reposted for fiscal year: " + self.doc.name)
- def clear_account_balances(self, account = ''):
+ def clear_account_balances(self):
# balances clear - `tabAccount Balance` for fiscal year
- cond = account and (" and account = '" + account + "'") or ''
- sql("update `tabAccount Balance` set opening=0, balance=0, debit=0, credit=0 where fiscal_year=%s %s", (self.doc.name, cond))
+ sql("update `tabAccount Balance` t1, tabAccount t2 set t1.opening=0, t1.balance=0, t1.debit=0, t1.credit=0 where t1.fiscal_year=%s and t2.company = %s and t1.account = t2.name", (self.doc.name, self.doc.company))
- def create_account_balances(self, account = ''):
+ def create_account_balances(self):
# get periods
period_list = self.get_period_list()
cnt = 0
# get accounts
- al = account and [[account]] or sql("select name from tabAccount")
+ al = sql("select name from tabAccount")
for a in al:
# check
@@ -83,14 +81,13 @@
return periods
# ====================================================================================
- def update_opening(self, account = ''):
+ def update_opening(self):
"""
set opening from last year closing
"""
- cond = account and (" and t2.name = '" + account + "'") or ''
- abl = sql("select t1.account, t1.balance from `tabAccount Balance` t1, tabAccount t2 where t1.period= '%s' and t2.company= '%s' and ifnull(t2.is_pl_account, 'No') = 'No' and t1.account = t2.name %s for update" % (self.doc.past_year, self.doc.company, cond))
+ abl = sql("select t1.account, t1.balance from `tabAccount Balance` t1, tabAccount t2 where t1.period= '%s' and t2.company= '%s' and ifnull(t2.is_pl_account, 'No') = 'No' and t1.account = t2.name for update" % (self.doc.past_year, self.doc.company))
cnt = 0
for ab in abl:
@@ -108,11 +105,10 @@
return sql("select debit_or_credit, lft, rgt, is_pl_account from tabAccount where name=%s", account)[0]
# ====================================================================================
- def post_entries(self, account = ''):
+ def post_entries(self):
sql("LOCK TABLE `tabGL Entry` WRITE")
- cond = account and (" and account = '" + account + "'") or ''
# post each gl entry (batch or complete)
- gle = sql("select name, account, debit, credit, is_opening, posting_date from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled,'No')='No' and company=%s %s", (self.doc.name, self.doc.company, cond))
+ gle = sql("select name, account, debit, credit, is_opening, posting_date from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled,'No')='No' and company=%s", (self.doc.name, self.doc.company))
account_details = {}
cnt = 0