Skip to content

Commit

Permalink
Merge branch 'version-13-hotfix' into mergify/bp/version-13-hotfix/pr…
Browse files Browse the repository at this point in the history
…-33444
  • Loading branch information
s-aga-r committed Jan 2, 2023
2 parents 4fb2d2c + 9b1384f commit 6c7815c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
20 changes: 19 additions & 1 deletion erpnext/stock/doctype/item/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def get_item(self, idx):
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",
Expand All @@ -101,9 +102,26 @@ def test_get_item_details(self):
"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")
Expand All @@ -127,7 +145,7 @@ def test_get_item_details(self):
)

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 = [
Expand Down
14 changes: 1 addition & 13 deletions erpnext/stock/doctype/stock_entry/stock_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,7 @@
from frappe import _
from frappe.model.mapper import get_mapped_doc
from frappe.query_builder.functions import Sum
from frappe.utils import (
add_days,
cint,
comma_or,
cstr,
flt,
format_time,
formatdate,
getdate,
nowdate,
today,
)
from frappe.utils import cint, comma_or, cstr, flt, format_time, formatdate, getdate, nowdate
from six import iteritems, itervalues, string_types

import erpnext
Expand Down Expand Up @@ -2565,4 +2554,3 @@ def get_supplied_items(purchase_order):
)

return supplied_item_details

4 changes: 3 additions & 1 deletion erpnext/stock/get_item_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ def get_projected_qty(item_code, warehouse):

@frappe.whitelist()
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:
from frappe.query_builder.functions import Coalesce, Sum
Expand All @@ -1177,12 +1177,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.actual_qty), 0).as_("actual_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)))
).run(as_dict=True)[0]

if company:
bin_details["company_total_stock"] = get_company_total_stock(item_code, company)

return bin_details


Expand Down

0 comments on commit 6c7815c

Please sign in to comment.