Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: landed cost voucher not submitting because of incorrect reference #39898

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions erpnext/controllers/buying_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def set_landed_cost_voucher_amount(self):
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]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,34 @@ def get_items_from_purchase_receipts(self):
def validate(self):
self.check_mandatory()
self.validate_receipt_documents()
self.validate_line_items()
init_landed_taxes_and_totals(self)
self.set_total_taxes_and_charges()
if not self.get("items"):
self.get_items_from_purchase_receipts()

self.set_applicable_charges_on_item()

def validate_line_items(self):
for d in self.get("items"):
if (
d.docstatus == 0
and d.purchase_receipt_item
and not frappe.db.exists(
d.receipt_document_type + " Item",
{"name": d.purchase_receipt_item, "parent": d.receipt_document},
)
):
frappe.throw(
_("Row {0}: {2} Item {1} does not exist in {2} {3}").format(
d.idx,
frappe.bold(d.purchase_receipt_item),
d.receipt_document_type,
frappe.bold(d.receipt_document),
),
title=_("Incorrect Reference Document (Purchase Receipt Item)"),
)

def check_mandatory(self):
if not self.get("purchase_receipts"):
frappe.throw(_("Please enter Receipt Document"))
Expand Down
Loading