fix: Correct variable references in PO seed script
Fixed 'items' is not defined error in demo seed script: - Changed 'items' references to 'items_data' (the function parameter) - Updated product_names extraction to use dict.get() for safety - Fixed create_po_reasoning_supplier_contract call to use correct parameters (contract_quantity instead of trust_score) This resolves the warnings about failed reasoning_data generation during purchase order seeding.
This commit is contained in:
@@ -128,10 +128,11 @@ async def create_purchase_order(
|
||||
reasoning_data = None
|
||||
|
||||
try:
|
||||
# Get product names from items
|
||||
product_names = [item.product_name for item in items if hasattr(item, 'product_name')]
|
||||
# Get product names from items_data
|
||||
items_list = items_data or []
|
||||
product_names = [item.get('product_name', f"Product {i+1}") for i, item in enumerate(items_list)]
|
||||
if not product_names:
|
||||
product_names = [f"Product {i+1}" for i in range(len(items))]
|
||||
product_names = ["Demo Product"]
|
||||
|
||||
if status == PurchaseOrderStatus.pending_approval:
|
||||
# Low stock detection reasoning
|
||||
@@ -151,8 +152,8 @@ async def create_purchase_order(
|
||||
reasoning_data = create_po_reasoning_supplier_contract(
|
||||
supplier_name=supplier.name,
|
||||
product_names=product_names,
|
||||
contract_terms=f"Auto-approval threshold: €500",
|
||||
trust_score=float(supplier.trust_score) if hasattr(supplier, 'trust_score') else 0.85
|
||||
contract_terms="monthly",
|
||||
contract_quantity=float(total_amount)
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to generate reasoning_data: {e}")
|
||||
|
||||
Reference in New Issue
Block a user