perf: extract loop invariant db calls
This commit is contained in:
parent
4f7af79c31
commit
648b2d72a5
@ -980,6 +980,9 @@ class AccountsController(TransactionBase):
|
|||||||
item_allowance = {}
|
item_allowance = {}
|
||||||
global_qty_allowance, global_amount_allowance = None, None
|
global_qty_allowance, global_amount_allowance = None, None
|
||||||
|
|
||||||
|
role_allowed_to_over_bill = frappe.db.get_single_value('Accounts Settings', 'role_allowed_to_over_bill')
|
||||||
|
user_roles = frappe.get_roles()
|
||||||
|
|
||||||
for item in self.get("items"):
|
for item in self.get("items"):
|
||||||
if item.get(item_ref_dn):
|
if item.get(item_ref_dn):
|
||||||
ref_amt = flt(frappe.db.get_value(ref_dt + " Item",
|
ref_amt = flt(frappe.db.get_value(ref_dt + " Item",
|
||||||
@ -1009,9 +1012,7 @@ class AccountsController(TransactionBase):
|
|||||||
total_billed_amt = abs(total_billed_amt)
|
total_billed_amt = abs(total_billed_amt)
|
||||||
max_allowed_amt = abs(max_allowed_amt)
|
max_allowed_amt = abs(max_allowed_amt)
|
||||||
|
|
||||||
role_allowed_to_over_bill = frappe.db.get_single_value('Accounts Settings', 'role_allowed_to_over_bill')
|
if total_billed_amt - max_allowed_amt > 0.01 and role_allowed_to_over_bill not in user_roles:
|
||||||
|
|
||||||
if total_billed_amt - max_allowed_amt > 0.01 and role_allowed_to_over_bill not in frappe.get_roles():
|
|
||||||
if self.doctype != "Purchase Invoice":
|
if self.doctype != "Purchase Invoice":
|
||||||
self.throw_overbill_exception(item, max_allowed_amt)
|
self.throw_overbill_exception(item, max_allowed_amt)
|
||||||
elif not cint(frappe.db.get_single_value("Buying Settings", "bill_for_rejected_quantity_in_purchase_invoice")):
|
elif not cint(frappe.db.get_single_value("Buying Settings", "bill_for_rejected_quantity_in_purchase_invoice")):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user