Maintain negative stock balance if balance qty is negative

This commit is contained in:
Nabin Hait
2014-10-09 19:25:03 +05:30
parent b7e5ad0a31
commit 4d74216147
8 changed files with 118 additions and 50 deletions

View File

@@ -305,9 +305,15 @@ def get_valuation_rate(item_code, warehouse):
last_valuation_rate = frappe.db.sql("""select valuation_rate
from `tabStock Ledger Entry`
where item_code = %s and warehouse = %s
and ifnull(qty_after_transaction, 0) > 0
and ifnull(valuation_rate, 0) > 0
order by posting_date desc, posting_time desc, name desc limit 1""", (item_code, warehouse))
if not last_valuation_rate:
last_valuation_rate = frappe.db.sql("""select valuation_rate
from `tabStock Ledger Entry`
where item_code = %s and ifnull(valuation_rate, 0) > 0
order by posting_date desc, posting_time desc, name desc limit 1""", item_code)
valuation_rate = flt(last_valuation_rate[0][0]) if last_valuation_rate else 0
if not valuation_rate: