Merge pull request #1287 from nabinhait/hotfix
Fixes in overbilling validation against DN/PR
This commit is contained in:
commit
1e42a3d028
@ -387,35 +387,38 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
for item in self.doclist.get({"parentfield": "entries"}):
|
for item in self.doclist.get({"parentfield": "entries"}):
|
||||||
if item.fields.get(item_ref_dn):
|
if item.fields.get(item_ref_dn):
|
||||||
already_billed = webnotes.conn.sql("""select sum(%s) from `tab%s`
|
|
||||||
where %s=%s and docstatus=1 and parent != %s""" %
|
|
||||||
(based_on, self.tname, item_ref_dn, '%s', '%s'),
|
|
||||||
(item.fields[item_ref_dn], self.doc.name))[0][0]
|
|
||||||
|
|
||||||
total_billed_amt = flt(flt(already_billed) + flt(item.fields[based_on]),
|
|
||||||
self.precision(based_on, item))
|
|
||||||
|
|
||||||
ref_amt = flt(webnotes.conn.get_value(ref_dt + " Item",
|
ref_amt = flt(webnotes.conn.get_value(ref_dt + " Item",
|
||||||
item.fields[item_ref_dn], based_on), self.precision(based_on, item))
|
item.fields[item_ref_dn], based_on), self.precision(based_on, item))
|
||||||
|
if not ref_amt:
|
||||||
|
webnotes.msgprint(_("As amount for item") + ": " + item.item_code + _(" in ") +
|
||||||
|
ref_dt + _(" is zero, system will not check for over-billed"))
|
||||||
|
else:
|
||||||
|
already_billed = webnotes.conn.sql("""select sum(%s) from `tab%s`
|
||||||
|
where %s=%s and docstatus=1 and parent != %s""" %
|
||||||
|
(based_on, self.tname, item_ref_dn, '%s', '%s'),
|
||||||
|
(item.fields[item_ref_dn], self.doc.name))[0][0]
|
||||||
|
|
||||||
tolerance, item_tolerance, global_tolerance = get_tolerance_for(item.item_code,
|
total_billed_amt = flt(flt(already_billed) + flt(item.fields[based_on]),
|
||||||
item_tolerance, global_tolerance)
|
self.precision(based_on, item))
|
||||||
|
|
||||||
max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100)
|
|
||||||
|
|
||||||
if total_billed_amt - max_allowed_amt > 0.01:
|
tolerance, item_tolerance, global_tolerance = get_tolerance_for(item.item_code,
|
||||||
reduce_by = total_billed_amt - max_allowed_amt
|
item_tolerance, global_tolerance)
|
||||||
|
|
||||||
webnotes.throw(_("Row #") + cstr(item.idx) + ": " +
|
max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100)
|
||||||
_(" Max amount allowed for Item ") + cstr(item.item_code) +
|
|
||||||
_(" against ") + ref_dt + " " +
|
if total_billed_amt - max_allowed_amt > 0.01:
|
||||||
cstr(item.fields[ref_dt.lower().replace(" ", "_")]) + _(" is ") +
|
reduce_by = total_billed_amt - max_allowed_amt
|
||||||
cstr(max_allowed_amt) + ". \n" +
|
|
||||||
_("""If you want to increase your overflow tolerance, please increase \
|
webnotes.throw(_("Row #") + cstr(item.idx) + ": " +
|
||||||
tolerance % in Global Defaults or Item master.
|
_(" Max amount allowed for Item ") + cstr(item.item_code) +
|
||||||
Or, you must reduce the amount by """) + cstr(reduce_by) + "\n" +
|
_(" against ") + ref_dt + " " +
|
||||||
_("""Also, please check if the order item has already been billed \
|
cstr(item.fields[ref_dt.lower().replace(" ", "_")]) + _(" is ") +
|
||||||
in the Sales Order"""))
|
cstr(max_allowed_amt) + ". \n" +
|
||||||
|
_("""If you want to increase your overflow tolerance, please increase \
|
||||||
|
tolerance % in Global Defaults or Item master.
|
||||||
|
Or, you must reduce the amount by """) + cstr(reduce_by) + "\n" +
|
||||||
|
_("""Also, please check if the order item has already been billed \
|
||||||
|
in the Sales Order"""))
|
||||||
|
|
||||||
def get_company_default(self, fieldname):
|
def get_company_default(self, fieldname):
|
||||||
from accounts.utils import get_company_default
|
from accounts.utils import get_company_default
|
||||||
|
Loading…
x
Reference in New Issue
Block a user