[fix] update future gl entries for stock

This commit is contained in:
Nabin Hait
2013-11-14 18:40:08 +05:30
parent 155232e04e
commit e83069cb32
9 changed files with 112 additions and 39 deletions

View File

@@ -5,6 +5,7 @@ from __future__ import unicode_literals
import webnotes
from webnotes import _, msgprint
from webnotes.utils import flt, cint, today, cstr
from webnotes.model.code import get_obj
from setup.utils import get_company_currency
from accounts.utils import get_fiscal_year, validate_fiscal_year
from utilities.transaction_base import TransactionBase, validate_conversion_rate
@@ -422,3 +423,12 @@ class AccountsController(TransactionBase):
self._abbr = webnotes.conn.get_value("Company", self.doc.company, "abbr")
return self._abbr
def check_credit_limit(self, account):
total_outstanding = webnotes.conn.sql("""
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
from `tabGL Entry` where account = %s""", account)
total_outstanding = flt(total_outstanding[0][0]) if total_outstanding else 0
if total_outstanding:
get_obj('Account', account).check_credit_limit(total_outstanding)