From c3b17024bd8c024c91dbde578b979dc00de83b33 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Fri, 23 May 2025 08:25:35 +0530 Subject: [PATCH] fix: skip last purchase rate for free item (#47693) --- erpnext/buying/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/buying/utils.py b/erpnext/buying/utils.py index 259c262d0d7..54f00417a89 100644 --- a/erpnext/buying/utils.py +++ b/erpnext/buying/utils.py @@ -20,6 +20,9 @@ def update_last_purchase_rate(doc, is_submit) -> None: this_purchase_date = getdate(doc.get("posting_date") or doc.get("transaction_date")) for d in doc.get("items"): + if d.get("is_free_item"): + continue + # get last purchase details last_purchase_details = get_last_purchase_details(d.item_code, doc.name)