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: backport asset value through landed cost voucher #43039

Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: improve asset item matching logic
  • Loading branch information
khushi8112 committed Sep 5, 2024
commit 3bb186736d8adbf83cdb1d75bb4f5f9db8af8532
11 changes: 8 additions & 3 deletions erpnext/patches/v15_0/link_purchase_item_to_asset_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,21 @@ def get_linked_item(doctype, parent, item_code, amount, quantity):
"parent": parent,
"item_code": item_code,
},
fields=["name", "amount", "qty", "landed_cost_voucher_amount"],
fields=["name", "rate", "amount", "qty", "landed_cost_voucher_amount"],
)
if len(items) == 1:
# If only one item exists, return it directly
return items[0].name

for item in items:
landed_cost = item.get("landed_cost_voucher_amount", 0)
if item.amount + landed_cost == amount and item.qty == quantity:
return item.name
# Check if the asset is grouped
if quantity > 1:
if item.amount + landed_cost == amount and item.qty == quantity:
return item.name
else:
if item.rate + landed_cost == amount:
return item.name

# If no exact match, return None
return None