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