[Fix] 'To Bill' status even if the amount is zero (#14784)

* Fix 'To Bill' status even if the invoice amount is zero

* Modify fix to only apply on Delivery Note documents
This commit is contained in:
Alchez
2018-09-06 18:27:06 +05:30
committed by Nabin Hait
parent a2a6568b7e
commit e52ae4eacb
5 changed files with 32 additions and 31 deletions

View File

@@ -129,7 +129,7 @@ class StatusUpdater(Document):
self.status = s[0]
break
elif s[1].startswith("eval:"):
if frappe.safe_eval(s[1][5:], None, { "self": self.as_dict(), "getdate": getdate,
if frappe.safe_eval(s[1][5:], None, { "self": self.as_dict(), "getdate": getdate,
"nowdate": nowdate, "get_value": frappe.db.get_value }):
self.status = s[0]
break
@@ -256,7 +256,7 @@ class StatusUpdater(Document):
if args['detail_id']:
if not args.get("extra_cond"): args["extra_cond"] = ""
frappe.db.sql("""update `tab%(target_dt)s`
set %(target_field)s = (
(select ifnull(sum(%(source_field)s), 0)
@@ -281,7 +281,7 @@ class StatusUpdater(Document):
"""Update percent field in parent transaction"""
self._update_modified(args, update_modified)
if args.get('target_parent_field'):
frappe.db.sql("""update `tab%(target_parent_dt)s`
set %(target_parent_field)s = round(
@@ -335,8 +335,7 @@ class StatusUpdater(Document):
from `tab%s Item` where %s=%s and docstatus=1""" %
(self.doctype, ref_fieldname, '%s'), (ref_dn))[0][0])
per_billed = ((ref_doc_qty if billed_qty > ref_doc_qty else billed_qty)\
/ ref_doc_qty)*100
per_billed = (min(ref_doc_qty, billed_qty) / ref_doc_qty) * 100
ref_doc = frappe.get_doc(ref_dt, ref_dn)