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: internal transfer condition #35158

Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def make_item_gl_entries(self, gl_entries, warehouse_account=None):
)

outgoing_amount = d.base_net_amount
if self.is_internal_supplier and d.valuation_rate:
if self.is_internal_transfer() and d.valuation_rate:
outgoing_amount = abs(
frappe.db.get_value(
"Stock Ledger Entry",
Expand Down
16 changes: 14 additions & 2 deletions erpnext/stock/stock_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def process_sle(self, sle):
sle.voucher_type in ["Purchase Receipt", "Purchase Invoice"]
and sle.voucher_detail_no
and sle.actual_qty < 0
and frappe.get_cached_value(sle.voucher_type, sle.voucher_no, "is_internal_supplier")
and is_internal_transfer(sle)
):
sle.outgoing_rate = get_incoming_rate_for_inter_company_transfer(sle)

Expand Down Expand Up @@ -679,7 +679,7 @@ def get_incoming_outgoing_rate_from_transaction(self, sle):
elif (
sle.voucher_type in ["Purchase Receipt", "Purchase Invoice"]
and sle.voucher_detail_no
and frappe.get_cached_value(sle.voucher_type, sle.voucher_no, "is_internal_supplier")
and is_internal_transfer(sle)
):
rate = get_incoming_rate_for_inter_company_transfer(sle)
else:
Expand Down Expand Up @@ -1609,3 +1609,15 @@ def get_incoming_rate_for_inter_company_transfer(sle) -> float:
)

return rate


def is_internal_transfer(sle):
data = frappe.get_cached_value(
sle.voucher_type,
sle.voucher_no,
["is_internal_supplier", "represents_company", "company"],
as_dict=True,
)

if data.is_internal_supplier and data.represents_company == data.company:
return True