Add POI feature and imporve the overall backend implementation
This commit is contained in:
@@ -207,9 +207,33 @@ async def trigger_safety_stock_optimization(
|
||||
)
|
||||
continue
|
||||
|
||||
# Get lead time from supplier if available
|
||||
lead_time_days = 7 # Default fallback
|
||||
if product.supplier_id:
|
||||
try:
|
||||
from shared.clients.suppliers_client import SuppliersClient
|
||||
suppliers_client = SuppliersClient()
|
||||
supplier_data = await suppliers_client.get_supplier_by_id(
|
||||
tenant_id=str(tenant_id),
|
||||
supplier_id=str(product.supplier_id)
|
||||
)
|
||||
if supplier_data and 'standard_lead_time' in supplier_data:
|
||||
lead_time_days = supplier_data['standard_lead_time']
|
||||
logger.debug(
|
||||
f"Using supplier lead time for product {product_id}",
|
||||
lead_time=lead_time_days,
|
||||
supplier_id=str(product.supplier_id)
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"Failed to fetch supplier lead time for product {product_id}, using default",
|
||||
error=str(e),
|
||||
supplier_id=str(product.supplier_id)
|
||||
)
|
||||
|
||||
# Product characteristics
|
||||
product_characteristics = {
|
||||
'lead_time_days': 7, # TODO: Get from supplier data
|
||||
'lead_time_days': lead_time_days,
|
||||
'shelf_life_days': 30 if product.is_perishable else 365,
|
||||
'perishable': product.is_perishable
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user