create_purchase_order
Generate purchase orders for art supply restocking. Automatically includes items below reorder levels and allows custom item additions to maintain optimal inventory.
Instructions
Create a purchase order for restocking. Automatically suggests items below reorder level.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| autoIncludeLowStock | No | Automatically include low stock items from this supplier | |
| customItems | No | Optional: comma-separated SKUs to include | |
| supplier | Yes | Supplier name |
Implementation Reference
- src/index.ts:225-235 (schema)Input schema for the create_purchase_order tool, defining parameters like supplier and auto-include low stock.name: 'create_purchase_order', description: 'Create a purchase order for restocking. Automatically suggests items below reorder level.', inputSchema: { type: 'object', properties: { supplier: { type: 'string', description: 'Supplier name' }, autoIncludeLowStock: { type: 'boolean', description: 'Automatically include low stock items from this supplier' }, customItems: { type: 'string', description: 'Optional: comma-separated SKUs to include' }, }, required: ['supplier'], },
- src/index.ts:833-856 (handler)Handler logic for create_purchase_order tool that finds supplier, identifies low stock items, calculates order details, and generates a purchase order summary.case 'create_purchase_order': { const supplier = String(args?.supplier || ''); const autoInclude = Boolean(args?.autoIncludeLowStock); const supplierInfo = storeData.suppliers.find(s => s.name.toLowerCase().includes(supplier.toLowerCase())); if (!supplierInfo) { return { content: [{ type: 'text', text: `❌ Supplier not found: "${supplier}"` }] }; } const supplierProducts = storeData.inventory.filter(i => i.supplier === supplierInfo.name); const lowStock = autoInclude ? supplierProducts.filter(i => i.quantity <= i.reorderLevel) : []; const orderTotal = lowStock.reduce((sum, item) => sum + (item.price * (item.reorderLevel * 2 - item.quantity)), 0); return { content: [{ type: 'text', text: `📝 Purchase Order Created\n\n🏢 Supplier: ${supplierInfo.name}\n📅 Date: ${new Date().toISOString().split('T')[0]}\n⏱️ Expected Delivery: ${supplierInfo.leadTime}\n\n${lowStock.length > 0 ? `Items to Order:\n${lowStock.map(item => `• ${item.name} (${item.id})\n Order Qty: ${item.reorderLevel * 2 - item.quantity} | Est. Cost: $${(item.price * (item.reorderLevel * 2 - item.quantity) * 0.6).toFixed(2)}` ).join('\n\n')}\n\n💰 Estimated Total: $${(orderTotal * 0.6).toFixed(2)}` : 'No items below reorder level for this supplier.'}` }] }; }
- src/index.ts:516-518 (registration)Registration of the ListToolsRequestSchema handler which returns the list of all tools, including create_purchase_order.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
- src/dashboard.ts:54-54 (registration)Mock registration of the tool in the dashboard server for UI display purposes.{ name: 'create_purchase_order', description: 'Generate purchase orders', category: 'Supplier Management' },