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: incorrect valuation rate for PI based revaluation (backport #45207) #45218

Merged
Merged
Changes from all commits
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
10 changes: 9 additions & 1 deletion erpnext/stock/stock_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,14 +1039,22 @@ def validate_negative_stock(self, sle):

def get_dynamic_incoming_outgoing_rate(self, sle):
# Get updated incoming/outgoing rate from transaction
if sle.recalculate_rate:
if sle.recalculate_rate or self.has_landed_cost_based_on_pi(sle):
rate = self.get_incoming_outgoing_rate_from_transaction(sle)

if flt(sle.actual_qty) >= 0:
sle.incoming_rate = rate
else:
sle.outgoing_rate = rate

def has_landed_cost_based_on_pi(self, sle):
if sle.voucher_type == "Purchase Receipt" and frappe.db.get_single_value(
"Buying Settings", "set_landed_cost_based_on_purchase_invoice_rate"
):
return True

return False

def get_incoming_outgoing_rate_from_transaction(self, sle):
rate = 0
# Material Transfer, Repack, Manufacturing
Expand Down
Loading