feat: validate negative stock for inventory dimension (backport #37373) (#37383)

* feat: validate negative stock for inventory dimension (#37373)

* feat: validate negative stock for inventory dimension

* test: test case for validate negative stock for inv dimension

(cherry picked from commit 1480acabb0)

# Conflicts:
#	erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
#	erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
#	erpnext/stock/stock_ledger.py

* chore: fix conflicts

* chore: fix conflicts

* chore: fix conflicts

* chore: fix linter issue

* chore: fix linter issue

* chore: fix linter issue

* chore: fix linter issue

* chore: fix linter issue

---------

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
This commit is contained in:
mergify[bot]
2023-10-16 19:15:18 +05:30
committed by GitHub
parent 6e3e4c8ade
commit 27a1e3bf83
8 changed files with 218 additions and 11 deletions

View File

@@ -95,6 +95,7 @@ def get_stock_balance(
posting_time=None,
with_valuation_rate=False,
with_serial_no=False,
inventory_dimensions_dict=None,
):
"""Returns stock balance quantity at given warehouse on given posting date or current date.
@@ -114,7 +115,13 @@ def get_stock_balance(
"posting_time": posting_time,
}
last_entry = get_previous_sle(args)
extra_cond = ""
if inventory_dimensions_dict:
for field, value in inventory_dimensions_dict.items():
args[field] = value
extra_cond += f" and {field} = %({field})s"
last_entry = get_previous_sle(args, extra_cond=extra_cond)
if with_valuation_rate:
if with_serial_no: