diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py index 417a4207d92c6d41016e5a79eb93743d6159ca8b..31e2306be5d93f879ef9e3e210e4f60cc176e3d8 100644 --- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py @@ -1927,6 +1927,59 @@ class TestStockEntry(IntegrationTestCase): self.assertEqual(sle.stock_value_difference, 100) self.assertEqual(sle.stock_value, 100 * i) + def test_stock_entry_amount(self): + warehouse = "_Test Warehouse - _TC" + rm_item_code = "Test Stock Entry Amount 1" + make_item(rm_item_code, {"is_stock_item": 1}) + + fg_item_code = "Test Repack Stock Entry Amount 1" + make_item(fg_item_code, {"is_stock_item": 1}) + + make_stock_entry( + item_code=rm_item_code, + qty=1, + to_warehouse=warehouse, + basic_rate=200, + posting_date=nowdate(), + ) + + se = make_stock_entry( + item_code=rm_item_code, + qty=1, + purpose="Repack", + basic_rate=100, + do_not_save=True, + ) + + se.items[0].s_warehouse = warehouse + se.append( + "items", + { + "item_code": fg_item_code, + "qty": 1, + "t_warehouse": warehouse, + "uom": "Nos", + "conversion_factor": 1.0, + }, + ) + se.set_stock_entry_type() + se.submit() + + self.assertEqual(se.items[0].amount, 200) + self.assertEqual(se.items[0].basic_amount, 200) + + make_stock_entry( + item_code=rm_item_code, + qty=1, + to_warehouse=warehouse, + basic_rate=300, + posting_date=add_days(nowdate(), -1), + ) + + se.reload() + self.assertEqual(se.items[0].amount, 300) + self.assertEqual(se.items[0].basic_amount, 300) + def make_serialized_item(self, **args): args = frappe._dict(args) diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py index 5a50a237b925b9ff5936491e45a97304c88ea5b2..6a6d21d17f9e696f09fbdd2b7368c48b88f24925 100644 --- a/erpnext/stock/stock_ledger.py +++ b/erpnext/stock/stock_ledger.py @@ -1239,7 +1239,11 @@ class update_entries_after: stock_entry.db_update() for d in stock_entry.items: # Update only the row that matches the voucher_detail_no or the row containing the FG/Scrap Item. - if d.name == voucher_detail_no or (not d.s_warehouse and d.t_warehouse): + if ( + d.name == voucher_detail_no + or (not d.s_warehouse and d.t_warehouse) + or stock_entry.purpose in ["Manufacture", "Repack"] + ): d.db_update() def update_rate_on_delivery_and_sales_return(self, sle, outgoing_rate):