Skip to content

Commit

Permalink
Merge pull request #45207 from rohitwaghchaure/fixed-support-29140
Browse files Browse the repository at this point in the history
fix: incorrect valuation rate for PI based revaluation
  • Loading branch information
rohitwaghchaure authored Jan 11, 2025
2 parents edb254e + 14ce233 commit c6c7d78
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion erpnext/stock/stock_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,14 +1040,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

0 comments on commit c6c7d78

Please sign in to comment.