fix: Allow creation of multiple landed cost voucher against a Purchase Document (#20058)
This commit is contained in:
parent
5af4c57ef7
commit
55bc26e300
@ -610,19 +610,28 @@ def make_stock_entry(source_name,target_doc=None):
|
||||
return doclist
|
||||
|
||||
def get_item_account_wise_additional_cost(purchase_document):
|
||||
landed_cost_voucher = frappe.get_value("Landed Cost Purchase Receipt",
|
||||
{"receipt_document": purchase_document, "docstatus": 1}, "parent")
|
||||
landed_cost_vouchers = frappe.get_all("Landed Cost Purchase Receipt", fields=["parent"],
|
||||
filters = {"receipt_document": purchase_document, "docstatus": 1})
|
||||
|
||||
if not landed_cost_voucher:
|
||||
if not landed_cost_vouchers:
|
||||
return
|
||||
|
||||
total_item_cost = 0
|
||||
item_account_wise_cost = {}
|
||||
landed_cost_voucher_doc = frappe.get_doc("Landed Cost Voucher", landed_cost_voucher)
|
||||
item_cost_allocated = []
|
||||
|
||||
for lcv in landed_cost_vouchers:
|
||||
landed_cost_voucher_doc = frappe.get_cached_doc("Landed Cost Voucher", lcv.parent)
|
||||
based_on_field = frappe.scrub(landed_cost_voucher_doc.distribute_charges_based_on)
|
||||
|
||||
for item in landed_cost_voucher_doc.items:
|
||||
if item.purchase_receipt_item not in item_cost_allocated:
|
||||
total_item_cost += item.get(based_on_field)
|
||||
item_cost_allocated.append(item.purchase_receipt_item)
|
||||
|
||||
for lcv in landed_cost_vouchers:
|
||||
landed_cost_voucher_doc = frappe.get_cached_doc("Landed Cost Voucher", lcv.parent)
|
||||
based_on_field = frappe.scrub(landed_cost_voucher_doc.distribute_charges_based_on)
|
||||
|
||||
for item in landed_cost_voucher_doc.items:
|
||||
if item.receipt_document == purchase_document:
|
||||
|
Loading…
x
Reference in New Issue
Block a user