mirror of
https://github.com/frappe/erpnext.git
synced 2026-02-21 10:26:30 +00:00
fix: include rejected amount in PI/PR overbilling validation logic (#47572)
* fix: include rejected amount in PI/PR overbilling validation logic
* fix: add check if amount is 0
* fix: unneccessary condition
(cherry picked from commit 8d9888b1b6)
This commit is contained in:
@@ -1106,6 +1106,10 @@ def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate
|
|||||||
if pr_doc.get("is_return") and not total_amount and total_billed_amount:
|
if pr_doc.get("is_return") and not total_amount and total_billed_amount:
|
||||||
total_amount = total_billed_amount
|
total_amount = total_billed_amount
|
||||||
|
|
||||||
|
amount = item.amount
|
||||||
|
if frappe.db.get_single_value("Buying Settings", "bill_for_rejected_quantity_in_purchase_invoice"):
|
||||||
|
amount += flt(item.rejected_qty * item.rate, item.precision("amount"))
|
||||||
|
|
||||||
if adjust_incoming_rate:
|
if adjust_incoming_rate:
|
||||||
adjusted_amt = 0.0
|
adjusted_amt = 0.0
|
||||||
|
|
||||||
@@ -1120,8 +1124,8 @@ def update_billing_percentage(pr_doc, update_modified=True, adjust_incoming_rate
|
|||||||
|
|
||||||
adjusted_amt = flt(adjusted_amt * flt(pr_doc.conversion_rate), item.precision("amount"))
|
adjusted_amt = flt(adjusted_amt * flt(pr_doc.conversion_rate), item.precision("amount"))
|
||||||
item.db_set("amount_difference_with_purchase_invoice", adjusted_amt, update_modified=False)
|
item.db_set("amount_difference_with_purchase_invoice", adjusted_amt, update_modified=False)
|
||||||
elif item.billed_amt > item.amount:
|
elif item.billed_amt > amount:
|
||||||
per_over_billed = (flt(item.billed_amt / item.amount, 2) * 100) - 100
|
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:
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
_("Over Billing Allowance exceeded for Purchase Receipt Item {0} ({1}) by {2}%").format(
|
_("Over Billing Allowance exceeded for Purchase Receipt Item {0} ({1}) by {2}%").format(
|
||||||
|
|||||||
Reference in New Issue
Block a user