fixed issue in update_voucher_outstanding

This commit is contained in:
nabinhait 2011-07-05 14:25:47 +05:30
parent 985d8a217f
commit 4b2f35ed79

View File

@ -165,17 +165,15 @@ class DocType:
def update_voucher_outstanding(self): def update_voucher_outstanding(self):
# Clear outstanding # Clear outstanding
self.clear_outstanding() self.clear_outstanding()
sql("LOCK TABLE `tabGL Entry` WRITE") against_voucher = sql("select against_voucher, against_voucher_type from `tabGL Entry` where fiscal_year=%s and ifnull(is_cancelled, 'No')='No' and company=%s and ifnull(against_voucher, '') != '' and ifnull(against_voucher_type, '') != '' group by against_voucher, against_voucher_type", (self.doc.name, self.doc.company))
against_voucher = sql("select against_voucher, against_voucher_type from `tabGL Entry` where fiscal_year=%s and is_cancelled='No' and company=%s and ifnull(against_voucher, '') != '' and ifnull(against_voucher_type, '') != '' group by against_voucher, against_voucher_type", (self.doc.name, self.doc.company))
for d in against_voucher: for d in against_voucher:
# get voucher balance # get voucher balance
bal = sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s", (d[0], d[1])) bal = sql("select sum(debit)-sum(credit) from `tabGL Entry` where against_voucher=%s and against_voucher_type=%s and ifnull(is_cancelled, 'No') = 'No'", (d[0], d[1]))
bal = bal and flt(bal[0][0]) or 0.0 bal = bal and flt(bal[0][0]) or 0.0
if d[1] == 'Payable Voucher': if d[1] == 'Payable Voucher':
bal = -bal bal = -bal
# set voucher balance # set voucher balance
sql("update `tab%s` set outstanding_amount=%s where name='%s'"% (d[1], bal, d[0])) sql("update `tab%s` set outstanding_amount=%s where name='%s'"% (d[1], bal, d[0]))
sql("UNLOCK TABLES")
# ==================================================================================== # ====================================================================================
# Generate periods # Generate periods