New enterprise feature2
This commit is contained in:
@@ -386,6 +386,46 @@ class ForecastServiceClient(BaseServiceClient):
|
||||
forecast_days=forecast_days
|
||||
)
|
||||
|
||||
async def get_aggregated_forecast(
|
||||
self,
|
||||
parent_tenant_id: str,
|
||||
start_date: date,
|
||||
end_date: date,
|
||||
product_id: Optional[str] = None
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
Get aggregated forecast for enterprise tenant and all children.
|
||||
|
||||
This method calls the enterprise forecasting aggregation endpoint which
|
||||
combines demand forecasts across the parent tenant and all child tenants
|
||||
in the network. Used for centralized production planning.
|
||||
|
||||
Args:
|
||||
parent_tenant_id: The parent tenant (central bakery) UUID
|
||||
start_date: Start date for forecast range
|
||||
end_date: End date for forecast range
|
||||
product_id: Optional product ID to filter forecasts
|
||||
|
||||
Returns:
|
||||
Aggregated forecast data including:
|
||||
- total_demand: Sum of all child demands
|
||||
- child_contributions: Per-child demand breakdown
|
||||
- forecast_date_range: Date range for the forecast
|
||||
- cached: Whether data was served from Redis cache
|
||||
"""
|
||||
params = {
|
||||
"start_date": start_date.isoformat(),
|
||||
"end_date": end_date.isoformat()
|
||||
}
|
||||
if product_id:
|
||||
params["product_id"] = product_id
|
||||
|
||||
return await self.get(
|
||||
"forecasting/enterprise/aggregated",
|
||||
tenant_id=parent_tenant_id,
|
||||
params=params
|
||||
)
|
||||
|
||||
async def create_forecast(
|
||||
self,
|
||||
tenant_id: str,
|
||||
|
||||
Reference in New Issue
Block a user