Merge branch 'develop' into fix/github-issue/28766
This commit is contained in:
commit
b425c2d7ec
@ -83,6 +83,7 @@ class TestItem(FrappeTestCase):
|
|||||||
def test_get_item_details(self):
|
def test_get_item_details(self):
|
||||||
# delete modified item price record and make as per test_records
|
# delete modified item price record and make as per test_records
|
||||||
frappe.db.sql("""delete from `tabItem Price`""")
|
frappe.db.sql("""delete from `tabItem Price`""")
|
||||||
|
frappe.db.sql("""delete from `tabBin`""")
|
||||||
|
|
||||||
to_check = {
|
to_check = {
|
||||||
"item_code": "_Test Item",
|
"item_code": "_Test Item",
|
||||||
@ -103,9 +104,26 @@ class TestItem(FrappeTestCase):
|
|||||||
"batch_no": None,
|
"batch_no": None,
|
||||||
"uom": "_Test UOM",
|
"uom": "_Test UOM",
|
||||||
"conversion_factor": 1.0,
|
"conversion_factor": 1.0,
|
||||||
|
"reserved_qty": 1,
|
||||||
|
"actual_qty": 5,
|
||||||
|
"ordered_qty": 10,
|
||||||
|
"projected_qty": 14,
|
||||||
}
|
}
|
||||||
|
|
||||||
make_test_objects("Item Price")
|
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"
|
company = "_Test Company"
|
||||||
currency = frappe.get_cached_value("Company", company, "default_currency")
|
currency = frappe.get_cached_value("Company", company, "default_currency")
|
||||||
@ -129,7 +147,7 @@ class TestItem(FrappeTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for key, value in to_check.items():
|
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):
|
def test_item_tax_template(self):
|
||||||
expected_item_tax_template = [
|
expected_item_tax_template = [
|
||||||
|
@ -1176,7 +1176,7 @@ def get_projected_qty(item_code, warehouse):
|
|||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_bin_details(item_code, warehouse, company=None, include_child_warehouses=False):
|
def get_bin_details(item_code, warehouse, company=None, include_child_warehouses=False):
|
||||||
bin_details = {"projected_qty": 0, "actual_qty": 0, "reserved_qty": 0}
|
bin_details = {"projected_qty": 0, "actual_qty": 0, "reserved_qty": 0, "ordered_qty": 0}
|
||||||
|
|
||||||
if warehouse:
|
if warehouse:
|
||||||
from frappe.query_builder.functions import Coalesce, Sum
|
from frappe.query_builder.functions import Coalesce, Sum
|
||||||
@ -1192,12 +1192,14 @@ def get_bin_details(item_code, warehouse, company=None, include_child_warehouses
|
|||||||
Coalesce(Sum(bin.projected_qty), 0).as_("projected_qty"),
|
Coalesce(Sum(bin.projected_qty), 0).as_("projected_qty"),
|
||||||
Coalesce(Sum(bin.actual_qty), 0).as_("actual_qty"),
|
Coalesce(Sum(bin.actual_qty), 0).as_("actual_qty"),
|
||||||
Coalesce(Sum(bin.reserved_qty), 0).as_("reserved_qty"),
|
Coalesce(Sum(bin.reserved_qty), 0).as_("reserved_qty"),
|
||||||
|
Coalesce(Sum(bin.ordered_qty), 0).as_("ordered_qty"),
|
||||||
)
|
)
|
||||||
.where((bin.item_code == item_code) & (bin.warehouse.isin(warehouses)))
|
.where((bin.item_code == item_code) & (bin.warehouse.isin(warehouses)))
|
||||||
).run(as_dict=True)[0]
|
).run(as_dict=True)[0]
|
||||||
|
|
||||||
if company:
|
if company:
|
||||||
bin_details["company_total_stock"] = get_company_total_stock(item_code, company)
|
bin_details["company_total_stock"] = get_company_total_stock(item_code, company)
|
||||||
|
|
||||||
return bin_details
|
return bin_details
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user