Skip to content

Commit

Permalink
fix: correct amt in account currency for lcv with manually distribute…
Browse files Browse the repository at this point in the history
…d charges. (backport #45532) (#45863)

fix: correct amt in account currency for lcv with manually distributed charges.

(cherry picked from commit db38e7b)

Co-authored-by: ljain112 <ljain112@gmail.com>
  • Loading branch information
mergify[bot] and ljain112 authored Feb 11, 2025
1 parent 08ba775 commit c61e4e2
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,26 +1165,25 @@ def get_item_account_wise_additional_cost(purchase_document):
for item in landed_cost_voucher_doc.items:
if item.receipt_document == purchase_document:
for account in landed_cost_voucher_doc.taxes:
exchange_rate = account.exchange_rate or 1
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, {"amount": 0.0, "base_amount": 0.0}
)

item_row = item_account_wise_cost[(item.item_code, item.purchase_receipt_item)][
account.expense_account
]

if total_item_cost > 0:
item_account_wise_cost[(item.item_code, item.purchase_receipt_item)][
account.expense_account
]["amount"] += account.amount * item.get(based_on_field) / total_item_cost
item_row["amount"] += account.amount * item.get(based_on_field) / total_item_cost

item_account_wise_cost[(item.item_code, item.purchase_receipt_item)][
account.expense_account
]["base_amount"] += account.base_amount * item.get(based_on_field) / total_item_cost
item_row["base_amount"] += (
account.base_amount * item.get(based_on_field) / total_item_cost
)
else:
item_account_wise_cost[(item.item_code, item.purchase_receipt_item)][
account.expense_account
]["amount"] += item.applicable_charges
item_account_wise_cost[(item.item_code, item.purchase_receipt_item)][
account.expense_account
]["base_amount"] += item.applicable_charges
item_row["amount"] += item.applicable_charges / exchange_rate
item_row["base_amount"] += item.applicable_charges

return item_account_wise_cost

Expand Down

0 comments on commit c61e4e2

Please sign in to comment.