Skip to content

Commit

Permalink
fix: incorrect incoming rate set for inter transfer purchase receipt
Browse files Browse the repository at this point in the history
(cherry picked from commit ddd24ea)
  • Loading branch information
rohitwaghchaure authored and mergify[bot] committed Aug 9, 2022
1 parent 9925eb9 commit 4e8b39a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion erpnext/controllers/buying_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ def set_incoming_rate(self):

rate = flt(outgoing_rate * (d.conversion_factor or 1), d.precision("rate"))
else:
rate = frappe.db.get_value(ref_doctype, d.get(frappe.scrub(ref_doctype)), "rate")
field = "incoming_rate" if self.get("is_internal_supplier") else "rate"
rate = frappe.db.get_value(ref_doctype, d.get(frappe.scrub(ref_doctype)), field)

if self.is_internal_transfer():
if rate != d.rate:
Expand Down
18 changes: 18 additions & 0 deletions erpnext/stock/stock_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,24 @@ def get_incoming_outgoing_rate_from_transaction(self, sle):
voucher_detail_no=sle.voucher_detail_no,
sle=sle,
)

elif (
sle.voucher_type in ["Purchase Receipt", "Purchase Invoice"]
and sle.actual_qty > 0
and frappe.get_cached_value(sle.voucher_type, sle.voucher_no, "is_internal_supplier")
):
sle_details = frappe.db.get_value(
"Stock Ledger Entry",
{
"voucher_type": sle.voucher_type,
"voucher_no": sle.voucher_no,
"dependant_sle_voucher_detail_no": sle.voucher_detail_no,
},
["stock_value_difference", "actual_qty"],
as_dict=1,
)

rate = abs(sle_details.stock_value_difference / sle.actual_qty)
else:
if sle.voucher_type in ("Purchase Receipt", "Purchase Invoice"):
rate_field = "valuation_rate"
Expand Down

0 comments on commit 4e8b39a

Please sign in to comment.