fixed issue in reseting in opening balance, clear bal only that company
This commit is contained in:
parent
5c55e43234
commit
c752d075e6
@ -21,34 +21,32 @@ class DocType:
|
|||||||
def __init__(self, d, dl):
|
def __init__(self, d, dl):
|
||||||
self.doc, self.doclist = d,dl
|
self.doc, self.doclist = d,dl
|
||||||
|
|
||||||
def repost(self, account = ''):
|
def repost(self):
|
||||||
if not self.doc.company:
|
if not self.doc.company:
|
||||||
msgprint("Please select company", raise_exception=1)
|
msgprint("Please select company", raise_exception=1)
|
||||||
|
|
||||||
if not in_transaction:
|
if not in_transaction:
|
||||||
sql("start transaction")
|
sql("start transaction")
|
||||||
|
|
||||||
self.clear_account_balances(account)
|
self.clear_account_balances()
|
||||||
self.create_account_balances(account)
|
self.create_account_balances()
|
||||||
self.update_opening(account)
|
self.update_opening()
|
||||||
self.post_entries(account)
|
self.post_entries()
|
||||||
sql("commit")
|
sql("commit")
|
||||||
|
|
||||||
msg_cond = account and " and account: " + account or ""
|
msgprint("Account balance reposted for fiscal year: " + self.doc.name)
|
||||||
msgprint("Account balance reposted for fiscal year: " + self.doc.name + msg_cond)
|
|
||||||
|
|
||||||
def clear_account_balances(self, account = ''):
|
def clear_account_balances(self):
|
||||||
# balances clear - `tabAccount Balance` for fiscal year
|
# balances clear - `tabAccount Balance` for fiscal year
|
||||||
cond = account and (" and account = '" + account + "'") or ''
|
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))
|
||||||
sql("update `tabAccount Balance` set opening=0, balance=0, debit=0, credit=0 where fiscal_year=%s %s", (self.doc.name, cond))
|
|
||||||
|
|
||||||
def create_account_balances(self, account = ''):
|
def create_account_balances(self):
|
||||||
# get periods
|
# get periods
|
||||||
period_list = self.get_period_list()
|
period_list = self.get_period_list()
|
||||||
cnt = 0
|
cnt = 0
|
||||||
|
|
||||||
# get accounts
|
# get accounts
|
||||||
al = account and [[account]] or sql("select name from tabAccount")
|
al = sql("select name from tabAccount")
|
||||||
|
|
||||||
for a in al:
|
for a in al:
|
||||||
# check
|
# check
|
||||||
@ -83,14 +81,13 @@ class DocType:
|
|||||||
return periods
|
return periods
|
||||||
|
|
||||||
# ====================================================================================
|
# ====================================================================================
|
||||||
def update_opening(self, account = ''):
|
def update_opening(self):
|
||||||
"""
|
"""
|
||||||
set opening from last year closing
|
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
|
cnt = 0
|
||||||
for ab in abl:
|
for ab in abl:
|
||||||
@ -108,11 +105,10 @@ class DocType:
|
|||||||
return sql("select debit_or_credit, lft, rgt, is_pl_account from tabAccount where name=%s", account)[0]
|
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")
|
sql("LOCK TABLE `tabGL Entry` WRITE")
|
||||||
cond = account and (" and account = '" + account + "'") or ''
|
|
||||||
# post each gl entry (batch or complete)
|
# 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 = {}
|
account_details = {}
|
||||||
|
|
||||||
cnt = 0
|
cnt = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user