fix: handle division by zero error (backport #45966) (#46015)

fix: handle division by zero error (#45966)

Co-authored-by: Sanket322 <shahsanket322003.com>
(cherry picked from commit 24394765a6)

Co-authored-by: Sanket Shah <113279972+Sanket322@users.noreply.github.com>
This commit is contained in:
mergify[bot]
2025-02-19 16:51:09 +05:30
committed by GitHub
parent 452e4dcbad
commit 15106b49b6

View File

@@ -5,7 +5,7 @@
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import comma_or, flt, get_link_to_form, getdate, now, nowdate
from frappe.utils import comma_or, flt, get_link_to_form, getdate, now, nowdate, safe_div
class OverAllowanceError(frappe.ValidationError):
@@ -543,7 +543,7 @@ class StatusUpdater(Document):
)[0][0]
)
per_billed = (min(ref_doc_qty, billed_qty) / ref_doc_qty) * 100
per_billed = safe_div(min(ref_doc_qty, billed_qty), ref_doc_qty) * 100
ref_doc = frappe.get_doc(ref_dt, ref_dn)