Merge pull request #53060 from frappe/mergify/bp/version-15-hotfix/pr-53057

fix: allow allowed roles to bypass over billing validation (backport #53057)
This commit is contained in:
Mihir Kandoi
2026-03-01 20:43:16 +05:30
committed by GitHub

View File

@@ -1127,6 +1127,7 @@ def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate
# Update Billing % based on pending accepted qty
buying_settings = frappe.get_single("Buying Settings")
over_billing_allowance = frappe.db.get_single_value("Accounts Settings", "over_billing_allowance")
role_allowed_to_over_bill = frappe.db.get_single_value("Accounts Settings", "role_allowed_to_over_bill")
total_amount, total_billed_amount, pi_landed_cost_amount = 0, 0, 0
item_wise_returned_qty = get_item_wise_returned_qty(pr_doc)
@@ -1172,7 +1173,10 @@ def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate
item.db_set("amount_difference_with_purchase_invoice", adjusted_amt, update_modified=False)
elif amount and item.billed_amt > amount:
per_over_billed = (flt(item.billed_amt / amount, 2) * 100) - 100
if per_over_billed > over_billing_allowance:
if (
per_over_billed > over_billing_allowance
and role_allowed_to_over_bill not in frappe.get_roles()
):
frappe.throw(
_("Over Billing Allowance exceeded for Purchase Receipt Item {0} ({1}) by {2}%").format(
item.name, frappe.bold(item.item_code), per_over_billed - over_billing_allowance