{
  "openapi": "3.0.0",
  "info": {
    "title": "Pacific Bending ERP API",
    "version": "3.8.0",
    "description": "\nPacific Bending Manufacturing ERP API\n\n## Overview\nRESTful API for metal fabrication and manufacturing operations built on ERPNext.\n\n## Authentication\nAll endpoints (except health checks) require authentication via session cookie or API key.\n\n### Session Authentication\nLogin via `/api/method/login` with username and password.\n\n### API Key Authentication\nInclude `Authorization: token api_key:api_secret` header.\n\n## Response Format\nAll endpoints return responses in this format:\n```json\n{\n  \"success\": true,\n  \"data\": {...},\n  \"message\": \"Success\"\n}\n```\n\n## Error Handling\nErrors include structured error codes for programmatic handling:\n```json\n{\n  \"success\": false,\n  \"error\": \"Validation Error\",\n  \"message\": \"Human readable message\",\n  \"error_code\": \"VE001\",\n  \"correlation_id\": \"abc123\"\n}\n```\n\n## Rate Limiting\nMost endpoints are rate-limited to 100 requests/minute per user.\nWhen exceeded, returns HTTP 429 with `retry_after` header.\n\n## Multi-Location\nData is scoped by warehouse group (location). Include `location` parameter\nor it defaults to user's primary location.\n",
    "contact": {
      "name": "Pacific Bending Development Team",
      "url": "https://github.com/pacific-bending"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://pb-docs.erp.observer/license"
    }
  },
  "servers": [
    {
      "url": "https://api.pacific-bending.com/api/method/pacific_bending_app.api",
      "description": "Production server"
    }
  ],
  "paths": {
    "/addresses.get_addresses_for_entities": {
      "post": {
        "operationId": "pacific_bending_app.api.addresses.get_addresses_for_entities",
        "summary": "Get addresses for multiple entities in a single call.",
        "tags": [
          "Addresses"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Batch version of get_addresses_for_entity for efficiency.\nUseful for list views that need to display addresses for many entities.\n\nArgs:\n    doctype: Entity type (\"Customer\", \"Lead\", \"Contact\", \"Supplier\")\n    names: List of entity document names\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"CUST-001\": [\n                {\"name\": \"Address-001\", \"address_line1\": \"123 Main St\", ...}\n            ],\n            \"CUST-002\": []  // No addresses\n        },\n        \"message\": \"Addresses retrieved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string"
                  },
                  "names": {
                    "type": "array"
                  }
                },
                "required": [
                  "doctype",
                  "names"
                ]
              }
            }
          }
        }
      }
    },
    "/addresses.get_addresses_for_entity": {
      "post": {
        "operationId": "pacific_bending_app.api.addresses.get_addresses_for_entity",
        "summary": "Get all addresses linked to an entity via Dynamic Link.",
        "tags": [
          "Addresses"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Reusable for Customer, Lead, Contact, Supplier, etc.\nThis endpoint bypasses the 417 \"Expectation Failed\" error that occurs\nwhen using direct REST API with Dynamic Link filters.\n\nArgs:\n    doctype: Entity type (\"Customer\", \"Lead\", \"Contact\", \"Supplier\")\n    name: Entity document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"Address-001\",\n                \"address_title\": \"Main Office\",\n                \"address_type\": \"Billing\",\n                \"address_line1\": \"123 Main St\",\n                \"city\": \"Vancouver\",\n                \"state\": \"BC\",\n                \"country\": \"Canada\",\n                \"pincode\": \"V6B 1A1\",\n                \"is_primary_address\": 1,\n                \"is_shipping_address\": 0,\n                ...\n            }\n        ],\n        \"message\": \"Addresses retrieved successfully\",\n        \"count\": 1\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "doctype",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/addresses.get_primary_address": {
      "post": {
        "operationId": "pacific_bending_app.api.addresses.get_primary_address",
        "summary": "Get the primary billing address for an entity.",
        "tags": [
          "Addresses"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns the address with is_primary_address=1, or the first address\nif none is marked as primary.\n\nArgs:\n    doctype: Entity type (\"Customer\", \"Lead\", \"Contact\", \"Supplier\")\n    name: Entity document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"name\": \"Address-001\",\n            \"address_line1\": \"123 Main St\",\n            ...\n        } | null,\n        \"message\": \"Primary address retrieved\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "doctype",
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/approvals.approve_accounting_approval": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.approve_accounting_approval",
        "summary": "Approve accounting approval for a quote",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v3.56: Simplified using consolidated helpers\nMarks the accounting approval as complete. If this was the only pending\napproval (engineering not needed or already approved), the quote is fully approved.\n\nArgs:\n    quote_id: Quote to approve\n    notes: Optional approval notes\n    conditions: Optional conditions for approval\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"quote_id\": \"SAL-QTN-2025-00456\",\n            \"track\": \"accounting\",\n            \"approved\": true,\n            \"approved_by\": \"admin@company.com\",\n            \"approved_at\": \"2025-11-15T14:30:00\",\n            \"notes\": \"Margin approved\",\n            \"conditions\": \"50% upfront payment required\",\n            \"fully_approved\": true\n        },\n        \"message\": \"Accounting approval granted\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_id": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "conditions": {
                    "type": "string"
                  }
                },
                "required": [
                  "quote_id"
                ]
              }
            }
          }
        }
      }
    },
    "/approvals.approve_engineering_review": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.approve_engineering_review",
        "summary": "Approve engineering review for a quote (Admin Only)",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v6.5: Restricted to Admin role for hospital-grade access control\nv3.56: Simplified using consolidated helpers\nMarks the engineering review as complete. If this was the only pending\napproval (accounting not needed), the quote is fully approved and submitted.\n\nArgs:\n    quote_id: Quote to approve\n    notes: Optional notes from engineering reviewer\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"quote_id\": \"SAL-QTN-2025-00123\",\n            \"track\": \"engineering\",\n            \"approved\": true,\n            \"approved_by\": \"admin@company.com\",\n            \"approved_at\": \"2025-11-15T14:30:00\",\n            \"notes\": \"Technical specs verified\",\n            \"fully_approved\": false\n        },\n        \"message\": \"Engineering review approved\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_id": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "quote_id"
                ]
              }
            }
          }
        }
      }
    },
    "/approvals.approve_quote": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.approve_quote",
        "summary": "Backward-compatible single-track approval endpoint.",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Routes to engineering/accounting approval based on explicit `track` or\nquote review status.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_id": {
                    "type": "string"
                  },
                  "approval_notes": {
                    "type": "string"
                  },
                  "conditions": {
                    "type": "string"
                  },
                  "track": {
                    "type": "string"
                  }
                },
                "required": [
                  "quote_id"
                ]
              }
            }
          }
        }
      }
    },
    "/approvals.bulk_approve_accounting": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.bulk_approve_accounting",
        "summary": "Bulk approve accounting for multiple quotes",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v3.56: NEW - Dual-track bulk operation\nApplies accounting approval to multiple quotes at once.\n\nArgs:\n    quote_ids: JSON array of quote IDs\n    notes: Optional notes applied to all quotes\n    conditions: Optional conditions applied to all quotes\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"total\": 10,\n            \"approved\": 8,\n            \"failed\": 2,\n            \"results\": [\n                {\"quote_id\": \"QTN-00123\", \"status\": \"approved\", \"fully_approved\": true},\n                {\"quote_id\": \"QTN-00124\", \"status\": \"failed\", \"error\": \"Below threshold\"}\n            ]\n        },\n        \"message\": \"Bulk accounting approval completed: 8 approved, 2 failed\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_ids": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "conditions": {
                    "type": "string"
                  }
                },
                "required": [
                  "quote_ids"
                ]
              }
            }
          }
        }
      }
    },
    "/approvals.bulk_approve_engineering": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.bulk_approve_engineering",
        "summary": "Bulk approve engineering review for multiple quotes (Admin Only)",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v6.5: Restricted to Admin role for hospital-grade access control\nv3.56: NEW - Dual-track bulk operation\nApplies engineering approval to multiple quotes at once.\n\nArgs:\n    quote_ids: JSON array of quote IDs (e.g., '[\"QTN-00123\", \"QTN-00124\"]')\n    notes: Optional notes applied to all quotes\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"total\": 10,\n            \"approved\": 8,\n            \"failed\": 2,\n            \"results\": [\n                {\"quote_id\": \"QTN-00123\", \"status\": \"approved\", \"fully_approved\": false},\n                {\"quote_id\": \"QTN-00124\", \"status\": \"failed\", \"error\": \"Engineering not required\"}\n            ]\n        },\n        \"message\": \"Bulk engineering approval completed: 8 approved, 2 failed\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_ids": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "quote_ids"
                ]
              }
            }
          }
        }
      }
    },
    "/approvals.get_approved_quotes": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.get_approved_quotes",
        "summary": "Get recently approved quotes",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v3.46: Returns quotes that have been fully approved (workflow_state = \"Approved\").\nShows the most recently approved quotes for reference and audit purposes.\n\nArgs:\n    location: Filter by location (optional)\n    limit: Maximum number of quotes to return (default: 50)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"SAL-QTN-2025-00456\",\n                \"title\": \"Fabrication Project\",\n                \"customer\": \"Acme Corp\",\n                \"grand_total\": 45000.0,\n                \"approved_by\": \"manager@company.com\",\n                \"approved_at\": \"2025-01-15T14:30:00\",\n                \"transaction_date\": \"2025-01-10\",\n                \"custom_liability_category\": \"Standard\"\n            }\n        ],\n        \"count\": 15,\n        \"message\": \"Approved quotes retrieved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  },
                  "sort_order": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/approvals.get_lost_quotes": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.get_lost_quotes",
        "summary": "Get quotes that have been marked as lost.",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v4.9: NEW - Lost track for quotes that didn't convert.\nReturns quotes marked as lost by users, allowing analysis of\nlost opportunities and conversion rates.\n\nArgs:\n    location: Filter by location (optional)\n    limit: Maximum number of quotes to return (default: 50)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"SAL-QTN-2025-00124\",\n                \"title\": \"Steel Frame Assembly\",\n                \"customer\": \"Acme Manufacturing\",\n                \"grand_total\": 45000.0,\n                \"transaction_date\": \"2025-01-10\",\n                \"location\": \"Maple Ridge\",\n                \"custom_liability_category\": \"Standard\",\n                \"lost_reason\": \"Customer went with competitor\",\n                \"lost_date\": \"2025-01-20\",\n                \"lost_by\": \"estimator@company.com\",\n                \"had_engineering_review\": true,\n                \"had_accounting_approval\": true,\n                \"submitted_by\": \"estimator@company.com\",\n                \"submitted_at\": \"2025-01-15T14:30:00\"\n            }\n        ],\n        \"count\": 3,\n        \"message\": \"Lost quotes retrieved successfully\"\n    }\n\nRaises:\n    frappe.PermissionError: If user lacks required role",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  },
                  "sort_order": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/approvals.get_my_submitted_quotes": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.get_my_submitted_quotes",
        "summary": "Get quotes submitted by the current user (Estimator's \"My Submissions\" view)",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v3.52: Returns quotes that the current user has submitted for approval,\nalong with their current status and progress through the approval workflow.\nThis allows estimators to track their submitted quotes without seeing\nother users' quotes.\n\nArgs:\n    limit: Maximum number of quotes to return (default: 50)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"SAL-QTN-2025-00123\",\n                \"customer\": \"Acme Manufacturing\",\n                \"grand_total\": 45000.0,\n                \"transaction_date\": \"2025-01-10\",\n                \"submitted_at\": \"2025-01-01T11:00:00\",\n                \"workflow_state\": \"Pending Both\",\n                \"status\": \"Draft\",\n                \"custom_engineering_approved_at\": null,\n                \"custom_accounting_approved_at\": null,\n                \"custom_engineering_review_required\": true,\n                \"days_pending\": 3,\n                \"priority\": \"High\",\n                \"custom_liability_category\": \"High\"\n            }\n        ],\n        \"count\": 5,\n        \"message\": \"Your submitted quotes retrieved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  },
                  "sort_order": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/approvals.get_ordered_quotes": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.get_ordered_quotes",
        "summary": "Get quotes that have been converted to Sales Orders.",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v4.9: NEW - Ordered track for successfully converted quotes.\nReturns quotes that have linked Sales Orders, showing the outcome\nof the sales process (won business).\n\nA quote is considered \"ordered\" if a Sales Order exists that\nreferences any of its items via the quotation_item link.\n\nArgs:\n    location: Filter by location (optional)\n    limit: Maximum number of quotes to return (default: 50)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"SAL-QTN-2025-00123\",\n                \"title\": \"Steel Frame Assembly\",\n                \"customer\": \"Acme Manufacturing\",\n                \"grand_total\": 45000.0,\n                \"transaction_date\": \"2025-01-10\",\n                \"location\": \"Maple Ridge\",\n                \"custom_liability_category\": \"Standard\",\n                \"sales_order\": \"SAL-SORD-2025-00456\",\n                \"sales_order_date\": \"2025-01-20\",\n                \"sales_order_total\": 45000.0,\n                \"had_engineering_review\": true,\n                \"had_accounting_approval\": true,\n                \"submitted_by\": \"estimator@company.com\",\n                \"submitted_at\": \"2025-01-15T14:30:00\"\n            }\n        ],\n        \"count\": 5,\n        \"message\": \"Ordered quotes retrieved successfully\"\n    }\n\nRaises:\n    frappe.PermissionError: If user lacks required role",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  },
                  "sort_order": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/approvals.get_pending_accounting_approvals": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.get_pending_accounting_approvals",
        "summary": "Get quotes pending Accounting Approval",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v3.43: Dual-track approval workflow\nReturns quotes above the threshold that need admin/accounting sign-off.\nThese are quotes with:\n- grand_total >= quote_accounting_approval_threshold\n- custom_accounting_approved_at is not set\n- Not yet rejected\n\nArgs:\n    location: Filter by location (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"SAL-QTN-2025-00456\",\n                \"title\": \"Large Fabrication Project\",\n                \"customer\": \"Big Corp\",\n                \"grand_total\": 75000.0,\n                \"submitted_by\": \"estimator@company.com\",\n                \"submitted_at\": \"2025-11-01T11:00:00\",\n                \"days_pending\": 2,\n                \"priority\": \"Medium\",\n                \"pending_tracks\": [\"accounting\"],\n                \"engineering_approved\": true,\n                \"accounting_approved\": false\n            }\n        ],\n        \"count\": 3,\n        \"message\": \"Pending accounting approvals retrieved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  },
                  "sort_order": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/approvals.get_pending_approvals": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.get_pending_approvals",
        "summary": "Get quotes pending approval",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves pending approvals\nKISS: Simple query with context enrichment\nDRY: Reuses helper functions\n\nFeatures:\n- Filtered by approval authority for the current workflow state\n- Explicit approver behaves the same as implicit current user selection\n- Shows seeded assignee as a routing hint without hiding actionable quotes\n- Includes days pending, priority, and context\n- Location-aware filtering (multi-location support)\n\nArgs:\n    approver: Optional specific approver email (defaults to current user)\n    location: Filter by location (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"QTN-00123\",\n                \"title\": \"Steel Frame Assembly\",\n                \"customer\": \"Acme Manufacturing\",\n                \"grand_total\": 45000.0,\n                \"submitted_by\": \"estimator@company.com\",\n                \"submitted_at\": \"2025-11-01T11:00:00\",\n                \"days_pending\": 3,\n                \"priority\": \"High\",\n                \"requires_my_approval\": true,\n                \"location\": \"Maple Ridge\"\n            }\n        ],\n        \"message\": \"Pending approvals retrieved successfully\",\n        \"count\": 5\n    }\n\nRaises:\n    frappe.PermissionError: If user lacks required role",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "approver": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  },
                  "sort_order": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/approvals.get_pending_engineering_reviews": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.get_pending_engineering_reviews",
        "summary": "Get quotes pending Engineering Review",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v3.43: Dual-track approval workflow\nReturns quotes that need technical validation from engineering team.\nThese are quotes with:\n- custom_engineering_review_required = 1\n- custom_engineering_approved_at is not set\n- Not yet rejected\n\nArgs:\n    location: Filter by location (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"SAL-QTN-2025-00123\",\n                \"title\": \"Steel Frame Assembly\",\n                \"customer\": \"Acme Manufacturing\",\n                \"grand_total\": 45000.0,\n                \"submitted_by\": \"estimator@company.com\",\n                \"submitted_at\": \"2025-11-01T11:00:00\",\n                \"days_pending\": 3,\n                \"priority\": \"High\",\n                \"pending_tracks\": [\"engineering\"],\n                \"engineering_approved\": false,\n                \"accounting_approved\": null\n            }\n        ],\n        \"count\": 5,\n        \"message\": \"Pending engineering reviews retrieved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  },
                  "sort_order": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/approvals.get_sent_to_customer_quotes": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.get_sent_to_customer_quotes",
        "summary": "Get quotes that have been sent to customer, awaiting PO/response.",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v4.8: NEW - Sent to Customer track for approved quotes that have been\ndelivered to customers and are awaiting their response.\n\nReturns quotes with:\n- Quote metadata (name, customer, grand_total)\n- Days since sent\n- Sent date (custom_sent_to_customer_at)\n- Sent by (custom_sent_to_customer_by)\n- Priority (based on value + age)\n- Sales Order link (has_sales_order, sales_order_name)\n- Actions available (withdraw, convert_to_sales_order)\n\nArgs:\n    location: Filter by location (optional)\n    limit: Maximum number of quotes to return (default: 50)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"SAL-QTN-2025-00123\",\n                \"title\": \"Steel Frame Assembly\",\n                \"customer\": \"Acme Manufacturing\",\n                \"grand_total\": 45000.0,\n                \"transaction_date\": \"2025-01-10\",\n                \"sent_to_customer_at\": \"2025-01-15T14:30:00\",\n                \"sent_to_customer_by\": \"estimator@company.com\",\n                \"days_since_sent\": 5,\n                \"priority\": \"High\",\n                \"has_sales_order\": false,\n                \"sales_order_name\": null,\n                \"location\": \"Maple Ridge\",\n                \"custom_liability_category\": \"Standard\"\n            }\n        ],\n        \"count\": 5,\n        \"message\": \"Sent to customer quotes retrieved successfully\"\n    }\n\nRaises:\n    frappe.PermissionError: If user lacks required role",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  },
                  "sort_order": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/approvals.mark_quote_as_lost": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.mark_quote_as_lost",
        "summary": "Mark a \"Sent to Customer\" quote as lost.",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v4.8: NEW - Allows marking sent quotes as lost when customer declines.\nSets workflow_state to \"Lost\" and creates audit trail.\nQuote remains in audit history but is filtered out of active tabs.\n\nArgs:\n    quote_id: Quote to mark as lost\n    lost_reason: Optional reason for marking as lost\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"quote_id\": \"SAL-QTN-2025-00123\",\n            \"status\": \"Lost\",\n            \"marked_by\": \"user@company.com\",\n            \"marked_at\": \"2025-01-15T14:30:00\",\n            \"lost_reason\": \"Customer went with competitor\"\n        },\n        \"message\": \"Quote marked as lost\"\n    }\n\nRaises:\n    frappe.ValidationError: If quote is not in \"Sent to Customer\" status\n    frappe.PermissionError: If user lacks required role",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_id": {
                    "type": "string"
                  },
                  "lost_reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "quote_id"
                ]
              }
            }
          }
        }
      }
    },
    "/approvals.reject_accounting_approval": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.reject_accounting_approval",
        "summary": "Reject accounting approval for a quote",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v4.7: Uses cancel+amend workflow\n- Original quote is cancelled (docstatus=2) for audit trail\n- New draft quote is created for revisions\n\nv3.56: Simplified using consolidated helpers\nMarks the quote as rejected due to accounting/financial concerns.\n\nArgs:\n    quote_id: Quote to reject\n    reason: Rejection reason (required, min 10 chars)\n    suggested_changes: Optional suggestions for improvement\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"quote_id\": \"SAL-QTN-2025-00456\",\n            \"new_quote_id\": \"SAL-QTN-2025-00457\",\n            \"track\": \"accounting\",\n            \"approved\": false,\n            \"rejected_by\": \"admin@company.com\",\n            \"rejected_at\": \"2025-11-15T14:30:00\",\n            \"reason\": \"Margin too low for project risk\"\n        },\n        \"message\": \"Accounting approval rejected - new draft created\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "suggested_changes": {
                    "type": "string"
                  }
                },
                "required": [
                  "quote_id",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/approvals.reject_engineering_review": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.reject_engineering_review",
        "summary": "Reject engineering review for a quote (Admin Only)",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v6.5: Restricted to Admin role for hospital-grade access control\nv4.7: Uses cancel+amend workflow\n- Original quote is cancelled (docstatus=2) for audit trail\n- New draft quote is created for revisions\n\nv3.56: Simplified using consolidated helpers\nMarks the quote as rejected due to engineering concerns.\n\nArgs:\n    quote_id: Quote to reject\n    reason: Rejection reason (required, min 10 chars)\n    suggested_changes: Optional suggestions for improvement\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"quote_id\": \"SAL-QTN-2025-00123\",\n            \"new_quote_id\": \"SAL-QTN-2025-00124\",\n            \"track\": \"engineering\",\n            \"approved\": false,\n            \"rejected_by\": \"admin@company.com\",\n            \"rejected_at\": \"2025-11-15T14:30:00\",\n            \"reason\": \"Technical feasibility concerns\"\n        },\n        \"message\": \"Engineering review rejected - new draft created\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "suggested_changes": {
                    "type": "string"
                  }
                },
                "required": [
                  "quote_id",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/approvals.reject_quote": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.reject_quote",
        "summary": "Backward-compatible single-track rejection endpoint.",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Routes to engineering/accounting rejection based on explicit `track` or\nquote review status.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_id": {
                    "type": "string"
                  },
                  "rejection_reason": {
                    "type": "string"
                  },
                  "suggested_changes": {
                    "type": "string"
                  },
                  "track": {
                    "type": "string"
                  }
                },
                "required": [
                  "quote_id",
                  "rejection_reason"
                ]
              }
            }
          }
        }
      }
    },
    "/approvals.withdraw_quote_submission": {
      "post": {
        "operationId": "pacific_bending_app.api.approvals.withdraw_quote_submission",
        "summary": "Withdraw a quote from the approval workflow.",
        "tags": [
          "Approvals"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v4.10: Refactored to use centralized QuotationWorkflow service.\n- Handles snapshots, audit trail, and cancel+amend logic.\n- Supports withdrawal from Pending, Approved, and Sent to Customer states.\n\nArgs:\n    quote_id: Quote to withdraw\n    reason: Justification for withdrawal\n\nReturns:\n    Standard API response with new draft ID",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "quote_id"
                ]
              }
            }
          }
        }
      }
    },
    "/auth.change_password": {
      "post": {
        "operationId": "pacific_bending_app.api.auth.change_password",
        "summary": "Change password for the current authenticated user.",
        "tags": [
          "Auth"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Wrapper over Frappe core `update_password` to keep frontend on app-owned API surface.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "current_password": {
                    "type": "string"
                  },
                  "new_password": {
                    "type": "string"
                  },
                  "logout_other_sessions": {
                    "type": "string"
                  }
                },
                "required": [
                  "current_password",
                  "new_password"
                ]
              }
            }
          }
        }
      }
    },
    "/auth.get_oauth_userinfo": {
      "post": {
        "operationId": "pacific_bending_app.api.auth.get_oauth_userinfo",
        "summary": "Custom OAuth userinfo endpoint for NextAuth integration.",
        "tags": [
          "Auth"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This endpoint returns user profile information with ALL roles as an array,\nwhich is required by NextAuth's profile() callback.\n\nAuthentication: OAuth Bearer token (handled by Frappe automatically)\n\nThe @frappe.whitelist() decorator allows this endpoint to be called with\nan OAuth Bearer token. Frappe validates the token and sets frappe.session.user.\n\nReturns:\n    {\n        \"sub\": \"user@example.com\",\n        \"user_id\": \"user@example.com\",\n        \"email\": \"user@example.com\",\n        \"name\": \"John Smith\",\n        \"full_name\": \"John Smith\",\n        \"roles\": [\"Admin\", \"Foreman\"],\n        \"permissions\": [\"read\", \"write\", ...]\n    }\n\nUsage:\n    Set ERPNEXT_OAUTH_USERINFO_URL to:\n    https://api.pacific-bending.com/api/method/pacific_bending_app.api.auth.get_oauth_userinfo"
      }
    },
    "/auth.request_password_reset": {
      "post": {
        "operationId": "pacific_bending_app.api.auth.request_password_reset",
        "summary": "Request a password reset email for a user account.",
        "tags": [
          "Auth"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Security best practice:\n- Always return a generic success message to prevent account enumeration.\n- Rate-limit guest calls to reduce abuse.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  }
                },
                "required": [
                  "email"
                ]
              }
            }
          }
        }
      }
    },
    "/bom_config.delete_qc_stage": {
      "post": {
        "operationId": "pacific_bending_app.api.bom_config.delete_qc_stage",
        "summary": "Soft delete a QC stage (sets active=0).",
        "tags": [
          "Bom Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    code: QC stage code to delete\n    force: If True, permanently delete (default: False)",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "force": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "code"
                ]
              }
            }
          }
        }
      }
    },
    "/bom_config.get_qc_stages": {
      "post": {
        "operationId": "pacific_bending_app.api.bom_config.get_qc_stages",
        "summary": "Get all QC stages for BOM templates.",
        "tags": [
          "Bom Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    active_only: If True, only return active QC stages (default: True)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\"code\": \"before_processing\", \"label\": \"Before Processing\", \"display_order\": 1, \"active\": true}\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active_only": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/bom_config.save_qc_stage": {
      "post": {
        "operationId": "pacific_bending_app.api.bom_config.save_qc_stage",
        "summary": "Create or update a QC stage.",
        "tags": [
          "Bom Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    qc_stage: JSON string of QC stage configuration\n        {\"code\": \"before_processing\", \"label\": \"Before Processing\", \"display_order\": 1, \"active\": true}\n\nReturns:\n    {\"success\": True, \"data\": {...}, \"message\": \"QC stage saved\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "qc_stage": {
                    "type": "string"
                  }
                },
                "required": [
                  "qc_stage"
                ]
              }
            }
          }
        }
      }
    },
    "/bom_config.seed_qc_stages": {
      "post": {
        "operationId": "pacific_bending_app.api.bom_config.seed_qc_stages",
        "summary": "Seed standard QC stages for BOM templates.",
        "tags": [
          "Bom Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Idempotent: Safe to run multiple times, will skip existing.\n\nCreates 6 standard QC stages.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/carbone_api.backup_templates": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.backup_templates",
        "summary": "Export all Carbone Templates to a directory for Git backup (Admin only)",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Creates a backup of all active templates with:\n- Template files organized by DocType\n- JSON metadata file with template info\n\nArgs:\n    output_dir: Optional output directory (defaults to carbone-templates-backup/)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"templates_exported\": 5,\n            \"output_dir\": \"/path/to/backup\",\n            \"files\": [\"quotation/Default.docx\", ...]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "output_dir": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/carbone_api.carbone_health_check": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.carbone_health_check",
        "summary": "Check Carbone service health and storage metrics",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"carbone\": {\"status\": \"healthy\", \"url\": \"...\"},\n            \"mappers\": [\"Quotation\", \"Work Order\", ...],\n            \"template_count\": 5,\n            \"storage\": {\n                \"generated_docs_count\": 150,\n                \"generated_docs_size_mb\": 75.5,\n                \"oldest_file_days\": 28,\n                \"retention_days\": 30\n            }\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/carbone_api.carbone_pdf_converter_check": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.carbone_pdf_converter_check",
        "summary": "Verify PDF conversion is working for all template types",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Tests that Carbone's PDF converters are operational by checking\nthe service status and attempting a simple render test if available.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"carbone_status\": {\"status\": \"healthy\", ...},\n            \"pdf_conversion_supported\": true,\n            \"converters_status\": {\n                \"libreoffice\": \"available\",\n                \"onlyoffice\": \"not_configured\"\n            },\n            \"supported_conversions\": [\"docx:pdf\", \"odt:pdf\", \"html:pdf\", ...]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin"
        ]
      }
    },
    "/carbone_api.delete_template": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.delete_template",
        "summary": "Delete a document template (Admin only)",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Deletes the Carbone Template DocType record. The associated file\nin Frappe File system is also deleted. Carbone auto-cleans unused\ntemplates, so no explicit delete to Carbone service is needed.\n\nArgs:\n    template_id: Carbone Template DocType name (e.g., \"TPL-QTN-0001\")\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Template deleted successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "template_id"
                ]
              }
            }
          }
        }
      }
    },
    "/carbone_api.download_template": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.download_template",
        "summary": "Download the original template file (DOCX, ODT, etc.)",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns a URL to download the template file stored in Frappe File system.\nThis allows users to download templates for editing in their preferred\nword processor before re-uploading.\n\nArgs:\n    template_id: Carbone Template DocType name (e.g., \"TPL-QTN-0001\")\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"file_url\": \"/private/files/templates/quotation_default.docx\",\n            \"file_name\": \"quotation_default.docx\",\n            \"file_extension\": \"docx\",\n            \"template_name\": \"Default\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Shop Floor",
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "template_id"
                ]
              }
            }
          }
        }
      }
    },
    "/carbone_api.email_document": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.email_document",
        "summary": "Generate PDF and email it to recipients",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    doc_type: DocType name (e.g., \"Quotation\")\n    doc_id: Document name (e.g., \"QTN-00042\")\n    recipients: Comma-separated email addresses\n    subject: Email subject\n    body: Email body (plain text or HTML)\n    template_name: Template name (e.g., \"Default\") - uses default if not specified\n    template_id: Carbone Template DocType ID - overrides template_name\n    cc: Comma-separated CC recipients (optional)\n    bcc: Comma-separated BCC recipients (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"recipients\": [\"user@example.com\"],\n            \"pdf_attached\": True,\n            \"communication_id\": \"COMM-00001\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doc_type": {
                    "type": "string"
                  },
                  "doc_id": {
                    "type": "string"
                  },
                  "recipients": {
                    "type": "string"
                  },
                  "subject": {
                    "type": "string"
                  },
                  "body": {
                    "type": "string"
                  },
                  "template_name": {
                    "type": "string"
                  },
                  "template_id": {
                    "type": "string"
                  },
                  "cc": {
                    "type": "string"
                  },
                  "bcc": {
                    "type": "string"
                  }
                },
                "required": [
                  "doc_type",
                  "doc_id",
                  "recipients",
                  "subject"
                ]
              }
            }
          }
        }
      }
    },
    "/carbone_api.get_available_variables": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.get_available_variables",
        "summary": "Get available template variables for document types",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    doc_type: Optional DocType filter\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"Quotation\": {\n                \"header\": [\"quote_number\", \"customer_name\", ...],\n                \"items\": [\"item_code\", \"qty\", \"rate\", ...],\n                \"computed\": [\"grand_total\", \"item_count\", ...]\n            }\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Shop Floor",
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doc_type": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/carbone_api.get_document_data": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.get_document_data",
        "summary": "Get Carbone-compatible JSON for a document",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Useful for testing templates in Carbone Studio.\n\nArgs:\n    doc_type: DocType name\n    doc_id: Document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": { ... Carbone JSON payload ... }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Shop Floor",
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doc_type": {
                    "type": "string"
                  },
                  "doc_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "doc_type",
                  "doc_id"
                ]
              }
            }
          }
        }
      }
    },
    "/carbone_api.get_supported_extensions": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.get_supported_extensions",
        "summary": "Get list of supported template file extensions",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"extensions\": [\"docx\", \"odt\", \"xlsx\", \"ods\", \"pptx\", \"odp\", \"html\"],\n            \"by_type\": {\n                \"document\": [\"docx\", \"odt\"],\n                \"spreadsheet\": [\"xlsx\", \"ods\"],\n                \"presentation\": [\"pptx\", \"odp\"],\n                \"web\": [\"html\"]\n            }\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ]
      }
    },
    "/carbone_api.get_template_counts_summary": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.get_template_counts_summary",
        "summary": "Return lightweight template counts for tab badges and page-level summaries.",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Shop Floor",
          "Admin"
        ]
      }
    },
    "/carbone_api.get_template_info": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.get_template_info",
        "summary": "Get detailed template information",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    doc_type: DocType name\n    template_name: Template name\n\nReturns:\n    Template info dict",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doc_type": {
                    "type": "string"
                  },
                  "template_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "doc_type"
                ]
              }
            }
          }
        }
      }
    },
    "/carbone_api.import_templates": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.import_templates",
        "summary": "Import Carbone Templates from a backup directory (Admin only)",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Reads templates from a backup directory created by backup_templates()\nand creates/updates Carbone Template DocType records.\n\nArgs:\n    input_dir: Directory containing backup (must have templates.json)\n    overwrite: If True, overwrite existing templates with same name/doctype\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"templates_imported\": 5,\n            \"skipped\": 2,\n            \"errors\": []\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "input_dir": {
                    "type": "string"
                  },
                  "overwrite": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "input_dir"
                ]
              }
            }
          }
        }
      }
    },
    "/carbone_api.list_templates": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.list_templates",
        "summary": "List available uploaded/synced document templates from Carbone Template DocType",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    doc_type: Optional DocType filter (Quotation, Sales Invoice, etc.)\n    location: Optional parent warehouse (location) filter.\n              If provided, returns location-specific + global templates.\n    search: Optional server-side text search across template id/name/description.\n    limit_page_length: Optional page size for paginated responses.\n    limit_start: Optional offset for paginated responses.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"TPL-QTN-0001\",\n                \"template_name\": \"Default\",\n                \"doc_type\": \"Quotation\",\n                \"file_extension\": \"docx\",\n                \"is_default\": 1,\n                \"is_active\": 1,\n                \"carbone_template_id\": \"abc123...\",\n                \"description\": \"Default quotation template\",\n                \"location\": \"Maple Ridge - PB\"\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Shop Floor",
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doc_type": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "search": {
                    "type": "string"
                  },
                  "limit_page_length": {
                    "type": "integer"
                  },
                  "limit_start": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/carbone_api.manual_cleanup_generated_documents": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.manual_cleanup_generated_documents",
        "summary": "Manual cleanup of generated documents (Admin only)",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Immediately removes generated documents older than the specified retention period.\nUseful for immediate cleanup without waiting for the daily scheduled task.\n\nArgs:\n    older_than_days: Override retention period (default: uses Pacific Bending Settings value)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"deleted\": 42,\n            \"errors\": 0,\n            \"skipped\": 108,\n            \"total_bytes_freed\": 21504000,\n            \"mb_freed\": 20.5\n        },\n        \"message\": \"Deleted 42 files (20.5 MB)\"\n    }\n\nNOTE: Rate limited to 5 calls per hour to prevent accidental bulk deletion.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "older_than_days": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/carbone_api.preview_quotation": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.preview_quotation",
        "summary": "Generate PDF preview from form data without saving to database.",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "For use during quote creation before first save, enabling live preview\nas the user fills out the form.\n\nArgs:\n    form_data: JSON string of quotation form data matching QuotationFormData schema\n    template_name: Template name (e.g., \"Default\") - uses default if not specified\n    template_id: Carbone Template DocType ID - overrides template_name\n    return_inline: If True, return PDF as base64 instead of saving to file.\n                  Use this for cross-domain iframe previews to avoid cookie issues.\n\nReturns:\n    When return_inline=False (default):\n    {\n        \"success\": True,\n        \"data\": {\n            \"file_url\": \"/private/files/generated_docs/preview_xxx.pdf\",\n            \"file_name\": \"preview_xxx.pdf\"\n        }\n    }\n\n    When return_inline=True:\n    {\n        \"success\": True,\n        \"data\": {\n            \"pdf_base64\": \"<base64-encoded-pdf>\",\n            \"file_name\": \"preview_xxx.pdf\",\n            \"content_type\": \"application/pdf\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "form_data": {
                    "type": "string"
                  },
                  "template_name": {
                    "type": "string"
                  },
                  "template_id": {
                    "type": "string"
                  },
                  "return_inline": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "form_data"
                ]
              }
            }
          }
        }
      }
    },
    "/carbone_api.render_document": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.render_document",
        "summary": "Generate document using Carbone",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    doc_type: ERPNext DocType name (e.g., \"Quotation\")\n    doc_id: Document name (e.g., \"QTN-00042\")\n    template_name: Template name (e.g., \"Default\") - uses default if not specified\n    template_id: Carbone Template DocType ID (e.g., \"TPL-QTN-0001\") - overrides template_name\n    output_format: Output format - pdf, docx, odt (default: \"pdf\")\n    custom_filename: Custom filename for download (optional)\n    return_inline: If True, return document as base64 instead of saving to file.\n                  Use this for cross-domain iframe previews to avoid cookie issues.\n\nReturns:\n    When return_inline=False (default):\n    {\n        \"success\": True,\n        \"data\": {\n            \"file_url\": \"/private/files/generated_docs/QTN-00042.pdf\",\n            \"file_name\": \"QTN-00042.pdf\",\n            \"size_bytes\": 12345,\n            \"template_used\": \"TPL-QTN-0001\"\n        }\n    }\n\n    When return_inline=True:\n    {\n        \"success\": True,\n        \"data\": {\n            \"pdf_base64\": \"<base64-encoded-document>\",\n            \"file_name\": \"QTN-00042.pdf\",\n            \"content_type\": \"application/pdf\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Shop Floor",
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doc_type": {
                    "type": "string"
                  },
                  "doc_id": {
                    "type": "string"
                  },
                  "template_name": {
                    "type": "string"
                  },
                  "template_id": {
                    "type": "string"
                  },
                  "output_format": {
                    "type": "string"
                  },
                  "custom_filename": {
                    "type": "string"
                  },
                  "return_inline": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "doc_type",
                  "doc_id"
                ]
              }
            }
          }
        }
      }
    },
    "/carbone_api.set_default_template": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.set_default_template",
        "summary": "Set a template as the default for its DocType (Admin only)",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Updates the is_default flag on the Carbone Template DocType record.\nAutomatically clears is_default on other templates for the same DocType.\n\nArgs:\n    template_id: Carbone Template DocType name (e.g., \"TPL-QTN-0001\")\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Default template updated\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "template_id"
                ]
              }
            }
          }
        }
      }
    },
    "/carbone_api.upload_template": {
      "post": {
        "operationId": "pacific_bending_app.api.carbone_api.upload_template",
        "summary": "Upload a new document template (Admin only)",
        "tags": [
          "Carbone Api"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Creates a Carbone Template DocType record which:\n- Stores the file in Frappe File system (backup)\n- Automatically uploads to Carbone service\n- Stores the Carbone template_id for rendering\n\nArgs:\n    doc_type: DocType name (Quotation, Sales Invoice, etc.)\n    template_name: Human-readable template name (e.g., \"Default\", \"Detailed\")\n    file_url: URL to an already-uploaded ERPNext File record\n    file_extension: Carbone-supported extension (auto-detected from file_url when omitted)\n    description: Optional description of the template\n    is_default: Set as default template for this DocType\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"template_id\": \"TPL-QTN-0001\",\n            \"carbone_template_id\": \"abc123...\",\n            \"size_bytes\": 12345\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doc_type": {
                    "type": "string"
                  },
                  "template_name": {
                    "type": "string"
                  },
                  "file_url": {
                    "type": "string"
                  },
                  "file_extension": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "is_default": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "doc_type",
                  "template_name"
                ]
              }
            }
          }
        }
      }
    },
    "/consumption.get_consumption_by_class": {
      "post": {
        "operationId": "pacific_bending_app.api.consumption.get_consumption_by_class",
        "summary": "Get aggregated consumption by class (Foreman/Admin only).",
        "tags": [
          "Consumption"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    date_from: Start date\n    date_to: End date\n    location: Filter by location\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"Use\": {\"count\": 150, \"total_qty\": 450.5},\n            \"Scrap\": {\"count\": 25, \"total_qty\": 75.2},\n            ...\n        },\n        \"message\": \"Consumption summary retrieved\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/consumption.get_consumption_for_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.consumption.get_consumption_for_batch",
        "summary": "Get all consumption records for a specific batch.",
        "tags": [
          "Consumption"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    batch_id: Batch ID\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PM20250001\",\n            \"total_consumed\": 45.5,\n            \"consumption_by_class\": {...},\n            \"records\": [...]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/consumption.get_consumption_history": {
      "post": {
        "operationId": "pacific_bending_app.api.consumption.get_consumption_history",
        "summary": "Get consumption history with filters.",
        "tags": [
          "Consumption"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Shop Floor users can only see their own consumption.\nForeman/Admin can see all consumption.\n\nArgs:\n    batch_id: Filter by batch\n    item_code: Filter by item\n    consumption_class: Filter by class\n    work_order: Filter by work order\n    user: Filter by user (Foreman/Admin only)\n    date_from: Filter by date range start\n    date_to: Filter by date range end\n    include_voided: Include voided records\n    search: Optional free-text search across ID/item/batch/user/work order\n    limit: Max records (default 50)\n    offset: Pagination offset\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": [...],\n        \"count\": 25,\n        \"total\": 150,\n        \"message\": \"Retrieved 25 consumption records\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "item_code": {
                    "type": "string"
                  },
                  "consumption_class": {
                    "type": "string"
                  },
                  "work_order": {
                    "type": "string"
                  },
                  "user": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  },
                  "include_voided": {
                    "type": "boolean"
                  },
                  "search": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/consumption.get_my_consumption": {
      "post": {
        "operationId": "pacific_bending_app.api.consumption.get_my_consumption",
        "summary": "Get current user's recent consumption records.",
        "tags": [
          "Consumption"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    consumption_class: Filter by class (optional)\n    limit: Max records (default 20)\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": [...],\n        \"count\": 15,\n        \"message\": \"Retrieved 15 consumption records\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "consumption_class": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/consumption.record_consumption": {
      "post": {
        "operationId": "pacific_bending_app.api.consumption.record_consumption",
        "summary": "Unified material consumption endpoint for both batch and non-batch items.",
        "tags": [
          "Consumption"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Creates a Material Consumption Log record and a Stock Entry (Material Issue)\nto decrement inventory. For batch items with line items, also decrements\nthe line item's available_qty.\n\nBehavior:\n- If batch_id provided \u2192 consume from batch (with reservation checking)\n- If batch_id not provided \u2192 direct warehouse consumption\n\nArgs:\n    item_code: Item to consume (REQUIRED)\n    warehouse: Source warehouse (REQUIRED)\n    quantity: Number of pieces/units to consume (REQUIRED)\n    consumption_class: Type of consumption (REQUIRED) - Use, Scrap, Damage, Missing, Return to Vendor, Sample/Testing\n    batch_id: Batch to consume from (optional - required for batch-tracked items)\n    batch_line_idx: Line item index for multi-piece batches (0-based, optional)\n    work_order: Optional Work Order reference\n    job_card: Optional Job Card reference\n    reason: Required for Scrap/Damage/Missing/Return to Vendor classes\n    notes: Additional notes\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"consumption_id\": \"MCL-2025-00001\",\n            \"item_code\": \"CS-SQT-2X2X14GA\",\n            \"batch_id\": \"PM20250001\",  // null for non-batch items\n            \"quantity\": 2,\n            \"consumption_class\": \"Use\",\n            \"stock_entry\": \"STE-00123\",\n            \"remaining_qty\": 8\n        },\n        \"message\": \"Recorded consumption of 2 pcs\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "warehouse": {
                    "type": "string"
                  },
                  "quantity": {
                    "type": "number"
                  },
                  "consumption_class": {
                    "type": "string"
                  },
                  "batch_id": {
                    "type": "string"
                  },
                  "batch_line_idx": {
                    "type": "string"
                  },
                  "item_variant_id": {
                    "type": "string"
                  },
                  "work_order": {
                    "type": "string"
                  },
                  "job_card": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code",
                  "warehouse",
                  "quantity",
                  "consumption_class"
                ]
              }
            }
          }
        }
      }
    },
    "/consumption.void_consumption": {
      "post": {
        "operationId": "pacific_bending_app.api.consumption.void_consumption",
        "summary": "Void a consumption record (Admin only).",
        "tags": [
          "Consumption"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Creates a reverse Stock Entry to restore inventory.\nDoes NOT delete the record - keeps it for audit trail.\n\nArgs:\n    consumption_id: Consumption ID to void\n    reason: Reason for voiding\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"consumption_id\": \"MCL-2025-00001\",\n            \"voided_by\": \"admin@example.com\",\n            \"reverse_stock_entry\": \"STE-00124\"\n        },\n        \"message\": \"Consumption voided successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "consumption_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "consumption_id"
                ]
              }
            }
          }
        }
      }
    },
    "/crm_tags.create_contact_tag_category": {
      "post": {
        "operationId": "pacific_bending_app.api.crm_tags.create_contact_tag_category",
        "summary": "Create a new contact tag category.",
        "tags": [
          "Crm Tags"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "category": {
                    "type": "string"
                  }
                },
                "required": [
                  "category"
                ]
              }
            }
          }
        }
      }
    },
    "/crm_tags.create_customer_tag_category": {
      "post": {
        "operationId": "pacific_bending_app.api.crm_tags.create_customer_tag_category",
        "summary": "Create a new customer tag category.",
        "tags": [
          "Crm Tags"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "category": {
                    "type": "string"
                  }
                },
                "required": [
                  "category"
                ]
              }
            }
          }
        }
      }
    },
    "/crm_tags.create_lead_tag_category": {
      "post": {
        "operationId": "pacific_bending_app.api.crm_tags.create_lead_tag_category",
        "summary": "Create a new lead tag category.",
        "tags": [
          "Crm Tags"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "category": {
                    "type": "string"
                  }
                },
                "required": [
                  "category"
                ]
              }
            }
          }
        }
      }
    },
    "/crm_tags.get_active_contact_tags": {
      "post": {
        "operationId": "pacific_bending_app.api.crm_tags.get_active_contact_tags",
        "summary": "Get active contact tag categories for filtering/selection.",
        "tags": [
          "Crm Tags"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/crm_tags.get_active_customer_tags": {
      "post": {
        "operationId": "pacific_bending_app.api.crm_tags.get_active_customer_tags",
        "summary": "Get active customer tag categories for filtering/selection.",
        "tags": [
          "Crm Tags"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/crm_tags.get_active_lead_tags": {
      "post": {
        "operationId": "pacific_bending_app.api.crm_tags.get_active_lead_tags",
        "summary": "Get active lead tag categories for filtering/selection.",
        "tags": [
          "Crm Tags"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/customers.check_order_eligibility": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.check_order_eligibility",
        "summary": "Check if order is eligible (credit + COD deposit).",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Pre-submit validation for frontend.\n\nArgs:\n    customer: Customer ID\n    order_amount: Order total amount\n    company: Company name (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"allowed\": True,\n            \"admin_override\": False,\n            \"deposit_required\": True,\n            \"deposit_amount\": 2500.00,\n            \"warnings\": []\n        },\n        \"message\": \"Order eligibility checked successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string"
                  },
                  "order_amount": {
                    "type": "number"
                  },
                  "company": {
                    "type": "string"
                  }
                },
                "required": [
                  "customer",
                  "order_amount"
                ]
              }
            }
          }
        }
      }
    },
    "/customers.get_contacts_list": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.get_contacts_list",
        "summary": "Get paginated contact list with company names enriched.",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This endpoint solves two problems:\n1. Company names are fetched via Dynamic Link join (not available in standard REST API)\n2. Search is server-side across multiple fields (first_name, last_name, email_id, designation)\n\nArgs:\n    search: Search term for multi-field OR search (optional)\n    limit_start: Pagination offset (default: 0)\n    limit_page_length: Page size (default: 25, max: 100)\n    order_by: Sort order (default: \"first_name asc\")\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"contacts\": [\n                {\n                    \"name\": \"Contact-001\",\n                    \"first_name\": \"John\",\n                    \"last_name\": \"Doe\",\n                    \"full_name\": \"John Doe\",\n                    \"email_id\": \"john@example.com\",\n                    \"phone\": \"+1-555-0100\",\n                    \"mobile_no\": \"+1-555-0101\",\n                    \"designation\": \"CEO\",\n                    \"department\": \"Executive\",\n                    \"is_primary_contact\": 1,\n                    \"is_billing_contact\": 0,\n                    \"status\": \"Open\",\n                    \"company_name\": \"Acme Manufacturing\"  # Enriched from Dynamic Link\n                }\n            ],\n            \"total\": 63,\n            \"limit_start\": 0,\n            \"limit_page_length\": 25\n        },\n        \"message\": \"Contacts retrieved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "search": {
                    "type": "string"
                  },
                  "limit_start": {
                    "type": "integer"
                  },
                  "limit_page_length": {
                    "type": "integer"
                  },
                  "order_by": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/customers.get_current_primary_contact": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.get_current_primary_contact",
        "summary": "Get the current primary contact for a customer.",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Useful for checking if a customer already has a primary contact\nbefore attempting to set a new one.\n\nArgs:\n    customer: Customer ID\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"name\": \"CONT-001\",\n            \"first_name\": \"John\",\n            \"last_name\": \"Doe\",\n            \"email_id\": \"john@example.com\",\n            \"designation\": \"CEO\"\n        } | null,\n        \"message\": \"Primary contact retrieved\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string"
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/customers.get_customer_contacts": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.get_customer_contacts",
        "summary": "Get all contacts linked to a customer via Dynamic Link",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "ERPNext stores Contact-Customer relationships in the Dynamic Link child table.\nThis endpoint provides access to that data which is not directly exposed via REST API.\n\nArgs:\n    customer: Customer ID (document name)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"Contact-001\",\n                \"first_name\": \"John\",\n                \"last_name\": \"Doe\",\n                \"full_name\": \"John Doe\",\n                \"email_id\": \"john@example.com\",\n                \"phone\": \"+1-555-0100\",\n                \"mobile_no\": \"+1-555-0101\",\n                \"designation\": \"CEO\",\n                \"is_primary_contact\": 1,\n                \"is_billing_contact\": 0\n            }\n        ],\n        \"message\": \"Contacts retrieved successfully\",\n        \"count\": 1\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string"
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/customers.get_customer_credit_status": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.get_customer_credit_status",
        "summary": "Get detailed credit status for a customer.",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    customer: Customer ID\n    company: Company name (optional, uses default if not provided)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"customer\": \"CUST-001\",\n            \"company\": \"Pacific Bending\",\n            \"credit_limit\": 50000.00,\n            \"credit_limit_active\": True,\n            \"outstanding_amount\": 12500.00,\n            \"credit_available\": 37500.00,\n            \"credit_utilization_percent\": 25.0,\n            \"is_over_limit\": False\n        },\n        \"message\": \"Credit status retrieved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string"
                  },
                  "company": {
                    "type": "string"
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/customers.get_customer_financial_summary": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.get_customer_financial_summary",
        "summary": "Get detailed financial summary for a specific customer",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves financial data for one customer\nKISS: Simple aggregation queries\n\nArgs:\n    customer: Customer ID\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"customer\": \"CUST-00123\",\n            \"customer_name\": \"Acme Manufacturing\",\n            \"outstanding_amount\": 12500.0,\n            \"credit_limit\": 50000.0,\n            \"credit_available\": 37500.0,\n            \"payment_history_score\": 85,\n            \"total_orders\": 45,\n            \"total_revenue\": 125000.0,\n            \"average_order_value\": 2777.78,\n            \"overdue_invoices\": 2,\n            \"days_overdue\": 15,\n            \"invoices\": [\n                {\n                    \"invoice_id\": \"INV-00456\",\n                    \"date\": \"2025-10-15\",\n                    \"due_date\": \"2025-11-14\",\n                    \"total\": 5000.0,\n                    \"outstanding\": 5000.0,\n                    \"status\": \"Overdue\"\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string"
                  }
                },
                "required": [
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/customers.get_customers_with_context": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.get_customers_with_context",
        "summary": "Get customers with full financial and relationship context",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves customer data with context\nKISS: Simple query with batch enrichment\nDRY: Reuses shared batch utility functions\n\nPerformance: Uses batch queries instead of N+1 pattern\n- Before: ~7-10 queries per customer (350+ queries for 50 customers)\n- After: 6 total queries regardless of customer count\n\nFeatures:\n- Outstanding amount (unpaid invoices)\n- Credit available (credit limit - outstanding)\n- Payment history score (0-100 based on on-time payments)\n- Overdue invoices count and days overdue\n- COD flag (custom field)\n- Customer relationship metrics (first order, total orders, total revenue)\n- Primary contact information\n\nArgs:\n    search: Search term for customer name (optional)\n    limit: Maximum customers to return (default: 50, max: 200)\n    location: Filter by location (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"CUST-00123\",\n                \"customer_name\": \"Acme Manufacturing\",\n                ...\n            }\n        ],\n        \"message\": \"Customers with context retrieved successfully\",\n        \"count\": 25\n    }\n\nRaises:\n    frappe.ValidationError: If limit exceeds 200",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "search": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "location": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/customers.get_payment_terms_summary": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.get_payment_terms_summary",
        "summary": "Get payment terms summary for customer.",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns payment terms, COD status, credit status\n\nArgs:\n    customer: Customer ID\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"payment_terms\": \"COD\",\n            \"is_cod\": True,\n            \"cod_deposit_required\": True,\n            \"credit_limit\": 50000.00,\n            \"credit_limit_active\": True\n        },\n        \"message\": \"Payment terms summary retrieved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/customers.get_primary_contacts_for_customers": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.get_primary_contacts_for_customers",
        "summary": "Get primary contacts for multiple customers in a single call",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This is optimized for the companies list page which needs to display\nthe primary contact for each company efficiently.\n\nArgs:\n    customers: List of Customer IDs\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"CUST-001\": {\n                \"name\": \"Contact-001\",\n                \"first_name\": \"John\",\n                \"last_name\": \"Doe\",\n                \"full_name\": \"John Doe\",\n                \"email_id\": \"john@example.com\",\n                \"designation\": \"CEO\",\n                \"is_primary_contact\": 1\n            },\n            \"CUST-002\": null  // No contact\n        },\n        \"message\": \"Primary contacts retrieved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customers": {
                    "type": "array"
                  }
                },
                "required": [
                  "customers"
                ]
              }
            }
          }
        }
      }
    },
    "/customers.link_contact_to_customer": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.link_contact_to_customer",
        "summary": "Link a contact to a customer via Dynamic Link",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This endpoint handles the ERPNext Dynamic Link pattern for Contact-Customer relationships.\nIt adds or updates the customer link in the contact's links child table.\n\nSecurity: Requires Estimator role or above (added Dec 30, 2025 audit)\n\nArgs:\n    contact: Contact ID (document name)\n    customer: Customer ID (document name)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Contact linked to customer successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact": {
                    "type": "string"
                  },
                  "customer": {
                    "type": "string"
                  }
                },
                "required": [
                  "contact",
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/customers.set_primary_contact": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.set_primary_contact",
        "summary": "Set a contact as the primary contact for a customer.",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "BEST PRACTICE: Ensures at most one primary contact per customer.\nAtomically unsets any existing primary contact before setting the new one.\n\nThis endpoint enforces the business rule that each customer can have\nat most one primary contact. When called:\n1. Finds all contacts linked to the customer\n2. Unsets is_primary_contact on all of them\n3. Sets is_primary_contact on the specified contact\n4. All in a single transaction (via @transactional decorator)\n\nArgs:\n    contact: Contact ID to set as primary\n    customer: Customer ID\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"contact\": \"CONT-001\",\n            \"customer\": \"CUST-001\",\n            \"previous_primary\": \"CONT-002\" | null\n        },\n        \"message\": \"Primary contact set successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact": {
                    "type": "string"
                  },
                  "customer": {
                    "type": "string"
                  }
                },
                "required": [
                  "contact",
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/customers.unlink_contact_from_customer": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.unlink_contact_from_customer",
        "summary": "Unlink a contact from a customer",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Removes the customer link from the contact's Dynamic Links.\n\nSecurity: Requires Estimator role or above (added Dec 30, 2025 audit)\n\nArgs:\n    contact: Contact ID (document name)\n    customer: Customer ID (document name)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Contact unlinked from customer successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact": {
                    "type": "string"
                  },
                  "customer": {
                    "type": "string"
                  }
                },
                "required": [
                  "contact",
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/customers.unset_primary_contact": {
      "post": {
        "operationId": "pacific_bending_app.api.customers.unset_primary_contact",
        "summary": "Unset a contact as primary for a customer.",
        "tags": [
          "Customers"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Simply clears the is_primary_contact flag without setting another.\nThe customer will have no primary contact after this operation.\n\nArgs:\n    contact: Contact ID to unset as primary\n    customer: Customer ID (for validation - contact must be linked)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Primary contact unset successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contact": {
                    "type": "string"
                  },
                  "customer": {
                    "type": "string"
                  }
                },
                "required": [
                  "contact",
                  "customer"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.amend_quotation": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.amend_quotation",
        "summary": "Create a new revision of an existing quotation.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_id": {
                    "type": "string"
                  },
                  "change_description": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.bulk_update_quote_items": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.bulk_update_quote_items",
        "summary": "Bulk update multiple quote line items at once.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_id": {
                    "type": "string"
                  },
                  "items": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_id",
                  "items"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.calculate_quote_pricing": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.calculate_quote_pricing",
        "summary": "Calculate pricing for quotation item.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "qty": {
                    "type": "number"
                  },
                  "operations": {
                    "type": "string"
                  },
                  "material_cost_override": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code",
                  "qty"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.compare_quotations": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.compare_quotations",
        "summary": "Compare two quotation revisions and return differences.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_id_1": {
                    "type": "string"
                  },
                  "quotation_id_2": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_id_1",
                  "quotation_id_2"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.convert_lead_to_customer": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.convert_lead_to_customer",
        "summary": "Convert Lead to Customer",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only handles lead conversion\nKISS: Simple, straightforward conversion logic\n\nArgs:\n    lead_id: Lead document name (e.g., \"LEAD-00001\")\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"customer_id\": \"CUST-00001\",\n        \"customer_name\": \"ABC Corp\"\n    }\n\nRaises:\n    frappe.DoesNotExistError: Lead not found\n    frappe.ValidationError: Lead already converted",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lead_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "lead_id"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.create_new_material_on_the_fly": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.create_new_material_on_the_fly",
        "summary": "Create new material or service item on-the-fly during quote creation",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only creates new items\nKISS: Simple item creation with essential fields\nDRY: Reuses validation decorators\n\nThis endpoint enables Estimators to create custom materials or services\nwithout leaving the quote builder, improving UX for custom jobs.\n\nArgs:\n    item_name: Item name (required, must be unique)\n    material: Material code (e.g., \"CS\", \"SS\", \"AL\") (optional, materials only)\n    shape: Shape (e.g., \"Plate\", \"Tube\", \"Bar\") (optional, materials only)\n    grade: Grade (e.g., \"A36\", \"304\", \"6061-T6\") (optional, materials only)\n    dimensions: Dimensions (e.g., \"6x10 feet\", \"2 inch diameter\") (optional, materials only)\n    standard_rate: Standard selling rate per unit (optional)\n    unit_system: Unit system for dimensions (\"Imperial\" or \"Metric\") (optional, defaults to \"Imperial\")\n    item_type: \"stock\" for materials or \"service\" for labor/services (optional, defaults to \"stock\")\n    stock_uom: Unit of measure (optional, defaults to \"Nos\" for stock, \"Hour\" for services)\n\nReturns:\n    Complete item dict with all fields\n\nRaises:\n    frappe.ValidationError: Item name already exists or invalid",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_name": {
                    "type": "string"
                  },
                  "material": {
                    "type": "string"
                  },
                  "shape": {
                    "type": "string"
                  },
                  "grade": {
                    "type": "string"
                  },
                  "dimensions": {
                    "type": "string"
                  },
                  "standard_rate": {
                    "type": "string"
                  },
                  "unit_system": {
                    "type": "string"
                  },
                  "item_type": {
                    "type": "string"
                  },
                  "stock_uom": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_name"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.create_quotation": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.create_quotation",
        "summary": "Create new quotation.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Phase 3: Multi-Location Support - Sets location on new quotations\nv3.42: Lead Support - Can now create quotes for Leads (not just Customers)",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "items": {
                    "type": "string"
                  },
                  "quotation_to": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string"
                  },
                  "lead_id": {
                    "type": "string"
                  },
                  "transaction_date": {
                    "type": "string"
                  },
                  "valid_till": {
                    "type": "string"
                  },
                  "estimated_lead_time_weeks": {
                    "type": "string"
                  },
                  "lead_time_unit": {
                    "type": "string"
                  },
                  "payment_terms_template": {
                    "type": "string"
                  },
                  "terms": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "warehouse": {
                    "type": "string"
                  },
                  "freight_mode": {
                    "type": "string"
                  },
                  "freight_zone": {
                    "type": "string"
                  },
                  "freight_total": {
                    "type": "string"
                  },
                  "contact_person": {
                    "type": "string"
                  },
                  "billing_address_line1": {
                    "type": "string"
                  },
                  "billing_address_line2": {
                    "type": "string"
                  },
                  "billing_city": {
                    "type": "string"
                  },
                  "billing_state": {
                    "type": "string"
                  },
                  "billing_country": {
                    "type": "string"
                  },
                  "billing_pincode": {
                    "type": "string"
                  },
                  "shipping_same_as_billing": {
                    "type": "string"
                  },
                  "shipping_address_line1": {
                    "type": "string"
                  },
                  "shipping_address_line2": {
                    "type": "string"
                  },
                  "shipping_city": {
                    "type": "string"
                  },
                  "shipping_state": {
                    "type": "string"
                  },
                  "shipping_country": {
                    "type": "string"
                  },
                  "shipping_pincode": {
                    "type": "string"
                  },
                  "custom_liability_category": {
                    "type": "string"
                  },
                  "custom_engineering_review_required": {
                    "type": "string"
                  },
                  "custom_total_taxes": {
                    "type": "string"
                  },
                  "custom_total_charges": {
                    "type": "string"
                  },
                  "custom_cod_flag": {
                    "type": "string"
                  },
                  "custom_lead_time_override": {
                    "type": "string"
                  }
                },
                "required": [
                  "items"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.create_work_order_from_quote": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.create_work_order_from_quote",
        "summary": "Convert Quotation to Work Order",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only handles quote-to-work-order conversion\nKISS: Simple, straightforward conversion logic\nDRY: Reuses validation decorators and error handling\n\nPhase 1 CRITICAL: Added validation to prevent $0.00 quotes from creating work orders\n\nThis is a CRITICAL endpoint for the primary workflow:\nQuote \u2192 Work Order \u2192 Job Card \u2192 Production\n\nArgs:\n    quotation_id: Quotation document name (e.g., \"QTN-00001\")\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"work_order_id\": \"WO-00001\",\n        \"status\": \"Not Started\"\n    }\n\nRaises:\n    frappe.DoesNotExistError: Quotation not found\n    frappe.ValidationError: Quotation not submitted, already converted, or has invalid data",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.delete_quotation": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.delete_quotation",
        "summary": "Delete a quotation with safety validation and cleanup.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.duplicate_quotation": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.duplicate_quotation",
        "summary": "Create a duplicate of an existing quotation.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source_quotation_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "source_quotation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.get_customer_context": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.get_customer_context",
        "summary": "Get comprehensive customer context for quotation creation",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Aggregate customer data\nDRY: Centralized customer context retrieval\n\nPhase 3: Multi-Location Support - Filters history by user's accessible locations\n\nArgs:\n    customer_id: Customer document name\n    location: Optional specific location to filter by\n\nReturns:\n    Comprehensive customer context including history and financials",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer_id": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  }
                },
                "required": [
                  "customer_id"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.get_estimator_dashboard_summary": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.get_estimator_dashboard_summary",
        "summary": "Return compact aggregate metrics for the estimator dashboard.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This keeps dashboard stat cards and badges off list endpoints so the page\ndoes not fan out across multiple paginated resources just to render counts.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/estimator.get_global_price_history": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.get_global_price_history",
        "summary": "Get global pricing for item across ALL customers (fallback when no customer history)",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Global price history lookup\nKISS: Simple SQL query without customer filter\n\nUse Case:\n- When quoting to a NEW customer with no history for this item\n- Falls back to showing what other customers have paid\n- Provides context even when customer-specific data unavailable\n\nPhase 3: Multi-Location Support - Filters by user's accessible locations\n\nArgs:\n    item_code: Item code\n    limit: Number of records to return (default 5, max 50)\n    location: Optional specific location to filter by\n\nReturns standardized API response",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "location": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.get_lead_time_suggestion": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.get_lead_time_suggestion",
        "summary": "Calculate ENHANCED capacity-aware lead time suggestion",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "IMPROVEMENTS (Medium Priority Feature):\n- Uses comprehensive workstation availability analysis\n- Considers actual scheduled job cards more accurately\n- Finds earliest available slot for each operation\n- Better bottleneck detection with multi-week analysis\n\nSOLID: Single Responsibility - Lead time calculation\nDRY: Uses WorkstationCapacity utility (reusable)\n\nPhase 3: Multi-Location Support - Considers location-specific workstation capacity\n\nArgs:\n    operations: JSON string of operations list\n        [\n            {\"operation\": \"Laser Cutting\", \"estimated_hours\": 2.5},\n            {\"operation\": \"Bending\", \"estimated_hours\": 1.0}\n        ]\n    location: Optional specific location to calculate for\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"estimated_weeks\": 2.5,\n            \"bottleneck_workstation\": \"Laser Cutting\",\n            \"capacity_breakdown\": [...],\n            \"suggestion_confidence\": \"high\",\n            \"earliest_start_week\": 2,\n            \"location\": \"LOC-001\"\n        },\n        \"message\": \"Lead time suggestion calculated\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "operations": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  }
                },
                "required": [
                  "operations"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.get_parent_item_sublines": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.get_parent_item_sublines",
        "summary": "Get subline items for a single parent line item.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "parent_item_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "parent_item_name"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.get_price_history": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.get_price_history",
        "summary": "Get historical pricing for item and customer",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Price history lookup\nKISS: Simple SQL query\n\nPhase 3: Multi-Location Support - Filters by user's accessible locations\n\nArgs:\n    customer_id: Customer document name\n    item_code: Item code\n    limit: Number of records to return (default 5, max 50)\n    location: Optional specific location to filter by\n\nReturns standardized API response",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "customer_id": {
                    "type": "string"
                  },
                  "item_code": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "location": {
                    "type": "string"
                  }
                },
                "required": [
                  "customer_id",
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.get_quotation_detail": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.get_quotation_detail",
        "summary": "OPTIMIZED: Fetch quotation + customer in single call with selected fields only.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "PERFORMANCE GAINS:\n- 2 API calls \u2192 1 (quotation + customer combined)\n- ~2s \u2192 ~0.5s (bypasses Frappe ORM overhead)\n- ~50KB \u2192 ~15KB data transferred (selected fields only)\n\nUses frappe.db.get_value() and frappe.db.get_all() for direct SQL\ninstead of frappe.get_doc() which loads full document + transformations.\n\nArgs:\n    quotation_id: Quotation document name (e.g., \"QTN-00001\")\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"quotation\": {...},\n            \"customer\": {...},\n            \"lead\": {...},\n            \"contact\": {...}\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.get_quotation_sublines": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.get_quotation_sublines",
        "summary": "Get all subline items for a quotation, grouped by parent line item.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v6.5: Returns sublines with category totals and counts for PDF generation.\n\nArgs:\n    quotation_name: Quotation document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"quotation\": \"QTN-001\",\n            \"line_items\": [\n                {\n                    \"line_item_name\": \"QTNITEM-001\",\n                    \"item_code\": \"STAIR-001\",\n                    \"item_name\": \"Custom Steel Staircase\",\n                    \"description\": \"20 ft length, custom fabrication\",\n                    \"has_sublines\": true,\n                    \"subline_count\": 5,\n                    \"sublines\": [...],\n                    \"category_totals\": {\n                        \"materials_total\": 2500,\n                        \"labor_total\": 1800,\n                        \"services_total\": 700\n                    },\n                    \"category_counts\": {\n                        \"materials_count\": 2,\n                        \"labor_count\": 2,\n                        \"services_count\": 1\n                    }\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_name"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.get_quotations": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.get_quotations",
        "summary": "Get paginated list of quotations with cursor-based pagination.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "filters": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "cursor": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/estimator.get_quote_timeline": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.get_quote_timeline",
        "summary": "Get complete timeline of quote status changes with user attribution.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Features:\n- Full audit trail of quote lifecycle\n- User attribution (who created, submitted, approved/rejected)\n- Duration in each status\n- Currently assigned approver (for pending quotes)",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quote_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "quote_id"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.save_quotation_sublines": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.save_quotation_sublines",
        "summary": "Save subline items for a quotation.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v6.5: Subline items enable detailed cost breakdowns within line items,\ngrouped by category (Materials/Labor/Services) for PDF output.\n\nThis endpoint:\n1. Deletes existing sublines for the quotation\n2. Creates new subline items\n3. Recalculates parent line item totals\n\nArgs:\n    quotation_name: Quotation document name\n    subline_items: JSON string of subline items array\n\nSubline Item Structure:\n    [{\n        \"parent_item\": \"item-1\",             # Required: Quotation Item name or item-<idx>\n        \"category\": \"Materials\",              # Required: Materials/Labor/Services\n        \"sort_order\": 0,                      # Optional: Display order\n        \"item_code\": \"STEEL-001\",             # Optional: Item catalog reference\n        \"description\": \"Steel Plate 20ft\",    # Required: Description\n        \"qty\": 10,                            # Required: Quantity\n        \"uom\": \"Nos\",                         # Optional: Unit of measure\n        \"rate\": 200,                          # Required: Rate per unit\n        \"operation\": \"Cutting\",               # Optional: For labor items\n        \"estimated_hours\": 4,                 # Optional: Labor hours\n        \"workstation\": \"WS-001\",              # Optional: Assigned workstation\n        \"item_variant\": \"IV-001\"              # Optional: Variant selection\n    }]\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"quotation\": \"QTN-001\",\n            \"subline_count\": 5,\n            \"parents_updated\": 2\n        },\n        \"message\": \"Subline items saved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_name": {
                    "type": "string"
                  },
                  "subline_items": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_name",
                  "subline_items"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.submit_quotation_to_customer": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.submit_quotation_to_customer",
        "summary": "Mark quotation as sent to customer.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v3.48: NEW - Part of corrected workflow for quote-to-sales-order conversion.\nv4.8: REFACTORED - Sets workflow_state to \"Sent to Customer\" instead of\n       changing ERPNext status.\n\nWORKFLOW (v4.8):\n    Draft \u2192 Pending Review \u2192 Approved (internal) \u2192 Sent to Customer (external)\n\nPrerequisite: workflow_state = \"Approved\"",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_name"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.submit_quote_for_engineering": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.submit_quote_for_engineering",
        "summary": "Submit quotation for approval workflow.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v4.8: Uses state machine for routing calculation, but preserves two-stage save\npattern for ERPNext compatibility.\n\nv4.7: Quote Locking Fix - Quotes are now submitted (docstatus=1) when entering\napproval workflow, preventing unauthorized edits.\n\nv3.47: Supports auto-approval for standard quotes\n- include_engineering=True: Requires engineering review\n- include_engineering=False + below threshold: Auto-approved\n- Above threshold: Always requires accounting approval",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_id": {
                    "type": "string"
                  },
                  "include_engineering": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "quotation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.update_quotation": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.update_quotation",
        "summary": "Update existing quotation.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_id": {
                    "type": "string"
                  },
                  "items": {
                    "type": "string"
                  },
                  "quotation_to": {
                    "type": "string"
                  },
                  "customer_id": {
                    "type": "string"
                  },
                  "lead_id": {
                    "type": "string"
                  },
                  "valid_till": {
                    "type": "string"
                  },
                  "estimated_lead_time_weeks": {
                    "type": "string"
                  },
                  "lead_time_unit": {
                    "type": "string"
                  },
                  "payment_terms_template": {
                    "type": "string"
                  },
                  "terms": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "warehouse": {
                    "type": "string"
                  },
                  "freight_mode": {
                    "type": "string"
                  },
                  "freight_zone": {
                    "type": "string"
                  },
                  "freight_total": {
                    "type": "string"
                  },
                  "contact_person": {
                    "type": "string"
                  },
                  "billing_address_line1": {
                    "type": "string"
                  },
                  "billing_address_line2": {
                    "type": "string"
                  },
                  "billing_city": {
                    "type": "string"
                  },
                  "billing_state": {
                    "type": "string"
                  },
                  "billing_country": {
                    "type": "string"
                  },
                  "billing_pincode": {
                    "type": "string"
                  },
                  "shipping_same_as_billing": {
                    "type": "string"
                  },
                  "shipping_address_line1": {
                    "type": "string"
                  },
                  "shipping_address_line2": {
                    "type": "string"
                  },
                  "shipping_city": {
                    "type": "string"
                  },
                  "shipping_state": {
                    "type": "string"
                  },
                  "shipping_country": {
                    "type": "string"
                  },
                  "shipping_pincode": {
                    "type": "string"
                  },
                  "custom_liability_category": {
                    "type": "string"
                  },
                  "custom_engineering_review_required": {
                    "type": "string"
                  },
                  "custom_total_taxes": {
                    "type": "string"
                  },
                  "custom_total_charges": {
                    "type": "string"
                  },
                  "custom_cod_flag": {
                    "type": "string"
                  },
                  "custom_lead_time_override": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/estimator.withdraw_submitted_quotation": {
      "post": {
        "operationId": "pacific_bending_app.api.estimator.withdraw_submitted_quotation",
        "summary": "Withdraw a quote that has been submitted to customer.",
        "tags": [
          "Estimator"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v4.10: Refactored to use centralized QuotationWorkflow service.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_name": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_name"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.add_jobs_to_powder_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.add_jobs_to_powder_batch",
        "summary": "Add Jobs To Powder Batch",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "job_cards": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id",
                  "job_cards"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.auto_populate_work_order": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.auto_populate_work_order",
        "summary": "Auto-populate Work Order from BOM template",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Copies BOM to WO\nKISS: Simple copy operations, increment counters\nCRITICAL: Eliminates repetitive data entry for repeat jobs\n\nArgs:\n    work_order_id: Work Order document name\n    item_code: Item code to find BOM template\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"auto_populated\": true,\n        \"bom_id\": \"BOM-ITEM-001\",\n        \"operations\": [...],\n        \"qc_checkpoints\": [...],\n        \"materials\": [...]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  },
                  "item_code": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id",
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.bulk_review_material_overrides": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.bulk_review_material_overrides",
        "summary": "Bulk approve/reject material override requests",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Bulk approval\nKISS: Loop through single approval function\nCRITICAL: Enables high-volume production efficiency\n\nArgs:\n    override_request_ids: JSON array of Override Request IDs\n        Example: '[\"MOR-001\", \"MOR-002\", \"MOR-003\"]'\n    approved: True to approve all, False to reject all\n    review_notes: Review notes applied to all requests\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"5 override requests processed, 4 succeeded, 1 failed\",\n        \"success_count\": 4,\n        \"failed_count\": 1,\n        \"failed_requests\": [\n            {\n                \"override_request_id\": \"MOR-003\",\n                \"error\": \"Insufficient stock\"\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "override_request_ids": {
                    "type": "string"
                  },
                  "approved": {
                    "type": "boolean"
                  },
                  "review_notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "override_request_ids",
                  "approved"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.bulk_update_work_order_status": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.bulk_update_work_order_status",
        "summary": "Bulk update work order status",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Bulk status update\nKISS: Loop through single update function\nCRITICAL: Enables efficient schedule management\n\nArgs:\n    work_order_ids: JSON array of Work Order IDs\n        Example: '[\"WO-001\", \"WO-002\", \"WO-003\"]'\n    status: New status to apply to all\n    force_override: Admin-only flag to bypass material blocking for In Progress\n    override_reason: Required when force_override is enabled for blocked starts\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"5 work orders processed, 4 succeeded, 1 failed\",\n        \"success_count\": 4,\n        \"failed_count\": 1,\n        \"blocked_count\": 1,\n        \"failed_work_orders\": [...]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_ids": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "force_override": {
                    "type": "string"
                  },
                  "override_reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_ids",
                  "status"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.cancel_powder_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.cancel_powder_batch",
        "summary": "Cancel Powder Batch",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "force": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.complete_job_card": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.complete_job_card",
        "summary": "Complete a job card and calculate time variance",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Completion tracking\nKISS: Calculate duration and variance\nCRITICAL: Enables time variance analysis for continuous improvement\n\nArgs:\n    job_card_id: Job Card ID\n    completed_qty: Optional completed quantity\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card completed successfully\",\n        \"job_card\": {\n            \"name\": \"JOB-00123\",\n            \"status\": \"Completed\",\n            \"start_time\": \"2025-11-14T10:30:00\",\n            \"end_time\": \"2025-11-14T14:30:00\",\n            \"actual_duration_mins\": 225.0,\n            \"estimated_duration_mins\": 240.0,\n            \"variance_percent\": -6.25,\n            \"break_time_mins\": 15.0\n        }\n    }\n\nRaises:\n    frappe.ValidationError: If job card not started",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "completed_qty": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.complete_job_card_impl": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.complete_job_card_impl",
        "summary": "Complete a job card and calculate time variance",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Completion tracking\nKISS: Calculate duration and variance\nCRITICAL: Enables time variance analysis for continuous improvement\n\nArgs:\n    job_card_id: Job Card ID\n    completed_qty: Optional completed quantity\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card completed successfully\",\n        \"job_card\": {\n            \"name\": \"JOB-00123\",\n            \"status\": \"Completed\",\n            \"start_time\": \"2025-11-14T10:30:00\",\n            \"end_time\": \"2025-11-14T14:30:00\",\n            \"actual_duration_mins\": 225.0,\n            \"estimated_duration_mins\": 240.0,\n            \"variance_percent\": -6.25,\n            \"break_time_mins\": 15.0\n        }\n    }\n\nRaises:\n    frappe.ValidationError: If job card not started",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "completed_qty": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.complete_job_card_with_tracking": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.complete_job_card_with_tracking",
        "summary": "Atomic operation: Complete job card AND finalize time tracking",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Atomic completion operation\n\nArgs:\n    job_card_id: Job Card ID\n    completed_qty: Completed quantity (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card completed successfully\",\n        \"job_card\": {...},\n        \"time_stats\": {...}\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "completed_qty": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "qc_status": {
                    "type": "string"
                  },
                  "qc_notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.complete_powder_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.complete_powder_batch",
        "summary": "Complete Powder Batch",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.complete_work_order": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.complete_work_order",
        "summary": "Complete a Work Order with optional forced override.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    work_order_id: Work Order document name\n    force: Force completion even with incomplete Job Cards\n    override_reason: Required when force=True\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"work_order_id\": \"WO-001\",\n            \"old_status\": \"In Progress\",\n            \"status\": \"Completed\",\n            \"force\": false\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  },
                  "force": {
                    "type": "boolean"
                  },
                  "override_reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.complete_work_order_partial": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.complete_work_order_partial",
        "summary": "Partially complete a Work Order for a specific quantity.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Phase 3 Enhancement (v1.98.2): Partial Completion Support\n\nThis allows completing a portion of the Work Order when:\n- Some Job Cards have completed more than others\n- QC failures require partial shipment\n- Customer needs partial delivery before full completion\n\nSOLID: Single Responsibility - Only handles partial completion\nKISS: Simple quantity tracking with clear status management\n\nArgs:\n    work_order_id: Work Order document name\n    completed_qty: Quantity to mark as completed (must be > 0)\n    notes: Optional notes for the partial completion\n    create_pick_list: Whether to auto-create Pick List (default True)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"work_order_id\": \"WO-001\",\n            \"completed_qty\": 5.0,\n            \"total_qty\": 10.0,\n            \"remaining_qty\": 5.0,\n            \"completion_percentage\": 50.0,\n            \"status\": \"Partially Completed\",\n            \"pick_list_id\": \"PL-001\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  },
                  "completed_qty": {
                    "type": "number"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "create_pick_list": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "work_order_id",
                  "completed_qty"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.create_manual_time_entry": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.create_manual_time_entry",
        "summary": "Create manual time entry for retroactive time logging",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Manual time entry creation only\nKISS: Simple validation and creation\nDRY: Reuses validation utilities\nCRITICAL: Allows recovery when workers forget to start/stop timer\n\nArgs:\n    job_card_id: Job Card ID (e.g., \"JC-00123\")\n    started_at: ISO 8601 timestamp (e.g., \"2023-11-15T10:30:00Z\")\n    ended_at: ISO 8601 timestamp (e.g., \"2023-11-15T14:30:00Z\")\n    duration_mins: Duration in minutes (must match calculated duration \u00b11 min)\n    completed_qty: Completed quantity (optional, default 0)\n    scrap_qty: Scrap quantity (optional, default 0)\n    notes: Notes about manual entry (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Manual time entry created successfully\",\n        \"time_entry\": {\n            \"name\": \"TENTRY-00001\",\n            \"job_card\": \"JC-00123\",\n            \"started_at\": \"2023-11-15T10:30:00Z\",\n            \"ended_at\": \"2023-11-15T14:30:00Z\",\n            \"duration_mins\": 240,\n            \"entry_type\": \"Manual\",\n            \"completed_qty\": 10,\n            \"created_by\": \"user@example.com\"\n        }\n    }\n\nRaises:\n    frappe.ValidationError: If validation fails (timestamps, duration, etc.)",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "started_at": {
                    "type": "string"
                  },
                  "ended_at": {
                    "type": "string"
                  },
                  "duration_mins": {
                    "type": "integer"
                  },
                  "completed_qty": {
                    "type": "integer"
                  },
                  "scrap_qty": {
                    "type": "integer"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "started_at",
                  "ended_at",
                  "duration_mins"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.create_powder_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.create_powder_batch",
        "summary": "Create Powder Batch",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_cards": {
                    "type": "string"
                  },
                  "workstation": {
                    "type": "string"
                  },
                  "color_profile": {
                    "type": "string"
                  },
                  "cure_profile": {
                    "type": "string"
                  },
                  "company": {
                    "type": "string"
                  },
                  "warehouse_group": {
                    "type": "string"
                  },
                  "planned_start": {
                    "type": "string"
                  },
                  "planned_end": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_cards"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.create_standalone_work_order": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.create_standalone_work_order",
        "summary": "Create a Work Order directly without requiring a Quotation",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Creates work orders without quote dependency\nKISS: Simple creation with sensible defaults\nCRITICAL: Enables internal jobs and repeat orders without quote workflow\n\nUse Cases:\n1. Internal manufacturing (repairs, samples, prototypes)\n2. Repeat customer orders (skip quote for known jobs)\n\nArgs:\n    production_item: Item to produce (required)\n    qty: Quantity to produce (required, min 1)\n    operations: JSON string of operations (required)\n    priority: \"Low\" | \"Medium\" | \"High\" | \"Urgent\" (default: Medium)\n    planned_start_date: ISO date string (optional)\n    planned_end_date: ISO date string (optional)\n    customer: Customer document name (optional, required if not internal)\n    is_internal_job: True if internal manufacturing (default: False)\n    internal_job_type: \"Repair\" | \"Sample\" | \"Internal\" | \"Other\" (optional)\n    internal_job_notes: Notes for internal job (optional)\n    required_items: JSON string of materials (optional)\n    wip_warehouse: Work in progress warehouse (optional)\n    fg_warehouse: Finished goods warehouse (optional)\n    bom_no: Native ERPNext BOM link\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Work Order created\",\n        \"data\": {\n            \"work_order_id\": \"WO-00123\",\n            \"material_status\": \"Green\" | \"Yellow\" | \"Red\",\n            \"job_cards_created\": 3\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "production_item": {
                    "type": "string"
                  },
                  "qty": {
                    "type": "integer"
                  },
                  "operations": {
                    "type": "string"
                  },
                  "priority": {
                    "type": "string"
                  },
                  "planned_start_date": {
                    "type": "string"
                  },
                  "planned_end_date": {
                    "type": "string"
                  },
                  "customer": {
                    "type": "string"
                  },
                  "is_internal_job": {
                    "type": "boolean"
                  },
                  "internal_job_type": {
                    "type": "string"
                  },
                  "internal_job_notes": {
                    "type": "string"
                  },
                  "required_items": {
                    "type": "string"
                  },
                  "wip_warehouse": {
                    "type": "string"
                  },
                  "fg_warehouse": {
                    "type": "string"
                  },
                  "bom_no": {
                    "type": "string"
                  }
                },
                "required": [
                  "production_item",
                  "qty",
                  "operations"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.deactivate_bom_template": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.deactivate_bom_template",
        "summary": "Deactivate a submitted BOM template (soft deactivation).",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Keeps history intact and synchronizes Item.default_bom when needed.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "bom_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "bom_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.delete_bom_attachment": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.delete_bom_attachment",
        "summary": "Delete one attachment linked to a BOM.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Idempotent:\n- If the file is already gone, returns success with changed=False.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "bom_id": {
                    "type": "string"
                  },
                  "file_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "bom_id",
                  "file_name"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.finalize_partial_work_order": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.finalize_partial_work_order",
        "summary": "Finalize a partially completed Work Order.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Marks the Work Order as fully completed, even if produced_qty < total qty.\nCreates final Stock Entry for any remaining WIP materials.\n\nPhase 3 Enhancement (v1.98.2): Partial Completion Finalization\n\nArgs:\n    work_order_id: Work Order document name\n    notes: Optional notes for finalization\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"work_order_id\": \"WO-001\",\n            \"final_produced_qty\": 8.0,\n            \"total_qty\": 10.0,\n            \"short_closed_qty\": 2.0,\n            \"status\": \"Completed\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_active_time_entry": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_active_time_entry",
        "summary": "Get currently active time entry for the authenticated user.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/foreman.get_batch_traceability": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_batch_traceability",
        "summary": "Return input batch usage for Work Order-level traceability.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Batch traceability only\nKISS: Simple batch collection with item enrichment\n\nArgs:\n    work_order_id: Work Order document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"work_order_id\": \"WO-001\",\n            \"produced_batch\": null,\n            \"produced_item\": \"ITEM-001\",\n            \"produced_qty\": 100.0,\n            \"input_batches\": [...]\n        },\n        \"message\": \"Batch traceability generated\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_bom_by_id": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_bom_by_id",
        "summary": "Get BOM template by its document ID (not item_code).",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Use case: Edit page where route param is BOM ID (e.g., \"BOM-ITEM-001\").\n\nSOLID: Single Responsibility - Retrieves BOM by ID\nKISS: Direct fetch of requested operational BOM\n\nArgs:\n    bom_id: BOM document name (e.g., \"BOM-ITEM-001\")\n\nReturns:\n    BOM data with operations, QC checkpoints, and materials, or null if not found.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "bom_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "bom_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_bom_template": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_bom_template",
        "summary": "Get BOM template for item",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves BOM\nKISS: Simple query and return\nYAGNI: Returns null if not found (not an error)\n\nArgs:\n    item_code: Item document name\n\nReturns:\n    BOM data with operations, QC checkpoints, and materials, or null if not found",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_consumption_entries": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_consumption_entries",
        "summary": "List material consumption entries for a Job Card.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Job card consumption listing only\nKISS: Simple row retrieval with item enrichment\n\nArgs:\n    job_card_id: Job Card document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"entries\": [...]\n        },\n        \"message\": \"Consumption entries retrieved\"\n    }\n\nRaises:\n    frappe.DoesNotExistError: If job card not found",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_consumption_summary": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_consumption_summary",
        "summary": "Aggregate material consumption for foreman dashboard panel.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Consumption aggregation only\nKISS: Simple aggregation with item grouping\n\nArgs:\n    work_order_id: Work Order document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"work_order_id\": \"WO-001\",\n            \"total_consumed_qty\": 150.5,\n            \"total_scrap_qty\": 5.2,\n            \"scrap_percentage\": 3.34,\n            \"items\": [...],\n            \"scrap_entries\": [...],\n            \"batch_traceability_enabled\": True\n        },\n        \"message\": \"Consumption summary generated\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_failed_time_entries": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_failed_time_entries",
        "summary": "Get pending failed time entries (admin only)",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Retrieval only\nKISS: Simple query wrapper\n\nArgs:\n    job_card_id: Filter by job card (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"failures\": [\n            {\n                \"name\": \"TEFL-00001\",\n                \"job_card\": \"JC-00123\",\n                \"action\": \"start\",\n                \"error_message\": \"Network timeout\",\n                \"logged_at\": \"2023-11-15T10:30:00\",\n                \"status\": \"Pending\"\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/foreman.get_job_card_time_entries": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_job_card_time_entries",
        "summary": "List all time entries for a Job Card.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_material_availability": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_material_availability",
        "summary": "Get ENHANCED material availability for Work Order (traffic light system)",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "IMPROVEMENTS (Medium Priority Feature):\n- Now includes reserved stock calculation\n- Shows actual available qty (available - reserved)\n- Shows shortage qty for each item\n- Better visibility into material allocation\n\nSOLID: Single Responsibility - Only checks stock levels\nDRY: Uses StockAvailability utility (reusable)\n\nPhase 3: Multi-Location Support - Filters stock by work order location\n\nArgs:\n    work_order_id: Work Order document name\n\nReturns:\n    {\n        \"status\": \"available\" | \"partial\" | \"unavailable\",\n        \"can_start\": true | false,\n        \"location\": \"LOC-00001\",\n        \"items\": [\n            {\n                \"item_code\": \"ITEM-001\",\n                \"item_name\": \"Steel Plate\",\n                \"required_qty\": 100,\n                \"available_qty\": 150,\n                \"reserved_qty\": 75,\n                \"actual_available_qty\": 75,\n                \"can_fulfill\": false,\n                \"shortage_qty\": 25,\n                \"uom\": \"kg\",\n                \"status\": \"partial\"\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_material_availability_impl": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_material_availability_impl",
        "summary": "Get ENHANCED material availability for Work Order (traffic light system)",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "IMPROVEMENTS (Medium Priority Feature):\n- Now includes reserved stock calculation\n- Shows actual available qty (available - reserved)\n- Shows shortage qty for each item\n- Better visibility into material allocation\n\nSOLID: Single Responsibility - Only checks stock levels\nDRY: Uses StockAvailability utility (reusable)\n\nPhase 3: Multi-Location Support - Filters stock by work order location\n\nArgs:\n    work_order_id: Work Order document name\n\nReturns:\n    {\n        \"status\": \"available\" | \"partial\" | \"unavailable\",\n        \"can_start\": true | false,\n        \"location\": \"LOC-00001\",\n        \"items\": [\n            {\n                \"item_code\": \"ITEM-001\",\n                \"item_name\": \"Steel Plate\",\n                \"required_qty\": 100,\n                \"available_qty\": 150,\n                \"reserved_qty\": 75,\n                \"actual_available_qty\": 75,\n                \"can_fulfill\": false,\n                \"shortage_qty\": 25,\n                \"uom\": \"kg\",\n                \"status\": \"partial\"\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_material_consumption": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_material_consumption",
        "summary": "Get material consumption summary for a work order",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Consumption aggregation\nKISS: Sum consumption across all job cards\nCRITICAL: Enables material variance reporting\n\nArgs:\n    work_order_id: Work Order ID\n\nReturns:\n    {\n        \"work_order_id\": \"WO-00123\",\n        \"total_items\": 5,\n        \"items\": [\n            {\n                \"item_code\": \"ITEM-001\",\n                \"planned_qty\": 100.0,\n                \"actual_qty\": 105.0,\n                \"scrap_qty\": 5.0,\n                \"variance_qty\": 5.0,\n                \"variance_percent\": 5.0,\n                \"uom\": \"kg\"\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_operator_availability": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_operator_availability",
        "summary": "Return active operator workload buckets for reassignment decisions.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Operator availability only\nKISS: Simple aggregation by operator\n\nArgs:\n    warehouse: Optional filter by WIP warehouse\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"operators\": [\n                {\n                    \"user_email\": \"john@example.com\",\n                    \"full_name\": \"John Doe\",\n                    \"active_job_cards\": 3,\n                    \"availability_status\": \"busy\",\n                    \"workstation\": \"WS-001\"\n                }\n            ]\n        },\n        \"message\": \"Operator availability retrieved\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "warehouse": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/foreman.get_operator_productivity": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_operator_productivity",
        "summary": "Get operator productivity metrics for date range.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Metrics calculation\nKISS: Uses ProductivityService for consistent logic\nDRY: Delegates to service layer for reusability\n\nv9.24: Refactored to use ProductivityService with:\n- Configurable thresholds (from Pacific Bending Settings)\n- Redis caching for performance\n- Consistent calculation logic\n\nArgs:\n    operator_id: User email\n    start_date: Start date (YYYY-MM-DD)\n    end_date: End date (YYYY-MM-DD)\n\nReturns:\n    {\n        \"operator_id\": \"john@example.com\",\n        \"date_range\": \"2025-11-01 to 2025-11-14\",\n        \"total_jobs_completed\": 45,\n        \"total_time_hours\": 120.5,\n        \"avg_time_per_job_mins\": 160.7,\n        \"avg_variance_percent\": -5.2,\n        \"on_time_jobs\": 38,\n        \"late_jobs\": 7,\n        \"on_time_percentage\": 84.4,\n        \"efficiency_level\": \"good\",\n        \"job_cards\": [...]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "operator_id": {
                    "type": "string"
                  },
                  "start_date": {
                    "type": "string"
                  },
                  "end_date": {
                    "type": "string"
                  }
                },
                "required": [
                  "operator_id",
                  "start_date",
                  "end_date"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_partial_completion_status": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_partial_completion_status",
        "summary": "Get partial completion status for a Work Order.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Phase 3 Enhancement (v1.98.2): Partial Completion Tracking\n\nArgs:\n    work_order_id: Work Order document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"work_order_id\": \"WO-001\",\n            \"total_qty\": 10.0,\n            \"produced_qty\": 5.0,\n            \"remaining_qty\": 5.0,\n            \"completion_percentage\": 50.0,\n            \"status\": \"Partially Completed\",\n            \"can_complete_more\": True,\n            \"job_cards_summary\": [...],\n            \"partial_pick_lists\": [...]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_powder_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_powder_batch",
        "summary": "Get Powder Batch",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.get_setup_time_variance": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_setup_time_variance",
        "summary": "Get setup time variance analysis for operations",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Setup time variance analysis\nKISS: Simple aggregation with optional filters\nCRITICAL: Enables identification of setup inefficiencies and process improvements\n\nSetup time variance = (actual_setup_time - estimated_setup_time) / estimated_setup_time * 100\n\nArgs:\n    from_date: Start date (YYYY-MM-DD, default: 30 days ago)\n    to_date: End date (YYYY-MM-DD, default: today)\n    workstation: Optional filter by workstation\n    location: Optional filter by location\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"summary\": {\n                \"total_operations\": 45,\n                \"avg_estimated_mins\": 15.0,\n                \"avg_actual_mins\": 18.5,\n                \"avg_variance_mins\": 3.5,\n                \"avg_variance_percent\": 23.3,\n                \"on_time_count\": 30,\n                \"over_count\": 12,\n                \"under_count\": 3\n            },\n            \"by_workstation\": [...],\n            \"by_operation\": [...],\n            \"outliers\": [...],\n            \"period\": {...}\n        },\n        \"message\": \"Setup time variance data retrieved\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from_date": {
                    "type": "string"
                  },
                  "to_date": {
                    "type": "string"
                  },
                  "workstation": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/foreman.get_shop_floor_operators": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_shop_floor_operators",
        "summary": "Return active operators available for Job Card assignment.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Operator listing only\nKISS: Simple user query with role filter\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"operators\": [\n                {\n                    \"name\": \"john\",\n                    \"email\": \"john@example.com\",\n                    \"full_name\": \"John Doe\",\n                    \"employee_id\": \"EMP-001\",\n                    \"is_employee\": true\n                }\n            ]\n        },\n        \"count\": 5,\n        \"message\": \"Shop floor operators retrieved\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  },
                  "location_group": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/foreman.get_time_tracking_summary": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.get_time_tracking_summary",
        "summary": "Aggregate planned vs actual labor from Job Cards and Time Entries.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.list_bom_attachments": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.list_bom_attachments",
        "summary": "List BOM attachments through a wrapper endpoint.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Keeps frontend on wrapper-first API boundaries instead of direct File queries.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "bom_id": {
                    "type": "string"
                  },
                  "limit_page_length": {
                    "type": "integer"
                  }
                },
                "required": [
                  "bom_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.list_bom_templates": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.list_bom_templates",
        "summary": "List submitted BOM templates with summary counts for list surfaces.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Wrapper endpoint to avoid direct frontend resource access and keep one\ncanonical API contract for template list behavior.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "is_active": {
                    "type": "string"
                  },
                  "created_by": {
                    "type": "string"
                  },
                  "item_search": {
                    "type": "string"
                  },
                  "limit_page_length": {
                    "type": "integer"
                  },
                  "limit_start": {
                    "type": "integer"
                  },
                  "sort_by": {
                    "type": "string"
                  },
                  "sort_order": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/foreman.list_powder_batches": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.list_powder_batches",
        "summary": "List Powder Batches",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workstation": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "warehouse_group": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "string"
                  },
                  "start": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/foreman.list_powder_color_profiles": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.list_powder_color_profiles",
        "summary": "List Powder Color Profiles",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active_only": {
                    "type": "string"
                  },
                  "search": {
                    "type": "string"
                  },
                  "start": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/foreman.list_powder_cure_profiles": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.list_powder_cure_profiles",
        "summary": "List Powder Cure Profiles",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active_only": {
                    "type": "string"
                  },
                  "search": {
                    "type": "string"
                  },
                  "start": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/foreman.log_failed_time_entry": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.log_failed_time_entry",
        "summary": "Log failed time entry operation for later recovery",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Failure logging only\nKISS: Simple log creation\nDRY: Reuses TimeEntryFailureLog DocType helper\n\nArgs:\n    job_card_id: Job Card ID\n    action: Action that failed (start, stop, pause, resume, complete)\n    error: Error message\n    context: JSON string with additional context\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Failure logged successfully\",\n        \"log_id\": \"TEFL-00001\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "action": {
                    "type": "string"
                  },
                  "error": {
                    "type": "string"
                  },
                  "context": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "action",
                  "error",
                  "context"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.pause_job_card": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.pause_job_card",
        "summary": "Pause a job card (break time)",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Pause tracking\nKISS: Log pause event\n\nArgs:\n    job_card_id: Job Card ID\n    reason: Optional pause reason\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card paused\",\n        \"pause_time\": \"2025-11-14T11:30:00\"\n    }\n\nRaises:\n    frappe.ValidationError: If job card not started or already paused",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.pause_job_card_impl": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.pause_job_card_impl",
        "summary": "Pause a job card (break time)",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Pause tracking\nKISS: Log pause event\n\nArgs:\n    job_card_id: Job Card ID\n    reason: Optional pause reason\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card paused\",\n        \"pause_time\": \"2025-11-14T11:30:00\"\n    }\n\nRaises:\n    frappe.ValidationError: If job card not started or already paused",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.pause_job_card_with_tracking": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.pause_job_card_with_tracking",
        "summary": "Atomic operation: Pause job card AND stop time tracking",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Atomic pause operation\n\nArgs:\n    job_card_id: Job Card ID\n    reason: Reason for pause (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card paused successfully\",\n        \"break_duration_mins\": 15.0\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.reactivate_bom_template": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.reactivate_bom_template",
        "summary": "Reactivate a submitted BOM template.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Preserves revision history and restores template eligibility for future Work Orders.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "bom_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "bom_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.reassign_job_card": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.reassign_job_card",
        "summary": "Reassign job card to a different operator",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Operator reassignment only\nKISS: Simple operator update with validation\nCONTRACT REQUIREMENT: Audit trail for operator changes\n\nArgs:\n    job_card_id: Job Card ID\n    new_operator: New operator email/ID\n    reason: Optional reason for reassignment\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"job_card_id\": \"JOB-00123\",\n            \"old_operator\": \"john@example.com\",\n            \"new_operator\": \"jane@example.com\",\n            \"reassigned_at\": \"2025-01-13T10:30:00\"\n        },\n        \"message\": \"Job card reassigned successfully\"\n    }\n\nRaises:\n    frappe.ValidationError: Invalid operator or operator lacks required skills",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "new_operator": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "new_operator"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.rebalance_powder_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.rebalance_powder_batch",
        "summary": "Rebalance Powder Batch",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "planned_start": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.record_material_consumption": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.record_material_consumption",
        "summary": "Record actual material consumption for a job card and deduct from batch availability",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Material tracking with availability sync\nKISS: Simple consumption logging with variance calculation\nCRITICAL: Enables material cost variance analysis, waste tracking, and\n          MAINTAINS INVENTORY ACCURACY by deducting from batch availability\n\nArgs:\n    job_card_id: Job Card ID\n    items: JSON string of consumed items\n        [\n            {\n                \"item_code\": \"ITEM-001\",\n                \"actual_qty\": 105.5,\n                \"batch_no\": \"BATCH-001\",\n                \"batch_line_idx\": 0,  # Optional: line item index for multi-piece batches\n                \"notes\": \"Used slightly more due to cut waste\"\n            }\n        ]\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Material consumption recorded successfully\",\n        \"job_card_id\": \"JOB-00123\",\n        \"items_logged\": 3,\n        \"consumption_logs\": [...],\n        \"batch_updates\": [...]  # Which batches were updated\n    }\n\nRaises:\n    frappe.ValidationError: If items not in BOM or insufficient batch quantity",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "items": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "items"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.record_material_consumption_impl": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.record_material_consumption_impl",
        "summary": "Record actual material consumption for a job card and deduct from batch availability",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Material tracking with availability sync\nKISS: Simple consumption logging with variance calculation\nCRITICAL: Enables material cost variance analysis, waste tracking, and\n          MAINTAINS INVENTORY ACCURACY by deducting from batch availability\n\nArgs:\n    job_card_id: Job Card ID\n    items: JSON string of consumed items\n        [\n            {\n                \"item_code\": \"ITEM-001\",\n                \"actual_qty\": 105.5,\n                \"batch_no\": \"BATCH-001\",\n                \"batch_line_idx\": 0,  # Optional: line item index for multi-piece batches\n                \"notes\": \"Used slightly more due to cut waste\"\n            }\n        ]\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Material consumption recorded successfully\",\n        \"job_card_id\": \"JOB-00123\",\n        \"items_logged\": 3,\n        \"consumption_logs\": [...],\n        \"batch_updates\": [...]  # Which batches were updated\n    }\n\nRaises:\n    frappe.ValidationError: If items not in BOM or insufficient batch quantity",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "items": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "items"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.record_scrap": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.record_scrap",
        "summary": "Record scrap/waste material for a job card",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Creates Stock Entry (Material Issue) for scrap\n\nSOLID: Single Responsibility - Scrap tracking\nKISS: Simple stock entry creation\nCRITICAL: Enables waste tracking and cost analysis\n\nArgs:\n    job_card_id: Job Card ID\n    item_code: Scrapped item code\n    scrap_qty: Scrap quantity\n    reason: Scrap reason\n    warehouse: Optional source warehouse (defaults to WIP warehouse)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Scrap recorded successfully\",\n        \"stock_entry_id\": \"STE-00789\",\n        \"item_code\": \"ITEM-001\",\n        \"scrap_qty\": 5.0,\n        \"reason\": \"Material defect\"\n    }\n\nRaises:\n    frappe.ValidationError: If scrap qty exceeds available quantity or WIP warehouse not configured",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "item_code": {
                    "type": "string"
                  },
                  "scrap_qty": {
                    "type": "number"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "warehouse": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "item_code",
                  "scrap_qty",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.remove_jobs_from_powder_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.remove_jobs_from_powder_batch",
        "summary": "Remove Jobs From Powder Batch",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "job_cards": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id",
                  "job_cards"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.reorder_job_cards": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.reorder_job_cards",
        "summary": "Reorder job cards within a work order (drag-and-drop scheduling)",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Job card sequencing only\nKISS: Simple sequence number update\nUX: Enables drag-and-drop scheduling in frontend\n\nArgs:\n    work_order_id: Work Order ID\n    new_order: JSON array of job card IDs in new order\n              Example: '[\"JOB-001\", \"JOB-003\", \"JOB-002\"]'\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"work_order_id\": \"WO-001\",\n            \"reordered_count\": 3,\n            \"job_cards\": [...]\n        },\n        \"message\": \"Job cards reordered successfully\"\n    }\n\nRaises:\n    frappe.ValidationError: Invalid order or job cards don't belong to work order",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  },
                  "new_order": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id",
                  "new_order"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.reorder_work_order_operations": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.reorder_work_order_operations",
        "summary": "Reorder Work Order operations",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only updates operation sequence\nKISS: Simple idx field updates\nSECURITY: Validates operations belong to work order (CRITICAL FIX)\n\nArgs:\n    work_order_id: Work Order document name\n    operations: JSON string of operations with new sequence\n        [\n            {\"name\": \"OP-001\", \"idx\": 1},\n            {\"name\": \"OP-002\", \"idx\": 2}\n        ]\n\nReturns:\n    {\"message\": \"success\"}\n\nRaises:\n    frappe.ValidationError: If operations don't belong to work order",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  },
                  "operations": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id",
                  "operations"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.resolve_failed_time_entry": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.resolve_failed_time_entry",
        "summary": "Mark failed time entry as resolved",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Resolution only\nKISS: Simple status update\n\nArgs:\n    log_id: Failure Log ID (e.g., \"TEFL-00001\")\n    resolution: Resolution type (Manual Entry Created, Not Needed, Duplicate, etc.)\n    notes: Resolution notes (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Failure resolved successfully\",\n        \"log_id\": \"TEFL-00001\",\n        \"resolution\": \"Manual Entry Created\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "log_id": {
                    "type": "string"
                  },
                  "resolution": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "log_id",
                  "resolution"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.resolve_time_entry_conflict": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.resolve_time_entry_conflict",
        "summary": "Resolve time entry conflict detected by overlap detection",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only resolves conflicts\nKISS: Simple resolution logic based on type\nDRY: Reuses create_manual_time_entry for creation\n\nArgs:\n    resolution_type: Resolution type (\"adjust\", \"merge\", \"cancel_new\", \"cancel_existing\")\n    proposed_job_card_id: Job Card ID for proposed entry\n    proposed_started_at: Proposed start time (ISO 8601)\n    proposed_ended_at: Proposed end time (ISO 8601)\n    proposed_duration_mins: Proposed duration in minutes\n    proposed_completed_qty: Proposed completed quantity\n    proposed_notes: Notes for proposed entry\n    existing_time_entry_id: ID of existing conflicting entry\n    adjusted_started_at: Adjusted start time (for \"adjust\" resolution)\n    adjusted_ended_at: Adjusted end time (for \"adjust\" resolution)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Conflict resolved successfully\",\n        \"resolution\": {\n            \"type\": \"adjust\",\n            \"time_entry\": {...}\n        }\n    }\n\nRaises:\n    frappe.ValidationError: If resolution parameters invalid",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "resolution_type": {
                    "type": "string"
                  },
                  "proposed_job_card_id": {
                    "type": "string"
                  },
                  "proposed_started_at": {
                    "type": "string"
                  },
                  "proposed_ended_at": {
                    "type": "string"
                  },
                  "proposed_duration_mins": {
                    "type": "integer"
                  },
                  "proposed_completed_qty": {
                    "type": "integer"
                  },
                  "proposed_notes": {
                    "type": "string"
                  },
                  "existing_time_entry_id": {
                    "type": "string"
                  },
                  "adjusted_started_at": {
                    "type": "string"
                  },
                  "adjusted_ended_at": {
                    "type": "string"
                  }
                },
                "required": [
                  "resolution_type"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.resume_job_card": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.resume_job_card",
        "summary": "Resume a paused job card",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Resume tracking\nKISS: Log resume event and calculate break time\n\nArgs:\n    job_card_id: Job Card ID\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card resumed\",\n        \"resume_time\": \"2025-11-14T11:45:00\",\n        \"break_duration_mins\": 15.0\n    }\n\nRaises:\n    frappe.ValidationError: If job card not paused",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.resume_job_card_impl": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.resume_job_card_impl",
        "summary": "Resume a paused job card",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Resume tracking\nKISS: Log resume event and calculate break time\n\nArgs:\n    job_card_id: Job Card ID\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card resumed\",\n        \"resume_time\": \"2025-11-14T11:45:00\",\n        \"break_duration_mins\": 15.0\n    }\n\nRaises:\n    frappe.ValidationError: If job card not paused",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.resume_job_card_with_tracking": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.resume_job_card_with_tracking",
        "summary": "Atomic operation: Resume job card AND start new time entry",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Atomic resume operation\n\nArgs:\n    job_card_id: Job Card ID\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card resumed successfully\",\n        \"resume_time\": \"2023-11-15T10:30:00\",\n        \"break_duration_mins\": 15.0\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.review_material_override": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.review_material_override",
        "summary": "Approve or reject material override request",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Reviews override request\nKISS: Simple approve/reject with Stock Entry creation\nCRITICAL: Unblocks shop floor workers in ~30 seconds\n\nArgs:\n    override_request_id: Material Override Request document name\n    approved: True to approve, False to reject\n    review_notes: Foreman's explanation\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"status\": \"approved\" | \"rejected\",\n        \"stock_entry_id\": \"STE-00789\" (if approved)\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "override_request_id": {
                    "type": "string"
                  },
                  "approved": {
                    "type": "boolean"
                  },
                  "review_notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "override_request_id",
                  "approved"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.save_bom_template": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.save_bom_template",
        "summary": "Save operation sequence as BOM template (MEMORY feature)",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Creates/updates BOM templates\nKISS: Simple BOM creation with operations, QC checkpoints, and materials\nCRITICAL: Enables system \"memory\" for repeat jobs\n\nArgs:\n    item_code: Item document name\n    operations: JSON string of operations\n    qc_checkpoints: Optional JSON string of QC checkpoints\n    materials: Optional JSON string of required materials\n    work_order_id: Optional Work Order ID to link\n    update_existing: If true, updates existing BOM instead of creating new\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"bom_id\": \"BOM-ITEM-001\",\n        \"action\": \"created\" | \"updated\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "operations": {
                    "type": "string"
                  },
                  "qc_checkpoints": {
                    "type": "string"
                  },
                  "materials": {
                    "type": "string"
                  },
                  "routing": {
                    "type": "string"
                  },
                  "template_notes": {
                    "type": "string"
                  },
                  "work_order_id": {
                    "type": "string"
                  },
                  "update_existing": {
                    "type": "boolean"
                  },
                  "is_default": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "item_code",
                  "operations"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.save_powder_color_profile": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.save_powder_color_profile",
        "summary": "Save Powder Color Profile",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "color_code": {
                    "type": "string"
                  },
                  "display_name": {
                    "type": "string"
                  },
                  "cleanup_group": {
                    "type": "string"
                  },
                  "is_active": {
                    "type": "string"
                  }
                },
                "required": [
                  "color_code"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.save_powder_cure_profile": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.save_powder_cure_profile",
        "summary": "Save Powder Cure Profile",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "profile_code": {
                    "type": "string"
                  },
                  "display_name": {
                    "type": "string"
                  },
                  "target_temp_c": {
                    "type": "string"
                  },
                  "dwell_minutes": {
                    "type": "string"
                  },
                  "is_active": {
                    "type": "string"
                  }
                },
                "required": [
                  "profile_code"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.split_powder_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.split_powder_batch",
        "summary": "Split Powder Batch",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "job_cards": {
                    "type": "string"
                  },
                  "split_after_sequence": {
                    "type": "string"
                  },
                  "planned_start": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.start_job_card": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.start_job_card",
        "summary": "Start a job card and log start time",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Time tracking only\nKISS: Simple timestamp logging\nCRITICAL: Enables labor cost tracking and time variance analysis\n\nArgs:\n    job_card_id: Job Card ID\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card started successfully\",\n        \"job_card\": {\n            \"name\": \"JOB-00123\",\n            \"status\": \"Work In Progress\",\n            \"start_time\": \"2025-11-14T10:30:00\"\n        }\n    }\n\nRaises:\n    frappe.ValidationError: If job card already started",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.start_job_card_impl": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.start_job_card_impl",
        "summary": "Start a job card and log start time",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Time tracking only\nKISS: Simple timestamp logging\nCRITICAL: Enables labor cost tracking and time variance analysis\n\nArgs:\n    job_card_id: Job Card ID\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card started successfully\",\n        \"job_card\": {\n            \"name\": \"JOB-00123\",\n            \"status\": \"Work In Progress\",\n            \"start_time\": \"2025-11-14T10:30:00\"\n        }\n    }\n\nRaises:\n    frappe.ValidationError: If job card already started",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.start_job_card_with_tracking": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.start_job_card_with_tracking",
        "summary": "Atomic operation: Start job card AND create time entry",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Both must succeed or both fail (rollback)\n\nSOLID: Single Responsibility - Atomic start operation\nKISS: Simple transaction wrapper\nCRITICAL: Prevents inconsistent state between job card and time tracking\n\nArgs:\n    job_card_id: Job Card ID\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job card started successfully\",\n        \"job_card\": {...},\n        \"time_entry\": {...}\n    }\n\nOR on failure:\n    {\n        \"success\": False,\n        \"error\": \"...\",\n        \"failure_log_id\": \"TEFL-00001\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.start_powder_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.start_powder_batch",
        "summary": "Start Powder Batch",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.start_time_tracking": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.start_time_tracking",
        "summary": "Start timer-only tracking for a Job Card.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This intentionally does NOT mutate Job Card status so UI flows can control\nstatus transitions independently without double writes.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.stop_time_tracking": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.stop_time_tracking",
        "summary": "Stop active timer-only tracking for a Job Card.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "completed_qty": {
                    "type": "string"
                  },
                  "scrap_qty": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.stop_work_order": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.stop_work_order",
        "summary": "Compatibility stop endpoint that avoids generic status-save flows.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.update_bom_template": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.update_bom_template",
        "summary": "Update existing BOM template",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only updates BOM\nKISS: Clear and replace operations/checkpoints/materials\n\nArgs:\n    bom_id: BOM document name\n    operations: JSON string of updated operations\n    qc_checkpoints: Optional JSON string of updated QC checkpoints\n    materials: Optional JSON string of updated materials\n    template_notes: Optional notes about the update\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"bom_id\": \"BOM-ITEM-001\",\n        \"action\": \"updated\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "bom_id": {
                    "type": "string"
                  },
                  "operations": {
                    "type": "string"
                  },
                  "qc_checkpoints": {
                    "type": "string"
                  },
                  "materials": {
                    "type": "string"
                  },
                  "routing": {
                    "type": "string"
                  },
                  "template_notes": {
                    "type": "string"
                  },
                  "is_default": {
                    "type": "string"
                  }
                },
                "required": [
                  "bom_id",
                  "operations"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.update_manual_time_entry": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.update_manual_time_entry",
        "summary": "Update an existing manual time entry so workers can revise mistakes.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "time_entry_id": {
                    "type": "string"
                  },
                  "started_at": {
                    "type": "string"
                  },
                  "ended_at": {
                    "type": "string"
                  },
                  "duration_mins": {
                    "type": "integer"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "time_entry_id",
                  "started_at",
                  "ended_at",
                  "duration_mins"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.update_work_order_status": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.update_work_order_status",
        "summary": "Update Work Order status with material availability blocking",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only updates status with validation\nKISS: Simple status transition with blocking logic\n\nArgs:\n    work_order_id: Work Order document name (e.g., \"WO-00123\")\n    status: New status (e.g., \"In Progress\", \"Completed\", \"Stopped\")\n    force_override: Admin-only flag to bypass material start blocking\n    override_reason: Required when force_override is enabled for blocked starts\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"status\": \"In Progress\"\n    }\n\nRaises:\n    frappe.ValidationError: If material unavailable when moving to \"In Progress\"",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "force_override": {
                    "type": "string"
                  },
                  "override_reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id",
                  "status"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.update_work_order_status_impl": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.update_work_order_status_impl",
        "summary": "Update Work Order status with material availability blocking",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only updates status with validation\nKISS: Simple status transition with blocking logic\n\nArgs:\n    work_order_id: Work Order document name (e.g., \"WO-00123\")\n    status: New status (e.g., \"In Progress\", \"Completed\", \"Stopped\")\n    force_override: Admin-only flag to bypass material start blocking\n    override_reason: Required when force_override is enabled for blocked starts\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"status\": \"In Progress\"\n    }\n\nRaises:\n    frappe.ValidationError: If material unavailable when moving to \"In Progress\"",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "force_override": {
                    "type": "string"
                  },
                  "override_reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id",
                  "status"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.upload_bom_attachment": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.upload_bom_attachment",
        "summary": "Upload one file attachment to a BOM through an app wrapper endpoint.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "bom_id": {
                    "type": "string"
                  },
                  "is_private": {
                    "type": "string"
                  },
                  "folder": {
                    "type": "string"
                  }
                },
                "required": [
                  "bom_id"
                ]
              }
            }
          }
        }
      }
    },
    "/foreman.validate_work_order_completion": {
      "post": {
        "operationId": "pacific_bending_app.api.foreman.validate_work_order_completion",
        "summary": "Validate if a Work Order can be completed.",
        "tags": [
          "Foreman"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    work_order_id: Work Order document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"total\": 5,\n            \"completed\": 3,\n            \"in_progress\": 1,\n            \"on_hold\": 0,\n            \"pending\": 1,\n            \"incomplete_cards\": [...]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id"
                ]
              }
            }
          }
        }
      }
    },
    "/freight.create_freight_zone": {
      "post": {
        "operationId": "pacific_bending_app.api.freight.create_freight_zone",
        "summary": "Create a new freight zone.",
        "tags": [
          "Freight"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    zone: JSON string of zone data\n        {\n            \"code\": \"FRASER\",\n            \"label\": \"Fraser Valley\",\n            \"rateType\": \"Flat Rate\",\n            \"flatRate\": 125.0,\n            \"isDefault\": false,\n            ...\n        }\n\nReturns:\n    {\"success\": True, \"data\": {...}, \"message\": \"...\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "zone": {
                    "type": "string"
                  }
                },
                "required": [
                  "zone"
                ]
              }
            }
          }
        }
      }
    },
    "/freight.delete_freight_zone": {
      "post": {
        "operationId": "pacific_bending_app.api.freight.delete_freight_zone",
        "summary": "Delete (soft delete) a freight zone.",
        "tags": [
          "Freight"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Sets is_active=0 instead of hard delete.\n\nArgs:\n    name: Zone document name (code)\n\nReturns:\n    {\"success\": True, \"message\": \"...\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/freight.get_default_zone": {
      "post": {
        "operationId": "pacific_bending_app.api.freight.get_default_zone",
        "summary": "Get the default freight zone.",
        "tags": [
          "Freight"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"code\": \"LOCAL\",\n            \"label\": \"Local (0-50km)\",\n            ...\n        } or null\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ]
      }
    },
    "/freight.get_freight_zones": {
      "post": {
        "operationId": "pacific_bending_app.api.freight.get_freight_zones",
        "summary": "Get all active freight zones for dropdown selection.",
        "tags": [
          "Freight"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "No role check because all authenticated users need zone list.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"zones\": [\n                {\n                    \"name\": \"LOCAL\",\n                    \"code\": \"LOCAL\",\n                    \"label\": \"Local (0-50km)\",\n                    \"rateType\": \"Free\",\n                    \"flatRate\": 0,\n                    \"isDefault\": true,\n                    ...\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ]
      }
    },
    "/freight.reset_freight_zones": {
      "post": {
        "operationId": "pacific_bending_app.api.freight.reset_freight_zones",
        "summary": "Reset Freight Zones to default seed data.",
        "tags": [
          "Freight"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This endpoint:\n1. Archives any non-default custom zones (sets is_active=0)\n2. Upserts all default zones from fixtures/freight_zone.json\n3. Returns summary of actions taken\n\nIdempotent: Safe to run multiple times.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"created\": 2,\n            \"updated\": 3,\n            \"archived\": 1,\n            \"zones\": [\"LOCAL\", \"METRO\", ...]\n        },\n        \"message\": \"...\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/freight.update_freight_zone": {
      "post": {
        "operationId": "pacific_bending_app.api.freight.update_freight_zone",
        "summary": "Update an existing freight zone.",
        "tags": [
          "Freight"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Note: Code cannot be changed as it's the primary key.\n\nArgs:\n    name: Zone document name (code)\n    zone: JSON string of updated zone data\n\nReturns:\n    {\"success\": True, \"data\": {...}, \"message\": \"...\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "zone": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "zone"
                ]
              }
            }
          }
        }
      }
    },
    "/health.check": {
      "post": {
        "operationId": "pacific_bending_app.api.health.check",
        "summary": "Health check endpoint for monitoring and load balancers",
        "tags": [
          "Health"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns basic system health status:\n- Database connectivity\n- Cache (Redis) connectivity\n- Application status\n- Response time\n\nThis endpoint is public (allow_guest=True) so load balancers can access it.\n\nReturns:\n    Dictionary with health status\n\nExample Response:\n    {\n        \"status\": \"healthy\",\n        \"timestamp\": 1699564800,\n        \"checks\": {\n            \"database\": {\"status\": \"healthy\", \"response_time_ms\": 5},\n            \"cache\": {\"status\": \"healthy\", \"response_time_ms\": 2},\n            \"app\": {\"status\": \"healthy\"}\n        }\n    }"
      }
    },
    "/health.detailed_check": {
      "post": {
        "operationId": "pacific_bending_app.api.health.detailed_check",
        "summary": "Detailed health check with additional metrics",
        "tags": [
          "Health"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Requires authentication. Returns more detailed information:\n- PDF generation status\n- Storage status\n- Template count\n- Queue health\n- WebSocket health\n- Carbone service health\n- Performance metrics\n\nReturns:\n    Dictionary with detailed health status",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/health.installation_health_check": {
      "post": {
        "operationId": "pacific_bending_app.api.health.installation_health_check",
        "summary": "Application health with installation and business logic verification.",
        "tags": [
          "Health"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Requires authentication. Returns comprehensive health status including:\n- Database and cache connectivity\n- Installation prerequisites (Frappe version, DocTypes, custom fields, roles)\n- System configuration (company, fiscal years, warehouses)\n- Business logic health (service items, payment terms, price lists, settings)\n- Transitional legacy installation summary (compact by default; verbose details opt-in via include_legacy_details=1)\n\nReturns:\n    Dictionary with comprehensive health status\n\nExample Response:\n    {\n        \"status\": \"healthy\",\n        \"timestamp\": 1699564800,\n        \"checks\": {\n            \"database\": {\"status\": \"healthy\", \"response_time_ms\": 5},\n            \"cache\": {\"status\": \"healthy\", \"response_time_ms\": 2},\n            \"installation\": {\n                \"healthy\": true,\n                \"prerequisites\": {...},\n                \"configuration\": {...},\n                \"health\": {...}\n            }\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/health.installation_health_check_v2": {
      "post": {
        "operationId": "pacific_bending_app.api.health.installation_health_check_v2",
        "summary": "Contract-stable v2 installation health endpoint.",
        "tags": [
          "Health"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Uses state-based readiness checks from installation_status as the source\nof truth and separates blockers from advisories for deterministic consumers.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/health.ping": {
      "post": {
        "operationId": "pacific_bending_app.api.health.ping",
        "summary": "Ultra-simple ping endpoint",
        "tags": [
          "Health"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns immediate response without any checks.\nUseful for basic connectivity testing.\n\nReturns:\n    Simple \"pong\" response"
      }
    },
    "/inventory.add_line_item_to_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.add_line_item_to_batch",
        "summary": "Add line item to batch or create new batch with line item.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "DESIGN PRINCIPLE: Stock is ALWAYS tracked by QUANTITY (piece count).\nDimensions (L\u00d7W) are METADATA for display and grouping only.\nArea is CALCULATED from L\u00d7W, never stored.\n\nLOCATION: Derived from warehouse's parent Warehouse group (native ERPNext hierarchy).\n\nNew batch model: One batch holds multiple pieces at various dimensions.\nExample:\n    Batch PM20250001:\n    - Line 1: qty=4, length=10, length_unit=ft\n    - Line 2: qty=4, length=20, length_unit=ft\n    - Line 3: qty=2, length=4, length_unit=ft, width=8, width_unit=ft (sheet)\n\nArgs:\n    item_code: Item code to add stock for\n    quantity: Number of PIECES at this dimension (integer)\n    warehouse: Target child warehouse under a configured location group\n    batch_id: Existing batch ID (optional - creates new if not provided)\n    length: Length dimension value (for Length and Area items)\n    length_unit: Unit for length (ft, in, m, cm) - default \"ft\"\n    width: Width dimension value (for Area items only)\n    width_unit: Unit for width (ft, in, m, cm) - default \"ft\"\n    unit_weight: Weight per piece in lbs (optional)\n    notes: Optional notes for this line item\n    mill_cert: Optional Link to Mill Certificate DocType\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PM20250001\",\n            \"line_item_idx\": 0,\n            \"quantity\": 4,\n            \"length\": 10.0,\n            \"length_unit\": \"ft\",\n            \"dimension_type\": \"L\",\n            \"is_new_batch\": false\n        },\n        \"message\": \"Added 4 pieces (10.0 ft each) to batch PM20250001\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "quantity": {
                    "type": "integer"
                  },
                  "warehouse": {
                    "type": "string"
                  },
                  "batch_id": {
                    "type": "string"
                  },
                  "length": {
                    "type": "string"
                  },
                  "length_unit": {
                    "type": "string"
                  },
                  "width": {
                    "type": "string"
                  },
                  "width_unit": {
                    "type": "string"
                  },
                  "unit_weight": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "mill_cert": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code",
                  "quantity",
                  "warehouse"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.create_quantity_item": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.create_quantity_item",
        "summary": "Create a quantity-tracked item (hardware, consumables, etc.)",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Stock behavior is derived from item group by default:\n- Services -> non-stock (no batches)\n- Other groups -> stock item (batch tracked)\n\nSOLID: Single Responsibility - Creates quantity items only\nKISS: Minimal required fields, smart defaults\nIDEMPOTENT: Returns existing item when the resolved item code already exists\n\nArgs:\n    item_name: Display name for the item (required)\n    item_code: Optional SKU/item code (auto-generated if not provided)\n    category: Item group (default: \"Unit Items\")\n    unit: Stock UOM (default: \"Nos\" for stock, \"Hour\" for non-stock)\n    description: Optional description\n    is_stock_item: Optional explicit stock flag (non-service groups only)\n    include_item_in_manufacturing: Optional manufacturing eligibility flag\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"item_code\": \"UN-BOLT-375-G8\",\n            \"item_name\": \"3/8\" Grade 8 Bolt\",\n            \"has_batch_no\": 1,\n            \"is_new\": True/False,\n            ...\n        },\n        \"message\": \"Item created successfully\" | \"Existing item found\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_name": {
                    "type": "string"
                  },
                  "item_code": {
                    "type": "string"
                  },
                  "category": {
                    "type": "string"
                  },
                  "unit": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "is_stock_item": {
                    "type": "string"
                  },
                  "include_item_in_manufacturing": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_name"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.get_all_batches": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_all_batches",
        "summary": "Get all batches across all items with filtering.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Used by the \"Find Batch\" tab in UnifiedAddStockWizard to allow users\nto find and add stock to any existing batch directly.\n\nArgs:\n    search: Search term for batch ID or item name/code (partial match)\n    location: Filter by warehouse group (parent warehouse name)\n    mill_cert: Filter by mill certificate number (partial match)\n    material: Filter by material code (CS, SS, AL, etc.)\n    date_from: Filter batches created after this date (ISO format YYYY-MM-DD)\n    date_to: Filter batches created before this date (ISO format YYYY-MM-DD)\n    limit: Max results (default 50, max 200)\n    offset: Pagination offset\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": [{\n            \"batch_id\": \"PM20250001\",\n            \"item_code\": \"CS-SQT-2X2X14GA\",\n            \"item_name\": \"Carbon Steel Square Tube 2x2 14ga\",\n            \"available_qty\": 5,\n            \"available_dimension\": 87.5,\n            \"dimension_type\": \"L\",\n            \"unit\": \"ft\",\n            \"warehouse\": \"Maple Ridge - Raw Materials - PB\",\n            \"location\": \"Maple Ridge\",\n            \"mill_cert\": \"MC-12345\",\n            \"material\": \"CS\",\n            \"creation_date\": \"2025-01-15\"\n        }],\n        \"count\": 25,\n        \"total\": 150\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "search": {
                    "type": "string"
                  },
                  "item_code": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "mill_cert": {
                    "type": "string"
                  },
                  "material": {
                    "type": "string"
                  },
                  "stock_state": {
                    "type": "string"
                  },
                  "batch_status": {
                    "type": "string"
                  },
                  "added_sort": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/inventory.get_batch_attachments": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_batch_attachments",
        "summary": "Get attachments for a batch from ERPNext File records.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns minimal metadata needed by the UI and avoids direct client-side\nquerying of the File DocType.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.get_batch_details": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_batch_details",
        "summary": "Get detailed batch information including dimensional tracking",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    batch_id: Batch identifier (e.g., PB.0042.2025)\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PB.0042.2025\",\n            \"item_code\": \"CS-SQT-2X2X14GA\",\n            \"item_name\": \"Carbon Steel Square Tube 2x2 14ga\",\n            \"dimension_type\": \"L\",\n            \"unit\": \"ft\",\n            \"original_dimension\": 20.0,\n            \"remaining_dimension\": 15.5,\n            \"consumed_dimension\": 4.5,\n            \"consumption_percent\": 22.5,\n            \"cut_count\": 2,\n            \"mill_certificate\": \"/files/mc-12345.pdf\",\n            \"mill_certificate_number\": \"MC-12345\",\n            \"warehouse_location\": \"Maple Ridge\",\n            \"stock_by_warehouse\": {...}\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.get_batch_details_bulk": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_batch_details_bulk",
        "summary": "Get detailed batch information for multiple batches in one request.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    batch_ids: JSON array of batch identifiers\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"PB.0042.2025\": {...batch detail payload...}\n        },\n        \"count\": 1\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_ids": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_ids"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.get_batch_genealogy": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_batch_genealogy",
        "summary": "Get full genealogy for a batch - both upstream and downstream.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Upstream: What raw material batches were consumed to make this batch?\nDownstream: What output batches was this raw material used to produce?\n\nArgs:\n    batch_id: Batch to get genealogy for\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PM20260100\",\n            \"item_code\": \"FG-RAILINGS-001\",\n            \"upstream\": [\n                {\n                    \"source_batch\": \"PM20260001\",\n                    \"item_code\": \"CS-SQT-2X2X14GA\",\n                    \"qty_consumed\": 5.0,\n                    \"consumed_at\": \"2026-01-10 10:30:00\",\n                    \"job_card\": \"JC-00123\"\n                }\n            ],\n            \"downstream\": [\n                {\n                    \"produced_batch\": \"PM20260150\",\n                    \"item_code\": \"FG-ASSEMBLY-001\",\n                    \"qty_consumed\": 2.0,\n                    \"consumed_at\": \"2026-01-11 14:00:00\"\n                }\n            ]\n        },\n        \"message\": \"Batch genealogy retrieved\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.get_batches_for_item": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_batches_for_item",
        "summary": "Get all batches for an item with stock availability and QC status.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Used by BatchSelector component for batch traceability UI.\nReturns batches FIFO-sorted by expiry date.\n\nArgs:\n    item_code: Item code to get batches for\n    warehouse: Optional warehouse filter\n    include_expired: Include expired batches in results\n    include_no_stock: Include batches with zero available stock\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"batches\": [\n                {\n                    \"batch_id\": \"PM20250001\",\n                    \"name\": \"PM20250001\",\n                    \"item_code\": \"STEEL-304\",\n                    \"item_name\": \"304 Stainless Steel Plate\",\n                    \"warehouse\": \"Maple Ridge - PB\",\n                    \"manufacturing_date\": \"2025-01-15\",\n                    \"expiry_date\": \"2026-01-15\",\n                    \"qty\": 100.0,\n                    \"reserved_qty\": 10.0,\n                    \"available_qty\": 90.0,\n                    \"qc_status\": \"Passed\",\n                    \"custom_heat_number\": \"ABC123\",\n                    \"custom_vendor\": \"ACME Steel\",\n                    \"custom_mill_certificate_number\": \"MC-001\",\n                    \"custom_has_mill_certificate\": true,\n                    \"disabled\": false\n                },\n                ...\n            ],\n            \"total_batches\": int,\n            \"total_available_qty\": float,\n            \"total_reserved_qty\": float\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "warehouse": {
                    "type": "string"
                  },
                  "include_expired": {
                    "type": "boolean"
                  },
                  "include_no_stock": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.get_inventory_items": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_inventory_items",
        "summary": "Get inventory items with strategy-aware stock display",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns items with dimensional availability (length/area) alongside quantity.\nEach item's display is determined by its shape:\n- Linear (Tube, Bar, Pipe): Shows remaining length in ft\n- Sheet (Plate, Sheet): Shows remaining area in sqft\n- Discrete: Shows quantity\n\nArgs:\n    search: Search term for item name/code\n    item_group: Filter by item group\n    shape: Filter by shape (Tube, Plate, etc.)\n    material: Filter by material code (CS, SS, AL, etc.)\n    dimension_type: Filter by tracking type (\"L\", \"LxW\", \"Qty\", \"Weight\")\n    template_only: Only include template items (custom_is_template=1)\n    location: Filter by warehouse location\n    show_out_of_stock: Include zero-stock items (default False)\n    include_disabled: Include disabled items (Admin only, default False)\n    limit: Max results (default 50, max 200)\n    offset: Pagination offset\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": [{\n            \"item_code\": \"CS-SQT-2X2X14GA\",\n            \"item_name\": \"Carbon Steel Square Tube 2x2 14ga\",\n            \"shape\": \"Tube\",\n            \"dimension_type\": \"L\",\n            \"unit\": \"ft\",\n            \"total_qty\": 5,\n            \"total_dimension\": 87.5,\n            \"stock_status\": \"in_stock\",\n            \"batch_count\": 3\n        }],\n        \"count\": 25,\n        \"total\": 150\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "search": {
                    "type": "string"
                  },
                  "item_group": {
                    "type": "string"
                  },
                  "item_groups": {
                    "type": "string"
                  },
                  "item_type": {
                    "type": "string"
                  },
                  "shape": {
                    "type": "string"
                  },
                  "material": {
                    "type": "string"
                  },
                  "dimension_type": {
                    "type": "string"
                  },
                  "template_only": {
                    "type": "boolean"
                  },
                  "location": {
                    "type": "string"
                  },
                  "show_out_of_stock": {
                    "type": "boolean"
                  },
                  "include_disabled": {
                    "type": "boolean"
                  },
                  "added_sort": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/inventory.get_inventory_overview": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_inventory_overview",
        "summary": "Get compact inventory overview stats and alert rows for dashboard surfaces.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This avoids sending the full inventory collection to the client for widgets\nthat only need aggregate counts plus a small alert sample.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "include_disabled": {
                    "type": "boolean"
                  },
                  "max_alerts": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/inventory.get_item_history": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_item_history",
        "summary": "Get purchase, sales, and quotation history for an item (and variants if applicable).",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Used in quote line items to show historical pricing and transaction context.\nFor template items with variants, includes history for all variant item codes.\n\nArgs:\n    item_code: Item code to query\n    include_variants: Include variant items for templates (default: True)\n    limit: Max records per section (default: 50)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"itemCode\": \"CS-SQT-2X2X14GA\",\n            \"itemName\": \"2x2 Square Tube\",\n            \"isService\": False,\n            \"isTemplate\": True,\n            \"purchaseOrders\": [...],\n            \"purchaseOrderCount\": 15,\n            \"salesOrders\": [...],\n            \"salesOrderCount\": 8,\n            \"quotations\": [...],\n            \"quotationCount\": 12\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "include_variants": {
                    "type": "boolean"
                  },
                  "limit": {
                    "type": "integer"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.get_stock_for_quoting": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_stock_for_quoting",
        "summary": "Get detailed stock with per-batch breakdown.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns dimensional availability for each item with batch breakdown.\n\nArgs:\n    item_codes: JSON array of item codes (e.g., '[\"ITEM-001\", \"ITEM-002\"]')\n    location: Optional location filter\n    include_empty: If True, include batches with 0 stock (for traceability)\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"CS-PLT-0.25\": {\n                \"item_name\": \"Carbon Steel Plate 1/4in\",\n                \"dimension_type\": \"LxW\",\n                \"unit\": \"sqft\",\n                \"total_available\": 96.0,\n                \"stock_status\": \"in_stock\",\n                \"batches\": [\n                    {\n                        \"batch_id\": \"PM20250004\",\n                        \"available\": 96.0,\n                        \"available_qty\": 3,\n                        \"location\": \"Maple Ridge\",\n                        \"warehouse\": \"Maple Ridge - Raw Materials - PB\",\n                        \"mill_cert\": \"MC-12345\",\n                        \"line_items\": [\n                            {\n                                \"idx\": 0,\n                                \"initial_qty\": 3,\n                                \"available_qty\": 3,\n                                \"consumed_qty\": 0,\n                                \"length\": 4.0,\n                                \"length_unit\": \"ft\",\n                                \"width\": 8.0,\n                                \"width_unit\": \"ft\",\n                                \"dimension_display\": \"4\u00d78 ft\"\n                            }\n                        ]\n                    }\n                ]\n            }\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_codes": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "include_empty": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "item_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.get_stock_integrity_alert_for_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_stock_integrity_alert_for_batch",
        "summary": "Return the active stock-integrity alert (if any) for one batch.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.get_stock_integrity_summary": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.get_stock_integrity_summary",
        "summary": "Read-only stock-integrity rollup for inventory dashboards.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/inventory.link_mill_certificate_to_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.link_mill_certificate_to_batch",
        "summary": "Link an uploaded mill certificate file to a batch",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "The file should already be uploaded via Frappe's file upload API.\nThis endpoint links the uploaded file to the batch's custom field.\n\nArgs:\n    batch_id: Batch identifier (e.g., PM20250001)\n    file_url: URL of the uploaded file (e.g., /files/mill-cert.pdf)\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PM20250001\",\n            \"mill_certificate\": \"/files/mill-cert.pdf\"\n        },\n        \"message\": \"Mill certificate linked successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "file_url": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id",
                  "file_url"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.pre_register_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.pre_register_batch",
        "summary": "Pre-register an empty batch for upcoming material.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Creates batch with status='Pre-Registered' and qty=0.\nStock is added later via add_line_item_to_batch() or quick_add_stock().\n\nUse Cases:\n1. PO Confirmation: Reserve batch ID when supplier confirms order\n2. In-Transit Tracking: Material shipped but not yet received\n3. Production Planning: Reserve output batch ID before WO starts\n\nArgs:\n    item_code: Item to create batch for\n    warehouse: Target warehouse (determines batch ID prefix)\n    batch_id: Optional custom batch ID (auto-generated if not provided)\n    vendor: Optional Link to Supplier DocType\n    heat_number: Vendor's heat number for traceability\n    mill_certificate_number: Mill certificate reference\n    purchase_order: Optional Link to Purchase Order DocType\n    expected_quantity: Expected pieces (for planning)\n    expected_date: Expected arrival date (YYYY-MM-DD)\n    notes: Optional notes\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PM20260001\",\n            \"status\": \"Pre-Registered\",\n            \"item_code\": \"CS-SQT-2X2X14GA\",\n            \"warehouse\": \"Maple Ridge - Raw Materials - PB\"\n        },\n        \"message\": \"Batch pre-registered successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "warehouse": {
                    "type": "string"
                  },
                  "batch_id": {
                    "type": "string"
                  },
                  "vendor": {
                    "type": "string"
                  },
                  "heat_number": {
                    "type": "string"
                  },
                  "mill_certificate_number": {
                    "type": "string"
                  },
                  "purchase_order": {
                    "type": "string"
                  },
                  "expected_quantity": {
                    "type": "string"
                  },
                  "expected_date": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code",
                  "warehouse"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.pre_register_production_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.pre_register_production_batch",
        "summary": "Pre Register Production Batch",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.quick_add_stock": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.quick_add_stock",
        "summary": "Quick stock addition for receiving materials and non-batch stock items.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "DESIGN PRINCIPLE: All availability tracking is QUANTITY-BASED (piece counts).\nDimensions (L\u00d7W) are METADATA ONLY for display and grouping purposes.\nArea is CALCULATED from L\u00d7W, never stored.\n\nLOCATION: Derived from warehouse's parent Warehouse group (native ERPNext hierarchy).\n\nCOMPANY CONTEXT (v6.4): Data-driven company resolution from business context.\nWarehouses are shared infrastructure (company=NULL). Company is derived from:\n1. Customer's company (if customer provided)\n2. Purchase Order's company\n3. Work Order's customer's company\n4. Global default (fallback)\n\nBatch-tracked behavior:\n- Creates ONE batch with ONE line item containing all pieces at the same dimension.\n- For multiple dimensions, call this function multiple times or use add_line_item_to_batch.\n\nNon-batch behavior:\n- Creates a Material Receipt directly against the warehouse.\n- Skips batch creation and returns `batch_id=None`.\n\nArgs:\n    item_code: Item code to add stock for\n    qty: Number of PIECES (the trackable unit - always integer)\n    warehouse: Target child warehouse under a configured location group\n    piece_length: Length dimension value (for Length and Area items)\n    length_unit: Unit for length (ft, in, m, cm) - default \"ft\"\n    piece_width: Width dimension value (for Area items only)\n    width_unit: Unit for width (ft, in, m, cm) - default \"ft\"\n    notes: Optional notes\n    mill_certificate_number: Optional mill cert reference\n    mill_cert: Optional Link to Mill Certificate DocType\n    custom_parameters: JSON array of custom parameters\n    batch_id: Optional existing batch ID to add to (creates new if not provided)\n    customer: Customer name (for company resolution) - v6.4\n    purchase_order: Purchase Order ID (for company resolution) - v6.4\n    work_order: Work Order ID (for company resolution) - v6.4\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PM20250001\" | null,\n            \"stock_entry\": \"MAT-STE-0001\",\n            \"total_qty\": 4,\n            \"piece_length\": 20.0,\n            \"length_unit\": \"ft\",\n            \"piece_width\": null,\n            \"width_unit\": null,\n            \"dimension_type\": \"L\",\n            \"is_new_batch\": true,\n            \"company\": \"Test Hospital Corp\"  # v6.4: Derived company\n        },\n        \"message\": \"Added 4 pieces (20 ft each) to batch PM20250001\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "qty": {
                    "type": "integer"
                  },
                  "warehouse": {
                    "type": "string"
                  },
                  "piece_length": {
                    "type": "string"
                  },
                  "length_unit": {
                    "type": "string"
                  },
                  "piece_width": {
                    "type": "string"
                  },
                  "width_unit": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "mill_certificate_number": {
                    "type": "string"
                  },
                  "mill_cert": {
                    "type": "string"
                  },
                  "custom_parameters": {
                    "type": "string"
                  },
                  "batch_id": {
                    "type": "string"
                  },
                  "customer": {
                    "type": "string"
                  },
                  "purchase_order": {
                    "type": "string"
                  },
                  "work_order": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code",
                  "qty",
                  "warehouse"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.record_consumption": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.record_consumption",
        "summary": "Record material consumption from batch.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Strategy-aware: uses length for linear, area for sheets, qty for discrete.\n\nIMPORTANT: Consumption is blocked by active reservations. If material is\nreserved by someone, it cannot be consumed until released.\n\nArgs:\n    batch_id: Source batch\n    amount: Amount consumed (in batch's unit: ft, sqft, or qty)\n    work_order: Optional work order reference\n    job_card: Optional job card reference\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PM20250001\",\n            \"consumed_amount\": 10.5,\n            \"remaining_amount\": 5.0,\n            \"unit\": \"ft\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "amount": {
                    "type": "number"
                  },
                  "work_order": {
                    "type": "string"
                  },
                  "job_card": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id",
                  "amount"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.transfer_batch_between_locations": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.transfer_batch_between_locations",
        "summary": "Transfer material from one location to another",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Creates a new child batch at the destination location with a new ID (PM/PX prefix).\nLinks the destination batch to the source batch as parent lineage for traceability.\nCreates stock entries (Material Issue + Material Receipt) to preserve\ninventory balance while creating a new destination batch.\n\nArgs:\n    source_batch_id: Source batch ID (e.g., \"PM20250001\")\n    target_location: Target location (warehouse group, child warehouse, or location display name)\n    qty: Quantity to transfer (in batch's unit: ft, sqft, or qty)\n    notes: Optional transfer notes\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"source_batch_id\": \"PM20250001\",\n            \"destination_batch_id\": \"PX20250001\",\n            \"qty_transferred\": 10.0,\n            \"unit\": \"ft\",\n            \"stock_entry_id\": \"MAT-00123\"\n        },\n        \"message\": \"Transferred 10.0 ft from PM20250001 to PX20250001\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source_batch_id": {
                    "type": "string"
                  },
                  "target_location": {
                    "type": "string"
                  },
                  "qty": {
                    "type": "number"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "source_batch_id",
                  "target_location",
                  "qty"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.update_batch_details": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.update_batch_details",
        "summary": "Update batch traceability details",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Allows updating:\n- Mill certificate number\n- Heat number (vendor's heat number for traceability)\n- Vendor (link to ERPNext Supplier)\n- Inventory date (date batch was added to inventory)\n- Purchase Order (link to ERPNext Purchase Order)\n- Notes (appended to batch comments)\n\nNote: Warehouse is determined by Stock Ledger Entry (native ERPNext pattern).\nTo move a batch to a different warehouse, use Stock Entry (Material Transfer).\n\nArgs:\n    batch_id: Batch identifier (e.g., PM20250001)\n    mill_certificate_number: Mill cert reference number (optional)\n    heat_number: Vendor's heat number for traceability (optional)\n    vendor: Link to Supplier DocType (optional)\n    inventory_date: Date batch was added to inventory (optional)\n    purchase_order: Link to Purchase Order DocType (optional)\n    notes: Additional notes to append (optional)\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PM20250001\",\n            \"mill_certificate_number\": \"MC-2025-12345\",\n            \"heat_number\": \"HT-2025-001\",\n            \"vendor\": \"Metal Supplier Inc\",\n            \"inventory_date\": \"2025-01-15\",\n            \"purchase_order\": \"PO-00001\",\n            \"updated_fields\": [\"mill_certificate_number\"]\n        },\n        \"message\": \"Batch updated successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "mill_certificate_number": {
                    "type": "string"
                  },
                  "heat_number": {
                    "type": "string"
                  },
                  "vendor": {
                    "type": "string"
                  },
                  "inventory_date": {
                    "type": "string"
                  },
                  "purchase_order": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/inventory.update_batch_status": {
      "post": {
        "operationId": "pacific_bending_app.api.inventory.update_batch_status",
        "summary": "Transition batch to a new status with audit trail.",
        "tags": [
          "Inventory"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Valid Transitions:\n- Pre-Registered \u2192 In-Transit (material shipped)\n- Pre-Registered \u2192 Active (stock received directly)\n- In-Transit \u2192 Active (material arrived)\n- Active \u2192 Depleted (all stock consumed)\n\nNote: Depleted is a terminal state (cannot transition out).\nUse stock adjustments for corrections.\n\nArgs:\n    batch_id: Batch to update\n    new_status: Target status (Pre-Registered, In-Transit, Active, Depleted)\n    notes: Optional notes explaining the transition\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PM20260001\",\n            \"old_status\": \"Pre-Registered\",\n            \"new_status\": \"In-Transit\",\n            \"transitioned_at\": \"2026-01-12 10:30:00\"\n        },\n        \"message\": \"Batch status updated successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "new_status": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id",
                  "new_status"
                ]
              }
            }
          }
        }
      }
    },
    "/items.disable_item": {
      "post": {
        "operationId": "pacific_bending_app.api.items.disable_item",
        "summary": "Soft delete an item by setting disabled=1.",
        "tags": [
          "Items"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only disables items\nBest Practice: Soft delete preserves referential integrity\n\nThis is the preferred method for \"deleting\" items because:\n- Preserves existing batches and transactions\n- Maintains historical data for reporting\n- Reversible via enable_item()\n- ERPNext native pattern (disabled field)\n\nArgs:\n    item_code: Item code to disable\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\"item_code\": \"ITEM-001\", \"disabled\": 1},\n        \"message\": \"Item ITEM-001 has been disabled\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/items.enable_item": {
      "post": {
        "operationId": "pacific_bending_app.api.items.enable_item",
        "summary": "Re-enable a disabled item by setting disabled=0.",
        "tags": [
          "Items"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only enables items\nBest Practice: Allows reversing soft delete\n\nArgs:\n    item_code: Item code to enable\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\"item_code\": \"ITEM-001\", \"disabled\": 0},\n        \"message\": \"Item ITEM-001 has been re-enabled\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/items.get_item_manufacturing_profile": {
      "post": {
        "operationId": "pacific_bending_app.api.items.get_item_manufacturing_profile",
        "summary": "Return native Item\u2194BOM linkage for UI/UX manufacturing surfaces.",
        "tags": [
          "Items"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Ownership model:\n- Master link: BOM.item + Item.default_bom\n- Transaction override: Sales Order Item.bom_no",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/items.get_item_stock_details": {
      "post": {
        "operationId": "pacific_bending_app.api.items.get_item_stock_details",
        "summary": "Get detailed stock information for a specific item",
        "tags": [
          "Items"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves stock details for one item\nKISS: Simple aggregation query\n\nArgs:\n    item_code: Item code to get stock for\n    location: Filter by location (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"item_code\": \"STEEL-PLATE-001\",\n            \"item_name\": \"Steel Plate 4x8 A36\",\n            \"total_actual_qty\": 150.0,\n            \"total_reserved_qty\": 30.0,\n            \"total_available_qty\": 120.0,\n            \"warehouses\": [\n                {\n                    \"warehouse\": \"Main Store - MR\",\n                    \"actual_qty\": 100.0,\n                    \"reserved_qty\": 20.0,\n                    \"available_qty\": 80.0\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/items.get_items_with_stock": {
      "post": {
        "operationId": "pacific_bending_app.api.items.get_items_with_stock",
        "summary": "Get items with real-time stock availability",
        "tags": [
          "Items"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves items with stock data\nKISS: Simple query builder pattern\nDRY: Reuses Frappe Query Builder\n\nFeatures:\n- Real-time stock availability from Bin table\n- Reserved quantity calculation (allocated to Work Orders)\n- Stock status indicators (in_stock, low_stock, out_of_stock)\n- Warehouse breakdown per item\n- Location-aware filtering (multi-location support)\n\nArgs:\n    search: Search term for item name/code (optional)\n    limit: Maximum items to return (default: 50, max: 200)\n    item_group: Filter by item group (optional)\n    show_out_of_stock: Include out-of-stock items (default: True)\n    location: Filter by location (optional, multi-location support)\n    include_disabled: Include disabled items - Admin only (default: False)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"ITEM-00123\",\n                \"item_code\": \"STEEL-PLATE-001\",\n                \"item_name\": \"Steel Plate 4x8 A36\",\n                \"description\": \"Hot rolled steel plate...\",\n                \"standard_rate\": 125.50,\n                \"uom\": \"Nos\",\n                \"item_group\": \"Raw Material\",\n                \"actual_qty\": 150.0,\n                \"reserved_qty\": 30.0,\n                \"projected_qty\": 120.0,\n                \"available_qty\": 120.0,\n                \"reorder_level\": 25,\n                \"lead_time_days\": 7,\n                \"stock_status\": \"in_stock\",\n                \"stock_badge_color\": \"green\",\n                \"warehouses\": [\n                    {\"warehouse\": \"Main Store - MR\", \"actual_qty\": 100.0},\n                    {\"warehouse\": \"WIP Store - MR\", \"actual_qty\": 50.0}\n                ]\n            }\n        ],\n        \"message\": \"Items with stock retrieved successfully\",\n        \"count\": 25\n    }\n\nRaises:\n    frappe.ValidationError: If limit exceeds 200",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "search": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "item_group": {
                    "type": "string"
                  },
                  "show_out_of_stock": {
                    "type": "boolean"
                  },
                  "location": {
                    "type": "string"
                  },
                  "include_disabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/items.set_item_default_bom": {
      "post": {
        "operationId": "pacific_bending_app.api.items.set_item_default_bom",
        "summary": "Set active/submitted default BOM for an item.",
        "tags": [
          "Items"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Idempotent:\n- Repeating the same request returns success without duplicating state changes.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "bom_no": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code",
                  "bom_no"
                ]
              }
            }
          }
        }
      }
    },
    "/items.update_item": {
      "post": {
        "operationId": "pacific_bending_app.api.items.update_item",
        "summary": "Update item fields for inventory management.",
        "tags": [
          "Items"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Allows Admin, Foreman, and Estimator roles to edit item settings:\n- Pricing: Variance threshold for quote warnings\n- Material defaults: Rounding increment\n- Other: Freight cost, weight per sqft, internal notes\n- Default attributes: Per-item override of shape defaults\n\nArgs:\n    item_code: The item code to update\n    updates: Dictionary of field values to update\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {...updated_item_fields...},\n        \"message\": \"Item updated successfully\"\n    }\n\nRaises:\n    frappe.ValidationError: If item not found or validation fails",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "updates": {
                    "type": "object"
                  }
                },
                "required": [
                  "item_code",
                  "updates"
                ]
              }
            }
          }
        }
      }
    },
    "/item_variants.activate_variant": {
      "post": {
        "operationId": "pacific_bending_app.api.item_variants.activate_variant",
        "summary": "Reactivate a soft-deleted variant.",
        "tags": [
          "Item Variants"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    variant_id: Variant document ID\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\"variantId\": \"...\", \"active\": true},\n        \"message\": \"Variant activated\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "variant_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "variant_id"
                ]
              }
            }
          }
        }
      }
    },
    "/item_variants.bulk_create_variants": {
      "post": {
        "operationId": "pacific_bending_app.api.item_variants.bulk_create_variants",
        "summary": "Bulk create variants for a template item.",
        "tags": [
          "Item Variants"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Partial success handling: returns both created variants and errors.\n\nArgs:\n    item_code: Parent template item code\n    variants: List of variant objects with keys:\n        - dimensionType, length, lengthUnit, width, widthUnit\n        - weight, weightUnit, variantName, customRate, displayOrder\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"created\": [...successfully created variants...],\n            \"errors\": [...failed variants with error messages...]\n        },\n        \"message\": \"Created X variants with Y errors\"\n    }\n\nExample Input:\n    variants: [\n        {\"dimensionType\": \"L\", \"length\": 20, \"lengthUnit\": \"ft\"},\n        {\"dimensionType\": \"L\", \"length\": 24, \"lengthUnit\": \"ft\"}\n    ]",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "variants": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code",
                  "variants"
                ]
              }
            }
          }
        }
      }
    },
    "/item_variants.create_variant": {
      "post": {
        "operationId": "pacific_bending_app.api.item_variants.create_variant",
        "summary": "Create a new variant for a template item.",
        "tags": [
          "Item Variants"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "The variant_name will be auto-generated from dimensions if not provided.\nThe dimension_type will be inherited from parent item if not specified.\n\nArgs:\n    item_code: Parent template item code (required)\n    dimension_type: L, LxW, Weight, or Qty (optional - inherits from parent)\n    length: Length value (required for L and LxW types)\n    length_unit: Unit for length (ft/in/m/cm/mm, default: ft)\n    width: Width value (required for LxW type)\n    width_unit: Unit for width (default: ft)\n    weight: Weight value (required for Weight type)\n    weight_unit: Unit for weight (kg/lb/g/oz, default: lb)\n    variant_name: Human-readable name (auto-generated if not provided)\n    custom_rate: Variant-specific rate override\n    custom_attributes: JSON for future extensibility\n    display_order: Sort order in UI (default: 0)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": { ...created variant... },\n        \"message\": \"Variant created successfully\"\n    }\n\nRaises:\n    ValidationError: If parent item is not a template\n    ValidationError: If required dimensions are missing for dimension_type",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "dimension_type": {
                    "type": "string"
                  },
                  "length": {
                    "type": "string"
                  },
                  "length_unit": {
                    "type": "string"
                  },
                  "width": {
                    "type": "string"
                  },
                  "width_unit": {
                    "type": "string"
                  },
                  "weight": {
                    "type": "string"
                  },
                  "weight_unit": {
                    "type": "string"
                  },
                  "variant_name": {
                    "type": "string"
                  },
                  "custom_rate": {
                    "type": "string"
                  },
                  "custom_attributes": {
                    "type": "string"
                  },
                  "display_order": {
                    "type": "integer"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/item_variants.deactivate_variant": {
      "post": {
        "operationId": "pacific_bending_app.api.item_variants.deactivate_variant",
        "summary": "Soft-delete a variant by setting active=0.",
        "tags": [
          "Item Variants"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Variants are never hard-deleted to preserve history.\n\nArgs:\n    variant_id: Variant document ID\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\"variantId\": \"...\", \"active\": false},\n        \"message\": \"Variant deactivated\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "variant_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "variant_id"
                ]
              }
            }
          }
        }
      }
    },
    "/item_variants.get_variant": {
      "post": {
        "operationId": "pacific_bending_app.api.item_variants.get_variant",
        "summary": "Get a single variant by ID.",
        "tags": [
          "Item Variants"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    variant_id: Variant document ID\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": { ...variant object... },\n        \"message\": \"Success\"\n    }\n\nRaises:\n    DoesNotExistError: If variant not found",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "variant_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "variant_id"
                ]
              }
            }
          }
        }
      }
    },
    "/item_variants.get_variant_runtime_settings": {
      "post": {
        "operationId": "pacific_bending_app.api.item_variants.get_variant_runtime_settings",
        "summary": "Expose variant runtime compatibility settings for UI hints.",
        "tags": [
          "Item Variants"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/item_variants.get_variant_shadow_mismatches": {
      "post": {
        "operationId": "pacific_bending_app.api.item_variants.get_variant_shadow_mismatches",
        "summary": "Return variant shadow mismatch telemetry rows for admin audit.",
        "tags": [
          "Item Variants"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "integer"
                  },
                  "start": {
                    "type": "integer"
                  },
                  "item_code": {
                    "type": "string"
                  },
                  "mismatch_reason": {
                    "type": "string"
                  },
                  "blocked": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/item_variants.get_variants": {
      "post": {
        "operationId": "pacific_bending_app.api.item_variants.get_variants",
        "summary": "Get all variants for a template item.",
        "tags": [
          "Item Variants"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves variant data\nKISS: Simple query with camelCase transformation\n\nArgs:\n    item_code: Parent template item code (required)\n    include_inactive: Include inactive (soft-deleted) variants (default: False)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"id\": \"abc123\",\n                \"itemCode\": \"CS-SQT-2X2X14GA\",\n                \"variantName\": \"20 ft\",\n                \"dimensionType\": \"L\",\n                \"length\": 20.0,\n                \"lengthUnit\": \"ft\",\n                \"active\": true,\n                ...\n            }\n        ],\n        \"message\": \"Success\"\n    }\n\nRaises:\n    ValidationError: If item_code not provided",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "include_inactive": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/item_variants.get_variants_and_stock_level": {
      "post": {
        "operationId": "pacific_bending_app.api.item_variants.get_variants_and_stock_level",
        "summary": "Get Item Variants with stock availability levels.",
        "tags": [
          "Item Variants"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns pre-defined variants (from Item Variant DocType) enriched\nwith current batch availability data. Unlike get_variants(), this\nendpoint shows ALL active variants regardless of stock status.\n\nSOLID: Combines variant catalog with dynamic stock data\nKISS: Single request returns complete data for UI rendering\n\nArgs:\n    item_code: Parent template item code (required)\n    location: Optional warehouse group to filter stock by location\n    include_inactive: Include inactive (soft-deleted) variants (default: False)\n    debug: Enable diagnostic logging for troubleshooting (default: False)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"id\": \"abc123\",\n                \"variantName\": \"20 ft\",\n                \"dimensionType\": \"L\",\n                \"length\": 20.0,\n                \"lengthUnit\": \"ft\",\n                \"customRate\": null,\n                \"displayOrder\": 1,\n                \"stockStatus\": \"in_stock\",\n                \"totalPieces\": 5,\n                \"batches\": [\n                    {\"batchId\": \"PM001\", \"availablePieces\": 3, \"location\": \"MR\"},\n                    {\"batchId\": \"PM002\", \"availablePieces\": 2, \"location\": \"MR\"}\n                ]\n            },\n            {\n                \"id\": \"def456\",\n                \"variantName\": \"10 ft\",\n                \"stockStatus\": \"out_of_stock\",\n                \"totalPieces\": 0,\n                \"batches\": []\n            }\n        ],\n        \"message\": \"Success\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "include_inactive": {
                    "type": "boolean"
                  },
                  "debug": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/item_variants.reorder_variants": {
      "post": {
        "operationId": "pacific_bending_app.api.item_variants.reorder_variants",
        "summary": "Update display_order for multiple variants at once.",
        "tags": [
          "Item Variants"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Useful for drag-and-drop reordering in UI.\n\nArgs:\n    variant_orders: List of {id, displayOrder} objects\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\"updated\": X},\n        \"message\": \"Updated display order for X variants\"\n    }\n\nExample Input:\n    variant_orders: [\n        {\"id\": \"abc123\", \"displayOrder\": 0},\n        {\"id\": \"def456\", \"displayOrder\": 10},\n        {\"id\": \"ghi789\", \"displayOrder\": 20}\n    ]",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "variant_orders": {
                    "type": "string"
                  }
                },
                "required": [
                  "variant_orders"
                ]
              }
            }
          }
        }
      }
    },
    "/item_variants.update_variant": {
      "post": {
        "operationId": "pacific_bending_app.api.item_variants.update_variant",
        "summary": "Update an existing variant.",
        "tags": [
          "Item Variants"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Only provided fields will be updated (None = no change).\n\nArgs:\n    variant_id: Variant document ID (required)\n    Other args: Fields to update (None = no change)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": { ...updated variant... },\n        \"message\": \"Variant updated successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "variant_id": {
                    "type": "string"
                  },
                  "variant_name": {
                    "type": "string"
                  },
                  "dimension_type": {
                    "type": "string"
                  },
                  "length": {
                    "type": "string"
                  },
                  "length_unit": {
                    "type": "string"
                  },
                  "width": {
                    "type": "string"
                  },
                  "width_unit": {
                    "type": "string"
                  },
                  "weight": {
                    "type": "string"
                  },
                  "weight_unit": {
                    "type": "string"
                  },
                  "custom_rate": {
                    "type": "string"
                  },
                  "custom_attributes": {
                    "type": "string"
                  },
                  "display_order": {
                    "type": "string"
                  }
                },
                "required": [
                  "variant_id"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.delete_attribute_type": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.delete_attribute_type",
        "summary": "Soft delete an attribute type (sets active=0).",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    code: Attribute type code to delete\n    force: If True, permanently delete (default: False)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Attribute type deleted successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "force": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "code"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.delete_attribute_value": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.delete_attribute_value",
        "summary": "Soft delete an attribute value (sets active=0).",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    attribute_type: The parent attribute type code\n    code: Value code to delete\n    force: If True, permanently delete (default: False)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Attribute value deleted successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "attribute_type": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  },
                  "force": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "attribute_type",
                  "code"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.delete_dimension_preset": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.delete_dimension_preset",
        "summary": "Soft delete a dimension preset (sets active=0).",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    preset_name: Preset name to delete\n    force: If True, permanently delete (default: False)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Dimension preset deleted successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "preset_name": {
                    "type": "string"
                  },
                  "force": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "preset_name"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.delete_material": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.delete_material",
        "summary": "Soft delete a material (sets active=0).",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only handles deletion\nKISS: Soft delete prevents data loss\n\nNote: Internal DocType is still \"Material Metal Type\" for database compatibility.\n\nArgs:\n    code: Material code to delete\n    force: If True, permanently delete (default: False, soft delete)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Material deleted successfully\"\n    }\n\nRaises:\n    ValidationError: If material is in use by items",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "force": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "code"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.delete_shape": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.delete_shape",
        "summary": "Soft delete a shape (sets active=0).",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    code: Shape code to delete\n    force: If True, permanently delete (default: False)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Shape deleted successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "force": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "code"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.export_config": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.export_config",
        "summary": "Export all material configuration as JSON for backup/migration.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"version\": \"1.0\",\n            \"exported_at\": \"2025-12-13T00:00:00\",\n            \"materials\": [...],\n            \"shapes\": [...],\n            \"dimension_presets\": [...]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/material_config.get_all_unit_values": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.get_all_unit_values",
        "summary": "Get all unit-type attribute values grouped by type.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This is useful for the Item Wizard to populate unit selectors\nwithout making multiple API calls.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"length\": [{\"code\": \"in\", ...}, {\"code\": \"ft\", ...}],\n            \"weight\": [{\"code\": \"kg\", ...}, {\"code\": \"lb\", ...}],\n            \"thickness\": [{\"code\": \"14GA\", ...}, ...]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/material_config.get_attribute_types": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.get_attribute_types",
        "summary": "Get all item attribute types.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns attribute types like \"length\", \"weight\", \"thickness\", \"color\", etc.\nThese define categories of values that can be assigned to items.\n\nArgs:\n    active_only: If True, only return active types (default: True)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"code\": \"length\",\n                \"label\": \"Length\",\n                \"attributeType\": \"unit\",\n                \"description\": \"Linear measurements\",\n                \"codePosition\": \"suffix\",\n                \"required\": false,\n                \"appliesToAllShapes\": true,\n                \"appliesToShapes\": [],\n                \"displayOrder\": 10\n            },\n            ...\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active_only": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/material_config.get_attribute_types_for_shape": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.get_attribute_types_for_shape",
        "summary": "Get attribute types applicable to a specific shape.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    shape_code: The shape code (e.g., \"SQT\", \"RCT\")\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [...] // Filtered attribute types\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "shape_code": {
                    "type": "string"
                  }
                },
                "required": [
                  "shape_code"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.get_attribute_values": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.get_attribute_values",
        "summary": "Get all values for an attribute type.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    attribute_type: The attribute type code (e.g., \"length\", \"color\")\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"code\": \"in\",\n                \"label\": \"Inches\",\n                \"shortLabel\": \"in\",\n                \"attributeType\": \"length\",\n                \"codeSuffix\": \"in\",\n                \"baseValue\": \"length-mm\",\n                \"conversionFactor\": 25.4,\n                \"displayOrder\": 40\n            },\n            ...\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "attribute_type": {
                    "type": "string"
                  }
                },
                "required": [
                  "attribute_type"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.get_dimension_presets": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.get_dimension_presets",
        "summary": "Get all dimension presets.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    active_only: If True, only return active presets (default: True)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"preset_name\": \"Standard Wall Thickness\",\n                \"preset_type\": \"wall_thickness\",\n                \"options\": [{\"value\": \"1/8\", \"label\": \"1/8\"\"}, ...]\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active_only": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/material_config.get_material_config": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.get_material_config",
        "summary": "Get complete material configuration for wizard consumption.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Aggregates all config in one endpoint for performance\nKISS: Single API call for all wizard needs\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"materials\": [...],\n            \"shapes\": [...],\n            \"dimension_presets\": [...]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/material_config.get_materials": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.get_materials",
        "summary": "Get all materials with their grades and finishes.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves materials\nKISS: Returns complete hierarchy in one call\n\nNote: Internal DocType is still \"Material Metal Type\" for database compatibility.\n\nArgs:\n    active_only: If True, only return active materials (default: True)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"code\": \"CS\",\n                \"label\": \"Carbon Steel\",\n                \"description\": \"Most common structural steel\",\n                \"display_order\": 1,\n                \"active\": 1,\n                \"grades\": [\n                    {\"code\": \"A36\", \"label\": \"A36\", \"is_default\": 1, ...}\n                ],\n                \"finishes\": [\n                    {\"code\": \"HR\", \"label\": \"Hot Rolled\", \"is_default\": 1, ...}\n                ]\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active_only": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/material_config.get_shape_default_attributes": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.get_shape_default_attributes",
        "summary": "Get default attributes configured for a shape.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "These are attributes that should be shown by default when creating\nitems with this shape. Users can add additional attributes from\nthe full list of available attributes.\n\nArgs:\n    shape_code: The shape code (e.g., \"SQT\", \"RCT\")\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"code\": \"finish\",\n                \"label\": \"Finish\",\n                \"attributeType\": \"classification\",\n                \"isRequired\": true,\n                \"displayOrder\": 10,\n                // Additional numeric fields if applicable\n                \"numericUnitType\": null,\n                \"defaultUnit\": null,\n                \"allowUnitSelection\": true\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "shape_code": {
                    "type": "string"
                  }
                },
                "required": [
                  "shape_code"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.get_shapes": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.get_shapes",
        "summary": "Get all shapes with their dimension field configurations and default attributes.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves shapes\nKISS: Returns complete configuration in one call\n\nArgs:\n    active_only: If True, only return active shapes (default: True)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"code\": \"SQT\",\n                \"name\": \"Square Tube\",\n                \"short_name\": \"Sq Tube\",\n                \"category\": \"tube\",\n                \"dimension_type\": \"L\",\n                \"icon_name\": \"square\",\n                \"code_pattern\": \"{material}-{code}-{size}X{size}X{wall}\",\n                \"common_sizes\": [...],\n                \"dimension_fields\": [...],\n                \"default_attributes\": [\n                    {\n                        \"code\": \"finish\",\n                        \"label\": \"Finish\",\n                        \"attributeType\": \"classification\",\n                        \"isRequired\": False,\n                        \"displayOrder\": 1\n                    }\n                ]\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active_only": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/material_config.get_units_for_numeric_attribute": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.get_units_for_numeric_attribute",
        "summary": "Get available units for a numeric attribute type.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Numeric attributes link to existing unit types (like \"weight\" or \"length\")\nand use that type's values as available units.\n\nArgs:\n    attribute_code: The numeric attribute type code (e.g., \"item_weight\")\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\"code\": \"lb\", \"label\": \"Pounds\", \"shortLabel\": \"lb\", \"conversionFactor\": 1.0},\n            {\"code\": \"kg\", \"label\": \"Kilograms\", \"shortLabel\": \"kg\", \"conversionFactor\": 2.20462},\n            ...\n        ],\n        \"defaultUnit\": \"lb\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "attribute_code": {
                    "type": "string"
                  }
                },
                "required": [
                  "attribute_code"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.import_config": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.import_config",
        "summary": "Import material configuration from JSON.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    config: JSON string of configuration to import\n    merge: If True, merge with existing (default). If False, replace all.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"materials_imported\": 4,\n            \"shapes_imported\": 14,\n            \"presets_imported\": 3\n        },\n        \"message\": \"Configuration imported successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "config": {
                    "type": "string"
                  },
                  "merge": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "config"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.reorder_items": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.reorder_items",
        "summary": "Bulk update display_order for items.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    doctype: DocType to reorder ('Material Metal Type', 'Material Shape', 'Material Dimension Preset')\n    items: JSON array of {name: string, display_order: number}\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Items reordered successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "doctype": {
                    "type": "string"
                  },
                  "items": {
                    "type": "string"
                  }
                },
                "required": [
                  "doctype",
                  "items"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.save_attribute_type": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.save_attribute_type",
        "summary": "Create or update an attribute type.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    attribute_type: JSON string of attribute type configuration\n        {\n            \"code\": \"color\",\n            \"label\": \"Color\",\n            \"attribute_type\": \"classification\",\n            \"description\": \"Material color\",\n            \"code_position\": \"suffix\",\n            \"required\": false,\n            \"applies_to_all_shapes\": true\n        }\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {...},\n        \"message\": \"Attribute type saved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "attribute_type": {
                    "type": "string"
                  }
                },
                "required": [
                  "attribute_type"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.save_attribute_value": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.save_attribute_value",
        "summary": "Create or update an attribute value.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    attribute_value: JSON string of attribute value configuration\n        {\n            \"code\": \"RED\",\n            \"label\": \"Red\",\n            \"short_label\": \"Red\",\n            \"attribute_type\": \"color\",\n            \"code_suffix\": \"RED\",\n            \"base_value\": null,\n            \"conversion_factor\": 1.0\n        }\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {...},\n        \"message\": \"Attribute value saved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "attribute_value": {
                    "type": "string"
                  }
                },
                "required": [
                  "attribute_value"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.save_dimension_preset": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.save_dimension_preset",
        "summary": "Create or update a dimension preset.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    preset: JSON string of preset configuration\n        {\n            \"preset_name\": \"Standard Wall Thickness\",\n            \"preset_type\": \"wall_thickness\",\n            \"options\": [{\"value\": \"1/8\", \"label\": \"1/8\"\"}, ...]\n        }\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {...},\n        \"message\": \"Dimension preset saved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "preset": {
                    "type": "string"
                  }
                },
                "required": [
                  "preset"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.save_material": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.save_material",
        "summary": "Create or update a material with grades and finishes.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Handles material persistence\nKISS: Upsert pattern - create if not exists, update if exists\n\nNote: Internal DocType is still \"Material Metal Type\" for database compatibility.\n\nArgs:\n    material: JSON string of material configuration\n        {\n            \"code\": \"CS\",\n            \"label\": \"Carbon Steel\",\n            \"description\": \"Most common structural steel\",\n            \"display_order\": 1,\n            \"active\": true,\n            \"grades\": [\n                {\"code\": \"A36\", \"label\": \"A36\", \"is_default\": true, ...}\n            ],\n            \"finishes\": [\n                {\"code\": \"HR\", \"label\": \"Hot Rolled\", \"is_default\": true, ...}\n            ]\n        }\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {...},\n        \"message\": \"Material saved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "material": {
                    "type": "string"
                  }
                },
                "required": [
                  "material"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.save_shape": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.save_shape",
        "summary": "Create or update a shape with dimension fields and default attributes.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Handles shape persistence\nKISS: Upsert pattern - create if not exists, update if exists\n\nArgs:\n    shape: JSON string of shape configuration\n        {\n            \"code\": \"SQT\",\n            \"name\": \"Square Tube\",\n            \"short_name\": \"Sq Tube\",\n            \"category\": \"tube\",\n            \"dimension_type\": \"L\",\n            \"icon_name\": \"square\",\n            \"code_pattern\": \"{material}-{code}-{size}X{size}X{wall}\",\n            \"common_sizes\": [\"2x2\", \"3x3\", \"4x4\"],\n            \"dimension_fields\": [\n                {\"field_name\": \"size\", \"label\": \"Size\", \"field_type\": \"number\", ...}\n            ],\n            \"default_attributes\": [\n                {\n                    \"attribute_type\": \"finish\",\n                    \"is_required\": False,\n                    \"display_order\": 1\n                }\n            ]\n        }\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {...},\n        \"message\": \"Shape saved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "shape": {
                    "type": "string"
                  }
                },
                "required": [
                  "shape"
                ]
              }
            }
          }
        }
      }
    },
    "/material_config.seed_all_material_config": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.seed_all_material_config",
        "summary": "Seed all material configuration data: dimension presets, materials, and shapes.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Idempotent: Safe to run multiple times, will skip existing records.\n\nThis is the main entry point for initializing the material configuration system.\nCall this when the system shows \"no shapes configured\" or dimensions aren't appearing.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"dimension_presets\": {\"created\": 11, \"skipped\": 0},\n            \"materials\": {\"created\": 4, \"skipped\": 0},\n            \"shapes\": {\"created\": 10, \"skipped\": 0}\n        },\n        \"message\": \"Material configuration seeded successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/material_config.seed_dimension_presets": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.seed_dimension_presets",
        "summary": "Seed standard dimension presets for material configuration.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Idempotent: Safe to run multiple times, will skip existing presets.\n\nCreates 11 dimension presets (6 imperial + 5 metric):\n\nImperial:\n1. Standard Gauge Thickness (for sheets)\n2. Standard Wall Thickness (for tubes)\n3. Pipe Schedule\n4. Plate Thickness\n5. Bar Thickness\n6. Angle Thickness\n\nMetric:\n7. Metric Gauge Thickness (mm)\n8. Metric Wall Thickness (mm)\n9. Metric Plate Thickness (mm)\n10. Metric Bar Thickness (mm)\n11. Metric Angle Thickness (mm)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"created\": 11,\n            \"skipped\": 0,\n            \"presets\": [\"Standard Gauge Thickness\", ...]\n        },\n        \"message\": \"Dimension presets seeded successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/material_config.seed_item_attributes": {
      "post": {
        "operationId": "pacific_bending_app.api.material_config.seed_item_attributes",
        "summary": "Seed standard item attribute types and values.",
        "tags": [
          "Material Config"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Idempotent: Safe to run multiple times.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"types_created\": 5,\n            \"types_skipped\": 0,\n            \"values_created\": 35,\n            \"values_skipped\": 0\n        },\n        \"message\": \"Item attributes seeded successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/mill_certificate.create_mill_certificate": {
      "post": {
        "operationId": "pacific_bending_app.api.mill_certificate.create_mill_certificate",
        "summary": "Create a new mill certificate record.",
        "tags": [
          "Mill Certificate"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "The file must already be uploaded via Frappe's file upload mechanism.\nPass the file_url returned from the upload.\n\nArgs:\n    file_url: URL of the uploaded file (required)\n    certificate_number: Vendor's certificate number (optional)\n    purchase_order: Link to Purchase Order (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"name\": \"MC-00001\",\n            \"certificate_number\": \"MC-2025-12345\",\n            \"file\": \"/files/mill-cert.pdf\",\n            \"purchase_order\": \"PO-00123\",\n            \"supplier_info\": \"Steel Supplier Inc\"\n        },\n        \"message\": \"Mill certificate created successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "file_url": {
                    "type": "string"
                  },
                  "certificate_number": {
                    "type": "string"
                  },
                  "purchase_order": {
                    "type": "string"
                  }
                },
                "required": [
                  "file_url"
                ]
              }
            }
          }
        }
      }
    },
    "/mill_certificate.get_mill_certificate_detail": {
      "post": {
        "operationId": "pacific_bending_app.api.mill_certificate.get_mill_certificate_detail",
        "summary": "Get details of a specific mill certificate.",
        "tags": [
          "Mill Certificate"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    name: Mill Certificate name (e.g., MC-00001)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"name\": \"MC-00001\",\n            \"certificate_number\": \"MC-2025-12345\",\n            \"file\": \"/files/mill-cert.pdf\",\n            \"purchase_order\": \"PO-00123\",\n            \"supplier_info\": \"Steel Supplier Inc\",\n            \"creation\": \"2025-12-15 10:30:00\",\n            \"modified\": \"2025-12-15 10:30:00\",\n            \"batch_count\": 5\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/mill_certificate.get_recent_mill_certificates": {
      "post": {
        "operationId": "pacific_bending_app.api.mill_certificate.get_recent_mill_certificates",
        "summary": "Get recent mill certificates for dropdown selection.",
        "tags": [
          "Mill Certificate"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    limit: Maximum number to return (default 10, max 50)\n    search: Optional search term for certificate_number\n    purchase_order: Optional filter by purchase order\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"MC-00001\",\n                \"certificate_number\": \"MC-2025-12345\",\n                \"file\": \"/files/mill-cert.pdf\",\n                \"purchase_order\": \"PO-00123\",\n                \"supplier_info\": \"Steel Supplier Inc\",\n                \"creation\": \"2025-12-15 10:30:00\",\n                \"has_file\": true\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "integer"
                  },
                  "search": {
                    "type": "string"
                  },
                  "purchase_order": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mill_certificate.search_mill_certificates": {
      "post": {
        "operationId": "pacific_bending_app.api.mill_certificate.search_mill_certificates",
        "summary": "Search mill certificates by certificate number or name.",
        "tags": [
          "Mill Certificate"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Optimized for autocomplete/typeahead use cases.\n\nArgs:\n    query: Search term\n    limit: Maximum results (default 10, max 20)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"MC-00001\",\n                \"certificate_number\": \"MC-2025-12345\",\n                \"display_label\": \"MC-00001 - MC-2025-12345\"\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        }
      }
    },
    "/mill_certificate.update_mill_certificate": {
      "post": {
        "operationId": "pacific_bending_app.api.mill_certificate.update_mill_certificate",
        "summary": "Update an existing mill certificate.",
        "tags": [
          "Mill Certificate"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Note: File cannot be changed after creation. Create a new record instead.\n\nArgs:\n    name: Mill Certificate name (e.g., MC-00001)\n    certificate_number: Updated certificate number\n    purchase_order: Updated purchase order link\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {...},\n        \"message\": \"Mill certificate updated successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "certificate_number": {
                    "type": "string"
                  },
                  "purchase_order": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/production_planning.create_material_requests_for_shortages": {
      "post": {
        "operationId": "pacific_bending_app.api.production_planning.create_material_requests_for_shortages",
        "summary": "Automatically generate Material Requests for items with shortages.",
        "tags": [
          "Production Planning"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "P1 Feature: Bridges the gap between shortage detection and procurement action.\nFinds items where required > available, identifies preferred suppliers,\nand creates draft Material Requests.\n\nSOLID: Single Responsibility - Creates procurement requests from shortages\nKISS: Simple supplier lookup with fallback to manual assignment\n\nArgs:\n    location: Filter by location (optional)\n    production_plan_name: Link to production plan (optional)\n    dry_run: If True, return what would be created without actually creating\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"dry_run\": false,\n            \"material_requests\": [\n                {\n                    \"material_request_id\": \"MAT-MR-2025-00001\",\n                    \"item_code\": \"STEEL-001\",\n                    \"shortage_qty\": 50,\n                    \"supplier\": \"ACME Steel\",\n                    \"estimated_value\": 500.00,\n                    \"status\": \"Draft\"\n                }\n            ],\n            \"items_without_supplier\": [\"ITEM-002\"],\n            \"total_requests\": 3,\n            \"total_estimated_value\": 1500.00\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "production_plan_name": {
                    "type": "string"
                  },
                  "dry_run": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/production_planning.create_production_plan": {
      "post": {
        "operationId": "pacific_bending_app.api.production_planning.create_production_plan",
        "summary": "Create a production plan grouping work orders",
        "tags": [
          "Production Planning"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Groups work orders into plan\nKISS: Simple grouping with target date\n\nArgs:\n    work_order_ids: JSON array of work order IDs\n    plan_name: Name for the plan (optional, auto-generated)\n    target_date: Target completion date (optional)\n    notes: Plan notes (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Production plan created\",\n        \"data\": {...}\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_ids": {
                    "type": "string"
                  },
                  "plan_name": {
                    "type": "string"
                  },
                  "target_date": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_ids"
                ]
              }
            }
          }
        }
      }
    },
    "/production_planning.get_capacity_availability": {
      "post": {
        "operationId": "pacific_bending_app.api.production_planning.get_capacity_availability",
        "summary": "Get capacity availability across workstations",
        "tags": [
          "Production Planning"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Calculates available capacity\nKISS: Simple capacity vs load comparison\n\nArgs:\n    location: Filter by location (optional)\n    date_from: Start date (optional, defaults to today)\n    date_to: End date (optional, defaults to 14 days ahead)\n    workstation: Filter by specific workstation (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"by_workstation\": [...],\n            \"by_date\": [...],\n            \"total_capacity_hours\": 1000,\n            \"total_scheduled_hours\": 600,\n            \"utilization_percent\": 60\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  },
                  "workstation": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/production_planning.get_demand_forecast": {
      "post": {
        "operationId": "pacific_bending_app.api.production_planning.get_demand_forecast",
        "summary": "Get demand forecast from quotes and orders",
        "tags": [
          "Production Planning"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Aggregates demand from multiple sources\nKISS: Simple aggregation by item and date\n\nArgs:\n    location: Filter by location (optional)\n    days_ahead: Days to look ahead for demand (default from Settings)\n    include_quotes: Include submitted quotations\n    include_sales_orders: Include confirmed sales orders\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"demand_by_item\": [...],\n            \"demand_by_date\": [...],\n            \"total_demand_qty\": 1000,\n            \"total_demand_value\": 50000\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "days_ahead": {
                    "type": "string"
                  },
                  "include_quotes": {
                    "type": "boolean"
                  },
                  "include_sales_orders": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/production_planning.get_material_requirements": {
      "post": {
        "operationId": "pacific_bending_app.api.production_planning.get_material_requirements",
        "summary": "Get material requirements vs availability (MRP-lite)",
        "tags": [
          "Production Planning"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Calculates material requirements\nKISS: Simple required vs available comparison\n\nArgs:\n    location: Filter by location (optional)\n    include_open_work_orders: Include materials for open work orders\n    include_pending_quotes: Include materials for pending quotes\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"materials\": [...],\n            \"shortages\": [...],\n            \"total_items\": 50,\n            \"items_with_shortage\": 5\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "include_open_work_orders": {
                    "type": "boolean"
                  },
                  "include_pending_quotes": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/production_planning.optimize_schedule": {
      "post": {
        "operationId": "pacific_bending_app.api.production_planning.optimize_schedule",
        "summary": "Suggest optimal scheduling of work orders",
        "tags": [
          "Production Planning"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Suggests schedule optimization\nKISS: Simple scheduling strategies\n\nArgs:\n    location: Filter by location (optional)\n    date_from: Start date (optional)\n    date_to: End date (optional)\n    strategy: Scheduling strategy (earliest_due_date, shortest_job_first, priority)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"suggested_sequence\": [...],\n            \"bottlenecks\": [...],\n            \"estimated_completion\": \"2024-01-15\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  },
                  "strategy": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/quality.add_adhoc_qc_checkpoint": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.add_adhoc_qc_checkpoint",
        "summary": "Add an ad-hoc QC checkpoint to a Job Card.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    job_card_id: Job Card document name\n    checkpoint_name: Name for the checkpoint\n    template_name: Optional QC template name\n    required: Whether checkpoint is required (default: True)\n    notes: Optional notes\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"job_card_id\": \"...\",\n            \"checkpoint_name\": \"...\",\n            \"checkpoint_id\": \"...\",\n            \"template_name\": \"...\",\n            \"required\": True,\n            \"added_by\": \"...\",\n            \"added_at\": \"...\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "checkpoint_name": {
                    "type": "string"
                  },
                  "template_name": {
                    "type": "string"
                  },
                  "required": {
                    "type": "boolean"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "checkpoint_name"
                ]
              }
            }
          }
        }
      }
    },
    "/quality.create_rework_job_card": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.create_rework_job_card",
        "summary": "Create a Rework Job Card when QC fails.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Links to original Job Card for traceability and creates new work order\noperation for rework.\n\nArgs:\n    original_job_card_id: Original Job Card document name\n    rework_qty: Quantity requiring rework\n    defect_type: Type of defect\n    rework_reason: Reason for rework\n    rework_instructions: Optional detailed instructions\n    assigned_operator: Optional operator to assign\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"rework_job_card\": {\n                \"name\": \"JC-REWORK-001\",\n                \"original_job_card\": \"JC-001\",\n                \"work_order\": \"WO-001\",\n                \"operation\": \"Welding\",\n                \"rework_qty\": 3,\n                \"rework_reason\": \"...\",\n                \"defect_type\": \"Weld\",\n                \"status\": \"Open\",\n                \"created_at\": \"...\"\n            }\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "original_job_card_id": {
                    "type": "string"
                  },
                  "rework_qty": {
                    "type": "integer"
                  },
                  "defect_type": {
                    "type": "string"
                  },
                  "rework_reason": {
                    "type": "string"
                  },
                  "rework_instructions": {
                    "type": "string"
                  },
                  "assigned_operator": {
                    "type": "string"
                  }
                },
                "required": [
                  "original_job_card_id",
                  "rework_qty",
                  "defect_type",
                  "rework_reason"
                ]
              }
            }
          }
        }
      }
    },
    "/quality.delete_qc_inspection_template": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.delete_qc_inspection_template",
        "summary": "Delete a native ERPNext Quality Inspection Template if it is not in use.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    name: Template name to delete\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"success\": True,\n            \"name\": \"template-name\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/quality.export_quality_report": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.export_quality_report",
        "summary": "Export quality report to CSV or JSON.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    location: Filter by location (optional)\n    date_from: Start date (optional)\n    date_to: End date (optional)\n    format: Export format (csv or json)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"file_url\": \"/private/files/quality_report_20260123.csv\",\n            \"filename\": \"quality_report_20260123.csv\",\n            \"record_count\": 150,\n            \"summary\": {\n                \"total_inspections\": 150,\n                \"passed\": 128,\n                \"failed\": 18,\n                \"rework\": 4,\n                \"first_pass_yield\": 85.33,\n                \"date_range\": {\"from\": \"2026-01-01\", \"to\": \"2026-01-31\"},\n                \"location\": \"Maple Ridge - PB\"\n            }\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  },
                  "format": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/quality.get_batch_qc_history": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.get_batch_qc_history",
        "summary": "Get QC inspection history for a batch.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    batch_id: Batch ID\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"batch_id\": \"PM20250001\",\n            \"qc_summary\": {\n                \"total_inspections\": 10,\n                \"passed\": 8,\n                \"failed\": 1,\n                \"rework\": 1,\n                \"pending\": 0\n            },\n            \"inspections\": [...]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/quality.get_defect_history": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.get_defect_history",
        "summary": "Get defect history with pagination and filtering.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    location: Filter by location (optional)\n    defect_type: Filter by defect type (optional)\n    severity: Filter by severity (optional)\n    search: Free-text search over job card/item/defect/operation (optional)\n    date_from: Start date filter (optional)\n    date_to: End date filter (optional)\n    page: Page number (default: 1)\n    page_size: Items per page (default: 20)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"defects\": [...],\n            \"total_count\": 100,\n            \"page\": 1,\n            \"page_size\": 20,\n            \"total_pages\": 5\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "defect_type": {
                    "type": "string"
                  },
                  "severity": {
                    "type": "string"
                  },
                  "search": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  },
                  "page": {
                    "type": "integer"
                  },
                  "page_size": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/quality.get_inspection_history": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.get_inspection_history",
        "summary": "Get QC inspection history with pagination and filtering.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    job_card_id: Filter by specific Job Card (optional)\n    work_order_id: Filter by Work Order (optional)\n    location: Filter by location (optional)\n    limit: Maximum records to return (default: 50)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"inspections\": [...],\n            \"total_count\": 100\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "work_order_id": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/quality.get_operation_qc_template": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.get_operation_qc_template",
        "summary": "Get the native Quality Inspection Template linked to an Operation.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns None when no template is linked.\n\nArgs:\n    operation: Operation name\n\nReturns:\n    Template dict or None",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "operation": {
                    "type": "string"
                  }
                },
                "required": [
                  "operation"
                ]
              }
            }
          }
        }
      }
    },
    "/quality.get_pending_incoming_inspections": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.get_pending_incoming_inspections",
        "summary": "Get pending incoming QC inspections (Purchase Receipts).",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    location: Filter by location (optional)\n    date_from: Start date filter (optional)\n    date_to: End date filter (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"inspections\": [...],\n            \"total_count\": 10,\n            \"pending_count\": 5,\n            \"overdue_count\": 2\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/quality.get_pending_inspections": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.get_pending_inspections",
        "summary": "Get list of pending QC inspections.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves pending inspections\nKISS: Simple filters, returns actionable list\n\nArgs:\n    location: Filter by location (optional)\n    workstation: Filter by workstation (optional)\n    date_from: Start date filter (optional)\n    date_to: End date filter (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"inspections\": [...],\n            \"total_count\": 10,\n            \"pending_count\": 5,\n            \"overdue_count\": 2\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "workstation": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/quality.get_pending_outgoing_inspections": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.get_pending_outgoing_inspections",
        "summary": "Get pending outgoing QC inspections (Delivery Notes).",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "ERPNext Best Practice: Final quality gate before shipping\n\nArgs:\n    location: Filter by location (optional)\n    date_from: Start date filter (optional)\n    date_to: End date filter (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"inspections\": [...],\n            \"total_count\": 10,\n            \"pending_count\": 5,\n            \"overdue_count\": 2\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/quality.get_qc_inspection_templates": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.get_qc_inspection_templates",
        "summary": "Get all Quality Inspection Templates for operations.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Uses native ERPNext Quality Inspection Template DocType.\n\nArgs:\n    include_disabled: If True, include disabled templates (default: False)\n    include_inactive: If True, include inactive templates (default: False)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"Weld Inspection\",\n                \"template_name\": \"Weld Inspection\",\n                \"description\": \"\",\n                \"active\": True,\n                \"parameters\": [...]\n            }\n        ],\n        \"count\": 5\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "include_disabled": {
                    "type": "boolean"
                  },
                  "include_inactive": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/quality.get_qc_metrics": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.get_qc_metrics",
        "summary": "Get QC metrics and analytics.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Calculates First Pass Yield (FPY), defect rate, and breakdowns.\n\nArgs:\n    location: Filter by location (optional)\n    date_from: Start date (optional, defaults to period)\n    date_to: End date (optional, defaults to today)\n    period: Time period (7d, 30d, 90d, YTD) if dates not provided\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"first_pass_yield\": 85.5,\n            \"defect_rate\": 14.5,\n            \"total_inspected\": 100,\n            \"total_passed\": 85,\n            \"total_failed\": 12,\n            \"total_rework\": 3,\n            \"by_defect_type\": {\n                \"Dimensional\": 5,\n                \"Weld\": 4,\n                ...\n            },\n            \"by_workstation\": {\n                \"Welding Station 1\": {\"total\": 50, \"passed\": 42, \"failed\": 8},\n                ...\n            },\n            \"trend\": [\n                {\"date\": \"2026-01-01\", \"total\": 10, \"passed\": 8, \"failed\": 2, \"fpy\": 80.0},\n                ...\n            ],\n            \"period\": {\"from\": \"2026-01-01\", \"to\": \"2026-01-31\"}\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/quality.has_qc_required_items": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.has_qc_required_items",
        "summary": "Check if a Delivery Note has items that require QC inspection.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    delivery_note_name: Delivery Note document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"has_qc_required\": True,\n            \"qc_required_count\": 5\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "delivery_note_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "delivery_note_name"
                ]
              }
            }
          }
        }
      }
    },
    "/quality.report_defect": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.report_defect",
        "summary": "Report a defect for a Job Card.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Records defect with validation\nKISS: Simple defect capture with optional details\n\nArgs:\n    job_card_id: Job Card document name\n    defect_type: Type of defect (Dimensional, Surface, Weld, etc.)\n    severity: Severity level (Low, Medium, High, Critical)\n    qty_affected: Quantity affected by defect (default: 1)\n    root_cause: Root cause category\n    corrective_action: Planned corrective action\n    notes: Additional notes\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Defect reported successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "defect_type": {
                    "type": "string"
                  },
                  "severity": {
                    "type": "string"
                  },
                  "qty_affected": {
                    "type": "integer"
                  },
                  "root_cause": {
                    "type": "string"
                  },
                  "corrective_action": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "defect_type"
                ]
              }
            }
          }
        }
      }
    },
    "/quality.save_qc_inspection_template": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.save_qc_inspection_template",
        "summary": "Create or update a native ERPNext Quality Inspection Template.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Idempotent upsert behavior:\n- if `name` exists, update that template\n- else if template_name exists, update it\n- else create a new template\n\nArgs:\n    template: JSON string or dict with template data\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"name\": \"template-name\",\n            \"message\": \"QC Inspection Template created\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template": {
                    "type": "string"
                  }
                },
                "required": [
                  "template"
                ]
              }
            }
          }
        }
      }
    },
    "/quality.seed_qc_inspection_templates": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.seed_qc_inspection_templates",
        "summary": "Seed QC inspection templates for common operations.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Creates templates for:\n- Cutting\n- Welding\n- Assembly\n- Painting\n- Final Inspection\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"created\": [\"Cutting\", \"Welding\", ...],\n            \"updated\": [],\n            \"skipped\": [],\n            \"summary\": \"Created 5 templates\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/quality.submit_detailed_inspection": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.submit_detailed_inspection",
        "summary": "Submit detailed QC inspection result.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Records inspection with full details\nKISS: Simple pass/fail with optional details\n\nArgs:\n    job_card_id: Job Card document name\n    status: QC status (Pass, Fail, Rework)\n    qty_inspected: Quantity inspected\n    qty_passed: Quantity that passed\n    qty_failed: Quantity that failed\n    defect_type: Type of defect (if failed)\n    severity: Severity level (Low, Medium, High, Critical)\n    root_cause: Root cause category\n    notes: Inspector notes\n    criteria_results: JSON string of criteria checklist results\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"job_card_id\": \"...\",\n            \"status\": \"Pass\",\n            \"inspector\": \"...\",\n            \"timestamp\": \"...\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "qty_inspected": {
                    "type": "integer"
                  },
                  "qty_passed": {
                    "type": "integer"
                  },
                  "qty_failed": {
                    "type": "integer"
                  },
                  "defect_type": {
                    "type": "string"
                  },
                  "severity": {
                    "type": "string"
                  },
                  "root_cause": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "criteria_results": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "status"
                ]
              }
            }
          }
        }
      }
    },
    "/quality.submit_incoming_inspection": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.submit_incoming_inspection",
        "summary": "Submit incoming QC inspection for Purchase Receipt.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    purchase_receipt_id: Purchase Receipt document name\n    status: QC status (Pass, Fail)\n    qty_inspected: Quantity inspected\n    qty_passed: Quantity that passed\n    qty_failed: Quantity that failed\n    defect_type: Type of defect (if failed)\n    severity: Severity level\n    root_cause: Root cause category\n    notes: Inspector notes\n    criteria_results: JSON string of criteria checklist results\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"purchase_receipt_id\": \"...\",\n            \"status\": \"Pass\",\n            \"can_release\": True,\n            \"inspector\": \"...\",\n            \"timestamp\": \"...\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "purchase_receipt_id": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "qty_inspected": {
                    "type": "integer"
                  },
                  "qty_passed": {
                    "type": "integer"
                  },
                  "qty_failed": {
                    "type": "integer"
                  },
                  "defect_type": {
                    "type": "string"
                  },
                  "severity": {
                    "type": "string"
                  },
                  "root_cause": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "criteria_results": {
                    "type": "string"
                  }
                },
                "required": [
                  "purchase_receipt_id",
                  "status"
                ]
              }
            }
          }
        }
      }
    },
    "/quality.submit_outgoing_inspection": {
      "post": {
        "operationId": "pacific_bending_app.api.quality.submit_outgoing_inspection",
        "summary": "Submit outgoing QC inspection for Delivery Note.",
        "tags": [
          "Quality"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "ERPNext Best Practice: Final quality gate before shipping\n\nArgs:\n    delivery_note_id: Delivery Note document name\n    status: QC status (Pass, Fail)\n    qty_inspected: Quantity inspected\n    qty_passed: Quantity that passed\n    qty_failed: Quantity that failed\n    defect_type: Type of defect (if failed)\n    severity: Severity level\n    root_cause: Root cause category\n    notes: Inspector notes\n    criteria_results: JSON string of criteria checklist results\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"delivery_note_id\": \"...\",\n            \"status\": \"Pass\",\n            \"can_ship\": True,\n            \"inspector\": \"...\",\n            \"timestamp\": \"...\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "delivery_note_id": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "qty_inspected": {
                    "type": "integer"
                  },
                  "qty_passed": {
                    "type": "integer"
                  },
                  "qty_failed": {
                    "type": "integer"
                  },
                  "defect_type": {
                    "type": "string"
                  },
                  "severity": {
                    "type": "string"
                  },
                  "root_cause": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "criteria_results": {
                    "type": "string"
                  }
                },
                "required": [
                  "delivery_note_id",
                  "status"
                ]
              }
            }
          }
        }
      }
    },
    "/quick_add_badge.create_quick_add_badge": {
      "post": {
        "operationId": "pacific_bending_app.api.quick_add_badge.create_quick_add_badge",
        "summary": "Create a new Quick Add Badge.",
        "tags": [
          "Quick Add Badge"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Admin-only endpoint for adding custom badges.\n\nArgs:\n    badge: JSON string of badge data\n        {\n            \"code\": \"RUSH_SETUP\",\n            \"label\": \"Rush + Setup\",\n            \"tooltipText\": \"Add rush fee and setup fee\",\n            \"iconName\": \"Tag\",\n            \"colorVariant\": \"amber\",\n            \"displayOrder\": 30,\n            \"categories\": [\n                {\"code\": \"RUSH\"},\n                {\"code\": \"SETUP\"}\n            ]\n        }\n\nReturns:\n    {\"success\": True, \"data\": {...}, \"message\": \"...\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "badge": {
                    "type": "string"
                  }
                },
                "required": [
                  "badge"
                ]
              }
            }
          }
        }
      }
    },
    "/quick_add_badge.delete_quick_add_badge": {
      "post": {
        "operationId": "pacific_bending_app.api.quick_add_badge.delete_quick_add_badge",
        "summary": "Delete (soft delete) a Quick Add Badge.",
        "tags": [
          "Quick Add Badge"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Sets is_active=0 to hide from quote editor.\n\nArgs:\n    name: Badge document name (code)\n\nReturns:\n    {\"success\": True, \"message\": \"...\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/quick_add_badge.get_all_quick_add_badges": {
      "post": {
        "operationId": "pacific_bending_app.api.quick_add_badge.get_all_quick_add_badges",
        "summary": "Get all Quick Add Badges (including inactive) for admin UI.",
        "tags": [
          "Quick Add Badge"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Admin-only endpoint for badge management.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"badges\": [...],  // All badges with isActive flag\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/quick_add_badge.get_quick_add_badges": {
      "post": {
        "operationId": "pacific_bending_app.api.quick_add_badge.get_quick_add_badges",
        "summary": "Get all active Quick Add Badges for the quote editor.",
        "tags": [
          "Quick Add Badge"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns badges with their linked categories and rates for\none-click tax/fee addition in the quote editor.\n\nNo role check because all authenticated users need badge list.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"badges\": [\n                {\n                    \"code\": \"BC_TAXES\",\n                    \"label\": \"BC Taxes\",\n                    \"tooltipText\": \"Add GST 5% + PST 7%\",\n                    \"iconName\": \"Zap\",\n                    \"colorVariant\": \"emerald\",\n                    \"displayOrder\": 10,\n                    \"categories\": [\n                        {\n                            \"code\": \"GST\",\n                            \"label\": \"GST\",\n                            \"defaultRate\": 5.0,\n                            \"chargeType\": \"Percentage\",\n                            \"isTax\": true\n                        }\n                    ]\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ]
      }
    },
    "/quick_add_badge.reset_quick_add_badges": {
      "post": {
        "operationId": "pacific_bending_app.api.quick_add_badge.reset_quick_add_badges",
        "summary": "Reset Quick Add Badges to default seed data.",
        "tags": [
          "Quick Add Badge"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This endpoint:\n1. Archives any non-default custom badges (sets is_active=0)\n2. Upserts all default badges from fixtures/quick_add_badge.json\n3. Returns summary of actions taken\n\nIdempotent: Safe to run multiple times.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"created\": 2,\n            \"updated\": 0,\n            \"archived\": 1,\n            \"badges\": [\"BC_TAXES\", \"HST_ONLY\"]\n        },\n        \"message\": \"...\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/quick_add_badge.update_quick_add_badge": {
      "post": {
        "operationId": "pacific_bending_app.api.quick_add_badge.update_quick_add_badge",
        "summary": "Update an existing Quick Add Badge.",
        "tags": [
          "Quick Add Badge"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Note: Code cannot be changed as it's the primary key.\n\nArgs:\n    name: Badge document name (code)\n    badge: JSON string of updated badge data\n\nReturns:\n    {\"success\": True, \"data\": {...}, \"message\": \"...\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "badge": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "badge"
                ]
              }
            }
          }
        }
      }
    },
    "/reservation.extend_reservation": {
      "post": {
        "operationId": "pacific_bending_app.api.reservation.extend_reservation",
        "summary": "Extend reservation expiration (Foreman/Admin only)",
        "tags": [
          "Reservation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    reservation_id: Reservation ID\n    additional_days: Number of days to add (1-90)\n    notes: Optional notes about extension\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"reservation_id\": \"MCO-2025-00001\",\n            \"old_expires_at\": \"2025-01-24 10:00:00\",\n            \"new_expires_at\": \"2025-01-31 10:00:00\",\n            \"additional_days\": 7\n        },\n        \"message\": \"Reservation extended by 7 days\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reservation_id": {
                    "type": "string"
                  },
                  "additional_days": {
                    "type": "integer"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "reservation_id",
                  "additional_days"
                ]
              }
            }
          }
        }
      }
    },
    "/reservation.get_all_reservations": {
      "post": {
        "operationId": "pacific_bending_app.api.reservation.get_all_reservations",
        "summary": "Get all reservations (Foreman/Admin only)",
        "tags": [
          "Reservation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    status: Filter by status (Active, Released, Expired) or None for all\n    user: Filter by user email\n    location: Filter by location\n    search: Optional free-text search across reservation/item/batch/project/user\n    limit: Max results (default 100)\n    offset: Pagination offset\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": [...],\n        \"count\": 25,\n        \"total\": 150,\n        \"message\": \"Retrieved 25 reservations\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string"
                  },
                  "user": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "search": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "offset": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/reservation.get_available_qty": {
      "post": {
        "operationId": "pacific_bending_app.api.reservation.get_available_qty",
        "summary": "Get available quantity for a batch (from line items)",
        "tags": [
          "Reservation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns quantity-based availability. available_qty on line items\nis the source of truth (already accounts for reservations).\n\nArgs:\n    batch_id: Batch ID\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PM20250001\",\n            \"total_qty\": 10,\n            \"available_qty\": 7,\n            \"reserved_qty\": 3,\n            \"dimension_type\": \"L\",\n            \"line_items\": [\n                {\"idx\": 0, \"quantity\": 10, \"available_qty\": 7, \"length_ft\": 8.0}\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/reservation.get_my_reservations": {
      "post": {
        "operationId": "pacific_bending_app.api.reservation.get_my_reservations",
        "summary": "Get current user's reservations",
        "tags": [
          "Reservation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    status: Filter by status (Active, Released, Expired) or None for all\n    include_expired: Include expired reservations in results\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": [{\n            \"reservation_id\": \"MCO-2025-00001\",\n            \"batch_id\": \"PM20250001\",\n            \"item_code\": \"CS-SQT-2X2X14GA\",\n            \"item_name\": \"Carbon Steel Square Tube 2x2 14ga\",\n            \"quantity\": 2,\n            \"dimension_type\": \"L\",\n            \"project_reference\": \"JOB-123\",\n            \"reserved_at\": \"2025-01-17 10:00:00\",\n            \"expires_at\": \"2025-01-24 10:00:00\",\n            \"days_remaining\": 7,\n            \"status\": \"Active\"\n        }],\n        \"count\": 5,\n        \"message\": \"Retrieved 5 reservations\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string"
                  },
                  "include_expired": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/reservation.get_reservations_for_batch": {
      "post": {
        "operationId": "pacific_bending_app.api.reservation.get_reservations_for_batch",
        "summary": "Get all active reservations for a specific batch",
        "tags": [
          "Reservation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    batch_id: Batch ID\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"batch_id\": \"PM20250001\",\n            \"total_reserved\": 3,\n            \"reservations\": [{\n                \"reservation_id\": \"MCO-2025-00001\",\n                \"quantity\": 2,\n                \"reserved_by\": \"user@example.com\",\n                \"reserved_by_name\": \"John Smith\",\n                \"line_item_idx\": 0,\n                \"dimension_value\": 10.0,\n                \"project_reference\": \"JOB-123\",\n                \"expires_at\": \"2025-01-24 10:00:00\",\n                \"days_remaining\": 5\n            }]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id"
                ]
              }
            }
          }
        }
      }
    },
    "/reservation.release_reservation": {
      "post": {
        "operationId": "pacific_bending_app.api.reservation.release_reservation",
        "summary": "Release a reservation (return material to available inventory)",
        "tags": [
          "Reservation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Releases the reservation, making material available again.\nIncrements available_qty on the line item if applicable.\n\nPermission rules:\n- Users can release their own reservations\n- Foreman/Admin can release anyone's reservations\n\nArgs:\n    reservation_id: Reservation ID (e.g., MCO-2025-00001)\n    notes: Optional release notes\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"reservation_id\": \"MCO-2025-00001\",\n            \"batch_id\": \"PM20250001\",\n            \"quantity\": 2,\n            \"released_by\": \"user@example.com\",\n            \"release_date\": \"2025-01-17 16:00:00\"\n        },\n        \"message\": \"Reservation released successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reservation_id": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "reservation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/reservation.reserve_material": {
      "post": {
        "operationId": "pacific_bending_app.api.reservation.reserve_material",
        "summary": "Reserve material from a batch (quantity-based)",
        "tags": [
          "Reservation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "DESIGN: All reservations are QUANTITY-based (pieces).\nDimensional fields (length_ft, area_sqft) are metadata only.\n\nCreates a reservation that blocks this quantity from:\n- Being reserved by others\n- Being consumed/used by anyone\n\nArgs:\n    batch_id: Batch ID to reserve from (e.g., \"PM20250001\")\n    quantity: Number of PIECES to reserve (always integer)\n    line_item_idx: Index of line item to reserve from (0-based, optional)\n    batch_line_idx: Backward-compatible alias for line_item_idx\n    project_reference: Free text project/job reference\n    notes: Optional notes\n    expiry_days: Days until expiry (default from Item or 7)\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"reservation_id\": \"MCO-2025-00001\",\n            \"batch_id\": \"PM20250001\",\n            \"line_item_idx\": 0,\n            \"item_code\": \"CS-SQT-2X2X14GA\",\n            \"item_name\": \"Carbon Steel Square Tube 2x2 14ga\",\n            \"quantity\": 2,\n            \"dimension_metadata\": {\"length_ft\": 10.0},\n            \"expires_at\": \"2025-01-24 14:30:00\",\n            \"reserved_by\": \"user@example.com\"\n        },\n        \"message\": \"Reserved 2 pieces from batch PM20250001\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Estimator",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "batch_id": {
                    "type": "string"
                  },
                  "quantity": {
                    "type": "integer"
                  },
                  "line_item_idx": {
                    "type": "string"
                  },
                  "batch_line_idx": {
                    "type": "string"
                  },
                  "item_variant_id": {
                    "type": "string"
                  },
                  "sales_order_id": {
                    "type": "string"
                  },
                  "project_reference": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "expiry_days": {
                    "type": "string"
                  }
                },
                "required": [
                  "batch_id",
                  "quantity"
                ]
              }
            }
          }
        }
      }
    },
    "/routing.delete_operation": {
      "post": {
        "operationId": "pacific_bending_app.api.routing.delete_operation",
        "summary": "Delete an Operation.",
        "tags": [
          "Routing"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Warning: This will fail if the Operation is used in any BOM or Routing.\n\nArgs:\n    name: Operation name to delete",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/routing.delete_routing": {
      "post": {
        "operationId": "pacific_bending_app.api.routing.delete_routing",
        "summary": "Delete a Routing.",
        "tags": [
          "Routing"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Warning: This will fail if the Routing is used in any BOM.\n\nArgs:\n    name: Routing name to delete",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/routing.get_operations": {
      "post": {
        "operationId": "pacific_bending_app.api.routing.get_operations",
        "summary": "Get all native ERPNext Operations for BOM templates.",
        "tags": [
          "Routing"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Uses native ERPNext Operation DocType instead of custom BOM Operation Type.\n\nArgs:\n    include_disabled: If True, include operations marked as disabled (default: False)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"Laser Cutting\",\n                \"workstation\": \"LASER-01\",\n                \"description\": \"...\",\n                \"batch_size\": 1,\n                \"quality_inspection_template\": null\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "include_disabled": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/routing.get_routing": {
      "post": {
        "operationId": "pacific_bending_app.api.routing.get_routing",
        "summary": "Get a single Routing with its operations.",
        "tags": [
          "Routing"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    name: Routing name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"name\": \"Standard Fabrication\",\n            \"disabled\": false,\n            \"operations\": [...]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/routing.get_routings": {
      "post": {
        "operationId": "pacific_bending_app.api.routing.get_routings",
        "summary": "Get all native ERPNext Routings for BOM templates.",
        "tags": [
          "Routing"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Routings define reusable operation sequences.\n\nArgs:\n    include_disabled: If True, include disabled routings (default: False)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"Standard Fabrication\",\n                \"disabled\": false,\n                \"operations\": [\n                    {\"operation\": \"Laser Cutting\", \"workstation\": \"LASER-01\", \"time_in_mins\": 30}\n                ]\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "include_disabled": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/routing.save_operation": {
      "post": {
        "operationId": "pacific_bending_app.api.routing.save_operation",
        "summary": "Create or update a native ERPNext Operation.",
        "tags": [
          "Routing"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    operation: JSON string of operation configuration\n        {\n            \"name\": \"Laser Cutting\",\n            \"workstation\": \"LASER-01\",\n            \"description\": \"High-precision laser cutting\",\n            \"batch_size\": 1\n        }\n\nReturns:\n    {\"success\": True, \"data\": {...}, \"message\": \"Operation saved\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "operation": {
                    "type": "string"
                  }
                },
                "required": [
                  "operation"
                ]
              }
            }
          }
        }
      }
    },
    "/routing.save_routing": {
      "post": {
        "operationId": "pacific_bending_app.api.routing.save_routing",
        "summary": "Create or update a native ERPNext Routing.",
        "tags": [
          "Routing"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    routing: JSON string of routing configuration\n        {\n            \"routing_name\": \"Standard Fabrication\",\n            \"operations\": [\n                {\"operation\": \"Laser Cutting\", \"workstation\": \"LASER-01\", \"time_in_mins\": 30},\n                {\"operation\": \"Bending\", \"time_in_mins\": 20}\n            ]\n        }\n\nReturns:\n    {\"success\": True, \"data\": {...}, \"message\": \"Routing saved\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "routing": {
                    "type": "string"
                  }
                },
                "required": [
                  "routing"
                ]
              }
            }
          }
        }
      }
    },
    "/routing.seed_operations": {
      "post": {
        "operationId": "pacific_bending_app.api.routing.seed_operations",
        "summary": "Seed standard Operations for metal fabrication.",
        "tags": [
          "Routing"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Idempotent: Safe to run multiple times, will skip existing.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/routing.seed_routings": {
      "post": {
        "operationId": "pacific_bending_app.api.routing.seed_routings",
        "summary": "Seed standard Routings for metal fabrication.",
        "tags": [
          "Routing"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Idempotent: Safe to run multiple times, will skip existing.\n\nCreates 7 standard routing templates.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/routing.toggle_routing": {
      "post": {
        "operationId": "pacific_bending_app.api.routing.toggle_routing",
        "summary": "Enable or disable a Routing.",
        "tags": [
          "Routing"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    name: Routing name\n    disabled: If provided, set to this value. Otherwise toggle.\n\nReturns:\n    {\"success\": True, \"data\": {\"name\": \"...\", \"disabled\": true/false}}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "disabled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/sales_order.get_sales_order_for_work_order": {
      "post": {
        "operationId": "pacific_bending_app.api.sales_order.get_sales_order_for_work_order",
        "summary": "Get Sales Order details for creating Work Orders.",
        "tags": [
          "Sales Order"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns items that can be manufactured (have active BOMs).\n\nArgs:\n    sales_order_name: Sales Order document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"sales_order\": \"SO-00001\",\n            \"customer\": \"Customer Name\",\n            \"warehouse_group\": \"Maple Ridge - PB\",\n            \"items\": [\n                {\n                    \"item_code\": \"ITEM-001\",\n                    \"qty\": 10,\n                    \"pending_qty\": 10,\n                    \"bom_no\": \"BOM-001\",\n                    \"routing\": \"Standard Fabrication\"\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_order_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "sales_order_name"
                ]
              }
            }
          }
        }
      }
    },
    "/sales_order.get_sales_order_work_order_progress": {
      "post": {
        "operationId": "pacific_bending_app.api.sales_order.get_sales_order_work_order_progress",
        "summary": "Get Work Order creation progress for a Sales Order.",
        "tags": [
          "Sales Order"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns detailed progress of which items have Work Orders created.\n\nArgs:\n    sales_order_name: Sales Order document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"sales_order\": \"SO-00001\",\n            \"total_items_with_bom\": 3,\n            \"work_orders_created\": 2,\n            \"work_orders_pending\": 1,\n            \"progress_percentage\": 66,\n            \"items\": [\n                {\n                    \"item_code\": \"ITEM-001\",\n                    \"item_name\": \"Steel Bracket\",\n                    \"qty\": 10,\n                    \"bom_no\": \"BOM-001\",\n                    \"work_order\": \"WO-00042\",\n                    \"work_order_status\": \"In Progress\"\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_order_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "sales_order_name"
                ]
              }
            }
          }
        }
      }
    },
    "/sales_order.get_sales_orders_for_quotation": {
      "post": {
        "operationId": "pacific_bending_app.api.sales_order.get_sales_orders_for_quotation",
        "summary": "Get all Sales Orders linked to a Quotation.",
        "tags": [
          "Sales Order"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "A quote can have multiple Sales Orders (partial orders, amendments).\nThis enables bidirectional navigation between quotes and sales orders.\n\nThe linkage exists via `tabSales Order Item.prevdoc_docname` which\nstores the source Quotation name for each item. We query this to\nfind all Sales Orders that were created from a given Quotation.\n\nArgs:\n    quotation_name: Quotation document name (e.g., \"QTN-00001\")\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"SAL-ORD-2025-00001\",\n                \"status\": \"To Deliver and Bill\",\n                \"transaction_date\": \"2025-01-15\",\n                \"delivery_date\": \"2025-02-01\",\n                \"grand_total\": 5000.00,\n                \"currency\": \"CAD\",\n                \"customer\": \"CUST-00001\",\n                \"customer_name\": \"Acme Corp\"\n            },\n            ...\n        ],\n        \"count\": 1\n    }\n\nNote:\n    - Excludes cancelled Sales Orders (docstatus != 2)\n    - Returns empty array if no Sales Orders exist\n    - Follows ERPNext best practices: linkage via prevdoc_docname",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_name"
                ]
              }
            }
          }
        }
      }
    },
    "/sales_order.get_sales_orders_needing_work_orders": {
      "post": {
        "operationId": "pacific_bending_app.api.sales_order.get_sales_orders_needing_work_orders",
        "summary": "Get Sales Orders that need Work Orders created.",
        "tags": [
          "Sales Order"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns Sales Orders with manufacturable items (have BOMs) but no\nWork Orders created yet. Critical for hospital operations where\nproduction initiation speed impacts patient care timelines.\n\nArgs:\n    limit: Maximum number of results (default: 20)\n    start: Pagination offset (default: 0)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"sales_orders\": [\n                {\n                    \"name\": \"SO-00001\",\n                    \"customer\": \"Customer Name\",\n                    \"customer_name\": \"Customer Display Name\",\n                    \"transaction_date\": \"2025-01-15\",\n                    \"delivery_date\": \"2025-02-01\",\n                    \"grand_total\": 15000.00,\n                    \"status\": \"To Deliver and Bill\",\n                    \"items_with_bom\": 3,\n                    \"items_needing_wo\": 2,\n                    \"work_order_progress\": \"1/3\"\n                }\n            ],\n            \"total_count\": 15\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "integer"
                  },
                  "start": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/sales_order.get_source_quotation": {
      "post": {
        "operationId": "pacific_bending_app.api.sales_order.get_source_quotation",
        "summary": "Get the source Quotation for a Sales Order with full details.",
        "tags": [
          "Sales Order"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Enables reverse navigation from Sales Order back to its source Quotation.\nQueries Sales Order Item.prevdoc_docname to find the linked quotation.\n\nArgs:\n    sales_order_name: Sales Order document name\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"name\": \"QTN-00001\",\n            \"status\": \"Approved\",\n            \"docstatus\": 1,\n            \"transaction_date\": \"2025-01-15\",\n            \"grand_total\": 5000.00,\n            \"currency\": \"CAD\",\n            \"customer_name\": \"Acme Corp\"\n        }  # null if no source quotation\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_order_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "sales_order_name"
                ]
              }
            }
          }
        }
      }
    },
    "/sales_order.list_sales_orders_for_estimator": {
      "post": {
        "operationId": "pacific_bending_app.api.sales_order.list_sales_orders_for_estimator",
        "summary": "Enriched paginated Sales Order list for estimator views.",
        "tags": [
          "Sales Order"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns standard Sales Order list fields plus a computed `work_order_progress`\nvalue (e.g., \"1/3\") derived from linked Work Orders and BOM-backed SO lines.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "integer"
                  },
                  "start": {
                    "type": "integer"
                  },
                  "sort": {
                    "type": "string"
                  },
                  "search": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/sales_order.make_internal_work_order": {
      "post": {
        "operationId": "pacific_bending_app.api.sales_order.make_internal_work_order",
        "summary": "Create Work Order for internal jobs (no customer/sales order).",
        "tags": [
          "Sales Order"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Use this for:\n- Shop improvements\n- Tooling\n- Internal projects\n- R&D\n\nArgs:\n    production_item: Item to produce\n    qty: Quantity to produce\n    job_description: Description of the internal job\n    internal_job_type: Type of internal job (Tooling, R&D, etc.)\n    bom_no: BOM to use (optional, uses default)\n    wip_warehouse: Work-in-progress warehouse\n    fg_warehouse: Finished goods warehouse\n    warehouse_group: Location/warehouse group\n\nReturns:\n    {\"success\": True, \"data\": {\"work_order\": \"WO-00001\"}}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "production_item": {
                    "type": "string"
                  },
                  "qty": {
                    "type": "integer"
                  },
                  "job_description": {
                    "type": "string"
                  },
                  "internal_job_type": {
                    "type": "string"
                  },
                  "bom_no": {
                    "type": "string"
                  },
                  "wip_warehouse": {
                    "type": "string"
                  },
                  "fg_warehouse": {
                    "type": "string"
                  },
                  "warehouse_group": {
                    "type": "string"
                  }
                },
                "required": [
                  "production_item",
                  "qty"
                ]
              }
            }
          }
        }
      }
    },
    "/sales_order.make_sales_order_from_quotation": {
      "post": {
        "operationId": "pacific_bending_app.api.sales_order.make_sales_order_from_quotation",
        "summary": "Create Sales Order from internally approved Quotation with customer PO information.",
        "tags": [
          "Sales Order"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "v3.48: Now captures customer PO information during conversion.\nv3.48.1: Add support for attaching PO document (PDF/image) to Sales Order.\n\nWorkflow: Sent to Customer (workflow_state = \"Sent to Customer\")\n\u2192 Customer PO Received \u2192 Sales Order Created.\nInternal \"Approved\" means \"ready to send to customer\", not \"sale confirmed\".\n\nThis is the ERPNext standard flow: Quotation \u2192 Sales Order.\nUses ERPNext's native document mapper for proper field inheritance.\n\nArgs:\n    quotation_name: Quotation document name\n    po_no: Customer purchase order number (v3.48: optional during API call, captured in frontend modal)\n    po_date: Customer purchase order date (v3.48: optional during API call, captured in frontend modal)\n    delivery_date: Expected delivery date (v3.48: optional, for planning purposes)\n    po_file_url: URL of an already-uploaded PO file (preferred)\n    po_file_data: Base64-encoded PO file data (deprecated fallback)\n    po_file_name: Original PO file name (deprecated fallback)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"sales_order\": \"SO-00001\",\n            \"customer\": \"Customer Name\",\n            \"items_count\": 3,\n            \"quotation_status\": \"Ordered\",  # Canonical workflow state after SO creation\n            \"po_file_url\": \"/files/...\"  # v3.48.1: URL of uploaded PO file (if provided)\n        },\n        \"message\": \"Sales Order created successfully\"\n    }\n\nRaises:\n    ValidationError: Quotation not sent to customer or already converted",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_name": {
                    "type": "string"
                  },
                  "po_no": {
                    "type": "string"
                  },
                  "po_date": {
                    "type": "string"
                  },
                  "delivery_date": {
                    "type": "string"
                  },
                  "po_file_url": {
                    "type": "string"
                  },
                  "po_file_data": {
                    "type": "string"
                  },
                  "po_file_name": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_name"
                ]
              }
            }
          }
        }
      }
    },
    "/sales_order.make_work_order_from_sales_order": {
      "post": {
        "operationId": "pacific_bending_app.api.sales_order.make_work_order_from_sales_order",
        "summary": "Create Work Order(s) from Sales Order items.",
        "tags": [
          "Sales Order"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This is the ERPNext standard flow: Sales Order \u2192 Work Order.\nUses native `sales_order` field on Work Order (NOT custom_quotation).\n\nArgs:\n    sales_order_name: Sales Order document name\n    items: JSON string of items to manufacture\n        [{\"item_code\": \"ITEM-001\", \"qty\": 10, \"bom_no\": \"BOM-001\"}]\n    wip_warehouse: Work-in-progress warehouse (optional, uses default)\n    fg_warehouse: Finished goods warehouse (optional, uses default)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"work_orders\": [\"WO-00001\", \"WO-00002\"],\n            \"count\": 2\n        },\n        \"message\": \"Work Orders created successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sales_order_name": {
                    "type": "string"
                  },
                  "items": {
                    "type": "string"
                  },
                  "wip_warehouse": {
                    "type": "string"
                  },
                  "fg_warehouse": {
                    "type": "string"
                  }
                },
                "required": [
                  "sales_order_name",
                  "items"
                ]
              }
            }
          }
        }
      }
    },
    "/sales_order.release_work_orders_to_production": {
      "post": {
        "operationId": "pacific_bending_app.api.sales_order.release_work_orders_to_production",
        "summary": "Submit draft Work Orders to release them into production.",
        "tags": [
          "Sales Order"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "ERPNext v15 lifecycle:\n  Draft Work Order -> Submit Work Order -> Job Cards auto-created by submit hooks.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_names": {
                    "type": "string"
                  },
                  "auto_transfer_materials": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_names"
                ]
              }
            }
          }
        }
      }
    },
    "/shop_floor.allocate_material_to_job": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor.allocate_material_to_job",
        "summary": "Allocate scanned material to job card",
        "tags": [
          "Shop Floor"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Creates Stock Entry\nKISS: Simple material transfer\nv3.0: Supports hybrid flow with Material Checkout integration\nv1.98.1 (Phase 2): Cross-Job Card material sharing from WIP\n\nMaterial Sharing Flow (Phase 2):\n1. Check if material is already in WIP for this Work Order\n2. If in WIP, skip Source \u2192 WIP transfer, just track allocation\n3. If not in WIP, proceed with normal Source \u2192 WIP transfer\n\nArgs:\n    job_card_id: Job Card document name\n    batch_no: Batch number to allocate\n    material_checkout_id: Optional Material Checkout ID for hybrid flow (v3.0)\n                         If provided, updates the Material Checkout with Stock Entry reference\n    force_source_transfer: If True, always transfer from source (skip WIP check)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"stock_entry_id\": \"STE-00456\",\n            \"qty_allocated\": 1.0,\n            \"allocation_source\": \"wip\",  # \"wip\", \"source\", or \"partial\"\n            \"material_checkout_id\": \"MCO-2025-00001\"  # if provided\n        },\n        \"message\": \"Material allocated to job\"\n    }\n\nRaises:\n    frappe.ValidationError: If validation fails or Stock Entry creation fails",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "batch_no": {
                    "type": "string"
                  },
                  "material_checkout_id": {
                    "type": "string"
                  },
                  "force_source_transfer": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "job_card_id",
                  "batch_no"
                ]
              }
            }
          }
        }
      }
    },
    "/shop_floor.complete_job_card": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor.complete_job_card",
        "summary": "Complete Job Card with QC status",
        "tags": [
          "Shop Floor"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only completes job card\nKISS: Simple status update with QC recording\nCONTRACT REQUIREMENT: Enforces QC checkpoint before completion\n\nPhase 3 Enhancement (v1.98.2): Partial Completion Support\n- Set partial_completion=True to complete only part of the Job Card\n- Keeps status as \"Work In Progress\" for partial completions\n- Accumulates completed quantities across multiple submissions\n\nArgs:\n    job_card_id: Job Card document name (e.g., \"JOB-00123\")\n    completed_qty: Quantity completed in this submission\n    notes: Optional worker notes\n    qc_status: Optional QC status (Pass, Fail, Rework)\n    qc_notes: Optional QC notes (required if Fail/Rework)\n    partial_completion: If True, allows partial completion without marking as \"Completed\"\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"job_card_id\": \"JOB-00123\",\n            \"status\": \"Completed\",\n            \"total_completed_qty\": 10.0,\n            \"for_quantity\": 10.0,\n            \"is_partial\": false,\n            \"remaining_qty\": 0.0\n        },\n        \"message\": \"Job card completed successfully\"\n    }\n\nRaises:\n    frappe.ValidationError: If QC checkpoint not passed or if QC notes missing",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "completed_qty": {
                    "type": "number"
                  },
                  "notes": {
                    "type": "string"
                  },
                  "qc_status": {
                    "type": "string"
                  },
                  "qc_notes": {
                    "type": "string"
                  },
                  "partial_completion": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "job_card_id",
                  "completed_qty"
                ]
              }
            }
          }
        }
      }
    },
    "/shop_floor.flag_job_for_help": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor.flag_job_for_help",
        "summary": "Flag job card for foreman assistance",
        "tags": [
          "Shop Floor"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Flags job and notifies\nKISS: Simple flag update with notification\nUX: Worker can signal issues without stopping work\n\nArgs:\n    job_card_id: Job Card document name\n    reason: Reason for flagging (e.g., \"Tool malfunction\", \"Unclear instructions\")\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"flagged\": true,\n        \"notification_sent\": true\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/shop_floor.get_shop_floor_tasks": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor.get_shop_floor_tasks",
        "summary": "Get list of job cards for shop floor worker",
        "tags": [
          "Shop Floor"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves job cards\nKISS: Simple query with optional filters\nPriority 1: Location-scoped filtering for multi-location security\n\nArgs:\n    workstation: Optional workstation filter\n    status: Optional status filter (e.g., \"Open\", \"Work In Progress\")\n    assigned_to_me: If True, only show job cards assigned to current user\n    location: Optional warehouse group filter (defaults to user's accessible locations)\n\nReturns:\n    {\n        \"success\": true,\n        \"data\": {\n            \"tasks\": [...],\n            \"total_count\": 10,\n            \"user_location\": \"Pacific Bending - Maple Ridge - PB\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workstation": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "assigned_to_me": {
                    "type": "boolean"
                  },
                  "location": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/shop_floor.get_unassigned_job_cards": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor.get_unassigned_job_cards",
        "summary": "Get Job Cards with no workstation assignment (unassigned pool).",
        "tags": [
          "Shop Floor"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Priority 1 Workflow Improvement: Provides visibility into Job Cards\nthat haven't been assigned to workstations yet for better scheduling.\n\nArgs:\n    location: Optional warehouse group filter (defaults to user's accessible locations)\n    status_filter: Optional status filter (e.g., \"Open\", \"Work In Progress\")\n    limit: Maximum number of results (default: 100)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"unassigned_pool\": [\n                {\n                    \"job_card_id\": \"JOB-00123\",\n                    \"work_order\": \"WO-00456\",\n                    \"operation\": \"Laser Cutting\",\n                    \"status\": \"Open\",\n                    \"for_quantity\": 100,\n                    \"completed_qty\": 0,\n                    \"warehouse_group\": \"Pacific Bending - Maple Ridge - PB\"\n                }\n            ],\n            \"total_count\": 5\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "status_filter": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/shop_floor.receive_material_scan": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor.receive_material_scan",
        "summary": "Receive material from PO via QR scan",
        "tags": [
          "Shop Floor"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Creates Purchase Receipt and Batch\nKISS: Simple PO receipt with batch creation\nYAGNI: Auto-generates batch if not provided\n\nArgs:\n    purchase_order_id: Purchase Order document name\n    item_code: Item being received\n    qty: Quantity received\n    batch_no: Optional batch number (auto-generated if not provided)\n    warehouse: Optional warehouse (uses default if not provided)\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"purchase_receipt_id\": \"PR-00123\",\n        \"batch_id\": \"PB.0001.2025\",\n        \"qty_received\": 50.0\n    }\n\nRaises:\n    frappe.ValidationError: If PO doesn't exist or item not in PO",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "purchase_order_id": {
                    "type": "string"
                  },
                  "item_code": {
                    "type": "string"
                  },
                  "qty": {
                    "type": "number"
                  },
                  "batch_no": {
                    "type": "string"
                  },
                  "warehouse": {
                    "type": "string"
                  },
                  "idempotency_key": {
                    "type": "string"
                  }
                },
                "required": [
                  "purchase_order_id",
                  "item_code",
                  "qty"
                ]
              }
            }
          }
        }
      }
    },
    "/shop_floor.request_material_override": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor.request_material_override",
        "summary": "Request material override when worker has wrong batch",
        "tags": [
          "Shop Floor"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Creates override request\nKISS: Simple request creation with notification\nCRITICAL: Prevents hard stop, enables 30-second resolution\n\nArgs:\n    job_card_id: Job Card document name\n    required_batch: Batch that should be used\n    substitute_batch: Batch worker actually has\n    reason: Worker's explanation for override\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"override_request_id\": \"MOR-00001\",\n        \"status\": \"Pending\",\n        \"notification_sent\": true\n    }\n\nRaises:\n    frappe.ValidationError: If Material Override Request DocType doesn't exist",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "required_batch": {
                    "type": "string"
                  },
                  "substitute_batch": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "required_batch",
                  "substitute_batch",
                  "reason"
                ]
              }
            }
          }
        }
      }
    },
    "/shop_floor.scan_qc_checkpoint": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor.scan_qc_checkpoint",
        "summary": "Scan QC checkpoint QR code and return checklist template",
        "tags": [
          "Shop Floor"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - QC checkpoint scanning\nKISS: Simple QR validation and checklist retrieval\nCONTRACT REQUIREMENT: QC checkpoint enforcement\n\nArgs:\n    job_card_id: Job Card document name\n    qr_data: Scanned QR code data (expected format: \"QC-CHECKPOINT-{operation}\")\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"job_card_id\": \"JOB-00123\",\n        \"operation\": \"Laser Cutting\",\n        \"checklist\": [...],  # QC checklist items\n        \"qc_required\": True,\n        \"current_status\": \"Pending\"\n    }\n\nRaises:\n    frappe.ValidationError: Invalid QR code or QC not required",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "QC Inspector",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "qr_data": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "qr_data"
                ]
              }
            }
          }
        }
      }
    },
    "/shop_floor.start_job_card": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor.start_job_card",
        "summary": "Start a job card (transition from Open to Work In Progress).",
        "tags": [
          "Shop Floor"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Production Schedule Integration (v1.0):\n- Called from JobCardDetailModal when foreman clicks \"Start Job\"\n- Sets status to \"Work In Progress\"\n- Records actual_start_time\n- Optionally assigns an employee\n\nSOLID: Single Responsibility - Only starts job card\nKISS: Simple status update with validation\n\nArgs:\n    job_card_id: Job Card document name (e.g., \"JOB-00123\")\n    employee_id: Optional employee ID to assign to the job\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"job_card_id\": \"JOB-00123\",\n            \"status\": \"Work In Progress\",\n            \"actual_start_time\": \"2026-02-23T10:30:00\",\n            \"assigned_employee\": \"EMP-0001\"\n        },\n        \"message\": \"Job card started successfully\"\n    }\n\nRaises:\n    frappe.ValidationError: If job card is not in \"Open\" status",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "employee_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id"
                ]
              }
            }
          }
        }
      }
    },
    "/shop_floor.submit_qc_checkpoint": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor.submit_qc_checkpoint",
        "summary": "Submit QC checkpoint results",
        "tags": [
          "Shop Floor"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - QC submission\nKISS: Simple status update with validation\nCONTRACT REQUIREMENT: Record QC results for audit trail\n\nArgs:\n    job_card_id: Job Card document name\n    qc_status: Pass, Fail, or Rework\n    qc_notes: Optional notes (required for Fail/Rework)\n    checklist_results: Optional checklist results JSON string\n\nReturns:\n    {\n        \"message\": \"success\",\n        \"job_card_id\": \"JOB-00123\",\n        \"qc_status\": \"Pass\",\n        \"can_complete\": True,\n        \"inspector\": \"user@example.com\",\n        \"timestamp\": \"2025-01-12T10:30:00\"\n    }\n\nRaises:\n    frappe.ValidationError: Invalid status or missing required notes",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "QC Inspector",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "qc_status": {
                    "type": "string"
                  },
                  "qc_notes": {
                    "type": "string"
                  },
                  "checklist_results": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "qc_status"
                ]
              }
            }
          }
        }
      }
    },
    "/shop_floor.validate_material_scan": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor.validate_material_scan",
        "summary": "Validate QR scanned material batch",
        "tags": [
          "Shop Floor"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only validates scan\nKISS: Simple validation logic with clear error messages\nCRITICAL: First line of defense against wrong material allocation\nSECURITY: Input validation before database queries (v1.0)\n\nArgs:\n    job_card_id: Job Card document name\n    batch_no: Scanned batch number (from QR code)\n\nReturns:\n    {\n        \"valid\": true,\n        \"batch\": {\n            \"batch_id\": \"PB.0001.2025\",\n            \"item\": \"ITEM-001\",\n            \"item_name\": \"Steel Plate\",\n            \"warehouse\": \"Main Store\",\n            \"qty\": 100.0\n        },\n        \"message\": \"Valid batch\"\n    }\n    OR\n    {\n        \"valid\": false,\n        \"batch\": null,\n        \"message\": \"Batch not found or wrong item\",\n        \"expected_item\": \"ITEM-001\",\n        \"scanned_item\": \"ITEM-002\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "batch_no": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "batch_no"
                ]
              }
            }
          }
        }
      }
    },
    "/shop_floor_mobile.allocate_material_mobile": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor_mobile.allocate_material_mobile",
        "summary": "Mobile-optimized material allocation",
        "tags": [
          "Shop Floor Mobile"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Args:\n    job_card_id: Job Card ID\n    batch_no: Batch number\n    qty: Quantity to allocate\n\nReturns:\n    Mobile-optimized response",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "batch_no": {
                    "type": "string"
                  },
                  "qty": {
                    "type": "number"
                  }
                },
                "required": [
                  "job_card_id",
                  "batch_no",
                  "qty"
                ]
              }
            }
          }
        }
      }
    },
    "/shop_floor_mobile.check_camera_permissions": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor_mobile.check_camera_permissions",
        "summary": "Helper endpoint to check if camera access is working",
        "tags": [
          "Shop Floor Mobile"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns:\n    {\n        \"camera_available\": true,\n        \"message\": \"Camera access ready\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/shop_floor_mobile.get_qr_format_examples": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor_mobile.get_qr_format_examples",
        "summary": "Get QR code format examples for user guidance",
        "tags": [
          "Shop Floor Mobile"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns:\n    List of valid QR code formats",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/shop_floor_mobile.validate_material_scan_mobile": {
      "post": {
        "operationId": "pacific_bending_app.api.shop_floor_mobile.validate_material_scan_mobile",
        "summary": "Mobile-optimized QR scan validation",
        "tags": [
          "Shop Floor Mobile"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Delegates to existing function, adds mobile formatting\nKISS: Simple wrapper with mobile response\nUX: Optimized for mobile screens and quick feedback\n\nMobile Optimizations:\n- Short, actionable messages\n- Visual indicators (icons, colors)\n- Haptic feedback hints\n- Minimal payload\n- Quick response (target: < 300ms)\n\nArgs:\n    job_card_id: Job Card document name\n    batch_no: Scanned batch number from QR code\n\nReturns:\n    Mobile-optimized response with visual indicators\n\nExample Success Response:\n    {\n        \"valid\": true,\n        \"severity\": \"success\",\n        \"icon\": \"\u2713\",\n        \"color\": \"#10b981\",\n        \"title\": \"\u2713 Correct Material\",\n        \"message\": \"Steel Plate 4x8\",\n        \"details\": {\n            \"batch_id\": \"PB.0001.2025\",\n            \"qty_info\": \"100.0 / 50.0\",\n            \"warehouse\": \"Main Store\"\n        },\n        \"action\": {\n            \"label\": \"Continue\",\n            \"type\": \"primary\"\n        },\n        \"haptic\": \"success\"\n    }\n\nExample Error Response:\n    {\n        \"valid\": false,\n        \"severity\": \"error\",\n        \"icon\": \"\u2717\",\n        \"color\": \"#ef4444\",\n        \"title\": \"\u2717 Wrong Material\",\n        \"message\": \"Scanned: Aluminum Sheet\",\n        \"error_type\": \"item_mismatch\",\n        \"details\": {\n            \"expected_items\": [\"STEEL-001\"],\n            \"scanned_item\": \"ALUM-001\"\n        },\n        \"action\": {\n            \"label\": \"Find Correct Material\",\n            \"type\": \"secondary\"\n        },\n        \"haptic\": \"error\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "batch_no": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "batch_no"
                ]
              }
            }
          }
        }
      }
    },
    "/tax_fee.calculate_charges": {
      "post": {
        "operationId": "pacific_bending_app.api.tax_fee.calculate_charges",
        "summary": "Calculate charge amounts for a given base amount.",
        "tags": [
          "Tax Fee"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Utility endpoint for frontend to preview charge calculations\nbefore saving.\n\nArgs:\n    base_amount: Line item amount (qty \u00d7 rate)\n    charges: JSON array of charge objects\n        [\n            {\"category\": \"GST\", \"chargeType\": \"Percentage\", \"rate\": 5},\n            {\"category\": \"SETUP\", \"chargeType\": \"Flat Amount\", \"rate\": 50}\n        ]\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"baseAmount\": 1000.00,\n            \"charges\": [\n                {\"category\": \"GST\", \"rate\": 5, \"amount\": 50.00},\n                {\"category\": \"SETUP\", \"rate\": 50, \"amount\": 50.00}\n            ],\n            \"totalTax\": 50.00,\n            \"totalFees\": 50.00,\n            \"lineTotal\": 1100.00\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "base_amount": {
                    "type": "number"
                  },
                  "charges": {
                    "type": "string"
                  }
                },
                "required": [
                  "base_amount",
                  "charges"
                ]
              }
            }
          }
        }
      }
    },
    "/tax_fee.create_tax_fee_category": {
      "post": {
        "operationId": "pacific_bending_app.api.tax_fee.create_tax_fee_category",
        "summary": "Create a new tax/fee category.",
        "tags": [
          "Tax Fee"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Admin-only endpoint for adding custom taxes or fees.\n\nArgs:\n    category: JSON string of category data\n        {\n            \"code\": \"ENV_FEE\",\n            \"label\": \"Environmental Fee\",\n            \"chargeType\": \"Flat Amount\",\n            \"defaultRate\": 25.0,\n            \"isTax\": false,\n            \"isDefaultTax\": false,\n            \"description\": \"Environmental disposal fee\"\n        }\n\nReturns:\n    {\"success\": True, \"data\": {...}, \"message\": \"...\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "category": {
                    "type": "string"
                  }
                },
                "required": [
                  "category"
                ]
              }
            }
          }
        }
      }
    },
    "/tax_fee.delete_tax_fee_category": {
      "post": {
        "operationId": "pacific_bending_app.api.tax_fee.delete_tax_fee_category",
        "summary": "Delete (soft delete) a tax/fee category.",
        "tags": [
          "Tax Fee"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Prevents deletion if category is used in existing quote items.\nSets is_active=0 instead of hard delete.\n\nArgs:\n    name: Category document name (code)\n\nReturns:\n    {\"success\": True, \"message\": \"...\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              }
            }
          }
        }
      }
    },
    "/tax_fee.get_default_taxes": {
      "post": {
        "operationId": "pacific_bending_app.api.tax_fee.get_default_taxes",
        "summary": "Get categories marked as default taxes (auto-add to new line items).",
        "tags": [
          "Tax Fee"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Used by frontend to automatically add GST+PST to new quote items\nwithout requiring manual selection.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"code\": \"GST\",\n                \"label\": \"GST\",\n                \"chargeType\": \"Percentage\",\n                \"defaultRate\": 5.0\n            }\n        ]\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ]
      }
    },
    "/tax_fee.get_quotation_tax_detail": {
      "post": {
        "operationId": "pacific_bending_app.api.tax_fee.get_quotation_tax_detail",
        "summary": "Get itemized tax/fee breakdown for a specific quotation.",
        "tags": [
          "Tax Fee"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns per-item charges with totals for displaying in quote detail view.\n\nArgs:\n    quotation_id: Quotation document ID (e.g., \"QTN-00001\")\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"quotationId\": \"QTN-00001\",\n            \"items\": [\n                {\n                    \"idx\": 1,\n                    \"itemCode\": \"STEEL-PLATE\",\n                    \"description\": \"Steel Plate 4x8\",\n                    \"amount\": 1250.00,\n                    \"charges\": [\n                        {\"category\": \"GST\", \"rate\": 5, \"amount\": 62.50},\n                        {\"category\": \"PST_BC\", \"rate\": 7, \"amount\": 87.50}\n                    ],\n                    \"totalTax\": 150.00,\n                    \"totalFees\": 0,\n                    \"lineTotal\": 1400.00\n                }\n            ],\n            \"summary\": {\n                \"subtotal\": 1250.00,\n                \"totalTax\": 150.00,\n                \"totalFees\": 0,\n                \"grandTotal\": 1400.00,\n                \"taxBreakdown\": [\n                    {\"category\": \"GST\", \"label\": \"GST\", \"total\": 62.50},\n                    {\"category\": \"PST_BC\", \"label\": \"BC PST\", \"total\": 87.50}\n                ]\n            }\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "quotation_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "quotation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/tax_fee.get_tax_fee_categories": {
      "post": {
        "operationId": "pacific_bending_app.api.tax_fee.get_tax_fee_categories",
        "summary": "Get all active tax/fee categories for dropdown selection.",
        "tags": [
          "Tax Fee"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns categories grouped by type (taxes vs fees) and sorted for\nintuitive display. Includes default_rate for auto-fill on selection.\n\nNo role check because all authenticated users need category list.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"categories\": [\n                {\n                    \"name\": \"GST\",\n                    \"code\": \"GST\",\n                    \"label\": \"GST\",\n                    \"chargeType\": \"Percentage\",\n                    \"defaultRate\": 5.0,\n                    \"isTax\": true,\n                    \"isDefaultTax\": true,\n                    \"description\": \"...\"\n                }\n            ],\n            \"taxes\": [...],    // Filtered: is_tax=1\n            \"fees\": [...]      // Filtered: is_tax=0\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ]
      }
    },
    "/tax_fee.get_tax_report": {
      "post": {
        "operationId": "pacific_bending_app.api.tax_fee.get_tax_report",
        "summary": "Get aggregated tax/fee data for reporting.",
        "tags": [
          "Tax Fee"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Queries Item Tax Fee Row joined with Quotation Item and Quotation\nto provide totals by category within a date range.\n\nArgs:\n    start_date: Start date (YYYY-MM-DD)\n    end_date: End date (YYYY-MM-DD)\n    category: Optional category code filter\n    is_tax_only: 1 = taxes only, 0 = all charges\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"period\": {\"start\": \"2024-01-01\", \"end\": \"2024-03-31\"},\n            \"breakdown\": [\n                {\"category\": \"GST\", \"label\": \"GST\", \"total\": 4250.00, \"count\": 45},\n                {\"category\": \"PST_BC\", \"label\": \"BC PST\", \"total\": 5950.00, \"count\": 45}\n            ],\n            \"grandTotal\": 10200.00,\n            \"quoteCount\": 45\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "start_date": {
                    "type": "string"
                  },
                  "end_date": {
                    "type": "string"
                  },
                  "category": {
                    "type": "string"
                  },
                  "is_tax_only": {
                    "type": "integer"
                  }
                },
                "required": [
                  "start_date",
                  "end_date"
                ]
              }
            }
          }
        }
      }
    },
    "/tax_fee.reset_tax_fee_categories": {
      "post": {
        "operationId": "pacific_bending_app.api.tax_fee.reset_tax_fee_categories",
        "summary": "Reset Tax Fee Categories to default seed data.",
        "tags": [
          "Tax Fee"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "This endpoint:\n1. Archives any non-default custom categories (sets is_active=0)\n2. Upserts all default categories from fixtures/tax_fee_category.json\n3. Returns summary of actions taken\n\nIdempotent: Safe to run multiple times.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"created\": 2,\n            \"updated\": 5,\n            \"archived\": 1,\n            \"categories\": [\"GST\", \"PST_BC\", ...]\n        },\n        \"message\": \"...\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/tax_fee.update_tax_fee_category": {
      "post": {
        "operationId": "pacific_bending_app.api.tax_fee.update_tax_fee_category",
        "summary": "Update an existing tax/fee category.",
        "tags": [
          "Tax Fee"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Note: Code cannot be changed as it's the primary key.\n\nArgs:\n    name: Category document name (code)\n    category: JSON string of updated category data\n\nReturns:\n    {\"success\": True, \"data\": {...}, \"message\": \"...\"}",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "category": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "category"
                ]
              }
            }
          }
        }
      }
    },
    "/user_preferences.debug_user_preferences": {
      "post": {
        "operationId": "pacific_bending_app.api.user_preferences.debug_user_preferences",
        "summary": "Debug endpoint to verify sync configuration and troubleshoot issues.",
        "tags": [
          "User Preferences"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns information about:\n- Current authenticated user (frappe.session.user)\n- Whether User Preferences DocType exists\n- Whether user has a preferences record\n- Current preferences version and last sync time\n\nUseful for debugging sync issues between frontend and backend.\n\nKISS: Simple diagnostic endpoint with no side effects\nYAGNI: Only returns what's needed for debugging\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"frappe_session_user\": \"user@example.com\",\n            \"doctype_exists\": True,\n            \"user_has_preferences\": True,\n            \"preferences_record\": {\n                \"name\": \"user@example.com\",\n                \"version\": 5,\n                \"modified\": \"2025-01-06 12:00:00\"\n            },\n            \"server_time\": \"2025-01-06T12:00:00\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/user_preferences.delete_user_preferences": {
      "post": {
        "operationId": "pacific_bending_app.api.user_preferences.delete_user_preferences",
        "summary": "Delete a user's preferences (Admin only).",
        "tags": [
          "User Preferences"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Used for cleaning up when users are deactivated or for testing.\nRegular users cannot delete their own preferences - use update with\nempty preferences instead.\n\nSOLID: Single Responsibility - Only deletes preferences\nKISS: Simple delete with permission check\nYAGNI: Hard delete, no need for soft delete on preferences\n\nArgs:\n    user_email: Email/ID of the user whose preferences to delete\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"User preferences deleted successfully\"\n    }\n\nRaises:\n    frappe.DoesNotExistError: If user preferences not found\n    frappe.PermissionError: If user lacks System Manager role",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_email": {
                    "type": "string"
                  }
                },
                "required": [
                  "user_email"
                ]
              }
            }
          }
        }
      }
    },
    "/user_preferences.get_user_preferences": {
      "post": {
        "operationId": "pacific_bending_app.api.user_preferences.get_user_preferences",
        "summary": "Get current user's preferences from the backend.",
        "tags": [
          "User Preferences"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Called on app startup to sync localStorage with server state.\nReturns null data if no preferences exist (first-time user).\n\nSOLID: Single Responsibility - Only retrieves preferences\nKISS: Simple getter with no complex transformations\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"preferences\": {...} or null,\n            \"version\": 5,\n            \"modified\": \"2025-01-06 12:00:00\"\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ]
      }
    },
    "/user_preferences.merge_user_preferences": {
      "post": {
        "operationId": "pacific_bending_app.api.user_preferences.merge_user_preferences",
        "summary": "Merge partial preferences into existing preferences.",
        "tags": [
          "User Preferences"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Useful for updating a single setting without sending the full preferences\nobject. Uses shallow merge at the top level.\n\nSOLID: Single Responsibility - Only merges partial preferences\nKISS: Simple shallow merge\nYAGNI: Only top-level merge, no deep merge complexity\n\nArgs:\n    partial_preferences: JSON string of preferences to merge\n        {\n            \"entityViewModes\": {\n                \"Lead\": \"table\"\n            }\n        }\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"version\": 7,\n            \"modified\": \"2025-01-06 12:00:00\"\n        },\n        \"message\": \"Preferences merged successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "partial_preferences": {
                    "type": "string"
                  }
                },
                "required": [
                  "partial_preferences"
                ]
              }
            }
          }
        }
      }
    },
    "/user_preferences.resolve_preferences_conflict": {
      "post": {
        "operationId": "pacific_bending_app.api.user_preferences.resolve_preferences_conflict",
        "summary": "Force-save preferences after client-side conflict resolution.",
        "tags": [
          "User Preferences"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Called when the frontend detects a conflict, performs its merge strategy\n(union favorites, server-wins for settings), and wants to save the result.\n\nSOLID: Single Responsibility - Only resolves conflicts\nKISS: Force-save without version check\nYAGNI: Simple force-save, conflict already resolved client-side\n\nArgs:\n    merged_preferences: JSON string of the merged/resolved preferences\n    resolved_from_version: The server version that was used in the merge\n        (for audit trail)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"version\": 8,\n            \"modified\": \"2025-01-06 12:00:00\"\n        },\n        \"message\": \"Conflict resolved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "merged_preferences": {
                    "type": "string"
                  },
                  "resolved_from_version": {
                    "type": "string"
                  }
                },
                "required": [
                  "merged_preferences",
                  "resolved_from_version"
                ]
              }
            }
          }
        }
      }
    },
    "/user_preferences.update_user_preferences": {
      "post": {
        "operationId": "pacific_bending_app.api.user_preferences.update_user_preferences",
        "summary": "Update user preferences with optimistic locking.",
        "tags": [
          "User Preferences"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Uses version numbers for conflict detection:\n- If server_version > client_version: Conflict detected\n- Returns server data for frontend to merge and retry\n\nSOLID: Single Responsibility - Only updates preferences\nKISS: Simple upsert with version check\nDRY: Delegates JSON parsing to frappe.parse_json\n\nArgs:\n    preferences: JSON string of preferences to save\n        {\n            \"workstationDashboard\": {\n                \"favoriteWorkstations\": [\"WS-001\", \"WS-002\"],\n                \"viewMode\": \"cards\"\n            },\n            \"entityViewModes\": {...},\n            \"dashboardLayouts\": {...}\n        }\n    client_version: Version number the client last synced with\n        (used for optimistic locking)\n\nReturns:\n    Success:\n    {\n        \"success\": True,\n        \"data\": {\n            \"version\": 6,\n            \"modified\": \"2025-01-06 12:00:00\"\n        },\n        \"message\": \"Preferences updated successfully\"\n    }\n\n    Conflict:\n    {\n        \"success\": False,\n        \"error_code\": \"CONFLICT\",\n        \"data\": {\n            \"server_version\": 7,\n            \"server_preferences\": {...}\n        },\n        \"message\": \"Version conflict - server has newer data\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "preferences": {
                    "type": "string"
                  },
                  "client_version": {
                    "type": "string"
                  }
                },
                "required": [
                  "preferences",
                  "client_version"
                ]
              }
            }
          }
        }
      }
    },
    "/users.create_user": {
      "post": {
        "operationId": "pacific_bending_app.api.users.create_user",
        "summary": "Create a new user with roles",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only creates users\nKISS: Simple user creation with role assignment\nDRY: Uses Frappe's user creation API\n\nArgs:\n    email: User email (will be username)\n    full_name: User's full name\n    roles: JSON array of role names (e.g., '[\"Estimator\", \"Shop Floor\"]')\n    send_welcome_email: Send onboarding email with secure setup link (default: True)\n    user_type: User type (default: \"System User\")\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"name\": \"user@example.com\",\n            \"email\": \"user@example.com\",\n            \"full_name\": \"John Doe\",\n            \"enabled\": 1,\n            \"roles\": [\"Estimator\", \"Shop Floor\"]\n        },\n        \"message\": \"User created successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string"
                  },
                  "full_name": {
                    "type": "string"
                  },
                  "roles": {
                    "type": "string"
                  },
                  "companies": {
                    "type": "string"
                  },
                  "warehouses": {
                    "type": "string"
                  },
                  "send_welcome_email": {
                    "type": "boolean"
                  },
                  "user_type": {
                    "type": "string"
                  },
                  "create_employee": {
                    "type": "string"
                  },
                  "employee_name": {
                    "type": "string"
                  },
                  "employee_number": {
                    "type": "string"
                  },
                  "employee_designation": {
                    "type": "string"
                  },
                  "employee_date_of_joining": {
                    "type": "string"
                  },
                  "employee_company": {
                    "type": "string"
                  }
                },
                "required": [
                  "email",
                  "full_name",
                  "roles"
                ]
              }
            }
          }
        }
      }
    },
    "/users.deactivate_user": {
      "post": {
        "operationId": "pacific_bending_app.api.users.deactivate_user",
        "summary": "Deactivate a user (soft delete)",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only deactivates users\nKISS: Simple status update\nDRY: Uses Frappe's user management\n\nArgs:\n    user_email: User email to deactivate\n    reason: Optional reason for deactivation\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"user\": \"user@example.com\",\n            \"deactivated_at\": \"2025-11-15T14:30:00\",\n            \"deactivated_by\": \"admin@example.com\",\n            \"reason\": \"Left company\"\n        },\n        \"message\": \"User deactivated successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_email": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "user_email"
                ]
              }
            }
          }
        }
      }
    },
    "/users.get_admin_summary": {
      "post": {
        "operationId": "pacific_bending_app.api.users.get_admin_summary",
        "summary": "Get summary of admin accounts for lockout prevention UI.",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns:\n    {\n        \"total_admins\": int,\n        \"admin_users\": [{\"name\": str, \"email\": str, \"enabled\": bool}],\n        \"can_safely_remove_admin\": bool\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/users.get_assignable_roles": {
      "post": {
        "operationId": "pacific_bending_app.api.users.get_assignable_roles",
        "summary": "Return user roles that can be assigned from the app's admin UI.",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns only canonical Pacific Bending app roles.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/users.get_role_permissions": {
      "post": {
        "operationId": "pacific_bending_app.api.users.get_role_permissions",
        "summary": "Get role permissions",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves permissions\nKISS: Simple permission query\nDRY: Uses Frappe's permission system\n\nArgs:\n    role: Specific role to get permissions for (optional, returns all if not specified)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"Estimator\": {\n                \"Quotation\": {\"read\": 1, \"write\": 1, \"create\": 1, \"delete\": 0},\n                \"Customer\": {\"read\": 1, \"write\": 1, \"create\": 1, \"delete\": 0}\n            },\n            \"Foreman\": {\n                \"Work Order\": {\"read\": 1, \"write\": 1, \"create\": 1, \"delete\": 0},\n                \"Job Card\": {\"read\": 1, \"write\": 1, \"create\": 1, \"delete\": 1}\n            }\n        },\n        \"message\": \"Role permissions retrieved successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/users.get_user_permission_scope": {
      "post": {
        "operationId": "pacific_bending_app.api.users.get_user_permission_scope",
        "summary": "Return Company/Warehouse User Permissions for a user.",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_email": {
                    "type": "string"
                  }
                },
                "required": [
                  "user_email"
                ]
              }
            }
          }
        }
      }
    },
    "/users.get_users": {
      "post": {
        "operationId": "pacific_bending_app.api.users.get_users",
        "summary": "Get list of users with role information",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only retrieves users\nKISS: Simple query with role enrichment\nDRY: Reuses Frappe Query Builder\n\nArgs:\n    search: Search term for user name/email (optional)\n    role: Filter by specific role (optional)\n    enabled: Filter by enabled status (1=enabled, 0=disabled, None=all)\n    limit: Maximum users to return (default: 50, max: 200)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": [\n            {\n                \"name\": \"user@example.com\",\n                \"email\": \"user@example.com\",\n                \"full_name\": \"John Doe\",\n                \"enabled\": 1,\n                \"user_type\": \"System User\",\n                \"roles\": [\"Estimator\", \"Foreman\"],\n                \"creation\": \"2024-01-15T10:00:00\",\n                \"last_login\": \"2024-01-20T14:30:00\",\n                \"user_image\": null\n            }\n        ],\n        \"count\": 25\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "search": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string"
                  },
                  "enabled": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/users.list_account_manager_users": {
      "post": {
        "operationId": "pacific_bending_app.api.users.list_account_manager_users",
        "summary": "List assignable account-manager users for estimator-facing CRM forms.",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns active System Users with canonical app roles and/or active Employee\nrecords linked via Employee.user_id. This keeps account-manager assignment\nconsistent with ERPNext v15's Employee\u2194User model while avoiding admin-only\nuser-management metadata.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "search": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/users.list_scope_options": {
      "post": {
        "operationId": "pacific_bending_app.api.users.list_scope_options",
        "summary": "List Company and Warehouse scope options for admin assignment UI.",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/users.reactivate_user": {
      "post": {
        "operationId": "pacific_bending_app.api.users.reactivate_user",
        "summary": "Reactivate a deactivated user",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only reactivates users\nKISS: Simple status update\n\nArgs:\n    user_email: User email to reactivate\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"user\": \"user@example.com\",\n            \"reactivated_at\": \"2025-11-15T15:00:00\",\n            \"reactivated_by\": \"admin@example.com\"\n        },\n        \"message\": \"User reactivated successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_email": {
                    "type": "string"
                  }
                },
                "required": [
                  "user_email"
                ]
              }
            }
          }
        }
      }
    },
    "/users.seed_scenario_users_for_local_testing": {
      "post": {
        "operationId": "pacific_bending_app.api.users.seed_scenario_users_for_local_testing",
        "summary": "Seed local role-handoff users used by the five confidence scenarios.",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Admin-only helper for development/testing environments. Operation is\nidempotent and safe to re-run.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/users.send_password_reset": {
      "post": {
        "operationId": "pacific_bending_app.api.users.send_password_reset",
        "summary": "Send ERPNext password-reset instructions for a user account.",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Admin workflow: used from User Management modal instead of setting\nplaintext passwords in-app.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_email": {
                    "type": "string"
                  }
                },
                "required": [
                  "user_email"
                ]
              }
            }
          }
        }
      }
    },
    "/users.update_employee_numbering_settings": {
      "post": {
        "operationId": "pacific_bending_app.api.users.update_employee_numbering_settings",
        "summary": "Update employee number auto-generation policy for User Management.",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "auto_enabled": {
                    "type": "string"
                  },
                  "allow_manual_override": {
                    "type": "string"
                  },
                  "prefix": {
                    "type": "string"
                  },
                  "digits": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/users.update_user_permission_scope": {
      "post": {
        "operationId": "pacific_bending_app.api.users.update_user_permission_scope",
        "summary": "Create/replace Company+Warehouse User Permissions for a user.",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_email": {
                    "type": "string"
                  },
                  "companies": {
                    "type": "string"
                  },
                  "warehouses": {
                    "type": "string"
                  },
                  "replace_all": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "user_email"
                ]
              }
            }
          }
        }
      }
    },
    "/users.update_user_roles": {
      "post": {
        "operationId": "pacific_bending_app.api.users.update_user_roles",
        "summary": "Update user roles",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only updates roles\nKISS: Simple role replacement or addition\nDRY: Uses Frappe's role management\n\nArgs:\n    user_email: User email\n    roles: JSON array of role names\n    replace_all: If True, replace all roles; if False, add to existing (default: True)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"user\": \"user@example.com\",\n            \"roles\": [\"Estimator\", \"Foreman\"],\n            \"previous_roles\": [\"Estimator\"]\n        },\n        \"message\": \"User roles updated successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_email": {
                    "type": "string"
                  },
                  "roles": {
                    "type": "string"
                  },
                  "replace_all": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "user_email",
                  "roles"
                ]
              }
            }
          }
        }
      }
    },
    "/users.upsert_user_employee_profile": {
      "post": {
        "operationId": "pacific_bending_app.api.users.upsert_user_employee_profile",
        "summary": "Create or update Employee profile linked to a User (`Employee.user_id`).",
        "tags": [
          "Users"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Best-practice ERPNext v15 pattern: operational identity is maintained on\nEmployee while authentication/permissions remain on User.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "user_email": {
                    "type": "string"
                  },
                  "create_employee": {
                    "type": "boolean"
                  },
                  "employee_name": {
                    "type": "string"
                  },
                  "employee_number": {
                    "type": "string"
                  },
                  "employee_designation": {
                    "type": "string"
                  },
                  "employee_date_of_joining": {
                    "type": "string"
                  },
                  "employee_company": {
                    "type": "string"
                  }
                },
                "required": [
                  "user_email"
                ]
              }
            }
          }
        }
      }
    },
    "/work_order_wizard.create_production_item_quick": {
      "post": {
        "operationId": "pacific_bending_app.api.work_order_wizard.create_production_item_quick",
        "summary": "Quick-create a production item with minimal fields",
        "tags": [
          "Work Order Wizard"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Creates production items only\nKISS: Minimal required fields, smart defaults\nIDEMPOTENT: Returns existing item by resolved unique item_code identity\n\nArgs:\n    item_name: Item name (required)\n    item_code: Item code (auto-generated if not provided)\n    item_group: Item group (default: \"Raw Material\")\n                Valid values: \"Raw Material\", \"Finished Goods\", \"Consumable\",\n                \"Products\", \"Services\", \"Sub Assemblies\"\n    description: Item description (auto-generated from attributes if not provided)\n    custom_material: Material code (AL, AS, BR, BZ, CS, CU, GL, MS, SS, TS, ZN)\n    custom_shape: Shape/form\n    custom_dimensions: Dimensions string\n    custom_unit_system: Unit system (\"Imperial\" or \"Metric\", defaults to \"Imperial\")\n    is_item_type: If True, creates an Item Type (template without length/area)\n    dimension_type: How inventory is tracked - \"Length\", \"LxW\", or \"Quantity\"\n    stock_uom: Stock unit of measure (default: \"Nos\" for stock, \"Hour\" for services)\n    is_stock_item: Optional explicit stock classification flag\n    include_item_in_manufacturing: Optional manufacturing eligibility flag\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"item_code\": \"ITEM-00123\",\n            \"item_name\": \"Custom Bracket\",\n            \"is_new\": True/False,\n            \"custom_is_template\":1/0,\n            \"custom_dimension_type\": \"L\"/\"LxW\"/\"Qty\",\n            ...\n        },\n        \"message\": \"Item created successfully\" | \"Existing item found\"\n     }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Estimator",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_name": {
                    "type": "string"
                  },
                  "item_code": {
                    "type": "string"
                  },
                  "item_group": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "custom_material": {
                    "type": "string"
                  },
                  "custom_shape": {
                    "type": "string"
                  },
                  "custom_dimensions": {
                    "type": "string"
                  },
                  "custom_unit_system": {
                    "type": "string"
                  },
                  "custom_attributes": {
                    "type": "string"
                  },
                  "is_item_type": {
                    "type": "boolean"
                  },
                  "dimension_type": {
                    "type": "string"
                  },
                  "stock_uom": {
                    "type": "string"
                  },
                  "is_stock_item": {
                    "type": "string"
                  },
                  "include_item_in_manufacturing": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_name"
                ]
              }
            }
          }
        }
      }
    },
    "/work_order_wizard.create_work_order_v2": {
      "post": {
        "operationId": "pacific_bending_app.api.work_order_wizard.create_work_order_v2",
        "summary": "Create work order from V2 wizard form data",
        "tags": [
          "Work Order Wizard"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Creates Work Order with all wizard data\nKISS: Accepts full wizard payload, creates complete WO\n\nArgs:\n    job_description: Description of the job\n    qty: Quantity to produce\n    priority: Priority level (Low, Medium, High, Urgent)\n    job_material_type: Material type from wizard\n    job_shape: Shape from wizard\n    job_dimensions: Dimensions from wizard\n    planned_start_date: Planned start (ISO format)\n    planned_end_date: Planned end/due date (ISO format)\n    production_item: Item to produce\n    item_match_type: How item was matched (existing, new, generic)\n    new_item_name: Name if new item was created\n    customer: Customer link\n    sales_order: Sales Order link\n    is_internal_job: Whether this is an internal job\n    internal_job_type: Type of internal job\n    internal_job_notes: Notes for internal job\n    operations: JSON array of operations\n    bom_no: Native ERPNext BOM link\n    required_items: JSON array of materials, each with optional batch_allocations:\n        [\n            {\n                \"item_code\": \"ITEM-001\",\n                \"item_name\": \"Steel Plate\",\n                \"required_qty\": 10,\n                \"batch_allocations\": [\n                    {\n                        \"batch_id\": \"BATCH-001\",\n                        \"batch_line_idx\": 0,\n                        \"allocated_qty\": 5\n                    }\n                ]\n            }\n        ]\n    wip_warehouse: Work-in-progress warehouse\n    fg_warehouse: Finished goods warehouse\n    notes: Additional notes\n\nNote (v3.1):\n    Batch allocations are persisted to the custom_batch_allocations child table,\n    ensuring allocation decisions from the wizard are not lost after Work Order creation.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"work_order_name\": \"WO-00123\"\n        },\n        \"message\": \"Work order created successfully\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_description": {
                    "type": "string"
                  },
                  "qty": {
                    "type": "integer"
                  },
                  "priority": {
                    "type": "string"
                  },
                  "job_material_type": {
                    "type": "string"
                  },
                  "job_shape": {
                    "type": "string"
                  },
                  "job_dimensions": {
                    "type": "string"
                  },
                  "planned_start_date": {
                    "type": "string"
                  },
                  "planned_end_date": {
                    "type": "string"
                  },
                  "production_item": {
                    "type": "string"
                  },
                  "item_match_type": {
                    "type": "string"
                  },
                  "new_item_name": {
                    "type": "string"
                  },
                  "customer": {
                    "type": "string"
                  },
                  "sales_order": {
                    "type": "string"
                  },
                  "is_internal_job": {
                    "type": "boolean"
                  },
                  "internal_job_type": {
                    "type": "string"
                  },
                  "internal_job_notes": {
                    "type": "string"
                  },
                  "operations": {
                    "type": "string"
                  },
                  "bom_no": {
                    "type": "string"
                  },
                  "required_items": {
                    "type": "string"
                  },
                  "wip_warehouse": {
                    "type": "string"
                  },
                  "fg_warehouse": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/work_order_wizard.get_bom_template_full": {
      "post": {
        "operationId": "pacific_bending_app.api.work_order_wizard.get_bom_template_full",
        "summary": "Get complete BOM template including operations AND materials",
        "tags": [
          "Work Order Wizard"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Retrieves BOM with full details\nKISS: Returns both operations and materials in one call\n\nArgs:\n    template_id: BOM document name (e.g., \"BOM-ITEM-001\")\n    qty: Quantity multiplier for material calculations (default 1)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"template_id\": \"BOM-ITEM-001\",\n            \"template_name\": \"Custom Bracket BOM\",\n            \"item\": \"ITEM-001\",\n            \"item_name\": \"Custom Bracket\",\n            \"operations\": [\n                {\n                    \"operation\": \"Cutting\",\n                    \"workstation\": \"WS-001\",\n                    \"time_in_mins\": 30,\n                    \"idx\": 1,\n                    \"description\": \"\"\n                }\n            ],\n            \"materials\": [\n                {\n                    \"item_code\": \"STEEL-001\",\n                    \"item_name\": \"Steel Plate\",\n                    \"required_qty\": 2.5,\n                    \"uom\": \"Kg\"\n                }\n            ],\n            \"qc_checkpoints\": [...]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template_id": {
                    "type": "string"
                  },
                  "qty": {
                    "type": "integer"
                  }
                },
                "required": [
                  "template_id"
                ]
              }
            }
          }
        }
      }
    },
    "/work_order_wizard.get_bom_template_preview": {
      "post": {
        "operationId": "pacific_bending_app.api.work_order_wizard.get_bom_template_preview",
        "summary": "Get BOM template with operations, QC checkpoints, and time estimates",
        "tags": [
          "Work Order Wizard"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "for preview in Work Order Wizard.\n\nSOLID: Single Responsibility - Returns preview data for template modal\nKISS: Lightweight preview focused on operations timeline\n\nArgs:\n    template_id: BOM document name (e.g., \"BOM-ITEM-001\")\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"name\": \"BOM-ITEM-001\",\n            \"item\": \"ITEM-001\",\n            \"item_name\": \"Custom Bracket\",\n            \"operations\": [\n                {\n                    \"operation\": \"Cutting\",\n                    \"operation_name\": \"Cutting\",\n                    \"workstation\": \"WS-001\",\n                    \"workstation_name\": \"Cutting Station\",\n                    \"time_in_mins\": 30,\n                    \"idx\": 1,\n                    \"description\": \"Cut to size\"\n                }\n            ],\n            \"qc_checkpoints\": [\n                {\n                    \"stage\": \"Cutting\",\n                    \"checkpoint_description\": \"Measure dimensions\",\n                    \"criteria\": \"\u00b11mm tolerance\",\n                    \"idx\": 1\n                }\n            ],\n            \"total_time_mins\": 90\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "template_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "template_id"
                ]
              }
            }
          }
        }
      }
    },
    "/work_order_wizard.get_bom_templates_list": {
      "post": {
        "operationId": "pacific_bending_app.api.work_order_wizard.get_bom_templates_list",
        "summary": "Get list of active BOM templates for selector",
        "tags": [
          "Work Order Wizard"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Lists BOM templates\nKISS: Simple search with item name/code\n\nArgs:\n    query: Search text (optional)\n    limit: Max results (default 20)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"templates\": [\n                {\n                    \"bom_id\": \"BOM-ITEM-001\",\n                    \"item\": \"ITEM-001\",\n                    \"item_name\": \"Steel Bracket\",\n                    \"operations_count\": 3,\n                    \"materials_count\": 5,\n                    \"is_default\": 1\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/work_order_wizard.get_recent_items": {
      "post": {
        "operationId": "pacific_bending_app.api.work_order_wizard.get_recent_items",
        "summary": "Get user's recently used production items from Work Orders",
        "tags": [
          "Work Order Wizard"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Retrieves recent items only\nKISS: Simple query based on Work Order creation time\n\nArgs:\n    limit: Maximum items to return (default 5)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"items\": [\n                {\n                    \"item_code\": \"ITEM-001\",\n                    \"item_name\": \"Steel Bracket\",\n                    \"last_used\": \"2025-12-10 14:30:00\",\n                    \"use_count\": 5,\n                    \"description\": \"...\",\n                    \"custom_material\": \"CS\"\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "limit": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/work_order_wizard.mark_item_used": {
      "post": {
        "operationId": "pacific_bending_app.api.work_order_wizard.mark_item_used",
        "summary": "Track item usage for recency sorting (lightweight)",
        "tags": [
          "Work Order Wizard"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only updates usage tracking\nKISS: Simple increment and timestamp update\n\nArgs:\n    item_code: Item document name\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Item usage tracked\"\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "item_code": {
                    "type": "string"
                  }
                },
                "required": [
                  "item_code"
                ]
              }
            }
          }
        }
      }
    },
    "/work_order_wizard.smart_item_search": {
      "post": {
        "operationId": "pacific_bending_app.api.work_order_wizard.smart_item_search",
        "summary": "Fuzzy search production items by name, description, material, shape",
        "tags": [
          "Work Order Wizard"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Only searches items\nKISS: Simple fuzzy matching with optional filters\n\nArgs:\n    query: Search text for item_code, item_name, description (optional)\n    material: Filter by material code (AL, AS, BR, BZ, CS, CU, GL, MS, SS, TS, ZN) (optional)\n    shape: Filter by custom_shape (optional)\n    limit: Max results to return (default 20)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"items\": [\n                {\n                    \"item_code\": \"ITEM-001\",\n                    \"item_name\": \"Steel Bracket\",\n                    \"description\": \"...\",\n                    \"custom_material\": \"CS\",\n                    \"custom_shape\": \"Bracket\",\n                    \"item_group\": \"Raw Material\",\n                    \"stock_uom\": \"Nos\"\n                }\n            ],\n            \"total_count\": 15\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager",
          "Foreman",
          "Estimator",
          "Shop Floor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "type": "string"
                  },
                  "material": {
                    "type": "string"
                  },
                  "shape": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/workstation.assign_to_workstation": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.assign_to_workstation",
        "summary": "Assign a job card to a workstation",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Assigns job to workstation\nKISS: Simple assignment with optional scheduling\n\nArgs:\n    job_card_id: Job Card document name\n    workstation_id: Workstation to assign to\n    expected_start: Expected start datetime (optional)\n    notes: Assignment notes (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Job assigned to workstation\",\n        \"data\": {...}\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "job_card_id": {
                    "type": "string"
                  },
                  "workstation_id": {
                    "type": "string"
                  },
                  "expected_start": {
                    "type": "string"
                  },
                  "notes": {
                    "type": "string"
                  }
                },
                "required": [
                  "job_card_id",
                  "workstation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/workstation.bulk_assign_tags": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.bulk_assign_tags",
        "summary": "Bulk assign tags to multiple workstations",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Bulk tag assignment\nKISS: Simple bulk update with replace/add modes\n\nArgs:\n    workstation_ids: JSON array of workstation IDs\n    tag_codes: JSON array of tag category codes to assign\n    mode: \"replace\" (clear existing + add) or \"add\" (append to existing)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Updated 5 workstations with 3 tags\",\n        \"data\": {\n            \"updated_count\": 5,\n            \"tags_assigned\": [\"laser\", \"cnc\", \"bending\"]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workstation_ids": {
                    "type": "string"
                  },
                  "tag_codes": {
                    "type": "string"
                  },
                  "mode": {
                    "type": "string"
                  }
                },
                "required": [
                  "workstation_ids",
                  "tag_codes"
                ]
              }
            }
          }
        }
      }
    },
    "/workstation.create_workstation": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.create_workstation",
        "summary": "Create a new workstation",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Creates workstation only\nKISS: Simple creation with sensible defaults\n\nArgs:\n    workstation_name: Name of the workstation (required)\n    description: Description of the workstation (optional)\n    warehouse: Warehouse group for location (optional, native ERPNext field)\n    capacity_per_day: Hours available per day (default: 8)\n    utilization_target: Target utilization percentage (default: 80)\n    hour_rate: Total hourly rate (default: 0) - used if breakdown not provided\n    hour_rate_labour: Labour cost per hour (optional)\n    hour_rate_electricity: Electricity cost per hour (optional)\n    hour_rate_rent: Rent/depreciation cost per hour (optional)\n    holiday_list: Holiday list for capacity planning (optional)\n    working_hours: JSON array of working hour slots (optional)\n        Each slot: {\"start_time\": \"09:00\", \"end_time\": \"17:00\", \"enabled\": true}\n    tags: JSON array of tag category codes (optional)\n    powder_enabled: Enable powder batching on this workstation (optional)\n    default_cure_profile: Default Powder Cure Profile code (optional)\n    max_powder_batch_size: Max jobs in a powder batch (optional)\n    color_changeover_minutes: Estimated color changeover duration in minutes (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Workstation created\",\n        \"data\": {\n            \"id\": \"WS-001\",\n            \"name\": \"CNC Mill #1\",\n            ...\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workstation_name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "warehouse": {
                    "type": "string"
                  },
                  "capacity_per_day": {
                    "type": "number"
                  },
                  "utilization_target": {
                    "type": "number"
                  },
                  "hour_rate": {
                    "type": "number"
                  },
                  "hour_rate_labour": {
                    "type": "string"
                  },
                  "hour_rate_electricity": {
                    "type": "string"
                  },
                  "hour_rate_rent": {
                    "type": "string"
                  },
                  "holiday_list": {
                    "type": "string"
                  },
                  "working_hours": {
                    "type": "string"
                  },
                  "tags": {
                    "type": "string"
                  },
                  "powder_enabled": {
                    "type": "string"
                  },
                  "default_cure_profile": {
                    "type": "string"
                  },
                  "max_powder_batch_size": {
                    "type": "string"
                  },
                  "color_changeover_minutes": {
                    "type": "string"
                  }
                },
                "required": [
                  "workstation_name"
                ]
              }
            }
          }
        }
      }
    },
    "/workstation.deactivate_workstation": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.deactivate_workstation",
        "summary": "Deactivate (soft delete) a workstation",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Deactivates workstation only\nKISS: Simple disable flag, preserves history\n\nNote: Does not permanently delete - sets disabled=1 to preserve\nhistorical data for job cards that referenced this workstation.\n\nArgs:\n    workstation_id: Workstation document name (required)\n    reason: Reason for deactivation (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Workstation deactivated\",\n        \"data\": {...}\n    }\n\nErrors:\n    - Cannot deactivate if workstation has active jobs assigned",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workstation_id": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "workstation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/workstation.get_active_tag_categories": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.get_active_tag_categories",
        "summary": "Get active workstation tag categories for filtering/selection",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Lists active tag categories\nKISS: Simple list for filters and selectors (non-admin view)\n\nUnlike the admin endpoint (settings.get_tag_categories), this only\nreturns active categories and is accessible to all staff.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"categories\": [\n                {\n                    \"code\": \"laser\",\n                    \"label\": \"Laser\",\n                    \"color\": \"#EF4444\"\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/workstation.get_holiday_lists": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.get_holiday_lists",
        "summary": "Get available holiday lists for workstation capacity planning",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Lists holiday lists\nKISS: Simple list for selector dropdown\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"holiday_lists\": [\n                {\n                    \"name\": \"Pacific Bending 2025\",\n                    \"total_holidays\": 12\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ]
      }
    },
    "/workstation.get_workstation_operations": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.get_workstation_operations",
        "summary": "Get operations that have this workstation as their default workstation",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Lists operations for a workstation\nKISS: Simple lookup for workstation-operation relationship\n\nArgs:\n    workstation_id: Workstation document name (required)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"operations\": [\n                {\n                    \"name\": \"Laser Cutting\",\n                    \"description\": \"Standard laser cutting operation\",\n                    \"batch_size\": 1,\n                    \"is_corrective\": false\n                }\n            ]\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workstation_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "workstation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/workstation.get_workstation_queue": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.get_workstation_queue",
        "summary": "Get job queue for a specific workstation",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Lists jobs in workstation queue\nKISS: Simple queue with status filtering\n\nArgs:\n    workstation_id: Workstation document name\n    status_filter: Filter by job status (optional)\n    limit: Maximum jobs to return\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"workstation\": {...},\n            \"queue\": [...],\n            \"total_jobs\": 15,\n            \"in_progress\": 2,\n            \"pending\": 13\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workstation_id": {
                    "type": "string"
                  },
                  "status_filter": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  }
                },
                "required": [
                  "workstation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/workstation.get_workstation_utilization": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.get_workstation_utilization",
        "summary": "Get historical utilization data for a workstation",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Calculates utilization metrics\nKISS: Simple daily utilization with trends\n\nArgs:\n    workstation_id: Workstation document name\n    date_from: Start date (optional)\n    date_to: End date (optional)\n    period: Period shorthand (7d, 30d)\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"workstation\": {...},\n            \"average_utilization\": 75.5,\n            \"daily_utilization\": [...],\n            \"peak_hours\": [...],\n            \"comparison\": {...}\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workstation_id": {
                    "type": "string"
                  },
                  "date_from": {
                    "type": "string"
                  },
                  "date_to": {
                    "type": "string"
                  },
                  "period": {
                    "type": "string"
                  }
                },
                "required": [
                  "workstation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/workstation.get_workstations": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.get_workstations",
        "summary": "Get list of workstations with current load",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Lists workstations with status\nKISS: Simple list with optional load data\n\nArgs:\n    location: Filter by location (optional)\n    tag_filter: JSON array of tag codes to filter by (optional)\n    status: Filter by status - available, busy, maintenance, offline (optional)\n    search: Search workstation name or description (optional)\n    include_load: Include current load metrics (default: True)\n    include_queue: Include job queue preview (default: False)\n    include_disabled: Include disabled workstations (default: True)\n    limit: Optional pagination limit (0/None returns all)\n    start: Optional pagination start offset\n    queue_date: Optional date filter (YYYY-MM-DD) for job queue (only applies if include_queue=True)\n    queue_limit: Maximum queue rows returned per workstation when include_queue=True.\n        Use a higher value for schedule-style views that need the real queue, not a preview.\n\nReturns:\n    {\n        \"success\": True,\n        \"data\": {\n            \"workstations\": [...],\n            \"total_count\": 10,\n            \"summary\": {\n                \"available\": 7,\n                \"busy\": 2,\n                \"maintenance\": 1\n            }\n        }\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Shop Floor",
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "location": {
                    "type": "string"
                  },
                  "tag_filter": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "search": {
                    "type": "string"
                  },
                  "include_load": {
                    "type": "boolean"
                  },
                  "include_queue": {
                    "type": "boolean"
                  },
                  "include_disabled": {
                    "type": "boolean"
                  },
                  "limit": {
                    "type": "string"
                  },
                  "start": {
                    "type": "integer"
                  },
                  "queue_date": {
                    "type": "string"
                  },
                  "queue_limit": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/workstation.reactivate_workstation": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.reactivate_workstation",
        "summary": "Reactivate a previously deactivated workstation",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Reactivates workstation only\nKISS: Simple re-enable\n\nArgs:\n    workstation_id: Workstation document name (required)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Workstation reactivated\",\n        \"data\": {...}\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workstation_id": {
                    "type": "string"
                  }
                },
                "required": [
                  "workstation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/workstation.seed_workstations": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.seed_workstations",
        "summary": "Seed standard Workstations for metal fabrication.",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Idempotent: Safe to run multiple times, will skip existing.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Admin",
          "System Manager"
        ]
      }
    },
    "/workstation.set_work_order_priority": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.set_work_order_priority",
        "summary": "Update scheduling priority for a Work Order.",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Accepts a 1-5 priority level and persists it to Work Order.custom_priority_level.",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "work_order_id": {
                    "type": "string"
                  },
                  "priority": {
                    "type": "string"
                  }
                },
                "required": [
                  "work_order_id",
                  "priority"
                ]
              }
            }
          }
        }
      }
    },
    "/workstation.update_workstation": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.update_workstation",
        "summary": "Update workstation details (partial updates supported)",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Updates workstation only\nKISS: Simple partial update pattern\n\nArgs:\n    workstation_id: Workstation document name (required)\n    workstation_name: New name (optional)\n    description: New description (optional)\n    warehouse: Warehouse group for location (optional, empty string to clear)\n    capacity_per_day: New capacity in hours (optional)\n    utilization_target: New target percentage (optional)\n    hour_rate: Total hourly rate (optional) - used if breakdown not provided\n    hour_rate_labour: Labour cost per hour (optional)\n    hour_rate_electricity: Electricity cost per hour (optional)\n    hour_rate_rent: Rent/depreciation cost per hour (optional)\n    holiday_list: Holiday list for capacity planning (optional, empty string to clear)\n    working_hours: JSON array of working hour slots (optional) - replaces existing schedule\n        Each slot: {\"start_time\": \"09:00\", \"end_time\": \"17:00\", \"enabled\": true}\n    tags: JSON array of tag category codes (optional) - replaces existing tags\n    powder_enabled: Toggle powder batching for this workstation (optional)\n    default_cure_profile: Default Powder Cure Profile code (optional, empty string clears)\n    max_powder_batch_size: Max jobs in a powder batch (optional)\n    color_changeover_minutes: Estimated color changeover duration in minutes (optional)\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Workstation updated\",\n        \"data\": {...}\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workstation_id": {
                    "type": "string"
                  },
                  "workstation_name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "warehouse": {
                    "type": "string"
                  },
                  "capacity_per_day": {
                    "type": "string"
                  },
                  "utilization_target": {
                    "type": "string"
                  },
                  "hour_rate": {
                    "type": "string"
                  },
                  "hour_rate_labour": {
                    "type": "string"
                  },
                  "hour_rate_electricity": {
                    "type": "string"
                  },
                  "hour_rate_rent": {
                    "type": "string"
                  },
                  "holiday_list": {
                    "type": "string"
                  },
                  "working_hours": {
                    "type": "string"
                  },
                  "tags": {
                    "type": "string"
                  },
                  "powder_enabled": {
                    "type": "string"
                  },
                  "default_cure_profile": {
                    "type": "string"
                  },
                  "max_powder_batch_size": {
                    "type": "string"
                  },
                  "color_changeover_minutes": {
                    "type": "string"
                  }
                },
                "required": [
                  "workstation_id"
                ]
              }
            }
          }
        }
      }
    },
    "/workstation.update_workstation_status": {
      "post": {
        "operationId": "pacific_bending_app.api.workstation.update_workstation_status",
        "summary": "Update workstation operational status",
        "tags": [
          "Workstation"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "SOLID: Single Responsibility - Updates workstation status\nKISS: Simple status update with reason\n\nArgs:\n    workstation_id: Workstation document name\n    status: New status (Available, Maintenance, Offline)\n    reason: Reason for status change\n    expected_available: Expected datetime when available again\n\nReturns:\n    {\n        \"success\": True,\n        \"message\": \"Workstation status updated\",\n        \"data\": {...}\n    }",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-required-roles": [
          "Foreman",
          "Admin",
          "System Manager"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workstation_id": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  },
                  "expected_available": {
                    "type": "string"
                  }
                },
                "required": [
                  "workstation_id",
                  "status"
                ]
              }
            }
          }
        }
      }
    },
    "/get_api_documentation": {
      "post": {
        "operationId": "pacific_bending_app.utils.api_schema.get_api_documentation",
        "summary": "API: Get comprehensive API documentation",
        "tags": [
          "Api Schema"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns OpenAPI 3.0 specification\n\nThis endpoint is publicly accessible for documentation purposes"
      }
    },
    "/get_error_codes": {
      "post": {
        "operationId": "pacific_bending_app.utils.api_schema.get_error_codes",
        "summary": "API: Get all error codes with messages and actions",
        "tags": [
          "Api Schema"
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Permission denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "description": "Returns comprehensive error code catalog\n\nThis endpoint is publicly accessible for documentation purposes"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "description": "API key authentication. Format: `token api_key:api_secret`"
      },
      "SessionAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "sid",
        "description": "Session cookie authentication (after login)"
      }
    },
    "schemas": {
      "AmendQuotationRequest": {
        "description": "Request for amending a submitted quotation",
        "properties": {
          "quotation_id": {
            "description": "Original quotation ID",
            "title": "Quotation Id",
            "type": "string"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Amendment reason",
            "title": "Reason"
          }
        },
        "required": [
          "quotation_id"
        ],
        "title": "AmendQuotationRequest",
        "type": "object"
      },
      "BulkUpdateQuoteItemsRequest": {
        "description": "Request for bulk updating quote items",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID",
            "title": "Quotation Id",
            "type": "string"
          },
          "items": {
            "description": "JSON array of items with updates",
            "title": "Items",
            "type": "string"
          }
        },
        "required": [
          "quotation_id",
          "items"
        ],
        "title": "BulkUpdateQuoteItemsRequest",
        "type": "object"
      },
      "CalculateQuotePricingRequest": {
        "description": "Request for price calculation",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID",
            "title": "Quotation Id",
            "type": "string"
          },
          "apply_discount": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": false,
            "description": "Apply customer discount",
            "title": "Apply Discount"
          },
          "discount_percent": {
            "anyOf": [
              {
                "maximum": 100,
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Override discount percentage",
            "title": "Discount Percent"
          }
        },
        "required": [
          "quotation_id"
        ],
        "title": "CalculateQuotePricingRequest",
        "type": "object"
      },
      "CompareQuotationsRequest": {
        "description": "Request for comparing two quotations",
        "properties": {
          "quotation_id_1": {
            "description": "First quotation ID",
            "title": "Quotation Id 1",
            "type": "string"
          },
          "quotation_id_2": {
            "description": "Second quotation ID",
            "title": "Quotation Id 2",
            "type": "string"
          }
        },
        "required": [
          "quotation_id_1",
          "quotation_id_2"
        ],
        "title": "CompareQuotationsRequest",
        "type": "object"
      },
      "ConvertLeadToCustomerRequest": {
        "description": "Request for lead to customer conversion",
        "properties": {
          "lead_id": {
            "description": "Lead ID to convert",
            "title": "Lead Id",
            "type": "string"
          }
        },
        "required": [
          "lead_id"
        ],
        "title": "ConvertLeadToCustomerRequest",
        "type": "object"
      },
      "CreateNewMaterialRequest": {
        "description": "Request for creating a new material on-the-fly",
        "properties": {
          "item_name": {
            "description": "Material name",
            "maxLength": 140,
            "minLength": 1,
            "title": "Item Name",
            "type": "string"
          },
          "item_group": {
            "description": "Item group (e.g., 'Raw Materials')",
            "title": "Item Group",
            "type": "string"
          },
          "uom": {
            "description": "Stock unit of measure",
            "title": "Uom",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item description",
            "title": "Description"
          },
          "is_stock_item": {
            "default": true,
            "description": "Track in inventory",
            "title": "Is Stock Item",
            "type": "boolean"
          },
          "standard_rate": {
            "anyOf": [
              {
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Standard selling rate",
            "title": "Standard Rate"
          },
          "valuation_rate": {
            "anyOf": [
              {
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Valuation/cost rate",
            "title": "Valuation Rate"
          }
        },
        "required": [
          "item_name",
          "item_group",
          "uom"
        ],
        "title": "CreateNewMaterialRequest",
        "type": "object"
      },
      "CreateQuotationRequest": {
        "description": "Request for creating a new quotation",
        "properties": {
          "party_name": {
            "description": "Customer name/ID",
            "title": "Party Name",
            "type": "string"
          },
          "quotation_to": {
            "default": "Customer",
            "description": "Quotation type",
            "title": "Quotation To",
            "type": "string"
          },
          "transaction_date": {
            "description": "Transaction date (YYYY-MM-DD)",
            "title": "Transaction Date",
            "type": "string"
          },
          "valid_till": {
            "description": "Valid until date (YYYY-MM-DD)",
            "title": "Valid Till",
            "type": "string"
          },
          "items": {
            "description": "Quotation line items",
            "items": {
              "$ref": "#/components/schemas/QuotationItemSchema"
            },
            "minItems": 1,
            "title": "Items",
            "type": "array"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Location group",
            "title": "Location"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Company (defaults to global default)",
            "title": "Company"
          },
          "currency": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Currency code (defaults to CAD)",
            "title": "Currency"
          },
          "customer_address": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Customer address reference",
            "title": "Customer Address"
          },
          "contact_person": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Contact person reference",
            "title": "Contact Person"
          },
          "custom_lead_time_weeks": {
            "anyOf": [
              {
                "maximum": 52,
                "minimum": 1,
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Lead time in weeks",
            "title": "Custom Lead Time Weeks"
          },
          "custom_notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Internal notes",
            "title": "Custom Notes"
          },
          "custom_customer_notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Notes for customer",
            "title": "Custom Customer Notes"
          }
        },
        "required": [
          "party_name",
          "transaction_date",
          "valid_till",
          "items"
        ],
        "title": "CreateQuotationRequest",
        "type": "object"
      },
      "QuotationItemSchema": {
        "description": "Schema for quotation line item",
        "properties": {
          "item_code": {
            "description": "Item code",
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item name (auto-populated if not provided)",
            "title": "Item Name"
          },
          "qty": {
            "description": "Quantity (must be > 0)",
            "exclusiveMinimum": 0,
            "title": "Qty",
            "type": "number"
          },
          "rate": {
            "description": "Rate per unit",
            "minimum": 0,
            "title": "Rate",
            "type": "number"
          },
          "uom": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Unit of measure",
            "title": "Uom"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item description",
            "title": "Description"
          },
          "discount_percentage": {
            "anyOf": [
              {
                "maximum": 100,
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": 0,
            "description": "Discount percentage",
            "title": "Discount Percentage"
          },
          "operation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Operation type for service items",
            "title": "Operation"
          },
          "estimated_hours": {
            "anyOf": [
              {
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Estimated hours for operation",
            "title": "Estimated Hours"
          },
          "custom_complexity_factor": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Complexity multiplier",
            "title": "Custom Complexity Factor"
          },
          "custom_notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Line item notes",
            "title": "Custom Notes"
          }
        },
        "required": [
          "item_code",
          "qty",
          "rate"
        ],
        "title": "QuotationItemSchema",
        "type": "object"
      },
      "CreateQuotationResponse": {
        "description": "Response for quotation creation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "quotation_id": {
            "description": "Created quotation ID",
            "title": "Quotation Id",
            "type": "string"
          },
          "grand_total": {
            "description": "Quotation grand total",
            "title": "Grand Total",
            "type": "number"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Resolved location group",
            "title": "Location"
          },
          "docstatus": {
            "description": "ERPNext document submission status",
            "title": "Docstatus",
            "type": "integer"
          },
          "status": {
            "description": "ERPNext status mirror",
            "title": "Status",
            "type": "string"
          },
          "workflow_state": {
            "description": "Canonical quote workflow state",
            "title": "Workflow State",
            "type": "string"
          },
          "message": {
            "default": "Quotation created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "quotation_id",
          "grand_total",
          "docstatus",
          "status",
          "workflow_state"
        ],
        "title": "CreateQuotationResponse",
        "type": "object"
      },
      "CreateWorkOrderFromQuoteRequest": {
        "description": "Request for converting quotation to work order",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID to convert",
            "title": "Quotation Id",
            "type": "string"
          }
        },
        "required": [
          "quotation_id"
        ],
        "title": "CreateWorkOrderFromQuoteRequest",
        "type": "object"
      },
      "CustomerAddressSchema": {
        "description": "Customer address reference",
        "properties": {
          "address_name": {
            "description": "Address document name",
            "title": "Address Name",
            "type": "string"
          },
          "address_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Billing/Shipping",
            "title": "Address Type"
          },
          "city": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "City",
            "title": "City"
          },
          "state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "State/Province",
            "title": "State"
          }
        },
        "required": [
          "address_name"
        ],
        "title": "CustomerAddressSchema",
        "type": "object"
      },
      "CustomerContactSchema": {
        "description": "Customer contact reference",
        "properties": {
          "contact_name": {
            "description": "Contact document name",
            "title": "Contact Name",
            "type": "string"
          },
          "first_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "First name",
            "title": "First Name"
          },
          "last_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Last name",
            "title": "Last Name"
          },
          "email_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Email address",
            "title": "Email Id"
          },
          "mobile_no": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Phone number",
            "title": "Mobile No"
          }
        },
        "required": [
          "contact_name"
        ],
        "title": "CustomerContactSchema",
        "type": "object"
      },
      "CustomerContextResponse": {
        "description": "Response for customer context",
        "properties": {
          "customer_id": {
            "title": "Customer Id",
            "type": "string"
          },
          "customer_name": {
            "title": "Customer Name",
            "type": "string"
          },
          "customer_group": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Customer Group"
          },
          "territory": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Territory"
          },
          "email_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Email Id"
          },
          "mobile_no": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Mobile No"
          },
          "credit_limit": {
            "default": 0,
            "title": "Credit Limit",
            "type": "number"
          },
          "outstanding_amount": {
            "default": 0,
            "title": "Outstanding Amount",
            "type": "number"
          },
          "available_credit": {
            "default": 0,
            "title": "Available Credit",
            "type": "number"
          },
          "addresses": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/CustomerAddressSchema"
            },
            "title": "Addresses",
            "type": "array"
          },
          "contacts": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/CustomerContactSchema"
            },
            "title": "Contacts",
            "type": "array"
          },
          "recent_quotations": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Recent Quotations",
            "type": "array"
          },
          "recent_orders": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Recent Orders",
            "type": "array"
          }
        },
        "required": [
          "customer_id",
          "customer_name"
        ],
        "title": "CustomerContextResponse",
        "type": "object"
      },
      "DuplicateQuotationRequest": {
        "description": "Request for duplicating a quotation",
        "properties": {
          "source_quotation_id": {
            "description": "Source quotation to duplicate",
            "title": "Source Quotation Id",
            "type": "string"
          }
        },
        "required": [
          "source_quotation_id"
        ],
        "title": "DuplicateQuotationRequest",
        "type": "object"
      },
      "GetCustomerContextRequest": {
        "description": "Request for customer context",
        "properties": {
          "customer_id": {
            "description": "Customer ID",
            "title": "Customer Id",
            "type": "string"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Warehouse group for location filtering",
            "title": "Location"
          }
        },
        "required": [
          "customer_id"
        ],
        "title": "GetCustomerContextRequest",
        "type": "object"
      },
      "GetGlobalPriceHistoryRequest": {
        "description": "Request for global price history (across all customers)",
        "properties": {
          "item_code": {
            "description": "Item code to look up",
            "title": "Item Code",
            "type": "string"
          },
          "limit": {
            "default": 5,
            "description": "Maximum records to return",
            "maximum": 50,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Location filter",
            "title": "Location"
          }
        },
        "required": [
          "item_code"
        ],
        "title": "GetGlobalPriceHistoryRequest",
        "type": "object"
      },
      "GetLeadTimeSuggestionRequest": {
        "description": "Request for lead time calculation",
        "properties": {
          "operations": {
            "description": "JSON array of operations with estimated hours",
            "title": "Operations",
            "type": "string"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Location for workstation lookup",
            "title": "Location"
          }
        },
        "required": [
          "operations"
        ],
        "title": "GetLeadTimeSuggestionRequest",
        "type": "object"
      },
      "GetPriceHistoryRequest": {
        "description": "Request for price history lookup",
        "properties": {
          "customer_id": {
            "description": "Customer ID",
            "title": "Customer Id",
            "type": "string"
          },
          "item_code": {
            "description": "Item code to look up",
            "title": "Item Code",
            "type": "string"
          },
          "limit": {
            "default": 5,
            "description": "Maximum records to return",
            "maximum": 50,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Location filter",
            "title": "Location"
          }
        },
        "required": [
          "customer_id",
          "item_code"
        ],
        "title": "GetPriceHistoryRequest",
        "type": "object"
      },
      "GetQuotationDetailRequest": {
        "description": "Request for quotation detail endpoint",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID (e.g., QTN-00001)",
            "title": "Quotation Id",
            "type": "string"
          }
        },
        "required": [
          "quotation_id"
        ],
        "title": "GetQuotationDetailRequest",
        "type": "object"
      },
      "GetQuotationsRequest": {
        "description": "Request for listing quotations",
        "properties": {
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by status",
            "title": "Status"
          },
          "customer": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by customer",
            "title": "Customer"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "start_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter from date (YYYY-MM-DD)",
            "title": "Start Date"
          },
          "end_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter to date (YYYY-MM-DD)",
            "title": "End Date"
          },
          "limit": {
            "default": 50,
            "description": "Page size",
            "maximum": 500,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          },
          "offset": {
            "default": 0,
            "description": "Page offset",
            "minimum": 0,
            "title": "Offset",
            "type": "integer"
          }
        },
        "title": "GetQuotationsRequest",
        "type": "object"
      },
      "LeadTimeSuggestionResponse": {
        "description": "Response for lead time calculation",
        "properties": {
          "suggested_weeks": {
            "description": "Suggested lead time in weeks",
            "title": "Suggested Weeks",
            "type": "integer"
          },
          "total_hours": {
            "description": "Total estimated hours",
            "title": "Total Hours",
            "type": "number"
          },
          "workstation_availability": {
            "additionalProperties": true,
            "description": "Availability by workstation",
            "title": "Workstation Availability",
            "type": "object"
          },
          "bottleneck_workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Workstation with longest queue",
            "title": "Bottleneck Workstation"
          },
          "earliest_start_date": {
            "description": "Earliest possible start date",
            "title": "Earliest Start Date",
            "type": "string"
          },
          "estimated_completion_date": {
            "description": "Estimated completion date",
            "title": "Estimated Completion Date",
            "type": "string"
          }
        },
        "required": [
          "suggested_weeks",
          "total_hours",
          "workstation_availability",
          "earliest_start_date",
          "estimated_completion_date"
        ],
        "title": "LeadTimeSuggestionResponse",
        "type": "object"
      },
      "PriceHistoryItem": {
        "description": "Single price history entry",
        "properties": {
          "quotation": {
            "title": "Quotation",
            "type": "string"
          },
          "transaction_date": {
            "title": "Transaction Date",
            "type": "string"
          },
          "qty": {
            "title": "Qty",
            "type": "number"
          },
          "rate": {
            "title": "Rate",
            "type": "number"
          },
          "amount": {
            "title": "Amount",
            "type": "number"
          },
          "status": {
            "title": "Status",
            "type": "string"
          }
        },
        "required": [
          "quotation",
          "transaction_date",
          "qty",
          "rate",
          "amount",
          "status"
        ],
        "title": "PriceHistoryItem",
        "type": "object"
      },
      "PriceHistoryResponse": {
        "description": "Response for price history lookup",
        "properties": {
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "customer_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Customer Id"
          },
          "average_rate": {
            "title": "Average Rate",
            "type": "number"
          },
          "min_rate": {
            "title": "Min Rate",
            "type": "number"
          },
          "max_rate": {
            "title": "Max Rate",
            "type": "number"
          },
          "history": {
            "items": {
              "$ref": "#/components/schemas/PriceHistoryItem"
            },
            "title": "History",
            "type": "array"
          }
        },
        "required": [
          "item_code",
          "average_rate",
          "min_rate",
          "max_rate",
          "history"
        ],
        "title": "PriceHistoryResponse",
        "type": "object"
      },
      "QuotationComparisonResponse": {
        "description": "Response for quotation comparison",
        "properties": {
          "quotation_1": {
            "$ref": "#/components/schemas/QuotationDetailResponse"
          },
          "quotation_2": {
            "$ref": "#/components/schemas/QuotationDetailResponse"
          },
          "differences": {
            "additionalProperties": true,
            "description": "Field-by-field differences",
            "title": "Differences",
            "type": "object"
          },
          "price_difference": {
            "description": "Total price difference",
            "title": "Price Difference",
            "type": "number"
          },
          "item_differences": {
            "description": "Item-level differences",
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Item Differences",
            "type": "array"
          }
        },
        "required": [
          "quotation_1",
          "quotation_2",
          "differences",
          "price_difference",
          "item_differences"
        ],
        "title": "QuotationComparisonResponse",
        "type": "object"
      },
      "QuotationDetailResponse": {
        "description": "Response for quotation detail",
        "properties": {
          "name": {
            "description": "Quotation ID",
            "title": "Name",
            "type": "string"
          },
          "party_name": {
            "description": "Customer ID",
            "title": "Party Name",
            "type": "string"
          },
          "customer_name": {
            "description": "Customer display name",
            "title": "Customer Name",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/QuotationStatus"
          },
          "transaction_date": {
            "title": "Transaction Date",
            "type": "string"
          },
          "valid_till": {
            "title": "Valid Till",
            "type": "string"
          },
          "grand_total": {
            "title": "Grand Total",
            "type": "number"
          },
          "currency": {
            "title": "Currency",
            "type": "string"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/QuotationItemResponse"
            },
            "title": "Items",
            "type": "array"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "workflow_state": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Workflow State"
          },
          "custom_approved_by": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Approved By"
          },
          "custom_lead_time_weeks": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Lead Time Weeks"
          },
          "custom_estimated_start_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Estimated Start Date"
          },
          "custom_estimated_completion_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Estimated Completion Date"
          },
          "owner": {
            "title": "Owner",
            "type": "string"
          },
          "creation": {
            "title": "Creation",
            "type": "string"
          },
          "modified": {
            "title": "Modified",
            "type": "string"
          }
        },
        "required": [
          "name",
          "party_name",
          "customer_name",
          "status",
          "transaction_date",
          "valid_till",
          "grand_total",
          "currency",
          "items",
          "owner",
          "creation",
          "modified"
        ],
        "title": "QuotationDetailResponse",
        "type": "object"
      },
      "QuotationItemResponse": {
        "description": "Response schema for quotation line item",
        "properties": {
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "qty": {
            "title": "Qty",
            "type": "number"
          },
          "rate": {
            "title": "Rate",
            "type": "number"
          },
          "amount": {
            "title": "Amount",
            "type": "number"
          },
          "uom": {
            "title": "Uom",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Description"
          },
          "discount_percentage": {
            "default": 0,
            "title": "Discount Percentage",
            "type": "number"
          },
          "discount_amount": {
            "default": 0,
            "title": "Discount Amount",
            "type": "number"
          }
        },
        "required": [
          "item_code",
          "item_name",
          "qty",
          "rate",
          "amount",
          "uom"
        ],
        "title": "QuotationItemResponse",
        "type": "object"
      },
      "QuotationStatus": {
        "type": "string",
        "enum": [
          "Draft",
          "Open",
          "Replied",
          "Ordered",
          "Lost",
          "Cancelled",
          "Expired"
        ]
      },
      "QuotationListItem": {
        "description": "Single quotation in list response",
        "properties": {
          "name": {
            "title": "Name",
            "type": "string"
          },
          "customer_name": {
            "title": "Customer Name",
            "type": "string"
          },
          "status": {
            "title": "Status",
            "type": "string"
          },
          "transaction_date": {
            "title": "Transaction Date",
            "type": "string"
          },
          "valid_till": {
            "title": "Valid Till",
            "type": "string"
          },
          "grand_total": {
            "title": "Grand Total",
            "type": "number"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "custom_lead_time_weeks": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Lead Time Weeks"
          }
        },
        "required": [
          "name",
          "customer_name",
          "status",
          "transaction_date",
          "valid_till",
          "grand_total"
        ],
        "title": "QuotationListItem",
        "type": "object"
      },
      "QuotationListResponse": {
        "description": "Paginated quotation list response",
        "properties": {
          "quotations": {
            "items": {
              "$ref": "#/components/schemas/QuotationListItem"
            },
            "title": "Quotations",
            "type": "array"
          },
          "total": {
            "title": "Total",
            "type": "integer"
          },
          "limit": {
            "title": "Limit",
            "type": "integer"
          },
          "offset": {
            "title": "Offset",
            "type": "integer"
          },
          "has_more": {
            "title": "Has More",
            "type": "boolean"
          }
        },
        "required": [
          "quotations",
          "total",
          "limit",
          "offset",
          "has_more"
        ],
        "title": "QuotationListResponse",
        "type": "object"
      },
      "QuoteTimelineEvent": {
        "description": "Single timeline event",
        "properties": {
          "timestamp": {
            "title": "Timestamp",
            "type": "string"
          },
          "event_type": {
            "title": "Event Type",
            "type": "string"
          },
          "description": {
            "title": "Description",
            "type": "string"
          },
          "user": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "User"
          },
          "data": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Data"
          }
        },
        "required": [
          "timestamp",
          "event_type",
          "description"
        ],
        "title": "QuoteTimelineEvent",
        "type": "object"
      },
      "QuoteTimelineResponse": {
        "description": "Response for quote timeline",
        "properties": {
          "quote_id": {
            "title": "Quote Id",
            "type": "string"
          },
          "events": {
            "items": {
              "$ref": "#/components/schemas/QuoteTimelineEvent"
            },
            "title": "Events",
            "type": "array"
          },
          "current_status": {
            "title": "Current Status",
            "type": "string"
          },
          "days_since_creation": {
            "title": "Days Since Creation",
            "type": "integer"
          }
        },
        "required": [
          "quote_id",
          "events",
          "current_status",
          "days_since_creation"
        ],
        "title": "QuoteTimelineResponse",
        "type": "object"
      },
      "SubmitQuoteForEngineeringRequest": {
        "description": "Request for submitting quote for engineering review",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID to submit",
            "title": "Quotation Id",
            "type": "string"
          }
        },
        "required": [
          "quotation_id"
        ],
        "title": "SubmitQuoteForEngineeringRequest",
        "type": "object"
      },
      "UpdateQuotationRequest": {
        "description": "Request for updating an existing quotation",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID to update",
            "title": "Quotation Id",
            "type": "string"
          },
          "items": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/QuotationItemSchema"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated line items",
            "title": "Items"
          },
          "valid_till": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "New validity date",
            "title": "Valid Till"
          },
          "custom_lead_time_weeks": {
            "anyOf": [
              {
                "maximum": 52,
                "minimum": 1,
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated lead time",
            "title": "Custom Lead Time Weeks"
          },
          "custom_notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated internal notes",
            "title": "Custom Notes"
          },
          "custom_customer_notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated customer notes",
            "title": "Custom Customer Notes"
          }
        },
        "required": [
          "quotation_id"
        ],
        "title": "UpdateQuotationRequest",
        "type": "object"
      },
      "WorkOrderCreationResponse": {
        "description": "Response for work order creation from quote",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "work_order_id": {
            "description": "Created work order ID",
            "title": "Work Order Id",
            "type": "string"
          },
          "quotation_id": {
            "description": "Source quotation ID",
            "title": "Quotation Id",
            "type": "string"
          },
          "job_cards": {
            "description": "Created job card IDs",
            "items": {
              "type": "string"
            },
            "title": "Job Cards",
            "type": "array"
          },
          "message": {
            "default": "Work order created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "work_order_id",
          "quotation_id",
          "job_cards"
        ],
        "title": "WorkOrderCreationResponse",
        "type": "object"
      },
      "BOMTemplateResponse": {
        "description": "Response for BOM template retrieval",
        "properties": {
          "name": {
            "description": "BOM ID",
            "title": "Name",
            "type": "string"
          },
          "item": {
            "description": "Product item code",
            "title": "Item",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "is_active": {
            "default": true,
            "title": "Is Active",
            "type": "boolean"
          },
          "is_default": {
            "default": false,
            "title": "Is Default",
            "type": "boolean"
          },
          "operations": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/OperationSchema"
            },
            "title": "Operations",
            "type": "array"
          },
          "items": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/MaterialSchema"
            },
            "title": "Items",
            "type": "array"
          },
          "qc_checkpoints": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/QCCheckpointSchema"
            },
            "title": "Qc Checkpoints",
            "type": "array"
          },
          "creation": {
            "title": "Creation",
            "type": "string"
          },
          "modified": {
            "title": "Modified",
            "type": "string"
          },
          "owner": {
            "title": "Owner",
            "type": "string"
          }
        },
        "required": [
          "name",
          "item",
          "item_name",
          "creation",
          "modified",
          "owner"
        ],
        "title": "BOMTemplateResponse",
        "type": "object"
      },
      "MaterialSchema": {
        "description": "BOM material definition",
        "properties": {
          "item_code": {
            "description": "Material item code",
            "title": "Item Code",
            "type": "string"
          },
          "qty": {
            "description": "Required quantity",
            "exclusiveMinimum": 0,
            "title": "Qty",
            "type": "number"
          },
          "uom": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Unit of measure",
            "title": "Uom"
          },
          "rate": {
            "anyOf": [
              {
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Material rate",
            "title": "Rate"
          },
          "operation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked operation name (legacy)",
            "title": "Operation"
          },
          "operation_instance_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked operation instance identifier",
            "title": "Operation Instance Id"
          }
        },
        "required": [
          "item_code",
          "qty"
        ],
        "title": "MaterialSchema",
        "type": "object"
      },
      "OperationSchema": {
        "description": "BOM operation definition",
        "properties": {
          "operation": {
            "description": "Operation name",
            "title": "Operation",
            "type": "string"
          },
          "operation_instance_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Stable operation instance identifier",
            "title": "Operation Instance Id"
          },
          "operation_label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "User-facing operation label (e.g., Assembly 1)",
            "title": "Operation Label"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Workstation assignment",
            "title": "Workstation"
          },
          "time_in_mins": {
            "default": 0,
            "description": "Estimated time in minutes",
            "minimum": 0,
            "title": "Time In Mins",
            "type": "number"
          },
          "sequence": {
            "default": 1,
            "description": "Operation sequence",
            "minimum": 1,
            "title": "Sequence",
            "type": "integer"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Operation notes",
            "title": "Description"
          }
        },
        "required": [
          "operation"
        ],
        "title": "OperationSchema",
        "type": "object"
      },
      "QCCheckpointSchema": {
        "description": "BOM template QC checkpoint definition (operation-linked, ERPNext v15-aligned)",
        "properties": {
          "checkpoint_name": {
            "description": "Checkpoint name",
            "title": "Checkpoint Name",
            "type": "string"
          },
          "operation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked Operation (preferred)",
            "title": "Operation"
          },
          "operation_instance_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked operation instance identifier (canonical)",
            "title": "Operation Instance Id"
          },
          "operation_label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked operation label for display",
            "title": "Operation Label"
          },
          "timing": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Before | After the linked operation",
            "title": "Timing"
          },
          "stage": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Legacy-compatible display stage label",
            "title": "Stage"
          },
          "handoff_note": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Optional rich-text handoff note (canonical)",
            "title": "Handoff Note"
          },
          "criteria": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Legacy alias for handoff note",
            "title": "Criteria"
          },
          "required": {
            "default": false,
            "description": "Is checkpoint mandatory",
            "title": "Required",
            "type": "boolean"
          }
        },
        "required": [
          "checkpoint_name"
        ],
        "title": "QCCheckpointSchema",
        "type": "object"
      },
      "BulkOperationResponse": {
        "description": "Response for bulk operations",
        "properties": {
          "success": {
            "default": true,
            "description": "Overall success (all items succeeded)",
            "title": "Success",
            "type": "boolean"
          },
          "total": {
            "description": "Total items processed",
            "title": "Total",
            "type": "integer"
          },
          "successful": {
            "description": "Number of successful operations",
            "title": "Successful",
            "type": "integer"
          },
          "failed": {
            "description": "Number of failed operations",
            "title": "Failed",
            "type": "integer"
          },
          "results": {
            "description": "Per-item results",
            "items": {
              "$ref": "#/components/schemas/BulkOperationResult"
            },
            "title": "Results",
            "type": "array"
          },
          "message": {
            "default": "Bulk operation completed",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "total",
          "successful",
          "failed",
          "results"
        ],
        "title": "BulkOperationResponse",
        "type": "object"
      },
      "BulkOperationResult": {
        "description": "Result of a single item in a bulk operation",
        "properties": {
          "id": {
            "description": "Item identifier",
            "title": "Id",
            "type": "string"
          },
          "success": {
            "description": "Whether operation succeeded",
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Result message",
            "title": "Message"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Error message if failed",
            "title": "Error"
          }
        },
        "required": [
          "id",
          "success"
        ],
        "title": "BulkOperationResult",
        "type": "object"
      },
      "BulkReviewMaterialOverridesRequest": {
        "description": "Request for bulk override review",
        "properties": {
          "override_request_ids": {
            "description": "JSON array of override request IDs",
            "title": "Override Request Ids",
            "type": "string"
          },
          "approved": {
            "description": "Approve or reject all",
            "title": "Approved",
            "type": "boolean"
          },
          "review_notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Review notes",
            "title": "Review Notes"
          }
        },
        "required": [
          "override_request_ids",
          "approved"
        ],
        "title": "BulkReviewMaterialOverridesRequest",
        "type": "object"
      },
      "BulkUpdateWorkOrderStatusRequest": {
        "description": "Request for bulk status update",
        "properties": {
          "work_order_ids": {
            "description": "JSON array of work order IDs",
            "title": "Work Order Ids",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/WorkOrderStatus",
            "description": "New status for all"
          }
        },
        "required": [
          "work_order_ids",
          "status"
        ],
        "title": "BulkUpdateWorkOrderStatusRequest",
        "type": "object"
      },
      "WorkOrderStatus": {
        "type": "string",
        "enum": [
          "Draft",
          "Not Started",
          "In Progress",
          "Completed",
          "Stopped",
          "Cancelled"
        ]
      },
      "CompleteJobCardRequest": {
        "description": "Request for completing a job card from shop floor",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "completed_qty": {
            "description": "Completed quantity",
            "exclusiveMinimum": 0,
            "title": "Completed Qty",
            "type": "number"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Completion notes",
            "title": "Notes"
          }
        },
        "required": [
          "job_card_id",
          "completed_qty"
        ],
        "title": "CompleteJobCardRequest",
        "type": "object"
      },
      "CreateManualTimeEntryRequest": {
        "description": "Request for manual time entry",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "start_time": {
            "description": "Start datetime (ISO format)",
            "title": "Start Time",
            "type": "string"
          },
          "end_time": {
            "description": "End datetime (ISO format)",
            "title": "End Time",
            "type": "string"
          },
          "employee": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Employee ID (defaults to current user)",
            "title": "Employee"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Time entry notes",
            "title": "Notes"
          }
        },
        "required": [
          "job_card_id",
          "start_time",
          "end_time"
        ],
        "title": "CreateManualTimeEntryRequest",
        "type": "object"
      },
      "CreateQCCheckpointRequest": {
        "description": "Request for creating QC checkpoint",
        "properties": {
          "work_order_id": {
            "description": "Work order ID",
            "title": "Work Order Id",
            "type": "string"
          },
          "operation_id": {
            "description": "Operation/Job card ID",
            "title": "Operation Id",
            "type": "string"
          },
          "checkpoint_data": {
            "description": "JSON checkpoint configuration",
            "title": "Checkpoint Data",
            "type": "string"
          }
        },
        "required": [
          "work_order_id",
          "operation_id",
          "checkpoint_data"
        ],
        "title": "CreateQCCheckpointRequest",
        "type": "object"
      },
      "GetMaterialAvailabilityRequest": {
        "description": "Request for material availability check",
        "properties": {
          "work_order_id": {
            "description": "Work order ID",
            "title": "Work Order Id",
            "type": "string"
          }
        },
        "required": [
          "work_order_id"
        ],
        "title": "GetMaterialAvailabilityRequest",
        "type": "object"
      },
      "GetOperatorProductivityRequest": {
        "description": "Request for operator productivity report",
        "properties": {
          "operator_id": {
            "description": "Operator user ID (email)",
            "title": "Operator Id",
            "type": "string"
          },
          "start_date": {
            "description": "Report start date (YYYY-MM-DD)",
            "title": "Start Date",
            "type": "string"
          },
          "end_date": {
            "description": "Report end date (YYYY-MM-DD)",
            "title": "End Date",
            "type": "string"
          }
        },
        "required": [
          "operator_id",
          "start_date",
          "end_date"
        ],
        "title": "GetOperatorProductivityRequest",
        "type": "object"
      },
      "JobCardDetailResponse": {
        "description": "Job card detail response",
        "properties": {
          "name": {
            "title": "Name",
            "type": "string"
          },
          "work_order": {
            "title": "Work Order",
            "type": "string"
          },
          "operation": {
            "title": "Operation",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/JobCardStatus"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Workstation"
          },
          "workstation_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Workstation Name"
          },
          "employee": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Employee"
          },
          "employee_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Employee Name"
          },
          "for_quantity": {
            "title": "For Quantity",
            "type": "number"
          },
          "transferred_qty": {
            "default": 0,
            "title": "Transferred Qty",
            "type": "number"
          },
          "total_completed_qty": {
            "default": 0,
            "title": "Total Completed Qty",
            "type": "number"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Started At"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Completed At"
          },
          "total_time_in_mins": {
            "default": 0,
            "title": "Total Time In Mins",
            "type": "number"
          },
          "items": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Items",
            "type": "array"
          }
        },
        "required": [
          "name",
          "work_order",
          "operation",
          "status",
          "for_quantity"
        ],
        "title": "JobCardDetailResponse",
        "type": "object"
      },
      "JobCardStatus": {
        "type": "string",
        "enum": [
          "Open",
          "Work In Progress",
          "Material Transferred",
          "Completed",
          "On Hold"
        ]
      },
      "JobCardSummary": {
        "description": "Job card summary for work order context",
        "properties": {
          "name": {
            "description": "Job card ID",
            "title": "Name",
            "type": "string"
          },
          "operation": {
            "description": "Operation name",
            "title": "Operation",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/JobCardStatus"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Workstation"
          },
          "operator": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Operator"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Started At"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Completed At"
          },
          "total_time_in_mins": {
            "default": 0,
            "title": "Total Time In Mins",
            "type": "number"
          }
        },
        "required": [
          "name",
          "operation",
          "status"
        ],
        "title": "JobCardSummary",
        "type": "object"
      },
      "MaterialAvailabilityItem": {
        "description": "Material availability for single item",
        "properties": {
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "required_qty": {
            "title": "Required Qty",
            "type": "number"
          },
          "available_qty": {
            "title": "Available Qty",
            "type": "number"
          },
          "reserved_qty": {
            "title": "Reserved Qty",
            "type": "number"
          },
          "actual_available_qty": {
            "title": "Actual Available Qty",
            "type": "number"
          },
          "can_fulfill": {
            "title": "Can Fulfill",
            "type": "boolean"
          },
          "shortage_qty": {
            "title": "Shortage Qty",
            "type": "number"
          },
          "status": {
            "$ref": "#/components/schemas/MaterialAvailabilityStatus"
          }
        },
        "required": [
          "item_code",
          "item_name",
          "required_qty",
          "available_qty",
          "reserved_qty",
          "actual_available_qty",
          "can_fulfill",
          "shortage_qty",
          "status"
        ],
        "title": "MaterialAvailabilityItem",
        "type": "object"
      },
      "MaterialAvailabilityStatus": {
        "type": "string",
        "enum": [
          "available",
          "partial",
          "unavailable"
        ]
      },
      "MaterialAvailabilityResponse": {
        "description": "Response for material availability check",
        "properties": {
          "work_order_id": {
            "title": "Work Order Id",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/MaterialAvailabilityStatus",
            "description": "Overall availability status"
          },
          "can_start": {
            "description": "Whether work order can start",
            "title": "Can Start",
            "type": "boolean"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/MaterialAvailabilityItem"
            },
            "title": "Items",
            "type": "array"
          },
          "total_shortage_value": {
            "default": 0,
            "title": "Total Shortage Value",
            "type": "number"
          }
        },
        "required": [
          "work_order_id",
          "status",
          "can_start",
          "items"
        ],
        "title": "MaterialAvailabilityResponse",
        "type": "object"
      },
      "MaterialConsumptionItem": {
        "description": "Single material consumption entry",
        "properties": {
          "item_code": {
            "description": "Material item code",
            "title": "Item Code",
            "type": "string"
          },
          "qty": {
            "description": "Quantity consumed",
            "exclusiveMinimum": 0,
            "title": "Qty",
            "type": "number"
          },
          "batch_no": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Batch number",
            "title": "Batch No"
          },
          "warehouse": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Source warehouse",
            "title": "Warehouse"
          }
        },
        "required": [
          "item_code",
          "qty"
        ],
        "title": "MaterialConsumptionItem",
        "type": "object"
      },
      "MaterialConsumptionResponse": {
        "description": "Response for material consumption query",
        "properties": {
          "work_order_id": {
            "title": "Work Order Id",
            "type": "string"
          },
          "total_consumed_value": {
            "title": "Total Consumed Value",
            "type": "number"
          },
          "items": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Items",
            "type": "array"
          },
          "by_job_card": {
            "additionalProperties": {
              "items": {
                "additionalProperties": true,
                "type": "object"
              },
              "type": "array"
            },
            "default": {},
            "title": "By Job Card",
            "type": "object"
          }
        },
        "required": [
          "work_order_id",
          "total_consumed_value"
        ],
        "title": "MaterialConsumptionResponse",
        "type": "object"
      },
      "OperatorProductivityResponse": {
        "description": "Response for operator productivity",
        "properties": {
          "operator_id": {
            "title": "Operator Id",
            "type": "string"
          },
          "operator_name": {
            "title": "Operator Name",
            "type": "string"
          },
          "period_start": {
            "title": "Period Start",
            "type": "string"
          },
          "period_end": {
            "title": "Period End",
            "type": "string"
          },
          "total_job_cards": {
            "title": "Total Job Cards",
            "type": "integer"
          },
          "completed_job_cards": {
            "title": "Completed Job Cards",
            "type": "integer"
          },
          "total_hours": {
            "title": "Total Hours",
            "type": "number"
          },
          "productive_hours": {
            "title": "Productive Hours",
            "type": "number"
          },
          "efficiency_percentage": {
            "title": "Efficiency Percentage",
            "type": "number"
          },
          "by_operation": {
            "additionalProperties": {
              "additionalProperties": true,
              "type": "object"
            },
            "default": {},
            "title": "By Operation",
            "type": "object"
          },
          "daily_breakdown": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Daily Breakdown",
            "type": "array"
          }
        },
        "required": [
          "operator_id",
          "operator_name",
          "period_start",
          "period_end",
          "total_job_cards",
          "completed_job_cards",
          "total_hours",
          "productive_hours",
          "efficiency_percentage"
        ],
        "title": "OperatorProductivityResponse",
        "type": "object"
      },
      "PauseJobCardRequest": {
        "description": "Request for pausing a job card",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Pause reason",
            "title": "Reason"
          }
        },
        "required": [
          "job_card_id"
        ],
        "title": "PauseJobCardRequest",
        "type": "object"
      },
      "QCCheckpointResultResponse": {
        "description": "Response for QC checkpoint result",
        "properties": {
          "checkpoint_id": {
            "title": "Checkpoint Id",
            "type": "string"
          },
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "result": {
            "$ref": "#/components/schemas/QCCheckpointStatus"
          },
          "reading": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Reading"
          },
          "inspector": {
            "title": "Inspector",
            "type": "string"
          },
          "inspection_time": {
            "title": "Inspection Time",
            "type": "string"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Notes"
          }
        },
        "required": [
          "checkpoint_id",
          "job_card_id",
          "result",
          "inspector",
          "inspection_time"
        ],
        "title": "QCCheckpointResultResponse",
        "type": "object"
      },
      "QCCheckpointStatus": {
        "description": "QC checkpoint status",
        "enum": [
          "Pending",
          "Pass",
          "Fail",
          "Rework",
          "Not Required"
        ],
        "title": "QCCheckpointStatus",
        "type": "string"
      },
      "ReassignJobCardRequest": {
        "description": "Request for reassigning job card",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "new_workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "New workstation",
            "title": "New Workstation"
          },
          "new_operator": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "New operator",
            "title": "New Operator"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Reassignment reason",
            "title": "Reason"
          }
        },
        "required": [
          "job_card_id"
        ],
        "title": "ReassignJobCardRequest",
        "type": "object"
      },
      "RecordMaterialConsumptionRequest": {
        "description": "Request for recording material consumption",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "items": {
            "description": "JSON array of consumed items",
            "title": "Items",
            "type": "string"
          }
        },
        "required": [
          "job_card_id",
          "items"
        ],
        "title": "RecordMaterialConsumptionRequest",
        "type": "object"
      },
      "RecordQCResultRequest": {
        "description": "Request for recording QC result",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "checkpoint_id": {
            "description": "QC checkpoint ID",
            "title": "Checkpoint Id",
            "type": "string"
          },
          "result": {
            "$ref": "#/components/schemas/QCCheckpointStatus",
            "description": "QC result"
          },
          "reading": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Measurement reading",
            "title": "Reading"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Inspector notes",
            "title": "Notes"
          }
        },
        "required": [
          "job_card_id",
          "checkpoint_id",
          "result"
        ],
        "title": "RecordQCResultRequest",
        "type": "object"
      },
      "RecordScrapRequest": {
        "description": "Request for recording scrap",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "item_code": {
            "description": "Scrap item code",
            "title": "Item Code",
            "type": "string"
          },
          "scrap_qty": {
            "description": "Scrap quantity",
            "exclusiveMinimum": 0,
            "title": "Scrap Qty",
            "type": "number"
          },
          "reason": {
            "description": "Scrap reason",
            "minLength": 1,
            "title": "Reason",
            "type": "string"
          },
          "warehouse": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Scrap warehouse",
            "title": "Warehouse"
          }
        },
        "required": [
          "job_card_id",
          "item_code",
          "scrap_qty",
          "reason"
        ],
        "title": "RecordScrapRequest",
        "type": "object"
      },
      "ReorderJobCardsRequest": {
        "description": "Request for reordering job cards",
        "properties": {
          "work_order_id": {
            "description": "Work order ID",
            "title": "Work Order Id",
            "type": "string"
          },
          "new_order": {
            "description": "JSON array of job card IDs in new order",
            "title": "New Order",
            "type": "string"
          }
        },
        "required": [
          "work_order_id",
          "new_order"
        ],
        "title": "ReorderJobCardsRequest",
        "type": "object"
      },
      "ReorderWorkOrderOperationsRequest": {
        "description": "Request for reordering operations",
        "properties": {
          "work_order_id": {
            "description": "Work order ID",
            "title": "Work Order Id",
            "type": "string"
          },
          "operations": {
            "description": "JSON array of operation IDs in new order",
            "title": "Operations",
            "type": "string"
          }
        },
        "required": [
          "work_order_id",
          "operations"
        ],
        "title": "ReorderWorkOrderOperationsRequest",
        "type": "object"
      },
      "ResolveTimeEntryConflictRequest": {
        "description": "Request for resolving time entry conflicts",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "conflicting_entry_id": {
            "description": "Conflicting time entry ID",
            "title": "Conflicting Entry Id",
            "type": "string"
          },
          "resolution": {
            "$ref": "#/components/schemas/TimeEntryConflictResolution",
            "description": "Resolution strategy"
          },
          "adjusted_times": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Adjusted times if using adjust_times strategy",
            "title": "Adjusted Times"
          }
        },
        "required": [
          "job_card_id",
          "conflicting_entry_id",
          "resolution"
        ],
        "title": "ResolveTimeEntryConflictRequest",
        "type": "object"
      },
      "TimeEntryConflictResolution": {
        "description": "Resolution strategy for time entry conflicts",
        "enum": [
          "keep_existing",
          "replace",
          "adjust_times"
        ],
        "title": "TimeEntryConflictResolution",
        "type": "string"
      },
      "ResumeJobCardRequest": {
        "description": "Request for resuming a job card",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          }
        },
        "required": [
          "job_card_id"
        ],
        "title": "ResumeJobCardRequest",
        "type": "object"
      },
      "ReviewMaterialOverrideRequest": {
        "description": "Request for reviewing material override",
        "properties": {
          "override_request_id": {
            "description": "Override request ID",
            "title": "Override Request Id",
            "type": "string"
          },
          "approved": {
            "description": "Approve or reject",
            "title": "Approved",
            "type": "boolean"
          },
          "review_notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Review notes",
            "title": "Review Notes"
          }
        },
        "required": [
          "override_request_id",
          "approved"
        ],
        "title": "ReviewMaterialOverrideRequest",
        "type": "object"
      },
      "SaveBOMTemplateRequest": {
        "description": "Request for creating/updating BOM template",
        "properties": {
          "item_code": {
            "description": "Product item code",
            "title": "Item Code",
            "type": "string"
          },
          "operations": {
            "description": "Operations list",
            "items": {
              "$ref": "#/components/schemas/OperationSchema"
            },
            "minItems": 1,
            "title": "Operations",
            "type": "array"
          },
          "materials": {
            "description": "Materials list",
            "items": {
              "$ref": "#/components/schemas/MaterialSchema"
            },
            "title": "Materials",
            "type": "array"
          },
          "qc_checkpoints": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/QCCheckpointSchema"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "QC checkpoints",
            "title": "Qc Checkpoints"
          },
          "with_operations": {
            "default": true,
            "description": "Include operations in BOM",
            "title": "With Operations",
            "type": "boolean"
          }
        },
        "required": [
          "item_code",
          "operations"
        ],
        "title": "SaveBOMTemplateRequest",
        "type": "object"
      },
      "StartJobCardRequest": {
        "description": "Request for starting a job card",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          }
        },
        "required": [
          "job_card_id"
        ],
        "title": "StartJobCardRequest",
        "type": "object"
      },
      "TimeEntryConflict": {
        "description": "Time entry conflict information",
        "properties": {
          "conflicting_entry_id": {
            "title": "Conflicting Entry Id",
            "type": "string"
          },
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "overlap_start": {
            "title": "Overlap Start",
            "type": "string"
          },
          "overlap_end": {
            "title": "Overlap End",
            "type": "string"
          },
          "overlap_mins": {
            "title": "Overlap Mins",
            "type": "number"
          }
        },
        "required": [
          "conflicting_entry_id",
          "job_card_id",
          "overlap_start",
          "overlap_end",
          "overlap_mins"
        ],
        "title": "TimeEntryConflict",
        "type": "object"
      },
      "TimeEntryConflictResponse": {
        "description": "Response when time entry conflicts detected",
        "properties": {
          "success": {
            "default": false,
            "title": "Success",
            "type": "boolean"
          },
          "has_conflicts": {
            "default": true,
            "title": "Has Conflicts",
            "type": "boolean"
          },
          "conflicts": {
            "items": {
              "$ref": "#/components/schemas/TimeEntryConflict"
            },
            "title": "Conflicts",
            "type": "array"
          },
          "resolution_options": {
            "items": {
              "type": "string"
            },
            "title": "Resolution Options",
            "type": "array"
          },
          "message": {
            "default": "Time entry conflicts detected",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "conflicts",
          "resolution_options"
        ],
        "title": "TimeEntryConflictResponse",
        "type": "object"
      },
      "TimeEntryResponse": {
        "description": "Response for time entry operations",
        "properties": {
          "time_entry_id": {
            "title": "Time Entry Id",
            "type": "string"
          },
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "start_time": {
            "title": "Start Time",
            "type": "string"
          },
          "end_time": {
            "title": "End Time",
            "type": "string"
          },
          "duration_mins": {
            "title": "Duration Mins",
            "type": "number"
          },
          "employee": {
            "title": "Employee",
            "type": "string"
          },
          "created": {
            "default": true,
            "title": "Created",
            "type": "boolean"
          }
        },
        "required": [
          "time_entry_id",
          "job_card_id",
          "start_time",
          "end_time",
          "duration_mins",
          "employee"
        ],
        "title": "TimeEntryResponse",
        "type": "object"
      },
      "UpdateWorkOrderStatusRequest": {
        "description": "Request for updating work order status",
        "properties": {
          "work_order_id": {
            "description": "Work order ID",
            "title": "Work Order Id",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/WorkOrderStatus",
            "description": "New status"
          }
        },
        "required": [
          "work_order_id",
          "status"
        ],
        "title": "UpdateWorkOrderStatusRequest",
        "type": "object"
      },
      "WorkOrderDetailResponse": {
        "description": "Work order detail response",
        "properties": {
          "name": {
            "description": "Work order ID",
            "title": "Name",
            "type": "string"
          },
          "production_item": {
            "title": "Production Item",
            "type": "string"
          },
          "qty": {
            "title": "Qty",
            "type": "number"
          },
          "status": {
            "$ref": "#/components/schemas/WorkOrderStatus"
          },
          "customer": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Customer"
          },
          "customer_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Customer Name"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "planned_start_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Planned Start Date"
          },
          "planned_end_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Planned End Date"
          },
          "actual_start_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Actual Start Date"
          },
          "actual_end_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Actual End Date"
          },
          "produced_qty": {
            "default": 0,
            "title": "Produced Qty",
            "type": "number"
          },
          "process_loss_qty": {
            "default": 0,
            "title": "Process Loss Qty",
            "type": "number"
          },
          "sales_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Sales Order"
          },
          "quotation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Quotation"
          },
          "bom_no": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Bom No"
          },
          "job_cards": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/JobCardSummary"
            },
            "title": "Job Cards",
            "type": "array"
          }
        },
        "required": [
          "name",
          "production_item",
          "qty",
          "status"
        ],
        "title": "WorkOrderDetailResponse",
        "type": "object"
      },
      "AllocateMaterialToJobRequest": {
        "description": "Request for allocating material to job",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "item_code": {
            "description": "Material item code",
            "title": "Item Code",
            "type": "string"
          },
          "batch_no": {
            "description": "Batch number",
            "title": "Batch No",
            "type": "string"
          },
          "qty": {
            "description": "Quantity to allocate",
            "exclusiveMinimum": 0,
            "title": "Qty",
            "type": "number"
          },
          "warehouse": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Source warehouse",
            "title": "Warehouse"
          }
        },
        "required": [
          "job_card_id",
          "item_code",
          "batch_no",
          "qty"
        ],
        "title": "AllocateMaterialToJobRequest",
        "type": "object"
      },
      "BatchInfoResponse": {
        "description": "Response for batch information",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "batch_no": {
            "title": "Batch No",
            "type": "string"
          },
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "initial_qty": {
            "title": "Initial Qty",
            "type": "number"
          },
          "available_qty": {
            "title": "Available Qty",
            "type": "number"
          },
          "reserved_qty": {
            "title": "Reserved Qty",
            "type": "number"
          },
          "consumed_qty": {
            "title": "Consumed Qty",
            "type": "number"
          },
          "warehouse": {
            "title": "Warehouse",
            "type": "string"
          },
          "warehouse_group": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Warehouse Group"
          },
          "supplier": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Supplier"
          },
          "supplier_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Supplier Name"
          },
          "purchase_receipt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Purchase Receipt"
          },
          "purchase_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Purchase Order"
          },
          "mill_certificate": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Mill Certificate"
          },
          "creation_date": {
            "title": "Creation Date",
            "type": "string"
          },
          "manufacturing_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Manufacturing Date"
          },
          "expiry_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Expiry Date"
          },
          "heat_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Heat Number"
          },
          "lot_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Lot Number"
          }
        },
        "required": [
          "batch_no",
          "item_code",
          "item_name",
          "initial_qty",
          "available_qty",
          "reserved_qty",
          "consumed_qty",
          "warehouse",
          "creation_date"
        ],
        "title": "BatchInfoResponse",
        "type": "object"
      },
      "FlagJobForHelpRequest": {
        "description": "Request for flagging job for help",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "reason": {
            "description": "Help request reason",
            "maxLength": 500,
            "minLength": 1,
            "title": "Reason",
            "type": "string"
          }
        },
        "required": [
          "job_card_id",
          "reason"
        ],
        "title": "FlagJobForHelpRequest",
        "type": "object"
      },
      "GetShopFloorTasksRequest": {
        "description": "Request for listing shop floor tasks",
        "properties": {
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by workstation",
            "title": "Workstation"
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by status",
            "title": "Status"
          }
        },
        "title": "GetShopFloorTasksRequest",
        "type": "object"
      },
      "HelpRequestResponse": {
        "description": "Response for help request",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "help_request_id": {
            "title": "Help Request Id",
            "type": "string"
          },
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/HelpRequestStatus",
            "default": "Open"
          },
          "notified_foremen": {
            "default": [],
            "items": {
              "type": "string"
            },
            "title": "Notified Foremen",
            "type": "array"
          },
          "message": {
            "default": "Help request submitted",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "help_request_id",
          "job_card_id"
        ],
        "title": "HelpRequestResponse",
        "type": "object"
      },
      "HelpRequestStatus": {
        "description": "Help request status",
        "enum": [
          "Open",
          "Acknowledged",
          "Resolved"
        ],
        "title": "HelpRequestStatus",
        "type": "string"
      },
      "MaterialAllocationResponse": {
        "description": "Response for material allocation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "allocation_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Allocation Id"
          },
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "batch_no": {
            "title": "Batch No",
            "type": "string"
          },
          "allocated_qty": {
            "title": "Allocated Qty",
            "type": "number"
          },
          "remaining_available": {
            "title": "Remaining Available",
            "type": "number"
          },
          "message": {
            "default": "Material allocated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "job_card_id",
          "item_code",
          "batch_no",
          "allocated_qty",
          "remaining_available"
        ],
        "title": "MaterialAllocationResponse",
        "type": "object"
      },
      "MaterialOverrideRequestResponse": {
        "description": "Response for material override request",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "override_request_id": {
            "description": "Created override request ID",
            "title": "Override Request Id",
            "type": "string"
          },
          "status": {
            "default": "Pending",
            "title": "Status",
            "type": "string"
          },
          "message": {
            "default": "Override request submitted for foreman approval",
            "title": "Message",
            "type": "string"
          },
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "original_item": {
            "title": "Original Item",
            "type": "string"
          },
          "substitute_item": {
            "title": "Substitute Item",
            "type": "string"
          },
          "substitute_batch": {
            "title": "Substitute Batch",
            "type": "string"
          }
        },
        "required": [
          "override_request_id",
          "job_card_id",
          "original_item",
          "substitute_item",
          "substitute_batch"
        ],
        "title": "MaterialOverrideRequestResponse",
        "type": "object"
      },
      "MaterialReceiptResponse": {
        "description": "Response for material receipt via scan",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "stock_entry_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Stock Entry Id"
          },
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "batch_no": {
            "title": "Batch No",
            "type": "string"
          },
          "qty_received": {
            "title": "Qty Received",
            "type": "number"
          },
          "uom": {
            "title": "Uom",
            "type": "string"
          },
          "fully_allocated": {
            "title": "Fully Allocated",
            "type": "boolean"
          },
          "remaining_required": {
            "title": "Remaining Required",
            "type": "number"
          },
          "message": {
            "default": "Material received successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "job_card_id",
          "item_code",
          "item_name",
          "batch_no",
          "qty_received",
          "uom",
          "fully_allocated",
          "remaining_required"
        ],
        "title": "MaterialReceiptResponse",
        "type": "object"
      },
      "MaterialScanValidationResponse": {
        "description": "Response for material scan validation",
        "properties": {
          "valid": {
            "description": "Whether scan is valid",
            "title": "Valid",
            "type": "boolean"
          },
          "status": {
            "$ref": "#/components/schemas/ScanValidationStatus"
          },
          "message": {
            "title": "Message",
            "type": "string"
          },
          "batch_no": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Batch No"
          },
          "item_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Item Code"
          },
          "item_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Item Name"
          },
          "available_qty": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Available Qty"
          },
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "required_item": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Required Item"
          },
          "required_qty": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Required Qty"
          },
          "mismatch_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Mismatch Reason"
          },
          "can_request_override": {
            "default": false,
            "title": "Can Request Override",
            "type": "boolean"
          }
        },
        "required": [
          "valid",
          "status",
          "message",
          "job_card_id"
        ],
        "title": "MaterialScanValidationResponse",
        "type": "object"
      },
      "ScanValidationStatus": {
        "description": "Material scan validation status",
        "enum": [
          "valid",
          "invalid",
          "wrong_material",
          "insufficient_qty",
          "batch_not_found"
        ],
        "title": "ScanValidationStatus",
        "type": "string"
      },
      "QCChecklistItem": {
        "description": "Single QC checklist item",
        "properties": {
          "item_id": {
            "title": "Item Id",
            "type": "string"
          },
          "description": {
            "title": "Description",
            "type": "string"
          },
          "measurement_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Measurement Type"
          },
          "specification": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Specification"
          },
          "tolerance": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Tolerance"
          },
          "is_mandatory": {
            "default": true,
            "title": "Is Mandatory",
            "type": "boolean"
          }
        },
        "required": [
          "item_id",
          "description"
        ],
        "title": "QCChecklistItem",
        "type": "object"
      },
      "QCCheckpointScanResponse": {
        "description": "Response for QC checkpoint scan",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "checkpoint_id": {
            "title": "Checkpoint Id",
            "type": "string"
          },
          "checkpoint_name": {
            "title": "Checkpoint Name",
            "type": "string"
          },
          "checkpoint_type": {
            "$ref": "#/components/schemas/QCCheckpointType"
          },
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "operation": {
            "title": "Operation",
            "type": "string"
          },
          "specification": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Specification"
          },
          "tolerance": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Tolerance"
          },
          "measurement_unit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Measurement Unit"
          },
          "checklist_items": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Checklist Items",
            "type": "array"
          },
          "current_status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Current Status"
          },
          "previous_result": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Previous Result"
          },
          "attempts": {
            "default": 0,
            "title": "Attempts",
            "type": "integer"
          }
        },
        "required": [
          "checkpoint_id",
          "checkpoint_name",
          "checkpoint_type",
          "job_card_id",
          "operation"
        ],
        "title": "QCCheckpointScanResponse",
        "type": "object"
      },
      "QCCheckpointType": {
        "description": "QC checkpoint types",
        "enum": [
          "measurement",
          "visual",
          "functional"
        ],
        "title": "QCCheckpointType",
        "type": "string"
      },
      "QCCheckpointSubmitResponse": {
        "description": "Response for QC checkpoint submission",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "checkpoint_id": {
            "title": "Checkpoint Id",
            "type": "string"
          },
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "result": {
            "title": "Result",
            "type": "string"
          },
          "inspector": {
            "title": "Inspector",
            "type": "string"
          },
          "inspection_time": {
            "title": "Inspection Time",
            "type": "string"
          },
          "can_proceed": {
            "default": true,
            "title": "Can Proceed",
            "type": "boolean"
          },
          "blocking_reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Blocking Reason"
          },
          "next_checkpoint": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Next Checkpoint"
          },
          "notifications_sent": {
            "default": [],
            "items": {
              "type": "string"
            },
            "title": "Notifications Sent",
            "type": "array"
          },
          "message": {
            "default": "QC checkpoint recorded",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "checkpoint_id",
          "job_card_id",
          "result",
          "inspector",
          "inspection_time"
        ],
        "title": "QCCheckpointSubmitResponse",
        "type": "object"
      },
      "ReceiveMaterialScanRequest": {
        "description": "Request for receiving material via scan",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "qr_data": {
            "description": "Scanned QR code data",
            "title": "Qr Data",
            "type": "string"
          },
          "qty": {
            "anyOf": [
              {
                "exclusiveMinimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Quantity (if not in QR)",
            "title": "Qty"
          }
        },
        "required": [
          "job_card_id",
          "qr_data"
        ],
        "title": "ReceiveMaterialScanRequest",
        "type": "object"
      },
      "RequestMaterialOverrideRequest": {
        "description": "Request for material override",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "original_item_code": {
            "description": "Originally required item",
            "title": "Original Item Code",
            "type": "string"
          },
          "substitute_item_code": {
            "description": "Proposed substitute item",
            "title": "Substitute Item Code",
            "type": "string"
          },
          "substitute_batch_no": {
            "description": "Substitute batch number",
            "title": "Substitute Batch No",
            "type": "string"
          },
          "reason": {
            "description": "Override reason",
            "minLength": 1,
            "title": "Reason",
            "type": "string"
          },
          "qty": {
            "anyOf": [
              {
                "exclusiveMinimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Override quantity",
            "title": "Qty"
          }
        },
        "required": [
          "job_card_id",
          "original_item_code",
          "substitute_item_code",
          "substitute_batch_no",
          "reason"
        ],
        "title": "RequestMaterialOverrideRequest",
        "type": "object"
      },
      "ScanQCCheckpointRequest": {
        "description": "Request for scanning QC checkpoint",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "qr_data": {
            "description": "Scanned QC checkpoint QR code",
            "title": "Qr Data",
            "type": "string"
          }
        },
        "required": [
          "job_card_id",
          "qr_data"
        ],
        "title": "ScanQCCheckpointRequest",
        "type": "object"
      },
      "ShopFloorTask": {
        "description": "Single shop floor task",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "work_order": {
            "title": "Work Order",
            "type": "string"
          },
          "operation": {
            "title": "Operation",
            "type": "string"
          },
          "status": {
            "title": "Status",
            "type": "string"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Workstation"
          },
          "workstation_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Workstation Name"
          },
          "target_qty": {
            "title": "Target Qty",
            "type": "number"
          },
          "completed_qty": {
            "title": "Completed Qty",
            "type": "number"
          },
          "remaining_qty": {
            "title": "Remaining Qty",
            "type": "number"
          },
          "sequence": {
            "default": 0,
            "title": "Sequence",
            "type": "integer"
          },
          "priority": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Priority"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Started At"
          },
          "estimated_completion": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Estimated Completion"
          },
          "materials_ready": {
            "default": false,
            "title": "Materials Ready",
            "type": "boolean"
          },
          "pending_materials": {
            "default": [],
            "items": {
              "type": "string"
            },
            "title": "Pending Materials",
            "type": "array"
          },
          "pending_qc_checkpoints": {
            "default": 0,
            "title": "Pending Qc Checkpoints",
            "type": "integer"
          },
          "failed_qc_checkpoints": {
            "default": 0,
            "title": "Failed Qc Checkpoints",
            "type": "integer"
          },
          "has_help_request": {
            "default": false,
            "title": "Has Help Request",
            "type": "boolean"
          }
        },
        "required": [
          "job_card_id",
          "work_order",
          "operation",
          "status",
          "target_qty",
          "completed_qty",
          "remaining_qty"
        ],
        "title": "ShopFloorTask",
        "type": "object"
      },
      "ShopFloorTasksResponse": {
        "description": "Response for shop floor tasks listing",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "tasks": {
            "items": {
              "$ref": "#/components/schemas/ShopFloorTask"
            },
            "title": "Tasks",
            "type": "array"
          },
          "total": {
            "title": "Total",
            "type": "integer"
          },
          "by_status": {
            "additionalProperties": {
              "type": "integer"
            },
            "default": {},
            "title": "By Status",
            "type": "object"
          },
          "by_workstation": {
            "additionalProperties": {
              "type": "integer"
            },
            "default": {},
            "title": "By Workstation",
            "type": "object"
          }
        },
        "required": [
          "tasks",
          "total"
        ],
        "title": "ShopFloorTasksResponse",
        "type": "object"
      },
      "SubmitQCCheckpointRequest": {
        "description": "Request for submitting QC checkpoint results",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "checkpoint_id": {
            "description": "Checkpoint ID",
            "title": "Checkpoint Id",
            "type": "string"
          },
          "result": {
            "description": "Pass/Fail/Rework",
            "title": "Result",
            "type": "string"
          },
          "checklist": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "JSON checklist items",
            "title": "Checklist"
          },
          "reading": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Measurement reading",
            "title": "Reading"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Inspector notes",
            "title": "Notes"
          },
          "photos": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Photo attachment URLs",
            "title": "Photos"
          }
        },
        "required": [
          "job_card_id",
          "checkpoint_id",
          "result"
        ],
        "title": "SubmitQCCheckpointRequest",
        "type": "object"
      },
      "ValidateMaterialScanRequest": {
        "description": "Request for validating material scan",
        "properties": {
          "job_card_id": {
            "description": "Job card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "batch_no": {
            "description": "Scanned batch number",
            "title": "Batch No",
            "type": "string"
          }
        },
        "required": [
          "job_card_id",
          "batch_no"
        ],
        "title": "ValidateMaterialScanRequest",
        "type": "object"
      },
      "CapacityUtilizationResponse": {
        "description": "Response for capacity utilization report",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "start_date": {
            "title": "Start Date",
            "type": "string"
          },
          "end_date": {
            "title": "End Date",
            "type": "string"
          },
          "overall_utilization": {
            "default": 0,
            "title": "Overall Utilization",
            "type": "number"
          },
          "bottleneck_workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Bottleneck Workstation"
          },
          "underutilized_workstations": {
            "default": [],
            "items": {
              "type": "string"
            },
            "title": "Underutilized Workstations",
            "type": "array"
          },
          "rows": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/CapacityUtilizationRow"
            },
            "title": "Rows",
            "type": "array"
          },
          "heatmap": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Heatmap",
            "type": "array"
          }
        },
        "required": [
          "start_date",
          "end_date"
        ],
        "title": "CapacityUtilizationResponse",
        "type": "object"
      },
      "CapacityUtilizationRow": {
        "description": "Single row in capacity utilization report",
        "properties": {
          "workstation": {
            "title": "Workstation",
            "type": "string"
          },
          "workstation_name": {
            "title": "Workstation Name",
            "type": "string"
          },
          "available_hours": {
            "title": "Available Hours",
            "type": "number"
          },
          "utilized_hours": {
            "title": "Utilized Hours",
            "type": "number"
          },
          "utilization_rate": {
            "title": "Utilization Rate",
            "type": "number"
          },
          "queue_hours": {
            "title": "Queue Hours",
            "type": "number"
          }
        },
        "required": [
          "workstation",
          "workstation_name",
          "available_hours",
          "utilized_hours",
          "utilization_rate",
          "queue_hours"
        ],
        "title": "CapacityUtilizationRow",
        "type": "object"
      },
      "DashboardMetricsResponse": {
        "description": "Response for dashboard metrics",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "period": {
            "title": "Period",
            "type": "string"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "work_orders_completed": {
            "default": 0,
            "title": "Work Orders Completed",
            "type": "integer"
          },
          "work_orders_in_progress": {
            "default": 0,
            "title": "Work Orders In Progress",
            "type": "integer"
          },
          "total_units_produced": {
            "default": 0,
            "title": "Total Units Produced",
            "type": "number"
          },
          "production_value": {
            "default": 0,
            "title": "Production Value",
            "type": "number"
          },
          "qc_pass_rate": {
            "default": 0,
            "title": "Qc Pass Rate",
            "type": "number"
          },
          "defect_rate": {
            "default": 0,
            "title": "Defect Rate",
            "type": "number"
          },
          "rework_count": {
            "default": 0,
            "title": "Rework Count",
            "type": "integer"
          },
          "average_lead_time_days": {
            "default": 0,
            "title": "Average Lead Time Days",
            "type": "number"
          },
          "on_time_delivery_rate": {
            "default": 0,
            "title": "On Time Delivery Rate",
            "type": "number"
          },
          "capacity_utilization": {
            "default": 0,
            "title": "Capacity Utilization",
            "type": "number"
          },
          "quotes_sent": {
            "default": 0,
            "title": "Quotes Sent",
            "type": "integer"
          },
          "quotes_won": {
            "default": 0,
            "title": "Quotes Won",
            "type": "integer"
          },
          "conversion_rate": {
            "default": 0,
            "title": "Conversion Rate",
            "type": "number"
          },
          "total_quoted_value": {
            "default": 0,
            "title": "Total Quoted Value",
            "type": "number"
          },
          "kpis": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/KPIMetric"
            },
            "title": "Kpis",
            "type": "array"
          }
        },
        "required": [
          "period"
        ],
        "title": "DashboardMetricsResponse",
        "type": "object"
      },
      "KPIMetric": {
        "description": "Single KPI metric",
        "properties": {
          "name": {
            "title": "Name",
            "type": "string"
          },
          "value": {
            "title": "Value",
            "type": "number"
          },
          "unit": {
            "title": "Unit",
            "type": "string"
          },
          "trend": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Trend"
          },
          "trend_direction": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Trend Direction"
          },
          "target": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Target"
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Status"
          }
        },
        "required": [
          "name",
          "value",
          "unit"
        ],
        "title": "KPIMetric",
        "type": "object"
      },
      "EfficiencyReportResponse": {
        "description": "Response for efficiency report",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "start_date": {
            "title": "Start Date",
            "type": "string"
          },
          "end_date": {
            "title": "End Date",
            "type": "string"
          },
          "average_efficiency": {
            "default": 0,
            "title": "Average Efficiency",
            "type": "number"
          },
          "total_productive_hours": {
            "default": 0,
            "title": "Total Productive Hours",
            "type": "number"
          },
          "total_available_hours": {
            "default": 0,
            "title": "Total Available Hours",
            "type": "number"
          },
          "rows": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/EfficiencyReportRow"
            },
            "title": "Rows",
            "type": "array"
          },
          "daily_efficiency": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Daily Efficiency",
            "type": "array"
          }
        },
        "required": [
          "start_date",
          "end_date"
        ],
        "title": "EfficiencyReportResponse",
        "type": "object"
      },
      "EfficiencyReportRow": {
        "description": "Single row in efficiency report",
        "properties": {
          "operator": {
            "title": "Operator",
            "type": "string"
          },
          "operator_name": {
            "title": "Operator Name",
            "type": "string"
          },
          "total_hours": {
            "title": "Total Hours",
            "type": "number"
          },
          "productive_hours": {
            "title": "Productive Hours",
            "type": "number"
          },
          "efficiency": {
            "title": "Efficiency",
            "type": "number"
          },
          "job_cards_completed": {
            "title": "Job Cards Completed",
            "type": "integer"
          }
        },
        "required": [
          "operator",
          "operator_name",
          "total_hours",
          "productive_hours",
          "efficiency",
          "job_cards_completed"
        ],
        "title": "EfficiencyReportRow",
        "type": "object"
      },
      "ExportReportRequest": {
        "description": "Request for exporting report",
        "properties": {
          "report_type": {
            "description": "Report type: production, quality, efficiency",
            "title": "Report Type",
            "type": "string"
          },
          "format": {
            "default": "xlsx",
            "description": "Export format: xlsx, csv, pdf",
            "title": "Format",
            "type": "string"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "start_date": {
            "description": "Report start date",
            "title": "Start Date",
            "type": "string"
          },
          "end_date": {
            "description": "Report end date",
            "title": "End Date",
            "type": "string"
          },
          "filters": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Additional filters",
            "title": "Filters"
          }
        },
        "required": [
          "report_type",
          "start_date",
          "end_date"
        ],
        "title": "ExportReportRequest",
        "type": "object"
      },
      "ExportReportResponse": {
        "description": "Response for report export",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "file_url": {
            "description": "URL to download exported file",
            "title": "File Url",
            "type": "string"
          },
          "file_name": {
            "title": "File Name",
            "type": "string"
          },
          "format": {
            "title": "Format",
            "type": "string"
          },
          "expires_at": {
            "description": "URL expiration time",
            "title": "Expires At",
            "type": "string"
          },
          "message": {
            "default": "Report exported successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "file_url",
          "file_name",
          "format",
          "expires_at"
        ],
        "title": "ExportReportResponse",
        "type": "object"
      },
      "GetCapacityUtilizationRequest": {
        "description": "Request for capacity utilization report",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "start_date": {
            "description": "Report start date",
            "title": "Start Date",
            "type": "string"
          },
          "end_date": {
            "description": "Report end date",
            "title": "End Date",
            "type": "string"
          }
        },
        "required": [
          "start_date",
          "end_date"
        ],
        "title": "GetCapacityUtilizationRequest",
        "type": "object"
      },
      "GetDashboardMetricsRequest": {
        "description": "Request for dashboard metrics",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "period": {
            "$ref": "#/components/schemas/ReportPeriod",
            "default": "this_month",
            "description": "Report period"
          },
          "start_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Custom period start (YYYY-MM-DD)",
            "title": "Start Date"
          },
          "end_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Custom period end (YYYY-MM-DD)",
            "title": "End Date"
          }
        },
        "title": "GetDashboardMetricsRequest",
        "type": "object"
      },
      "ReportPeriod": {
        "description": "Report time period",
        "enum": [
          "today",
          "this_week",
          "this_month",
          "this_quarter",
          "this_year",
          "custom"
        ],
        "title": "ReportPeriod",
        "type": "string"
      },
      "GetEfficiencyReportRequest": {
        "description": "Request for efficiency report",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "start_date": {
            "description": "Report start date",
            "title": "Start Date",
            "type": "string"
          },
          "end_date": {
            "description": "Report end date",
            "title": "End Date",
            "type": "string"
          },
          "operator": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by operator",
            "title": "Operator"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by workstation",
            "title": "Workstation"
          }
        },
        "required": [
          "start_date",
          "end_date"
        ],
        "title": "GetEfficiencyReportRequest",
        "type": "object"
      },
      "GetProductionReportRequest": {
        "description": "Request for production report",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "start_date": {
            "description": "Report start date",
            "title": "Start Date",
            "type": "string"
          },
          "end_date": {
            "description": "Report end date",
            "title": "End Date",
            "type": "string"
          },
          "group_by": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "day",
            "description": "Group by: day, week, month",
            "title": "Group By"
          }
        },
        "required": [
          "start_date",
          "end_date"
        ],
        "title": "GetProductionReportRequest",
        "type": "object"
      },
      "GetQualityReportRequest": {
        "description": "Request for quality report",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "start_date": {
            "description": "Report start date",
            "title": "Start Date",
            "type": "string"
          },
          "end_date": {
            "description": "Report end date",
            "title": "End Date",
            "type": "string"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by workstation",
            "title": "Workstation"
          },
          "operation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by operation type",
            "title": "Operation"
          }
        },
        "required": [
          "start_date",
          "end_date"
        ],
        "title": "GetQualityReportRequest",
        "type": "object"
      },
      "ProductionReportResponse": {
        "description": "Response for production report",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "start_date": {
            "title": "Start Date",
            "type": "string"
          },
          "end_date": {
            "title": "End Date",
            "type": "string"
          },
          "total_work_orders": {
            "default": 0,
            "title": "Total Work Orders",
            "type": "integer"
          },
          "total_units": {
            "default": 0,
            "title": "Total Units",
            "type": "number"
          },
          "total_value": {
            "default": 0,
            "title": "Total Value",
            "type": "number"
          },
          "total_scrap_value": {
            "default": 0,
            "title": "Total Scrap Value",
            "type": "number"
          },
          "rows": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/ProductionReportRow"
            },
            "title": "Rows",
            "type": "array"
          },
          "by_product": {
            "additionalProperties": {
              "additionalProperties": true,
              "type": "object"
            },
            "default": {},
            "title": "By Product",
            "type": "object"
          },
          "by_workstation": {
            "additionalProperties": {
              "additionalProperties": true,
              "type": "object"
            },
            "default": {},
            "title": "By Workstation",
            "type": "object"
          }
        },
        "required": [
          "start_date",
          "end_date"
        ],
        "title": "ProductionReportResponse",
        "type": "object"
      },
      "ProductionReportRow": {
        "description": "Single row in production report",
        "properties": {
          "date": {
            "title": "Date",
            "type": "string"
          },
          "work_orders_completed": {
            "title": "Work Orders Completed",
            "type": "integer"
          },
          "units_produced": {
            "title": "Units Produced",
            "type": "number"
          },
          "production_value": {
            "title": "Production Value",
            "type": "number"
          },
          "scrap_qty": {
            "title": "Scrap Qty",
            "type": "number"
          },
          "scrap_value": {
            "title": "Scrap Value",
            "type": "number"
          }
        },
        "required": [
          "date",
          "work_orders_completed",
          "units_produced",
          "production_value",
          "scrap_qty",
          "scrap_value"
        ],
        "title": "ProductionReportRow",
        "type": "object"
      },
      "QualityReportResponse": {
        "description": "Response for quality report",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "start_date": {
            "title": "Start Date",
            "type": "string"
          },
          "end_date": {
            "title": "End Date",
            "type": "string"
          },
          "total_checkpoints": {
            "default": 0,
            "title": "Total Checkpoints",
            "type": "integer"
          },
          "overall_pass_rate": {
            "default": 0,
            "title": "Overall Pass Rate",
            "type": "number"
          },
          "top_failure_reasons": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Top Failure Reasons",
            "type": "array"
          },
          "rows": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/QualityReportRow"
            },
            "title": "Rows",
            "type": "array"
          },
          "by_operation": {
            "additionalProperties": {
              "additionalProperties": true,
              "type": "object"
            },
            "default": {},
            "title": "By Operation",
            "type": "object"
          },
          "by_inspector": {
            "additionalProperties": {
              "additionalProperties": true,
              "type": "object"
            },
            "default": {},
            "title": "By Inspector",
            "type": "object"
          }
        },
        "required": [
          "start_date",
          "end_date"
        ],
        "title": "QualityReportResponse",
        "type": "object"
      },
      "QualityReportRow": {
        "description": "Single row in quality report",
        "properties": {
          "date": {
            "title": "Date",
            "type": "string"
          },
          "total_checkpoints": {
            "title": "Total Checkpoints",
            "type": "integer"
          },
          "passed": {
            "title": "Passed",
            "type": "integer"
          },
          "failed": {
            "title": "Failed",
            "type": "integer"
          },
          "rework": {
            "title": "Rework",
            "type": "integer"
          },
          "pass_rate": {
            "title": "Pass Rate",
            "type": "number"
          }
        },
        "required": [
          "date",
          "total_checkpoints",
          "passed",
          "failed",
          "rework",
          "pass_rate"
        ],
        "title": "QualityReportRow",
        "type": "object"
      },
      "AdjustStockRequest": {
        "description": "Request for stock adjustment",
        "properties": {
          "item_code": {
            "description": "Item code",
            "title": "Item Code",
            "type": "string"
          },
          "warehouse": {
            "description": "Warehouse",
            "title": "Warehouse",
            "type": "string"
          },
          "qty_change": {
            "description": "Quantity change (positive or negative)",
            "title": "Qty Change",
            "type": "number"
          },
          "batch_no": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Batch number",
            "title": "Batch No"
          },
          "reason": {
            "description": "Adjustment reason",
            "title": "Reason",
            "type": "string"
          }
        },
        "required": [
          "item_code",
          "warehouse",
          "qty_change",
          "reason"
        ],
        "title": "AdjustStockRequest",
        "type": "object"
      },
      "BatchTraceabilityResponse": {
        "description": "Response for batch traceability",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "batch_no": {
            "title": "Batch No",
            "type": "string"
          },
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "source": {
            "additionalProperties": true,
            "default": {},
            "title": "Source",
            "type": "object"
          },
          "parent_batches": {
            "default": [],
            "items": {
              "type": "string"
            },
            "title": "Parent Batches",
            "type": "array"
          },
          "vendors": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Vendors",
            "type": "array"
          },
          "purchase_documents": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Purchase Documents",
            "type": "array"
          },
          "mill_certificates": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Mill Certificates",
            "type": "array"
          },
          "work_orders": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Work Orders",
            "type": "array"
          },
          "job_cards": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Job Cards",
            "type": "array"
          },
          "child_batches": {
            "default": [],
            "items": {
              "type": "string"
            },
            "title": "Child Batches",
            "type": "array"
          },
          "finished_goods": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Finished Goods",
            "type": "array"
          },
          "genealogy": {
            "additionalProperties": true,
            "default": {},
            "title": "Genealogy",
            "type": "object"
          }
        },
        "required": [
          "batch_no",
          "item_code"
        ],
        "title": "BatchTraceabilityResponse",
        "type": "object"
      },
      "CancelReservationRequest": {
        "description": "Request for canceling reservation",
        "properties": {
          "reservation_id": {
            "description": "Reservation ID to cancel",
            "title": "Reservation Id",
            "type": "string"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Cancellation reason",
            "title": "Reason"
          }
        },
        "required": [
          "reservation_id"
        ],
        "title": "CancelReservationRequest",
        "type": "object"
      },
      "CreateMaterialReservationRequest": {
        "description": "Request for creating material reservation",
        "properties": {
          "item_code": {
            "description": "Item to reserve",
            "title": "Item Code",
            "type": "string"
          },
          "qty": {
            "description": "Quantity to reserve",
            "exclusiveMinimum": 0,
            "title": "Qty",
            "type": "number"
          },
          "warehouse": {
            "description": "Source warehouse",
            "title": "Warehouse",
            "type": "string"
          },
          "work_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Related work order",
            "title": "Work Order"
          },
          "job_card": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Related job card",
            "title": "Job Card"
          },
          "batch_no": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Specific batch to reserve",
            "title": "Batch No"
          },
          "expiry_hours": {
            "default": 24,
            "description": "Reservation expiry in hours",
            "maximum": 168,
            "minimum": 1,
            "title": "Expiry Hours",
            "type": "integer"
          }
        },
        "required": [
          "item_code",
          "qty",
          "warehouse"
        ],
        "title": "CreateMaterialReservationRequest",
        "type": "object"
      },
      "CreateTransferRequestRequest": {
        "description": "Request for inter-location transfer",
        "properties": {
          "from_location": {
            "description": "Source warehouse group",
            "title": "From Location",
            "type": "string"
          },
          "to_location": {
            "description": "Destination warehouse group",
            "title": "To Location",
            "type": "string"
          },
          "items": {
            "description": "JSON array of items to transfer",
            "title": "Items",
            "type": "string"
          },
          "reason": {
            "description": "Transfer reason",
            "title": "Reason",
            "type": "string"
          },
          "priority": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "Normal",
            "description": "Priority: Normal, Urgent",
            "title": "Priority"
          }
        },
        "required": [
          "from_location",
          "to_location",
          "items",
          "reason"
        ],
        "title": "CreateTransferRequestRequest",
        "type": "object"
      },
      "GetBatchInfoRequest": {
        "description": "Request for batch information",
        "properties": {
          "batch_no": {
            "description": "Batch number",
            "title": "Batch No",
            "type": "string"
          }
        },
        "required": [
          "batch_no"
        ],
        "title": "GetBatchInfoRequest",
        "type": "object"
      },
      "GetBatchTraceabilityRequest": {
        "description": "Request for batch traceability",
        "properties": {
          "batch_no": {
            "description": "Batch number",
            "title": "Batch No",
            "type": "string"
          },
          "include_downstream": {
            "default": true,
            "description": "Include downstream usage",
            "title": "Include Downstream",
            "type": "boolean"
          }
        },
        "required": [
          "batch_no"
        ],
        "title": "GetBatchTraceabilityRequest",
        "type": "object"
      },
      "GetItemMovementRequest": {
        "description": "Request for item movement history",
        "properties": {
          "item_code": {
            "description": "Item code",
            "title": "Item Code",
            "type": "string"
          },
          "warehouse": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by warehouse",
            "title": "Warehouse"
          },
          "start_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Start date (YYYY-MM-DD)",
            "title": "Start Date"
          },
          "end_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "End date (YYYY-MM-DD)",
            "title": "End Date"
          },
          "limit": {
            "default": 50,
            "description": "Maximum records",
            "maximum": 500,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          }
        },
        "required": [
          "item_code"
        ],
        "title": "GetItemMovementRequest",
        "type": "object"
      },
      "GetLowStockItemsRequest": {
        "description": "Request for low stock items",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "threshold_percent": {
            "default": 20,
            "description": "Percentage of reorder level",
            "maximum": 100,
            "minimum": 0,
            "title": "Threshold Percent",
            "type": "number"
          }
        },
        "title": "GetLowStockItemsRequest",
        "type": "object"
      },
      "GetStockBalanceRequest": {
        "description": "Request for stock balance",
        "properties": {
          "item_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by item code",
            "title": "Item Code"
          },
          "warehouse": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by warehouse",
            "title": "Warehouse"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by warehouse group",
            "title": "Location"
          },
          "include_reserved": {
            "default": true,
            "description": "Include reserved quantities",
            "title": "Include Reserved",
            "type": "boolean"
          }
        },
        "title": "GetStockBalanceRequest",
        "type": "object"
      },
      "InventorySummaryResponse": {
        "description": "Response for inventory summary",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "total_stock_value": {
            "default": 0,
            "title": "Total Stock Value",
            "type": "number"
          },
          "total_items": {
            "default": 0,
            "title": "Total Items",
            "type": "integer"
          },
          "low_stock_count": {
            "default": 0,
            "title": "Low Stock Count",
            "type": "integer"
          },
          "warehouses": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/WarehouseSummary"
            },
            "title": "Warehouses",
            "type": "array"
          },
          "top_items_by_value": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Top Items By Value",
            "type": "array"
          },
          "aging_summary": {
            "additionalProperties": {
              "type": "number"
            },
            "default": {},
            "title": "Aging Summary",
            "type": "object"
          }
        },
        "title": "InventorySummaryResponse",
        "type": "object"
      },
      "WarehouseSummary": {
        "description": "Warehouse summary",
        "properties": {
          "warehouse": {
            "title": "Warehouse",
            "type": "string"
          },
          "warehouse_name": {
            "title": "Warehouse Name",
            "type": "string"
          },
          "warehouse_group": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Warehouse Group"
          },
          "total_items": {
            "title": "Total Items",
            "type": "integer"
          },
          "total_stock_value": {
            "title": "Total Stock Value",
            "type": "number"
          },
          "low_stock_items": {
            "title": "Low Stock Items",
            "type": "integer"
          }
        },
        "required": [
          "warehouse",
          "warehouse_name",
          "total_items",
          "total_stock_value",
          "low_stock_items"
        ],
        "title": "WarehouseSummary",
        "type": "object"
      },
      "ItemMovement": {
        "description": "Single item movement record",
        "properties": {
          "date": {
            "title": "Date",
            "type": "string"
          },
          "voucher_type": {
            "title": "Voucher Type",
            "type": "string"
          },
          "voucher_no": {
            "title": "Voucher No",
            "type": "string"
          },
          "qty_change": {
            "title": "Qty Change",
            "type": "number"
          },
          "balance_qty": {
            "title": "Balance Qty",
            "type": "number"
          },
          "warehouse": {
            "title": "Warehouse",
            "type": "string"
          },
          "batch_no": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Batch No"
          },
          "remarks": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Remarks"
          }
        },
        "required": [
          "date",
          "voucher_type",
          "voucher_no",
          "qty_change",
          "balance_qty",
          "warehouse"
        ],
        "title": "ItemMovement",
        "type": "object"
      },
      "ItemMovementResponse": {
        "description": "Response for item movement history",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "movements": {
            "items": {
              "$ref": "#/components/schemas/ItemMovement"
            },
            "title": "Movements",
            "type": "array"
          },
          "total_in": {
            "default": 0,
            "title": "Total In",
            "type": "number"
          },
          "total_out": {
            "default": 0,
            "title": "Total Out",
            "type": "number"
          },
          "current_balance": {
            "default": 0,
            "title": "Current Balance",
            "type": "number"
          }
        },
        "required": [
          "item_code",
          "item_name",
          "movements"
        ],
        "title": "ItemMovementResponse",
        "type": "object"
      },
      "LowStockItem": {
        "description": "Single low stock item",
        "properties": {
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "warehouse": {
            "title": "Warehouse",
            "type": "string"
          },
          "current_qty": {
            "title": "Current Qty",
            "type": "number"
          },
          "reorder_level": {
            "title": "Reorder Level",
            "type": "number"
          },
          "reorder_qty": {
            "title": "Reorder Qty",
            "type": "number"
          },
          "shortage_qty": {
            "title": "Shortage Qty",
            "type": "number"
          },
          "last_purchase_rate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Last Purchase Rate"
          },
          "estimated_reorder_value": {
            "default": 0,
            "title": "Estimated Reorder Value",
            "type": "number"
          }
        },
        "required": [
          "item_code",
          "item_name",
          "warehouse",
          "current_qty",
          "reorder_level",
          "reorder_qty",
          "shortage_qty"
        ],
        "title": "LowStockItem",
        "type": "object"
      },
      "LowStockResponse": {
        "description": "Response for low stock items",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/LowStockItem"
            },
            "title": "Items",
            "type": "array"
          },
          "total_items": {
            "title": "Total Items",
            "type": "integer"
          },
          "total_estimated_value": {
            "default": 0,
            "title": "Total Estimated Value",
            "type": "number"
          },
          "critical_items": {
            "default": [],
            "items": {
              "type": "string"
            },
            "title": "Critical Items",
            "type": "array"
          }
        },
        "required": [
          "items",
          "total_items"
        ],
        "title": "LowStockResponse",
        "type": "object"
      },
      "ReceiveTransferRequest": {
        "description": "Request for receiving transfer",
        "properties": {
          "transfer_id": {
            "description": "Transfer request ID",
            "title": "Transfer Id",
            "type": "string"
          },
          "received_items": {
            "description": "JSON array of received items with quantities",
            "title": "Received Items",
            "type": "string"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Receipt notes",
            "title": "Notes"
          }
        },
        "required": [
          "transfer_id",
          "received_items"
        ],
        "title": "ReceiveTransferRequest",
        "type": "object"
      },
      "ReservationResponse": {
        "description": "Response for reservation creation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "reservation_id": {
            "title": "Reservation Id",
            "type": "string"
          },
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "qty": {
            "title": "Qty",
            "type": "number"
          },
          "warehouse": {
            "title": "Warehouse",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/ReservationStatus",
            "default": "Active"
          },
          "expires_at": {
            "title": "Expires At",
            "type": "string"
          },
          "message": {
            "default": "Reservation created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "reservation_id",
          "item_code",
          "qty",
          "warehouse",
          "expires_at"
        ],
        "title": "ReservationResponse",
        "type": "object"
      },
      "ReservationStatus": {
        "description": "Material reservation status",
        "enum": [
          "Active",
          "Fulfilled",
          "Cancelled",
          "Expired"
        ],
        "title": "ReservationStatus",
        "type": "string"
      },
      "StockAdjustmentResponse": {
        "description": "Response for stock adjustment",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "stock_entry_id": {
            "title": "Stock Entry Id",
            "type": "string"
          },
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "warehouse": {
            "title": "Warehouse",
            "type": "string"
          },
          "qty_change": {
            "title": "Qty Change",
            "type": "number"
          },
          "new_balance": {
            "title": "New Balance",
            "type": "number"
          },
          "message": {
            "default": "Stock adjusted successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "stock_entry_id",
          "item_code",
          "warehouse",
          "qty_change",
          "new_balance"
        ],
        "title": "StockAdjustmentResponse",
        "type": "object"
      },
      "StockBalanceItem": {
        "description": "Single item stock balance",
        "properties": {
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "warehouse": {
            "title": "Warehouse",
            "type": "string"
          },
          "warehouse_name": {
            "title": "Warehouse Name",
            "type": "string"
          },
          "actual_qty": {
            "title": "Actual Qty",
            "type": "number"
          },
          "reserved_qty": {
            "title": "Reserved Qty",
            "type": "number"
          },
          "available_qty": {
            "title": "Available Qty",
            "type": "number"
          },
          "uom": {
            "title": "Uom",
            "type": "string"
          },
          "valuation_rate": {
            "title": "Valuation Rate",
            "type": "number"
          },
          "stock_value": {
            "title": "Stock Value",
            "type": "number"
          },
          "reorder_level": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Reorder Level"
          },
          "reorder_qty": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Reorder Qty"
          },
          "is_below_reorder": {
            "default": false,
            "title": "Is Below Reorder",
            "type": "boolean"
          }
        },
        "required": [
          "item_code",
          "item_name",
          "warehouse",
          "warehouse_name",
          "actual_qty",
          "reserved_qty",
          "available_qty",
          "uom",
          "valuation_rate",
          "stock_value"
        ],
        "title": "StockBalanceItem",
        "type": "object"
      },
      "StockBalanceResponse": {
        "description": "Response for stock balance query",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/StockBalanceItem"
            },
            "title": "Items",
            "type": "array"
          },
          "total_stock_value": {
            "default": 0,
            "title": "Total Stock Value",
            "type": "number"
          },
          "by_location": {
            "additionalProperties": {
              "additionalProperties": true,
              "type": "object"
            },
            "default": {},
            "title": "By Location",
            "type": "object"
          }
        },
        "required": [
          "items"
        ],
        "title": "StockBalanceResponse",
        "type": "object"
      },
      "TransferReceiptResponse": {
        "description": "Response for transfer receipt",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "transfer_id": {
            "title": "Transfer Id",
            "type": "string"
          },
          "stock_entry_id": {
            "title": "Stock Entry Id",
            "type": "string"
          },
          "items_received": {
            "title": "Items Received",
            "type": "integer"
          },
          "total_qty_received": {
            "title": "Total Qty Received",
            "type": "number"
          },
          "discrepancies": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Discrepancies",
            "type": "array"
          },
          "message": {
            "default": "Transfer received successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "transfer_id",
          "stock_entry_id",
          "items_received",
          "total_qty_received"
        ],
        "title": "TransferReceiptResponse",
        "type": "object"
      },
      "TransferRequestResponse": {
        "description": "Response for transfer request",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "transfer_id": {
            "title": "Transfer Id",
            "type": "string"
          },
          "from_location": {
            "title": "From Location",
            "type": "string"
          },
          "to_location": {
            "title": "To Location",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/TransferStatus",
            "default": "Pending"
          },
          "total_items": {
            "title": "Total Items",
            "type": "integer"
          },
          "total_qty": {
            "title": "Total Qty",
            "type": "number"
          },
          "message": {
            "default": "Transfer request created",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "transfer_id",
          "from_location",
          "to_location",
          "total_items",
          "total_qty"
        ],
        "title": "TransferRequestResponse",
        "type": "object"
      },
      "TransferStatus": {
        "description": "Inter-location transfer status",
        "enum": [
          "Draft",
          "Pending",
          "In Transit",
          "Received",
          "Cancelled"
        ],
        "title": "TransferStatus",
        "type": "string"
      },
      "AvailableVariablesResponse": {
        "description": "Response for available template variables",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Available variables by category",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "message"
        ],
        "title": "AvailableVariablesResponse",
        "type": "object"
      },
      "CarboneHealthResponse": {
        "description": "Response for Carbone health check",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Health status",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "message"
        ],
        "title": "CarboneHealthResponse",
        "type": "object"
      },
      "DeleteTemplateRequest": {
        "description": "Request for deleting a template",
        "properties": {
          "template_id": {
            "description": "Carbone Template DocType ID (e.g., TPL-QTN-0001)",
            "title": "Template Id",
            "type": "string"
          }
        },
        "required": [
          "template_id"
        ],
        "title": "DeleteTemplateRequest",
        "type": "object"
      },
      "DeleteTemplateResponse": {
        "description": "Response for template deletion",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "Template deleted successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "DeleteTemplateResponse",
        "type": "object"
      },
      "DocumentDataResponse": {
        "description": "Response for document data (Carbone JSON)",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Carbone-compatible JSON data",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Document data retrieved",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "DocumentDataResponse",
        "type": "object"
      },
      "GetAvailableVariablesRequest": {
        "description": "Request for getting available template variables",
        "properties": {
          "doc_type": {
            "description": "DocType name",
            "title": "Doc Type",
            "type": "string"
          }
        },
        "required": [
          "doc_type"
        ],
        "title": "GetAvailableVariablesRequest",
        "type": "object"
      },
      "GetDocumentDataRequest": {
        "description": "Request for getting Carbone-compatible JSON data",
        "properties": {
          "doc_type": {
            "description": "DocType name",
            "title": "Doc Type",
            "type": "string"
          },
          "doc_id": {
            "description": "Document ID",
            "title": "Doc Id",
            "type": "string"
          }
        },
        "required": [
          "doc_type",
          "doc_id"
        ],
        "title": "GetDocumentDataRequest",
        "type": "object"
      },
      "GetTemplateInfoRequest": {
        "description": "Request for template information",
        "properties": {
          "doc_type": {
            "description": "DocType name",
            "title": "Doc Type",
            "type": "string"
          },
          "template_name": {
            "default": "default",
            "description": "Template name",
            "title": "Template Name",
            "type": "string"
          }
        },
        "required": [
          "doc_type"
        ],
        "title": "GetTemplateInfoRequest",
        "type": "object"
      },
      "ListTemplatesRequest": {
        "description": "Request for listing templates",
        "properties": {
          "doc_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by DocType",
            "title": "Doc Type"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location (returns location-specific + global)",
            "title": "Location"
          }
        },
        "title": "ListTemplatesRequest",
        "type": "object"
      },
      "ListTemplatesResponse": {
        "description": "Response for template listing",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "List of templates",
            "items": {
              "$ref": "#/components/schemas/TemplateInfo"
            },
            "title": "Data",
            "type": "array"
          },
          "message": {
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "message"
        ],
        "title": "ListTemplatesResponse",
        "type": "object"
      },
      "TemplateInfo": {
        "description": "Template information",
        "properties": {
          "name": {
            "description": "Template DocType ID (e.g., TPL-QTN-0001)",
            "title": "Name",
            "type": "string"
          },
          "template_name": {
            "description": "Human-readable name",
            "title": "Template Name",
            "type": "string"
          },
          "doc_type": {
            "description": "Associated DocType",
            "title": "Doc Type",
            "type": "string"
          },
          "file_extension": {
            "description": "Template file extension",
            "title": "File Extension",
            "type": "string"
          },
          "is_default": {
            "default": 0,
            "description": "Is default template (1 or 0)",
            "title": "Is Default",
            "type": "integer"
          },
          "is_active": {
            "default": 1,
            "description": "Is active (1 or 0)",
            "title": "Is Active",
            "type": "integer"
          },
          "carbone_template_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Carbone service template ID",
            "title": "Carbone Template Id"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Template description",
            "title": "Description"
          },
          "version": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Template version",
            "title": "Version"
          },
          "last_synced": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Last sync timestamp",
            "title": "Last Synced"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Location-specific template",
            "title": "Location"
          }
        },
        "required": [
          "name",
          "template_name",
          "doc_type",
          "file_extension"
        ],
        "title": "TemplateInfo",
        "type": "object"
      },
      "PreviewQuotationRequest": {
        "description": "Request for previewing quotation before save",
        "properties": {
          "form_data": {
            "description": "JSON string of quotation form data",
            "title": "Form Data",
            "type": "string"
          },
          "template_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Template name",
            "title": "Template Name"
          },
          "template_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Carbone Template DocType ID",
            "title": "Template Id"
          },
          "return_inline": {
            "default": false,
            "description": "Return as base64 instead of file URL",
            "title": "Return Inline",
            "type": "boolean"
          }
        },
        "required": [
          "form_data"
        ],
        "title": "PreviewQuotationRequest",
        "type": "object"
      },
      "QuotationFormData": {
        "description": "Quotation form data for preview",
        "properties": {
          "party_name": {
            "description": "Customer ID or 'PREVIEW' for template preview",
            "title": "Party Name",
            "type": "string"
          },
          "customer_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Customer display name",
            "title": "Customer Name"
          },
          "transaction_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Transaction date",
            "title": "Transaction Date"
          },
          "valid_till": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Valid until date",
            "title": "Valid Till"
          },
          "items": {
            "description": "Line items",
            "items": {
              "$ref": "#/components/schemas/QuotationItemFormData"
            },
            "minItems": 1,
            "title": "Items",
            "type": "array"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Location",
            "title": "Location"
          },
          "custom_lead_time_weeks": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Lead time in weeks",
            "title": "Custom Lead Time Weeks"
          },
          "custom_notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Internal notes",
            "title": "Custom Notes"
          },
          "custom_customer_notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Customer-facing notes",
            "title": "Custom Customer Notes"
          }
        },
        "required": [
          "party_name",
          "items"
        ],
        "title": "QuotationFormData",
        "type": "object"
      },
      "QuotationItemFormData": {
        "description": "Single quotation item from form",
        "properties": {
          "item_code": {
            "description": "Item code",
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item name",
            "title": "Item Name"
          },
          "qty": {
            "description": "Quantity",
            "exclusiveMinimum": 0,
            "title": "Qty",
            "type": "number"
          },
          "rate": {
            "description": "Rate per unit",
            "minimum": 0,
            "title": "Rate",
            "type": "number"
          },
          "uom": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Unit of measure",
            "title": "Uom"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Description",
            "title": "Description"
          }
        },
        "required": [
          "item_code",
          "qty",
          "rate"
        ],
        "title": "QuotationItemFormData",
        "type": "object"
      },
      "RenderDocumentInlineResponse": {
        "description": "Response for document rendering (inline/base64 mode)",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Render result with base64 content",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Document generated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "RenderDocumentInlineResponse",
        "type": "object"
      },
      "RenderDocumentRequest": {
        "description": "Request for rendering a document",
        "properties": {
          "doc_type": {
            "description": "ERPNext DocType name",
            "title": "Doc Type",
            "type": "string"
          },
          "doc_id": {
            "description": "Document name/ID",
            "title": "Doc Id",
            "type": "string"
          },
          "template_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Template name (uses default if not specified)",
            "title": "Template Name"
          },
          "template_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Carbone Template DocType ID (overrides template_name)",
            "title": "Template Id"
          },
          "output_format": {
            "default": "pdf",
            "description": "Output format (pdf, docx, odt, etc.)",
            "title": "Output Format",
            "type": "string"
          },
          "custom_filename": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Custom filename for download",
            "title": "Custom Filename"
          },
          "return_inline": {
            "default": false,
            "description": "Return as base64 instead of file URL",
            "title": "Return Inline",
            "type": "boolean"
          }
        },
        "required": [
          "doc_type",
          "doc_id"
        ],
        "title": "RenderDocumentRequest",
        "type": "object"
      },
      "RenderDocumentResponse": {
        "description": "Response for document rendering (file mode)",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Render result",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Document generated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "RenderDocumentResponse",
        "type": "object"
      },
      "SetDefaultTemplateRequest": {
        "description": "Request for setting default template",
        "properties": {
          "template_id": {
            "description": "Carbone Template DocType ID",
            "title": "Template Id",
            "type": "string"
          },
          "doc_type": {
            "description": "DocType name",
            "title": "Doc Type",
            "type": "string"
          }
        },
        "required": [
          "template_id",
          "doc_type"
        ],
        "title": "SetDefaultTemplateRequest",
        "type": "object"
      },
      "TemplateDetailResponse": {
        "description": "Response for template detail",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Template details",
            "title": "Data",
            "type": "object"
          }
        },
        "required": [
          "data"
        ],
        "title": "TemplateDetailResponse",
        "type": "object"
      },
      "UploadTemplateRequest": {
        "description": "Request for uploading a new template",
        "properties": {
          "doc_type": {
            "description": "DocType name",
            "title": "Doc Type",
            "type": "string"
          },
          "template_name": {
            "description": "Template name",
            "maxLength": 100,
            "minLength": 1,
            "title": "Template Name",
            "type": "string"
          },
          "file_url": {
            "description": "URL of an already uploaded ERPNext File",
            "title": "File Url",
            "type": "string"
          },
          "file_extension": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "File extension (docx, odt, xlsx, etc.)",
            "title": "File Extension"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "",
            "description": "Template description",
            "title": "Description"
          },
          "is_default": {
            "default": false,
            "description": "Set as default template",
            "title": "Is Default",
            "type": "boolean"
          }
        },
        "required": [
          "doc_type",
          "template_name",
          "file_url"
        ],
        "title": "UploadTemplateRequest",
        "type": "object"
      },
      "UploadTemplateResponse": {
        "description": "Response for template upload",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Created template info",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Template uploaded successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UploadTemplateResponse",
        "type": "object"
      },
      "BulkQCUpdateResult": {
        "description": "Single result in bulk update",
        "properties": {
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "success": {
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Message"
          }
        },
        "required": [
          "job_card_id",
          "success"
        ],
        "title": "BulkQCUpdateResult",
        "type": "object"
      },
      "BulkUpdateQCStatusRequest": {
        "description": "Request for bulk QC status update",
        "properties": {
          "job_card_ids": {
            "description": "JSON array of job card IDs",
            "title": "Job Card Ids",
            "type": "string"
          },
          "status": {
            "description": "QC status to apply",
            "title": "Status",
            "type": "string"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Bulk update notes",
            "title": "Notes"
          }
        },
        "required": [
          "job_card_ids",
          "status"
        ],
        "title": "BulkUpdateQCStatusRequest",
        "type": "object"
      },
      "BulkUpdateQCStatusResponse": {
        "description": "Response for bulk QC status update",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Bulk update results",
            "title": "Data",
            "type": "object"
          }
        },
        "required": [
          "data"
        ],
        "title": "BulkUpdateQCStatusResponse",
        "type": "object"
      },
      "CreateQCChecklistRequest": {
        "description": "Request for creating QC checklist",
        "properties": {
          "operation": {
            "description": "Operation name",
            "title": "Operation",
            "type": "string"
          },
          "checklist_items": {
            "description": "JSON array of checklist items",
            "title": "Checklist Items",
            "type": "string"
          },
          "is_mandatory": {
            "default": true,
            "description": "Is checklist mandatory",
            "title": "Is Mandatory",
            "type": "boolean"
          }
        },
        "required": [
          "operation",
          "checklist_items"
        ],
        "title": "CreateQCChecklistRequest",
        "type": "object"
      },
      "CreateQCChecklistResponse": {
        "description": "Response for checklist creation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/QCChecklist"
          },
          "message": {
            "default": "QC checklist created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CreateQCChecklistResponse",
        "type": "object"
      },
      "QCChecklist": {
        "description": "QC checklist for operation",
        "properties": {
          "operation": {
            "title": "Operation",
            "type": "string"
          },
          "items": {
            "items": {
              "$ref": "#/components/schemas/QCChecklistItem"
            },
            "title": "Items",
            "type": "array"
          },
          "created_at": {
            "title": "Created At",
            "type": "string"
          },
          "created_by": {
            "title": "Created By",
            "type": "string"
          }
        },
        "required": [
          "operation",
          "items",
          "created_at",
          "created_by"
        ],
        "title": "QCChecklist",
        "type": "object"
      },
      "DailyQCTrend": {
        "description": "Daily QC trend data point",
        "properties": {
          "date": {
            "title": "Date",
            "type": "string"
          },
          "total_inspected": {
            "title": "Total Inspected",
            "type": "integer"
          },
          "passed": {
            "title": "Passed",
            "type": "integer"
          },
          "failed": {
            "title": "Failed",
            "type": "integer"
          },
          "rework": {
            "title": "Rework",
            "type": "integer"
          },
          "first_pass_yield": {
            "title": "First Pass Yield",
            "type": "number"
          }
        },
        "required": [
          "date",
          "total_inspected",
          "passed",
          "failed",
          "rework",
          "first_pass_yield"
        ],
        "title": "DailyQCTrend",
        "type": "object"
      },
      "DefectAnalysisItem": {
        "description": "Defect analysis breakdown item",
        "properties": {
          "category": {
            "title": "Category",
            "type": "string"
          },
          "count": {
            "title": "Count",
            "type": "integer"
          },
          "percentage": {
            "title": "Percentage",
            "type": "number"
          },
          "trend": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Trend"
          }
        },
        "required": [
          "category",
          "count",
          "percentage"
        ],
        "title": "DefectAnalysisItem",
        "type": "object"
      },
      "DefectAnalysisResponse": {
        "description": "Response for defect analysis",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Defect analysis data",
            "title": "Data",
            "type": "object"
          }
        },
        "required": [
          "data"
        ],
        "title": "DefectAnalysisResponse",
        "type": "object"
      },
      "DefectReportData": {
        "description": "Defect report details",
        "properties": {
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "work_order": {
            "title": "Work Order",
            "type": "string"
          },
          "operation": {
            "title": "Operation",
            "type": "string"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Workstation"
          },
          "defect_type": {
            "title": "Defect Type",
            "type": "string"
          },
          "severity": {
            "title": "Severity",
            "type": "string"
          },
          "qty_affected": {
            "title": "Qty Affected",
            "type": "integer"
          },
          "root_cause": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Root Cause"
          },
          "corrective_action": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Corrective Action"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Notes"
          },
          "reported_by": {
            "title": "Reported By",
            "type": "string"
          },
          "reported_at": {
            "title": "Reported At",
            "type": "string"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          }
        },
        "required": [
          "job_card_id",
          "work_order",
          "operation",
          "defect_type",
          "severity",
          "qty_affected",
          "reported_by",
          "reported_at"
        ],
        "title": "DefectReportData",
        "type": "object"
      },
      "GetDefectAnalysisRequest": {
        "description": "Request for defect analysis",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "date_from": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Start date",
            "title": "Date From"
          },
          "date_to": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "End date",
            "title": "Date To"
          },
          "group_by": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "defect_type",
            "description": "Group by field",
            "title": "Group By"
          }
        },
        "title": "GetDefectAnalysisRequest",
        "type": "object"
      },
      "GetInspectionHistoryRequest": {
        "description": "Request for inspection history",
        "properties": {
          "job_card_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by job card",
            "title": "Job Card Id"
          },
          "work_order_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by work order",
            "title": "Work Order Id"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "limit": {
            "default": 50,
            "description": "Maximum records",
            "maximum": 500,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          }
        },
        "title": "GetInspectionHistoryRequest",
        "type": "object"
      },
      "GetInspectionHistoryResponse": {
        "description": "Response for inspection history",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Inspection history with count",
            "title": "Data",
            "type": "object"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetInspectionHistoryResponse",
        "type": "object"
      },
      "GetPendingInspectionsRequest": {
        "description": "Request for pending QC inspections",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by workstation",
            "title": "Workstation"
          },
          "date_from": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Start date filter",
            "title": "Date From"
          },
          "date_to": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "End date filter",
            "title": "Date To"
          }
        },
        "title": "GetPendingInspectionsRequest",
        "type": "object"
      },
      "GetPendingInspectionsResponse": {
        "description": "Response for pending inspections",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Inspection data with summary",
            "title": "Data",
            "type": "object"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetPendingInspectionsResponse",
        "type": "object"
      },
      "GetQCMetricsRequest": {
        "description": "Request for QC metrics and analytics",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "date_from": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Start date",
            "title": "Date From"
          },
          "date_to": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "End date",
            "title": "Date To"
          },
          "period": {
            "default": "30d",
            "description": "Period shorthand (7d, 30d, 90d, YTD)",
            "title": "Period",
            "type": "string"
          }
        },
        "title": "GetQCMetricsRequest",
        "type": "object"
      },
      "GetQCMetricsResponse": {
        "description": "Response for QC metrics",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/QCMetricsData"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetQCMetricsResponse",
        "type": "object"
      },
      "QCMetricsData": {
        "description": "QC metrics data",
        "properties": {
          "first_pass_yield": {
            "description": "First pass yield percentage",
            "title": "First Pass Yield",
            "type": "number"
          },
          "defect_rate": {
            "description": "Defect rate percentage",
            "title": "Defect Rate",
            "type": "number"
          },
          "total_inspected": {
            "title": "Total Inspected",
            "type": "integer"
          },
          "total_passed": {
            "title": "Total Passed",
            "type": "integer"
          },
          "total_failed": {
            "title": "Total Failed",
            "type": "integer"
          },
          "total_rework": {
            "default": 0,
            "title": "Total Rework",
            "type": "integer"
          },
          "by_defect_type": {
            "additionalProperties": {
              "type": "integer"
            },
            "title": "By Defect Type",
            "type": "object"
          },
          "by_workstation": {
            "additionalProperties": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "By Workstation",
            "type": "object"
          },
          "trend": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Trend",
            "type": "array"
          },
          "period": {
            "additionalProperties": {
              "type": "string"
            },
            "title": "Period",
            "type": "object"
          }
        },
        "required": [
          "first_pass_yield",
          "defect_rate",
          "total_inspected",
          "total_passed",
          "total_failed"
        ],
        "title": "QCMetricsData",
        "type": "object"
      },
      "InspectionHistoryItem": {
        "description": "Single inspection history record",
        "properties": {
          "id": {
            "title": "Id",
            "type": "string"
          },
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "work_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Work Order"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Workstation"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "operation": {
            "title": "Operation",
            "type": "string"
          },
          "status": {
            "title": "Status",
            "type": "string"
          },
          "inspector": {
            "title": "Inspector",
            "type": "string"
          },
          "inspected_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Inspected At"
          },
          "qty_inspected": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Qty Inspected"
          },
          "qty_passed": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Qty Passed"
          },
          "qty_failed": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Qty Failed"
          },
          "defect_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Defect Type"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Notes"
          }
        },
        "required": [
          "id",
          "job_card_id",
          "operation",
          "status",
          "inspector"
        ],
        "title": "InspectionHistoryItem",
        "type": "object"
      },
      "InspectionResult": {
        "description": "QC inspection result",
        "properties": {
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "status": {
            "title": "Status",
            "type": "string"
          },
          "inspector": {
            "title": "Inspector",
            "type": "string"
          },
          "timestamp": {
            "title": "Timestamp",
            "type": "string"
          }
        },
        "required": [
          "job_card_id",
          "status",
          "inspector",
          "timestamp"
        ],
        "title": "InspectionResult",
        "type": "object"
      },
      "PendingInspection": {
        "description": "Single pending inspection",
        "properties": {
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "work_order": {
            "title": "Work Order",
            "type": "string"
          },
          "operation": {
            "title": "Operation",
            "type": "string"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Workstation"
          },
          "item_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Item Code"
          },
          "item_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Item Name"
          },
          "batch_no": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Batch No"
          },
          "qty": {
            "title": "Qty",
            "type": "number"
          },
          "completed_qty": {
            "title": "Completed Qty",
            "type": "number"
          },
          "status": {
            "title": "Status",
            "type": "string"
          },
          "qc_status": {
            "title": "Qc Status",
            "type": "string"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "created_at": {
            "title": "Created At",
            "type": "string"
          },
          "is_overdue": {
            "default": false,
            "title": "Is Overdue",
            "type": "boolean"
          }
        },
        "required": [
          "job_card_id",
          "work_order",
          "operation",
          "qty",
          "completed_qty",
          "status",
          "qc_status",
          "created_at"
        ],
        "title": "PendingInspection",
        "type": "object"
      },
      "ReportDefectRequest": {
        "description": "Request for reporting a defect",
        "properties": {
          "job_card_id": {
            "description": "Job Card document name",
            "title": "Job Card Id",
            "type": "string"
          },
          "defect_type": {
            "description": "Type of defect",
            "title": "Defect Type",
            "type": "string"
          },
          "severity": {
            "default": "Medium",
            "description": "Severity level",
            "title": "Severity",
            "type": "string"
          },
          "qty_affected": {
            "default": 1,
            "description": "Quantity affected",
            "minimum": 1,
            "title": "Qty Affected",
            "type": "integer"
          },
          "root_cause": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Root cause category",
            "title": "Root Cause"
          },
          "corrective_action": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Corrective action taken",
            "title": "Corrective Action"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Additional notes",
            "title": "Notes"
          }
        },
        "required": [
          "job_card_id",
          "defect_type"
        ],
        "title": "ReportDefectRequest",
        "type": "object"
      },
      "ReportDefectResponse": {
        "description": "Response for defect report",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "title": "Message",
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/DefectReportData"
          }
        },
        "required": [
          "message",
          "data"
        ],
        "title": "ReportDefectResponse",
        "type": "object"
      },
      "SubmitDetailedInspectionRequest": {
        "description": "Request for submitting detailed QC inspection",
        "properties": {
          "job_card_id": {
            "description": "Job Card document name",
            "title": "Job Card Id",
            "type": "string"
          },
          "status": {
            "description": "QC status (Pass, Fail, Rework)",
            "title": "Status",
            "type": "string"
          },
          "qty_inspected": {
            "default": 0,
            "description": "Quantity inspected",
            "minimum": 0,
            "title": "Qty Inspected",
            "type": "integer"
          },
          "qty_passed": {
            "default": 0,
            "description": "Quantity that passed",
            "minimum": 0,
            "title": "Qty Passed",
            "type": "integer"
          },
          "qty_failed": {
            "default": 0,
            "description": "Quantity that failed",
            "minimum": 0,
            "title": "Qty Failed",
            "type": "integer"
          },
          "defect_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Type of defect if failed",
            "title": "Defect Type"
          },
          "severity": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Severity level",
            "title": "Severity"
          },
          "root_cause": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Root cause category",
            "title": "Root Cause"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Inspector notes",
            "title": "Notes"
          },
          "criteria_results": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "JSON checklist results",
            "title": "Criteria Results"
          }
        },
        "required": [
          "job_card_id",
          "status"
        ],
        "title": "SubmitDetailedInspectionRequest",
        "type": "object"
      },
      "SubmitInspectionResponse": {
        "description": "Response for inspection submission",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "title": "Message",
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/InspectionResult"
          }
        },
        "required": [
          "message",
          "data"
        ],
        "title": "SubmitInspectionResponse",
        "type": "object"
      },
      "WeeklyQCSummary": {
        "description": "Weekly QC summary",
        "properties": {
          "week_start": {
            "title": "Week Start",
            "type": "string"
          },
          "week_end": {
            "title": "Week End",
            "type": "string"
          },
          "total_inspected": {
            "title": "Total Inspected",
            "type": "integer"
          },
          "first_pass_yield": {
            "title": "First Pass Yield",
            "type": "number"
          },
          "top_defects": {
            "items": {
              "type": "string"
            },
            "title": "Top Defects",
            "type": "array"
          }
        },
        "required": [
          "week_start",
          "week_end",
          "total_inspected",
          "first_pass_yield",
          "top_defects"
        ],
        "title": "WeeklyQCSummary",
        "type": "object"
      },
      "CreateTaxRateRequest": {
        "description": "Request for creating tax rate template",
        "properties": {
          "tax_rate": {
            "description": "JSON string of tax rate configuration",
            "title": "Tax Rate",
            "type": "string"
          }
        },
        "required": [
          "tax_rate"
        ],
        "title": "CreateTaxRateRequest",
        "type": "object"
      },
      "CreateTaxRateResponse": {
        "description": "Response for tax rate creation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Created tax rate",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Tax rate created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CreateTaxRateResponse",
        "type": "object"
      },
      "DeleteTaxRateRequest": {
        "description": "Request for deleting tax rate template",
        "properties": {
          "name": {
            "description": "Tax template ID to delete",
            "title": "Name",
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "title": "DeleteTaxRateRequest",
        "type": "object"
      },
      "DeleteTaxRateResponse": {
        "description": "Response for tax rate deletion",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "Tax rate deleted successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "DeleteTaxRateResponse",
        "type": "object"
      },
      "EmailSettingsData": {
        "description": "Outbound email settings fields (ERPNext Email Account aligned).",
        "properties": {
          "email_account_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Email Account document name",
            "title": "Email Account Name"
          },
          "smtp_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Enable outgoing SMTP for system emails",
            "title": "Smtp Enabled"
          },
          "smtp_server": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "SMTP server address",
            "title": "Smtp Server"
          },
          "smtp_port": {
            "anyOf": [
              {
                "maximum": 65535,
                "minimum": 1,
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "SMTP port",
            "title": "Smtp Port"
          },
          "smtp_use_tls": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Use TLS encryption",
            "title": "Smtp Use Tls"
          },
          "smtp_use_ssl": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Use SSL encryption",
            "title": "Smtp Use Ssl"
          },
          "smtp_username": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "SMTP login username",
            "title": "Smtp Username"
          },
          "smtp_password": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "SMTP password (masked on read)",
            "title": "Smtp Password"
          },
          "from_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "From email address",
            "title": "From Email"
          },
          "from_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "From display name",
            "title": "From Name"
          },
          "default_outgoing": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Set as ERPNext default outgoing Email Account",
            "title": "Default Outgoing"
          },
          "always_use_account_email_id_as_sender": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Always use account email as sender for outbound mail",
            "title": "Always Use Account Email Id As Sender"
          },
          "append_emails_to_sent_folder": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Append sent mails to Sent folder",
            "title": "Append Emails To Sent Folder"
          },
          "disable_smtp_authentication": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Disable SMTP authentication (for trusted relay servers)",
            "title": "Disable Smtp Authentication"
          }
        },
        "title": "EmailSettingsData",
        "type": "object"
      },
      "GetEmailSettingsResponse": {
        "description": "Response for email settings",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Email settings (password masked)",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Email settings retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetEmailSettingsResponse",
        "type": "object"
      },
      "GetLocationsResponse": {
        "description": "Response for locations list",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "Location list",
            "items": {
              "$ref": "#/components/schemas/LocationInfo"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Total count",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Locations retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetLocationsResponse",
        "type": "object"
      },
      "LocationInfo": {
        "description": "Location (warehouse group) information",
        "properties": {
          "name": {
            "description": "Warehouse name",
            "title": "Name",
            "type": "string"
          },
          "warehouse_name": {
            "description": "Display name",
            "title": "Warehouse Name",
            "type": "string"
          },
          "is_group": {
            "description": "Is warehouse group",
            "title": "Is Group",
            "type": "integer"
          },
          "parent_warehouse": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Parent warehouse",
            "title": "Parent Warehouse"
          },
          "custom_batch_prefix": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Batch number prefix",
            "title": "Custom Batch Prefix"
          }
        },
        "required": [
          "name",
          "warehouse_name",
          "is_group"
        ],
        "title": "LocationInfo",
        "type": "object"
      },
      "GetNotificationSettingsResponse": {
        "description": "Response for notification settings",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Notification settings",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Notification settings retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetNotificationSettingsResponse",
        "type": "object"
      },
      "GetQuoteSettingsResponse": {
        "description": "Response for quote settings",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Quote settings",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Quote settings retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetQuoteSettingsResponse",
        "type": "object"
      },
      "GetSystemSettingsResponse": {
        "description": "Response for system settings",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "System settings",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Settings retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetSystemSettingsResponse",
        "type": "object"
      },
      "GetTaxRatesResponse": {
        "description": "Response for tax rates list",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "Tax rate templates",
            "items": {
              "$ref": "#/components/schemas/TaxRateItem"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Total count",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Tax rates retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetTaxRatesResponse",
        "type": "object"
      },
      "TaxRateItem": {
        "description": "Single tax rate template in list",
        "properties": {
          "name": {
            "description": "Tax template ID",
            "title": "Name",
            "type": "string"
          },
          "title": {
            "description": "Tax template title",
            "title": "Title",
            "type": "string"
          },
          "is_default": {
            "default": 0,
            "description": "Is default template",
            "title": "Is Default",
            "type": "integer"
          },
          "disabled": {
            "default": 0,
            "description": "Is disabled",
            "title": "Disabled",
            "type": "integer"
          },
          "taxes": {
            "description": "Tax charges",
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Taxes",
            "type": "array"
          }
        },
        "required": [
          "name",
          "title"
        ],
        "title": "TaxRateItem",
        "type": "object"
      },
      "GetUserPreferencesResponse": {
        "description": "Response for get_user_preferences endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/PreferencesData",
            "description": "User preferences data"
          },
          "message": {
            "default": "Preferences retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetUserPreferencesResponse",
        "type": "object"
      },
      "PreferencesData": {
        "description": "User preferences data structure.",
        "properties": {
          "preferences": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "User preferences object (null if not set)",
            "title": "Preferences"
          },
          "version": {
            "default": 0,
            "description": "Version number for optimistic locking",
            "title": "Version",
            "type": "integer"
          },
          "modified": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Last modified timestamp",
            "title": "Modified"
          }
        },
        "title": "PreferencesData",
        "type": "object"
      },
      "NotificationSettingsData": {
        "description": "Notification settings fields",
        "properties": {
          "enable_email_notifications": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Enable email notifications",
            "title": "Enable Email Notifications"
          },
          "enable_sms_notifications": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Enable SMS notifications",
            "title": "Enable Sms Notifications"
          },
          "enable_push_notifications": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Enable push notifications",
            "title": "Enable Push Notifications"
          }
        },
        "title": "NotificationSettingsData",
        "type": "object"
      },
      "QuoteSettingsData": {
        "description": "Quote settings fields",
        "properties": {
          "default_validity_days": {
            "anyOf": [
              {
                "maximum": 365,
                "minimum": 1,
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Default quote validity in days",
            "title": "Default Validity Days"
          },
          "default_lead_time_weeks": {
            "anyOf": [
              {
                "maximum": 52,
                "minimum": 1,
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Default lead time in weeks",
            "title": "Default Lead Time Weeks"
          },
          "auto_number_prefix": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Quote number prefix",
            "title": "Auto Number Prefix"
          },
          "require_approval": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Require approval before sending",
            "title": "Require Approval"
          },
          "approval_threshold": {
            "anyOf": [
              {
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Amount threshold for approval",
            "title": "Approval Threshold"
          },
          "default_terms": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Default terms and conditions",
            "title": "Default Terms"
          }
        },
        "title": "QuoteSettingsData",
        "type": "object"
      },
      "SystemSettingsData": {
        "description": "System settings fields",
        "properties": {
          "company_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Company name",
            "title": "Company Name"
          },
          "primary_admin_email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Primary admin email used for setup ownership and operational alerts",
            "title": "Primary Admin Email"
          },
          "fiscal_year_start": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Fiscal year start date",
            "title": "Fiscal Year Start"
          },
          "default_currency": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Default currency code",
            "title": "Default Currency"
          },
          "timezone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "System timezone",
            "title": "Timezone"
          },
          "date_format": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Date display format",
            "title": "Date Format"
          },
          "time_format": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Time display format",
            "title": "Time Format"
          },
          "enable_email_notifications": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Enable email notifications",
            "title": "Enable Email Notifications"
          },
          "enable_sms_notifications": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Enable SMS notifications",
            "title": "Enable Sms Notifications"
          },
          "enable_push_notifications": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Enable push notifications",
            "title": "Enable Push Notifications"
          }
        },
        "title": "SystemSettingsData",
        "type": "object"
      },
      "TaxChargeItem": {
        "description": "Single tax charge in template",
        "properties": {
          "charge_type": {
            "default": "On Net Total",
            "description": "Charge calculation type",
            "title": "Charge Type",
            "type": "string"
          },
          "account_head": {
            "description": "Tax account head",
            "title": "Account Head",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "",
            "description": "Tax description",
            "title": "Description"
          },
          "rate": {
            "description": "Tax rate percentage",
            "minimum": 0,
            "title": "Rate",
            "type": "number"
          }
        },
        "required": [
          "account_head",
          "rate"
        ],
        "title": "TaxChargeItem",
        "type": "object"
      },
      "TaxRateData": {
        "description": "Tax rate template data",
        "properties": {
          "title": {
            "description": "Tax template title",
            "title": "Title",
            "type": "string"
          },
          "is_default": {
            "default": 0,
            "description": "Is default template",
            "title": "Is Default",
            "type": "integer"
          },
          "taxes": {
            "description": "Tax charges",
            "items": {
              "$ref": "#/components/schemas/TaxChargeItem"
            },
            "minItems": 1,
            "title": "Taxes",
            "type": "array"
          }
        },
        "required": [
          "title",
          "taxes"
        ],
        "title": "TaxRateData",
        "type": "object"
      },
      "TestEmailConnectionRequest": {
        "description": "Request for testing email connection",
        "properties": {
          "settings": {
            "description": "JSON string of SMTP settings to test",
            "title": "Settings",
            "type": "string"
          }
        },
        "required": [
          "settings"
        ],
        "title": "TestEmailConnectionRequest",
        "type": "object"
      },
      "TestEmailConnectionResponse": {
        "description": "Response for email connection test",
        "properties": {
          "success": {
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "title": "Message",
            "type": "string"
          },
          "details": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Connection details",
            "title": "Details"
          }
        },
        "required": [
          "success",
          "message"
        ],
        "title": "TestEmailConnectionResponse",
        "type": "object"
      },
      "TestEmailRequest": {
        "description": "Request for sending a test email using configured default outgoing account.",
        "properties": {
          "recipient": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Optional recipient email. Defaults to current admin user email.",
            "title": "Recipient"
          }
        },
        "title": "TestEmailRequest",
        "type": "object"
      },
      "TestEmailResponse": {
        "description": "Response for sending test email.",
        "properties": {
          "success": {
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "title": "Message",
            "type": "string"
          },
          "details": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Delivery details",
            "title": "Details"
          }
        },
        "required": [
          "success",
          "message"
        ],
        "title": "TestEmailResponse",
        "type": "object"
      },
      "UpdateEmailSettingsRequest": {
        "description": "Request for updating email settings",
        "properties": {
          "settings": {
            "description": "JSON string of email settings",
            "title": "Settings",
            "type": "string"
          }
        },
        "required": [
          "settings"
        ],
        "title": "UpdateEmailSettingsRequest",
        "type": "object"
      },
      "UpdateEmailSettingsResponse": {
        "description": "Response for email settings update",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Updated email settings",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Email settings updated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateEmailSettingsResponse",
        "type": "object"
      },
      "UpdateNotificationSettingsRequest": {
        "description": "Request for updating notification settings",
        "properties": {
          "settings": {
            "description": "JSON string of notification settings",
            "title": "Settings",
            "type": "string"
          }
        },
        "required": [
          "settings"
        ],
        "title": "UpdateNotificationSettingsRequest",
        "type": "object"
      },
      "UpdateNotificationSettingsResponse": {
        "description": "Response for notification settings update",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Updated notification settings",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Notification settings updated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateNotificationSettingsResponse",
        "type": "object"
      },
      "UpdateQuoteSettingsRequest": {
        "description": "Request for updating quote settings",
        "properties": {
          "settings": {
            "description": "JSON string of quote settings",
            "title": "Settings",
            "type": "string"
          }
        },
        "required": [
          "settings"
        ],
        "title": "UpdateQuoteSettingsRequest",
        "type": "object"
      },
      "UpdateQuoteSettingsResponse": {
        "description": "Response for quote settings update",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Updated quote settings",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Quote settings updated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateQuoteSettingsResponse",
        "type": "object"
      },
      "UpdateSystemSettingsRequest": {
        "description": "Request for updating system settings",
        "properties": {
          "settings": {
            "description": "JSON string of settings to update",
            "title": "Settings",
            "type": "string"
          }
        },
        "required": [
          "settings"
        ],
        "title": "UpdateSystemSettingsRequest",
        "type": "object"
      },
      "UpdateSystemSettingsResponse": {
        "description": "Response for system settings update",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Updated settings",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Settings updated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateSystemSettingsResponse",
        "type": "object"
      },
      "UpdateTaxRateRequest": {
        "description": "Request for updating tax rate template",
        "properties": {
          "name": {
            "description": "Tax template ID",
            "title": "Name",
            "type": "string"
          },
          "tax_rate": {
            "description": "JSON string of updated configuration",
            "title": "Tax Rate",
            "type": "string"
          }
        },
        "required": [
          "name",
          "tax_rate"
        ],
        "title": "UpdateTaxRateRequest",
        "type": "object"
      },
      "UpdateTaxRateResponse": {
        "description": "Response for tax rate update",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Updated tax rate",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Tax rate updated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateTaxRateResponse",
        "type": "object"
      },
      "UpdateUserPreferencesRequest": {
        "description": "Request to update user preferences with optimistic locking.",
        "properties": {
          "preferences": {
            "description": "JSON string of preferences to save",
            "title": "Preferences",
            "type": "string"
          },
          "client_version": {
            "description": "Version number the client last synced with",
            "title": "Client Version",
            "type": "string"
          }
        },
        "required": [
          "preferences",
          "client_version"
        ],
        "title": "UpdateUserPreferencesRequest",
        "type": "object"
      },
      "UpdateUserPreferencesResponse": {
        "description": "Response for update_user_preferences endpoint (success case).",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/UpdateResultData",
            "description": "Update result"
          },
          "message": {
            "default": "Preferences updated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateUserPreferencesResponse",
        "type": "object"
      },
      "UpdateResultData": {
        "description": "Result from successful preference update.",
        "properties": {
          "version": {
            "description": "New version number after update",
            "title": "Version",
            "type": "integer"
          },
          "modified": {
            "description": "New modified timestamp",
            "title": "Modified",
            "type": "string"
          }
        },
        "required": [
          "version",
          "modified"
        ],
        "title": "UpdateResultData",
        "type": "object"
      },
      "UserPreferencesData": {
        "description": "User preferences fields",
        "properties": {
          "default_location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Default location",
            "title": "Default Location"
          },
          "default_workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Default workstation",
            "title": "Default Workstation"
          },
          "theme": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "UI theme preference",
            "title": "Theme"
          },
          "language": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Language preference",
            "title": "Language"
          },
          "notifications_enabled": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Enable notifications",
            "title": "Notifications Enabled"
          }
        },
        "title": "UserPreferencesData",
        "type": "object"
      },
      "GetItemGroupsRequest": {
        "description": "Request parameters for get_item_groups",
        "properties": {
          "include_groups": {
            "default": false,
            "description": "Include parent groups (is_group=1)",
            "title": "Include Groups",
            "type": "boolean"
          },
          "parent_group": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by parent Item Group",
            "title": "Parent Group"
          }
        },
        "title": "GetItemGroupsRequest",
        "type": "object"
      },
      "GetItemGroupsResponse": {
        "description": "Response from get_item_groups",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "items": {
              "$ref": "#/components/schemas/ItemGroupData"
            },
            "title": "Data",
            "type": "array"
          },
          "default": {
            "type": "string",
            "description": "Default Item Group for new items",
            "title": "Default"
          },
          "message": {
            "title": "Message",
            "type": "string"
          },
          "count": {
            "title": "Count",
            "type": "integer"
          }
        },
        "required": [
          "data",
          "default",
          "message",
          "count"
        ],
        "title": "GetItemGroupsResponse",
        "type": "object"
      },
      "ItemGroupData": {
        "description": "Single Item Group record",
        "properties": {
          "name": {
            "description": "Unique identifier (e.g., 'Raw Material')",
            "title": "Name",
            "type": "string"
          },
          "item_group_name": {
            "description": "Display name",
            "title": "Item Group Name",
            "type": "string"
          },
          "parent_item_group": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Parent group name",
            "title": "Parent Item Group"
          },
          "is_group": {
            "default": 0,
            "description": "1 if parent group, 0 if leaf",
            "title": "Is Group",
            "type": "integer"
          }
        },
        "required": [
          "name",
          "item_group_name"
        ],
        "title": "ItemGroupData",
        "type": "object"
      },
      "GetMasterDataBundleResponse": {
        "description": "Response from get_master_data_bundle",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/MasterDataBundleData"
          },
          "message": {
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "message"
        ],
        "title": "GetMasterDataBundleResponse",
        "type": "object"
      },
      "MasterDataBundleData": {
        "description": "Combined master data for initial page load",
        "properties": {
          "item_groups": {
            "items": {
              "$ref": "#/components/schemas/ItemGroupData"
            },
            "title": "Item Groups",
            "type": "array"
          },
          "uoms": {
            "items": {
              "$ref": "#/components/schemas/UOMData"
            },
            "title": "Uoms",
            "type": "array"
          },
          "defaults": {
            "$ref": "#/components/schemas/MasterDataDefaults"
          }
        },
        "required": [
          "item_groups",
          "uoms",
          "defaults"
        ],
        "title": "MasterDataBundleData",
        "type": "object"
      },
      "MasterDataDefaults": {
        "description": "Default values for master data",
        "properties": {
          "item_group": {
            "default": "Raw Material",
            "description": "Default Item Group",
            "title": "Item Group",
            "type": "string"
          },
          "uom": {
            "default": "Nos",
            "description": "Default UOM",
            "title": "Uom",
            "type": "string"
          }
        },
        "title": "MasterDataDefaults",
        "type": "object"
      },
      "UOMData": {
        "description": "Single UOM record",
        "properties": {
          "name": {
            "description": "Unique identifier (e.g., 'Nos')",
            "title": "Name",
            "type": "string"
          },
          "uom_name": {
            "description": "Display name",
            "title": "Uom Name",
            "type": "string"
          },
          "must_be_whole_number": {
            "default": 0,
            "description": "1 if must be whole number, 0 if decimals allowed",
            "title": "Must Be Whole Number",
            "type": "integer"
          }
        },
        "required": [
          "name",
          "uom_name"
        ],
        "title": "UOMData",
        "type": "object"
      },
      "GetUOMsRequest": {
        "description": "Request parameters for get_uoms",
        "properties": {
          "must_be_whole_number": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by whole number requirement",
            "title": "Must Be Whole Number"
          }
        },
        "title": "GetUOMsRequest",
        "type": "object"
      },
      "GetUOMsResponse": {
        "description": "Response from get_uoms",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "items": {
              "$ref": "#/components/schemas/UOMData"
            },
            "title": "Data",
            "type": "array"
          },
          "default": {
            "type": "string",
            "description": "Default UOM for new items",
            "title": "Default"
          },
          "message": {
            "title": "Message",
            "type": "string"
          },
          "count": {
            "title": "Count",
            "type": "integer"
          }
        },
        "required": [
          "data",
          "default",
          "message",
          "count"
        ],
        "title": "GetUOMsResponse",
        "type": "object"
      },
      "DeleteDimensionPresetRequest": {
        "description": "Request for deleting dimension preset",
        "properties": {
          "name": {
            "description": "Preset name to delete",
            "title": "Name",
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "title": "DeleteDimensionPresetRequest",
        "type": "object"
      },
      "DeleteDimensionPresetResponse": {
        "description": "Response for dimension preset deletion",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "Dimension preset deleted successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "DeleteDimensionPresetResponse",
        "type": "object"
      },
      "DeleteMaterialRequest": {
        "description": "Request for deleting material",
        "properties": {
          "code": {
            "description": "Material code to delete",
            "title": "Code",
            "type": "string"
          }
        },
        "required": [
          "code"
        ],
        "title": "DeleteMaterialRequest",
        "type": "object"
      },
      "DeleteMaterialResponse": {
        "description": "Response for material deletion",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "Material deleted successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "DeleteMaterialResponse",
        "type": "object"
      },
      "DeleteShapeRequest": {
        "description": "Request for deleting shape",
        "properties": {
          "code": {
            "description": "Shape code to delete",
            "title": "Code",
            "type": "string"
          }
        },
        "required": [
          "code"
        ],
        "title": "DeleteShapeRequest",
        "type": "object"
      },
      "DeleteShapeResponse": {
        "description": "Response for shape deletion",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "Shape deleted successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "DeleteShapeResponse",
        "type": "object"
      },
      "DimensionField": {
        "description": "Dimension field configuration for shapes",
        "properties": {
          "key": {
            "description": "Field key (e.g., thickness)",
            "minLength": 1,
            "title": "Key",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "type": {
            "default": "number",
            "description": "Field type: number, select, text",
            "title": "Type",
            "type": "string"
          },
          "unit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Unit of measure",
            "title": "Unit"
          },
          "required": {
            "default": true,
            "description": "Is field required",
            "title": "Required",
            "type": "boolean"
          },
          "min_value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Minimum value (for number type)",
            "title": "Min Value"
          },
          "max_value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Maximum value (for number type)",
            "title": "Max Value"
          },
          "step": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Step value (for number type)",
            "title": "Step"
          },
          "options": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/DimensionOption"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Options for select type",
            "title": "Options"
          },
          "default_value": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Default value",
            "title": "Default Value"
          },
          "display_order": {
            "default": 0,
            "description": "Display order",
            "minimum": 0,
            "title": "Display Order",
            "type": "integer"
          }
        },
        "required": [
          "key",
          "label"
        ],
        "title": "DimensionField",
        "type": "object"
      },
      "DimensionOption": {
        "description": "Single option in dimension field dropdown",
        "properties": {
          "value": {
            "description": "Option value",
            "title": "Value",
            "type": "string"
          },
          "label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Display label (defaults to value)",
            "title": "Label"
          }
        },
        "required": [
          "value"
        ],
        "title": "DimensionOption",
        "type": "object"
      },
      "DimensionPresetData": {
        "description": "Dimension preset configuration",
        "properties": {
          "name": {
            "description": "Preset name",
            "title": "Name",
            "type": "string"
          },
          "shape_code": {
            "description": "Associated shape code",
            "title": "Shape Code",
            "type": "string"
          },
          "field_key": {
            "description": "Dimension field key",
            "title": "Field Key",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Preset description",
            "title": "Description"
          },
          "options": {
            "description": "Preset options",
            "items": {
              "$ref": "#/components/schemas/PresetOption"
            },
            "minItems": 1,
            "title": "Options",
            "type": "array"
          },
          "is_default": {
            "default": false,
            "description": "Use as default for this field",
            "title": "Is Default",
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "shape_code",
          "field_key",
          "options"
        ],
        "title": "DimensionPresetData",
        "type": "object"
      },
      "PresetOption": {
        "description": "Single preset option",
        "properties": {
          "value": {
            "description": "Option value",
            "title": "Value",
            "type": "string"
          },
          "label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Display label",
            "title": "Label"
          },
          "is_common": {
            "default": false,
            "description": "Is commonly used option",
            "title": "Is Common",
            "type": "boolean"
          }
        },
        "required": [
          "value"
        ],
        "title": "PresetOption",
        "type": "object"
      },
      "DimensionPresetResponse": {
        "description": "Single dimension preset in response",
        "properties": {
          "name": {
            "title": "Name",
            "type": "string"
          },
          "shape_code": {
            "title": "Shape Code",
            "type": "string"
          },
          "field_key": {
            "title": "Field Key",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Description"
          },
          "options": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/PresetOption"
            },
            "title": "Options",
            "type": "array"
          },
          "is_default": {
            "default": 0,
            "title": "Is Default",
            "type": "integer"
          }
        },
        "required": [
          "name",
          "shape_code",
          "field_key"
        ],
        "title": "DimensionPresetResponse",
        "type": "object"
      },
      "GenerateItemCodeRequest": {
        "description": "Request for generating item code from material configuration",
        "properties": {
          "material_code": {
            "description": "Material code (e.g., CS)",
            "title": "Material Code",
            "type": "string"
          },
          "grade_code": {
            "description": "Grade code (e.g., A36)",
            "title": "Grade Code",
            "type": "string"
          },
          "finish_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Finish code (e.g., HR)",
            "title": "Finish Code"
          },
          "shape_code": {
            "description": "Shape code (e.g., SHEET)",
            "title": "Shape Code",
            "type": "string"
          },
          "dimensions": {
            "description": "JSON object of dimension values",
            "title": "Dimensions",
            "type": "string"
          }
        },
        "required": [
          "material_code",
          "grade_code",
          "shape_code",
          "dimensions"
        ],
        "title": "GenerateItemCodeRequest",
        "type": "object"
      },
      "GenerateItemCodeResponse": {
        "description": "Response for item code generation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Generated item code info",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Item code generated",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GenerateItemCodeResponse",
        "type": "object"
      },
      "GetDimensionPresetsRequest": {
        "description": "Request for dimension presets",
        "properties": {
          "shape_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by shape code",
            "title": "Shape Code"
          },
          "field_key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by dimension field key",
            "title": "Field Key"
          }
        },
        "title": "GetDimensionPresetsRequest",
        "type": "object"
      },
      "GetDimensionPresetsResponse": {
        "description": "Response for dimension presets list",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "Presets list",
            "items": {
              "$ref": "#/components/schemas/DimensionPresetResponse"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Total count",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Dimension presets retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetDimensionPresetsResponse",
        "type": "object"
      },
      "GetMaterialsRequest": {
        "description": "Request for materials list",
        "properties": {
          "active_only": {
            "default": true,
            "description": "Only return active materials",
            "title": "Active Only",
            "type": "boolean"
          }
        },
        "title": "GetMaterialsRequest",
        "type": "object"
      },
      "GetMaterialsResponse": {
        "description": "Response for materials list",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "Materials list",
            "items": {
              "$ref": "#/components/schemas/MaterialResponse"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Total count",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Materials retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetMaterialsResponse",
        "type": "object"
      },
      "MaterialFinish": {
        "description": "Material finish/coating definition",
        "properties": {
          "code": {
            "description": "Finish code (e.g., HR)",
            "maxLength": 20,
            "minLength": 1,
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Finish description",
            "title": "Description"
          },
          "is_default": {
            "default": false,
            "description": "Is default finish",
            "title": "Is Default",
            "type": "boolean"
          },
          "display_order": {
            "default": 0,
            "description": "Display order",
            "minimum": 0,
            "title": "Display Order",
            "type": "integer"
          }
        },
        "required": [
          "code",
          "label"
        ],
        "title": "MaterialFinish",
        "type": "object"
      },
      "MaterialGrade": {
        "description": "Material grade definition",
        "properties": {
          "code": {
            "description": "Grade code (e.g., A36)",
            "maxLength": 20,
            "minLength": 1,
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Grade description",
            "title": "Description"
          },
          "astm_spec": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "ASTM specification",
            "title": "Astm Spec"
          },
          "substitutes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Acceptable substitutes",
            "title": "Substitutes"
          },
          "is_default": {
            "default": false,
            "description": "Is default grade",
            "title": "Is Default",
            "type": "boolean"
          },
          "display_order": {
            "default": 0,
            "description": "Display order",
            "minimum": 0,
            "title": "Display Order",
            "type": "integer"
          }
        },
        "required": [
          "code",
          "label"
        ],
        "title": "MaterialGrade",
        "type": "object"
      },
      "MaterialResponse": {
        "description": "Single material in response",
        "properties": {
          "code": {
            "title": "Code",
            "type": "string"
          },
          "label": {
            "title": "Label",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Description"
          },
          "display_order": {
            "default": 0,
            "title": "Display Order",
            "type": "integer"
          },
          "active": {
            "default": 1,
            "title": "Active",
            "type": "integer"
          },
          "grades": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/MaterialGrade"
            },
            "title": "Grades",
            "type": "array"
          },
          "finishes": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/MaterialFinish"
            },
            "title": "Finishes",
            "type": "array"
          }
        },
        "required": [
          "code",
          "label"
        ],
        "title": "MaterialResponse",
        "type": "object"
      },
      "GetShapesRequest": {
        "description": "Request for shapes list",
        "properties": {
          "active_only": {
            "default": true,
            "description": "Only return active shapes",
            "title": "Active Only",
            "type": "boolean"
          }
        },
        "title": "GetShapesRequest",
        "type": "object"
      },
      "GetShapesResponse": {
        "description": "Response for shapes list",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "Shapes list",
            "items": {
              "$ref": "#/components/schemas/ShapeResponse"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Total count",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Shapes retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetShapesResponse",
        "type": "object"
      },
      "ShapeResponse": {
        "description": "Single shape in response",
        "properties": {
          "code": {
            "title": "Code",
            "type": "string"
          },
          "label": {
            "title": "Label",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Description"
          },
          "icon": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Icon"
          },
          "display_order": {
            "default": 0,
            "title": "Display Order",
            "type": "integer"
          },
          "active": {
            "default": 1,
            "title": "Active",
            "type": "integer"
          },
          "dimension_fields": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/DimensionField"
            },
            "title": "Dimension Fields",
            "type": "array"
          }
        },
        "required": [
          "code",
          "label"
        ],
        "title": "ShapeResponse",
        "type": "object"
      },
      "MaterialData": {
        "description": "Material configuration data",
        "properties": {
          "code": {
            "description": "Material code",
            "maxLength": 20,
            "minLength": 1,
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Material description",
            "title": "Description"
          },
          "display_order": {
            "default": 0,
            "description": "Display order",
            "minimum": 0,
            "title": "Display Order",
            "type": "integer"
          },
          "active": {
            "default": true,
            "description": "Is material active",
            "title": "Active",
            "type": "boolean"
          },
          "grades": {
            "description": "Available grades",
            "items": {
              "$ref": "#/components/schemas/MaterialGrade"
            },
            "title": "Grades",
            "type": "array"
          },
          "finishes": {
            "description": "Available finishes",
            "items": {
              "$ref": "#/components/schemas/MaterialFinish"
            },
            "title": "Finishes",
            "type": "array"
          }
        },
        "required": [
          "code",
          "label"
        ],
        "title": "MaterialData",
        "type": "object"
      },
      "ReorderMaterialsRequest": {
        "description": "Request for reordering materials",
        "properties": {
          "order": {
            "description": "JSON array of material codes in new order",
            "title": "Order",
            "type": "string"
          }
        },
        "required": [
          "order"
        ],
        "title": "ReorderMaterialsRequest",
        "type": "object"
      },
      "SaveDimensionPresetRequest": {
        "description": "Request for creating/updating dimension preset",
        "properties": {
          "preset": {
            "description": "JSON string of preset configuration",
            "title": "Preset",
            "type": "string"
          }
        },
        "required": [
          "preset"
        ],
        "title": "SaveDimensionPresetRequest",
        "type": "object"
      },
      "SaveDimensionPresetResponse": {
        "description": "Response for dimension preset save",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/DimensionPresetResponse",
            "description": "Saved preset"
          },
          "message": {
            "default": "Dimension preset saved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "SaveDimensionPresetResponse",
        "type": "object"
      },
      "SaveMaterialRequest": {
        "description": "Request for creating/updating material",
        "properties": {
          "material": {
            "description": "JSON string of material configuration",
            "title": "Material",
            "type": "string"
          }
        },
        "required": [
          "material"
        ],
        "title": "SaveMaterialRequest",
        "type": "object"
      },
      "SaveMaterialResponse": {
        "description": "Response for material save",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/MaterialResponse",
            "description": "Saved material"
          },
          "message": {
            "default": "Material saved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "SaveMaterialResponse",
        "type": "object"
      },
      "SaveShapeRequest": {
        "description": "Request for creating/updating shape",
        "properties": {
          "shape": {
            "description": "JSON string of shape configuration",
            "title": "Shape",
            "type": "string"
          }
        },
        "required": [
          "shape"
        ],
        "title": "SaveShapeRequest",
        "type": "object"
      },
      "SaveShapeResponse": {
        "description": "Response for shape save",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/ShapeResponse",
            "description": "Saved shape"
          },
          "message": {
            "default": "Shape saved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "SaveShapeResponse",
        "type": "object"
      },
      "ShapeData": {
        "description": "Shape configuration data",
        "properties": {
          "code": {
            "description": "Shape code",
            "maxLength": 20,
            "minLength": 1,
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Shape description",
            "title": "Description"
          },
          "icon": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Icon identifier",
            "title": "Icon"
          },
          "display_order": {
            "default": 0,
            "description": "Display order",
            "minimum": 0,
            "title": "Display Order",
            "type": "integer"
          },
          "active": {
            "default": true,
            "description": "Is shape active",
            "title": "Active",
            "type": "boolean"
          },
          "dimension_fields": {
            "description": "Dimension fields",
            "items": {
              "$ref": "#/components/schemas/DimensionField"
            },
            "minItems": 1,
            "title": "Dimension Fields",
            "type": "array"
          }
        },
        "required": [
          "code",
          "label",
          "dimension_fields"
        ],
        "title": "ShapeData",
        "type": "object"
      },
      "AssignJobResponse": {
        "description": "Response for job assignment",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Assignment details",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Job assigned to workstation",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "AssignJobResponse",
        "type": "object"
      },
      "AssignJobToWorkstationRequest": {
        "description": "Request for assigning job to workstation",
        "properties": {
          "job_card_id": {
            "description": "Job Card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "workstation_id": {
            "description": "Target workstation",
            "title": "Workstation Id",
            "type": "string"
          },
          "scheduled_start": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Scheduled start datetime",
            "title": "Scheduled Start"
          },
          "priority": {
            "default": 0,
            "description": "Priority level",
            "maximum": 10,
            "minimum": 0,
            "title": "Priority",
            "type": "integer"
          }
        },
        "required": [
          "job_card_id",
          "workstation_id"
        ],
        "title": "AssignJobToWorkstationRequest",
        "type": "object"
      },
      "GetUtilizationResponse": {
        "description": "Response for utilization report",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Utilization data",
            "title": "Data",
            "type": "object"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetUtilizationResponse",
        "type": "object"
      },
      "GetWorkstationDetailRequest": {
        "description": "Request for workstation detail",
        "properties": {
          "workstation_id": {
            "description": "Workstation ID",
            "title": "Workstation Id",
            "type": "string"
          },
          "include_schedule": {
            "default": true,
            "description": "Include schedule info",
            "title": "Include Schedule",
            "type": "boolean"
          },
          "include_history": {
            "default": false,
            "description": "Include job history",
            "title": "Include History",
            "type": "boolean"
          }
        },
        "required": [
          "workstation_id"
        ],
        "title": "GetWorkstationDetailRequest",
        "type": "object"
      },
      "GetWorkstationDetailResponse": {
        "description": "Response for workstation detail",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/WorkstationDetail"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetWorkstationDetailResponse",
        "type": "object"
      },
      "QueuedJob": {
        "description": "Job in workstation queue",
        "properties": {
          "job_card_id": {
            "title": "Job Card Id",
            "type": "string"
          },
          "work_order": {
            "title": "Work Order",
            "type": "string"
          },
          "operation": {
            "title": "Operation",
            "type": "string"
          },
          "priority": {
            "default": 0,
            "title": "Priority",
            "type": "integer"
          },
          "estimated_hours": {
            "title": "Estimated Hours",
            "type": "number"
          },
          "status": {
            "title": "Status",
            "type": "string"
          },
          "scheduled_start": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Scheduled Start"
          },
          "powder_batch_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Powder Batch Id"
          },
          "powder_batch_status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Powder Batch Status"
          },
          "powder_color_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Powder Color Code"
          },
          "cure_profile_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Cure Profile Code"
          },
          "powder_sequence": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Powder Sequence"
          }
        },
        "required": [
          "job_card_id",
          "work_order",
          "operation",
          "estimated_hours",
          "status"
        ],
        "title": "QueuedJob",
        "type": "object"
      },
      "WorkingHourSlot": {
        "description": "Single working hour slot",
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Slot ID",
            "title": "Name"
          },
          "start_time": {
            "description": "Start time (HH:MM)",
            "title": "Start Time",
            "type": "string"
          },
          "end_time": {
            "description": "End time (HH:MM)",
            "title": "End Time",
            "type": "string"
          },
          "enabled": {
            "default": true,
            "description": "Is slot enabled",
            "title": "Enabled",
            "type": "boolean"
          }
        },
        "required": [
          "start_time",
          "end_time"
        ],
        "title": "WorkingHourSlot",
        "type": "object"
      },
      "WorkstationDetail": {
        "description": "Detailed workstation information",
        "properties": {
          "name": {
            "title": "Name",
            "type": "string"
          },
          "workstation_name": {
            "title": "Workstation Name",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Description"
          },
          "warehouse": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Warehouse"
          },
          "production_capacity": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Production Capacity"
          },
          "hour_rate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Hour Rate"
          },
          "hour_rate_labour": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Hour Rate Labour"
          },
          "hour_rate_electricity": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Hour Rate Electricity"
          },
          "hour_rate_rent": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Hour Rate Rent"
          },
          "holiday_list": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Holiday List"
          },
          "custom_capacity_hours_per_day": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Capacity Hours Per Day"
          },
          "custom_utilization_target": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Utilization Target"
          },
          "custom_current_utilization": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Current Utilization"
          },
          "custom_operational_status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Operational Status"
          },
          "tags": {
            "default": [],
            "items": {
              "type": "string"
            },
            "title": "Tags",
            "type": "array"
          },
          "working_hours": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/WorkingHourSlot"
            },
            "title": "Working Hours",
            "type": "array"
          },
          "current_job": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Current Job"
          },
          "queue": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/QueuedJob"
            },
            "title": "Queue",
            "type": "array"
          },
          "schedule": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Schedule"
          },
          "history": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "History"
          }
        },
        "required": [
          "name",
          "workstation_name"
        ],
        "title": "WorkstationDetail",
        "type": "object"
      },
      "GetWorkstationLoadRequest": {
        "description": "Request for workstation load analysis",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "date_from": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Start date",
            "title": "Date From"
          },
          "date_to": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "End date",
            "title": "Date To"
          }
        },
        "title": "GetWorkstationLoadRequest",
        "type": "object"
      },
      "GetWorkstationLoadResponse": {
        "description": "Response for workstation load analysis",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Load analysis data",
            "title": "Data",
            "type": "object"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetWorkstationLoadResponse",
        "type": "object"
      },
      "GetWorkstationQueueRequest": {
        "description": "Request for workstation job queue",
        "properties": {
          "workstation_id": {
            "description": "Workstation ID",
            "title": "Workstation Id",
            "type": "string"
          },
          "days_ahead": {
            "default": 7,
            "description": "Days to look ahead",
            "maximum": 30,
            "minimum": 1,
            "title": "Days Ahead",
            "type": "integer"
          }
        },
        "required": [
          "workstation_id"
        ],
        "title": "GetWorkstationQueueRequest",
        "type": "object"
      },
      "GetWorkstationUtilizationRequest": {
        "description": "Request for workstation utilization report",
        "properties": {
          "workstation_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by workstation",
            "title": "Workstation Id"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "date_from": {
            "description": "Start date",
            "title": "Date From",
            "type": "string"
          },
          "date_to": {
            "description": "End date",
            "title": "Date To",
            "type": "string"
          },
          "group_by": {
            "default": "day",
            "description": "Group by: day, week, month",
            "title": "Group By",
            "type": "string"
          }
        },
        "required": [
          "date_from",
          "date_to"
        ],
        "title": "GetWorkstationUtilizationRequest",
        "type": "object"
      },
      "GetWorkstationsRequest": {
        "description": "Request for workstations list",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "tag_filter": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "JSON array of tag codes",
            "title": "Tag Filter"
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by status",
            "title": "Status"
          },
          "search": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Search name or description",
            "title": "Search"
          },
          "include_load": {
            "default": true,
            "description": "Include current load metrics",
            "title": "Include Load",
            "type": "boolean"
          },
          "include_queue": {
            "default": false,
            "description": "Include job queue preview",
            "title": "Include Queue",
            "type": "boolean"
          }
        },
        "title": "GetWorkstationsRequest",
        "type": "object"
      },
      "GetWorkstationsResponse": {
        "description": "Response for workstations list",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Workstations data with summary",
            "title": "Data",
            "type": "object"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetWorkstationsResponse",
        "type": "object"
      },
      "ReorderWorkstationQueueRequest": {
        "description": "Request for reordering workstation queue",
        "properties": {
          "workstation_id": {
            "description": "Workstation ID",
            "title": "Workstation Id",
            "type": "string"
          },
          "job_order": {
            "description": "JSON array of job card IDs in new order",
            "title": "Job Order",
            "type": "string"
          }
        },
        "required": [
          "workstation_id",
          "job_order"
        ],
        "title": "ReorderWorkstationQueueRequest",
        "type": "object"
      },
      "UpdateWorkstationCapacityRequest": {
        "description": "Request for updating workstation capacity",
        "properties": {
          "workstation_id": {
            "description": "Workstation ID",
            "title": "Workstation Id",
            "type": "string"
          },
          "capacity_hours_per_day": {
            "anyOf": [
              {
                "maximum": 24,
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Daily capacity hours",
            "title": "Capacity Hours Per Day"
          },
          "utilization_target": {
            "anyOf": [
              {
                "maximum": 100,
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Target utilization %",
            "title": "Utilization Target"
          }
        },
        "required": [
          "workstation_id"
        ],
        "title": "UpdateWorkstationCapacityRequest",
        "type": "object"
      },
      "UpdateWorkstationCapacityResponse": {
        "description": "Response for capacity update",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Updated workstation info",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Workstation capacity updated",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateWorkstationCapacityResponse",
        "type": "object"
      },
      "UpdateWorkstationStatusRequest": {
        "description": "Request for updating workstation status",
        "properties": {
          "workstation_id": {
            "description": "Workstation ID",
            "title": "Workstation Id",
            "type": "string"
          },
          "status": {
            "description": "New status",
            "title": "Status",
            "type": "string"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Status change reason",
            "title": "Reason"
          }
        },
        "required": [
          "workstation_id",
          "status"
        ],
        "title": "UpdateWorkstationStatusRequest",
        "type": "object"
      },
      "UpdateWorkstationStatusResponse": {
        "description": "Response for status update",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Updated workstation info",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Workstation status updated",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateWorkstationStatusResponse",
        "type": "object"
      },
      "UpdateWorkstationWorkingHoursRequest": {
        "description": "Request for updating workstation working hours",
        "properties": {
          "workstation_id": {
            "description": "Workstation ID",
            "title": "Workstation Id",
            "type": "string"
          },
          "working_hours": {
            "description": "JSON array of working hour slots",
            "title": "Working Hours",
            "type": "string"
          }
        },
        "required": [
          "workstation_id",
          "working_hours"
        ],
        "title": "UpdateWorkstationWorkingHoursRequest",
        "type": "object"
      },
      "UtilizationDataPoint": {
        "description": "Single utilization data point",
        "properties": {
          "date": {
            "title": "Date",
            "type": "string"
          },
          "workstation_id": {
            "title": "Workstation Id",
            "type": "string"
          },
          "workstation_name": {
            "title": "Workstation Name",
            "type": "string"
          },
          "available_hours": {
            "title": "Available Hours",
            "type": "number"
          },
          "utilized_hours": {
            "title": "Utilized Hours",
            "type": "number"
          },
          "utilization_rate": {
            "title": "Utilization Rate",
            "type": "number"
          }
        },
        "required": [
          "date",
          "workstation_id",
          "workstation_name",
          "available_hours",
          "utilized_hours",
          "utilization_rate"
        ],
        "title": "UtilizationDataPoint",
        "type": "object"
      },
      "WorkstationListItem": {
        "description": "Single workstation in list",
        "properties": {
          "name": {
            "description": "Workstation ID",
            "title": "Name",
            "type": "string"
          },
          "workstation_name": {
            "description": "Display name",
            "title": "Workstation Name",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Description"
          },
          "warehouse": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Location/warehouse",
            "title": "Warehouse"
          },
          "production_capacity": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Production Capacity"
          },
          "hour_rate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Hour Rate"
          },
          "hour_rate_labour": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Hour Rate Labour"
          },
          "hour_rate_electricity": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Hour Rate Electricity"
          },
          "hour_rate_rent": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Hour Rate Rent"
          },
          "custom_capacity_hours_per_day": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Capacity Hours Per Day"
          },
          "custom_utilization_target": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Utilization Target"
          },
          "custom_current_utilization": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Current Utilization"
          },
          "custom_operational_status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Operational Status"
          },
          "custom_powder_enabled": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Powder Enabled"
          },
          "custom_default_cure_profile": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Default Cure Profile"
          },
          "custom_max_batch_size": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Max Batch Size"
          },
          "custom_color_changeover_minutes": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Custom Color Changeover Minutes"
          },
          "tags": {
            "default": [],
            "items": {
              "type": "string"
            },
            "title": "Tags",
            "type": "array"
          },
          "working_hours": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/WorkingHourSlot"
            },
            "title": "Working Hours",
            "type": "array"
          },
          "current_load": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Current Load"
          },
          "queue_preview": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/QueuedJob"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Queue Preview"
          }
        },
        "required": [
          "name",
          "workstation_name"
        ],
        "title": "WorkstationListItem",
        "type": "object"
      },
      "WorkstationLoadData": {
        "description": "Workstation load analysis data",
        "properties": {
          "workstation_id": {
            "title": "Workstation Id",
            "type": "string"
          },
          "workstation_name": {
            "title": "Workstation Name",
            "type": "string"
          },
          "current_utilization": {
            "title": "Current Utilization",
            "type": "number"
          },
          "target_utilization": {
            "title": "Target Utilization",
            "type": "number"
          },
          "load_level": {
            "title": "Load Level",
            "type": "string"
          },
          "queued_hours": {
            "title": "Queued Hours",
            "type": "number"
          },
          "capacity_hours": {
            "title": "Capacity Hours",
            "type": "number"
          },
          "overload_hours": {
            "default": 0,
            "title": "Overload Hours",
            "type": "number"
          }
        },
        "required": [
          "workstation_id",
          "workstation_name",
          "current_utilization",
          "target_utilization",
          "load_level",
          "queued_hours",
          "capacity_hours"
        ],
        "title": "WorkstationLoadData",
        "type": "object"
      },
      "WorkstationQueueResponse": {
        "description": "Response for workstation queue",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Queue data",
            "title": "Data",
            "type": "object"
          }
        },
        "required": [
          "data"
        ],
        "title": "WorkstationQueueResponse",
        "type": "object"
      },
      "WorkstationSummary": {
        "description": "Workstation summary counts",
        "properties": {
          "available": {
            "default": 0,
            "title": "Available",
            "type": "integer"
          },
          "busy": {
            "default": 0,
            "title": "Busy",
            "type": "integer"
          },
          "maintenance": {
            "default": 0,
            "title": "Maintenance",
            "type": "integer"
          },
          "offline": {
            "default": 0,
            "title": "Offline",
            "type": "integer"
          }
        },
        "title": "WorkstationSummary",
        "type": "object"
      },
      "WorkstationTag": {
        "description": "Workstation tag/category",
        "properties": {
          "tag_category": {
            "description": "Tag category code",
            "title": "Tag Category",
            "type": "string"
          },
          "tag_label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Tag display label",
            "title": "Tag Label"
          }
        },
        "required": [
          "tag_category"
        ],
        "title": "WorkstationTag",
        "type": "object"
      },
      "CalculateFreightRequest": {
        "description": "Request for calculating freight cost",
        "properties": {
          "zone_code": {
            "description": "Freight zone code",
            "title": "Zone Code",
            "type": "string"
          },
          "order_total": {
            "description": "Order subtotal",
            "minimum": 0,
            "title": "Order Total",
            "type": "number"
          },
          "total_weight": {
            "anyOf": [
              {
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Total weight in kg",
            "title": "Total Weight"
          },
          "total_units": {
            "anyOf": [
              {
                "minimum": 0,
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Total units",
            "title": "Total Units"
          }
        },
        "required": [
          "zone_code",
          "order_total"
        ],
        "title": "CalculateFreightRequest",
        "type": "object"
      },
      "CalculateFreightResponse": {
        "description": "Response for freight calculation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Calculated freight",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Freight calculated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CalculateFreightResponse",
        "type": "object"
      },
      "CreateFreightZoneRequest": {
        "description": "Request for creating freight zone",
        "properties": {
          "zone": {
            "description": "JSON string of zone configuration",
            "title": "Zone",
            "type": "string"
          }
        },
        "required": [
          "zone"
        ],
        "title": "CreateFreightZoneRequest",
        "type": "object"
      },
      "CreateFreightZoneResponse": {
        "description": "Response for zone creation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/FreightZone",
            "description": "Created zone"
          },
          "message": {
            "default": "Freight zone created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CreateFreightZoneResponse",
        "type": "object"
      },
      "FreightZone": {
        "description": "Freight zone information",
        "properties": {
          "name": {
            "description": "Zone document name",
            "title": "Name",
            "type": "string"
          },
          "code": {
            "description": "Zone code",
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "rateType": {
            "description": "Rate type",
            "title": "Ratetype",
            "type": "string"
          },
          "flatRate": {
            "default": 0,
            "description": "Flat rate amount",
            "title": "Flatrate",
            "type": "number"
          },
          "isDefault": {
            "default": false,
            "description": "Is default zone",
            "title": "Isdefault",
            "type": "boolean"
          },
          "displayOrder": {
            "default": 0,
            "description": "Display order",
            "title": "Displayorder",
            "type": "integer"
          },
          "minDistanceKm": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Mindistancekm"
          },
          "maxDistanceKm": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Maxdistancekm"
          },
          "regions": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Regions"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Description"
          }
        },
        "required": [
          "name",
          "code",
          "label",
          "rateType"
        ],
        "title": "FreightZone",
        "type": "object"
      },
      "DeleteFreightZoneRequest": {
        "description": "Request for deleting freight zone",
        "properties": {
          "name": {
            "description": "Zone document name to delete",
            "title": "Name",
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "title": "DeleteFreightZoneRequest",
        "type": "object"
      },
      "DeleteFreightZoneResponse": {
        "description": "Response for zone deletion",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "Freight zone deleted successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "DeleteFreightZoneResponse",
        "type": "object"
      },
      "FreightZoneData": {
        "description": "Freight zone configuration data",
        "properties": {
          "code": {
            "description": "Zone code",
            "maxLength": 20,
            "minLength": 1,
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "rateType": {
            "description": "Rate type: Free, Flat Amount, Percentage, etc.",
            "title": "Ratetype",
            "type": "string"
          },
          "flatRate": {
            "default": 0,
            "description": "Flat rate amount",
            "minimum": 0,
            "title": "Flatrate",
            "type": "number"
          },
          "isDefault": {
            "default": false,
            "description": "Is default zone",
            "title": "Isdefault",
            "type": "boolean"
          },
          "displayOrder": {
            "default": 0,
            "description": "Display order",
            "minimum": 0,
            "title": "Displayorder",
            "type": "integer"
          },
          "minDistanceKm": {
            "anyOf": [
              {
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Minimum distance in km",
            "title": "Mindistancekm"
          },
          "maxDistanceKm": {
            "anyOf": [
              {
                "minimum": 0,
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Maximum distance in km",
            "title": "Maxdistancekm"
          },
          "regions": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Comma-separated region codes",
            "title": "Regions"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Zone description",
            "title": "Description"
          }
        },
        "required": [
          "code",
          "label",
          "rateType"
        ],
        "title": "FreightZoneData",
        "type": "object"
      },
      "GetDefaultZoneRequest": {
        "description": "Request for default freight zone",
        "properties": {},
        "title": "GetDefaultZoneRequest",
        "type": "object"
      },
      "GetDefaultZoneResponse": {
        "description": "Response for default zone",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FreightZone"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Default zone or null"
          },
          "message": {
            "default": "Default zone retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "GetDefaultZoneResponse",
        "type": "object"
      },
      "GetFreightZonesRequest": {
        "description": "Request for freight zones list",
        "properties": {
          "active_only": {
            "default": true,
            "description": "Only return active zones",
            "title": "Active Only",
            "type": "boolean"
          }
        },
        "title": "GetFreightZonesRequest",
        "type": "object"
      },
      "GetFreightZonesResponse": {
        "description": "Response for freight zones list",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Zones data",
            "title": "Data",
            "type": "object"
          },
          "count": {
            "description": "Total count",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Freight zones retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetFreightZonesResponse",
        "type": "object"
      },
      "GetZoneByDistanceRequest": {
        "description": "Request for zone lookup by distance",
        "properties": {
          "distance_km": {
            "description": "Distance in kilometers",
            "minimum": 0,
            "title": "Distance Km",
            "type": "number"
          }
        },
        "required": [
          "distance_km"
        ],
        "title": "GetZoneByDistanceRequest",
        "type": "object"
      },
      "GetZoneByDistanceResponse": {
        "description": "Response for zone lookup by distance",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FreightZone"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Matching zone or null"
          },
          "message": {
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "message"
        ],
        "title": "GetZoneByDistanceResponse",
        "type": "object"
      },
      "SetDefaultZoneRequest": {
        "description": "Request for setting default zone",
        "properties": {
          "zone_code": {
            "description": "Zone code to set as default",
            "title": "Zone Code",
            "type": "string"
          }
        },
        "required": [
          "zone_code"
        ],
        "title": "SetDefaultZoneRequest",
        "type": "object"
      },
      "UpdateFreightZoneRequest": {
        "description": "Request for updating freight zone",
        "properties": {
          "name": {
            "description": "Zone document name to update",
            "title": "Name",
            "type": "string"
          },
          "zone": {
            "description": "JSON string of updated configuration",
            "title": "Zone",
            "type": "string"
          }
        },
        "required": [
          "name",
          "zone"
        ],
        "title": "UpdateFreightZoneRequest",
        "type": "object"
      },
      "UpdateFreightZoneResponse": {
        "description": "Response for zone update",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/FreightZone",
            "description": "Updated zone"
          },
          "message": {
            "default": "Freight zone updated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateFreightZoneResponse",
        "type": "object"
      },
      "CalculateChargesData": {
        "description": "Calculated charges data",
        "properties": {
          "baseAmount": {
            "title": "Baseamount",
            "type": "number"
          },
          "charges": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/CalculatedCharge"
            },
            "title": "Charges",
            "type": "array"
          },
          "totalTax": {
            "default": 0,
            "title": "Totaltax",
            "type": "number"
          },
          "totalFees": {
            "default": 0,
            "title": "Totalfees",
            "type": "number"
          },
          "lineTotal": {
            "default": 0,
            "title": "Linetotal",
            "type": "number"
          }
        },
        "required": [
          "baseAmount"
        ],
        "title": "CalculateChargesData",
        "type": "object"
      },
      "CalculatedCharge": {
        "description": "Result of charge calculation",
        "properties": {
          "category": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Category"
          },
          "chargeType": {
            "title": "Chargetype",
            "type": "string"
          },
          "rate": {
            "title": "Rate",
            "type": "number"
          },
          "amount": {
            "description": "Calculated amount",
            "title": "Amount",
            "type": "number"
          },
          "isTax": {
            "default": false,
            "title": "Istax",
            "type": "boolean"
          }
        },
        "required": [
          "chargeType",
          "rate",
          "amount"
        ],
        "title": "CalculatedCharge",
        "type": "object"
      },
      "CalculateChargesRequest": {
        "description": "Request for calculating charges",
        "properties": {
          "base_amount": {
            "description": "Line item amount (qty \u00d7 rate)",
            "minimum": 0,
            "title": "Base Amount",
            "type": "number"
          },
          "charges": {
            "description": "JSON array of charge objects",
            "title": "Charges",
            "type": "string"
          }
        },
        "required": [
          "base_amount",
          "charges"
        ],
        "title": "CalculateChargesRequest",
        "type": "object"
      },
      "CalculateChargesResponse": {
        "description": "Response for charge calculation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/CalculateChargesData",
            "description": "Calculated charges"
          },
          "message": {
            "default": "Charges calculated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CalculateChargesResponse",
        "type": "object"
      },
      "ChargeItem": {
        "description": "Single charge for calculation",
        "properties": {
          "category": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Category code",
            "title": "Category"
          },
          "chargeType": {
            "default": "Percentage",
            "description": "Charge type",
            "title": "Chargetype",
            "type": "string"
          },
          "rate": {
            "description": "Rate value",
            "title": "Rate",
            "type": "number"
          },
          "isTax": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Is tax (looked up if not provided)",
            "title": "Istax"
          }
        },
        "required": [
          "rate"
        ],
        "title": "ChargeItem",
        "type": "object"
      },
      "CreateTaxFeeCategoryRequest": {
        "description": "Request for creating tax/fee category",
        "properties": {
          "category": {
            "description": "JSON string of category data",
            "title": "Category",
            "type": "string"
          }
        },
        "required": [
          "category"
        ],
        "title": "CreateTaxFeeCategoryRequest",
        "type": "object"
      },
      "CreateTaxFeeCategoryResponse": {
        "description": "Response for category creation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/TaxFeeCategoryInfo",
            "description": "Created category"
          },
          "message": {
            "default": "Tax/fee category created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CreateTaxFeeCategoryResponse",
        "type": "object"
      },
      "TaxFeeCategoryInfo": {
        "description": "Tax/fee category information",
        "properties": {
          "name": {
            "description": "Category document name",
            "title": "Name",
            "type": "string"
          },
          "code": {
            "description": "Category code",
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "chargeType": {
            "description": "Percentage or Flat Amount",
            "title": "Chargetype",
            "type": "string"
          },
          "defaultRate": {
            "default": 0,
            "description": "Default rate",
            "title": "Defaultrate",
            "type": "number"
          },
          "isTax": {
            "description": "Is tax (vs fee)",
            "title": "Istax",
            "type": "boolean"
          },
          "isDefaultTax": {
            "default": false,
            "description": "Auto-add to new items",
            "title": "Isdefaulttax",
            "type": "boolean"
          },
          "displayOrder": {
            "default": 0,
            "description": "Display order",
            "title": "Displayorder",
            "type": "integer"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Description"
          }
        },
        "required": [
          "name",
          "code",
          "label",
          "chargeType",
          "isTax"
        ],
        "title": "TaxFeeCategoryInfo",
        "type": "object"
      },
      "DeleteTaxFeeCategoryRequest": {
        "description": "Request for deleting tax/fee category",
        "properties": {
          "name": {
            "description": "Category document name to delete",
            "title": "Name",
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "title": "DeleteTaxFeeCategoryRequest",
        "type": "object"
      },
      "DeleteTaxFeeCategoryResponse": {
        "description": "Response for category deletion",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "Tax/fee category deactivated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "DeleteTaxFeeCategoryResponse",
        "type": "object"
      },
      "GetDefaultTaxesRequest": {
        "description": "Request for default taxes list (no parameters needed)",
        "properties": {},
        "title": "GetDefaultTaxesRequest",
        "type": "object"
      },
      "GetDefaultTaxesResponse": {
        "description": "Response for default taxes list",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "Default taxes",
            "items": {
              "$ref": "#/components/schemas/TaxFeeCategoryInfo"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Total count",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Default taxes retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetDefaultTaxesResponse",
        "type": "object"
      },
      "GetQuotationTaxDetailRequest": {
        "description": "Request for quotation tax detail",
        "properties": {
          "quotation_id": {
            "description": "Quotation document ID",
            "title": "Quotation Id",
            "type": "string"
          }
        },
        "required": [
          "quotation_id"
        ],
        "title": "GetQuotationTaxDetailRequest",
        "type": "object"
      },
      "GetQuotationTaxDetailResponse": {
        "description": "Response for quotation tax detail",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/QuotationTaxDetailData",
            "description": "Tax detail data"
          },
          "message": {
            "default": "Quotation tax detail retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetQuotationTaxDetailResponse",
        "type": "object"
      },
      "ItemChargeDetail": {
        "description": "Charge detail for single quote item",
        "properties": {
          "category": {
            "title": "Category",
            "type": "string"
          },
          "label": {
            "title": "Label",
            "type": "string"
          },
          "chargeType": {
            "title": "Chargetype",
            "type": "string"
          },
          "rate": {
            "title": "Rate",
            "type": "number"
          },
          "amount": {
            "title": "Amount",
            "type": "number"
          },
          "isTax": {
            "title": "Istax",
            "type": "boolean"
          }
        },
        "required": [
          "category",
          "label",
          "chargeType",
          "rate",
          "amount",
          "isTax"
        ],
        "title": "ItemChargeDetail",
        "type": "object"
      },
      "QuotationItemDetail": {
        "description": "Quote item with tax/fee breakdown",
        "properties": {
          "idx": {
            "title": "Idx",
            "type": "integer"
          },
          "itemCode": {
            "title": "Itemcode",
            "type": "string"
          },
          "itemName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Itemname"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Description"
          },
          "qty": {
            "default": 0,
            "title": "Qty",
            "type": "number"
          },
          "rate": {
            "default": 0,
            "title": "Rate",
            "type": "number"
          },
          "amount": {
            "default": 0,
            "title": "Amount",
            "type": "number"
          },
          "charges": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/ItemChargeDetail"
            },
            "title": "Charges",
            "type": "array"
          },
          "totalTax": {
            "default": 0,
            "title": "Totaltax",
            "type": "number"
          },
          "totalFees": {
            "default": 0,
            "title": "Totalfees",
            "type": "number"
          },
          "lineTotal": {
            "default": 0,
            "title": "Linetotal",
            "type": "number"
          }
        },
        "required": [
          "idx",
          "itemCode"
        ],
        "title": "QuotationItemDetail",
        "type": "object"
      },
      "QuotationTaxDetailData": {
        "description": "Quotation tax detail data",
        "properties": {
          "quotationId": {
            "title": "Quotationid",
            "type": "string"
          },
          "items": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/QuotationItemDetail"
            },
            "title": "Items",
            "type": "array"
          },
          "summary": {
            "$ref": "#/components/schemas/QuotationTaxSummary"
          }
        },
        "required": [
          "quotationId",
          "summary"
        ],
        "title": "QuotationTaxDetailData",
        "type": "object"
      },
      "QuotationTaxSummary": {
        "description": "Quotation tax summary",
        "properties": {
          "subtotal": {
            "default": 0,
            "title": "Subtotal",
            "type": "number"
          },
          "totalTax": {
            "default": 0,
            "title": "Totaltax",
            "type": "number"
          },
          "totalFees": {
            "default": 0,
            "title": "Totalfees",
            "type": "number"
          },
          "grandTotal": {
            "default": 0,
            "title": "Grandtotal",
            "type": "number"
          },
          "taxBreakdown": {
            "default": [],
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Taxbreakdown",
            "type": "array"
          }
        },
        "title": "QuotationTaxSummary",
        "type": "object"
      },
      "GetTaxFeeCategoriesRequest": {
        "description": "Request for tax/fee categories list (no parameters needed)",
        "properties": {},
        "title": "GetTaxFeeCategoriesRequest",
        "type": "object"
      },
      "GetTaxFeeCategoriesResponse": {
        "description": "Response for tax/fee categories list",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Categories data",
            "title": "Data",
            "type": "object"
          },
          "count": {
            "description": "Total count",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Tax/fee categories retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetTaxFeeCategoriesResponse",
        "type": "object"
      },
      "GetTaxReportRequest": {
        "description": "Request for tax report",
        "properties": {
          "start_date": {
            "description": "Start date (YYYY-MM-DD)",
            "title": "Start Date",
            "type": "string"
          },
          "end_date": {
            "description": "End date (YYYY-MM-DD)",
            "title": "End Date",
            "type": "string"
          },
          "category": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by category code",
            "title": "Category"
          },
          "is_tax_only": {
            "default": 1,
            "description": "1=taxes only, 0=all charges",
            "title": "Is Tax Only",
            "type": "integer"
          }
        },
        "required": [
          "start_date",
          "end_date"
        ],
        "title": "GetTaxReportRequest",
        "type": "object"
      },
      "GetTaxReportResponse": {
        "description": "Response for tax report",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/TaxReportData",
            "description": "Report data"
          },
          "message": {
            "default": "Tax report generated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetTaxReportResponse",
        "type": "object"
      },
      "TaxBreakdownItem": {
        "description": "Tax breakdown in report",
        "properties": {
          "category": {
            "title": "Category",
            "type": "string"
          },
          "label": {
            "title": "Label",
            "type": "string"
          },
          "isTax": {
            "default": true,
            "title": "Istax",
            "type": "boolean"
          },
          "total": {
            "title": "Total",
            "type": "number"
          },
          "count": {
            "default": 0,
            "title": "Count",
            "type": "integer"
          }
        },
        "required": [
          "category",
          "label",
          "total"
        ],
        "title": "TaxBreakdownItem",
        "type": "object"
      },
      "TaxReportData": {
        "description": "Tax report data",
        "properties": {
          "period": {
            "$ref": "#/components/schemas/TaxReportPeriod"
          },
          "breakdown": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/TaxBreakdownItem"
            },
            "title": "Breakdown",
            "type": "array"
          },
          "grandTotal": {
            "default": 0,
            "title": "Grandtotal",
            "type": "number"
          },
          "quoteCount": {
            "default": 0,
            "title": "Quotecount",
            "type": "integer"
          }
        },
        "required": [
          "period"
        ],
        "title": "TaxReportData",
        "type": "object"
      },
      "TaxReportPeriod": {
        "description": "Tax report period",
        "properties": {
          "start": {
            "title": "Start",
            "type": "string"
          },
          "end": {
            "title": "End",
            "type": "string"
          }
        },
        "required": [
          "start",
          "end"
        ],
        "title": "TaxReportPeriod",
        "type": "object"
      },
      "ResetTaxFeeCategoriesRequest": {
        "description": "Request for resetting categories to defaults (no parameters needed)",
        "properties": {},
        "title": "ResetTaxFeeCategoriesRequest",
        "type": "object"
      },
      "ResetTaxFeeCategoriesResponse": {
        "description": "Response for categories reset",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Reset summary",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "message"
        ],
        "title": "ResetTaxFeeCategoriesResponse",
        "type": "object"
      },
      "TaxFeeCategoryData": {
        "description": "Tax/fee category configuration data",
        "properties": {
          "code": {
            "description": "Category code",
            "maxLength": 20,
            "minLength": 1,
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "chargeType": {
            "default": "Percentage",
            "description": "Percentage or Flat Amount",
            "title": "Chargetype",
            "type": "string"
          },
          "defaultRate": {
            "default": 0,
            "description": "Default rate",
            "minimum": 0,
            "title": "Defaultrate",
            "type": "number"
          },
          "isTax": {
            "default": true,
            "description": "Is tax (vs fee)",
            "title": "Istax",
            "type": "boolean"
          },
          "isDefaultTax": {
            "default": false,
            "description": "Auto-add to new items",
            "title": "Isdefaulttax",
            "type": "boolean"
          },
          "displayOrder": {
            "default": 0,
            "description": "Display order",
            "minimum": 0,
            "title": "Displayorder",
            "type": "integer"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Category description",
            "title": "Description"
          }
        },
        "required": [
          "code",
          "label"
        ],
        "title": "TaxFeeCategoryData",
        "type": "object"
      },
      "UpdateTaxFeeCategoryRequest": {
        "description": "Request for updating tax/fee category",
        "properties": {
          "name": {
            "description": "Category document name to update",
            "title": "Name",
            "type": "string"
          },
          "category": {
            "description": "JSON string of updated configuration",
            "title": "Category",
            "type": "string"
          }
        },
        "required": [
          "name",
          "category"
        ],
        "title": "UpdateTaxFeeCategoryRequest",
        "type": "object"
      },
      "UpdateTaxFeeCategoryResponse": {
        "description": "Response for category update",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/TaxFeeCategoryInfo",
            "description": "Updated category"
          },
          "message": {
            "default": "Tax/fee category updated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateTaxFeeCategoryResponse",
        "type": "object"
      },
      "CreateMillCertificateData": {
        "description": "Created mill certificate data",
        "properties": {
          "name": {
            "title": "Name",
            "type": "string"
          },
          "certificate_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Certificate Number"
          },
          "file": {
            "title": "File",
            "type": "string"
          },
          "purchase_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Purchase Order"
          },
          "supplier_info": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Supplier Info"
          },
          "creation": {
            "title": "Creation",
            "type": "string"
          }
        },
        "required": [
          "name",
          "file",
          "creation"
        ],
        "title": "CreateMillCertificateData",
        "type": "object"
      },
      "CreateMillCertificateRequest": {
        "description": "Request for creating mill certificate",
        "properties": {
          "file_url": {
            "description": "URL of uploaded file (required)",
            "title": "File Url",
            "type": "string"
          },
          "certificate_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Vendor's certificate number",
            "title": "Certificate Number"
          },
          "purchase_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Link to Purchase Order",
            "title": "Purchase Order"
          }
        },
        "required": [
          "file_url"
        ],
        "title": "CreateMillCertificateRequest",
        "type": "object"
      },
      "CreateMillCertificateResponse": {
        "description": "Response for mill certificate creation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/CreateMillCertificateData",
            "description": "Created certificate"
          },
          "message": {
            "default": "Mill certificate created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CreateMillCertificateResponse",
        "type": "object"
      },
      "GetMillCertificateDetailRequest": {
        "description": "Request for mill certificate detail",
        "properties": {
          "name": {
            "description": "Mill Certificate name (e.g., MC-00001)",
            "title": "Name",
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "title": "GetMillCertificateDetailRequest",
        "type": "object"
      },
      "GetMillCertificateDetailResponse": {
        "description": "Response for mill certificate detail",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/MillCertificateDetail",
            "description": "Certificate details"
          },
          "message": {
            "default": "Mill certificate retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetMillCertificateDetailResponse",
        "type": "object"
      },
      "MillCertificateDetail": {
        "description": "Detailed mill certificate information",
        "properties": {
          "name": {
            "title": "Name",
            "type": "string"
          },
          "certificate_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Certificate Number"
          },
          "file": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "File"
          },
          "purchase_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Purchase Order"
          },
          "supplier_info": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Supplier Info"
          },
          "creation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Creation"
          },
          "modified": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Modified"
          },
          "batch_count": {
            "default": 0,
            "description": "Number of linked batches",
            "title": "Batch Count",
            "type": "integer"
          },
          "has_file": {
            "default": false,
            "title": "Has File",
            "type": "boolean"
          }
        },
        "required": [
          "name"
        ],
        "title": "MillCertificateDetail",
        "type": "object"
      },
      "GetRecentMillCertificatesRequest": {
        "description": "Request for recent mill certificates",
        "properties": {
          "limit": {
            "default": 10,
            "description": "Maximum results (default 10)",
            "maximum": 50,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          },
          "search": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Search by certificate number",
            "title": "Search"
          },
          "purchase_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by purchase order",
            "title": "Purchase Order"
          }
        },
        "title": "GetRecentMillCertificatesRequest",
        "type": "object"
      },
      "GetRecentMillCertificatesResponse": {
        "description": "Response for recent mill certificates",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "Mill certificates list",
            "items": {
              "$ref": "#/components/schemas/MillCertificateInfo"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Total count",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Mill certificates retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetRecentMillCertificatesResponse",
        "type": "object"
      },
      "MillCertificateInfo": {
        "description": "Mill certificate information",
        "properties": {
          "name": {
            "description": "Mill Certificate ID (e.g., MC-00001)",
            "title": "Name",
            "type": "string"
          },
          "certificate_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Vendor's certificate number",
            "title": "Certificate Number"
          },
          "file": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "File URL",
            "title": "File"
          },
          "purchase_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked Purchase Order",
            "title": "Purchase Order"
          },
          "supplier_info": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Supplier information",
            "title": "Supplier Info"
          },
          "creation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Creation"
          },
          "has_file": {
            "default": false,
            "description": "Whether file is attached",
            "title": "Has File",
            "type": "boolean"
          }
        },
        "required": [
          "name"
        ],
        "title": "MillCertificateInfo",
        "type": "object"
      },
      "MillCertificateSearchResult": {
        "description": "Search result for mill certificate",
        "properties": {
          "name": {
            "title": "Name",
            "type": "string"
          },
          "certificate_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Certificate Number"
          },
          "file": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "File"
          },
          "purchase_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Purchase Order"
          },
          "creation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Creation"
          },
          "display_label": {
            "description": "Formatted display label",
            "title": "Display Label",
            "type": "string"
          },
          "has_file": {
            "default": false,
            "title": "Has File",
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "display_label"
        ],
        "title": "MillCertificateSearchResult",
        "type": "object"
      },
      "SearchMillCertificatesRequest": {
        "description": "Request for searching mill certificates",
        "properties": {
          "query": {
            "description": "Search term (min 2 chars)",
            "minLength": 2,
            "title": "Query",
            "type": "string"
          },
          "limit": {
            "default": 10,
            "description": "Maximum results (default 10)",
            "maximum": 20,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          }
        },
        "required": [
          "query"
        ],
        "title": "SearchMillCertificatesRequest",
        "type": "object"
      },
      "SearchMillCertificatesResponse": {
        "description": "Response for mill certificate search",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "Search results",
            "items": {
              "$ref": "#/components/schemas/MillCertificateSearchResult"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Result count",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Search completed",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "SearchMillCertificatesResponse",
        "type": "object"
      },
      "UpdateMillCertificateData": {
        "description": "Updated mill certificate data",
        "properties": {
          "name": {
            "title": "Name",
            "type": "string"
          },
          "certificate_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Certificate Number"
          },
          "file": {
            "title": "File",
            "type": "string"
          },
          "purchase_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Purchase Order"
          },
          "supplier_info": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Supplier Info"
          },
          "modified": {
            "title": "Modified",
            "type": "string"
          }
        },
        "required": [
          "name",
          "file",
          "modified"
        ],
        "title": "UpdateMillCertificateData",
        "type": "object"
      },
      "UpdateMillCertificateRequest": {
        "description": "Request for updating mill certificate",
        "properties": {
          "name": {
            "description": "Mill Certificate name",
            "title": "Name",
            "type": "string"
          },
          "certificate_number": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated certificate number",
            "title": "Certificate Number"
          },
          "purchase_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated purchase order link",
            "title": "Purchase Order"
          }
        },
        "required": [
          "name"
        ],
        "title": "UpdateMillCertificateRequest",
        "type": "object"
      },
      "UpdateMillCertificateResponse": {
        "description": "Response for mill certificate update",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/UpdateMillCertificateData",
            "description": "Updated certificate"
          },
          "message": {
            "default": "Mill certificate updated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateMillCertificateResponse",
        "type": "object"
      },
      "AllocateMaterialMobileRequest": {
        "description": "Request for mobile material allocation",
        "properties": {
          "job_card_id": {
            "description": "Job Card ID",
            "title": "Job Card Id",
            "type": "string"
          },
          "batch_no": {
            "description": "Batch number",
            "title": "Batch No",
            "type": "string"
          },
          "qty": {
            "description": "Quantity to allocate",
            "exclusiveMinimum": 0,
            "title": "Qty",
            "type": "number"
          }
        },
        "required": [
          "job_card_id",
          "batch_no",
          "qty"
        ],
        "title": "AllocateMaterialMobileRequest",
        "type": "object"
      },
      "AllocateMaterialMobileResponse": {
        "description": "Response for mobile material allocation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "severity": {
            "default": "success",
            "title": "Severity",
            "type": "string"
          },
          "icon": {
            "default": "\u2713",
            "title": "Icon",
            "type": "string"
          },
          "color": {
            "default": "#10b981",
            "title": "Color",
            "type": "string"
          },
          "title": {
            "default": "\u2713 Material Allocated",
            "title": "Title",
            "type": "string"
          },
          "message": {
            "default": "Material ready to use",
            "title": "Message",
            "type": "string"
          },
          "details": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Details"
          },
          "haptic": {
            "default": "success",
            "title": "Haptic",
            "type": "string"
          }
        },
        "title": "AllocateMaterialMobileResponse",
        "type": "object"
      },
      "CheckCameraPermissionsResponse": {
        "description": "Response for camera permissions check",
        "properties": {
          "camera_available": {
            "default": true,
            "title": "Camera Available",
            "type": "boolean"
          },
          "message": {
            "default": "Camera access ready",
            "title": "Message",
            "type": "string"
          },
          "api_version": {
            "default": "1.0",
            "title": "Api Version",
            "type": "string"
          },
          "scan_endpoint": {
            "default": "/api/method/pacific_bending_app.api.shop_floor_mobile.validate_material_scan_mobile",
            "title": "Scan Endpoint",
            "type": "string"
          }
        },
        "title": "CheckCameraPermissionsResponse",
        "type": "object"
      },
      "GetQRFormatExamplesResponse": {
        "description": "Response for QR format examples",
        "properties": {
          "formats": {
            "description": "Supported QR formats",
            "items": {
              "$ref": "#/components/schemas/QRFormatExample"
            },
            "title": "Formats",
            "type": "array"
          },
          "tips": {
            "description": "Scanning tips for users",
            "items": {
              "type": "string"
            },
            "title": "Tips",
            "type": "array"
          }
        },
        "required": [
          "formats",
          "tips"
        ],
        "title": "GetQRFormatExamplesResponse",
        "type": "object"
      },
      "QRFormatExample": {
        "description": "QR code format example",
        "properties": {
          "name": {
            "description": "Format name",
            "title": "Name",
            "type": "string"
          },
          "pattern": {
            "description": "Pattern description",
            "title": "Pattern",
            "type": "string"
          },
          "example": {
            "description": "Example value",
            "title": "Example",
            "type": "string"
          },
          "description": {
            "description": "Format description",
            "title": "Description",
            "type": "string"
          }
        },
        "required": [
          "name",
          "pattern",
          "example",
          "description"
        ],
        "title": "QRFormatExample",
        "type": "object"
      },
      "MobileScanErrorResponse": {
        "description": "Mobile-optimized error response for material scan",
        "properties": {
          "valid": {
            "default": false,
            "title": "Valid",
            "type": "boolean"
          },
          "severity": {
            "default": "error",
            "title": "Severity",
            "type": "string"
          },
          "icon": {
            "default": "\u2717",
            "title": "Icon",
            "type": "string"
          },
          "color": {
            "default": "#ef4444",
            "title": "Color",
            "type": "string"
          },
          "title": {
            "description": "Error title with icon",
            "title": "Title",
            "type": "string"
          },
          "message": {
            "description": "Error message for display",
            "title": "Message",
            "type": "string"
          },
          "error_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Error classification",
            "title": "Error Type"
          },
          "details": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ScanDetails"
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "action": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ScanAction"
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "haptic": {
            "default": "error",
            "title": "Haptic",
            "type": "string"
          }
        },
        "required": [
          "title",
          "message"
        ],
        "title": "MobileScanErrorResponse",
        "type": "object"
      },
      "ScanAction": {
        "description": "Suggested action after scan",
        "properties": {
          "label": {
            "description": "Button label",
            "title": "Label",
            "type": "string"
          },
          "type": {
            "default": "primary",
            "description": "Action type: primary, secondary, danger",
            "title": "Type",
            "type": "string"
          }
        },
        "required": [
          "label"
        ],
        "title": "ScanAction",
        "type": "object"
      },
      "ScanDetails": {
        "description": "Scan result details",
        "properties": {
          "batch_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Batch Id"
          },
          "qty_info": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Qty Info"
          },
          "warehouse": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Warehouse"
          },
          "expected_items": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Expected Items"
          },
          "scanned_item": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Scanned Item"
          },
          "correlation_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Correlation Id"
          }
        },
        "title": "ScanDetails",
        "type": "object"
      },
      "MobileScanSuccessResponse": {
        "description": "Mobile-optimized success response for material scan",
        "properties": {
          "valid": {
            "default": true,
            "title": "Valid",
            "type": "boolean"
          },
          "severity": {
            "default": "success",
            "title": "Severity",
            "type": "string"
          },
          "icon": {
            "default": "\u2713",
            "title": "Icon",
            "type": "string"
          },
          "color": {
            "default": "#10b981",
            "title": "Color",
            "type": "string"
          },
          "title": {
            "description": "Short title with icon",
            "title": "Title",
            "type": "string"
          },
          "message": {
            "description": "Brief message for display",
            "title": "Message",
            "type": "string"
          },
          "details": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ScanDetails"
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "action": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ScanAction"
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "haptic": {
            "default": "success",
            "title": "Haptic",
            "type": "string"
          }
        },
        "required": [
          "title",
          "message"
        ],
        "title": "MobileScanSuccessResponse",
        "type": "object"
      },
      "ValidateMaterialScanMobileRequest": {
        "description": "Request for mobile material scan validation",
        "properties": {
          "job_card_id": {
            "description": "Job Card document name",
            "title": "Job Card Id",
            "type": "string"
          },
          "batch_no": {
            "description": "Scanned batch number from QR code",
            "title": "Batch No",
            "type": "string"
          }
        },
        "required": [
          "job_card_id",
          "batch_no"
        ],
        "title": "ValidateMaterialScanMobileRequest",
        "type": "object"
      },
      "Bottleneck": {
        "description": "Production bottleneck",
        "properties": {
          "workstation": {
            "title": "Workstation",
            "type": "string"
          },
          "pending_jobs": {
            "title": "Pending Jobs",
            "type": "integer"
          },
          "severity": {
            "description": "high or medium",
            "title": "Severity",
            "type": "string"
          }
        },
        "required": [
          "workstation",
          "pending_jobs",
          "severity"
        ],
        "title": "Bottleneck",
        "type": "object"
      },
      "CapacityAvailabilityData": {
        "description": "Capacity availability data",
        "properties": {
          "by_workstation": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/WorkstationCapacity"
            },
            "title": "By Workstation",
            "type": "array"
          },
          "by_date": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/DailyCapacity"
            },
            "title": "By Date",
            "type": "array"
          },
          "total_capacity_hours": {
            "default": 0,
            "title": "Total Capacity Hours",
            "type": "number"
          },
          "total_scheduled_hours": {
            "default": 0,
            "title": "Total Scheduled Hours",
            "type": "number"
          },
          "total_available_hours": {
            "default": 0,
            "title": "Total Available Hours",
            "type": "number"
          },
          "utilization_percent": {
            "default": 0,
            "title": "Utilization Percent",
            "type": "number"
          },
          "period": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Period"
          }
        },
        "title": "CapacityAvailabilityData",
        "type": "object"
      },
      "DailyCapacity": {
        "description": "Capacity data for a specific date",
        "properties": {
          "date": {
            "title": "Date",
            "type": "string"
          },
          "day_name": {
            "title": "Day Name",
            "type": "string"
          },
          "capacity_hours": {
            "title": "Capacity Hours",
            "type": "number"
          },
          "scheduled_hours": {
            "title": "Scheduled Hours",
            "type": "number"
          },
          "available_hours": {
            "title": "Available Hours",
            "type": "number"
          },
          "job_count": {
            "title": "Job Count",
            "type": "integer"
          },
          "utilization_percent": {
            "title": "Utilization Percent",
            "type": "number"
          }
        },
        "required": [
          "date",
          "day_name",
          "capacity_hours",
          "scheduled_hours",
          "available_hours",
          "job_count",
          "utilization_percent"
        ],
        "title": "DailyCapacity",
        "type": "object"
      },
      "WorkstationCapacity": {
        "description": "Capacity data for a workstation",
        "properties": {
          "workstation_id": {
            "title": "Workstation Id",
            "type": "string"
          },
          "workstation_name": {
            "title": "Workstation Name",
            "type": "string"
          },
          "capacity_per_day": {
            "default": 8,
            "title": "Capacity Per Day",
            "type": "number"
          },
          "total_capacity_hours": {
            "title": "Total Capacity Hours",
            "type": "number"
          },
          "scheduled_hours": {
            "title": "Scheduled Hours",
            "type": "number"
          },
          "available_hours": {
            "title": "Available Hours",
            "type": "number"
          },
          "job_count": {
            "default": 0,
            "title": "Job Count",
            "type": "integer"
          },
          "utilization_percent": {
            "title": "Utilization Percent",
            "type": "number"
          },
          "status": {
            "description": "available, busy, or overloaded",
            "title": "Status",
            "type": "string"
          }
        },
        "required": [
          "workstation_id",
          "workstation_name",
          "total_capacity_hours",
          "scheduled_hours",
          "available_hours",
          "utilization_percent",
          "status"
        ],
        "title": "WorkstationCapacity",
        "type": "object"
      },
      "CreateProductionPlanRequest": {
        "description": "Request for creating production plan",
        "properties": {
          "work_order_ids": {
            "description": "JSON array of work order IDs",
            "title": "Work Order Ids",
            "type": "string"
          },
          "plan_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Name for the plan (auto-generated if not provided)",
            "title": "Plan Name"
          },
          "target_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Target completion date",
            "title": "Target Date"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Plan notes",
            "title": "Notes"
          }
        },
        "required": [
          "work_order_ids"
        ],
        "title": "CreateProductionPlanRequest",
        "type": "object"
      },
      "CreateProductionPlanResponse": {
        "description": "Response for production plan creation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/ProductionPlanData",
            "description": "Created plan"
          },
          "message": {
            "default": "Production plan created",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CreateProductionPlanResponse",
        "type": "object"
      },
      "ProductionPlanData": {
        "description": "Production plan data",
        "properties": {
          "plan_name": {
            "title": "Plan Name",
            "type": "string"
          },
          "work_orders": {
            "default": [],
            "items": {
              "type": "string"
            },
            "title": "Work Orders",
            "type": "array"
          },
          "target_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Target Date"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Notes"
          },
          "total_qty": {
            "default": 0,
            "title": "Total Qty",
            "type": "number"
          },
          "total_items": {
            "default": 0,
            "title": "Total Items",
            "type": "integer"
          },
          "items_summary": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/ProductionPlanItem"
            },
            "title": "Items Summary",
            "type": "array"
          },
          "created_by": {
            "title": "Created By",
            "type": "string"
          },
          "created_at": {
            "title": "Created At",
            "type": "string"
          },
          "status": {
            "default": "Draft",
            "title": "Status",
            "type": "string"
          }
        },
        "required": [
          "plan_name",
          "created_by",
          "created_at"
        ],
        "title": "ProductionPlanData",
        "type": "object"
      },
      "ProductionPlanItem": {
        "description": "Item summary in production plan",
        "properties": {
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "total_qty": {
            "title": "Total Qty",
            "type": "number"
          },
          "work_order_count": {
            "title": "Work Order Count",
            "type": "integer"
          }
        },
        "required": [
          "item_code",
          "item_name",
          "total_qty",
          "work_order_count"
        ],
        "title": "ProductionPlanItem",
        "type": "object"
      },
      "DemandByDate": {
        "description": "Aggregated demand by date",
        "properties": {
          "date": {
            "title": "Date",
            "type": "string"
          },
          "qty": {
            "title": "Qty",
            "type": "number"
          },
          "value": {
            "title": "Value",
            "type": "number"
          },
          "orders": {
            "title": "Orders",
            "type": "integer"
          }
        },
        "required": [
          "date",
          "qty",
          "value",
          "orders"
        ],
        "title": "DemandByDate",
        "type": "object"
      },
      "DemandByItem": {
        "description": "Aggregated demand by item",
        "properties": {
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "total_qty": {
            "title": "Total Qty",
            "type": "number"
          },
          "total_value": {
            "title": "Total Value",
            "type": "number"
          },
          "source_count": {
            "title": "Source Count",
            "type": "integer"
          },
          "earliest_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Earliest Date"
          },
          "sources": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/DemandSource"
            },
            "title": "Sources",
            "type": "array"
          }
        },
        "required": [
          "item_code",
          "item_name",
          "total_qty",
          "total_value",
          "source_count"
        ],
        "title": "DemandByItem",
        "type": "object"
      },
      "DemandSource": {
        "description": "Source of demand (quotation or sales order)",
        "properties": {
          "type": {
            "description": "Quotation or Sales Order",
            "title": "Type",
            "type": "string"
          },
          "name": {
            "description": "Document name",
            "title": "Name",
            "type": "string"
          },
          "qty": {
            "description": "Quantity from this source",
            "title": "Qty",
            "type": "number"
          }
        },
        "required": [
          "type",
          "name",
          "qty"
        ],
        "title": "DemandSource",
        "type": "object"
      },
      "DemandForecastData": {
        "description": "Demand forecast data",
        "properties": {
          "demand_by_item": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/DemandByItem"
            },
            "title": "Demand By Item",
            "type": "array"
          },
          "demand_by_date": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/DemandByDate"
            },
            "title": "Demand By Date",
            "type": "array"
          },
          "total_demand_qty": {
            "default": 0,
            "title": "Total Demand Qty",
            "type": "number"
          },
          "total_demand_value": {
            "default": 0,
            "title": "Total Demand Value",
            "type": "number"
          },
          "period": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DemandPeriod"
              },
              {
                "type": "null"
              }
            ],
            "default": null
          }
        },
        "title": "DemandForecastData",
        "type": "object"
      },
      "DemandPeriod": {
        "description": "Demand forecast period",
        "properties": {
          "from": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "From"
          },
          "to": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "To"
          },
          "days": {
            "title": "Days",
            "type": "integer"
          }
        },
        "required": [
          "days"
        ],
        "title": "DemandPeriod",
        "type": "object"
      },
      "GetCapacityAvailabilityRequest": {
        "description": "Request for capacity availability",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "date_from": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Start date (YYYY-MM-DD)",
            "title": "Date From"
          },
          "date_to": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "End date (YYYY-MM-DD)",
            "title": "Date To"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by specific workstation",
            "title": "Workstation"
          }
        },
        "title": "GetCapacityAvailabilityRequest",
        "type": "object"
      },
      "GetCapacityAvailabilityResponse": {
        "description": "Response for capacity availability",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/CapacityAvailabilityData",
            "description": "Capacity data"
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Message"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetCapacityAvailabilityResponse",
        "type": "object"
      },
      "GetDemandForecastRequest": {
        "description": "Request for demand forecast",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "days_ahead": {
            "default": 30,
            "description": "Days to look ahead",
            "maximum": 365,
            "minimum": 1,
            "title": "Days Ahead",
            "type": "integer"
          },
          "include_quotes": {
            "default": true,
            "description": "Include submitted quotations",
            "title": "Include Quotes",
            "type": "boolean"
          },
          "include_sales_orders": {
            "default": true,
            "description": "Include confirmed sales orders",
            "title": "Include Sales Orders",
            "type": "boolean"
          }
        },
        "title": "GetDemandForecastRequest",
        "type": "object"
      },
      "GetDemandForecastResponse": {
        "description": "Response for demand forecast",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/DemandForecastData",
            "description": "Forecast data"
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Message"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetDemandForecastResponse",
        "type": "object"
      },
      "GetMaterialRequirementsRequest": {
        "description": "Request for material requirements (MRP-lite)",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "include_open_work_orders": {
            "default": true,
            "description": "Include materials for open work orders",
            "title": "Include Open Work Orders",
            "type": "boolean"
          },
          "include_pending_quotes": {
            "default": false,
            "description": "Include materials for pending quotes",
            "title": "Include Pending Quotes",
            "type": "boolean"
          }
        },
        "title": "GetMaterialRequirementsRequest",
        "type": "object"
      },
      "GetMaterialRequirementsResponse": {
        "description": "Response for material requirements",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/MaterialRequirementsData",
            "description": "Material requirements"
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Message"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetMaterialRequirementsResponse",
        "type": "object"
      },
      "MaterialRequirement": {
        "description": "Material requirement with availability",
        "properties": {
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "required_qty": {
            "title": "Required Qty",
            "type": "number"
          },
          "available_qty": {
            "title": "Available Qty",
            "type": "number"
          },
          "reserved_qty": {
            "title": "Reserved Qty",
            "type": "number"
          },
          "net_available": {
            "title": "Net Available",
            "type": "number"
          },
          "shortage_qty": {
            "title": "Shortage Qty",
            "type": "number"
          },
          "coverage_percent": {
            "title": "Coverage Percent",
            "type": "number"
          },
          "status": {
            "description": "adequate or shortage",
            "title": "Status",
            "type": "string"
          },
          "source_count": {
            "default": 0,
            "title": "Source Count",
            "type": "integer"
          }
        },
        "required": [
          "item_code",
          "item_name",
          "required_qty",
          "available_qty",
          "reserved_qty",
          "net_available",
          "shortage_qty",
          "coverage_percent",
          "status"
        ],
        "title": "MaterialRequirement",
        "type": "object"
      },
      "MaterialRequirementsData": {
        "description": "Material requirements data (MRP-lite)",
        "properties": {
          "materials": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/MaterialRequirement"
            },
            "title": "Materials",
            "type": "array"
          },
          "shortages": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/MaterialRequirement"
            },
            "title": "Shortages",
            "type": "array"
          },
          "total_items": {
            "default": 0,
            "title": "Total Items",
            "type": "integer"
          },
          "items_with_shortage": {
            "default": 0,
            "title": "Items With Shortage",
            "type": "integer"
          },
          "summary": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Summary"
          }
        },
        "title": "MaterialRequirementsData",
        "type": "object"
      },
      "OptimizeScheduleData": {
        "description": "Schedule optimization data",
        "properties": {
          "suggested_sequence": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/ScheduledWorkOrder"
            },
            "title": "Suggested Sequence",
            "type": "array"
          },
          "bottlenecks": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/Bottleneck"
            },
            "title": "Bottlenecks",
            "type": "array"
          },
          "estimated_completion": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Estimated Completion"
          },
          "strategy_used": {
            "title": "Strategy Used",
            "type": "string"
          },
          "total_work_orders": {
            "default": 0,
            "title": "Total Work Orders",
            "type": "integer"
          },
          "period": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Period"
          }
        },
        "required": [
          "strategy_used"
        ],
        "title": "OptimizeScheduleData",
        "type": "object"
      },
      "ScheduledWorkOrder": {
        "description": "Work order in scheduling sequence",
        "properties": {
          "sequence": {
            "title": "Sequence",
            "type": "integer"
          },
          "work_order": {
            "title": "Work Order",
            "type": "string"
          },
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "qty": {
            "title": "Qty",
            "type": "number"
          },
          "due_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Due Date"
          },
          "priority": {
            "default": "Medium",
            "title": "Priority",
            "type": "string"
          },
          "current_status": {
            "title": "Current Status",
            "type": "string"
          },
          "recommended_start": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Recommended Start"
          }
        },
        "required": [
          "sequence",
          "work_order",
          "item_code",
          "item_name",
          "qty",
          "current_status"
        ],
        "title": "ScheduledWorkOrder",
        "type": "object"
      },
      "OptimizeScheduleRequest": {
        "description": "Request for schedule optimization",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "date_from": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Start date",
            "title": "Date From"
          },
          "date_to": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "End date",
            "title": "Date To"
          },
          "strategy": {
            "default": "earliest_due_date",
            "description": "Scheduling strategy",
            "title": "Strategy",
            "type": "string"
          }
        },
        "title": "OptimizeScheduleRequest",
        "type": "object"
      },
      "OptimizeScheduleResponse": {
        "description": "Response for schedule optimization",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/OptimizeScheduleData",
            "description": "Optimization results"
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Message"
          }
        },
        "required": [
          "data"
        ],
        "title": "OptimizeScheduleResponse",
        "type": "object"
      },
      "BatchAvailabilityData": {
        "description": "Batch availability data",
        "properties": {
          "batch_id": {
            "title": "Batch Id",
            "type": "string"
          },
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "total_qty": {
            "description": "Total original quantity",
            "title": "Total Qty",
            "type": "integer"
          },
          "available_qty": {
            "description": "Available pieces",
            "title": "Available Qty",
            "type": "integer"
          },
          "reserved_qty": {
            "description": "Reserved pieces",
            "title": "Reserved Qty",
            "type": "integer"
          },
          "dimension_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Dimension Type"
          },
          "line_items": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/LineItemAvailability"
            },
            "title": "Line Items",
            "type": "array"
          }
        },
        "required": [
          "batch_id",
          "item_code",
          "total_qty",
          "available_qty",
          "reserved_qty"
        ],
        "title": "BatchAvailabilityData",
        "type": "object"
      },
      "LineItemAvailability": {
        "description": "Line item availability data",
        "properties": {
          "idx": {
            "title": "Idx",
            "type": "integer"
          },
          "quantity": {
            "description": "Original quantity",
            "title": "Quantity",
            "type": "integer"
          },
          "available_qty": {
            "description": "Available pieces",
            "title": "Available Qty",
            "type": "integer"
          },
          "reserved_qty": {
            "default": 0,
            "title": "Reserved Qty",
            "type": "integer"
          },
          "consumed_qty": {
            "default": 0,
            "title": "Consumed Qty",
            "type": "integer"
          },
          "length": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Length"
          },
          "length_unit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "ft",
            "title": "Length Unit"
          },
          "width": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Width"
          },
          "width_unit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Width Unit"
          }
        },
        "required": [
          "idx",
          "quantity",
          "available_qty"
        ],
        "title": "LineItemAvailability",
        "type": "object"
      },
      "BatchReservationsData": {
        "description": "Reservations for a batch",
        "properties": {
          "batch_id": {
            "title": "Batch Id",
            "type": "string"
          },
          "total_reserved": {
            "title": "Total Reserved",
            "type": "integer"
          },
          "reservations": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/ReservationForBatch"
            },
            "title": "Reservations",
            "type": "array"
          }
        },
        "required": [
          "batch_id",
          "total_reserved"
        ],
        "title": "BatchReservationsData",
        "type": "object"
      },
      "ReservationForBatch": {
        "description": "Reservation info when viewing batch",
        "properties": {
          "reservation_id": {
            "title": "Reservation Id",
            "type": "string"
          },
          "quantity": {
            "title": "Quantity",
            "type": "integer"
          },
          "reserved_by": {
            "title": "Reserved By",
            "type": "string"
          },
          "reserved_by_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Reserved By Name"
          },
          "line_item_idx": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Line Item Idx"
          },
          "dimension_value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Dimension Value"
          },
          "project_reference": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Project Reference"
          },
          "reserved_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Reserved At"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Expires At"
          },
          "days_remaining": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Days Remaining"
          }
        },
        "required": [
          "reservation_id",
          "quantity",
          "reserved_by"
        ],
        "title": "ReservationForBatch",
        "type": "object"
      },
      "DimensionMetadata": {
        "description": "Dimensional metadata for display (not for tracking)",
        "properties": {
          "length": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Length"
          },
          "length_unit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "ft",
            "title": "Length Unit"
          },
          "width": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Width"
          },
          "width_unit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "ft",
            "title": "Width Unit"
          }
        },
        "title": "DimensionMetadata",
        "type": "object"
      },
      "ExtendReservationData": {
        "description": "Extend reservation result data",
        "properties": {
          "reservation_id": {
            "title": "Reservation Id",
            "type": "string"
          },
          "old_expires_at": {
            "title": "Old Expires At",
            "type": "string"
          },
          "new_expires_at": {
            "title": "New Expires At",
            "type": "string"
          },
          "additional_days": {
            "title": "Additional Days",
            "type": "integer"
          }
        },
        "required": [
          "reservation_id",
          "old_expires_at",
          "new_expires_at",
          "additional_days"
        ],
        "title": "ExtendReservationData",
        "type": "object"
      },
      "ExtendReservationRequest": {
        "description": "Request for extending reservation (Foreman+)",
        "properties": {
          "reservation_id": {
            "description": "Reservation ID",
            "title": "Reservation Id",
            "type": "string"
          },
          "additional_days": {
            "description": "Days to add (1-90)",
            "maximum": 90,
            "minimum": 1,
            "title": "Additional Days",
            "type": "integer"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Extension notes",
            "title": "Notes"
          }
        },
        "required": [
          "reservation_id",
          "additional_days"
        ],
        "title": "ExtendReservationRequest",
        "type": "object"
      },
      "ExtendReservationResponse": {
        "description": "Response for extending reservation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/ExtendReservationData",
            "description": "Extension result"
          },
          "message": {
            "default": "Reservation extended",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "ExtendReservationResponse",
        "type": "object"
      },
      "GetAllReservationsRequest": {
        "description": "Request for all reservations (Foreman/Admin)",
        "properties": {
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "Active",
            "description": "Filter by status",
            "title": "Status"
          },
          "user": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by user email",
            "title": "User"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by location",
            "title": "Location"
          },
          "limit": {
            "default": 100,
            "description": "Max results",
            "maximum": 500,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          },
          "offset": {
            "default": 0,
            "description": "Pagination offset",
            "minimum": 0,
            "title": "Offset",
            "type": "integer"
          }
        },
        "title": "GetAllReservationsRequest",
        "type": "object"
      },
      "GetAllReservationsResponse": {
        "description": "Response for all reservations",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "All reservations",
            "items": {
              "$ref": "#/components/schemas/ReservationInfo"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Results in response",
            "title": "Count",
            "type": "integer"
          },
          "total": {
            "description": "Total matching",
            "title": "Total",
            "type": "integer"
          },
          "message": {
            "default": "Retrieved reservations",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count",
          "total"
        ],
        "title": "GetAllReservationsResponse",
        "type": "object"
      },
      "ReservationInfo": {
        "description": "Reservation information",
        "properties": {
          "reservation_id": {
            "description": "Reservation ID (e.g., MCO-2025-00001)",
            "title": "Reservation Id",
            "type": "string"
          },
          "batch_id": {
            "title": "Batch Id",
            "type": "string"
          },
          "line_item_idx": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Line Item Idx"
          },
          "item_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Item Code"
          },
          "item_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Item Name"
          },
          "quantity": {
            "description": "Number of pieces reserved",
            "title": "Quantity",
            "type": "integer"
          },
          "dimension_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "L, LxW, Qty, etc.",
            "title": "Dimension Type"
          },
          "dimension_value": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Dimension Value"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Location"
          },
          "project_reference": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Project Reference"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Notes"
          },
          "reserved_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Reserved At"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Expires At"
          },
          "days_remaining": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Days Remaining"
          },
          "status": {
            "default": "Active",
            "title": "Status",
            "type": "string"
          }
        },
        "required": [
          "reservation_id",
          "batch_id",
          "quantity"
        ],
        "title": "ReservationInfo",
        "type": "object"
      },
      "GetAvailableQtyRequest": {
        "description": "Request for batch availability",
        "properties": {
          "batch_id": {
            "description": "Batch ID",
            "title": "Batch Id",
            "type": "string"
          }
        },
        "required": [
          "batch_id"
        ],
        "title": "GetAvailableQtyRequest",
        "type": "object"
      },
      "GetAvailableQtyResponse": {
        "description": "Response for batch availability",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/BatchAvailabilityData",
            "description": "Availability data"
          },
          "message": {
            "default": "Batch availability retrieved",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetAvailableQtyResponse",
        "type": "object"
      },
      "GetMyReservationsRequest": {
        "description": "Request for user's reservations",
        "properties": {
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "Active",
            "description": "Filter by status: Active, Released, Expired",
            "title": "Status"
          },
          "include_expired": {
            "default": false,
            "description": "Include expired reservations",
            "title": "Include Expired",
            "type": "boolean"
          }
        },
        "title": "GetMyReservationsRequest",
        "type": "object"
      },
      "GetMyReservationsResponse": {
        "description": "Response for user's reservations",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "User's reservations",
            "items": {
              "$ref": "#/components/schemas/ReservationInfo"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Total count",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Retrieved reservations",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetMyReservationsResponse",
        "type": "object"
      },
      "GetReservationsForBatchRequest": {
        "description": "Request for batch reservations",
        "properties": {
          "batch_id": {
            "description": "Batch ID",
            "title": "Batch Id",
            "type": "string"
          }
        },
        "required": [
          "batch_id"
        ],
        "title": "GetReservationsForBatchRequest",
        "type": "object"
      },
      "GetReservationsForBatchResponse": {
        "description": "Response for batch reservations",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/BatchReservationsData",
            "description": "Batch reservations"
          },
          "message": {
            "default": "Found active reservations",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetReservationsForBatchResponse",
        "type": "object"
      },
      "ReleaseReservationData": {
        "description": "Release reservation result data",
        "properties": {
          "reservation_id": {
            "title": "Reservation Id",
            "type": "string"
          },
          "batch_id": {
            "title": "Batch Id",
            "type": "string"
          },
          "quantity": {
            "title": "Quantity",
            "type": "integer"
          },
          "released_by": {
            "title": "Released By",
            "type": "string"
          },
          "release_date": {
            "title": "Release Date",
            "type": "string"
          }
        },
        "required": [
          "reservation_id",
          "batch_id",
          "quantity",
          "released_by",
          "release_date"
        ],
        "title": "ReleaseReservationData",
        "type": "object"
      },
      "ReleaseReservationRequest": {
        "description": "Request for releasing reservation",
        "properties": {
          "reservation_id": {
            "description": "Reservation ID to release",
            "title": "Reservation Id",
            "type": "string"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Release notes",
            "title": "Notes"
          }
        },
        "required": [
          "reservation_id"
        ],
        "title": "ReleaseReservationRequest",
        "type": "object"
      },
      "ReleaseReservationResponse": {
        "description": "Response for releasing reservation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/ReleaseReservationData",
            "description": "Release data"
          },
          "message": {
            "default": "Reservation released successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "ReleaseReservationResponse",
        "type": "object"
      },
      "ReserveMaterialData": {
        "description": "Reserve material result data",
        "properties": {
          "reservation_id": {
            "title": "Reservation Id",
            "type": "string"
          },
          "batch_id": {
            "title": "Batch Id",
            "type": "string"
          },
          "line_item_idx": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Line Item Idx"
          },
          "item_code": {
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "title": "Item Name",
            "type": "string"
          },
          "quantity": {
            "title": "Quantity",
            "type": "integer"
          },
          "dimension_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Dimension Type"
          },
          "dimension_metadata": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DimensionMetadata"
              },
              {
                "type": "null"
              }
            ],
            "default": null
          },
          "expires_at": {
            "title": "Expires At",
            "type": "string"
          },
          "reserved_by": {
            "title": "Reserved By",
            "type": "string"
          },
          "project_reference": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Project Reference"
          }
        },
        "required": [
          "reservation_id",
          "batch_id",
          "item_code",
          "item_name",
          "quantity",
          "expires_at",
          "reserved_by"
        ],
        "title": "ReserveMaterialData",
        "type": "object"
      },
      "ReserveMaterialRequest": {
        "description": "Request for reserving material",
        "properties": {
          "batch_id": {
            "description": "Batch ID to reserve from",
            "title": "Batch Id",
            "type": "string"
          },
          "quantity": {
            "description": "Number of pieces to reserve",
            "exclusiveMinimum": 0,
            "title": "Quantity",
            "type": "integer"
          },
          "line_item_idx": {
            "anyOf": [
              {
                "minimum": 0,
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Line item index (0-based)",
            "title": "Line Item Idx"
          },
          "project_reference": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Project/job reference",
            "title": "Project Reference"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Reservation notes",
            "title": "Notes"
          },
          "expiry_days": {
            "anyOf": [
              {
                "minimum": 1,
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Days until expiry (default: 7)",
            "title": "Expiry Days"
          }
        },
        "required": [
          "batch_id",
          "quantity"
        ],
        "title": "ReserveMaterialRequest",
        "type": "object"
      },
      "ReserveMaterialResponse": {
        "description": "Response for material reservation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/ReserveMaterialData",
            "description": "Reservation data"
          },
          "message": {
            "default": "Reserved pieces from batch",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "ReserveMaterialResponse",
        "type": "object"
      },
      "ActivateVariantResponse": {
        "description": "Response for activate_variant endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/ActivationData",
            "description": "Activation result"
          },
          "message": {
            "default": "Variant activated",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "ActivateVariantResponse",
        "type": "object"
      },
      "ActivationData": {
        "description": "Data returned from activate/deactivate endpoints.",
        "properties": {
          "variantId": {
            "description": "Variant document ID",
            "title": "Variantid",
            "type": "string"
          },
          "active": {
            "description": "New active status",
            "title": "Active",
            "type": "boolean"
          }
        },
        "required": [
          "variantId",
          "active"
        ],
        "title": "ActivationData",
        "type": "object"
      },
      "BatchStock": {
        "description": "Batch availability data for variant stock enrichment.",
        "properties": {
          "batchId": {
            "description": "Batch document ID",
            "title": "Batchid",
            "type": "string"
          },
          "lineIdx": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Batch line item index",
            "title": "Lineidx"
          },
          "availablePieces": {
            "default": 0,
            "description": "Available pieces in batch",
            "title": "Availablepieces",
            "type": "integer"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Location short label (e.g., 'MR')",
            "title": "Location"
          }
        },
        "required": [
          "batchId"
        ],
        "title": "BatchStock",
        "type": "object"
      },
      "BulkCreateData": {
        "description": "Data returned from bulk_create_variants endpoint.",
        "properties": {
          "created": {
            "description": "Successfully created variants",
            "items": {
              "$ref": "#/components/schemas/VariantData"
            },
            "title": "Created",
            "type": "array"
          },
          "errors": {
            "description": "Failed variants with error details",
            "items": {
              "$ref": "#/components/schemas/BulkCreateError"
            },
            "title": "Errors",
            "type": "array"
          }
        },
        "required": [
          "created",
          "errors"
        ],
        "title": "BulkCreateData",
        "type": "object"
      },
      "BulkCreateError": {
        "description": "Error details for failed variant in bulk creation.",
        "properties": {
          "index": {
            "description": "Index in input array",
            "title": "Index",
            "type": "integer"
          },
          "input": {
            "additionalProperties": true,
            "description": "Original input that failed",
            "title": "Input",
            "type": "object"
          },
          "error": {
            "description": "Error message",
            "title": "Error",
            "type": "string"
          }
        },
        "required": [
          "index",
          "input",
          "error"
        ],
        "title": "BulkCreateError",
        "type": "object"
      },
      "VariantData": {
        "description": "Complete variant data structure (camelCase for frontend).",
        "properties": {
          "id": {
            "description": "Variant document ID",
            "title": "Id",
            "type": "string"
          },
          "itemCode": {
            "description": "Parent template item code",
            "title": "Itemcode",
            "type": "string"
          },
          "variantName": {
            "description": "Human-readable variant name",
            "title": "Variantname",
            "type": "string"
          },
          "dimensionType": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Dimension type (L, LxW, Weight, Qty)",
            "title": "Dimensiontype"
          },
          "length": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Length value",
            "title": "Length"
          },
          "lengthUnit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "ft",
            "description": "Length unit",
            "title": "Lengthunit"
          },
          "width": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Width value (for LxW types)",
            "title": "Width"
          },
          "widthUnit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "ft",
            "description": "Width unit",
            "title": "Widthunit"
          },
          "weight": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Weight value",
            "title": "Weight"
          },
          "weightUnit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "lb",
            "description": "Weight unit",
            "title": "Weightunit"
          },
          "customRate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Variant-specific rate override",
            "title": "Customrate"
          },
          "customAttributes": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "description": "Custom attributes JSON",
            "title": "Customattributes"
          },
          "displayOrder": {
            "default": 0,
            "description": "Sort order in UI",
            "title": "Displayorder",
            "type": "integer"
          },
          "active": {
            "default": true,
            "description": "Whether variant is active",
            "title": "Active",
            "type": "boolean"
          },
          "migrationId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "UUID for data portability",
            "title": "Migrationid"
          }
        },
        "required": [
          "id",
          "itemCode",
          "variantName"
        ],
        "title": "VariantData",
        "type": "object"
      },
      "BulkCreateVariantsRequest": {
        "description": "Request for bulk variant creation.",
        "properties": {
          "item_code": {
            "description": "Parent template item code",
            "title": "Item Code",
            "type": "string"
          },
          "variants": {
            "description": "List of variants to create",
            "items": {
              "$ref": "#/components/schemas/BulkVariantInput"
            },
            "title": "Variants",
            "type": "array"
          }
        },
        "required": [
          "item_code",
          "variants"
        ],
        "title": "BulkCreateVariantsRequest",
        "type": "object"
      },
      "BulkVariantInput": {
        "description": "Input for bulk variant creation.",
        "properties": {
          "dimensionType": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Dimension type",
            "title": "Dimensiontype"
          },
          "length": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Length value",
            "title": "Length"
          },
          "lengthUnit": {
            "default": "ft",
            "description": "Length unit",
            "title": "Lengthunit",
            "type": "string"
          },
          "width": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Width value",
            "title": "Width"
          },
          "widthUnit": {
            "default": "ft",
            "description": "Width unit",
            "title": "Widthunit",
            "type": "string"
          },
          "weight": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Weight value",
            "title": "Weight"
          },
          "weightUnit": {
            "default": "lb",
            "description": "Weight unit",
            "title": "Weightunit",
            "type": "string"
          },
          "variantName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Human-readable name",
            "title": "Variantname"
          },
          "customRate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Rate override",
            "title": "Customrate"
          },
          "displayOrder": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Sort order",
            "title": "Displayorder"
          }
        },
        "title": "BulkVariantInput",
        "type": "object"
      },
      "BulkCreateVariantsResponse": {
        "description": "Response for bulk_create_variants endpoint.",
        "properties": {
          "success": {
            "description": "True if all variants created, False if any errors",
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/BulkCreateData",
            "description": "Created variants and errors"
          },
          "message": {
            "default": "Created X variants with Y errors",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "success",
          "data"
        ],
        "title": "BulkCreateVariantsResponse",
        "type": "object"
      },
      "CreateVariantRequest": {
        "description": "Request to create a new variant.",
        "properties": {
          "item_code": {
            "description": "Parent template item code",
            "title": "Item Code",
            "type": "string"
          },
          "dimension_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Dimension type (inherits from parent if not specified)",
            "title": "Dimension Type"
          },
          "length": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Length value",
            "title": "Length"
          },
          "length_unit": {
            "default": "ft",
            "description": "Length unit",
            "title": "Length Unit",
            "type": "string"
          },
          "width": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Width value (for LxW types)",
            "title": "Width"
          },
          "width_unit": {
            "default": "ft",
            "description": "Width unit",
            "title": "Width Unit",
            "type": "string"
          },
          "weight": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Weight value",
            "title": "Weight"
          },
          "weight_unit": {
            "default": "lb",
            "description": "Weight unit",
            "title": "Weight Unit",
            "type": "string"
          },
          "variant_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Human-readable name (auto-generated if not provided)",
            "title": "Variant Name"
          },
          "custom_rate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Variant-specific rate override",
            "title": "Custom Rate"
          },
          "custom_attributes": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Custom attributes JSON",
            "title": "Custom Attributes"
          },
          "display_order": {
            "default": 0,
            "description": "Sort order in UI",
            "title": "Display Order",
            "type": "integer"
          }
        },
        "required": [
          "item_code"
        ],
        "title": "CreateVariantRequest",
        "type": "object"
      },
      "CreateVariantResponse": {
        "description": "Response for create_variant endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/VariantData",
            "description": "Created variant"
          },
          "message": {
            "default": "Variant created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CreateVariantResponse",
        "type": "object"
      },
      "DeactivateVariantResponse": {
        "description": "Response for deactivate_variant endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/ActivationData",
            "description": "Deactivation result"
          },
          "message": {
            "default": "Variant deactivated",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "DeactivateVariantResponse",
        "type": "object"
      },
      "GetVariantRequest": {
        "description": "Request to get a single variant.",
        "properties": {
          "variant_id": {
            "description": "Variant document ID",
            "title": "Variant Id",
            "type": "string"
          }
        },
        "required": [
          "variant_id"
        ],
        "title": "GetVariantRequest",
        "type": "object"
      },
      "GetVariantResponse": {
        "description": "Response for get_variant endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/VariantData",
            "description": "Single variant data"
          },
          "message": {
            "default": "Variant retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetVariantResponse",
        "type": "object"
      },
      "GetVariantsAndStockLevelRequest": {
        "description": "Request for variants with stock levels.",
        "properties": {
          "item_code": {
            "description": "Parent template item code",
            "title": "Item Code",
            "type": "string"
          },
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Warehouse group to filter stock by location",
            "title": "Location"
          },
          "include_inactive": {
            "default": false,
            "description": "Include inactive variants",
            "title": "Include Inactive",
            "type": "boolean"
          }
        },
        "required": [
          "item_code"
        ],
        "title": "GetVariantsAndStockLevelRequest",
        "type": "object"
      },
      "GetVariantsAndStockLevelResponse": {
        "description": "Response for get_variants_and_stock_level endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "Variants enriched with stock data",
            "items": {
              "$ref": "#/components/schemas/VariantWithStock"
            },
            "title": "Data",
            "type": "array"
          },
          "message": {
            "default": "Success",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetVariantsAndStockLevelResponse",
        "type": "object"
      },
      "StockStatus": {
        "description": "Stock availability status.",
        "enum": [
          "in_stock",
          "low_stock",
          "out_of_stock"
        ],
        "title": "StockStatus",
        "type": "string"
      },
      "VariantWithStock": {
        "description": "Variant data enriched with stock availability.",
        "properties": {
          "id": {
            "description": "Variant document ID",
            "title": "Id",
            "type": "string"
          },
          "itemCode": {
            "description": "Parent template item code",
            "title": "Itemcode",
            "type": "string"
          },
          "variantName": {
            "description": "Human-readable variant name",
            "title": "Variantname",
            "type": "string"
          },
          "dimensionType": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Dimension type (L, LxW, Weight, Qty)",
            "title": "Dimensiontype"
          },
          "length": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Length value",
            "title": "Length"
          },
          "lengthUnit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "ft",
            "description": "Length unit",
            "title": "Lengthunit"
          },
          "width": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Width value (for LxW types)",
            "title": "Width"
          },
          "widthUnit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "ft",
            "description": "Width unit",
            "title": "Widthunit"
          },
          "weight": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Weight value",
            "title": "Weight"
          },
          "weightUnit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "lb",
            "description": "Weight unit",
            "title": "Weightunit"
          },
          "customRate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Variant-specific rate override",
            "title": "Customrate"
          },
          "customAttributes": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "description": "Custom attributes JSON",
            "title": "Customattributes"
          },
          "displayOrder": {
            "default": 0,
            "description": "Sort order in UI",
            "title": "Displayorder",
            "type": "integer"
          },
          "active": {
            "default": true,
            "description": "Whether variant is active",
            "title": "Active",
            "type": "boolean"
          },
          "migrationId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "UUID for data portability",
            "title": "Migrationid"
          },
          "stockStatus": {
            "$ref": "#/components/schemas/StockStatus",
            "description": "Stock availability status"
          },
          "totalPieces": {
            "default": 0,
            "description": "Total available pieces across all batches",
            "title": "Totalpieces",
            "type": "integer"
          },
          "batches": {
            "description": "Batch availability details",
            "items": {
              "$ref": "#/components/schemas/BatchStock"
            },
            "title": "Batches",
            "type": "array"
          }
        },
        "required": [
          "id",
          "itemCode",
          "variantName",
          "stockStatus"
        ],
        "title": "VariantWithStock",
        "type": "object"
      },
      "GetVariantsRequest": {
        "description": "Request to get variants for an item.",
        "properties": {
          "item_code": {
            "description": "Parent template item code",
            "title": "Item Code",
            "type": "string"
          },
          "include_inactive": {
            "default": false,
            "description": "Include inactive (soft-deleted) variants",
            "title": "Include Inactive",
            "type": "boolean"
          }
        },
        "required": [
          "item_code"
        ],
        "title": "GetVariantsRequest",
        "type": "object"
      },
      "GetVariantsResponse": {
        "description": "Response for get_variants endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "List of variants",
            "items": {
              "$ref": "#/components/schemas/VariantData"
            },
            "title": "Data",
            "type": "array"
          },
          "message": {
            "default": "Success",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetVariantsResponse",
        "type": "object"
      },
      "ReorderData": {
        "description": "Data returned from reorder_variants endpoint.",
        "properties": {
          "updated": {
            "description": "Number of variants updated",
            "title": "Updated",
            "type": "integer"
          }
        },
        "required": [
          "updated"
        ],
        "title": "ReorderData",
        "type": "object"
      },
      "ReorderVariantsRequest": {
        "description": "Request to reorder multiple variants.",
        "properties": {
          "variant_orders": {
            "description": "List of variant IDs with new display orders",
            "items": {
              "$ref": "#/components/schemas/VariantOrder"
            },
            "title": "Variant Orders",
            "type": "array"
          }
        },
        "required": [
          "variant_orders"
        ],
        "title": "ReorderVariantsRequest",
        "type": "object"
      },
      "VariantOrder": {
        "description": "Variant order for reordering endpoint.",
        "properties": {
          "id": {
            "description": "Variant document ID",
            "title": "Id",
            "type": "string"
          },
          "displayOrder": {
            "description": "New display order value",
            "title": "Displayorder",
            "type": "integer"
          }
        },
        "required": [
          "id",
          "displayOrder"
        ],
        "title": "VariantOrder",
        "type": "object"
      },
      "ReorderVariantsResponse": {
        "description": "Response for reorder_variants endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/ReorderData",
            "description": "Reorder result"
          },
          "message": {
            "default": "Updated display order for X variants",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "ReorderVariantsResponse",
        "type": "object"
      },
      "UpdateVariantRequest": {
        "description": "Request to update an existing variant.",
        "properties": {
          "variant_id": {
            "description": "Variant document ID",
            "title": "Variant Id",
            "type": "string"
          },
          "variant_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated name",
            "title": "Variant Name"
          },
          "dimension_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated dimension type",
            "title": "Dimension Type"
          },
          "length": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated length",
            "title": "Length"
          },
          "length_unit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated length unit",
            "title": "Length Unit"
          },
          "width": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated width",
            "title": "Width"
          },
          "width_unit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated width unit",
            "title": "Width Unit"
          },
          "weight": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated weight",
            "title": "Weight"
          },
          "weight_unit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated weight unit",
            "title": "Weight Unit"
          },
          "custom_rate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated rate override",
            "title": "Custom Rate"
          },
          "custom_attributes": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated custom attributes",
            "title": "Custom Attributes"
          },
          "display_order": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Updated display order",
            "title": "Display Order"
          }
        },
        "required": [
          "variant_id"
        ],
        "title": "UpdateVariantRequest",
        "type": "object"
      },
      "UpdateVariantResponse": {
        "description": "Response for update_variant endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/VariantData",
            "description": "Updated variant"
          },
          "message": {
            "default": "Variant updated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateVariantResponse",
        "type": "object"
      },
      "BOMMaterial": {
        "description": "Material item from BOM template.",
        "properties": {
          "item_code": {
            "description": "Material item code",
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "description": "Material item name",
            "title": "Item Name",
            "type": "string"
          },
          "required_qty": {
            "description": "Required quantity (multiplied by qty)",
            "title": "Required Qty",
            "type": "number"
          },
          "stock_qty": {
            "description": "Stock quantity",
            "title": "Stock Qty",
            "type": "number"
          },
          "uom": {
            "description": "Unit of measure",
            "title": "Uom",
            "type": "string"
          },
          "stock_uom": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Stock UOM",
            "title": "Stock Uom"
          },
          "rate": {
            "default": 0,
            "description": "Item rate",
            "title": "Rate",
            "type": "number"
          },
          "amount": {
            "default": 0,
            "description": "Total amount",
            "title": "Amount",
            "type": "number"
          },
          "has_bom": {
            "default": false,
            "description": "Whether material has its own BOM",
            "title": "Has Bom",
            "type": "boolean"
          },
          "item_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item group/type",
            "title": "Item Type"
          },
          "operation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked operation name (legacy)",
            "title": "Operation"
          },
          "operation_instance_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked operation instance identifier",
            "title": "Operation Instance Id"
          },
          "operation_label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked operation label",
            "title": "Operation Label"
          }
        },
        "required": [
          "item_code",
          "item_name",
          "required_qty",
          "stock_qty",
          "uom"
        ],
        "title": "BOMMaterial",
        "type": "object"
      },
      "BOMOperation": {
        "description": "Operation from BOM template.",
        "properties": {
          "operation": {
            "description": "Operation document name",
            "title": "Operation",
            "type": "string"
          },
          "operation_instance_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Stable operation instance identifier",
            "title": "Operation Instance Id"
          },
          "operation_label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "User-facing operation label",
            "title": "Operation Label"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Workstation for operation",
            "title": "Workstation"
          },
          "time_in_mins": {
            "default": 0,
            "description": "Estimated time in minutes",
            "title": "Time In Mins",
            "type": "number"
          },
          "idx": {
            "description": "Operation sequence index",
            "title": "Idx",
            "type": "integer"
          },
          "description": {
            "default": "",
            "description": "Operation description",
            "title": "Description",
            "type": "string"
          }
        },
        "required": [
          "operation",
          "idx"
        ],
        "title": "BOMOperation",
        "type": "object"
      },
      "BOMTemplate": {
        "description": "BOM template list item for selector.",
        "properties": {
          "bom_id": {
            "description": "BOM document name",
            "title": "Bom Id",
            "type": "string"
          },
          "item": {
            "description": "Item code",
            "title": "Item",
            "type": "string"
          },
          "item_name": {
            "description": "Item name",
            "title": "Item Name",
            "type": "string"
          },
          "operations_count": {
            "default": 0,
            "description": "Number of operations",
            "title": "Operations Count",
            "type": "integer"
          },
          "materials_count": {
            "default": 0,
            "description": "Number of materials",
            "title": "Materials Count",
            "type": "integer"
          },
          "is_active": {
            "default": 1,
            "description": "Whether BOM is active",
            "title": "Is Active",
            "type": "integer"
          },
          "is_default": {
            "default": 0,
            "description": "Whether this is the default BOM",
            "title": "Is Default",
            "type": "integer"
          },
          "modified": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Last modified timestamp",
            "title": "Modified"
          }
        },
        "required": [
          "bom_id",
          "item",
          "item_name"
        ],
        "title": "BOMTemplate",
        "type": "object"
      },
      "BOMTemplateFullData": {
        "description": "Complete BOM template data.",
        "properties": {
          "template_id": {
            "description": "BOM document name",
            "title": "Template Id",
            "type": "string"
          },
          "template_name": {
            "description": "BOM name",
            "title": "Template Name",
            "type": "string"
          },
          "item": {
            "description": "Item code",
            "title": "Item",
            "type": "string"
          },
          "item_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item name",
            "title": "Item Name"
          },
          "is_active": {
            "description": "Whether BOM is active",
            "title": "Is Active",
            "type": "integer"
          },
          "is_default": {
            "description": "Whether this is default BOM",
            "title": "Is Default",
            "type": "integer"
          },
          "quantity": {
            "description": "BOM base quantity",
            "title": "Quantity",
            "type": "number"
          },
          "operations": {
            "description": "BOM operations",
            "items": {
              "$ref": "#/components/schemas/BOMOperation"
            },
            "title": "Operations",
            "type": "array"
          },
          "materials": {
            "description": "BOM materials",
            "items": {
              "$ref": "#/components/schemas/BOMMaterial"
            },
            "title": "Materials",
            "type": "array"
          },
          "qc_checkpoints": {
            "description": "QC checkpoints",
            "items": {
              "$ref": "#/components/schemas/QCCheckpoint"
            },
            "title": "Qc Checkpoints",
            "type": "array"
          },
          "times_used": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Usage count",
            "title": "Times Used"
          },
          "last_used_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Last used date",
            "title": "Last Used Date"
          }
        },
        "required": [
          "template_id",
          "template_name",
          "item",
          "is_active",
          "is_default",
          "quantity"
        ],
        "title": "BOMTemplateFullData",
        "type": "object"
      },
      "QCCheckpoint": {
        "description": "QC checkpoint from BOM template.",
        "properties": {
          "stage": {
            "description": "Display stage label (legacy-compatible)",
            "title": "Stage",
            "type": "string"
          },
          "operation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked Operation (preferred)",
            "title": "Operation"
          },
          "operation_instance_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked operation instance identifier (canonical)",
            "title": "Operation Instance Id"
          },
          "operation_label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Linked operation label",
            "title": "Operation Label"
          },
          "timing": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Before or After the linked operation",
            "title": "Timing"
          },
          "idx": {
            "description": "Checkpoint sequence index",
            "title": "Idx",
            "type": "integer"
          },
          "checkpoint_description": {
            "description": "Checkpoint description",
            "title": "Checkpoint Description",
            "type": "string"
          },
          "handoff_note": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Optional rich-text handoff note (canonical)",
            "title": "Handoff Note"
          },
          "criteria": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Legacy alias for handoff note",
            "title": "Criteria"
          },
          "required": {
            "default": false,
            "description": "Whether this checkpoint is required",
            "title": "Required",
            "type": "boolean"
          }
        },
        "required": [
          "stage",
          "idx",
          "checkpoint_description"
        ],
        "title": "QCCheckpoint",
        "type": "object"
      },
      "BOMTemplatesListData": {
        "description": "Data from BOM templates list query.",
        "properties": {
          "templates": {
            "description": "Available BOM templates",
            "items": {
              "$ref": "#/components/schemas/BOMTemplate"
            },
            "title": "Templates",
            "type": "array"
          }
        },
        "required": [
          "templates"
        ],
        "title": "BOMTemplatesListData",
        "type": "object"
      },
      "BatchAllocation": {
        "description": "Batch allocation for material in work order.",
        "properties": {
          "batch_id": {
            "description": "Batch document ID",
            "title": "Batch Id",
            "type": "string"
          },
          "batch_line_idx": {
            "default": 0,
            "description": "Batch line item index",
            "title": "Batch Line Idx",
            "type": "integer"
          },
          "allocated_qty": {
            "description": "Quantity allocated from this batch",
            "title": "Allocated Qty",
            "type": "number"
          }
        },
        "required": [
          "batch_id",
          "allocated_qty"
        ],
        "title": "BatchAllocation",
        "type": "object"
      },
      "CreateProductionItemQuickRequest": {
        "description": "Request to quick-create a production item.",
        "properties": {
          "item_name": {
            "description": "Item name (required)",
            "minLength": 1,
            "title": "Item Name",
            "type": "string"
          },
          "item_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item code (auto-generated if not provided)",
            "title": "Item Code"
          },
          "item_group": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item group (default: Raw Material)",
            "title": "Item Group"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item description",
            "title": "Description"
          },
          "custom_material": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Material code",
            "title": "Custom Material"
          },
          "custom_shape": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Shape/form",
            "title": "Custom Shape"
          },
          "custom_dimensions": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Dimensions string",
            "title": "Custom Dimensions"
          },
          "custom_unit_system": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Imperial or Metric",
            "title": "Custom Unit System"
          },
          "custom_attributes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Custom attributes JSON",
            "title": "Custom Attributes"
          },
          "is_item_type": {
            "default": false,
            "description": "Create as Item Type (template)",
            "title": "Is Item Type",
            "type": "boolean"
          },
          "dimension_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Dimension tracking type",
            "title": "Dimension Type"
          }
        },
        "required": [
          "item_name"
        ],
        "title": "CreateProductionItemQuickRequest",
        "type": "object"
      },
      "CreateProductionItemQuickResponse": {
        "description": "Response for create_production_item_quick endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "additionalProperties": true,
            "description": "Created/existing item data with is_new flag",
            "title": "Data",
            "type": "object"
          },
          "message": {
            "default": "Item created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CreateProductionItemQuickResponse",
        "type": "object"
      },
      "CreateWorkOrderData": {
        "description": "Data from work order creation.",
        "properties": {
          "work_order_name": {
            "description": "Created work order document name",
            "title": "Work Order Name",
            "type": "string"
          }
        },
        "required": [
          "work_order_name"
        ],
        "title": "CreateWorkOrderData",
        "type": "object"
      },
      "CreateWorkOrderV2Request": {
        "description": "Request to create work order from wizard.",
        "properties": {
          "job_description": {
            "default": "",
            "description": "Job description",
            "title": "Job Description",
            "type": "string"
          },
          "qty": {
            "default": 1,
            "description": "Quantity to produce",
            "minimum": 1,
            "title": "Qty",
            "type": "integer"
          },
          "priority": {
            "default": "Medium",
            "description": "Priority level",
            "title": "Priority",
            "type": "string"
          },
          "job_material_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Material type from wizard",
            "title": "Job Material Type"
          },
          "job_shape": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Shape from wizard",
            "title": "Job Shape"
          },
          "job_dimensions": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Dimensions from wizard",
            "title": "Job Dimensions"
          },
          "planned_start_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Planned start (ISO format)",
            "title": "Planned Start Date"
          },
          "planned_end_date": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Planned end/due date (ISO format)",
            "title": "Planned End Date"
          },
          "production_item": {
            "description": "Item to produce",
            "title": "Production Item",
            "type": "string"
          },
          "item_match_type": {
            "default": "existing",
            "description": "How item was matched",
            "title": "Item Match Type",
            "type": "string"
          },
          "new_item_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Name if new item was created",
            "title": "New Item Name"
          },
          "customer": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Customer link",
            "title": "Customer"
          },
          "sales_order": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Sales Order link",
            "title": "Sales Order"
          },
          "is_internal_job": {
            "default": false,
            "description": "Whether this is an internal job",
            "title": "Is Internal Job",
            "type": "boolean"
          },
          "internal_job_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Type of internal job",
            "title": "Internal Job Type"
          },
          "internal_job_notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Notes for internal job",
            "title": "Internal Job Notes"
          },
          "operations": {
            "default": "[]",
            "description": "JSON array of operations",
            "title": "Operations",
            "type": "string"
          },
          "bom_no": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Native ERPNext BOM link",
            "title": "Bom No"
          },
          "required_items": {
            "default": "[]",
            "description": "JSON array of materials with batch_allocations",
            "title": "Required Items",
            "type": "string"
          },
          "wip_warehouse": {
            "description": "Work-in-progress warehouse",
            "title": "Wip Warehouse",
            "type": "string"
          },
          "fg_warehouse": {
            "description": "Finished goods warehouse",
            "title": "Fg Warehouse",
            "type": "string"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Additional notes",
            "title": "Notes"
          }
        },
        "required": [
          "production_item",
          "wip_warehouse",
          "fg_warehouse"
        ],
        "title": "CreateWorkOrderV2Request",
        "type": "object"
      },
      "CreateWorkOrderV2Response": {
        "description": "Response for create_work_order_v2 endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/CreateWorkOrderData",
            "description": "Created work order info"
          },
          "message": {
            "default": "Work order created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CreateWorkOrderV2Response",
        "type": "object"
      },
      "GetBOMTemplateFullRequest": {
        "description": "Request to get complete BOM template.",
        "properties": {
          "template_id": {
            "description": "BOM document name",
            "title": "Template Id",
            "type": "string"
          },
          "qty": {
            "default": 1,
            "description": "Quantity multiplier for material calculations",
            "minimum": 1,
            "title": "Qty",
            "type": "integer"
          }
        },
        "required": [
          "template_id"
        ],
        "title": "GetBOMTemplateFullRequest",
        "type": "object"
      },
      "GetBOMTemplateFullResponse": {
        "description": "Response for get_bom_template_full endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/BOMTemplateFullData",
            "description": "Complete BOM template"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetBOMTemplateFullResponse",
        "type": "object"
      },
      "GetBOMTemplatesListRequest": {
        "description": "Request for BOM templates list.",
        "properties": {
          "query": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Search text",
            "title": "Query"
          },
          "limit": {
            "default": 20,
            "description": "Max results",
            "maximum": 50,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          }
        },
        "title": "GetBOMTemplatesListRequest",
        "type": "object"
      },
      "GetBOMTemplatesListResponse": {
        "description": "Response for get_bom_templates_list endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/BOMTemplatesListData",
            "description": "BOM templates list"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetBOMTemplatesListResponse",
        "type": "object"
      },
      "GetRecentItemsRequest": {
        "description": "Request to get recent items.",
        "properties": {
          "limit": {
            "default": 5,
            "description": "Maximum items to return",
            "maximum": 20,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          }
        },
        "title": "GetRecentItemsRequest",
        "type": "object"
      },
      "GetRecentItemsResponse": {
        "description": "Response for get_recent_items endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/RecentItemsData",
            "description": "Recent items data"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetRecentItemsResponse",
        "type": "object"
      },
      "RecentItem": {
        "description": "Recently used production item.",
        "properties": {
          "item_code": {
            "description": "Item code",
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "description": "Item name",
            "title": "Item Name",
            "type": "string"
          },
          "last_used": {
            "description": "Last used timestamp (ISO format)",
            "title": "Last Used",
            "type": "string"
          },
          "use_count": {
            "description": "Number of times used",
            "title": "Use Count",
            "type": "integer"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item description",
            "title": "Description"
          },
          "custom_material": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Material code",
            "title": "Custom Material"
          },
          "custom_shape": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Shape/form",
            "title": "Custom Shape"
          },
          "custom_dimensions": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Dimensions",
            "title": "Custom Dimensions"
          },
          "image": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item image URL",
            "title": "Image"
          }
        },
        "required": [
          "item_code",
          "item_name",
          "last_used",
          "use_count"
        ],
        "title": "RecentItem",
        "type": "object"
      },
      "RecentItemsData": {
        "description": "Data from recent items query.",
        "properties": {
          "items": {
            "description": "Recently used items",
            "items": {
              "$ref": "#/components/schemas/RecentItem"
            },
            "title": "Items",
            "type": "array"
          }
        },
        "required": [
          "items"
        ],
        "title": "RecentItemsData",
        "type": "object"
      },
      "MarkItemUsedRequest": {
        "description": "Request to track item usage.",
        "properties": {
          "item_code": {
            "description": "Item document name",
            "title": "Item Code",
            "type": "string"
          }
        },
        "required": [
          "item_code"
        ],
        "title": "MarkItemUsedRequest",
        "type": "object"
      },
      "MarkItemUsedResponse": {
        "description": "Response for mark_item_used endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "Item usage tracked",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "MarkItemUsedResponse",
        "type": "object"
      },
      "OperationInput": {
        "description": "Operation input for work order creation.",
        "properties": {
          "operation": {
            "description": "Operation document name",
            "title": "Operation",
            "type": "string"
          },
          "workstation": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Workstation",
            "title": "Workstation"
          },
          "time_in_mins": {
            "default": 0,
            "description": "Estimated time",
            "title": "Time In Mins",
            "type": "number"
          },
          "description": {
            "default": "",
            "description": "Operation description",
            "title": "Description",
            "type": "string"
          }
        },
        "required": [
          "operation"
        ],
        "title": "OperationInput",
        "type": "object"
      },
      "RequiredItem": {
        "description": "Required material item for work order creation.",
        "properties": {
          "item_code": {
            "description": "Material item code",
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Material item name",
            "title": "Item Name"
          },
          "required_qty": {
            "description": "Required quantity",
            "title": "Required Qty",
            "type": "number"
          },
          "qty": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Alternative quantity field",
            "title": "Qty"
          },
          "batch_allocations": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/BatchAllocation"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Batch allocations for this material",
            "title": "Batch Allocations"
          }
        },
        "required": [
          "item_code",
          "required_qty"
        ],
        "title": "RequiredItem",
        "type": "object"
      },
      "SearchItem": {
        "description": "Item from smart search results.",
        "properties": {
          "item_code": {
            "description": "Item document name",
            "title": "Item Code",
            "type": "string"
          },
          "item_name": {
            "description": "Item display name",
            "title": "Item Name",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item description",
            "title": "Description"
          },
          "item_group": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item category/group",
            "title": "Item Group"
          },
          "stock_uom": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Stock unit of measure",
            "title": "Stock Uom"
          },
          "custom_material": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Material code",
            "title": "Custom Material"
          },
          "custom_shape": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Shape/form",
            "title": "Custom Shape"
          },
          "custom_dimensions": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Dimensions string",
            "title": "Custom Dimensions"
          },
          "image": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item image URL",
            "title": "Image"
          }
        },
        "required": [
          "item_code",
          "item_name"
        ],
        "title": "SearchItem",
        "type": "object"
      },
      "SearchResultData": {
        "description": "Data from smart item search.",
        "properties": {
          "items": {
            "description": "Matching items",
            "items": {
              "$ref": "#/components/schemas/SearchItem"
            },
            "title": "Items",
            "type": "array"
          },
          "total_count": {
            "description": "Total matches (before limit)",
            "title": "Total Count",
            "type": "integer"
          }
        },
        "required": [
          "items",
          "total_count"
        ],
        "title": "SearchResultData",
        "type": "object"
      },
      "SmartItemSearchRequest": {
        "description": "Request for smart item search.",
        "properties": {
          "query": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Search text for item_code, item_name, description",
            "title": "Query"
          },
          "material": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by material code",
            "title": "Material"
          },
          "shape": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Filter by custom_shape",
            "title": "Shape"
          },
          "limit": {
            "default": 20,
            "description": "Max results to return",
            "maximum": 100,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          }
        },
        "title": "SmartItemSearchRequest",
        "type": "object"
      },
      "SmartItemSearchResponse": {
        "description": "Response for smart_item_search endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/SearchResultData",
            "description": "Search results"
          }
        },
        "required": [
          "data"
        ],
        "title": "SmartItemSearchResponse",
        "type": "object"
      },
      "DeleteQCStageRequest": {
        "description": "Request to delete a QC stage.",
        "properties": {
          "code": {
            "description": "QC stage code to delete",
            "title": "Code",
            "type": "string"
          },
          "force": {
            "default": false,
            "description": "If True, permanently delete. If False, set active=False",
            "title": "Force",
            "type": "boolean"
          }
        },
        "required": [
          "code"
        ],
        "title": "DeleteQCStageRequest",
        "type": "object"
      },
      "DeleteQCStageResponse": {
        "description": "Response for delete_qc_stage endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "QC stage deactivated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "DeleteQCStageResponse",
        "type": "object"
      },
      "GetQCStagesRequest": {
        "description": "Request to get QC stages.",
        "properties": {
          "active_only": {
            "default": true,
            "description": "If True, only return active QC stages",
            "title": "Active Only",
            "type": "boolean"
          }
        },
        "title": "GetQCStagesRequest",
        "type": "object"
      },
      "GetQCStagesResponse": {
        "description": "Response for get_qc_stages endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "List of QC stages",
            "items": {
              "$ref": "#/components/schemas/QCStageData"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Number of stages returned",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "QC stages retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetQCStagesResponse",
        "type": "object"
      },
      "QCStageData": {
        "description": "QC stage data structure.",
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Document name (same as code)",
            "title": "Name"
          },
          "code": {
            "description": "QC stage code (lowercase, underscored)",
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Human-readable label",
            "title": "Label",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Stage description",
            "title": "Description"
          },
          "display_order": {
            "default": 0,
            "description": "Sort order in UI",
            "title": "Display Order",
            "type": "integer"
          },
          "active": {
            "default": true,
            "description": "Whether stage is active",
            "title": "Active",
            "type": "boolean"
          }
        },
        "required": [
          "code",
          "label"
        ],
        "title": "QCStageData",
        "type": "object"
      },
      "QCStageInput": {
        "description": "Input for creating/updating a QC stage.",
        "properties": {
          "code": {
            "description": "QC stage code",
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Human-readable label",
            "title": "Label",
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Stage description",
            "title": "Description"
          },
          "display_order": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": 0,
            "description": "Sort order in UI",
            "title": "Display Order"
          },
          "active": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": true,
            "description": "Whether stage is active",
            "title": "Active"
          }
        },
        "required": [
          "code",
          "label"
        ],
        "title": "QCStageInput",
        "type": "object"
      },
      "SaveQCStageRequest": {
        "description": "Request to create or update a QC stage.",
        "properties": {
          "qc_stage": {
            "description": "JSON string of QC stage configuration",
            "title": "Qc Stage",
            "type": "string"
          }
        },
        "required": [
          "qc_stage"
        ],
        "title": "SaveQCStageRequest",
        "type": "object"
      },
      "SaveQCStageResponse": {
        "description": "Response for save_qc_stage endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/QCStageData",
            "description": "Saved QC stage"
          },
          "message": {
            "default": "QC stage saved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "SaveQCStageResponse",
        "type": "object"
      },
      "SeedQCStagesData": {
        "description": "Data from seed_qc_stages operation.",
        "properties": {
          "created": {
            "description": "Number of stages created",
            "title": "Created",
            "type": "integer"
          },
          "skipped": {
            "description": "Number of stages skipped (already exist)",
            "title": "Skipped",
            "type": "integer"
          },
          "total": {
            "description": "Total stages in seed data",
            "title": "Total",
            "type": "integer"
          }
        },
        "required": [
          "created",
          "skipped",
          "total"
        ],
        "title": "SeedQCStagesData",
        "type": "object"
      },
      "SeedQCStagesResponse": {
        "description": "Response for seed_qc_stages endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/SeedQCStagesData",
            "description": "Seeding operation results"
          },
          "message": {
            "default": "Seeding complete: X created, Y skipped",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "SeedQCStagesResponse",
        "type": "object"
      },
      "ConflictData": {
        "description": "Data returned when version conflict is detected.",
        "properties": {
          "server_version": {
            "description": "Current server version",
            "title": "Server Version",
            "type": "integer"
          },
          "server_preferences": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Server's current preferences for client-side merge",
            "title": "Server Preferences"
          }
        },
        "required": [
          "server_version"
        ],
        "title": "ConflictData",
        "type": "object"
      },
      "DebugData": {
        "description": "Debug information for troubleshooting sync issues.",
        "properties": {
          "frappe_session_user": {
            "description": "Current authenticated user",
            "title": "Frappe Session User",
            "type": "string"
          },
          "doctype_exists": {
            "description": "Whether User Preferences DocType exists",
            "title": "Doctype Exists",
            "type": "boolean"
          },
          "user_has_preferences": {
            "description": "Whether user has a preferences record",
            "title": "User Has Preferences",
            "type": "boolean"
          },
          "preferences_record": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PreferencesRecord"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Preferences record details (if exists)"
          },
          "server_time": {
            "description": "Current server time (ISO format)",
            "title": "Server Time",
            "type": "string"
          }
        },
        "required": [
          "frappe_session_user",
          "doctype_exists",
          "user_has_preferences",
          "server_time"
        ],
        "title": "DebugData",
        "type": "object"
      },
      "PreferencesRecord": {
        "description": "Preferences record info for debug endpoint.",
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Document name",
            "title": "Name"
          },
          "version": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Version number",
            "title": "Version"
          },
          "modified": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Last modified timestamp",
            "title": "Modified"
          },
          "last_synced_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Last sync timestamp",
            "title": "Last Synced At"
          }
        },
        "title": "PreferencesRecord",
        "type": "object"
      },
      "DebugUserPreferencesResponse": {
        "description": "Response for debug_user_preferences endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/DebugData",
            "description": "Debug information"
          },
          "message": {
            "default": "Debug info retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "DebugUserPreferencesResponse",
        "type": "object"
      },
      "DeleteUserPreferencesRequest": {
        "description": "Request to delete user preferences (admin only).",
        "properties": {
          "user_email": {
            "description": "Email/ID of the user whose preferences to delete",
            "title": "User Email",
            "type": "string"
          }
        },
        "required": [
          "user_email"
        ],
        "title": "DeleteUserPreferencesRequest",
        "type": "object"
      },
      "DeleteUserPreferencesResponse": {
        "description": "Response for delete_user_preferences endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "User preferences deleted successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "DeleteUserPreferencesResponse",
        "type": "object"
      },
      "MergeUserPreferencesRequest": {
        "description": "Request to merge partial preferences.",
        "properties": {
          "partial_preferences": {
            "description": "JSON string of preferences to merge",
            "title": "Partial Preferences",
            "type": "string"
          }
        },
        "required": [
          "partial_preferences"
        ],
        "title": "MergeUserPreferencesRequest",
        "type": "object"
      },
      "MergeUserPreferencesResponse": {
        "description": "Response for merge_user_preferences endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/UpdateResultData",
            "description": "Merge result"
          },
          "message": {
            "default": "Preferences merged successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "MergeUserPreferencesResponse",
        "type": "object"
      },
      "ResolvePreferencesConflictRequest": {
        "description": "Request to force-save after client-side conflict resolution.",
        "properties": {
          "merged_preferences": {
            "description": "JSON string of merged/resolved preferences",
            "title": "Merged Preferences",
            "type": "string"
          },
          "resolved_from_version": {
            "description": "The server version used in the merge (for audit trail)",
            "title": "Resolved From Version",
            "type": "string"
          }
        },
        "required": [
          "merged_preferences",
          "resolved_from_version"
        ],
        "title": "ResolvePreferencesConflictRequest",
        "type": "object"
      },
      "ResolvePreferencesConflictResponse": {
        "description": "Response for resolve_preferences_conflict endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/UpdateResultData",
            "description": "Resolution result"
          },
          "message": {
            "default": "Conflict resolved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "ResolvePreferencesConflictResponse",
        "type": "object"
      },
      "UpdateUserPreferencesConflictResponse": {
        "description": "Response for update_user_preferences endpoint (conflict case).",
        "properties": {
          "success": {
            "default": false,
            "title": "Success",
            "type": "boolean"
          },
          "error_code": {
            "default": "CONFLICT",
            "description": "Error code indicating version conflict",
            "title": "Error Code",
            "type": "string"
          },
          "data": {
            "$ref": "#/components/schemas/ConflictData",
            "description": "Server data for client-side merge"
          },
          "message": {
            "default": "Version conflict - server has newer data",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateUserPreferencesConflictResponse",
        "type": "object"
      },
      "GetOAuthUserInfoResponse": {
        "description": "Response for get_oauth_userinfo endpoint.\n\nDirectly returns the OAuthUserInfo structure (not wrapped in success/data).\nThis matches the OAuth/OIDC userinfo standard format.",
        "properties": {
          "sub": {
            "description": "Subject identifier (user email)",
            "title": "Sub",
            "type": "string"
          },
          "email": {
            "description": "User email address",
            "title": "Email",
            "type": "string"
          },
          "name": {
            "description": "User display name",
            "title": "Name",
            "type": "string"
          },
          "full_name": {
            "default": "",
            "description": "User full name",
            "title": "Full Name",
            "type": "string"
          },
          "user_id": {
            "description": "User identifier (same as email)",
            "title": "User Id",
            "type": "string"
          },
          "roles": {
            "description": "Array of Pacific Bending application roles",
            "items": {
              "type": "string"
            },
            "title": "Roles",
            "type": "array"
          },
          "permissions": {
            "description": "High-level permission indicators",
            "items": {
              "type": "string"
            },
            "title": "Permissions",
            "type": "array"
          }
        },
        "required": [
          "sub",
          "email",
          "name",
          "user_id",
          "roles"
        ],
        "title": "GetOAuthUserInfoResponse",
        "type": "object"
      },
      "OAuthUserInfo": {
        "description": "OAuth userinfo response for NextAuth integration.\n\nReturns user profile information with ALL roles as an array,\nwhich is required by NextAuth's profile() callback.",
        "properties": {
          "sub": {
            "description": "Subject identifier (user email)",
            "title": "Sub",
            "type": "string"
          },
          "email": {
            "description": "User email address",
            "title": "Email",
            "type": "string"
          },
          "name": {
            "description": "User display name",
            "title": "Name",
            "type": "string"
          },
          "full_name": {
            "default": "",
            "description": "User full name",
            "title": "Full Name",
            "type": "string"
          },
          "user_id": {
            "description": "User identifier (same as email)",
            "title": "User Id",
            "type": "string"
          },
          "roles": {
            "description": "Array of Pacific Bending application roles",
            "items": {
              "type": "string"
            },
            "title": "Roles",
            "type": "array"
          },
          "permissions": {
            "description": "High-level permission indicators",
            "items": {
              "type": "string"
            },
            "title": "Permissions",
            "type": "array"
          }
        },
        "required": [
          "sub",
          "email",
          "name",
          "user_id",
          "roles"
        ],
        "title": "OAuthUserInfo",
        "type": "object"
      },
      "AppCheck": {
        "description": "Application status check result.",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/HealthStatus",
            "description": "Health status"
          },
          "site": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Current Frappe site name",
            "title": "Site"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Error message if unhealthy",
            "title": "Error"
          }
        },
        "required": [
          "status"
        ],
        "title": "AppCheck",
        "type": "object"
      },
      "HealthStatus": {
        "description": "Health status values.",
        "enum": [
          "healthy",
          "unhealthy",
          "degraded"
        ],
        "title": "HealthStatus",
        "type": "string"
      },
      "CacheCheck": {
        "description": "Cache (Redis) connectivity check result.",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/HealthStatus",
            "description": "Health status"
          },
          "response_time_ms": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Response time in milliseconds",
            "title": "Response Time Ms"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Error message if unhealthy",
            "title": "Error"
          }
        },
        "required": [
          "status"
        ],
        "title": "CacheCheck",
        "type": "object"
      },
      "DatabaseCheck": {
        "description": "Database connectivity check result.",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/HealthStatus",
            "description": "Health status"
          },
          "response_time_ms": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Response time in milliseconds",
            "title": "Response Time Ms"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Error message if unhealthy",
            "title": "Error"
          }
        },
        "required": [
          "status"
        ],
        "title": "DatabaseCheck",
        "type": "object"
      },
      "DetailedHealthCheckResponse": {
        "description": "Response for detailed_check endpoint.\n\nExtended health check with PDF-specific metrics (requires authentication).",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/HealthStatus",
            "description": "Overall health status"
          },
          "timestamp": {
            "description": "Unix timestamp",
            "title": "Timestamp",
            "type": "integer"
          },
          "checks": {
            "$ref": "#/components/schemas/DetailedHealthChecks",
            "description": "Detailed check results"
          },
          "total_response_time_ms": {
            "description": "Total response time in milliseconds",
            "title": "Total Response Time Ms",
            "type": "number"
          }
        },
        "required": [
          "status",
          "timestamp",
          "checks",
          "total_response_time_ms"
        ],
        "title": "DetailedHealthCheckResponse",
        "type": "object"
      },
      "DetailedHealthChecks": {
        "description": "Extended health checks for authenticated users.",
        "properties": {
          "database": {
            "$ref": "#/components/schemas/DatabaseCheck",
            "description": "Database connectivity"
          },
          "cache": {
            "$ref": "#/components/schemas/CacheCheck",
            "description": "Cache (Redis) connectivity"
          },
          "app": {
            "$ref": "#/components/schemas/AppCheck",
            "description": "Application status"
          },
          "pdf_storage": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PDFStorageCheck"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "PDF storage status"
          },
          "templates": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TemplateCheck"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Template count"
          },
          "pdf_system": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "PDF system status (if error)",
            "title": "Pdf System"
          }
        },
        "required": [
          "database",
          "cache",
          "app"
        ],
        "title": "DetailedHealthChecks",
        "type": "object"
      },
      "PDFStorageCheck": {
        "description": "PDF storage directories check result.",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/HealthStatus",
            "description": "Health status"
          },
          "generated_pdfs_dir_exists": {
            "description": "Whether generated_pdfs directory exists",
            "title": "Generated Pdfs Dir Exists",
            "type": "boolean"
          },
          "letterheads_dir_exists": {
            "description": "Whether letterheads directory exists",
            "title": "Letterheads Dir Exists",
            "type": "boolean"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Error message if degraded",
            "title": "Error"
          }
        },
        "required": [
          "status",
          "generated_pdfs_dir_exists",
          "letterheads_dir_exists"
        ],
        "title": "PDFStorageCheck",
        "type": "object"
      },
      "TemplateCheck": {
        "description": "Template count check result.",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/HealthStatus",
            "description": "Health status"
          },
          "count": {
            "description": "Number of print format templates",
            "title": "Count",
            "type": "integer"
          }
        },
        "required": [
          "status",
          "count"
        ],
        "title": "TemplateCheck",
        "type": "object"
      },
      "HealthCheckResponse": {
        "description": "Response for check endpoint.\n\nBasic health check for load balancers (allow_guest=True).",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/HealthStatus",
            "description": "Overall health status"
          },
          "timestamp": {
            "description": "Unix timestamp",
            "title": "Timestamp",
            "type": "integer"
          },
          "checks": {
            "$ref": "#/components/schemas/HealthChecks",
            "description": "Individual check results"
          },
          "total_response_time_ms": {
            "description": "Total response time in milliseconds",
            "title": "Total Response Time Ms",
            "type": "number"
          }
        },
        "required": [
          "status",
          "timestamp",
          "checks",
          "total_response_time_ms"
        ],
        "title": "HealthCheckResponse",
        "type": "object"
      },
      "HealthChecks": {
        "description": "Collection of health check results.",
        "properties": {
          "database": {
            "$ref": "#/components/schemas/DatabaseCheck",
            "description": "Database connectivity"
          },
          "cache": {
            "$ref": "#/components/schemas/CacheCheck",
            "description": "Cache (Redis) connectivity"
          },
          "app": {
            "$ref": "#/components/schemas/AppCheck",
            "description": "Application status"
          }
        },
        "required": [
          "database",
          "cache",
          "app"
        ],
        "title": "HealthChecks",
        "type": "object"
      },
      "PingResponse": {
        "description": "Response for ping endpoint.\n\nUltra-simple ping for basic connectivity testing (allow_guest=True).",
        "properties": {
          "status": {
            "default": "ok",
            "description": "Status indicator",
            "title": "Status",
            "type": "string"
          },
          "message": {
            "default": "pong",
            "description": "Ping response",
            "title": "Message",
            "type": "string"
          },
          "timestamp": {
            "description": "Unix timestamp",
            "title": "Timestamp",
            "type": "integer"
          }
        },
        "required": [
          "timestamp"
        ],
        "title": "PingResponse",
        "type": "object"
      },
      "CustomFieldDefinition": {
        "description": "Custom field definition structure.",
        "properties": {
          "field_name": {
            "description": "Unique field identifier",
            "title": "Field Name",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "field_type": {
            "$ref": "#/components/schemas/FieldType",
            "description": "Field type (text or number)"
          },
          "unit": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Unit suffix (e.g., 'ga', 'mm')",
            "title": "Unit"
          },
          "required": {
            "default": false,
            "description": "Whether field is required",
            "title": "Required",
            "type": "boolean"
          },
          "display_order": {
            "default": 0,
            "description": "Sort order in UI",
            "title": "Display Order",
            "type": "integer"
          },
          "active": {
            "default": true,
            "description": "Whether field is active",
            "title": "Active",
            "type": "boolean"
          },
          "placeholder": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Input placeholder text",
            "title": "Placeholder"
          },
          "help_text": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Help text for users",
            "title": "Help Text"
          }
        },
        "required": [
          "field_name",
          "label",
          "field_type"
        ],
        "title": "CustomFieldDefinition",
        "type": "object"
      },
      "FieldType": {
        "description": "Supported custom field types.",
        "enum": [
          "text",
          "number"
        ],
        "title": "FieldType",
        "type": "string"
      },
      "DeleteCustomFieldDefinitionErrorResponse": {
        "description": "Error response for delete_custom_field_definition endpoint.",
        "properties": {
          "success": {
            "default": false,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "description": "Error message",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "message"
        ],
        "title": "DeleteCustomFieldDefinitionErrorResponse",
        "type": "object"
      },
      "DeleteCustomFieldDefinitionRequest": {
        "description": "Request to delete a custom field definition.",
        "properties": {
          "field_name": {
            "description": "Field name to delete",
            "title": "Field Name",
            "type": "string"
          },
          "force": {
            "default": false,
            "description": "If True, permanently remove. If False, set active=False",
            "title": "Force",
            "type": "boolean"
          }
        },
        "required": [
          "field_name"
        ],
        "title": "DeleteCustomFieldDefinitionRequest",
        "type": "object"
      },
      "DeleteCustomFieldDefinitionResponse": {
        "description": "Response for delete_custom_field_definition endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "Custom field deleted successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "DeleteCustomFieldDefinitionResponse",
        "type": "object"
      },
      "GetCustomFieldDefinitionsResponse": {
        "description": "Response for get_custom_field_definitions endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "description": "Active custom field definitions",
            "items": {
              "$ref": "#/components/schemas/CustomFieldDefinition"
            },
            "title": "Data",
            "type": "array"
          },
          "count": {
            "description": "Number of fields returned",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Custom fields retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetCustomFieldDefinitionsResponse",
        "type": "object"
      },
      "ReorderCustomFieldsRequest": {
        "description": "Request to reorder custom fields.",
        "properties": {
          "field_order": {
            "description": "JSON array of field names in desired order",
            "title": "Field Order",
            "type": "string"
          }
        },
        "required": [
          "field_order"
        ],
        "title": "ReorderCustomFieldsRequest",
        "type": "object"
      },
      "ReorderCustomFieldsResponse": {
        "description": "Response for reorder_custom_fields endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "Fields reordered successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "ReorderCustomFieldsResponse",
        "type": "object"
      },
      "SaveCustomFieldDefinitionErrorResponse": {
        "description": "Error response for save_custom_field_definition endpoint.",
        "properties": {
          "success": {
            "default": false,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "description": "Error message",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "message"
        ],
        "title": "SaveCustomFieldDefinitionErrorResponse",
        "type": "object"
      },
      "SaveCustomFieldDefinitionRequest": {
        "description": "Request to create or update a custom field definition.",
        "properties": {
          "field_definition": {
            "description": "JSON string of field config",
            "title": "Field Definition",
            "type": "string"
          }
        },
        "required": [
          "field_definition"
        ],
        "title": "SaveCustomFieldDefinitionRequest",
        "type": "object"
      },
      "SaveCustomFieldDefinitionResponse": {
        "description": "Response for save_custom_field_definition endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/CustomFieldDefinition",
            "description": "Saved field definition"
          },
          "message": {
            "default": "Custom field saved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "SaveCustomFieldDefinitionResponse",
        "type": "object"
      },
      "AdminBadgesData": {
        "description": "Data containing all badges including inactive (admin view).",
        "properties": {
          "badges": {
            "description": "All badges with isActive flag",
            "items": {
              "$ref": "#/components/schemas/QuickAddBadgeAdmin"
            },
            "title": "Badges",
            "type": "array"
          }
        },
        "required": [
          "badges"
        ],
        "title": "AdminBadgesData",
        "type": "object"
      },
      "BadgeCategoryAdmin": {
        "description": "Category with admin-specific fields.",
        "properties": {
          "code": {
            "description": "Tax Fee Category code",
            "title": "Code",
            "type": "string"
          },
          "label": {
            "default": "",
            "description": "Category label",
            "title": "Label",
            "type": "string"
          },
          "defaultRate": {
            "default": 0,
            "description": "Default rate (uses override if set)",
            "title": "Defaultrate",
            "type": "number"
          },
          "chargeType": {
            "$ref": "#/components/schemas/ChargeType",
            "default": "Percentage",
            "description": "Charge type"
          },
          "isTax": {
            "default": true,
            "description": "Whether this is a tax (vs fee)",
            "title": "Istax",
            "type": "boolean"
          },
          "overrideRate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Badge-specific rate override",
            "title": "Overriderate"
          }
        },
        "required": [
          "code"
        ],
        "title": "BadgeCategoryAdmin",
        "type": "object"
      },
      "ChargeType": {
        "description": "Charge type for tax/fee categories.",
        "enum": [
          "Percentage",
          "Fixed"
        ],
        "title": "ChargeType",
        "type": "string"
      },
      "ColorVariant": {
        "description": "Available color variants for badge styling.",
        "enum": [
          "emerald",
          "amber",
          "blue",
          "purple",
          "red",
          "slate"
        ],
        "title": "ColorVariant",
        "type": "string"
      },
      "QuickAddBadgeAdmin": {
        "description": "Quick add badge with admin-specific fields.",
        "properties": {
          "code": {
            "description": "Badge code (uppercase, underscored)",
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "tooltipText": {
            "default": "",
            "description": "Tooltip text",
            "title": "Tooltiptext",
            "type": "string"
          },
          "iconName": {
            "default": "Zap",
            "description": "Lucide icon name",
            "title": "Iconname",
            "type": "string"
          },
          "colorVariant": {
            "$ref": "#/components/schemas/ColorVariant",
            "default": "emerald",
            "description": "Color variant"
          },
          "displayOrder": {
            "default": 0,
            "description": "Sort order in UI",
            "title": "Displayorder",
            "type": "integer"
          },
          "categories": {
            "description": "Linked categories with override rates",
            "items": {
              "$ref": "#/components/schemas/BadgeCategoryAdmin"
            },
            "title": "Categories",
            "type": "array"
          },
          "name": {
            "description": "Document name (same as code)",
            "title": "Name",
            "type": "string"
          },
          "isActive": {
            "default": true,
            "description": "Whether badge is active",
            "title": "Isactive",
            "type": "boolean"
          }
        },
        "required": [
          "code",
          "label",
          "name"
        ],
        "title": "QuickAddBadgeAdmin",
        "type": "object"
      },
      "BadgeCategory": {
        "description": "Category linked to a quick add badge.",
        "properties": {
          "code": {
            "description": "Tax Fee Category code",
            "title": "Code",
            "type": "string"
          },
          "label": {
            "default": "",
            "description": "Category label",
            "title": "Label",
            "type": "string"
          },
          "defaultRate": {
            "default": 0,
            "description": "Default rate (uses override if set)",
            "title": "Defaultrate",
            "type": "number"
          },
          "chargeType": {
            "$ref": "#/components/schemas/ChargeType",
            "default": "Percentage",
            "description": "Charge type"
          },
          "isTax": {
            "default": true,
            "description": "Whether this is a tax (vs fee)",
            "title": "Istax",
            "type": "boolean"
          }
        },
        "required": [
          "code"
        ],
        "title": "BadgeCategory",
        "type": "object"
      },
      "BadgeInput": {
        "description": "Input for creating/updating a quick add badge.",
        "properties": {
          "code": {
            "description": "Badge code",
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "tooltipText": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "",
            "description": "Tooltip text",
            "title": "Tooltiptext"
          },
          "iconName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "Zap",
            "description": "Lucide icon name",
            "title": "Iconname"
          },
          "colorVariant": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": "emerald",
            "description": "Color variant",
            "title": "Colorvariant"
          },
          "displayOrder": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": 0,
            "description": "Sort order",
            "title": "Displayorder"
          },
          "isActive": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "default": true,
            "description": "Active status",
            "title": "Isactive"
          },
          "categories": {
            "description": "Linked categories",
            "items": {
              "$ref": "#/components/schemas/CategoryInput"
            },
            "title": "Categories",
            "type": "array"
          }
        },
        "required": [
          "code",
          "label",
          "categories"
        ],
        "title": "BadgeInput",
        "type": "object"
      },
      "CategoryInput": {
        "description": "Category input for badge creation/update.",
        "properties": {
          "code": {
            "description": "Tax Fee Category code",
            "title": "Code",
            "type": "string"
          },
          "overrideRate": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Badge-specific rate override",
            "title": "Overriderate"
          }
        },
        "required": [
          "code"
        ],
        "title": "CategoryInput",
        "type": "object"
      },
      "BadgesData": {
        "description": "Data containing badges list.",
        "properties": {
          "badges": {
            "description": "List of badges",
            "items": {
              "$ref": "#/components/schemas/QuickAddBadge"
            },
            "title": "Badges",
            "type": "array"
          }
        },
        "required": [
          "badges"
        ],
        "title": "BadgesData",
        "type": "object"
      },
      "QuickAddBadge": {
        "description": "Quick add badge for quote editor.",
        "properties": {
          "code": {
            "description": "Badge code (uppercase, underscored)",
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Display label",
            "title": "Label",
            "type": "string"
          },
          "tooltipText": {
            "default": "",
            "description": "Tooltip text",
            "title": "Tooltiptext",
            "type": "string"
          },
          "iconName": {
            "default": "Zap",
            "description": "Lucide icon name",
            "title": "Iconname",
            "type": "string"
          },
          "colorVariant": {
            "$ref": "#/components/schemas/ColorVariant",
            "default": "emerald",
            "description": "Color variant"
          },
          "displayOrder": {
            "default": 0,
            "description": "Sort order in UI",
            "title": "Displayorder",
            "type": "integer"
          },
          "categories": {
            "description": "Linked tax/fee categories",
            "items": {
              "$ref": "#/components/schemas/BadgeCategory"
            },
            "title": "Categories",
            "type": "array"
          }
        },
        "required": [
          "code",
          "label"
        ],
        "title": "QuickAddBadge",
        "type": "object"
      },
      "CreateBadgeData": {
        "description": "Data from badge creation.",
        "properties": {
          "name": {
            "description": "Document name",
            "title": "Name",
            "type": "string"
          },
          "code": {
            "description": "Badge code",
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Badge label",
            "title": "Label",
            "type": "string"
          }
        },
        "required": [
          "name",
          "code",
          "label"
        ],
        "title": "CreateBadgeData",
        "type": "object"
      },
      "CreateQuickAddBadgeRequest": {
        "description": "Request to create a new quick add badge.",
        "properties": {
          "badge": {
            "description": "JSON string of badge data",
            "title": "Badge",
            "type": "string"
          }
        },
        "required": [
          "badge"
        ],
        "title": "CreateQuickAddBadgeRequest",
        "type": "object"
      },
      "CreateQuickAddBadgeResponse": {
        "description": "Response for create_quick_add_badge endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/CreateBadgeData",
            "description": "Created badge info"
          },
          "message": {
            "default": "Quick add badge created successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CreateQuickAddBadgeResponse",
        "type": "object"
      },
      "DeleteQuickAddBadgeRequest": {
        "description": "Request to delete (soft delete) a quick add badge.",
        "properties": {
          "name": {
            "description": "Badge document name (code)",
            "title": "Name",
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "title": "DeleteQuickAddBadgeRequest",
        "type": "object"
      },
      "DeleteQuickAddBadgeResponse": {
        "description": "Response for delete_quick_add_badge endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "message": {
            "default": "Quick add badge deactivated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "DeleteQuickAddBadgeResponse",
        "type": "object"
      },
      "GetAllQuickAddBadgesResponse": {
        "description": "Response for get_all_quick_add_badges endpoint (admin).",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/AdminBadgesData",
            "description": "All badges data"
          },
          "count": {
            "description": "Number of badges returned",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "All quick add badges retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetAllQuickAddBadgesResponse",
        "type": "object"
      },
      "GetQuickAddBadgesResponse": {
        "description": "Response for get_quick_add_badges endpoint (quote editor).",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/BadgesData",
            "description": "Badges data"
          },
          "count": {
            "description": "Number of badges returned",
            "title": "Count",
            "type": "integer"
          },
          "message": {
            "default": "Quick add badges retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data",
          "count"
        ],
        "title": "GetQuickAddBadgesResponse",
        "type": "object"
      },
      "ResetBadgesData": {
        "description": "Data from reset operation.",
        "properties": {
          "created": {
            "description": "Number of badges created",
            "title": "Created",
            "type": "integer"
          },
          "updated": {
            "description": "Number of badges updated",
            "title": "Updated",
            "type": "integer"
          },
          "archived": {
            "description": "Number of custom badges archived",
            "title": "Archived",
            "type": "integer"
          },
          "badges": {
            "description": "List of default badge codes",
            "items": {
              "type": "string"
            },
            "title": "Badges",
            "type": "array"
          }
        },
        "required": [
          "created",
          "updated",
          "archived",
          "badges"
        ],
        "title": "ResetBadgesData",
        "type": "object"
      },
      "ResetQuickAddBadgesResponse": {
        "description": "Response for reset_quick_add_badges endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/ResetBadgesData",
            "description": "Reset operation results"
          },
          "message": {
            "default": "Quick add badges reset: X created, Y updated, Z archived",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "ResetQuickAddBadgesResponse",
        "type": "object"
      },
      "UpdateBadgeData": {
        "description": "Data from badge update.",
        "properties": {
          "name": {
            "description": "Document name",
            "title": "Name",
            "type": "string"
          },
          "code": {
            "description": "Badge code",
            "title": "Code",
            "type": "string"
          },
          "label": {
            "description": "Badge label",
            "title": "Label",
            "type": "string"
          },
          "isActive": {
            "description": "Active status",
            "title": "Isactive",
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "code",
          "label",
          "isActive"
        ],
        "title": "UpdateBadgeData",
        "type": "object"
      },
      "UpdateQuickAddBadgeRequest": {
        "description": "Request to update an existing quick add badge.",
        "properties": {
          "name": {
            "description": "Badge document name (code)",
            "title": "Name",
            "type": "string"
          },
          "badge": {
            "description": "JSON string of updated badge data",
            "title": "Badge",
            "type": "string"
          }
        },
        "required": [
          "name",
          "badge"
        ],
        "title": "UpdateQuickAddBadgeRequest",
        "type": "object"
      },
      "UpdateQuickAddBadgeResponse": {
        "description": "Response for update_quick_add_badge endpoint.",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/UpdateBadgeData",
            "description": "Updated badge info"
          },
          "message": {
            "default": "Quick add badge updated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "UpdateQuickAddBadgeResponse",
        "type": "object"
      },
      "ChangeSummary": {
        "description": "Summary of changes between versions",
        "properties": {
          "items_added": {
            "default": 0,
            "description": "Number of line items added",
            "minimum": 0,
            "title": "Items Added",
            "type": "integer"
          },
          "items_removed": {
            "default": 0,
            "description": "Number of line items removed",
            "minimum": 0,
            "title": "Items Removed",
            "type": "integer"
          },
          "items_modified": {
            "default": 0,
            "description": "Number of line items modified",
            "minimum": 0,
            "title": "Items Modified",
            "type": "integer"
          },
          "fields_changed": {
            "default": 0,
            "description": "Number of quote-level fields changed",
            "minimum": 0,
            "title": "Fields Changed",
            "type": "integer"
          },
          "total_difference": {
            "default": 0,
            "description": "Change in grand total",
            "title": "Total Difference",
            "type": "number"
          },
          "percent_difference": {
            "default": 0,
            "description": "Percentage change in grand total",
            "title": "Percent Difference",
            "type": "number"
          },
          "diff_summary": {
            "default": "",
            "description": "Human-readable summary of changes",
            "title": "Diff Summary",
            "type": "string"
          }
        },
        "title": "ChangeSummary",
        "type": "object"
      },
      "CompareTwoVersionsRequest": {
        "description": "Request for comparing two versions",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID",
            "title": "Quotation Id",
            "type": "string"
          },
          "version1": {
            "description": "First version number (typically older)",
            "minimum": 1,
            "title": "Version1",
            "type": "integer"
          },
          "version2": {
            "description": "Second version number (typically newer)",
            "minimum": 1,
            "title": "Version2",
            "type": "integer"
          }
        },
        "required": [
          "quotation_id",
          "version1",
          "version2"
        ],
        "title": "CompareTwoVersionsRequest",
        "type": "object"
      },
      "CompareTwoVersionsResponse": {
        "description": "Response for version comparison",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/VersionComparison"
          },
          "message": {
            "default": "Comparison completed successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "CompareTwoVersionsResponse",
        "type": "object"
      },
      "FieldChange": {
        "description": "A single field change between versions",
        "properties": {
          "field": {
            "description": "Field name",
            "title": "Field",
            "type": "string"
          },
          "old_value": {
            "default": null,
            "description": "Previous value",
            "title": "Old Value"
          },
          "new_value": {
            "default": null,
            "description": "New value",
            "title": "New Value"
          },
          "label": {
            "default": "",
            "description": "Human-readable field label",
            "title": "Label",
            "type": "string"
          }
        },
        "required": [
          "field"
        ],
        "title": "FieldChange",
        "type": "object"
      },
      "ItemChange": {
        "description": "A line item change between versions",
        "properties": {
          "item_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Item code if available",
            "title": "Item Code"
          },
          "description": {
            "default": "",
            "description": "Item description",
            "title": "Description",
            "type": "string"
          },
          "change_type": {
            "description": "Type of change: added, removed, modified",
            "title": "Change Type",
            "type": "string"
          },
          "changes": {
            "description": "Field-level changes for modified items",
            "items": {
              "$ref": "#/components/schemas/FieldChange"
            },
            "title": "Changes",
            "type": "array"
          }
        },
        "required": [
          "change_type"
        ],
        "title": "ItemChange",
        "type": "object"
      },
      "VersionComparison": {
        "description": "Comparison data between two versions",
        "properties": {
          "field_changes": {
            "description": "Quote-level field changes",
            "items": {
              "$ref": "#/components/schemas/FieldChange"
            },
            "title": "Field Changes",
            "type": "array"
          },
          "item_changes": {
            "additionalProperties": {
              "items": {
                "$ref": "#/components/schemas/ItemChange"
              },
              "type": "array"
            },
            "description": "Line item changes grouped by type: added, removed, modified",
            "title": "Item Changes",
            "type": "object"
          },
          "summary": {
            "$ref": "#/components/schemas/ChangeSummary"
          }
        },
        "title": "VersionComparison",
        "type": "object"
      },
      "GetSuggestedLabelData": {
        "description": "Data payload for suggested label response",
        "properties": {
          "suggested_label": {
            "default": "",
            "description": "Suggested label based on context",
            "title": "Suggested Label",
            "type": "string"
          }
        },
        "title": "GetSuggestedLabelData",
        "type": "object"
      },
      "GetSuggestedLabelRequest": {
        "description": "Request for suggested version label",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID",
            "title": "Quotation Id",
            "type": "string"
          }
        },
        "required": [
          "quotation_id"
        ],
        "title": "GetSuggestedLabelRequest",
        "type": "object"
      },
      "GetSuggestedLabelResponse": {
        "description": "Response for suggested label",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/GetSuggestedLabelData"
          },
          "message": {
            "default": "Label suggestion retrieved",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetSuggestedLabelResponse",
        "type": "object"
      },
      "GetVersionDetailData": {
        "description": "Data payload for version detail response",
        "properties": {
          "version": {
            "$ref": "#/components/schemas/VersionDetail"
          },
          "snapshot": {
            "additionalProperties": true,
            "description": "Full quotation snapshot",
            "title": "Snapshot",
            "type": "object"
          },
          "items": {
            "description": "Line items snapshot",
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "title": "Items",
            "type": "array"
          },
          "comparison": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/VersionComparison"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Comparison with current version"
          }
        },
        "required": [
          "version"
        ],
        "title": "GetVersionDetailData",
        "type": "object"
      },
      "UserInfo": {
        "description": "User information for version creator",
        "properties": {
          "email": {
            "description": "User email address",
            "title": "Email",
            "type": "string"
          },
          "full_name": {
            "description": "User's full name",
            "title": "Full Name",
            "type": "string"
          }
        },
        "required": [
          "email",
          "full_name"
        ],
        "title": "UserInfo",
        "type": "object"
      },
      "VersionDetail": {
        "description": "Detailed version metadata",
        "properties": {
          "name": {
            "description": "Version document name",
            "title": "Name",
            "type": "string"
          },
          "version_number": {
            "minimum": 1,
            "title": "Version Number",
            "type": "integer"
          },
          "version_label": {
            "default": "",
            "title": "Version Label",
            "type": "string"
          },
          "created_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "title": "Created At"
          },
          "notes": {
            "default": "",
            "title": "Notes",
            "type": "string"
          },
          "grand_total": {
            "default": 0,
            "title": "Grand Total",
            "type": "number"
          },
          "item_count": {
            "default": 0,
            "title": "Item Count",
            "type": "integer"
          },
          "created_by": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UserInfo"
              },
              {
                "type": "null"
              }
            ],
            "default": null
          }
        },
        "required": [
          "name",
          "version_number"
        ],
        "title": "VersionDetail",
        "type": "object"
      },
      "GetVersionDetailRequest": {
        "description": "Request for version detail with full snapshot",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID",
            "title": "Quotation Id",
            "type": "string"
          },
          "version_number": {
            "description": "Version number to retrieve",
            "minimum": 1,
            "title": "Version Number",
            "type": "integer"
          }
        },
        "required": [
          "quotation_id",
          "version_number"
        ],
        "title": "GetVersionDetailRequest",
        "type": "object"
      },
      "GetVersionDetailResponse": {
        "description": "Response for version detail",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/GetVersionDetailData"
          },
          "message": {
            "default": "Version details retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetVersionDetailResponse",
        "type": "object"
      },
      "GetVersionsData": {
        "description": "Data payload for version history response",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID",
            "title": "Quotation Id",
            "type": "string"
          },
          "current_version": {
            "default": 0,
            "description": "Current version number",
            "minimum": 0,
            "title": "Current Version",
            "type": "integer"
          },
          "has_versions": {
            "default": false,
            "description": "Whether quotation has any saved versions",
            "title": "Has Versions",
            "type": "boolean"
          },
          "versions": {
            "description": "List of versions",
            "items": {
              "$ref": "#/components/schemas/QuotationVersionSummary"
            },
            "title": "Versions",
            "type": "array"
          }
        },
        "required": [
          "quotation_id"
        ],
        "title": "GetVersionsData",
        "type": "object"
      },
      "QuotationVersionSummary": {
        "description": "Version summary for timeline display",
        "properties": {
          "name": {
            "description": "Version document name (e.g., QVER-QTN-00042-3)",
            "title": "Name",
            "type": "string"
          },
          "version_number": {
            "description": "Sequential version number",
            "minimum": 1,
            "title": "Version Number",
            "type": "integer"
          },
          "version_label": {
            "default": "",
            "description": "Optional label (e.g., 'Sent to Customer')",
            "title": "Version Label",
            "type": "string"
          },
          "created_at": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Creation timestamp (ISO format)",
            "title": "Created At"
          },
          "notes": {
            "default": "",
            "description": "What changed in this version",
            "title": "Notes",
            "type": "string"
          },
          "grand_total": {
            "default": 0,
            "description": "Quote total at time of snapshot",
            "minimum": 0,
            "title": "Grand Total",
            "type": "number"
          },
          "item_count": {
            "default": 0,
            "description": "Number of line items",
            "minimum": 0,
            "title": "Item Count",
            "type": "integer"
          },
          "change_summary": {
            "$ref": "#/components/schemas/ChangeSummary"
          },
          "is_current": {
            "default": false,
            "description": "Whether this is the current version",
            "title": "Is Current",
            "type": "boolean"
          },
          "created_by": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/UserInfo"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "User who saved this version"
          }
        },
        "required": [
          "name",
          "version_number"
        ],
        "title": "QuotationVersionSummary",
        "type": "object"
      },
      "GetVersionsRequest": {
        "description": "Request for version history",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID (e.g., QTN-00042)",
            "title": "Quotation Id",
            "type": "string"
          }
        },
        "required": [
          "quotation_id"
        ],
        "title": "GetVersionsRequest",
        "type": "object"
      },
      "GetVersionsResponse": {
        "description": "Response for version history",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/GetVersionsData"
          },
          "message": {
            "default": "Version history retrieved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "GetVersionsResponse",
        "type": "object"
      },
      "RestoreVersionData": {
        "description": "Data payload for restore version response",
        "properties": {
          "new_version_number": {
            "description": "New version number created",
            "minimum": 1,
            "title": "New Version Number",
            "type": "integer"
          },
          "restored_from": {
            "description": "Version number restored from",
            "minimum": 1,
            "title": "Restored From",
            "type": "integer"
          },
          "message": {
            "description": "Human-readable result message",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "new_version_number",
          "restored_from",
          "message"
        ],
        "title": "RestoreVersionData",
        "type": "object"
      },
      "RestoreVersionRequest": {
        "description": "Request for restoring from a previous version",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID",
            "title": "Quotation Id",
            "type": "string"
          },
          "version_number": {
            "description": "Version number to restore from",
            "minimum": 1,
            "title": "Version Number",
            "type": "integer"
          },
          "notes": {
            "anyOf": [
              {
                "maxLength": 500,
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Optional notes for the restore operation",
            "title": "Notes"
          }
        },
        "required": [
          "quotation_id",
          "version_number"
        ],
        "title": "RestoreVersionRequest",
        "type": "object"
      },
      "RestoreVersionResponse": {
        "description": "Response for restoring a version",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/RestoreVersionData"
          },
          "message": {
            "default": "Version restored successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "RestoreVersionResponse",
        "type": "object"
      },
      "SaveVersionData": {
        "description": "Data payload for save version response",
        "properties": {
          "version_number": {
            "description": "Created version number",
            "minimum": 1,
            "title": "Version Number",
            "type": "integer"
          },
          "name": {
            "description": "Version document name",
            "title": "Name",
            "type": "string"
          }
        },
        "required": [
          "version_number",
          "name"
        ],
        "title": "SaveVersionData",
        "type": "object"
      },
      "SaveVersionRequest": {
        "description": "Request for saving a new version checkpoint",
        "properties": {
          "quotation_id": {
            "description": "Quotation ID",
            "title": "Quotation Id",
            "type": "string"
          },
          "version_label": {
            "anyOf": [
              {
                "maxLength": 100,
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Optional label for this version",
            "title": "Version Label"
          },
          "notes": {
            "anyOf": [
              {
                "maxLength": 500,
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Optional description of what changed",
            "title": "Notes"
          }
        },
        "required": [
          "quotation_id"
        ],
        "title": "SaveVersionRequest",
        "type": "object"
      },
      "SaveVersionResponse": {
        "description": "Response for saving a new version",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/SaveVersionData"
          },
          "message": {
            "default": "Version saved successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "SaveVersionResponse",
        "type": "object"
      },
      "ApiResponse": {
        "description": "Standard API response wrapper\n\nAll Pacific Bending API endpoints return responses in this format.\nThe `data` field contains the actual response payload.\n\nExample:\n    {\n        \"success\": true,\n        \"data\": {...},\n        \"message\": \"Success\"\n    }",
        "properties": {
          "success": {
            "default": true,
            "description": "Whether the operation succeeded",
            "title": "Success",
            "type": "boolean"
          },
          "data": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Response payload",
            "title": "Data"
          },
          "message": {
            "default": "Success",
            "description": "Human-readable message",
            "title": "Message",
            "type": "string"
          }
        },
        "title": "ApiResponse",
        "type": "object"
      },
      "AuditEntry": {
        "description": "Audit log entry",
        "properties": {
          "timestamp": {
            "description": "When the action occurred",
            "format": "date-time",
            "title": "Timestamp",
            "type": "string"
          },
          "user": {
            "description": "User who performed the action",
            "title": "User",
            "type": "string"
          },
          "action": {
            "description": "Action type",
            "title": "Action",
            "type": "string"
          },
          "old_value": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Previous value",
            "title": "Old Value"
          },
          "new_value": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "New value",
            "title": "New Value"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Additional notes",
            "title": "Notes"
          }
        },
        "required": [
          "timestamp",
          "user",
          "action"
        ],
        "title": "AuditEntry",
        "type": "object"
      },
      "CustomerRef": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Customer ID"
          },
          "customer_name": {
            "type": "string",
            "description": "Display name"
          }
        },
        "required": [
          "name",
          "customer_name"
        ]
      },
      "DateRangeRequest": {
        "description": "Date range filter parameters",
        "properties": {
          "start_date": {
            "anyOf": [
              {
                "format": "date",
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Start date (inclusive)",
            "title": "Start Date"
          },
          "end_date": {
            "anyOf": [
              {
                "format": "date",
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "End date (inclusive)",
            "title": "End Date"
          }
        },
        "title": "DateRangeRequest",
        "type": "object"
      },
      "DocumentGenerationResponse": {
        "description": "Response for document generation",
        "properties": {
          "success": {
            "default": true,
            "title": "Success",
            "type": "boolean"
          },
          "file_url": {
            "description": "URL to download generated document",
            "title": "File Url",
            "type": "string"
          },
          "file_name": {
            "description": "Generated filename",
            "title": "File Name",
            "type": "string"
          },
          "format": {
            "description": "Document format (pdf, docx, etc.)",
            "title": "Format",
            "type": "string"
          },
          "message": {
            "default": "Document generated successfully",
            "title": "Message",
            "type": "string"
          }
        },
        "required": [
          "file_url",
          "file_name",
          "format"
        ],
        "title": "DocumentGenerationResponse",
        "type": "object"
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "default": false
          },
          "error": {
            "type": "string",
            "description": "Error type"
          },
          "message": {
            "type": "string",
            "description": "Human-readable error message"
          },
          "error_code": {
            "type": "string",
            "description": "Structured error code (e.g., 'VE001')"
          },
          "user_message": {
            "type": "string",
            "description": "User-friendly error message"
          },
          "correlation_id": {
            "type": "string",
            "description": "Error tracking ID for support"
          },
          "details": {
            "type": "object",
            "description": "Additional error details (dev mode only)"
          }
        },
        "required": [
          "success",
          "error",
          "message"
        ]
      },
      "FileInfo": {
        "description": "File metadata",
        "properties": {
          "file_name": {
            "description": "Original filename",
            "title": "File Name",
            "type": "string"
          },
          "file_url": {
            "description": "URL to access the file",
            "title": "File Url",
            "type": "string"
          },
          "file_size": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "File size in bytes",
            "title": "File Size"
          },
          "file_type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "MIME type",
            "title": "File Type"
          }
        },
        "required": [
          "file_name",
          "file_url"
        ],
        "title": "FileInfo",
        "type": "object"
      },
      "ItemRef": {
        "type": "object",
        "properties": {
          "item_code": {
            "type": "string"
          },
          "item_name": {
            "type": "string"
          },
          "uom": {
            "type": "string"
          }
        },
        "required": [
          "item_code",
          "item_name"
        ]
      },
      "LocationFilterRequest": {
        "description": "Location filter parameter",
        "properties": {
          "location": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Warehouse group name for location filtering",
            "title": "Location"
          }
        },
        "title": "LocationFilterRequest",
        "type": "object"
      },
      "LocationRef": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Location ID"
          },
          "title": {
            "type": "string",
            "description": "Display name"
          }
        },
        "required": [
          "name"
        ]
      },
      "PaginatedResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "default": true
          },
          "data": {
            "type": "array",
            "items": {}
          },
          "message": {
            "type": "string"
          },
          "pagination": {
            "$ref": "#/components/schemas/PaginationMeta"
          }
        }
      },
      "PaginationMeta": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer",
            "description": "Total number of items"
          },
          "limit": {
            "type": "integer",
            "description": "Items per page"
          },
          "offset": {
            "type": "integer",
            "description": "Current offset"
          },
          "has_more": {
            "type": "boolean",
            "description": "Whether more items exist"
          }
        },
        "required": [
          "total",
          "limit",
          "offset",
          "has_more"
        ]
      },
      "PaginationRequest": {
        "description": "Standard pagination parameters",
        "properties": {
          "limit": {
            "default": 50,
            "description": "Items per page (max 500)",
            "maximum": 500,
            "minimum": 1,
            "title": "Limit",
            "type": "integer"
          },
          "offset": {
            "default": 0,
            "description": "Number of items to skip",
            "minimum": 0,
            "title": "Offset",
            "type": "integer"
          }
        },
        "title": "PaginationRequest",
        "type": "object"
      },
      "RateLimitResponse": {
        "description": "Response when rate limit is exceeded",
        "properties": {
          "success": {
            "default": false,
            "title": "Success",
            "type": "boolean"
          },
          "error": {
            "default": "Rate Limit Exceeded",
            "title": "Error",
            "type": "string"
          },
          "message": {
            "default": "Too many requests. Please slow down.",
            "title": "Message",
            "type": "string"
          },
          "retry_after": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Seconds until rate limit resets",
            "title": "Retry After"
          }
        },
        "title": "RateLimitResponse",
        "type": "object"
      },
      "SearchRequest": {
        "description": "Search/filter parameters",
        "properties": {
          "search": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Search term",
            "title": "Search"
          },
          "filters": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Additional filters as key-value pairs",
            "title": "Filters"
          }
        },
        "title": "SearchRequest",
        "type": "object"
      },
      "SuccessResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "default": true,
            "description": "Operation success status"
          },
          "data": {
            "description": "Response payload (varies by endpoint)"
          },
          "message": {
            "type": "string",
            "default": "Success",
            "description": "Human-readable message"
          }
        },
        "required": [
          "success"
        ]
      },
      "UserRef": {
        "description": "Reference to a user",
        "properties": {
          "name": {
            "description": "User ID (email)",
            "title": "Name",
            "type": "string"
          },
          "full_name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "default": null,
            "description": "Full name",
            "title": "Full Name"
          }
        },
        "required": [
          "name"
        ],
        "title": "UserRef",
        "type": "object"
      },
      "QCStatus": {
        "type": "string",
        "enum": [
          "Pending",
          "Pass",
          "Fail",
          "Rework",
          "Not Required"
        ]
      },
      "ErrorCodes": {
        "type": "object",
        "description": "Catalog of all error codes",
        "properties": {
          "TIME_ENTRY_FUTURE": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "TE001"
              },
              "message": {
                "type": "string",
                "example": "Time entry cannot be in the future"
              },
              "user_message": {
                "type": "string",
                "example": "You cannot log time for future dates. Please check your start and end times."
              },
              "severity": {
                "type": "string",
                "example": "warning"
              }
            }
          },
          "TIME_ENTRY_DURATION_MISMATCH": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "TE002"
              },
              "message": {
                "type": "string",
                "example": "Duration mismatch: calculated {calculated} mins, provided {provided} mins"
              },
              "user_message": {
                "type": "string",
                "example": "The duration you entered doesn't match the time range. Please verify your start and end times."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "TIME_ENTRY_INVALID_RANGE": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "TE003"
              },
              "message": {
                "type": "string",
                "example": "End time must be after start time"
              },
              "user_message": {
                "type": "string",
                "example": "The end time must be later than the start time. Please correct the time range."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "TIME_ENTRY_OVERLAPPING": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "TE004"
              },
              "message": {
                "type": "string",
                "example": "Time entry overlaps with existing entry"
              },
              "user_message": {
                "type": "string",
                "example": "This time entry overlaps with an existing entry for this job card. Please adjust the time range."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "TIME_ENTRY_JOB_CARD_COMPLETED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "TE005"
              },
              "message": {
                "type": "string",
                "example": "Cannot add time entry to completed job card"
              },
              "user_message": {
                "type": "string",
                "example": "This job card is already completed. Time entries cannot be added."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "JOB_CARD_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "JC001"
              },
              "message": {
                "type": "string",
                "example": "Job card {job_card_id} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The requested job card could not be found. Please verify the job card ID."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "JOB_CARD_INVALID_STATUS": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "JC002"
              },
              "message": {
                "type": "string",
                "example": "Cannot transition from {current_status} to {new_status}"
              },
              "user_message": {
                "type": "string",
                "example": "This status change is not allowed for the current job card state."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "JOB_CARD_ALREADY_STARTED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "JC003"
              },
              "message": {
                "type": "string",
                "example": "Job card is already in progress"
              },
              "user_message": {
                "type": "string",
                "example": "This job card is already started. Please pause or complete it first."
              },
              "severity": {
                "type": "string",
                "example": "warning"
              }
            }
          },
          "JOB_CARD_NOT_STARTED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "JC004"
              },
              "message": {
                "type": "string",
                "example": "Job card has not been started"
              },
              "user_message": {
                "type": "string",
                "example": "This job card needs to be started before it can be paused or completed."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "JOB_CARD_QUANTITY_EXCEEDED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "JC005"
              },
              "message": {
                "type": "string",
                "example": "Completed quantity exceeds target quantity"
              },
              "user_message": {
                "type": "string",
                "example": "The completed quantity cannot exceed the target quantity for this job card."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "SETTINGS_INVALID_EMAIL": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "ST001"
              },
              "message": {
                "type": "string",
                "example": "Invalid email address: {email}"
              },
              "user_message": {
                "type": "string",
                "example": "Please provide a valid email address."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "SETTINGS_INVALID_PORT": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "ST002"
              },
              "message": {
                "type": "string",
                "example": "Invalid port number: {port}"
              },
              "user_message": {
                "type": "string",
                "example": "Port number must be between 1 and 65535."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "SETTINGS_SMTP_CONNECTION_FAILED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "ST003"
              },
              "message": {
                "type": "string",
                "example": "SMTP connection failed: {error}"
              },
              "user_message": {
                "type": "string",
                "example": "Could not connect to SMTP server. Please check your email settings and try again."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "SETTINGS_SMTP_AUTH_FAILED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "ST004"
              },
              "message": {
                "type": "string",
                "example": "SMTP authentication failed"
              },
              "user_message": {
                "type": "string",
                "example": "Email authentication failed. Please check your username and password."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "SETTINGS_MISSING_REQUIRED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "ST005"
              },
              "message": {
                "type": "string",
                "example": "Missing required setting: {field}"
              },
              "user_message": {
                "type": "string",
                "example": "The field '{field}' is required. Please provide a value."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "PERMISSION_DENIED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "PE001"
              },
              "message": {
                "type": "string",
                "example": "User {user} does not have permission for {action}"
              },
              "user_message": {
                "type": "string",
                "example": "You do not have permission to perform this action. Please contact your administrator."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "PERMISSION_ROLE_REQUIRED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "PE002"
              },
              "message": {
                "type": "string",
                "example": "Required role: {role}"
              },
              "user_message": {
                "type": "string",
                "example": "This action requires the '{role}' role. Please contact your administrator."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "VALIDATION_REQUIRED_FIELD": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "VE001"
              },
              "message": {
                "type": "string",
                "example": "Required field missing: {field}"
              },
              "user_message": {
                "type": "string",
                "example": "The field '{field}' is required. Please provide a value."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "VALIDATION_INVALID_FORMAT": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "VE002"
              },
              "message": {
                "type": "string",
                "example": "Invalid format for {field}"
              },
              "user_message": {
                "type": "string",
                "example": "The format of '{field}' is invalid. Please check the expected format."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "VALIDATION_OUT_OF_RANGE": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "VE003"
              },
              "message": {
                "type": "string",
                "example": "{field} must be between {min} and {max}"
              },
              "user_message": {
                "type": "string",
                "example": "The value of '{field}' is out of range. It must be between {min} and {max}."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "VALIDATION_INVALID_OPTION": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "VE004"
              },
              "message": {
                "type": "string",
                "example": "Invalid option for {field}: {value}"
              },
              "user_message": {
                "type": "string",
                "example": "'{value}' is not a valid option for '{field}'."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "TRANSACTION_ROLLBACK": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "TX001"
              },
              "message": {
                "type": "string",
                "example": "Transaction rolled back: {error}"
              },
              "user_message": {
                "type": "string",
                "example": "The operation could not be completed and has been rolled back. Please try again."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "TRANSACTION_FAILED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "TX002"
              },
              "message": {
                "type": "string",
                "example": "Transaction failed: {error}"
              },
              "user_message": {
                "type": "string",
                "example": "The operation failed. Please try again or contact support."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "SYSTEM_UNKNOWN_ERROR": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "SY001"
              },
              "message": {
                "type": "string",
                "example": "Unknown error occurred: {error}"
              },
              "user_message": {
                "type": "string",
                "example": "An unexpected error occurred. Please try again or contact support."
              },
              "severity": {
                "type": "string",
                "example": "critical"
              }
            }
          },
          "SYSTEM_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "SY002"
              },
              "message": {
                "type": "string",
                "example": "{resource} not found: {identifier}"
              },
              "user_message": {
                "type": "string",
                "example": "The requested {resource} could not be found."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "CREDIT_LIMIT_EXCEEDED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "CR001"
              },
              "message": {
                "type": "string",
                "example": "Order exceeds credit limit for customer {customer}"
              },
              "user_message": {
                "type": "string",
                "example": "This order would exceed the customer's credit limit. Contact administrator for approval."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "CREDIT_LIMIT_ADMIN_OVERRIDE": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "CR002"
              },
              "message": {
                "type": "string",
                "example": "Admin override for credit limit - customer {customer}"
              },
              "user_message": {
                "type": "string",
                "example": "Order approved with admin credit limit override."
              },
              "severity": {
                "type": "string",
                "example": "info"
              }
            }
          },
          "COD_DEPOSIT_REQUIRED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "CR003"
              },
              "message": {
                "type": "string",
                "example": "COD deposit required: {amount} not available"
              },
              "user_message": {
                "type": "string",
                "example": "This customer requires a 50% deposit for COD orders. Please record advance payment before submitting."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "PAYMENT_TERMS_NOT_SET": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "CR004"
              },
              "message": {
                "type": "string",
                "example": "Payment terms not set for customer {customer}"
              },
              "user_message": {
                "type": "string",
                "example": "Customer has no payment terms configured. Please set payment terms."
              },
              "severity": {
                "type": "string",
                "example": "warning"
              }
            }
          },
          "CUSTOMER_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "CR005"
              },
              "message": {
                "type": "string",
                "example": "Customer not found: {customer}"
              },
              "user_message": {
                "type": "string",
                "example": "The specified customer could not be found. Please verify the customer ID."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "QUOTE_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "QT001"
              },
              "message": {
                "type": "string",
                "example": "Quotation not found: {quote_id}"
              },
              "user_message": {
                "type": "string",
                "example": "The specified quotation could not be found. Please verify the quotation ID."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "QUOTE_VERSION_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "QT002"
              },
              "message": {
                "type": "string",
                "example": "Version {version} not found for quotation {quote_id}"
              },
              "user_message": {
                "type": "string",
                "example": "The requested version does not exist for this quotation."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "QUOTE_VERSION_CORRUPT": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "QT003"
              },
              "message": {
                "type": "string",
                "example": "Version {version} data is corrupted for quotation {quote_id}"
              },
              "user_message": {
                "type": "string",
                "example": "This version's data appears to be corrupted. Please contact support."
              },
              "severity": {
                "type": "string",
                "example": "critical"
              }
            }
          },
          "QUOTE_ALREADY_SUBMITTED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "QT004"
              },
              "message": {
                "type": "string",
                "example": "Quotation {quote_id} is not in draft status"
              },
              "user_message": {
                "type": "string",
                "example": "This quotation has already been submitted and cannot be modified. Please amend it to create a new version."
              },
              "severity": {
                "type": "string",
                "example": "warning"
              }
            }
          },
          "QUOTE_NO_ITEMS": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "QT005"
              },
              "message": {
                "type": "string",
                "example": "Quotation {quote_id} has no line items"
              },
              "user_message": {
                "type": "string",
                "example": "Please add at least one item before submitting this quotation."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "LEAD_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "LD001"
              },
              "message": {
                "type": "string",
                "example": "Lead not found: {lead}"
              },
              "user_message": {
                "type": "string",
                "example": "The specified lead could not be found. Please verify the lead ID."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "CONTACT_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "LD005"
              },
              "message": {
                "type": "string",
                "example": "Contact not found: {contact}"
              },
              "user_message": {
                "type": "string",
                "example": "The specified contact could not be found. Please verify the contact ID."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "LEAD_REQUIRED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "LD002"
              },
              "message": {
                "type": "string",
                "example": "Lead ID is required when quotation_to is 'Lead'"
              },
              "user_message": {
                "type": "string",
                "example": "Please select a lead for this quotation."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "CUSTOMER_REQUIRED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "LD003"
              },
              "message": {
                "type": "string",
                "example": "Customer ID is required when quotation_to is 'Customer'"
              },
              "user_message": {
                "type": "string",
                "example": "Please select a customer for this quotation."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "INVALID_PARTY_TYPE": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "LD004"
              },
              "message": {
                "type": "string",
                "example": "Invalid quotation_to value: {party_type}. Must be 'Customer' or 'Lead'"
              },
              "user_message": {
                "type": "string",
                "example": "Please select either Customer or Lead for this quotation."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "WORK_ORDER_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "WO001"
              },
              "message": {
                "type": "string",
                "example": "Work order {work_order_id} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The requested work order could not be found. Please verify the work order ID."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "WORK_ORDER_INVALID_STATUS": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "WO002"
              },
              "message": {
                "type": "string",
                "example": "Work order {work_order_id} is in invalid status: {status}"
              },
              "user_message": {
                "type": "string",
                "example": "This work order cannot be modified in its current status."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "WORK_ORDER_ALREADY_COMPLETED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "WO003"
              },
              "message": {
                "type": "string",
                "example": "Work order {work_order_id} is already completed"
              },
              "user_message": {
                "type": "string",
                "example": "This work order has already been completed. No further modifications allowed."
              },
              "severity": {
                "type": "string",
                "example": "warning"
              }
            }
          },
          "WORK_ORDER_NO_BOM": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "WO004"
              },
              "message": {
                "type": "string",
                "example": "Work order {work_order_id} has no BOM"
              },
              "user_message": {
                "type": "string",
                "example": "This work order requires a BOM before proceeding."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "BATCH_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "BA001"
              },
              "message": {
                "type": "string",
                "example": "Batch {batch_id} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The specified batch could not be found. Please verify the batch ID."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "BATCH_INSUFFICIENT_STOCK": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "BA002"
              },
              "message": {
                "type": "string",
                "example": "Batch {batch_id} has insufficient stock. Available: {available}, Required: {required}"
              },
              "user_message": {
                "type": "string",
                "example": "Insufficient stock in this batch. Please use a different batch or adjust quantity."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "BATCH_WRONG_ITEM": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "BA003"
              },
              "message": {
                "type": "string",
                "example": "Batch {batch_id} belongs to item {expected_item}, not {actual_item}"
              },
              "user_message": {
                "type": "string",
                "example": "This batch is for a different item. Please select the correct batch."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "INSUFFICIENT_STOCK": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "MA001"
              },
              "message": {
                "type": "string",
                "example": "Insufficient stock for item {item_code}. Available: {available}, Required: {required}"
              },
              "user_message": {
                "type": "string",
                "example": "Not enough stock available for this item. Please check inventory or use a different batch."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "WAREHOUSE_MISMATCH": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "MA002"
              },
              "message": {
                "type": "string",
                "example": "Warehouse {warehouse} does not match work order location"
              },
              "user_message": {
                "type": "string",
                "example": "This warehouse is at a different location than the work order. Please select a warehouse at the same location."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "MATERIAL_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "MA003"
              },
              "message": {
                "type": "string",
                "example": "Material {item_code} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The specified material could not be found. Please verify the item code."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "WAREHOUSE_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "MA004"
              },
              "message": {
                "type": "string",
                "example": "Warehouse {warehouse} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The specified warehouse could not be found. Please verify the warehouse name."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "ITEM_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "MA005"
              },
              "message": {
                "type": "string",
                "example": "Item {item_code} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The specified item could not be found. Please verify the item code."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "NO_WIP_WAREHOUSE": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "MA006"
              },
              "message": {
                "type": "string",
                "example": "Work order {work_order_id} has no WIP warehouse configured"
              },
              "user_message": {
                "type": "string",
                "example": "This work order requires a WIP warehouse to be configured before materials can be managed."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "MATERIAL_OPERATION_MISMATCH": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "MA007"
              },
              "message": {
                "type": "string",
                "example": "Material {item_code} is not linked to operation {operation}"
              },
              "user_message": {
                "type": "string",
                "example": "This material is not used in the specified operation. Please select a different material."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "OVERRIDE_REQUEST_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "OR001"
              },
              "message": {
                "type": "string",
                "example": "Override request {override_id} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The specified override request could not be found."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "OVERRIDE_ALREADY_APPROVED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "OR002"
              },
              "message": {
                "type": "string",
                "example": "Override request {override_id} has already been approved"
              },
              "user_message": {
                "type": "string",
                "example": "This override request has already been approved."
              },
              "severity": {
                "type": "string",
                "example": "info"
              }
            }
          },
          "OVERRIDE_ALREADY_REJECTED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "OR003"
              },
              "message": {
                "type": "string",
                "example": "Override request {override_id} has already been rejected"
              },
              "user_message": {
                "type": "string",
                "example": "This override request has already been rejected."
              },
              "severity": {
                "type": "string",
                "example": "info"
              }
            }
          },
          "OVERRIDE_ALREADY_PENDING": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "OR004"
              },
              "message": {
                "type": "string",
                "example": "Override request {override_id} is still pending review"
              },
              "user_message": {
                "type": "string",
                "example": "This override request is still pending approval."
              },
              "severity": {
                "type": "string",
                "example": "warning"
              }
            }
          },
          "INSUFFICIENT_OVERRIDE_QTY": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "OR005"
              },
              "message": {
                "type": "string",
                "example": "Cannot approve override: Insufficient quantity available. Required: {required}, Available: {available}"
              },
              "user_message": {
                "type": "string",
                "example": "Not enough stock available to approve this override. Please check inventory."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "STOCK_ENTRY_FAILED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "SE001"
              },
              "message": {
                "type": "string",
                "example": "Failed to create stock entry: {error}"
              },
              "user_message": {
                "type": "string",
                "example": "Could not record stock entry. Please try again."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "STOCK_TRANSFER_FAILED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "SE002"
              },
              "message": {
                "type": "string",
                "example": "Failed to transfer stock: {error}"
              },
              "user_message": {
                "type": "string",
                "example": "Could not transfer stock. Please try again."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "BOM_TEMPLATE_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "BT001"
              },
              "message": {
                "type": "string",
                "example": "BOM template {template_id} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The specified BOM template could not be found."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "BOM_TEMPLATE_INACTIVE": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "BT002"
              },
              "message": {
                "type": "string",
                "example": "BOM template {template_id} is inactive"
              },
              "user_message": {
                "type": "string",
                "example": "This BOM template is inactive. Please activate it before using."
              },
              "severity": {
                "type": "string",
                "example": "warning"
              }
            }
          },
          "BOM_TEMPLATE_NO_OPERATIONS": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "BT003"
              },
              "message": {
                "type": "string",
                "example": "BOM template {template_id} has no operations"
              },
              "user_message": {
                "type": "string",
                "example": "This BOM template has no operations defined. Please add operations."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "INVALID_BOM_ATTACHMENT": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "BT004"
              },
              "message": {
                "type": "string",
                "example": "Invalid BOM attachment: {error}"
              },
              "user_message": {
                "type": "string",
                "example": "Could not upload attachment. Please check the file format."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "OPERATION_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "OP001"
              },
              "message": {
                "type": "string",
                "example": "Operation {operation} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The specified operation could not be found."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "USER_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "US001"
              },
              "message": {
                "type": "string",
                "example": "User {user} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The specified user could not be found. Please verify the user ID."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "USER_ALREADY_EXISTS": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "US002"
              },
              "message": {
                "type": "string",
                "example": "User {email} already exists"
              },
              "user_message": {
                "type": "string",
                "example": "A user with this email already exists."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "USER_ALREADY_ACTIVE": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "US003"
              },
              "message": {
                "type": "string",
                "example": "User {user} is already active"
              },
              "user_message": {
                "type": "string",
                "example": "This user is already active."
              },
              "severity": {
                "type": "string",
                "example": "warning"
              }
            }
          },
          "USER_ALREADY_DEACTIVATED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "US004"
              },
              "message": {
                "type": "string",
                "example": "User {user} is already deactivated"
              },
              "user_message": {
                "type": "string",
                "example": "This user is already deactivated."
              },
              "severity": {
                "type": "string",
                "example": "warning"
              }
            }
          },
          "ROLE_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "US005"
              },
              "message": {
                "type": "string",
                "example": "Role {role} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The specified role could not be found."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "CANNOT_MODIFY_SELF": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "US006"
              },
              "message": {
                "type": "string",
                "example": "Cannot modify your own user account"
              },
              "user_message": {
                "type": "string",
                "example": "You cannot modify your own user account."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "PROTECTED_ACCOUNT": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "US007"
              },
              "message": {
                "type": "string",
                "example": "Cannot {action} protected account {user}"
              },
              "user_message": {
                "type": "string",
                "example": "This action is not allowed on this protected account."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "SCENARIO_USER_SEED_DISABLED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "US008"
              },
              "message": {
                "type": "string",
                "example": "Scenario user seeding is disabled for this site"
              },
              "user_message": {
                "type": "string",
                "example": "Scenario user seeding is disabled for this site. Enable developer_mode or set allow_scenario_user_seed in site_config.json."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "EMPLOYEE_NOT_FOUND": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "EM001"
              },
              "message": {
                "type": "string",
                "example": "Employee {employee} not found"
              },
              "user_message": {
                "type": "string",
                "example": "The specified employee could not be found."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "EMPLOYEE_ALREADY_LINKED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "EM002"
              },
              "message": {
                "type": "string",
                "example": "Employee already linked to user {user}"
              },
              "user_message": {
                "type": "string",
                "example": "This employee is already linked to another user."
              },
              "severity": {
                "type": "string",
                "example": "warning"
              }
            }
          },
          "EMPLOYEE_REQUIRED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "EM003"
              },
              "message": {
                "type": "string",
                "example": "Employee profile is required for role {role}"
              },
              "user_message": {
                "type": "string",
                "example": "An employee profile is required for this role."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "SETTINGS_SAVE_FAILED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "ST006"
              },
              "message": {
                "type": "string",
                "example": "Failed to save settings: {error}"
              },
              "user_message": {
                "type": "string",
                "example": "Could not save settings. Please try again."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          },
          "SETTINGS_LOAD_FAILED": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "ST007"
              },
              "message": {
                "type": "string",
                "example": "Failed to load settings: {error}"
              },
              "user_message": {
                "type": "string",
                "example": "Could not load settings. Please refresh the page."
              },
              "severity": {
                "type": "string",
                "example": "error"
              }
            }
          }
        }
      }
    },
    "responses": {
      "Success": {
        "description": "Successful operation",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/SuccessResponse"
            }
          }
        }
      },
      "BadRequest": {
        "description": "Validation error or bad request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "error": "Validation Error",
              "message": "Missing required parameter: quotation_id",
              "error_code": "VE001"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Authentication required",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "error": "Unauthorized",
              "message": "Please login to continue"
            }
          }
        }
      },
      "Forbidden": {
        "description": "Permission denied",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "error": "Permission Denied",
              "message": "You do not have permission to perform this action",
              "error_code": "PE001"
            }
          }
        }
      },
      "NotFound": {
        "description": "Resource not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "error": "Not Found",
              "message": "The requested resource was not found",
              "error_code": "SY002"
            }
          }
        }
      },
      "RateLimited": {
        "description": "Rate limit exceeded",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "error": "Rate Limit Exceeded",
              "message": "Too many requests. Please slow down.",
              "retry_after": 60
            }
          }
        }
      },
      "ServerError": {
        "description": "Internal server error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "success": false,
              "error": "Internal Server Error",
              "message": "An unexpected error occurred",
              "correlation_id": "abc123"
            }
          }
        }
      }
    },
    "parameters": {
      "LocationParam": {
        "name": "location",
        "in": "query",
        "description": "Warehouse group name for location filtering",
        "schema": {
          "type": "string"
        },
        "example": "Maple Ridge - PB"
      },
      "LimitParam": {
        "name": "limit",
        "in": "query",
        "description": "Maximum items to return (max 500)",
        "schema": {
          "type": "integer",
          "default": 50,
          "maximum": 500
        }
      },
      "OffsetParam": {
        "name": "offset",
        "in": "query",
        "description": "Number of items to skip",
        "schema": {
          "type": "integer",
          "default": 0,
          "minimum": 0
        }
      },
      "SearchParam": {
        "name": "search",
        "in": "query",
        "description": "Search term",
        "schema": {
          "type": "string"
        }
      },
      "StartDateParam": {
        "name": "start_date",
        "in": "query",
        "description": "Filter by start date (YYYY-MM-DD)",
        "schema": {
          "type": "string",
          "format": "date"
        }
      },
      "EndDateParam": {
        "name": "end_date",
        "in": "query",
        "description": "Filter by end date (YYYY-MM-DD)",
        "schema": {
          "type": "string",
          "format": "date"
        }
      }
    }
  },
  "tags": [
    {
      "name": "Admin",
      "description": "System administration and reporting endpoints"
    },
    {
      "name": "Auth",
      "description": "Authentication endpoints"
    },
    {
      "name": "Carbone",
      "description": "Document generation endpoints"
    },
    {
      "name": "Customers",
      "description": "Customer management endpoints"
    },
    {
      "name": "Estimator",
      "description": "Quotation and lead management endpoints"
    },
    {
      "name": "Foreman",
      "description": "Work order and material management endpoints"
    },
    {
      "name": "Freight",
      "description": "Freight zone management endpoints"
    },
    {
      "name": "Health",
      "description": "System health check endpoints"
    },
    {
      "name": "Inventory",
      "description": "Inventory management endpoints"
    },
    {
      "name": "Material Config",
      "description": "Material configuration endpoints"
    },
    {
      "name": "Quality",
      "description": "QC checkpoint management endpoints"
    },
    {
      "name": "Routing",
      "description": "Operations and routing management endpoints"
    },
    {
      "name": "Sales Order",
      "description": "Sales order workflow endpoints"
    },
    {
      "name": "Settings",
      "description": "System settings management endpoints"
    },
    {
      "name": "Shop Floor",
      "description": "Job card and material tracking endpoints"
    },
    {
      "name": "Shop Floor Mobile",
      "description": "Mobile QR scanning endpoints"
    },
    {
      "name": "Tax Fee",
      "description": "Tax and fee configuration endpoints"
    },
    {
      "name": "Users",
      "description": "User management endpoints"
    },
    {
      "name": "Workstation",
      "description": "Workstation management endpoints"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    },
    {
      "SessionAuth": []
    }
  ]
}