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:
|
||||
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:
|
||||
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"))
|
||||
item.db_set("amount_difference_with_purchase_invoice", adjusted_amt, update_modified=False)
|
||||
elif item.billed_amt > item.amount:
|
||||
per_over_billed = (flt(item.billed_amt / item.amount, 2) * 100) - 100
|
||||
elif item.billed_amt > amount:
|
||||
per_over_billed = (flt(item.billed_amt / amount, 2) * 100) - 100
|
||||
if per_over_billed > over_billing_allowance:
|
||||
frappe.throw(
|
||||
_("Over Billing Allowance exceeded for Purchase Receipt Item {0} ({1}) by {2}%").format(
|
||||
|
||||
Reference in New Issue
Block a user