fix: incoming rate for the stand-alone credit note

(cherry picked from commit b06eca8dcb)

# Conflicts:
#	erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
This commit is contained in:
Rohit Waghchaure
2025-06-23 14:28:28 +05:30
committed by Mergify
parent 78013d3d8f
commit ad40bfe4ea
3 changed files with 130 additions and 0 deletions

View File

@@ -680,6 +680,14 @@ def get_rate_for_return(
raise_error_if_no_rate=False,
)
if not rate and voucher_type in ["Sales Invoice", "Delivery Note"]:
details = frappe.db.get_value(
voucher_type + " Item", voucher_detail_no, ["rate", "allow_zero_valuation_rate"], as_dict=1
)
if details and not details.allow_zero_valuation_rate:
rate = flt(details.rate)
return rate

View File

@@ -525,6 +525,15 @@ class SellingController(StockController):
self.doctype, self.name, d.item_code, self.return_against, item_row=d
)
if (
self.get("is_return")
and not d.incoming_rate
and not self.get("return_against")
and not self.is_internal_transfer()
and not d.get("allow_zero_valuation_rate")
):
d.incoming_rate = d.rate
# For internal transfers use incoming rate as the valuation rate
if self.is_internal_transfer():
if self.doctype == "Delivery Note" or self.get("update_stock"):