Kaynağa Gözat

agregar modulo toteat al desarrollo

Erwin Jacimino 2 hafta önce
ebeveyn
işleme
a705140e60
2 değiştirilmiş dosya ile 21 ekleme ve 12 silme
  1. 17 10
      models/items.py
  2. 4 2
      toteat/toteat.py

+ 17 - 10
models/items.py

@@ -1,6 +1,7 @@
 from typing import List, Optional
 from pydantic import BaseModel
 
+
 class Item(BaseModel):
     name: str
     price: float
@@ -8,6 +9,7 @@ class Item(BaseModel):
     comment: str
     kitchen_id: int
 
+
 class Order(BaseModel):
     """Order model matching the database schema"""
     customerName: str
@@ -16,13 +18,16 @@ class Order(BaseModel):
     orderDate: str
     table: int
 
+
 class OrderBilling(BaseModel):
     """Order model matching the database schema"""
     table: int
     payment: str
+
+
 class Product(BaseModel):
     """Product model matching the database schema"""
-    id: int
+    id: str
     name: str
     type: Optional[str] = None
     description: Optional[str] = None
@@ -30,11 +35,11 @@ class Product(BaseModel):
     image: Optional[str] = None
     status: int = 1  # 0: Inactive, 1: Active
     quantity: Optional[int] = 1  # Optional quantity for the product
-    kitchen_id: Optional[int] = None
-    promo_id:Optional[int]  # ID of the promotional offer if applicable
-    promo_price:Optional[int]  # Promotional price if applicable
-    promo_day:Optional[int]  # Day of the week for promo (1-7)
-    
+    kitchen_id: Optional[str] = None
+    promo_id: Optional[int]  # ID of the promotional offer if applicable
+    promo_price: Optional[int]  # Promotional price if applicable
+    promo_day: Optional[int]  # Day of the week for promo (1-7)
+
 
 class ProductEditRequest(BaseModel):
     """Request model for editing a product"""
@@ -46,9 +51,10 @@ class ProductEditRequest(BaseModel):
     status: Optional[int] = None  # 0: Inactive, 1: Active
     quantity: Optional[int] = None  # Optional quantity for the product
 
+
 class ProductCreateRequest(BaseModel):
     """Request model for creating a new product"""
-    id: int
+    id: str
     name: str
     type: str
     description: str
@@ -57,6 +63,7 @@ class ProductCreateRequest(BaseModel):
     status: Optional[int] = 1  # 0: Inactive, 1: Active
     quantity: Optional[int] = 1  # Optional quantity for the product
 
+
 class ProductTypes:
     """Enumeration of product types"""
     BEER = "Cerveza"
@@ -67,12 +74,12 @@ class ProductTypes:
         """Returns a list of all product types"""
         atributos = {}
         for nombre in dir(ProductTypes):
-            if not nombre.startswith('_'):  # Excluir atributos privados/especiales
+            if not nombre.startswith('_'):  # Excluir atributos privados
                 valor = getattr(ProductTypes, nombre)
                 if not callable(valor):  # Excluir métodos
                     atributos[nombre] = valor
         return list(atributos.values())
-    
+
 
 if __name__ == "__main__":
-    print(ProductTypes.get_all_types())
+    print(ProductTypes.get_all_types())

+ 4 - 2
toteat/toteat.py

@@ -304,20 +304,22 @@ def get_category(id_category) -> Dict[str, Any]:
 
 
 def get_product(product_id) -> Optional[Product]:
+    print(f"producto recibido: {product_id}")
     pid = str(product_id)
+    print(f"pid: {pid}")
     for it in _fetch_menu():
         if str(it.get("id")) == pid:
             mapped = _to_fudo_product(it)
             cat_id = mapped["relationships"]["productCategory"]["data"]["id"]
             return Product(
-                id=int(mapped["id"]),
+                id=mapped["id"],
                 name=mapped["attributes"]["name"],
                 type=get_category(cat_id)["name"] or "Producto",
                 price=int(mapped["attributes"]["price"] or 0),
                 image=mapped["attributes"]["imageUrl"],
                 description=mapped["attributes"]["description"],
                 status=1,
-                kitchen_id=int(mapped["relationships"]["kitchen"]["data"]["id"] or 0),
+                kitchen_id=mapped["relationships"]["kitchen"]["data"]["id"] or None,
                 promo_day=None,
                 promo_price=None,
                 promo_id=None,