refactor: add guard clause in for loop

Reduce overly indented code/improve readability.
This commit is contained in:
Ankush Menat 2021-09-20 16:36:27 +05:30
parent 43bf82b58b
commit 5e4fbba753
No known key found for this signature in database
GPG Key ID: 8EA82E09BBD13AAF

View File

@ -986,14 +986,17 @@ class AccountsController(TransactionBase):
total_overbilled_amt = 0.0 total_overbilled_amt = 0.0
for item in self.get("items"): for item in self.get("items"):
if item.get(item_ref_dn): if not item.get(item_ref_dn):
continue
ref_amt = flt(frappe.db.get_value(ref_dt + " Item", ref_amt = flt(frappe.db.get_value(ref_dt + " Item",
item.get(item_ref_dn), based_on), self.precision(based_on, item)) item.get(item_ref_dn), based_on), self.precision(based_on, item))
if not ref_amt: if not ref_amt:
frappe.msgprint( frappe.msgprint(
_("Warning: System will not check overbilling since amount for Item {0} in {1} is zero") _("Warning: System will not check overbilling since amount for Item {0} in {1} is zero")
.format(item.item_code, ref_dt)) .format(item.item_code, ref_dt))
else: continue
already_billed = frappe.db.sql(""" already_billed = frappe.db.sql("""
select sum(%s) select sum(%s)
from `tab%s` from `tab%s`