Added inventory amount per food package management
This commit is contained in:
@@ -384,6 +384,32 @@ def create_server() -> MCPServer:
|
||||
await api_request('DELETE', f'kitchen/items/{item_id}/')
|
||||
return {'success': True, 'removed_item_id': item_id}
|
||||
|
||||
@server.tool(structured_output=True, description='Read stock for an owned product ID or search query, optionally limited to a location ID. Returns package details and remaining totals. Does not change stock.')
|
||||
async def inventory_get_stock(product_id: str | None = None, query: str | None = None,
|
||||
location_id: int | None = None) -> dict[str, Any]:
|
||||
params = {'product_id': product_id, 'query': query, 'location_id': location_id}
|
||||
return await api_request('GET', 'kitchen/stock/', params={k: v for k, v in params.items() if v is not None})
|
||||
|
||||
@server.tool(structured_output=True, description='Preview exact package deductions for one owned product without changing stock. A shortage is reported rather than silently consumed.')
|
||||
async def inventory_preview_consumption(product_id: str, amount: Decimal, unit: str,
|
||||
package_id: str | None = None) -> dict[str, Any]:
|
||||
return await api_request('POST', 'kitchen/consumption/preview/', payload={
|
||||
'product_id': product_id, 'amount': str(amount), 'unit': unit, 'package_id': package_id})
|
||||
|
||||
@server.tool(structured_output=True, description='Consume an exact quantity from owned inventory packages atomically. Requires a unique idempotency key. If stock is short, preview first and use allow_partial only with explicit user choice.')
|
||||
async def inventory_consume(product_id: str, amount: Decimal, unit: str, idempotency_key: str,
|
||||
package_id: str | None = None, source_reference: str = '',
|
||||
description: str = '', allow_partial: bool = False) -> dict[str, Any]:
|
||||
return await api_request('POST', 'kitchen/consumption/', payload={
|
||||
'product_id': product_id, 'amount': str(amount), 'unit': unit,
|
||||
'package_id': package_id, 'source_reference': source_reference,
|
||||
'description': description, 'allow_partial': allow_partial},
|
||||
idempotency_key=idempotency_key)
|
||||
|
||||
@server.tool(structured_output=True, description='Undo a previous owned inventory consumption transaction when its affected packages have not changed since. Records an auditable reversal.')
|
||||
async def inventory_undo_consumption(transaction_id: str) -> dict[str, Any]:
|
||||
return await api_request('POST', f'kitchen/consumption/{transaction_id}/undo/', payload={})
|
||||
|
||||
return server
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user