brotherton-erpnext/erpnext/tests/test_point_of_sale.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.6 KiB
Python
Raw Normal View History

2022-02-01 07:44:28 +00:00
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt
from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile
from erpnext.selling.page.point_of_sale.point_of_sale import get_items
from erpnext.stock.doctype.item.test_item import make_item
from erpnext.stock.doctype.stock_entry.stock_entry_utils import make_stock_entry
from erpnext.tests.utils import ERPNextTestCase
class TestPointOfSale(ERPNextTestCase):
def test_item_search(self):
"""
Test Stock and Service Item Search.
"""
pos_profile = make_pos_profile()
2022-02-01 09:14:12 +00:00
item1 = make_item("Test Search Stock Item", {"is_stock_item": 1})
2022-02-01 07:44:28 +00:00
make_stock_entry(
2022-02-01 09:14:12 +00:00
item_code="Test Search Stock Item",
qty=10,
to_warehouse="_Test Warehouse - _TC",
rate=500,
2022-02-01 07:44:28 +00:00
)
result = get_items(
start=0,
page_length=20,
price_list=None,
item_group=item1.item_group,
pos_profile=pos_profile.name,
2022-02-01 09:14:12 +00:00
search_term="Test Search Stock Item",
2022-02-01 07:44:28 +00:00
)
filtered_items = result.get("items")
self.assertEqual(len(filtered_items), 1)
2022-02-01 09:14:12 +00:00
self.assertEqual(filtered_items[0]["item_code"], item1.item_code)
2022-02-01 07:44:28 +00:00
self.assertEqual(filtered_items[0]["actual_qty"], 10)
2022-02-01 09:14:12 +00:00
item2 = make_item("Test Search Service Item", {"is_stock_item": 0})
2022-02-01 07:44:28 +00:00
result = get_items(
start=0,
page_length=20,
price_list=None,
item_group=item2.item_group,
pos_profile=pos_profile.name,
2022-02-01 09:14:12 +00:00
search_term="Test Search Service Item",
2022-02-01 07:44:28 +00:00
)
filtered_items = result.get("items")
self.assertEqual(len(filtered_items), 1)
2022-02-01 09:14:12 +00:00
self.assertEqual(filtered_items[0]["item_code"], item2.item_code)