From 8e59fe90cc6d2af7f4b2e1c6e2d5a95444738719 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Sun, 1 Mar 2026 15:16:38 +0530 Subject: [PATCH] fix: allow allowed roles to bypass over billing validation (cherry picked from commit 04127019f9c4ea7776a85ef583118d1b283adbe8) # Conflicts: # erpnext/stock/doctype/purchase_receipt/purchase_receipt.py --- .../doctype/purchase_receipt/purchase_receipt.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py index fc3df50de80..358dbd1e86a 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py @@ -1126,7 +1126,13 @@ def get_billed_amount_against_po(po_items): def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate=False): # Update Billing % based on pending accepted qty buying_settings = frappe.get_single("Buying Settings") +<<<<<<< HEAD over_billing_allowance = frappe.db.get_single_value("Accounts Settings", "over_billing_allowance") +======= + over_billing_allowance, role_allowed_to_over_bill = frappe.get_single_value( + "Accounts Settings", ["over_billing_allowance", "role_allowed_to_over_bill"] + ) +>>>>>>> 04127019f9 (fix: allow allowed roles to bypass over billing validation) 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 +1178,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