[fix] [minor] Negative outstanding validation for JV against JV
diff --git a/accounts/doctype/gl_entry/gl_entry.py b/accounts/doctype/gl_entry/gl_entry.py
index 3a0b28c..d3c6317 100644
--- a/accounts/doctype/gl_entry/gl_entry.py
+++ b/accounts/doctype/gl_entry/gl_entry.py
@@ -5,8 +5,7 @@
import webnotes
from webnotes.utils import flt, fmt_money, getdate
-from webnotes.model.code import get_obj
-from webnotes import msgprint, _
+from webnotes import _
class DocType:
def __init__(self,d,dl):
@@ -130,11 +129,12 @@
against_voucher_amount = flt(webnotes.conn.sql("""
select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0))
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
if against_voucher_amount < 0:
bal = -bal
-
+
# Validation : Outstanding can not be negative
if bal < 0 and not on_cancel:
webnotes.throw(_("Outstanding for Voucher ") + against_voucher + _(" will become ") +
@@ -158,4 +158,4 @@
elif frozen_accounts_modifier not in webnotes.user.get_roles():
webnotes.throw(account + _(" is a frozen account. ") +
_("To create / edit transactions against this account, you need role") + ": " +
- frozen_accounts_modifier)
+ frozen_accounts_modifier)
\ No newline at end of file