Merge pull request #33495 from dj12djdjs/fix-get-bin-details

fix(stock): missing ordered_qty in get_bin_details
This commit is contained in:
Sagar Sharma 2023-01-02 11:14:25 +05:30 committed by GitHub
commit 332f4dc028
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -83,6 +83,7 @@ class TestItem(FrappeTestCase):
def test_get_item_details(self):
# delete modified item price record and make as per test_records
frappe.db.sql("""delete from `tabItem Price`""")
frappe.db.sql("""delete from `tabBin`""")
to_check = {
"item_code": "_Test Item",
@ -103,9 +104,26 @@ class TestItem(FrappeTestCase):
"batch_no": None,
"uom": "_Test UOM",
"conversion_factor": 1.0,
"reserved_qty": 1,
"actual_qty": 5,
"ordered_qty": 10,
"projected_qty": 14,
}
make_test_objects("Item Price")
make_test_objects(
"Bin",
[
{
"item_code": "_Test Item",
"warehouse": "_Test Warehouse - _TC",
"reserved_qty": 1,
"actual_qty": 5,
"ordered_qty": 10,
"projected_qty": 14,
}
],
)
company = "_Test Company"
currency = frappe.get_cached_value("Company", company, "default_currency")
@ -129,7 +147,7 @@ class TestItem(FrappeTestCase):
)
for key, value in to_check.items():
self.assertEqual(value, details.get(key))
self.assertEqual(value, details.get(key), key)
def test_item_tax_template(self):
expected_item_tax_template = [

View File

@ -1175,10 +1175,10 @@ def get_bin_details(item_code, warehouse, company=None):
bin_details = frappe.db.get_value(
"Bin",
{"item_code": item_code, "warehouse": warehouse},
["projected_qty", "actual_qty", "reserved_qty"],
["projected_qty", "actual_qty", "reserved_qty", "ordered_qty"],
as_dict=True,
cache=True,
) or {"projected_qty": 0, "actual_qty": 0, "reserved_qty": 0}
) or {"projected_qty": 0, "actual_qty": 0, "reserved_qty": 0, "ordered_qty": 0}
if company:
bin_details["company_total_stock"] = get_company_total_stock(item_code, company)
return bin_details