1+ from  warehouse .core .warehouse  import  WareHouse 
2+ from  warehouse .core .entities  import  WarehouseItem 
3+ 
4+ def  get_item_id () ->  str :
5+     """Prompts the user to enter a product ID. 
6+ 
7+     Returns: 
8+         str: The product ID entered by the user. 
9+     """ 
10+     wid  =  input ("Enter the product id: " )
11+     return  wid 
12+ 
13+ def  get_item_quantity () ->  int :
14+     """Prompts the user to enter the number of items (quantity). 
15+ 
16+     Returns: 
17+         int: The quantity entered by the user. 
18+     """ 
19+     quantity  =  int (input ("Enter number of items: " ))
20+     return  quantity 
21+ 
22+ def  get_item_name () ->  str :
23+     """Prompts the user to enter a product name. 
24+ 
25+     Returns: 
26+         str: The product name entered by the user. 
27+     """ 
28+     name  =  input ("Enter the product name: " )
29+     return  name 
30+ 
31+ def  get_item_details () ->  tuple [str , str , float , int ]:
32+     """Collects all necessary details for a new or existing warehouse item 
33+     from the user: ID, name, price, and quantity. 
34+ 
35+     Returns: 
36+         tuple: A tuple containing the item ID (str), name (str), price (float), 
37+             and quantity (int). 
38+     """ 
39+     wid : str  =  get_item_id ()
40+     name : str  =  get_item_name ()
41+     price : float  =  float (input ("Enter the price of product: " ))
42+     quantity : int  =  get_item_quantity ()
43+     return  wid ,name ,price ,quantity 
44+ 
45+ def  main () ->  None :
46+     """Main function to run the warehouse management application. 
47+ 
48+     Initializes a warehouse and runs a command-line interface loop 
49+     to allow the user to add, procure, sell, and search for products. 
50+     """ 
51+     print ("Welcome to warehouse" )
52+     warehouse : WareHouse  =  WareHouse (
53+         wid = "w1001" ,
54+         name = "Hyd warehouse 1" ,
55+         location = "Ameerpet" )
56+     while  True :
57+         print ("1. Add a new product to Warehouse" )
58+         print ("2. Procure existing products" )
59+         print ("3. Sell Products" )
60+         print ("4. Get item by id" )
61+         print ("5. Get items by name" )
62+         print ("6. quit" )
63+         choice : str  =  input ("Enter your choice: " )
64+         if  choice  not  in   ("1" , "2" , "3" , "4" , "5" , "6" ):
65+             print ("Invalid entry" )
66+         elif  choice  ==  "1" :
67+             wid : str 
68+             name : str 
69+             price : float 
70+             quantity : int 
71+             wid , name , price , quantity  =  get_item_details ()
72+             warehouse .add_new_item (item_id =  wid , name = name , price = price , quantity = quantity )
73+         elif  choice  ==  "2" :
74+             wid : str  =  get_item_id ()
75+             quantity : int  =  get_item_quantity ()
76+             warehouse .procure_item (item_id = wid , quantity = quantity )
77+         elif  choice  ==  "3" :
78+             wid : str  =  get_item_id ()
79+             quantity : int  =  get_item_quantity ()
80+             warehouse .sell_item (item_id = wid , quantity = quantity )
81+         elif  choice  ==  "4" :
82+             wid : str  =  get_item_id ()
83+             item : WarehouseItem  |  None  =  warehouse .find_item_by_id (item_id = wid )
84+             if  item :
85+                 print (item )
86+             else :
87+                 print ("Item not found" )
88+         elif  choice  ==  "5" :
89+             name : str  =  get_item_name ()
90+             # Assuming find_item_by_name returns an iterable of WarehouseItem 
91+             for  item  in  warehouse .find_item_by_name (name = name ):
92+                 print (item )
93+         elif  choice  ==  "6" :
94+             print ("Bye................" )
95+             break 
96+ 
97+ if  __name__  ==  "__main__" :
98+     main ()
0 commit comments