Skip to content

Commit

Permalink
fix: recalculate costs in SCR while reposting
Browse files Browse the repository at this point in the history
(cherry picked from commit a6cb6c6)
  • Loading branch information
s-aga-r authored and mergify[bot] committed May 15, 2023
1 parent 3a7c69f commit 9a8ee62
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions erpnext/stock/stock_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,13 +781,19 @@ def update_rate_on_purchase_receipt(self, sle, outgoing_rate):
d.db_update()

def update_rate_on_subcontracting_receipt(self, sle, outgoing_rate):
if frappe.db.exists(sle.voucher_type + " Item", sle.voucher_detail_no):
frappe.db.set_value(sle.voucher_type + " Item", sle.voucher_detail_no, "rate", outgoing_rate)
if frappe.db.exists("Subcontracting Receipt Item", sle.voucher_detail_no):
frappe.db.set_value("Subcontracting Receipt Item", sle.voucher_detail_no, "rate", outgoing_rate)
else:
frappe.db.set_value(
"Subcontracting Receipt Supplied Item", sle.voucher_detail_no, "rate", outgoing_rate
)

scr = frappe.get_doc("Subcontracting Receipt", sle.voucher_no, for_update=True)
scr.set_missing_values()
scr.db_update()
for d in scr.items + scr.get("supplied_items", []):
d.db_update()

def get_serialized_values(self, sle):
incoming_rate = flt(sle.incoming_rate)
actual_qty = flt(sle.actual_qty)
Expand Down

0 comments on commit 9a8ee62

Please sign in to comment.