mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-01 07:37:04 +00:00
fix: keep Standard Cost stock value in step with the standard rate
Mirrors update_qty's Standard Cost handling and drops fixed test item
names so reruns start from fresh SLE-less items.
(cherry picked from commit 49a43aad81)
This commit is contained in:
@@ -50,6 +50,15 @@ class Bin(Document):
|
|||||||
self.actual_qty = last_sle.qty_after_transaction
|
self.actual_qty = last_sle.qty_after_transaction
|
||||||
self.valuation_rate = last_sle.valuation_rate
|
self.valuation_rate = last_sle.valuation_rate
|
||||||
self.stock_value = last_sle.stock_value
|
self.stock_value = last_sle.stock_value
|
||||||
|
|
||||||
|
from erpnext.stock.utils import get_valuation_method
|
||||||
|
|
||||||
|
if get_valuation_method(self.item_code) == "Standard Cost":
|
||||||
|
from erpnext.stock.doctype.item_standard_cost.item_standard_cost import get_item_standard_rate
|
||||||
|
|
||||||
|
self.stock_value = flt(self.actual_qty) * flt(
|
||||||
|
get_item_standard_rate(self.item_code, self.company)
|
||||||
|
)
|
||||||
self.planned_qty = get_planned_qty(self.item_code, self.warehouse)
|
self.planned_qty = get_planned_qty(self.item_code, self.warehouse)
|
||||||
self.indented_qty = get_indented_qty(self.item_code, self.warehouse)
|
self.indented_qty = get_indented_qty(self.item_code, self.warehouse)
|
||||||
self.ordered_qty = get_ordered_qty(self.item_code, self.warehouse)
|
self.ordered_qty = get_ordered_qty(self.item_code, self.warehouse)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class TestBin(ERPNextTestSuite):
|
|||||||
def test_recalculate_values(self):
|
def test_recalculate_values(self):
|
||||||
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
|
||||||
|
|
||||||
item_code = make_item("_TestBinRecalculateValues").name
|
item_code = make_item().name
|
||||||
warehouse = "_Test Warehouse - _TC"
|
warehouse = "_Test Warehouse - _TC"
|
||||||
make_stock_entry(item_code=item_code, target=warehouse, qty=10, rate=100)
|
make_stock_entry(item_code=item_code, target=warehouse, qty=10, rate=100)
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ class TestBin(ERPNextTestSuite):
|
|||||||
self.assertEqual(bin.stock_value, 1000)
|
self.assertEqual(bin.stock_value, 1000)
|
||||||
|
|
||||||
def test_recalculate_values_without_sle(self):
|
def test_recalculate_values_without_sle(self):
|
||||||
item_code = make_item("_TestBinRecalculateValuesNoSLE").name
|
item_code = make_item().name
|
||||||
warehouse = "_Test Warehouse - _TC"
|
warehouse = "_Test Warehouse - _TC"
|
||||||
|
|
||||||
bin = _create_bin(item_code, warehouse)
|
bin = _create_bin(item_code, warehouse)
|
||||||
|
|||||||
Reference in New Issue
Block a user