Skip to content

Commit

Permalink
Merge pull request #36066 from frappe/mergify/bp/version-14/pr-36065
Browse files Browse the repository at this point in the history
fix: Delivery Note return valuation (backport #36063) (backport #36065)
  • Loading branch information
rohitwaghchaure authored Jul 10, 2023
2 parents 7831896 + 8c041eb commit db809cb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
6 changes: 5 additions & 1 deletion erpnext/controllers/sales_and_purchase_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,11 @@ def get_filters(
if reference_voucher_detail_no:
filters["voucher_detail_no"] = reference_voucher_detail_no

if item_row and item_row.get("warehouse"):
if (
voucher_type in ["Purchase Receipt", "Purchase Invoice"]
and item_row
and item_row.get("warehouse")
):
filters["warehouse"] = item_row.get("warehouse")

return filters
Expand Down
31 changes: 31 additions & 0 deletions erpnext/stock/doctype/delivery_note/test_delivery_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,37 @@ def test_sales_return_for_non_bundled_items_full(self):
self.assertEqual(dn.per_returned, 100)
self.assertEqual(dn.status, "Return Issued")

def test_delivery_note_return_valuation_on_different_warehuose(self):
from erpnext.stock.doctype.warehouse.test_warehouse import create_warehouse

company = frappe.db.get_value("Warehouse", "Stores - TCP1", "company")
item_code = "Test Return Valuation For DN"
make_item("Test Return Valuation For DN", {"is_stock_item": 1})
return_warehouse = create_warehouse("Returned Test Warehouse", company=company)

make_stock_entry(item_code=item_code, target="Stores - TCP1", qty=5, basic_rate=150)

dn = create_delivery_note(
item_code=item_code,
qty=5,
rate=500,
warehouse="Stores - TCP1",
company=company,
expense_account="Cost of Goods Sold - TCP1",
cost_center="Main - TCP1",
)

dn.submit()
self.assertEqual(dn.items[0].incoming_rate, 150)

from erpnext.controllers.sales_and_purchase_return import make_return_doc

return_dn = make_return_doc(dn.doctype, dn.name)
return_dn.items[0].warehouse = return_warehouse
return_dn.save().submit()

self.assertEqual(return_dn.items[0].incoming_rate, 150)

def test_return_single_item_from_bundled_items(self):
company = frappe.db.get_value("Warehouse", "Stores - TCP1", "company")

Expand Down

0 comments on commit db809cb

Please sign in to comment.