Minor fixes
diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
index 83853dd..842409f 100644
--- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
@@ -112,6 +112,6 @@
test_recurring_document(self, test_records)
-test_dependencies = ["BOM"]
+test_dependencies = ["BOM", "Item Price"]
test_records = frappe.get_test_records('Purchase Order')
diff --git a/erpnext/stock/doctype/item_price/test_records.json b/erpnext/stock/doctype/item_price/test_records.json
index b4ceb92..36870cd 100644
--- a/erpnext/stock/doctype/item_price/test_records.json
+++ b/erpnext/stock/doctype/item_price/test_records.json
@@ -16,5 +16,11 @@
"item_code": "_Test Item 2",
"price_list": "_Test Price List Rest of the World",
"price_list_rate": 20
+ },
+ {
+ "doctype": "Item Price",
+ "item_code": "_Test Item Home Desktop 100",
+ "price_list": "_Test Price List",
+ "price_list_rate": 1000
}
]
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index 67f621a..69751a2 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -151,6 +151,6 @@
accounts_settings.save()
-test_dependencies = ["BOM"]
+test_dependencies = ["BOM", "Item Price"]
test_records = frappe.get_test_records('Purchase Receipt')
diff --git a/erpnext/stock/stock_ledger.py b/erpnext/stock/stock_ledger.py
index 2956170..7dc8d83 100644
--- a/erpnext/stock/stock_ledger.py
+++ b/erpnext/stock/stock_ledger.py
@@ -275,7 +275,7 @@
incoming_rate = flt(sle.incoming_rate)
actual_qty = flt(sle.actual_qty)
- intialize_stock_queue(stock_queue, sle.item_code, sle.warehouse)
+ intialize_stock_queue(stock_queue, sle.item_code, sle.warehouse, actual_qty)
if actual_qty > 0:
if stock_queue[-1][0] > 0:
@@ -289,7 +289,7 @@
else:
qty_to_pop = abs(actual_qty)
while qty_to_pop:
- intialize_stock_queue(stock_queue, sle.item_code, sle.warehouse)
+ intialize_stock_queue(stock_queue, sle.item_code, sle.warehouse, actual_qty)
batch = stock_queue[0]
@@ -318,9 +318,9 @@
return abs(valuation_rate)
-def intialize_stock_queue(stock_queue, item_code, warehouse):
+def intialize_stock_queue(stock_queue, item_code, warehouse, actual_qty):
if not stock_queue:
- estimated_val_rate = get_valuation_rate(item_code, warehouse)
+ estimated_val_rate = get_valuation_rate(item_code, warehouse) if actual_qty < 0 else 0
stock_queue.append([0, estimated_val_rate])
def _raise_exceptions(args, verbose=1):