fix: landed cost voucher not submitting because of incorrect reference (#39898)
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index fb68010..27ac9d5 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -217,8 +217,8 @@
lc_voucher_data = frappe.db.sql(
"""select sum(applicable_charges), cost_center
from `tabLanded Cost Item`
- where docstatus = 1 and purchase_receipt_item = %s""",
- d.name,
+ where docstatus = 1 and purchase_receipt_item = %s and receipt_document = %s""",
+ (d.name, self.name),
)
d.landed_cost_voucher_amount = lc_voucher_data[0][0] if lc_voucher_data else 0.0
if not d.cost_center and lc_voucher_data and lc_voucher_data[0][1]: