fix: landed cost voucher not submitting because of incorrect reference (#39898) (cherry picked from commit 6239fd704b7d7a60c54b8042a8cc83b5c9e75eab) Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
parent
f08b424972
commit
a548f12941
@ -217,8 +217,8 @@ class BuyingController(SubcontractingController):
|
|||||||
lc_voucher_data = frappe.db.sql(
|
lc_voucher_data = frappe.db.sql(
|
||||||
"""select sum(applicable_charges), cost_center
|
"""select sum(applicable_charges), cost_center
|
||||||
from `tabLanded Cost Item`
|
from `tabLanded Cost Item`
|
||||||
where docstatus = 1 and purchase_receipt_item = %s""",
|
where docstatus = 1 and purchase_receipt_item = %s and receipt_document = %s""",
|
||||||
d.name,
|
(d.name, self.name),
|
||||||
)
|
)
|
||||||
d.landed_cost_voucher_amount = lc_voucher_data[0][0] if lc_voucher_data else 0.0
|
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]:
|
if not d.cost_center and lc_voucher_data and lc_voucher_data[0][1]:
|
||||||
|
@ -65,6 +65,7 @@ class LandedCostVoucher(Document):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.check_mandatory()
|
self.check_mandatory()
|
||||||
self.validate_receipt_documents()
|
self.validate_receipt_documents()
|
||||||
|
self.validate_line_items()
|
||||||
init_landed_taxes_and_totals(self)
|
init_landed_taxes_and_totals(self)
|
||||||
self.set_total_taxes_and_charges()
|
self.set_total_taxes_and_charges()
|
||||||
if not self.get("items"):
|
if not self.get("items"):
|
||||||
@ -72,6 +73,26 @@ class LandedCostVoucher(Document):
|
|||||||
|
|
||||||
self.set_applicable_charges_on_item()
|
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):
|
def check_mandatory(self):
|
||||||
if not self.get("purchase_receipts"):
|
if not self.get("purchase_receipts"):
|
||||||
frappe.throw(_("Please enter Receipt Document"))
|
frappe.throw(_("Please enter Receipt Document"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user