[fix] [minor] Negative outstanding validation for JV against JV

This commit is contained in:
Nabin Hait 2013-12-12 12:50:42 +05:30
parent 9d835a039a
commit 13fc64d732

View File

@ -5,8 +5,7 @@ from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils import flt, fmt_money, getdate from webnotes.utils import flt, fmt_money, getdate
from webnotes.model.code import get_obj from webnotes import _
from webnotes import msgprint, _
class DocType: class DocType:
def __init__(self,d,dl): def __init__(self,d,dl):
@ -130,11 +129,12 @@ def update_outstanding_amt(account, against_voucher_type, against_voucher, on_ca
against_voucher_amount = flt(webnotes.conn.sql(""" against_voucher_amount = flt(webnotes.conn.sql("""
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s
and account = %s""", (against_voucher, account))[0][0]) and account = %s and ifnull(against_voucher, '') = ''""",
(against_voucher, account))[0][0])
bal = against_voucher_amount + bal bal = against_voucher_amount + bal
if against_voucher_amount < 0: if against_voucher_amount < 0:
bal = -bal bal = -bal
# Validation : Outstanding can not be negative # Validation : Outstanding can not be negative
if bal < 0 and not on_cancel: if bal < 0 and not on_cancel:
webnotes.throw(_("Outstanding for Voucher ") + against_voucher + _(" will become ") + webnotes.throw(_("Outstanding for Voucher ") + against_voucher + _(" will become ") +
@ -158,4 +158,4 @@ def validate_frozen_account(account, adv_adj):
elif frozen_accounts_modifier not in webnotes.user.get_roles(): elif frozen_accounts_modifier not in webnotes.user.get_roles():
webnotes.throw(account + _(" is a frozen account. ") + webnotes.throw(account + _(" is a frozen account. ") +
_("To create / edit transactions against this account, you need role") + ": " + _("To create / edit transactions against this account, you need role") + ": " +
frozen_accounts_modifier) frozen_accounts_modifier)